diff --git a/contrib/babelfishpg_common/src/varchar.c b/contrib/babelfishpg_common/src/varchar.c index 787550a558b..9dab5ce0a62 100644 --- a/contrib/babelfishpg_common/src/varchar.c +++ b/contrib/babelfishpg_common/src/varchar.c @@ -921,7 +921,10 @@ varchar2numeric(PG_FUNCTION_ARGS) char *str; str = varchar2cstring(source); - result = DatumGetNumeric(DirectFunctionCall1(numeric_in, CStringGetDatum(str))); + result = DatumGetNumeric(DirectFunctionCall3(numeric_in, + CStringGetDatum(str), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); pfree(str); PG_RETURN_NUMERIC(result); } diff --git a/test/JDBC/expected/BABEL-5129-vu-cleanup.out b/test/JDBC/expected/BABEL-5129-vu-cleanup.out new file mode 100644 index 00000000000..cee389b28f9 --- /dev/null +++ b/test/JDBC/expected/BABEL-5129-vu-cleanup.out @@ -0,0 +1,2 @@ +DROP TABLE babel_5129 +GO diff --git a/test/JDBC/expected/BABEL-5129-vu-prepare.out b/test/JDBC/expected/BABEL-5129-vu-prepare.out new file mode 100644 index 00000000000..b77dbc007b0 --- /dev/null +++ b/test/JDBC/expected/BABEL-5129-vu-prepare.out @@ -0,0 +1,28 @@ + +-- Tests for ISNUMERIC function with varchar and nvarchar variables +CREATE TABLE babel_5129 ( + int_type int, + numeric_type numeric(10,5), + money_type money, + varchar_type varchar(20), + nvarchar_type nvarchar(20) +) +GO + +INSERT INTO babel_5129 ( + int_type, + numeric_type, + money_type, + varchar_type, + nvarchar_type +) +VALUES ( + 45000, + 12345.12, + 237891.22, + '12.3420000000', + '12.3420000000' +) +GO +~~ROW COUNT: 1~~ + diff --git a/test/JDBC/expected/BABEL-5129-vu-verify.out b/test/JDBC/expected/BABEL-5129-vu-verify.out new file mode 100644 index 00000000000..41a860d252e --- /dev/null +++ b/test/JDBC/expected/BABEL-5129-vu-verify.out @@ -0,0 +1,217 @@ + +-- Tests for ISNUMERIC function with varchar and nvarchar variables +SELECT * FROM babel_5129 +GO +~~START~~ +int#!#numeric#!#money#!#varchar#!#nvarchar +45000#!#12345.12000#!#237891.2200#!#12.3420000000#!#12.3420000000 +~~END~~ + +-- Test int +SELECT ISNUMERIC(int_type) +FROM babel_5129 +GO +~~START~~ +int +1 +~~END~~ + +-- Test numeric +SELECT ISNUMERIC(numeric_type) +FROM babel_5129 +GO +~~START~~ +int +1 +~~END~~ + +-- Test money +SELECT ISNUMERIC(money_type) +FROM babel_5129 +GO +~~START~~ +int +1 +~~END~~ + +-- Test varchar +SELECT ISNUMERIC(varchar_type) +FROM babel_5129 +GO +~~START~~ +int +1 +~~END~~ + +-- Test nvarchar +SELECT ISNUMERIC(nvarchar_type) +FROM babel_5129 +GO +~~START~~ +int +1 +~~END~~ + + +-- Test numeric variable +DECLARE @a numeric(24,6); +SELECT @a = 12.3420000000; +SELECT ISNUMERIC(@a), LEN(@a), DATALENGTH(@a) +GO +~~START~~ +int#!#int#!#int +1#!#9#!#6 +~~END~~ + + +-- Test varchar variable +DECLARE @v varchar(20); +SELECT @v = '12.3420000000'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +1#!#13#!#13 +~~END~~ + + +-- Test nvarchar variable +DECLARE @nv nvarchar(10); +SELECT @nv = '12.3420000000'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +1#!#10#!#10 +~~END~~ + + +-- Test NULL varchar variable +DECLARE @v varchar(20); +SELECT @v = NULL; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +0#!##!# +~~END~~ + + +-- Test NULL nvarchar variable +DECLARE @nv nvarchar(10); +SELECT @nv = null; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +0#!##!# +~~END~~ + + +-- Test empty varchar variable +DECLARE @v varchar(20); +SELECT @v = ''; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +0#!#0#!#0 +~~END~~ + + +-- Test empty nvarchar variable +DECLARE @nv nvarchar(10); +SELECT @nv = ''; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +0#!#0#!#0 +~~END~~ + + +-- Test varchar with number argument that exceeds range of bigint. +DECLARE @v varchar(20); +SELECT @v = '9223372036854775807'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +1#!#19#!#19 +~~END~~ + + +DECLARE @v varchar(20); +SELECT @v = '-9223372036854775808'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +1#!#20#!#20 +~~END~~ + + +-- Test nvarchar with number argument that exceeds range of bigint. +DECLARE @nv nvarchar(20); +SELECT @nv = '9223372036854775807'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +1#!#19#!#19 +~~END~~ + + +DECLARE @nv nvarchar(20); +SELECT @nv = '-9223372036854775808'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +1#!#20#!#20 +~~END~~ + + +-- Test varchar with lengthy numeric value +DECLARE @v varchar; +SELECT @v = '12345678901234567890123456789012345'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +1#!#1#!#1 +~~END~~ + + +-- Test nvarchar with lengthy numeric value +DECLARE @nv nvarchar; +SELECT @nv = '12345678901234567890123456789012345'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +1#!#1#!#1 +~~END~~ + + +-- Test varchar variable with invalid numeric +DECLARE @v varchar(20); +SELECT @v = '12.34.20000000'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO +~~START~~ +int#!#int#!#int +0#!#14#!#14 +~~END~~ + + +-- Test nvarchar variable with invalid numeric +DECLARE @nv nvarchar(10); +SELECT @nv = '12.34.20000000'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO +~~START~~ +int#!#int#!#int +0#!#10#!#10 +~~END~~ + diff --git a/test/JDBC/input/BABEL-5129-vu-cleanup.sql b/test/JDBC/input/BABEL-5129-vu-cleanup.sql new file mode 100644 index 00000000000..2fb355d10ab --- /dev/null +++ b/test/JDBC/input/BABEL-5129-vu-cleanup.sql @@ -0,0 +1,2 @@ +DROP TABLE babel_5129 +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-5129-vu-prepare.sql b/test/JDBC/input/BABEL-5129-vu-prepare.sql new file mode 100644 index 00000000000..06e10855753 --- /dev/null +++ b/test/JDBC/input/BABEL-5129-vu-prepare.sql @@ -0,0 +1,26 @@ +-- Tests for ISNUMERIC function with varchar and nvarchar variables + +CREATE TABLE babel_5129 ( + int_type int, + numeric_type numeric(10,5), + money_type money, + varchar_type varchar(20), + nvarchar_type nvarchar(20) +) +GO + +INSERT INTO babel_5129 ( + int_type, + numeric_type, + money_type, + varchar_type, + nvarchar_type +) +VALUES ( + 45000, + 12345.12, + 237891.22, + '12.3420000000', + '12.3420000000' +) +GO \ No newline at end of file diff --git a/test/JDBC/input/BABEL-5129-vu-verify.sql b/test/JDBC/input/BABEL-5129-vu-verify.sql new file mode 100644 index 00000000000..0ef888bbccf --- /dev/null +++ b/test/JDBC/input/BABEL-5129-vu-verify.sql @@ -0,0 +1,112 @@ +-- Tests for ISNUMERIC function with varchar and nvarchar variables + +SELECT * FROM babel_5129 +GO +-- Test int +SELECT ISNUMERIC(int_type) +FROM babel_5129 +GO +-- Test numeric +SELECT ISNUMERIC(numeric_type) +FROM babel_5129 +GO +-- Test money +SELECT ISNUMERIC(money_type) +FROM babel_5129 +GO +-- Test varchar +SELECT ISNUMERIC(varchar_type) +FROM babel_5129 +GO +-- Test nvarchar +SELECT ISNUMERIC(nvarchar_type) +FROM babel_5129 +GO + +-- Test numeric variable +DECLARE @a numeric(24,6); +SELECT @a = 12.3420000000; +SELECT ISNUMERIC(@a), LEN(@a), DATALENGTH(@a) +GO + +-- Test varchar variable +DECLARE @v varchar(20); +SELECT @v = '12.3420000000'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +-- Test nvarchar variable +DECLARE @nv nvarchar(10); +SELECT @nv = '12.3420000000'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO + +-- Test NULL varchar variable +DECLARE @v varchar(20); +SELECT @v = NULL; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +-- Test NULL nvarchar variable +DECLARE @nv nvarchar(10); +SELECT @nv = null; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO + +-- Test empty varchar variable +DECLARE @v varchar(20); +SELECT @v = ''; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +-- Test empty nvarchar variable +DECLARE @nv nvarchar(10); +SELECT @nv = ''; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO + +-- Test varchar with number argument that exceeds range of bigint. +DECLARE @v varchar(20); +SELECT @v = '9223372036854775807'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +DECLARE @v varchar(20); +SELECT @v = '-9223372036854775808'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +-- Test nvarchar with number argument that exceeds range of bigint. +DECLARE @nv nvarchar(20); +SELECT @nv = '9223372036854775807'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO + +DECLARE @nv nvarchar(20); +SELECT @nv = '-9223372036854775808'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO + +-- Test varchar with lengthy numeric value +DECLARE @v varchar; +SELECT @v = '12345678901234567890123456789012345'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +-- Test nvarchar with lengthy numeric value +DECLARE @nv nvarchar; +SELECT @nv = '12345678901234567890123456789012345'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO + +-- Test varchar variable with invalid numeric +DECLARE @v varchar(20); +SELECT @v = '12.34.20000000'; +SELECT ISNUMERIC(@v), LEN(@v), DATALENGTH(@v) +GO + +-- Test nvarchar variable with invalid numeric +DECLARE @nv nvarchar(10); +SELECT @nv = '12.34.20000000'; +SELECT ISNUMERIC(@nv), LEN(@nv), DATALENGTH(@nv) +GO \ No newline at end of file diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index e9d6aa23e74..06136d7d4e0 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -436,3 +436,22 @@ babel_4328_datetime2 babel_4328_datetimeoffset BABEL-3401 babel_726 +BABEL-3820 +stuff +PARTITION +BABEL-5071 +string_agg_within +reverse +string_agg +getdate +sys_sequences +replicate +space +SELECT_INTO_TEST +binary-datatype-operators +sys_dm_os_sys_info +cast-varchar-to-time +test_db_collation +BABEL-5119 +BABEL-5129 +