From ff800be8ad5613b17403dea9924da7e8ba03c62f Mon Sep 17 00:00:00 2001 From: yashneet vinayak Date: Tue, 31 Dec 2024 08:36:55 +0000 Subject: [PATCH] additional condition to handle other datatype typmod if common type is numeric Signed-off-by: yashneet vinayak --- contrib/babelfishpg_tsql/src/pltsql_coerce.c | 2 +- .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out | 9 ++++++--- .../expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out | 9 ++++++--- test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out | 9 ++++++--- .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out | 9 ++++++--- .../BABEL-CASE_EXPR-before-16_6-vu-verify.out | 3 +++ .../chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out | 3 +++ .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out | 10 +++++++--- .../BABEL-CASE_EXPR-before-16_6-vu-verify.out | 9 ++++++--- .../japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out | 9 ++++++--- .../BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql | 3 +++ .../input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql | 3 +++ test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql | 3 +++ 13 files changed, 59 insertions(+), 22 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index ae0c385dbc..1143585d96 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -2053,7 +2053,7 @@ tsql_select_common_typmod_hook(ParseState *pstate, List *exprs, Oid common_type) if (typmod == -1 && (*pltsql_protocol_plugin_ptr)) typmod = (*pltsql_protocol_plugin_ptr)->get_numeric_typmod_from_exp(NULL, expr); - if (typmod == -1) + if (typmod == -1 || getBaseType(type) != NUMERICOID) continue; scale = (typmod - VARHDRSZ) & 0xffff; diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index a1a79f9a1c..f7461d45cb 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out index f85efb051f..8f0dcf72a0 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index ae0a77cbd5..b80f9636f6 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index 06b7b69ef4..1256aaff92 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out index ab188adc9c..98adc276c7 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out index e0fd761eec..438ed2af19 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index f37829d961..1a19bc2ae4 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,10 @@ numeric ~~END~~ + +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out index f37829d961..483f41ccf1 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_6-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out index 8586b965a2..3e9886842b 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -14308,9 +14308,9 @@ ORDER BY value; GO ~~START~~ numeric -1.2300000000 -4.5600000000 -7.8900000000 +1.23 +4.56 +7.89 ~~END~~ @@ -14365,6 +14365,9 @@ numeric ~~END~~ +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql index 679f4b562a..acb969d183 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.sql @@ -8199,6 +8199,9 @@ SELECT CAST(4.56 AS NUMERIC(5,2)) ORDER BY value; GO +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql index 395d2b4d1e..dd6a93a901 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql @@ -8200,6 +8200,9 @@ SELECT CAST(4.56 AS NUMERIC(5,2)) ORDER BY value; GO +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL diff --git a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql index 395d2b4d1e..dd6a93a901 100644 --- a/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql +++ b/test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql @@ -8200,6 +8200,9 @@ SELECT CAST(4.56 AS NUMERIC(5,2)) ORDER BY value; GO +-- TODO FIX: While calculating for money and smallmoney +-- babelfish is calculating it same as numeric logic +-- which is different from TSQL. -- Test Case 81: UNION with MONEY type SELECT CAST(1.23 AS DECIMAL(10,2)) AS value UNION ALL