From 93e8a0315acb0f7ee637204b460eba12f1f65d58 Mon Sep 17 00:00:00 2001
From: Vitaly Ustinov <vitaly.ustinov@tsimagine.com>
Date: Mon, 7 Nov 2022 16:01:09 -0500
Subject: [PATCH] Fix importing from Sybase schema (float fields)

Related issue: tds-fdw#321
---
 src/tds_fdw.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/tds_fdw.c b/src/tds_fdw.c
index c4623ae..f642141 100644
--- a/src/tds_fdw.c
+++ b/src/tds_fdw.c
@@ -3256,7 +3256,10 @@ tdsImportSqlServerSchema(ImportForeignSchemaStmt *stmt, DBPROCESS  *dbproc,
 
 					/* Floating-point types */
 					else if (strcmp(data_type, "float") == 0)
-						appendStringInfo(&buf, " float(%d)", numeric_precision);
+						if (numeric_precision == 0)
+							appendStringInfoString(&buf, " float");
+						else
+							appendStringInfo(&buf, " float(%d)", numeric_precision);
 					else if (strcmp(data_type, "real") == 0)
 						appendStringInfoString(&buf, " real");
 
@@ -3638,7 +3641,10 @@ tdsImportSybaseSchema(ImportForeignSchemaStmt *stmt, DBPROCESS  *dbproc,
 
 					/* Floating-point types */
 					else if (strcmp(data_type, "float") == 0)
-						appendStringInfo(&buf, " float(%d)", numeric_precision);
+						if (numeric_precision == 0)
+							appendStringInfoString(&buf, " float");
+						else
+							appendStringInfo(&buf, " float(%d)", numeric_precision);
 					else if (strcmp(data_type, "real") == 0)
 						appendStringInfoString(&buf, " real");
 
