Skip to content

Commit

Permalink
additional condition to handle other datatype typmod if common type i…
Browse files Browse the repository at this point in the history
…s numeric

Signed-off-by: yashneet vinayak <[email protected]>
  • Loading branch information
yashneet vinayak committed Dec 31, 2024
1 parent 729d5ab commit ff800be
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 22 deletions.
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/src/pltsql_coerce.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions test/JDBC/expected/BABEL-CASE_EXPR-before-16_6-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14308,9 +14308,9 @@ ORDER BY value;
GO
~~START~~
numeric
1.2300000000
4.5600000000
7.8900000000
1.23
4.56
7.89
~~END~~


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/JDBC/input/BABEL-CASE_EXPR-before-16_6-vu-verify.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/JDBC/input/BABEL-CASE_EXPR-vu-verify.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff800be

Please sign in to comment.