From cd20d5f5d0fbc88fe143c7a197d7b48dc1d4efbc Mon Sep 17 00:00:00 2001 From: Yvinayak07 <100944709+Yvinayak07@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:06:29 +0530 Subject: [PATCH] Allow Smalldatetime type and date type compare to choose index clause. (#3085) Index scan would not be chosen by optimiser if there is any filter that involves operator between Smalldatetime and date even though index is created on Smalldatetime column. We have defined an operator class between smalldatetime and date. Issues Resolved Task: BABEL-4709 Authored-by: yashneet vinayak yashneet@amazon.com Signed-off-by: yashneet vinayak --- contrib/babelfishpg_common/Makefile | 9 +- contrib/babelfishpg_common/Version.config | 2 +- .../babelfishpg_common/sql/smalldatetime.sql | 30 +- .../babelfish_common_helper--4.4.0--4.5.0.sql | 51 + .../babelfishpg_common--3.8.0--4.0.0.sql | 2 + .../upgrades/spatial_types--4.4.0--4.5.0.sql | 3 + ...ime_date_cmp-13_9-14_6-15_2-vu-cleanup.out | 246 ++ ...ime_date_cmp-13_9-14_6-15_2-vu-prepare.out | 372 ++ ...time_date_cmp-13_9-14_6-15_2-vu-verify.out | 3224 +++++++++++++++++ .../smalldatetime_date_cmp-vu-cleanup.out | 246 ++ .../smalldatetime_date_cmp-vu-prepare.out | 372 ++ .../smalldatetime_date_cmp-vu-verify.out | 3212 ++++++++++++++++ ...ime_date_cmp-13_9-14_6-15_2-vu-cleanup.sql | 246 ++ ...ime_date_cmp-13_9-14_6-15_2-vu-prepare.sql | 360 ++ ...time_date_cmp-13_9-14_6-15_2-vu-verify.mix | 804 ++++ .../smalldatetime_date_cmp-vu-cleanup.sql | 246 ++ .../smalldatetime_date_cmp-vu-prepare.sql | 360 ++ .../smalldatetime_date_cmp-vu-verify.mix | 804 ++++ test/JDBC/jdbc_schedule | 3 + test/JDBC/upgrade/13_4/schedule | 1 + test/JDBC/upgrade/13_5/schedule | 1 + test/JDBC/upgrade/13_7/schedule | 2 + test/JDBC/upgrade/13_8/schedule | 2 + test/JDBC/upgrade/13_9/schedule | 2 + test/JDBC/upgrade/14_10/schedule | 1 + test/JDBC/upgrade/14_11/schedule | 1 + test/JDBC/upgrade/14_12/schedule | 2 + test/JDBC/upgrade/14_13/schedule | 1 + test/JDBC/upgrade/14_15/schedule | 2 +- test/JDBC/upgrade/14_16/schedule | 1 + test/JDBC/upgrade/14_3/schedule | 1 + test/JDBC/upgrade/14_5/schedule | 1 + test/JDBC/upgrade/14_6/schedule | 1 + test/JDBC/upgrade/14_7/schedule | 1 + test/JDBC/upgrade/14_8/schedule | 1 + test/JDBC/upgrade/14_9/schedule | 1 + test/JDBC/upgrade/15_1/schedule | 1 + test/JDBC/upgrade/15_10/schedule | 2 +- test/JDBC/upgrade/15_11/schedule | 1 + test/JDBC/upgrade/15_2/schedule | 1 + test/JDBC/upgrade/15_3/schedule | 1 + test/JDBC/upgrade/15_4/schedule | 1 + test/JDBC/upgrade/15_5/schedule | 1 + test/JDBC/upgrade/15_6/schedule | 1 + test/JDBC/upgrade/15_7/schedule | 1 + test/JDBC/upgrade/15_8/schedule | 1 + test/JDBC/upgrade/16_1/schedule | 1 + test/JDBC/upgrade/16_2/schedule | 1 + test/JDBC/upgrade/16_3/schedule | 2 + test/JDBC/upgrade/16_4/schedule | 2 + test/JDBC/upgrade/16_6/schedule | 2 +- test/JDBC/upgrade/latest/schedule | 1 + .../expected_dependency.out | 14 +- 53 files changed, 10630 insertions(+), 18 deletions(-) create mode 100644 contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.4.0--4.5.0.sql create mode 100644 contrib/babelfishpg_common/sql/upgrades/babelfishpg_common--3.8.0--4.0.0.sql create mode 100644 contrib/babelfishpg_common/sql/upgrades/spatial_types--4.4.0--4.5.0.sql create mode 100644 test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.out create mode 100644 test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.out create mode 100644 test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.out create mode 100644 test/JDBC/expected/smalldatetime_date_cmp-vu-cleanup.out create mode 100644 test/JDBC/expected/smalldatetime_date_cmp-vu-prepare.out create mode 100644 test/JDBC/expected/smalldatetime_date_cmp-vu-verify.out create mode 100644 test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.sql create mode 100644 test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.sql create mode 100644 test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.mix create mode 100644 test/JDBC/input/smalldatetime_date_cmp-vu-cleanup.sql create mode 100644 test/JDBC/input/smalldatetime_date_cmp-vu-prepare.sql create mode 100644 test/JDBC/input/smalldatetime_date_cmp-vu-verify.mix diff --git a/contrib/babelfishpg_common/Makefile b/contrib/babelfishpg_common/Makefile index 03c68f8550..6bf1ffea0b 100644 --- a/contrib/babelfishpg_common/Makefile +++ b/contrib/babelfishpg_common/Makefile @@ -61,7 +61,8 @@ GENERATED_UPGRADES = \ sql/$(EXTENSION)--4.0.0--4.1.0.sql \ sql/$(EXTENSION)--4.1.0--4.2.0.sql \ sql/$(EXTENSION)--4.2.0--4.3.0.sql \ - sql/$(EXTENSION)--4.3.0--4.4.0.sql + sql/$(EXTENSION)--4.3.0--4.4.0.sql \ + sql/$(EXTENSION)--4.4.0--4.5.0.sql ifdef PREV_EXTVERSION DATA = sql/$(EXTENSION)--$(PREV_EXTVERSION).sql @@ -126,6 +127,9 @@ ifeq (,$(filter $(FLAG_TO_CHECK),$(PG_CPPFLAGS))) sql/$(EXTENSION)--4.3.0--4.4.0.sql: sql/upgrades/babelfishpg_upgrades.in cpp -D PREV_VERSION=4.3.0 -D CUR_VERSION=4.4.0 $< | sed 's/^# /-- /g' > $@ + + sql/$(EXTENSION)--4.4.0--4.5.0.sql: sql/upgrades/babelfishpg_upgrades.in + cpp -D PREV_VERSION=4.4.0 -D CUR_VERSION=4.5.0 $< | sed 's/^# /-- /g' > $@ else # The flag is present build the .in file including the spatial type files sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).in @@ -152,6 +156,9 @@ else sql/$(EXTENSION)--4.3.0--4.4.0.sql: sql/upgrades/babelfishpg_upgrades.in cpp -D ENABLE_SPATIAL_TYPES=1 -D PREV_VERSION=4.3.0 -D CUR_VERSION=4.4.0 $< | sed 's/^# /-- /g' > $@ + sql/$(EXTENSION)--4.4.0--4.5.0.sql: sql/upgrades/babelfishpg_upgrades.in + cpp -D ENABLE_SPATIAL_TYPES=1 -D PREV_VERSION=4.4.0 -D CUR_VERSION=4.5.0 $< | sed 's/^# /-- /g' > $@ + endif sql/babelfishpg_common--%.sql: sql/upgrades/babelfishpg_common--%.sql diff --git a/contrib/babelfishpg_common/Version.config b/contrib/babelfishpg_common/Version.config index 140a0ad268..fdf2d7e5a5 100644 --- a/contrib/babelfishpg_common/Version.config +++ b/contrib/babelfishpg_common/Version.config @@ -1,4 +1,4 @@ BBFPGCMN_MAJOR_VERSION=4 -BBFPGCMN_MINOR_VERSION=4 +BBFPGCMN_MINOR_VERSION=5 BBFPGCMN_MICRO_VERSION=0 diff --git a/contrib/babelfishpg_common/sql/smalldatetime.sql b/contrib/babelfishpg_common/sql/smalldatetime.sql index 5143f46aa0..48a3ae2e06 100644 --- a/contrib/babelfishpg_common/sql/smalldatetime.sql +++ b/contrib/babelfishpg_common/sql/smalldatetime.sql @@ -470,6 +470,16 @@ RETURNS INT4 AS 'timestamp_cmp' LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE; +CREATE FUNCTION sys.smalldatetime_date_cmp(sys.SMALLDATETIME, date) +RETURNS INT4 +AS 'timestamp_cmp_date' +LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE; + +CREATE FUNCTION sys.date_smalldatetime_cmp(date, sys.SMALLDATETIME) +RETURNS INT4 +AS 'date_cmp_timestamp' +LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE; + CREATE FUNCTION smalldatetime_hash(sys.SMALLDATETIME) RETURNS INT4 AS 'timestamp_hash' @@ -482,7 +492,25 @@ DEFAULT FOR TYPE sys.SMALLDATETIME USING btree AS OPERATOR 3 = (sys.SMALLDATETIME, sys.SMALLDATETIME), OPERATOR 4 >= (sys.SMALLDATETIME, sys.SMALLDATETIME), OPERATOR 5 > (sys.SMALLDATETIME, sys.SMALLDATETIME), - FUNCTION 1 smalldatetime_cmp(sys.SMALLDATETIME, sys.SMALLDATETIME); + FUNCTION 1 sys.smalldatetime_cmp(sys.SMALLDATETIME, sys.SMALLDATETIME); + +CREATE OPERATOR CLASS sys.smalldatetime_date_ops +FOR TYPE sys.SMALLDATETIME USING btree FAMILY smalldatetime_ops AS + OPERATOR 1 sys.< (sys.SMALLDATETIME, date), + OPERATOR 2 sys.<= (sys.SMALLDATETIME, date), + OPERATOR 3 sys.= (sys.SMALLDATETIME, date), + OPERATOR 4 sys.>= (sys.SMALLDATETIME, date), + OPERATOR 5 sys.> (sys.SMALLDATETIME, date), + FUNCTION 1 sys.smalldatetime_date_cmp(sys.SMALLDATETIME, date); + +CREATE OPERATOR CLASS sys.date_smalldatetime_ops +FOR TYPE sys.SMALLDATETIME USING btree FAMILY smalldatetime_ops AS + OPERATOR 1 sys.< (date, sys.SMALLDATETIME), + OPERATOR 2 sys.<= (date, sys.SMALLDATETIME), + OPERATOR 3 sys.= (date, sys.SMALLDATETIME), + OPERATOR 4 sys.>= (date, sys.SMALLDATETIME), + OPERATOR 5 sys.> (date, sys.SMALLDATETIME), + FUNCTION 1 sys.date_smalldatetime_cmp(date, sys.SMALLDATETIME); CREATE OPERATOR CLASS sys.smalldatetime_ops DEFAULT FOR TYPE sys.SMALLDATETIME USING hash AS diff --git a/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.4.0--4.5.0.sql b/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.4.0--4.5.0.sql new file mode 100644 index 0000000000..f27f85778a --- /dev/null +++ b/contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.4.0--4.5.0.sql @@ -0,0 +1,51 @@ +------------------------------------------------------------------------------ +---- Include changes related to other datatypes except spatial types here ---- +------------------------------------------------------------------------------ + +-- complain if script is sourced in psql, rather than via ALTER EXTENSION +\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO "4.5.0"" to load this file. \quit + +SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false); + +CREATE OR REPLACE FUNCTION sys.smalldatetime_date_cmp(sys.SMALLDATETIME, date) +RETURNS INT4 +AS 'timestamp_cmp_date' +LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.date_smalldatetime_cmp(date, sys.SMALLDATETIME) +RETURNS INT4 +AS 'date_cmp_timestamp' +LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE; + +-- Operator class for smalldatetime_ops to incorporate various operator between smalldatetime and date for Index scan +DO $$ +BEGIN +IF NOT EXISTS(SELECT 1 FROM pg_opclass opc JOIN pg_opfamily opf ON opc.opcfamily = opf.oid WHERE opc.opcname = 'smalldatetime_date_ops' AND opc.opcnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'sys') AND opf.opfname = 'smalldatetime_ops') THEN +CREATE OPERATOR CLASS sys.smalldatetime_date_ops +FOR TYPE sys.SMALLDATETIME USING btree FAMILY smalldatetime_ops AS + OPERATOR 1 sys.< (sys.SMALLDATETIME, date), + OPERATOR 2 sys.<= (sys.SMALLDATETIME, date), + OPERATOR 3 sys.= (sys.SMALLDATETIME, date), + OPERATOR 4 sys.>= (sys.SMALLDATETIME, date), + OPERATOR 5 sys.> (sys.SMALLDATETIME, date), + FUNCTION 1 sys.smalldatetime_date_cmp(sys.SMALLDATETIME, date); +END IF; +END $$; + +-- Operator class for smalldatetime_ops to incorporate various operator between date and smalldatetime for Index scan +DO $$ +BEGIN +IF NOT EXISTS(SELECT 1 FROM pg_opclass opc JOIN pg_opfamily opf ON opc.opcfamily = opf.oid WHERE opc.opcname = 'date_smalldatetime_ops' AND opc.opcnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'sys') AND opf.opfname = 'smalldatetime_ops') THEN +CREATE OPERATOR CLASS sys.date_smalldatetime_ops +FOR TYPE sys.SMALLDATETIME USING btree FAMILY smalldatetime_ops AS + OPERATOR 1 sys.< (date, sys.SMALLDATETIME), + OPERATOR 2 sys.<= (date, sys.SMALLDATETIME), + OPERATOR 3 sys.= (date, sys.SMALLDATETIME), + OPERATOR 4 sys.>= (date, sys.SMALLDATETIME), + OPERATOR 5 sys.> (date, sys.SMALLDATETIME), + FUNCTION 1 sys.date_smalldatetime_cmp(date, sys.SMALLDATETIME); +END IF; +END $$; + +-- Reset search_path to not affect any subsequent scripts +SELECT set_config('search_path', trim(leading 'sys, ' from current_setting('search_path')), false); diff --git a/contrib/babelfishpg_common/sql/upgrades/babelfishpg_common--3.8.0--4.0.0.sql b/contrib/babelfishpg_common/sql/upgrades/babelfishpg_common--3.8.0--4.0.0.sql new file mode 100644 index 0000000000..b166a4ff89 --- /dev/null +++ b/contrib/babelfishpg_common/sql/upgrades/babelfishpg_common--3.8.0--4.0.0.sql @@ -0,0 +1,2 @@ +-- complain if script is sourced in psql, rather than via ALTER EXTENSION +\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO '4.0.0'" to load this file. \quit diff --git a/contrib/babelfishpg_common/sql/upgrades/spatial_types--4.4.0--4.5.0.sql b/contrib/babelfishpg_common/sql/upgrades/spatial_types--4.4.0--4.5.0.sql new file mode 100644 index 0000000000..4a18af015f --- /dev/null +++ b/contrib/babelfishpg_common/sql/upgrades/spatial_types--4.4.0--4.5.0.sql @@ -0,0 +1,3 @@ +------------------------------------------------------- +---- Include changes related to spatial types here ---- +------------------------------------------------------- diff --git a/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.out b/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.out new file mode 100644 index 0000000000..e56a71aec0 --- /dev/null +++ b/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.out @@ -0,0 +1,246 @@ +DROP PROCEDURE test_smalldatetime_date_p1; +GO + +DROP PROCEDURE test_smalldatetime_date_p2; +GO + +DROP PROCEDURE test_smalldatetime_date_p3; +GO + +DROP PROCEDURE test_smalldatetime_date_p4; +GO + +DROP PROCEDURE test_smalldatetime_date_p5; +GO + +DROP PROCEDURE test_smalldatetime_date_p6; +GO + +DROP PROCEDURE test_smalldatetime_date_p7; +GO + +DROP PROCEDURE test_smalldatetime_date_p8; +GO + +DROP PROCEDURE test_smalldatetime_date_p9; +GO + +DROP PROCEDURE test_smalldatetime_date_p10; +GO + +DROP PROCEDURE test_smalldatetime_date_p11; +GO + +DROP PROCEDURE test_smalldatetime_date_p12; +GO + +DROP PROCEDURE test_smalldatetime_date_p13; +GO + +DROP PROCEDURE test_smalldatetime_date_p14; +GO + +DROP PROCEDURE test_smalldatetime_date_p15; +GO + +DROP PROCEDURE test_smalldatetime_date_p16; +GO + +DROP PROCEDURE test_smalldatetime_date_p17; +GO + +DROP PROCEDURE test_smalldatetime_date_p18; +GO + +DROP PROCEDURE test_smalldatetime_date_p19; +GO + +DROP PROCEDURE test_smalldatetime_date_p20; +GO + +DROP VIEW test_smalldatetime_date_v1; +GO + +DROP VIEW test_smalldatetime_date_v2; +GO + +DROP VIEW test_smalldatetime_date_v3; +GO + +DROP VIEW test_smalldatetime_date_v4; +GO + +DROP VIEW test_smalldatetime_date_v5; +GO + +DROP VIEW test_smalldatetime_date_v6; +GO + +DROP VIEW test_smalldatetime_date_v7; +GO + +DROP VIEW test_smalldatetime_date_v8; +GO + +DROP VIEW test_smalldatetime_date_v9; +GO + +DROP VIEW test_smalldatetime_date_v10; +GO + +DROP VIEW test_smalldatetime_date_v11; +GO + +DROP VIEW test_smalldatetime_date_v12; +GO + +DROP VIEW test_smalldatetime_date_v13; +GO + +DROP VIEW test_smalldatetime_date_v14; +GO + +DROP VIEW test_smalldatetime_date_v15; +GO + +DROP VIEW test_smalldatetime_date_v16; +GO + +DROP VIEW test_smalldatetime_date_v17; +GO + +DROP VIEW test_smalldatetime_date_v18; +GO + +DROP VIEW test_smalldatetime_date_v19; +GO + +DROP VIEW test_smalldatetime_date_v20; +GO + +DROP INDEX smalldate_date_cmp_ind1 on smalldate_date_cmp_t1; +GO + +DROP TABLE smalldate_date_cmp_t1; +GO + +-- tests for index on date column +DROP PROCEDURE test_date_smalldatetime_p1; +GO + +DROP PROCEDURE test_date_smalldatetime_p2; +GO + +DROP PROCEDURE test_date_smalldatetime_p3; +GO + +DROP PROCEDURE test_date_smalldatetime_p4; +GO + +DROP PROCEDURE test_date_smalldatetime_p5; +GO + +DROP PROCEDURE test_date_smalldatetime_p6; +GO + +DROP PROCEDURE test_date_smalldatetime_p7; +GO + +DROP PROCEDURE test_date_smalldatetime_p8; +GO + +DROP PROCEDURE test_date_smalldatetime_p9; +GO + +DROP PROCEDURE test_date_smalldatetime_p10; +GO + +DROP PROCEDURE test_date_smalldatetime_p11; +GO + +DROP PROCEDURE test_date_smalldatetime_p12; +GO + +DROP PROCEDURE test_date_smalldatetime_p13; +GO + +DROP PROCEDURE test_date_smalldatetime_p15; +GO + +DROP PROCEDURE test_date_smalldatetime_p16; +GO + +DROP PROCEDURE test_date_smalldatetime_p17; +GO + +DROP PROCEDURE test_date_smalldatetime_p18; +GO + +DROP PROCEDURE test_date_smalldatetime_p19; +GO + +DROP PROCEDURE test_date_smalldatetime_p20; +GO + +DROP VIEW test_date_smalldatetime_v1; +GO + +DROP VIEW test_date_smalldatetime_v2; +GO + +DROP VIEW test_date_smalldatetime_v3; +GO + +DROP VIEW test_date_smalldatetime_v4; +GO + +DROP VIEW test_date_smalldatetime_v5; +GO + +DROP VIEW test_date_smalldatetime_v6; +GO + +DROP VIEW test_date_smalldatetime_v7; +GO + +DROP VIEW test_date_smalldatetime_v8; +GO + +DROP VIEW test_date_smalldatetime_v9; +GO + +DROP VIEW test_date_smalldatetime_v10; +GO + +DROP VIEW test_date_smalldatetime_v11; +GO + +DROP VIEW test_date_smalldatetime_v12; +GO + +DROP VIEW test_date_smalldatetime_v13; +GO + +DROP VIEW test_date_smalldatetime_v15; +GO + +DROP VIEW test_date_smalldatetime_v16; +GO + +DROP VIEW test_date_smalldatetime_v17; +GO + +DROP VIEW test_date_smalldatetime_v18; +GO + +DROP VIEW test_date_smalldatetime_v19; +GO + +DROP VIEW test_date_smalldatetime_v20; +GO + +DROP INDEX date_smalldatetime_cmp_ind1 on date_smalldatetime_cmp_t1; +GO + +DROP TABLE date_smalldatetime_cmp_t1; +GO diff --git a/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.out b/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.out new file mode 100644 index 0000000000..538659e056 --- /dev/null +++ b/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.out @@ -0,0 +1,372 @@ +CREATE TABLE smalldate_date_cmp_t1 ( + smalldatetime_col SMALLDATETIME +) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-13 14:30:00' as smalldatetime) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-15 14:30:00' as smalldatetime) from generate_series(1, 100000) +GO +~~ROW COUNT: 100000~~ + + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-17 14:30:00' as smalldatetime) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +CREATE NONCLUSTERED INDEX smalldate_date_cmp_ind1 ON smalldate_date_cmp_t1 +( + smalldatetime_col ASC +) +GO + +-- seq scan +CREATE PROCEDURE test_smalldatetime_date_p1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE PROCEDURE test_smalldatetime_date_p7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE PROCEDURE test_smalldatetime_date_p15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- seq scan +CREATE VIEW test_smalldatetime_date_v1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE VIEW test_smalldatetime_date_v7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE VIEW test_smalldatetime_date_v15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- Creating index on date +-- FIX ME: Following test cases are for the index +-- created on date column, which will not choose +-- index clause when comparison between date +-- and smalldatetime. +CREATE TABLE date_smalldatetime_cmp_t1 ( + date_col DATE +) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-13' as date) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-15' as date) from generate_series(1, 100000) +GO +~~ROW COUNT: 100000~~ + + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-17' as date) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +CREATE NONCLUSTERED INDEX date_smalldatetime_cmp_ind1 ON date_smalldatetime_cmp_t1 +( + date_col ASC +) +GO + +CREATE PROCEDURE test_date_smalldatetime_p1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE VIEW test_date_smalldatetime_v16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE VIEW test_date_smalldatetime_v19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE VIEW test_date_smalldatetime_v20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO diff --git a/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.out b/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.out new file mode 100644 index 0000000000..3971ef9421 --- /dev/null +++ b/test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.out @@ -0,0 +1,3224 @@ +-- psql +ANALYZE master_dbo.smalldate_date_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +~~START~~ +text +0 +~~END~~ + +SELECT set_config('debug_parallel_query', '0', false); +GO +~~START~~ +text +off +~~END~~ + +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO +~~START~~ +text +off +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE) +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-13'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 123.730 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE) +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-15'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.165 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE) +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.118 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-13'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 7.435 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-15'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.120 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-17'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.113 ms +~~END~~ + + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 3.004 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.631 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.757 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.679 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 3.204 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.474 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 4.614 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 3.167 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 3.333 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.120 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.219 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.609 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 2.846 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.120 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.130 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.088 ms +~~END~~ + + +-- ORDER BY clause +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col +Sort + Sort Key: smalldatetime_col NULLS FIRST + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 7.693 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col +Sort + Sort Key: smalldatetime_col NULLS FIRST + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.140 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col +Sort + Sort Key: smalldatetime_col NULLS FIRST + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.154 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.122 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col +Sort + Sort Key: smalldatetime_col NULLS FIRST + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.119 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col +Sort + Sort Key: smalldatetime_col NULLS FIRST + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.119 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) ORDER BY smalldatetime_col +Sort + Sort Key: smalldatetime_col NULLS FIRST + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.138 ms +~~END~~ + + +-- testing with joins +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col < s2.smalldatetime_col +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col < s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col > s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 31.737 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col > s2.smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col > s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col < s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.465 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col <= s2.smalldatetime_col +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col <= s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col >= s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.127 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col >= s2.smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col >= s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col <= s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.123 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col = s2.smalldatetime_col +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col = s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col = s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.348 ms +~~END~~ + + +EXEC test_smalldatetime_date_p1; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p1 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE) + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-13'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.205 ms +~~END~~ + + +EXEC test_smalldatetime_date_p2; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p2 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE) + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-15'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.122 ms +~~END~~ + + +EXEC test_smalldatetime_date_p3; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p3 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE) + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.113 ms +~~END~~ + + +EXEC test_smalldatetime_date_p4; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p4 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-13'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.118 ms +~~END~~ + + +EXEC test_smalldatetime_date_p5; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p5 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-15'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.112 ms +~~END~~ + + +EXEC test_smalldatetime_date_p6; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p6 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-17'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.112 ms +~~END~~ + + +EXEC test_smalldatetime_date_p7; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p7 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.113 ms +~~END~~ + + +EXEC test_smalldatetime_date_p8; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p8 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.112 ms +~~END~~ + + +EXEC test_smalldatetime_date_p9; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p9 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.150 ms +~~END~~ + + +EXEC test_smalldatetime_date_p10; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p10 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.113 ms +~~END~~ + + +EXEC test_smalldatetime_date_p11; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p11 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.111 ms +~~END~~ + + +EXEC test_smalldatetime_date_p12; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p12 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.112 ms +~~END~~ + + +EXEC test_smalldatetime_date_p13; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p13 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.133 ms +~~END~~ + + +EXEC test_smalldatetime_date_p14; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p14 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.093 ms +~~END~~ + + +EXEC test_smalldatetime_date_p15; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p15 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.113 ms +~~END~~ + + +EXEC test_smalldatetime_date_p16; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p16 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.114 ms +~~END~~ + + +EXEC test_smalldatetime_date_p17; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p17 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.154 ms +~~END~~ + + +EXEC test_smalldatetime_date_p18; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p18 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.115 ms +~~END~~ + + +EXEC test_smalldatetime_date_p19; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p19 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.114 ms +~~END~~ + + +EXEC test_smalldatetime_date_p20; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p20 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.115 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v1; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v1 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-13'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.507 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v2; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v2 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-15'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.060 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v3; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v3 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.059 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v4; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v4 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-13'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v5; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v5 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-15'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v6; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v6 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-17'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v7; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v7 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v8; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v8 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v9; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v9 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v10; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v10 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.071 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v11; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v11 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v12; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v12 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v13; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v13 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v14; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v14 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v15; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v15 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.055 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v16; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v16 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v17; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v17 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v18; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v18 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v19; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v19 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v20; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v20 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO +~~START~~ +int +100020 +~~END~~ + + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO +~~START~~ +int +0 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +int +0 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p1; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p2; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p3; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p4; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p5; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p6; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p7; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p8; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p9; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p10; +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p11; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p12; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p13; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p14; +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p15; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p16; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p17; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p18; +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p19; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v1; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v2; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v3; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v4; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v5; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v6; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v7; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v8; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v9; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v10; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v11; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v12; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v13; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v14; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v15; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v16; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v17; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v18; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v19; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO +~~START~~ +text +on +~~END~~ + + +-- psql +-- tests for index on date column +ANALYZE master_dbo.date_smalldatetime_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +~~START~~ +text +0 +~~END~~ + +SELECT set_config('debug_parallel_query', '0', false); +GO +~~START~~ +text +off +~~END~~ + +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO +~~START~~ +text +off +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-13 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.406 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-15 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.172 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.128 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-13 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.126 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-15 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.114 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.115 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col < '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.114 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <= '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.117 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone) AND (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.153 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col = '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.120 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col > '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.115 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.116 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.136 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone > date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.119 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone >= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.115 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) AND ('2023-06-18 00:00:00'::smalldatetime(0) without time zone >= date_col)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.148 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone = date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.112 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone < date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.111 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.110 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.130 ms +~~END~~ + + +EXEC test_date_smalldatetime_p1; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p1 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-13 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.123 ms +~~END~~ + + +EXEC test_date_smalldatetime_p2; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p2 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-15 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.114 ms +~~END~~ + + +EXEC test_date_smalldatetime_p3; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p3 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.162 ms +~~END~~ + + +EXEC test_date_smalldatetime_p4; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p4 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-13 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +EXEC test_date_smalldatetime_p5; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p5 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-15 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.178 ms +~~END~~ + + +EXEC test_date_smalldatetime_p6; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p6 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.178 ms +~~END~~ + + +EXEC test_date_smalldatetime_p7; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p7 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col < '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_date_smalldatetime_p8; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p8 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <= '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.168 ms +~~END~~ + + +EXEC test_date_smalldatetime_p9; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p9 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone) AND (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.228 ms +~~END~~ + + +EXEC test_date_smalldatetime_p10; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p10 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col = '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.169 ms +~~END~~ + + +EXEC test_date_smalldatetime_p11; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p11 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col > '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.172 ms +~~END~~ + + +EXEC test_date_smalldatetime_p12; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p12 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.171 ms +~~END~~ + + +EXEC test_date_smalldatetime_p13; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p13 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.200 ms +~~END~~ + + +EXEC test_date_smalldatetime_p15; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p15 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone > date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.168 ms +~~END~~ + + +EXEC test_date_smalldatetime_p16; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p16 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone >= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.165 ms +~~END~~ + + +EXEC test_date_smalldatetime_p17; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p17 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) AND ('2023-06-18 00:00:00'::smalldatetime(0) without time zone >= date_col)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.226 ms +~~END~~ + + +EXEC test_date_smalldatetime_p18; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p18 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone = date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.163 ms +~~END~~ + + +EXEC test_date_smalldatetime_p19; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p19 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone < date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.127 ms +~~END~~ + + +EXEC test_date_smalldatetime_p20; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p20 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.118 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v1; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v1 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-13 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.061 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v2; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v2 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-15 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.059 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v3; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v3 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.058 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v4; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v4 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-13 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.058 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v5; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v5 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-15 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v6; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v6 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v7; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v7 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col < '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v8; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v8 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <= '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v9; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v9 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone) AND (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v10; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v10 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col = '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v11; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v11 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col > '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v12; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v12 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v13; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v13 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v15; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v15 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone > date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.058 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v16; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v16 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone >= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v17; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v17 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) AND ('2023-06-18 00:00:00'::smalldatetime(0) without time zone >= date_col)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.056 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v18; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v18 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone = date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.057 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v19; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v19 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone < date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.058 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v20; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v20 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.058 ms +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO +~~START~~ +int +20 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +int +20 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p1; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p2; +GO +~~START~~ +int +20 +~~END~~ + + +EXEC test_date_smalldatetime_p3; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p4; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p5; +GO +~~START~~ +int +20 +~~END~~ + + +EXEC test_date_smalldatetime_p6; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p7; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p8; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p9; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p10; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p11; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p12; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p13; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p15; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p16; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p17; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p18; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p19; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v1; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v2; +GO +~~START~~ +int +20 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v3; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v4; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v5; +GO +~~START~~ +int +20 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v6; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v7; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v8; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v9; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v10; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v11; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v12; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v13; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v15; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v16; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v17; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v18; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v19; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO +~~START~~ +text +on +~~END~~ + diff --git a/test/JDBC/expected/smalldatetime_date_cmp-vu-cleanup.out b/test/JDBC/expected/smalldatetime_date_cmp-vu-cleanup.out new file mode 100644 index 0000000000..e56a71aec0 --- /dev/null +++ b/test/JDBC/expected/smalldatetime_date_cmp-vu-cleanup.out @@ -0,0 +1,246 @@ +DROP PROCEDURE test_smalldatetime_date_p1; +GO + +DROP PROCEDURE test_smalldatetime_date_p2; +GO + +DROP PROCEDURE test_smalldatetime_date_p3; +GO + +DROP PROCEDURE test_smalldatetime_date_p4; +GO + +DROP PROCEDURE test_smalldatetime_date_p5; +GO + +DROP PROCEDURE test_smalldatetime_date_p6; +GO + +DROP PROCEDURE test_smalldatetime_date_p7; +GO + +DROP PROCEDURE test_smalldatetime_date_p8; +GO + +DROP PROCEDURE test_smalldatetime_date_p9; +GO + +DROP PROCEDURE test_smalldatetime_date_p10; +GO + +DROP PROCEDURE test_smalldatetime_date_p11; +GO + +DROP PROCEDURE test_smalldatetime_date_p12; +GO + +DROP PROCEDURE test_smalldatetime_date_p13; +GO + +DROP PROCEDURE test_smalldatetime_date_p14; +GO + +DROP PROCEDURE test_smalldatetime_date_p15; +GO + +DROP PROCEDURE test_smalldatetime_date_p16; +GO + +DROP PROCEDURE test_smalldatetime_date_p17; +GO + +DROP PROCEDURE test_smalldatetime_date_p18; +GO + +DROP PROCEDURE test_smalldatetime_date_p19; +GO + +DROP PROCEDURE test_smalldatetime_date_p20; +GO + +DROP VIEW test_smalldatetime_date_v1; +GO + +DROP VIEW test_smalldatetime_date_v2; +GO + +DROP VIEW test_smalldatetime_date_v3; +GO + +DROP VIEW test_smalldatetime_date_v4; +GO + +DROP VIEW test_smalldatetime_date_v5; +GO + +DROP VIEW test_smalldatetime_date_v6; +GO + +DROP VIEW test_smalldatetime_date_v7; +GO + +DROP VIEW test_smalldatetime_date_v8; +GO + +DROP VIEW test_smalldatetime_date_v9; +GO + +DROP VIEW test_smalldatetime_date_v10; +GO + +DROP VIEW test_smalldatetime_date_v11; +GO + +DROP VIEW test_smalldatetime_date_v12; +GO + +DROP VIEW test_smalldatetime_date_v13; +GO + +DROP VIEW test_smalldatetime_date_v14; +GO + +DROP VIEW test_smalldatetime_date_v15; +GO + +DROP VIEW test_smalldatetime_date_v16; +GO + +DROP VIEW test_smalldatetime_date_v17; +GO + +DROP VIEW test_smalldatetime_date_v18; +GO + +DROP VIEW test_smalldatetime_date_v19; +GO + +DROP VIEW test_smalldatetime_date_v20; +GO + +DROP INDEX smalldate_date_cmp_ind1 on smalldate_date_cmp_t1; +GO + +DROP TABLE smalldate_date_cmp_t1; +GO + +-- tests for index on date column +DROP PROCEDURE test_date_smalldatetime_p1; +GO + +DROP PROCEDURE test_date_smalldatetime_p2; +GO + +DROP PROCEDURE test_date_smalldatetime_p3; +GO + +DROP PROCEDURE test_date_smalldatetime_p4; +GO + +DROP PROCEDURE test_date_smalldatetime_p5; +GO + +DROP PROCEDURE test_date_smalldatetime_p6; +GO + +DROP PROCEDURE test_date_smalldatetime_p7; +GO + +DROP PROCEDURE test_date_smalldatetime_p8; +GO + +DROP PROCEDURE test_date_smalldatetime_p9; +GO + +DROP PROCEDURE test_date_smalldatetime_p10; +GO + +DROP PROCEDURE test_date_smalldatetime_p11; +GO + +DROP PROCEDURE test_date_smalldatetime_p12; +GO + +DROP PROCEDURE test_date_smalldatetime_p13; +GO + +DROP PROCEDURE test_date_smalldatetime_p15; +GO + +DROP PROCEDURE test_date_smalldatetime_p16; +GO + +DROP PROCEDURE test_date_smalldatetime_p17; +GO + +DROP PROCEDURE test_date_smalldatetime_p18; +GO + +DROP PROCEDURE test_date_smalldatetime_p19; +GO + +DROP PROCEDURE test_date_smalldatetime_p20; +GO + +DROP VIEW test_date_smalldatetime_v1; +GO + +DROP VIEW test_date_smalldatetime_v2; +GO + +DROP VIEW test_date_smalldatetime_v3; +GO + +DROP VIEW test_date_smalldatetime_v4; +GO + +DROP VIEW test_date_smalldatetime_v5; +GO + +DROP VIEW test_date_smalldatetime_v6; +GO + +DROP VIEW test_date_smalldatetime_v7; +GO + +DROP VIEW test_date_smalldatetime_v8; +GO + +DROP VIEW test_date_smalldatetime_v9; +GO + +DROP VIEW test_date_smalldatetime_v10; +GO + +DROP VIEW test_date_smalldatetime_v11; +GO + +DROP VIEW test_date_smalldatetime_v12; +GO + +DROP VIEW test_date_smalldatetime_v13; +GO + +DROP VIEW test_date_smalldatetime_v15; +GO + +DROP VIEW test_date_smalldatetime_v16; +GO + +DROP VIEW test_date_smalldatetime_v17; +GO + +DROP VIEW test_date_smalldatetime_v18; +GO + +DROP VIEW test_date_smalldatetime_v19; +GO + +DROP VIEW test_date_smalldatetime_v20; +GO + +DROP INDEX date_smalldatetime_cmp_ind1 on date_smalldatetime_cmp_t1; +GO + +DROP TABLE date_smalldatetime_cmp_t1; +GO diff --git a/test/JDBC/expected/smalldatetime_date_cmp-vu-prepare.out b/test/JDBC/expected/smalldatetime_date_cmp-vu-prepare.out new file mode 100644 index 0000000000..538659e056 --- /dev/null +++ b/test/JDBC/expected/smalldatetime_date_cmp-vu-prepare.out @@ -0,0 +1,372 @@ +CREATE TABLE smalldate_date_cmp_t1 ( + smalldatetime_col SMALLDATETIME +) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-13 14:30:00' as smalldatetime) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-15 14:30:00' as smalldatetime) from generate_series(1, 100000) +GO +~~ROW COUNT: 100000~~ + + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-17 14:30:00' as smalldatetime) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +CREATE NONCLUSTERED INDEX smalldate_date_cmp_ind1 ON smalldate_date_cmp_t1 +( + smalldatetime_col ASC +) +GO + +-- seq scan +CREATE PROCEDURE test_smalldatetime_date_p1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE PROCEDURE test_smalldatetime_date_p7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE PROCEDURE test_smalldatetime_date_p15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- seq scan +CREATE VIEW test_smalldatetime_date_v1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE VIEW test_smalldatetime_date_v7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE VIEW test_smalldatetime_date_v15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- Creating index on date +-- FIX ME: Following test cases are for the index +-- created on date column, which will not choose +-- index clause when comparison between date +-- and smalldatetime. +CREATE TABLE date_smalldatetime_cmp_t1 ( + date_col DATE +) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-13' as date) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-15' as date) from generate_series(1, 100000) +GO +~~ROW COUNT: 100000~~ + + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-17' as date) from generate_series(1, 10) +GO +~~ROW COUNT: 10~~ + + +CREATE NONCLUSTERED INDEX date_smalldatetime_cmp_ind1 ON date_smalldatetime_cmp_t1 +( + date_col ASC +) +GO + +CREATE PROCEDURE test_date_smalldatetime_p1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE VIEW test_date_smalldatetime_v16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE VIEW test_date_smalldatetime_v19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE VIEW test_date_smalldatetime_v20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO diff --git a/test/JDBC/expected/smalldatetime_date_cmp-vu-verify.out b/test/JDBC/expected/smalldatetime_date_cmp-vu-verify.out new file mode 100644 index 0000000000..5b8357c456 --- /dev/null +++ b/test/JDBC/expected/smalldatetime_date_cmp-vu-verify.out @@ -0,0 +1,3212 @@ +-- psql +ANALYZE master_dbo.smalldate_date_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +~~START~~ +text +0 +~~END~~ + +SELECT set_config('debug_parallel_query', '0', false); +GO +~~START~~ +text +off +~~END~~ + +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO +~~START~~ +text +off +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE) +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-13'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 197.796 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE) +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-15'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.210 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE) +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-13'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 13.683 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-15'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.174 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-17'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.169 ms +~~END~~ + + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 5.765 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 1.109 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 1.296 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 1.187 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 6.324 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.764 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 8.595 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 6.429 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 6.828 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.183 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.353 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 1.098 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 5.817 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.181 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.200 ms +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.138 ms +~~END~~ + + +-- ORDER BY clause +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 15.153 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.194 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.239 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.190 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.192 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.192 ms +~~END~~ + + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) ORDER BY smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) ORDER BY smalldatetime_col +Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.215 ms +~~END~~ + + +-- testing with joins +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col < s2.smalldatetime_col +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col < s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col > s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 60.743 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col > s2.smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col > s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col < s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.761 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col <= s2.smalldatetime_col +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col <= s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col >= s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.192 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col >= s2.smalldatetime_col; +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col >= s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col <= s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.190 ms +~~END~~ + + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col = s2.smalldatetime_col +GO +~~START~~ +text +Query Text: SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col = s2.smalldatetime_col +Nested Loop + -> Seq Scan on smalldate_date_cmp_t1 s1 + -> Memoize + Cache Key: s1.smalldatetime_col + Cache Mode: binary + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 s2 + Index Cond: (smalldatetime_col = s1.smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.592 ms +~~END~~ + + +EXEC test_smalldatetime_date_p1; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p1 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE) + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-13'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.213 ms +~~END~~ + + +EXEC test_smalldatetime_date_p2; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p2 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE) + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-15'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_smalldatetime_date_p3; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p3 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE) + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.172 ms +~~END~~ + + +EXEC test_smalldatetime_date_p4; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p4 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-13'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.177 ms +~~END~~ + + +EXEC test_smalldatetime_date_p5; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p5 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-15'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_smalldatetime_date_p6; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p6 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col + -> Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-17'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.172 ms +~~END~~ + + +EXEC test_smalldatetime_date_p7; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p7 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.171 ms +~~END~~ + + +EXEC test_smalldatetime_date_p8; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p8 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_smalldatetime_date_p9; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p9 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.235 ms +~~END~~ + + +EXEC test_smalldatetime_date_p10; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p10 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.172 ms +~~END~~ + + +EXEC test_smalldatetime_date_p11; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p11 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.171 ms +~~END~~ + + +EXEC test_smalldatetime_date_p12; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p12 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.171 ms +~~END~~ + + +EXEC test_smalldatetime_date_p13; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p13 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.200 ms +~~END~~ + + +EXEC test_smalldatetime_date_p14; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p14 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.137 ms +~~END~~ + + +EXEC test_smalldatetime_date_p15; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p15 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.171 ms +~~END~~ + + +EXEC test_smalldatetime_date_p16; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p16 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.174 ms +~~END~~ + + +EXEC test_smalldatetime_date_p17; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p17 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.222 ms +~~END~~ + + +EXEC test_smalldatetime_date_p18; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p18 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.171 ms +~~END~~ + + +EXEC test_smalldatetime_date_p19; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p19 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_smalldatetime_date_p20; +GO +~~START~~ +text +Query Text: EXEC test_smalldatetime_date_p20 + Query Text: SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col + -> Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.174 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v1; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v1 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-13'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.694 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v2; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v2 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-15'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.086 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v3; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v3 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: (smalldatetime_col <> '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.086 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v4; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v4 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-13'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.085 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v5; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v5 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-15'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.085 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v6; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v6 +Aggregate + -> Seq Scan on smalldate_date_cmp_t1 + Filter: ('2023-06-17'::date <> smalldatetime_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.085 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v7; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v7 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.085 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v8; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v8 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.122 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v9; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v9 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col <= '2023-06-18'::date) AND (smalldatetime_col >= '2023-06-16'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.119 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v10; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v10 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v11; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v11 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.123 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v12; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v12 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.088 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v13; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v13 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.086 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v14; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v14 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col IS NULL) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.088 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v15; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v15 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col < '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.085 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v16; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v16 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col <= '2023-06-14'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.086 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v17; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v17 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: ((smalldatetime_col >= '2023-06-16'::date) AND (smalldatetime_col <= '2023-06-18'::date)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.087 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v18; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v18 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col = '2023-06-17'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.087 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v19; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v19 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col > '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.086 ms +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v20; +GO +~~START~~ +text +Query Text: SELECT * FROM test_smalldatetime_date_v20 +Aggregate + -> Index Only Scan using smalldate_date_cmp_ind1smalldat671b849847ebd8ff45b7a2a5182502b2 on smalldate_date_cmp_t1 + Index Cond: (smalldatetime_col >= '2023-06-16'::date) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO +~~START~~ +int +100020 +~~END~~ + + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO +~~START~~ +int +0 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +int +0 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p1; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p2; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p3; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p4; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p5; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p6; +GO +~~START~~ +int +100020 +~~END~~ + + +EXEC test_smalldatetime_date_p7; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p8; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p9; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p10; +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p11; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p12; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p13; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p14; +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p15; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p16; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p17; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p18; +GO +~~START~~ +int +0 +~~END~~ + + +EXEC test_smalldatetime_date_p19; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_smalldatetime_date_p20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v1; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v2; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v3; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v4; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v5; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v6; +GO +~~START~~ +int +100020 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v7; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v8; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v9; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v10; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v11; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v12; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v13; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v14; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v15; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v16; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v17; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v18; +GO +~~START~~ +int +0 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v19; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_smalldatetime_date_v20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO +~~START~~ +text +on +~~END~~ + + +-- psql +-- tests for index on date column +ANALYZE master_dbo.date_smalldatetime_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +~~START~~ +text +0 +~~END~~ + +SELECT set_config('debug_parallel_query', '0', false); +GO +~~START~~ +text +off +~~END~~ + +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO +~~START~~ +text +off +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-13 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.582 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-15 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.183 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.180 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-13 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.186 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-15 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.179 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.177 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col < '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <= '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.181 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone) AND (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.238 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col = '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.180 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col > '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.179 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.180 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.208 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone > date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.178 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone >= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.177 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) AND ('2023-06-18 00:00:00'::smalldatetime(0) without time zone >= date_col)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.228 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone = date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.178 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone < date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.177 ms +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +text +Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME) +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.199 ms +~~END~~ + + +EXEC test_date_smalldatetime_p1; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p1 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-13 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +EXEC test_date_smalldatetime_p2; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p2 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-15 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.174 ms +~~END~~ + + +EXEC test_date_smalldatetime_p3; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p3 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.175 ms +~~END~~ + + +EXEC test_date_smalldatetime_p4; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p4 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-13 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.175 ms +~~END~~ + + +EXEC test_date_smalldatetime_p5; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p5 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-15 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.174 ms +~~END~~ + + +EXEC test_date_smalldatetime_p6; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p6 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.175 ms +~~END~~ + + +EXEC test_date_smalldatetime_p7; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p7 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col < '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_date_smalldatetime_p8; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p8 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <= '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +EXEC test_date_smalldatetime_p9; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p9 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone) AND (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.227 ms +~~END~~ + + +EXEC test_date_smalldatetime_p10; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p10 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col = '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_date_smalldatetime_p11; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p11 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col > '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.173 ms +~~END~~ + + +EXEC test_date_smalldatetime_p12; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p12 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.175 ms +~~END~~ + + +EXEC test_date_smalldatetime_p13; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p13 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME) + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.199 ms +~~END~~ + + +EXEC test_date_smalldatetime_p15; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p15 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone > date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.176 ms +~~END~~ + + +EXEC test_date_smalldatetime_p16; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p16 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone >= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.207 ms +~~END~~ + + +EXEC test_date_smalldatetime_p17; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p17 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) AND ('2023-06-18 00:00:00'::smalldatetime(0) without time zone >= date_col)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.229 ms +~~END~~ + + +EXEC test_date_smalldatetime_p18; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p18 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone = date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.179 ms +~~END~~ + + +EXEC test_date_smalldatetime_p19; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p19 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone < date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.255 ms +~~END~~ + + +EXEC test_date_smalldatetime_p20; +GO +~~START~~ +text +Query Text: EXEC test_date_smalldatetime_p20 + Query Text: SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col + -> Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.177 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v1; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v1 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-13 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.086 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v2; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v2 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-15 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v3; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v3 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <> '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.093 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v4; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v4 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-13 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.087 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v5; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v5 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-15 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.089 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v6; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v6 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone <> date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.087 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v7; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v7 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col < '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.119 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v8; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v8 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col <= '2023-06-14 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.093 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v9; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v9 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone) AND (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.127 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v10; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v10 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col = '2023-06-17 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v11; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v11 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col > '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.123 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v12; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v12 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v13; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v13 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ((date_col >= '2023-06-16 00:00:00'::smalldatetime(0) without time zone) AND (date_col <= '2023-06-18 00:00:00'::smalldatetime(0) without time zone)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.122 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v15; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v15 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone > date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.125 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v16; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v16 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-14 00:00:00'::smalldatetime(0) without time zone >= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.120 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v17; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v17 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: (('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) AND ('2023-06-18 00:00:00'::smalldatetime(0) without time zone >= date_col)) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.121 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v18; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v18 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-17 00:00:00'::smalldatetime(0) without time zone = date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v19; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v19 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone < date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v20; +GO +~~START~~ +text +Query Text: SELECT * FROM test_date_smalldatetime_v20 +Aggregate + -> Seq Scan on date_smalldatetime_cmp_t1 + Filter: ('2023-06-16 00:00:00'::smalldatetime(0) without time zone <= date_col) +~~END~~ + +~~START~~ +text +Babelfish T-SQL Batch Parsing Time: 0.124 ms +~~END~~ + + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO +~~START~~ +int +20 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +int +20 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p1; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p2; +GO +~~START~~ +int +20 +~~END~~ + + +EXEC test_date_smalldatetime_p3; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p4; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p5; +GO +~~START~~ +int +20 +~~END~~ + + +EXEC test_date_smalldatetime_p6; +GO +~~START~~ +int +100010 +~~END~~ + + +EXEC test_date_smalldatetime_p7; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p8; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p9; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p10; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p11; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p12; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p13; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p15; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p16; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p17; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p18; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p19; +GO +~~START~~ +int +10 +~~END~~ + + +EXEC test_date_smalldatetime_p20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v1; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v2; +GO +~~START~~ +int +20 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v3; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v4; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v5; +GO +~~START~~ +int +20 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v6; +GO +~~START~~ +int +100010 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v7; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v8; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v9; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v10; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v11; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v12; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v13; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v15; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v16; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v17; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v18; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v19; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT * FROM test_date_smalldatetime_v20; +GO +~~START~~ +int +10 +~~END~~ + + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO +~~START~~ +text +on +~~END~~ + diff --git a/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.sql b/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.sql new file mode 100644 index 0000000000..e56a71aec0 --- /dev/null +++ b/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.sql @@ -0,0 +1,246 @@ +DROP PROCEDURE test_smalldatetime_date_p1; +GO + +DROP PROCEDURE test_smalldatetime_date_p2; +GO + +DROP PROCEDURE test_smalldatetime_date_p3; +GO + +DROP PROCEDURE test_smalldatetime_date_p4; +GO + +DROP PROCEDURE test_smalldatetime_date_p5; +GO + +DROP PROCEDURE test_smalldatetime_date_p6; +GO + +DROP PROCEDURE test_smalldatetime_date_p7; +GO + +DROP PROCEDURE test_smalldatetime_date_p8; +GO + +DROP PROCEDURE test_smalldatetime_date_p9; +GO + +DROP PROCEDURE test_smalldatetime_date_p10; +GO + +DROP PROCEDURE test_smalldatetime_date_p11; +GO + +DROP PROCEDURE test_smalldatetime_date_p12; +GO + +DROP PROCEDURE test_smalldatetime_date_p13; +GO + +DROP PROCEDURE test_smalldatetime_date_p14; +GO + +DROP PROCEDURE test_smalldatetime_date_p15; +GO + +DROP PROCEDURE test_smalldatetime_date_p16; +GO + +DROP PROCEDURE test_smalldatetime_date_p17; +GO + +DROP PROCEDURE test_smalldatetime_date_p18; +GO + +DROP PROCEDURE test_smalldatetime_date_p19; +GO + +DROP PROCEDURE test_smalldatetime_date_p20; +GO + +DROP VIEW test_smalldatetime_date_v1; +GO + +DROP VIEW test_smalldatetime_date_v2; +GO + +DROP VIEW test_smalldatetime_date_v3; +GO + +DROP VIEW test_smalldatetime_date_v4; +GO + +DROP VIEW test_smalldatetime_date_v5; +GO + +DROP VIEW test_smalldatetime_date_v6; +GO + +DROP VIEW test_smalldatetime_date_v7; +GO + +DROP VIEW test_smalldatetime_date_v8; +GO + +DROP VIEW test_smalldatetime_date_v9; +GO + +DROP VIEW test_smalldatetime_date_v10; +GO + +DROP VIEW test_smalldatetime_date_v11; +GO + +DROP VIEW test_smalldatetime_date_v12; +GO + +DROP VIEW test_smalldatetime_date_v13; +GO + +DROP VIEW test_smalldatetime_date_v14; +GO + +DROP VIEW test_smalldatetime_date_v15; +GO + +DROP VIEW test_smalldatetime_date_v16; +GO + +DROP VIEW test_smalldatetime_date_v17; +GO + +DROP VIEW test_smalldatetime_date_v18; +GO + +DROP VIEW test_smalldatetime_date_v19; +GO + +DROP VIEW test_smalldatetime_date_v20; +GO + +DROP INDEX smalldate_date_cmp_ind1 on smalldate_date_cmp_t1; +GO + +DROP TABLE smalldate_date_cmp_t1; +GO + +-- tests for index on date column +DROP PROCEDURE test_date_smalldatetime_p1; +GO + +DROP PROCEDURE test_date_smalldatetime_p2; +GO + +DROP PROCEDURE test_date_smalldatetime_p3; +GO + +DROP PROCEDURE test_date_smalldatetime_p4; +GO + +DROP PROCEDURE test_date_smalldatetime_p5; +GO + +DROP PROCEDURE test_date_smalldatetime_p6; +GO + +DROP PROCEDURE test_date_smalldatetime_p7; +GO + +DROP PROCEDURE test_date_smalldatetime_p8; +GO + +DROP PROCEDURE test_date_smalldatetime_p9; +GO + +DROP PROCEDURE test_date_smalldatetime_p10; +GO + +DROP PROCEDURE test_date_smalldatetime_p11; +GO + +DROP PROCEDURE test_date_smalldatetime_p12; +GO + +DROP PROCEDURE test_date_smalldatetime_p13; +GO + +DROP PROCEDURE test_date_smalldatetime_p15; +GO + +DROP PROCEDURE test_date_smalldatetime_p16; +GO + +DROP PROCEDURE test_date_smalldatetime_p17; +GO + +DROP PROCEDURE test_date_smalldatetime_p18; +GO + +DROP PROCEDURE test_date_smalldatetime_p19; +GO + +DROP PROCEDURE test_date_smalldatetime_p20; +GO + +DROP VIEW test_date_smalldatetime_v1; +GO + +DROP VIEW test_date_smalldatetime_v2; +GO + +DROP VIEW test_date_smalldatetime_v3; +GO + +DROP VIEW test_date_smalldatetime_v4; +GO + +DROP VIEW test_date_smalldatetime_v5; +GO + +DROP VIEW test_date_smalldatetime_v6; +GO + +DROP VIEW test_date_smalldatetime_v7; +GO + +DROP VIEW test_date_smalldatetime_v8; +GO + +DROP VIEW test_date_smalldatetime_v9; +GO + +DROP VIEW test_date_smalldatetime_v10; +GO + +DROP VIEW test_date_smalldatetime_v11; +GO + +DROP VIEW test_date_smalldatetime_v12; +GO + +DROP VIEW test_date_smalldatetime_v13; +GO + +DROP VIEW test_date_smalldatetime_v15; +GO + +DROP VIEW test_date_smalldatetime_v16; +GO + +DROP VIEW test_date_smalldatetime_v17; +GO + +DROP VIEW test_date_smalldatetime_v18; +GO + +DROP VIEW test_date_smalldatetime_v19; +GO + +DROP VIEW test_date_smalldatetime_v20; +GO + +DROP INDEX date_smalldatetime_cmp_ind1 on date_smalldatetime_cmp_t1; +GO + +DROP TABLE date_smalldatetime_cmp_t1; +GO diff --git a/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.sql b/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.sql new file mode 100644 index 0000000000..0b8692dfd1 --- /dev/null +++ b/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare.sql @@ -0,0 +1,360 @@ +CREATE TABLE smalldate_date_cmp_t1 ( + smalldatetime_col SMALLDATETIME +) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-13 14:30:00' as smalldatetime) from generate_series(1, 10) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-15 14:30:00' as smalldatetime) from generate_series(1, 100000) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-17 14:30:00' as smalldatetime) from generate_series(1, 10) +GO + +CREATE NONCLUSTERED INDEX smalldate_date_cmp_ind1 ON smalldate_date_cmp_t1 +( + smalldatetime_col ASC +) +GO + +-- seq scan +CREATE PROCEDURE test_smalldatetime_date_p1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE PROCEDURE test_smalldatetime_date_p7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE PROCEDURE test_smalldatetime_date_p15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- seq scan +CREATE VIEW test_smalldatetime_date_v1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE VIEW test_smalldatetime_date_v7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE VIEW test_smalldatetime_date_v15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- Creating index on date +-- FIX ME: Following test cases are for the index +-- created on date column, which will not choose +-- index clause when comparison between date +-- and smalldatetime. +CREATE TABLE date_smalldatetime_cmp_t1 ( + date_col DATE +) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-13' as date) from generate_series(1, 10) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-15' as date) from generate_series(1, 100000) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-17' as date) from generate_series(1, 10) +GO + +CREATE NONCLUSTERED INDEX date_smalldatetime_cmp_ind1 ON date_smalldatetime_cmp_t1 +( + date_col ASC +) +GO + +CREATE PROCEDURE test_date_smalldatetime_p1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE VIEW test_date_smalldatetime_v16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE VIEW test_date_smalldatetime_v19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE VIEW test_date_smalldatetime_v20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO diff --git a/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.mix b/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.mix new file mode 100644 index 0000000000..cd94e157ff --- /dev/null +++ b/test/JDBC/input/smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify.mix @@ -0,0 +1,804 @@ +-- psql +ANALYZE master_dbo.smalldate_date_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +SELECT set_config('debug_parallel_query', '0', false); +GO +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +-- ORDER BY clause +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) ORDER BY smalldatetime_col; +GO + +-- testing with joins +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col < s2.smalldatetime_col +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col > s2.smalldatetime_col; +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col <= s2.smalldatetime_col +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col >= s2.smalldatetime_col; +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col = s2.smalldatetime_col +GO + +EXEC test_smalldatetime_date_p1; +GO + +EXEC test_smalldatetime_date_p2; +GO + +EXEC test_smalldatetime_date_p3; +GO + +EXEC test_smalldatetime_date_p4; +GO + +EXEC test_smalldatetime_date_p5; +GO + +EXEC test_smalldatetime_date_p6; +GO + +EXEC test_smalldatetime_date_p7; +GO + +EXEC test_smalldatetime_date_p8; +GO + +EXEC test_smalldatetime_date_p9; +GO + +EXEC test_smalldatetime_date_p10; +GO + +EXEC test_smalldatetime_date_p11; +GO + +EXEC test_smalldatetime_date_p12; +GO + +EXEC test_smalldatetime_date_p13; +GO + +EXEC test_smalldatetime_date_p14; +GO + +EXEC test_smalldatetime_date_p15; +GO + +EXEC test_smalldatetime_date_p16; +GO + +EXEC test_smalldatetime_date_p17; +GO + +EXEC test_smalldatetime_date_p18; +GO + +EXEC test_smalldatetime_date_p19; +GO + +EXEC test_smalldatetime_date_p20; +GO + +SELECT * FROM test_smalldatetime_date_v1; +GO + +SELECT * FROM test_smalldatetime_date_v2; +GO + +SELECT * FROM test_smalldatetime_date_v3; +GO + +SELECT * FROM test_smalldatetime_date_v4; +GO + +SELECT * FROM test_smalldatetime_date_v5; +GO + +SELECT * FROM test_smalldatetime_date_v6; +GO + +SELECT * FROM test_smalldatetime_date_v7; +GO + +SELECT * FROM test_smalldatetime_date_v8; +GO + +SELECT * FROM test_smalldatetime_date_v9; +GO + +SELECT * FROM test_smalldatetime_date_v10; +GO + +SELECT * FROM test_smalldatetime_date_v11; +GO + +SELECT * FROM test_smalldatetime_date_v12; +GO + +SELECT * FROM test_smalldatetime_date_v13; +GO + +SELECT * FROM test_smalldatetime_date_v14; +GO + +SELECT * FROM test_smalldatetime_date_v15; +GO + +SELECT * FROM test_smalldatetime_date_v16; +GO + +SELECT * FROM test_smalldatetime_date_v17; +GO + +SELECT * FROM test_smalldatetime_date_v18; +GO + +SELECT * FROM test_smalldatetime_date_v19; +GO + +SELECT * FROM test_smalldatetime_date_v20; +GO + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +EXEC test_smalldatetime_date_p1; +GO + +EXEC test_smalldatetime_date_p2; +GO + +EXEC test_smalldatetime_date_p3; +GO + +EXEC test_smalldatetime_date_p4; +GO + +EXEC test_smalldatetime_date_p5; +GO + +EXEC test_smalldatetime_date_p6; +GO + +EXEC test_smalldatetime_date_p7; +GO + +EXEC test_smalldatetime_date_p8; +GO + +EXEC test_smalldatetime_date_p9; +GO + +EXEC test_smalldatetime_date_p10; +GO + +EXEC test_smalldatetime_date_p11; +GO + +EXEC test_smalldatetime_date_p12; +GO + +EXEC test_smalldatetime_date_p13; +GO + +EXEC test_smalldatetime_date_p14; +GO + +EXEC test_smalldatetime_date_p15; +GO + +EXEC test_smalldatetime_date_p16; +GO + +EXEC test_smalldatetime_date_p17; +GO + +EXEC test_smalldatetime_date_p18; +GO + +EXEC test_smalldatetime_date_p19; +GO + +EXEC test_smalldatetime_date_p20; +GO + +SELECT * FROM test_smalldatetime_date_v1; +GO + +SELECT * FROM test_smalldatetime_date_v2; +GO + +SELECT * FROM test_smalldatetime_date_v3; +GO + +SELECT * FROM test_smalldatetime_date_v4; +GO + +SELECT * FROM test_smalldatetime_date_v5; +GO + +SELECT * FROM test_smalldatetime_date_v6; +GO + +SELECT * FROM test_smalldatetime_date_v7; +GO + +SELECT * FROM test_smalldatetime_date_v8; +GO + +SELECT * FROM test_smalldatetime_date_v9; +GO + +SELECT * FROM test_smalldatetime_date_v10; +GO + +SELECT * FROM test_smalldatetime_date_v11; +GO + +SELECT * FROM test_smalldatetime_date_v12; +GO + +SELECT * FROM test_smalldatetime_date_v13; +GO + +SELECT * FROM test_smalldatetime_date_v14; +GO + +SELECT * FROM test_smalldatetime_date_v15; +GO + +SELECT * FROM test_smalldatetime_date_v16; +GO + +SELECT * FROM test_smalldatetime_date_v17; +GO + +SELECT * FROM test_smalldatetime_date_v18; +GO + +SELECT * FROM test_smalldatetime_date_v19; +GO + +SELECT * FROM test_smalldatetime_date_v20; +GO + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO + +-- tests for index on date column +-- psql +ANALYZE master_dbo.date_smalldatetime_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +SELECT set_config('debug_parallel_query', '0', false); +GO +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +EXEC test_date_smalldatetime_p1; +GO + +EXEC test_date_smalldatetime_p2; +GO + +EXEC test_date_smalldatetime_p3; +GO + +EXEC test_date_smalldatetime_p4; +GO + +EXEC test_date_smalldatetime_p5; +GO + +EXEC test_date_smalldatetime_p6; +GO + +EXEC test_date_smalldatetime_p7; +GO + +EXEC test_date_smalldatetime_p8; +GO + +EXEC test_date_smalldatetime_p9; +GO + +EXEC test_date_smalldatetime_p10; +GO + +EXEC test_date_smalldatetime_p11; +GO + +EXEC test_date_smalldatetime_p12; +GO + +EXEC test_date_smalldatetime_p13; +GO + +EXEC test_date_smalldatetime_p15; +GO + +EXEC test_date_smalldatetime_p16; +GO + +EXEC test_date_smalldatetime_p17; +GO + +EXEC test_date_smalldatetime_p18; +GO + +EXEC test_date_smalldatetime_p19; +GO + +EXEC test_date_smalldatetime_p20; +GO + +SELECT * FROM test_date_smalldatetime_v1; +GO + +SELECT * FROM test_date_smalldatetime_v2; +GO + +SELECT * FROM test_date_smalldatetime_v3; +GO + +SELECT * FROM test_date_smalldatetime_v4; +GO + +SELECT * FROM test_date_smalldatetime_v5; +GO + +SELECT * FROM test_date_smalldatetime_v6; +GO + +SELECT * FROM test_date_smalldatetime_v7; +GO + +SELECT * FROM test_date_smalldatetime_v8; +GO + +SELECT * FROM test_date_smalldatetime_v9; +GO + +SELECT * FROM test_date_smalldatetime_v10; +GO + +SELECT * FROM test_date_smalldatetime_v11; +GO + +SELECT * FROM test_date_smalldatetime_v12; +GO + +SELECT * FROM test_date_smalldatetime_v13; +GO + +SELECT * FROM test_date_smalldatetime_v15; +GO + +SELECT * FROM test_date_smalldatetime_v16; +GO + +SELECT * FROM test_date_smalldatetime_v17; +GO + +SELECT * FROM test_date_smalldatetime_v18; +GO + +SELECT * FROM test_date_smalldatetime_v19; +GO + +SELECT * FROM test_date_smalldatetime_v20; +GO + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +EXEC test_date_smalldatetime_p1; +GO + +EXEC test_date_smalldatetime_p2; +GO + +EXEC test_date_smalldatetime_p3; +GO + +EXEC test_date_smalldatetime_p4; +GO + +EXEC test_date_smalldatetime_p5; +GO + +EXEC test_date_smalldatetime_p6; +GO + +EXEC test_date_smalldatetime_p7; +GO + +EXEC test_date_smalldatetime_p8; +GO + +EXEC test_date_smalldatetime_p9; +GO + +EXEC test_date_smalldatetime_p10; +GO + +EXEC test_date_smalldatetime_p11; +GO + +EXEC test_date_smalldatetime_p12; +GO + +EXEC test_date_smalldatetime_p13; +GO + +EXEC test_date_smalldatetime_p15; +GO + +EXEC test_date_smalldatetime_p16; +GO + +EXEC test_date_smalldatetime_p17; +GO + +EXEC test_date_smalldatetime_p18; +GO + +EXEC test_date_smalldatetime_p19; +GO + +EXEC test_date_smalldatetime_p20; +GO + +SELECT * FROM test_date_smalldatetime_v1; +GO + +SELECT * FROM test_date_smalldatetime_v2; +GO + +SELECT * FROM test_date_smalldatetime_v3; +GO + +SELECT * FROM test_date_smalldatetime_v4; +GO + +SELECT * FROM test_date_smalldatetime_v5; +GO + +SELECT * FROM test_date_smalldatetime_v6; +GO + +SELECT * FROM test_date_smalldatetime_v7; +GO + +SELECT * FROM test_date_smalldatetime_v8; +GO + +SELECT * FROM test_date_smalldatetime_v9; +GO + +SELECT * FROM test_date_smalldatetime_v10; +GO + +SELECT * FROM test_date_smalldatetime_v11; +GO + +SELECT * FROM test_date_smalldatetime_v12; +GO + +SELECT * FROM test_date_smalldatetime_v13; +GO + +SELECT * FROM test_date_smalldatetime_v15; +GO + +SELECT * FROM test_date_smalldatetime_v16; +GO + +SELECT * FROM test_date_smalldatetime_v17; +GO + +SELECT * FROM test_date_smalldatetime_v18; +GO + +SELECT * FROM test_date_smalldatetime_v19; +GO + +SELECT * FROM test_date_smalldatetime_v20; +GO + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO diff --git a/test/JDBC/input/smalldatetime_date_cmp-vu-cleanup.sql b/test/JDBC/input/smalldatetime_date_cmp-vu-cleanup.sql new file mode 100644 index 0000000000..e56a71aec0 --- /dev/null +++ b/test/JDBC/input/smalldatetime_date_cmp-vu-cleanup.sql @@ -0,0 +1,246 @@ +DROP PROCEDURE test_smalldatetime_date_p1; +GO + +DROP PROCEDURE test_smalldatetime_date_p2; +GO + +DROP PROCEDURE test_smalldatetime_date_p3; +GO + +DROP PROCEDURE test_smalldatetime_date_p4; +GO + +DROP PROCEDURE test_smalldatetime_date_p5; +GO + +DROP PROCEDURE test_smalldatetime_date_p6; +GO + +DROP PROCEDURE test_smalldatetime_date_p7; +GO + +DROP PROCEDURE test_smalldatetime_date_p8; +GO + +DROP PROCEDURE test_smalldatetime_date_p9; +GO + +DROP PROCEDURE test_smalldatetime_date_p10; +GO + +DROP PROCEDURE test_smalldatetime_date_p11; +GO + +DROP PROCEDURE test_smalldatetime_date_p12; +GO + +DROP PROCEDURE test_smalldatetime_date_p13; +GO + +DROP PROCEDURE test_smalldatetime_date_p14; +GO + +DROP PROCEDURE test_smalldatetime_date_p15; +GO + +DROP PROCEDURE test_smalldatetime_date_p16; +GO + +DROP PROCEDURE test_smalldatetime_date_p17; +GO + +DROP PROCEDURE test_smalldatetime_date_p18; +GO + +DROP PROCEDURE test_smalldatetime_date_p19; +GO + +DROP PROCEDURE test_smalldatetime_date_p20; +GO + +DROP VIEW test_smalldatetime_date_v1; +GO + +DROP VIEW test_smalldatetime_date_v2; +GO + +DROP VIEW test_smalldatetime_date_v3; +GO + +DROP VIEW test_smalldatetime_date_v4; +GO + +DROP VIEW test_smalldatetime_date_v5; +GO + +DROP VIEW test_smalldatetime_date_v6; +GO + +DROP VIEW test_smalldatetime_date_v7; +GO + +DROP VIEW test_smalldatetime_date_v8; +GO + +DROP VIEW test_smalldatetime_date_v9; +GO + +DROP VIEW test_smalldatetime_date_v10; +GO + +DROP VIEW test_smalldatetime_date_v11; +GO + +DROP VIEW test_smalldatetime_date_v12; +GO + +DROP VIEW test_smalldatetime_date_v13; +GO + +DROP VIEW test_smalldatetime_date_v14; +GO + +DROP VIEW test_smalldatetime_date_v15; +GO + +DROP VIEW test_smalldatetime_date_v16; +GO + +DROP VIEW test_smalldatetime_date_v17; +GO + +DROP VIEW test_smalldatetime_date_v18; +GO + +DROP VIEW test_smalldatetime_date_v19; +GO + +DROP VIEW test_smalldatetime_date_v20; +GO + +DROP INDEX smalldate_date_cmp_ind1 on smalldate_date_cmp_t1; +GO + +DROP TABLE smalldate_date_cmp_t1; +GO + +-- tests for index on date column +DROP PROCEDURE test_date_smalldatetime_p1; +GO + +DROP PROCEDURE test_date_smalldatetime_p2; +GO + +DROP PROCEDURE test_date_smalldatetime_p3; +GO + +DROP PROCEDURE test_date_smalldatetime_p4; +GO + +DROP PROCEDURE test_date_smalldatetime_p5; +GO + +DROP PROCEDURE test_date_smalldatetime_p6; +GO + +DROP PROCEDURE test_date_smalldatetime_p7; +GO + +DROP PROCEDURE test_date_smalldatetime_p8; +GO + +DROP PROCEDURE test_date_smalldatetime_p9; +GO + +DROP PROCEDURE test_date_smalldatetime_p10; +GO + +DROP PROCEDURE test_date_smalldatetime_p11; +GO + +DROP PROCEDURE test_date_smalldatetime_p12; +GO + +DROP PROCEDURE test_date_smalldatetime_p13; +GO + +DROP PROCEDURE test_date_smalldatetime_p15; +GO + +DROP PROCEDURE test_date_smalldatetime_p16; +GO + +DROP PROCEDURE test_date_smalldatetime_p17; +GO + +DROP PROCEDURE test_date_smalldatetime_p18; +GO + +DROP PROCEDURE test_date_smalldatetime_p19; +GO + +DROP PROCEDURE test_date_smalldatetime_p20; +GO + +DROP VIEW test_date_smalldatetime_v1; +GO + +DROP VIEW test_date_smalldatetime_v2; +GO + +DROP VIEW test_date_smalldatetime_v3; +GO + +DROP VIEW test_date_smalldatetime_v4; +GO + +DROP VIEW test_date_smalldatetime_v5; +GO + +DROP VIEW test_date_smalldatetime_v6; +GO + +DROP VIEW test_date_smalldatetime_v7; +GO + +DROP VIEW test_date_smalldatetime_v8; +GO + +DROP VIEW test_date_smalldatetime_v9; +GO + +DROP VIEW test_date_smalldatetime_v10; +GO + +DROP VIEW test_date_smalldatetime_v11; +GO + +DROP VIEW test_date_smalldatetime_v12; +GO + +DROP VIEW test_date_smalldatetime_v13; +GO + +DROP VIEW test_date_smalldatetime_v15; +GO + +DROP VIEW test_date_smalldatetime_v16; +GO + +DROP VIEW test_date_smalldatetime_v17; +GO + +DROP VIEW test_date_smalldatetime_v18; +GO + +DROP VIEW test_date_smalldatetime_v19; +GO + +DROP VIEW test_date_smalldatetime_v20; +GO + +DROP INDEX date_smalldatetime_cmp_ind1 on date_smalldatetime_cmp_t1; +GO + +DROP TABLE date_smalldatetime_cmp_t1; +GO diff --git a/test/JDBC/input/smalldatetime_date_cmp-vu-prepare.sql b/test/JDBC/input/smalldatetime_date_cmp-vu-prepare.sql new file mode 100644 index 0000000000..0b8692dfd1 --- /dev/null +++ b/test/JDBC/input/smalldatetime_date_cmp-vu-prepare.sql @@ -0,0 +1,360 @@ +CREATE TABLE smalldate_date_cmp_t1 ( + smalldatetime_col SMALLDATETIME +) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-13 14:30:00' as smalldatetime) from generate_series(1, 10) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-15 14:30:00' as smalldatetime) from generate_series(1, 100000) +GO + +INSERT INTO smalldate_date_cmp_t1 (smalldatetime_col) SELECT cast('2023-06-17 14:30:00' as smalldatetime) from generate_series(1, 10) +GO + +CREATE NONCLUSTERED INDEX smalldate_date_cmp_ind1 ON smalldate_date_cmp_t1 +( + smalldatetime_col ASC +) +GO + +-- seq scan +CREATE PROCEDURE test_smalldatetime_date_p1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE PROCEDURE test_smalldatetime_date_p7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE PROCEDURE test_smalldatetime_date_p14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE PROCEDURE test_smalldatetime_date_p15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE PROCEDURE test_smalldatetime_date_p20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- seq scan +CREATE VIEW test_smalldatetime_date_v1 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v2 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v3 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v4 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v5 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v6 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +CREATE VIEW test_smalldatetime_date_v7 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v8 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v9 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v10 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v11 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v12 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v13 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +CREATE VIEW test_smalldatetime_date_v14 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +CREATE VIEW test_smalldatetime_date_v15 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v16 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v17 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v18 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v19 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +CREATE VIEW test_smalldatetime_date_v20 AS +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +-- Creating index on date +-- FIX ME: Following test cases are for the index +-- created on date column, which will not choose +-- index clause when comparison between date +-- and smalldatetime. +CREATE TABLE date_smalldatetime_cmp_t1 ( + date_col DATE +) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-13' as date) from generate_series(1, 10) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-15' as date) from generate_series(1, 100000) +GO + +INSERT INTO date_smalldatetime_cmp_t1 (date_col) SELECT cast('2023-06-17' as date) from generate_series(1, 10) +GO + +CREATE NONCLUSTERED INDEX date_smalldatetime_cmp_ind1 ON date_smalldatetime_cmp_t1 +( + date_col ASC +) +GO + +CREATE PROCEDURE test_date_smalldatetime_p1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE PROCEDURE test_date_smalldatetime_p15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE PROCEDURE test_date_smalldatetime_p20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v1 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v2 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v3 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v4 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v5 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v6 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +CREATE VIEW test_date_smalldatetime_v7 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v8 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v9 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v10 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v11 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v12 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v13 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +CREATE VIEW test_date_smalldatetime_v15 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +CREATE VIEW test_date_smalldatetime_v16 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v17 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +CREATE VIEW test_date_smalldatetime_v18 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +CREATE VIEW test_date_smalldatetime_v19 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +CREATE VIEW test_date_smalldatetime_v20 AS +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO diff --git a/test/JDBC/input/smalldatetime_date_cmp-vu-verify.mix b/test/JDBC/input/smalldatetime_date_cmp-vu-verify.mix new file mode 100644 index 0000000000..cd94e157ff --- /dev/null +++ b/test/JDBC/input/smalldatetime_date_cmp-vu-verify.mix @@ -0,0 +1,804 @@ +-- psql +ANALYZE master_dbo.smalldate_date_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +SELECT set_config('debug_parallel_query', '0', false); +GO +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +-- ORDER BY clause +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE) ORDER BY smalldatetime_col; +GO + +SELECT smalldatetime_col FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE) ORDER BY smalldatetime_col; +GO + +-- testing with joins +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col < s2.smalldatetime_col +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col > s2.smalldatetime_col; +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col <= s2.smalldatetime_col +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col >= s2.smalldatetime_col; +GO + +SELECT s1.smalldatetime_col FROM smalldate_date_cmp_t1 s1 JOIN smalldate_date_cmp_t1 s2 ON s1.smalldatetime_col = s2.smalldatetime_col +GO + +EXEC test_smalldatetime_date_p1; +GO + +EXEC test_smalldatetime_date_p2; +GO + +EXEC test_smalldatetime_date_p3; +GO + +EXEC test_smalldatetime_date_p4; +GO + +EXEC test_smalldatetime_date_p5; +GO + +EXEC test_smalldatetime_date_p6; +GO + +EXEC test_smalldatetime_date_p7; +GO + +EXEC test_smalldatetime_date_p8; +GO + +EXEC test_smalldatetime_date_p9; +GO + +EXEC test_smalldatetime_date_p10; +GO + +EXEC test_smalldatetime_date_p11; +GO + +EXEC test_smalldatetime_date_p12; +GO + +EXEC test_smalldatetime_date_p13; +GO + +EXEC test_smalldatetime_date_p14; +GO + +EXEC test_smalldatetime_date_p15; +GO + +EXEC test_smalldatetime_date_p16; +GO + +EXEC test_smalldatetime_date_p17; +GO + +EXEC test_smalldatetime_date_p18; +GO + +EXEC test_smalldatetime_date_p19; +GO + +EXEC test_smalldatetime_date_p20; +GO + +SELECT * FROM test_smalldatetime_date_v1; +GO + +SELECT * FROM test_smalldatetime_date_v2; +GO + +SELECT * FROM test_smalldatetime_date_v3; +GO + +SELECT * FROM test_smalldatetime_date_v4; +GO + +SELECT * FROM test_smalldatetime_date_v5; +GO + +SELECT * FROM test_smalldatetime_date_v6; +GO + +SELECT * FROM test_smalldatetime_date_v7; +GO + +SELECT * FROM test_smalldatetime_date_v8; +GO + +SELECT * FROM test_smalldatetime_date_v9; +GO + +SELECT * FROM test_smalldatetime_date_v10; +GO + +SELECT * FROM test_smalldatetime_date_v11; +GO + +SELECT * FROM test_smalldatetime_date_v12; +GO + +SELECT * FROM test_smalldatetime_date_v13; +GO + +SELECT * FROM test_smalldatetime_date_v14; +GO + +SELECT * FROM test_smalldatetime_date_v15; +GO + +SELECT * FROM test_smalldatetime_date_v16; +GO + +SELECT * FROM test_smalldatetime_date_v17; +GO + +SELECT * FROM test_smalldatetime_date_v18; +GO + +SELECT * FROM test_smalldatetime_date_v19; +GO + +SELECT * FROM test_smalldatetime_date_v20; +GO + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +-- seq scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-13' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-15' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <> CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-13' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-15' AS DATE) <> smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) <> smalldatetime_col; +GO + +-- index scan +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col < CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-14' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col <= CAST('2023-06-18' AS DATE) AND smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col = CAST('2023-06-17' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col > CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col >= CAST('2023-06-16' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) > smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-14' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col AND CAST('2023-06-18' AS DATE) >= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-17' AS DATE) = smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) < smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE CAST('2023-06-16' AS DATE) <= smalldatetime_col; +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col BETWEEN CAST('2023-06-16' AS DATE) AND CAST('2023-06-18' AS DATE); +GO + +SELECT COUNT(*) FROM smalldate_date_cmp_t1 WHERE smalldatetime_col IS NULL +GO + +EXEC test_smalldatetime_date_p1; +GO + +EXEC test_smalldatetime_date_p2; +GO + +EXEC test_smalldatetime_date_p3; +GO + +EXEC test_smalldatetime_date_p4; +GO + +EXEC test_smalldatetime_date_p5; +GO + +EXEC test_smalldatetime_date_p6; +GO + +EXEC test_smalldatetime_date_p7; +GO + +EXEC test_smalldatetime_date_p8; +GO + +EXEC test_smalldatetime_date_p9; +GO + +EXEC test_smalldatetime_date_p10; +GO + +EXEC test_smalldatetime_date_p11; +GO + +EXEC test_smalldatetime_date_p12; +GO + +EXEC test_smalldatetime_date_p13; +GO + +EXEC test_smalldatetime_date_p14; +GO + +EXEC test_smalldatetime_date_p15; +GO + +EXEC test_smalldatetime_date_p16; +GO + +EXEC test_smalldatetime_date_p17; +GO + +EXEC test_smalldatetime_date_p18; +GO + +EXEC test_smalldatetime_date_p19; +GO + +EXEC test_smalldatetime_date_p20; +GO + +SELECT * FROM test_smalldatetime_date_v1; +GO + +SELECT * FROM test_smalldatetime_date_v2; +GO + +SELECT * FROM test_smalldatetime_date_v3; +GO + +SELECT * FROM test_smalldatetime_date_v4; +GO + +SELECT * FROM test_smalldatetime_date_v5; +GO + +SELECT * FROM test_smalldatetime_date_v6; +GO + +SELECT * FROM test_smalldatetime_date_v7; +GO + +SELECT * FROM test_smalldatetime_date_v8; +GO + +SELECT * FROM test_smalldatetime_date_v9; +GO + +SELECT * FROM test_smalldatetime_date_v10; +GO + +SELECT * FROM test_smalldatetime_date_v11; +GO + +SELECT * FROM test_smalldatetime_date_v12; +GO + +SELECT * FROM test_smalldatetime_date_v13; +GO + +SELECT * FROM test_smalldatetime_date_v14; +GO + +SELECT * FROM test_smalldatetime_date_v15; +GO + +SELECT * FROM test_smalldatetime_date_v16; +GO + +SELECT * FROM test_smalldatetime_date_v17; +GO + +SELECT * FROM test_smalldatetime_date_v18; +GO + +SELECT * FROM test_smalldatetime_date_v19; +GO + +SELECT * FROM test_smalldatetime_date_v20; +GO + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO + +-- tests for index on date column +-- psql +ANALYZE master_dbo.date_smalldatetime_cmp_t1; +GO + +-- tsql +select set_config('max_parallel_workers_per_gather', '0', false); +GO +SELECT set_config('debug_parallel_query', '0', false); +GO +SELECT set_config('babelfishpg_tsql.explain_costs', 'off', false) +GO + +SET BABELFISH_SHOWPLAN_ALL ON +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +EXEC test_date_smalldatetime_p1; +GO + +EXEC test_date_smalldatetime_p2; +GO + +EXEC test_date_smalldatetime_p3; +GO + +EXEC test_date_smalldatetime_p4; +GO + +EXEC test_date_smalldatetime_p5; +GO + +EXEC test_date_smalldatetime_p6; +GO + +EXEC test_date_smalldatetime_p7; +GO + +EXEC test_date_smalldatetime_p8; +GO + +EXEC test_date_smalldatetime_p9; +GO + +EXEC test_date_smalldatetime_p10; +GO + +EXEC test_date_smalldatetime_p11; +GO + +EXEC test_date_smalldatetime_p12; +GO + +EXEC test_date_smalldatetime_p13; +GO + +EXEC test_date_smalldatetime_p15; +GO + +EXEC test_date_smalldatetime_p16; +GO + +EXEC test_date_smalldatetime_p17; +GO + +EXEC test_date_smalldatetime_p18; +GO + +EXEC test_date_smalldatetime_p19; +GO + +EXEC test_date_smalldatetime_p20; +GO + +SELECT * FROM test_date_smalldatetime_v1; +GO + +SELECT * FROM test_date_smalldatetime_v2; +GO + +SELECT * FROM test_date_smalldatetime_v3; +GO + +SELECT * FROM test_date_smalldatetime_v4; +GO + +SELECT * FROM test_date_smalldatetime_v5; +GO + +SELECT * FROM test_date_smalldatetime_v6; +GO + +SELECT * FROM test_date_smalldatetime_v7; +GO + +SELECT * FROM test_date_smalldatetime_v8; +GO + +SELECT * FROM test_date_smalldatetime_v9; +GO + +SELECT * FROM test_date_smalldatetime_v10; +GO + +SELECT * FROM test_date_smalldatetime_v11; +GO + +SELECT * FROM test_date_smalldatetime_v12; +GO + +SELECT * FROM test_date_smalldatetime_v13; +GO + +SELECT * FROM test_date_smalldatetime_v15; +GO + +SELECT * FROM test_date_smalldatetime_v16; +GO + +SELECT * FROM test_date_smalldatetime_v17; +GO + +SELECT * FROM test_date_smalldatetime_v18; +GO + +SELECT * FROM test_date_smalldatetime_v19; +GO + +SELECT * FROM test_date_smalldatetime_v20; +GO + +SET BABELFISH_SHOWPLAN_ALL OFF +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-13' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-15' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <> CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-13' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-15' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) <> date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col < CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-14' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col <= CAST('2023-06-18' AS SMALLDATETIME) AND date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col = CAST('2023-06-17' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col > CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col >= CAST('2023-06-16' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) > date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-14' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col AND CAST('2023-06-18' AS SMALLDATETIME) >= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-17' AS SMALLDATETIME) = date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) < date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE CAST('2023-06-16' AS SMALLDATETIME) <= date_col; +GO + +SELECT COUNT(*) FROM date_smalldatetime_cmp_t1 WHERE date_col BETWEEN CAST('2023-06-16' AS SMALLDATETIME) AND CAST('2023-06-18' AS SMALLDATETIME); +GO + +EXEC test_date_smalldatetime_p1; +GO + +EXEC test_date_smalldatetime_p2; +GO + +EXEC test_date_smalldatetime_p3; +GO + +EXEC test_date_smalldatetime_p4; +GO + +EXEC test_date_smalldatetime_p5; +GO + +EXEC test_date_smalldatetime_p6; +GO + +EXEC test_date_smalldatetime_p7; +GO + +EXEC test_date_smalldatetime_p8; +GO + +EXEC test_date_smalldatetime_p9; +GO + +EXEC test_date_smalldatetime_p10; +GO + +EXEC test_date_smalldatetime_p11; +GO + +EXEC test_date_smalldatetime_p12; +GO + +EXEC test_date_smalldatetime_p13; +GO + +EXEC test_date_smalldatetime_p15; +GO + +EXEC test_date_smalldatetime_p16; +GO + +EXEC test_date_smalldatetime_p17; +GO + +EXEC test_date_smalldatetime_p18; +GO + +EXEC test_date_smalldatetime_p19; +GO + +EXEC test_date_smalldatetime_p20; +GO + +SELECT * FROM test_date_smalldatetime_v1; +GO + +SELECT * FROM test_date_smalldatetime_v2; +GO + +SELECT * FROM test_date_smalldatetime_v3; +GO + +SELECT * FROM test_date_smalldatetime_v4; +GO + +SELECT * FROM test_date_smalldatetime_v5; +GO + +SELECT * FROM test_date_smalldatetime_v6; +GO + +SELECT * FROM test_date_smalldatetime_v7; +GO + +SELECT * FROM test_date_smalldatetime_v8; +GO + +SELECT * FROM test_date_smalldatetime_v9; +GO + +SELECT * FROM test_date_smalldatetime_v10; +GO + +SELECT * FROM test_date_smalldatetime_v11; +GO + +SELECT * FROM test_date_smalldatetime_v12; +GO + +SELECT * FROM test_date_smalldatetime_v13; +GO + +SELECT * FROM test_date_smalldatetime_v15; +GO + +SELECT * FROM test_date_smalldatetime_v16; +GO + +SELECT * FROM test_date_smalldatetime_v17; +GO + +SELECT * FROM test_date_smalldatetime_v18; +GO + +SELECT * FROM test_date_smalldatetime_v19; +GO + +SELECT * FROM test_date_smalldatetime_v20; +GO + +SELECT set_config('babelfishpg_tsql.explain_costs', 'on', false) +GO diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index d9897e0367..612d5b0c2e 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -96,6 +96,9 @@ ignore#!#BABEL-2736-before-16_5-vu-cleanup ignore#!#BABEL-2736-before-15_3-vu-prepare ignore#!#BABEL-2736-before-15_3-vu-verify ignore#!#BABEL-2736-before-15_3-vu-cleanup +ignore#!#smalldatetime_date_cmp-13_9-14_6-15_2-vu-prepare +ignore#!#smalldatetime_date_cmp-13_9-14_6-15_2-vu-verify +ignore#!#smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup # These tests are meant for upgrade scenario prior to (potential) 14_5 release ignore#!#BABEL-3147-before-14_5-vu-prepare diff --git a/test/JDBC/upgrade/13_4/schedule b/test/JDBC/upgrade/13_4/schedule index 762c62e19e..bdbb2160fb 100644 --- a/test/JDBC/upgrade/13_4/schedule +++ b/test/JDBC/upgrade/13_4/schedule @@ -251,4 +251,5 @@ space binary-datatype-operators BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5059-before-14_7-or-15_2 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/13_5/schedule b/test/JDBC/upgrade/13_5/schedule index d2921a7adf..62828df979 100644 --- a/test/JDBC/upgrade/13_5/schedule +++ b/test/JDBC/upgrade/13_5/schedule @@ -304,4 +304,5 @@ binary-datatype-operators BABEL-5059-before-14_7-or-15_2 replace-before-15_8-or-16_4 BABEL-CASE_EXPR-before-16_5-or-15_9 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/13_7/schedule b/test/JDBC/upgrade/13_7/schedule index 003a209571..47d360ecec 100644 --- a/test/JDBC/upgrade/13_7/schedule +++ b/test/JDBC/upgrade/13_7/schedule @@ -353,3 +353,5 @@ binary-datatype-operators BABEL-5059-before-14_7-or-15_2 replace-before-15_8-or-16_4 BABEL-CASE_EXPR-before-16_5-or-15_9 +smalldatetime_date_cmp + diff --git a/test/JDBC/upgrade/13_8/schedule b/test/JDBC/upgrade/13_8/schedule index 1ba07c2c2b..42c68b036e 100644 --- a/test/JDBC/upgrade/13_8/schedule +++ b/test/JDBC/upgrade/13_8/schedule @@ -353,3 +353,5 @@ binary-datatype-operators BABEL-5059-before-14_7-or-15_2 replace-before-15_8-or-16_4 BABEL-CASE_EXPR-before-16_5-or-15_9 +smalldatetime_date_cmp + diff --git a/test/JDBC/upgrade/13_9/schedule b/test/JDBC/upgrade/13_9/schedule index 6c96e99210..821d72b349 100644 --- a/test/JDBC/upgrade/13_9/schedule +++ b/test/JDBC/upgrade/13_9/schedule @@ -358,3 +358,5 @@ binary-datatype-operators BABEL-5059-before-14_7-or-15_2 replace-before-15_8-or-16_4 BABEL-CASE_EXPR-before-16_5-or-15_9 +smalldatetime_date_cmp-13_9-14_6-15_2 + diff --git a/test/JDBC/upgrade/14_10/schedule b/test/JDBC/upgrade/14_10/schedule index 02e0de4398..ca3a9d73d3 100644 --- a/test/JDBC/upgrade/14_10/schedule +++ b/test/JDBC/upgrade/14_10/schedule @@ -468,4 +468,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/14_11/schedule b/test/JDBC/upgrade/14_11/schedule index 41fd0e733c..1bd7d3c9bb 100644 --- a/test/JDBC/upgrade/14_11/schedule +++ b/test/JDBC/upgrade/14_11/schedule @@ -466,4 +466,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/14_12/schedule b/test/JDBC/upgrade/14_12/schedule index 76218878bd..87a5b376a6 100644 --- a/test/JDBC/upgrade/14_12/schedule +++ b/test/JDBC/upgrade/14_12/schedule @@ -467,3 +467,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp-13_9-14_6-15_2 + diff --git a/test/JDBC/upgrade/14_13/schedule b/test/JDBC/upgrade/14_13/schedule index 42fd98061d..846be6a741 100644 --- a/test/JDBC/upgrade/14_13/schedule +++ b/test/JDBC/upgrade/14_13/schedule @@ -467,4 +467,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/14_15/schedule b/test/JDBC/upgrade/14_15/schedule index 42fd98061d..8039b8e58f 100644 --- a/test/JDBC/upgrade/14_15/schedule +++ b/test/JDBC/upgrade/14_15/schedule @@ -467,4 +467,4 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 - +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/14_16/schedule b/test/JDBC/upgrade/14_16/schedule index 42fd98061d..e0bb0a11b3 100644 --- a/test/JDBC/upgrade/14_16/schedule +++ b/test/JDBC/upgrade/14_16/schedule @@ -467,4 +467,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp-13_9-14_6-15_2 diff --git a/test/JDBC/upgrade/14_3/schedule b/test/JDBC/upgrade/14_3/schedule index c1cb8c0fe0..a7e9c72757 100644 --- a/test/JDBC/upgrade/14_3/schedule +++ b/test/JDBC/upgrade/14_3/schedule @@ -387,4 +387,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp-13_9-14_6-15_2 diff --git a/test/JDBC/upgrade/14_5/schedule b/test/JDBC/upgrade/14_5/schedule index ed9fd0d828..0783d30cb1 100644 --- a/test/JDBC/upgrade/14_5/schedule +++ b/test/JDBC/upgrade/14_5/schedule @@ -399,4 +399,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp-13_9-14_6-15_2 diff --git a/test/JDBC/upgrade/14_6/schedule b/test/JDBC/upgrade/14_6/schedule index f20969befa..6f43ba4e27 100644 --- a/test/JDBC/upgrade/14_6/schedule +++ b/test/JDBC/upgrade/14_6/schedule @@ -436,4 +436,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp-13_9-14_6-15_2 diff --git a/test/JDBC/upgrade/14_7/schedule b/test/JDBC/upgrade/14_7/schedule index cd9594f401..d890565fc9 100644 --- a/test/JDBC/upgrade/14_7/schedule +++ b/test/JDBC/upgrade/14_7/schedule @@ -458,4 +458,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/14_8/schedule b/test/JDBC/upgrade/14_8/schedule index 4b7cc09543..7e685d5ba1 100644 --- a/test/JDBC/upgrade/14_8/schedule +++ b/test/JDBC/upgrade/14_8/schedule @@ -460,4 +460,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/14_9/schedule b/test/JDBC/upgrade/14_9/schedule index 8557e208af..1038b94795 100644 --- a/test/JDBC/upgrade/14_9/schedule +++ b/test/JDBC/upgrade/14_9/schedule @@ -463,4 +463,5 @@ cast-varchar-to-time xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_1/schedule b/test/JDBC/upgrade/15_1/schedule index 388067f36e..45015737e2 100644 --- a/test/JDBC/upgrade/15_1/schedule +++ b/test/JDBC/upgrade/15_1/schedule @@ -436,4 +436,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-15_3 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_10/schedule b/test/JDBC/upgrade/15_10/schedule index 28dbf0fa5a..439b2b6457 100644 --- a/test/JDBC/upgrade/15_10/schedule +++ b/test/JDBC/upgrade/15_10/schedule @@ -549,4 +549,4 @@ BABEL-5119_before_16_5 BABEL-CASE_EXPR BABEL-5186 BABEL-2736 - +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_11/schedule b/test/JDBC/upgrade/15_11/schedule index 28dbf0fa5a..674c9097e9 100644 --- a/test/JDBC/upgrade/15_11/schedule +++ b/test/JDBC/upgrade/15_11/schedule @@ -549,4 +549,5 @@ BABEL-5119_before_16_5 BABEL-CASE_EXPR BABEL-5186 BABEL-2736 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_2/schedule b/test/JDBC/upgrade/15_2/schedule index ecbf7ac273..daa2d5c4c7 100644 --- a/test/JDBC/upgrade/15_2/schedule +++ b/test/JDBC/upgrade/15_2/schedule @@ -472,4 +472,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-15_3 +smalldatetime_date_cmp-13_9-14_6-15_2 diff --git a/test/JDBC/upgrade/15_3/schedule b/test/JDBC/upgrade/15_3/schedule index 556404f0a8..4c3e836046 100644 --- a/test/JDBC/upgrade/15_3/schedule +++ b/test/JDBC/upgrade/15_3/schedule @@ -491,4 +491,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_4/schedule b/test/JDBC/upgrade/15_4/schedule index 0259940182..886e3aa452 100644 --- a/test/JDBC/upgrade/15_4/schedule +++ b/test/JDBC/upgrade/15_4/schedule @@ -504,4 +504,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_5/schedule b/test/JDBC/upgrade/15_5/schedule index e03acae5b6..389c72a9f2 100644 --- a/test/JDBC/upgrade/15_5/schedule +++ b/test/JDBC/upgrade/15_5/schedule @@ -535,4 +535,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_6/schedule b/test/JDBC/upgrade/15_6/schedule index 84ceeede80..63e1cf1430 100644 --- a/test/JDBC/upgrade/15_6/schedule +++ b/test/JDBC/upgrade/15_6/schedule @@ -550,4 +550,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_7/schedule b/test/JDBC/upgrade/15_7/schedule index 20a9507c12..3a5c7e1c04 100644 --- a/test/JDBC/upgrade/15_7/schedule +++ b/test/JDBC/upgrade/15_7/schedule @@ -558,4 +558,5 @@ GRANT_SCHEMA-before-15_9-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/15_8/schedule b/test/JDBC/upgrade/15_8/schedule index 2215a17e27..7f34b2dc5a 100644 --- a/test/JDBC/upgrade/15_8/schedule +++ b/test/JDBC/upgrade/15_8/schedule @@ -549,4 +549,5 @@ GRANT_SCHEMA-before-15_9-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/16_1/schedule b/test/JDBC/upgrade/16_1/schedule index e0e32c4a44..26e10ce74d 100644 --- a/test/JDBC/upgrade/16_1/schedule +++ b/test/JDBC/upgrade/16_1/schedule @@ -544,4 +544,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/16_2/schedule b/test/JDBC/upgrade/16_2/schedule index de81e526c3..f01d3d3756 100644 --- a/test/JDBC/upgrade/16_2/schedule +++ b/test/JDBC/upgrade/16_2/schedule @@ -558,4 +558,5 @@ xml_exist-before-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/16_3/schedule b/test/JDBC/upgrade/16_3/schedule index aa78010247..2d4c752809 100644 --- a/test/JDBC/upgrade/16_3/schedule +++ b/test/JDBC/upgrade/16_3/schedule @@ -562,3 +562,5 @@ GRANT_SCHEMA-before-15_9-16_5 BABEL-CASE_EXPR-before-16_5-or-15_9 BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp + diff --git a/test/JDBC/upgrade/16_4/schedule b/test/JDBC/upgrade/16_4/schedule index f166b9a976..086e54945e 100644 --- a/test/JDBC/upgrade/16_4/schedule +++ b/test/JDBC/upgrade/16_4/schedule @@ -575,3 +575,5 @@ BABEL-CASE_EXPR-before-16_5-or-15_9 charindex_replace_patindex BABEL-5186 BABEL-2736-before-16_5 +smalldatetime_date_cmp + diff --git a/test/JDBC/upgrade/16_6/schedule b/test/JDBC/upgrade/16_6/schedule index 1eaf79c4f9..1df975b4df 100644 --- a/test/JDBC/upgrade/16_6/schedule +++ b/test/JDBC/upgrade/16_6/schedule @@ -581,4 +581,4 @@ BABEL-CASE_EXPR charindex_replace_patindex BABEL-5186 BABEL-2736 - +smalldatetime_date_cmp diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 0ee423093a..9b3d516db4 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -584,4 +584,5 @@ BABEL-CASE_EXPR charindex_replace_patindex BABEL-5186 BABEL-2736 +smalldatetime_date_cmp diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index 968f532f84..3e7aaa6385 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -300,6 +300,7 @@ Function sys.datalength(text) Function sys.date2datetimeoffset(date) Function sys.date2smalldatetime(date) Function sys.date_bucket_internal_helper(text,integer,boolean,boolean,anyelement) +Function sys.date_smalldatetime_cmp(date,sys.smalldatetime) Function sys.date_sqlvariant(date) Function sys.dateadd_internal(text,integer,anyelement) Function sys.dateadd_internal_datetime(text,integer,anyelement,integer) @@ -605,6 +606,7 @@ Function sys.smalldatetime2time(sys.smalldatetime) Function sys.smalldatetime2timestamptz(sys.smalldatetime) Function sys.smalldatetime2varchar(sys.smalldatetime) Function sys.smalldatetime_cmp(sys.smalldatetime,sys.smalldatetime) +Function sys.smalldatetime_date_cmp(sys.smalldatetime,date) Function sys.smalldatetime_hash(sys.smalldatetime) Function sys.smalldatetime_larger(sys.smalldatetime,sys.smalldatetime) Function sys.smalldatetime_smaller(sys.smalldatetime,sys.smalldatetime) @@ -854,7 +856,6 @@ Operator sys./(sys.smallmoney,sys.tinyint) Operator sys./(sys.tinyint,sys.smallmoney) Operator sys./(sys.tinyint,sys.tinyint) Operator sys.<(bigint,sys.fixeddecimal) -Operator sys.<(date,sys.smalldatetime) Operator sys.<(integer,sys."bit") Operator sys.<(integer,sys.fixeddecimal) Operator sys.<(numeric,sys.fixeddecimal) @@ -867,10 +868,8 @@ Operator sys.<(sys.fixeddecimal,integer) Operator sys.<(sys.fixeddecimal,numeric) Operator sys.<(sys.fixeddecimal,smallint) Operator sys.<(sys.rowversion,sys.rowversion) -Operator sys.<(sys.smalldatetime,date) Operator sys.<(sys.smalldatetime,sys.smalldatetime) Operator sys.<=(bigint,sys.fixeddecimal) -Operator sys.<=(date,sys.smalldatetime) Operator sys.<=(integer,sys."bit") Operator sys.<=(integer,sys.fixeddecimal) Operator sys.<=(numeric,sys.fixeddecimal) @@ -885,12 +884,10 @@ Operator sys.<=(sys.fixeddecimal,numeric) Operator sys.<=(sys.fixeddecimal,smallint) Operator sys.<=(sys.fixeddecimal,sys.fixeddecimal) Operator sys.<=(sys.rowversion,sys.rowversion) -Operator sys.<=(sys.smalldatetime,date) Operator sys.<=(sys.smalldatetime,sys.smalldatetime) Operator sys.<=(sys.sql_variant,sys.sql_variant) Operator sys.<=(sys.uniqueidentifier,sys.uniqueidentifier) Operator sys.<>(bigint,sys.fixeddecimal) -Operator sys.<>(date,sys.smalldatetime) Operator sys.<>(integer,sys."bit") Operator sys.<>(integer,sys.fixeddecimal) Operator sys.<>(numeric,sys.fixeddecimal) @@ -909,12 +906,10 @@ Operator sys.<>(sys.fixeddecimal,sys.fixeddecimal) Operator sys.<>(sys.geography,sys.geography) Operator sys.<>(sys.geometry,sys.geometry) Operator sys.<>(sys.rowversion,sys.rowversion) -Operator sys.<>(sys.smalldatetime,date) Operator sys.<>(sys.smalldatetime,sys.smalldatetime) Operator sys.<>(sys.sql_variant,sys.sql_variant) Operator sys.<>(sys.uniqueidentifier,sys.uniqueidentifier) Operator sys.=(bigint,sys.fixeddecimal) -Operator sys.=(date,sys.smalldatetime) Operator sys.=(integer,sys."bit") Operator sys.=(integer,sys.fixeddecimal) Operator sys.=(numeric,sys.fixeddecimal) @@ -927,10 +922,8 @@ Operator sys.=(sys.fixeddecimal,smallint) Operator sys.=(sys.geography,sys.geography) Operator sys.=(sys.geometry,sys.geometry) Operator sys.=(sys.rowversion,sys.rowversion) -Operator sys.=(sys.smalldatetime,date) Operator sys.=(sys.smalldatetime,sys.smalldatetime) Operator sys.>(bigint,sys.fixeddecimal) -Operator sys.>(date,sys.smalldatetime) Operator sys.>(integer,sys."bit") Operator sys.>(integer,sys.fixeddecimal) Operator sys.>(numeric,sys.fixeddecimal) @@ -947,11 +940,9 @@ Operator sys.>(sys.fixeddecimal,numeric) Operator sys.>(sys.fixeddecimal,smallint) Operator sys.>(sys.fixeddecimal,sys.fixeddecimal) Operator sys.>(sys.rowversion,sys.rowversion) -Operator sys.>(sys.smalldatetime,date) Operator sys.>(sys.smalldatetime,sys.smalldatetime) Operator sys.>(sys.uniqueidentifier,sys.uniqueidentifier) Operator sys.>=(bigint,sys.fixeddecimal) -Operator sys.>=(date,sys.smalldatetime) Operator sys.>=(integer,sys."bit") Operator sys.>=(integer,sys.fixeddecimal) Operator sys.>=(numeric,sys.fixeddecimal) @@ -966,7 +957,6 @@ Operator sys.>=(sys.fixeddecimal,numeric) Operator sys.>=(sys.fixeddecimal,smallint) Operator sys.>=(sys.fixeddecimal,sys.fixeddecimal) Operator sys.>=(sys.rowversion,sys.rowversion) -Operator sys.>=(sys.smalldatetime,date) Operator sys.>=(sys.smalldatetime,sys.smalldatetime) Operator sys.>=(sys.sql_variant,sys.sql_variant) Operator sys.>=(sys.uniqueidentifier,sys.uniqueidentifier)