Skip to content

Commit

Permalink
Updated sys.tsql_type_radix_for_sp_columns_helper function to return …
Browse files Browse the repository at this point in the history
…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 [email protected]
  • Loading branch information
basasairohan authored and Jason Teng committed Nov 29, 2023
1 parent c75f1a0 commit a8e6b3c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions contrib/babelfishpg_tsql/sql/babelfishpg_tsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/expected/sp_columns_100.out
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ 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#!#<NULL>#!#<NULL>#!#-5#!#<NULL>#!#<NULL>#!#1#!#NO#!#0#!#0#!#0#!#1#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#63
master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!#<NULL>#!#1#!#<NULL>#!#<NULL>#!#3#!#<NULL>#!#<NULL>#!#2#!#YES#!#0#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#106
master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!#10#!#1#!#<NULL>#!#<NULL>#!#3#!#<NULL>#!#<NULL>#!#2#!#YES#!#0#!#0#!#0#!#0#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#<NULL>#!#106
~~END~~

exec [sys].sp_columns N'decimal_int_identity',N'dbo',NULL,NULL,@ODBCVer=3,@fUsePattern=1;
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#!#<NULL>#!#<NULL>#!#-5#!#<NULL>#!#<NULL>#!#1#!#NO#!#63
master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!#<NULL>#!#1#!#<NULL>#!#<NULL>#!#3#!#<NULL>#!#<NULL>#!#2#!#YES#!#106
master#!#dbo#!#decimal_int_identity#!#dec5int_col#!#3#!#decimal#!#5#!#7#!#0#!#10#!#1#!#<NULL>#!#<NULL>#!#3#!#<NULL>#!#<NULL>#!#2#!#YES#!#106
~~END~~


Expand Down

0 comments on commit a8e6b3c

Please sign in to comment.