From a8e6b3ce68908d5a012e0cd4c149cdd4cf3c746d Mon Sep 17 00:00:00 2001 From: Sai Rohan Basa <108261379+basasairohan@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:47:26 +0530 Subject: [PATCH] Updated sys.tsql_type_radix_for_sp_columns_helper function to return RADIX 10 for decimal datatype (#2077) Currently, sp_columns and sp_columns_100 returns RADIX NULL for decimal datatype. This changes fixes it to return RADIX 10 for decimal datatype Issues Resolved BABEL-4588 Signed-off-by: Sai Rohan Basa bsrohan@amazon.com --- .../babelfishpg_tsql/sql/babelfishpg_tsql.sql | 1 + .../babelfishpg_tsql--3.3.0--3.4.0.sql | 19 +++++++++++++++++++ test/JDBC/expected/sp_columns_100.out | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql b/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql index f9f413e970..76ce519b30 100644 --- a/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql +++ b/contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql @@ -235,6 +235,7 @@ BEGIN WHEN 'money' THEN radix = 10; WHEN 'smallmoney' THEN radix = 10; WHEN 'sql_variant' THEN radix = 10; + WHEN 'decimal' THEN radix = 10; ELSE radix = NULL; END CASE; diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql index 2a70b44c35..e5e5f65640 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql @@ -4489,6 +4489,25 @@ RETURNS INT AS STRICT LANGUAGE C IMMUTABLE PARALLEL SAFE; +CREATE OR REPLACE FUNCTION sys.tsql_type_radix_for_sp_columns_helper(IN type TEXT) +RETURNS SMALLINT +AS $$ +DECLARE + radix SMALLINT; +BEGIN + CASE type + WHEN 'tinyint' THEN radix = 10; + WHEN 'money' THEN radix = 10; + WHEN 'smallmoney' THEN radix = 10; + WHEN 'sql_variant' THEN radix = 10; + WHEN 'decimal' THEN radix = 10; + ELSE + radix = NULL; + END CASE; + RETURN radix; +END; +$$ LANGUAGE plpgsql IMMUTABLE STRICT; + -- Drops the temporary procedure used by the upgrade script. -- Please have this be one of the last statements executed in this upgrade script. DROP PROCEDURE sys.babelfish_drop_deprecated_object(varchar, varchar, varchar); diff --git a/test/JDBC/expected/sp_columns_100.out b/test/JDBC/expected/sp_columns_100.out index f475f268fa..3996f98d25 100644 --- a/test/JDBC/expected/sp_columns_100.out +++ b/test/JDBC/expected/sp_columns_100.out @@ -291,7 +291,7 @@ go ~~START~~ varchar#!#varchar#!#varchar#!#varchar#!#smallint#!#varchar#!#int#!#int#!#smallint#!#smallint#!#smallint#!#varchar#!#nvarchar#!#smallint#!#smallint#!#int#!#int#!#varchar#!#smallint#!#smallint#!#smallint#!#smallint#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#int master#!#dbo#!#decimal_int_identity#!#i_col#!#-5#!#bigint#!#19#!#8#!#0#!#10#!#0#!##!##!#-5#!##!##!#1#!#NO#!#0#!#0#!#0#!#1#!##!##!##!##!##!##!#63 -master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!##!#1#!##!##!#3#!##!##!#2#!#YES#!#0#!#0#!#0#!#0#!##!##!##!##!##!##!#106 +master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!#10#!#1#!##!##!#3#!##!##!#2#!#YES#!#0#!#0#!#0#!#0#!##!##!##!##!##!##!#106 ~~END~~ exec [sys].sp_columns N'decimal_int_identity',N'dbo',NULL,NULL,@ODBCVer=3,@fUsePattern=1; @@ -299,7 +299,7 @@ go ~~START~~ varchar#!#varchar#!#varchar#!#varchar#!#smallint#!#varchar#!#int#!#int#!#smallint#!#smallint#!#smallint#!#varchar#!#nvarchar#!#smallint#!#smallint#!#int#!#int#!#varchar#!#int master#!#dbo#!#decimal_int_identity#!#i_col#!#-5#!#bigint#!#19#!#8#!#0#!#10#!#0#!##!##!#-5#!##!##!#1#!#NO#!#63 -master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!##!#1#!##!##!#3#!##!##!#2#!#YES#!#106 +master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!#10#!#1#!##!##!#3#!##!##!#2#!#YES#!#106 ~~END~~