-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 [email protected] Signed-off-by: yashneet vinayak <[email protected]>
- Loading branch information
1 parent
b9e4d53
commit cd20d5f
Showing
53 changed files
with
10,630 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
BBFPGCMN_MAJOR_VERSION=4 | ||
BBFPGCMN_MINOR_VERSION=4 | ||
BBFPGCMN_MINOR_VERSION=5 | ||
BBFPGCMN_MICRO_VERSION=0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
contrib/babelfishpg_common/sql/upgrades/babelfish_common_helper--4.4.0--4.5.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
2 changes: 2 additions & 0 deletions
2
contrib/babelfishpg_common/sql/upgrades/babelfishpg_common--3.8.0--4.0.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
3 changes: 3 additions & 0 deletions
3
contrib/babelfishpg_common/sql/upgrades/spatial_types--4.4.0--4.5.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
------------------------------------------------------- | ||
---- Include changes related to spatial types here ---- | ||
------------------------------------------------------- |
246 changes: 246 additions & 0 deletions
246
test/JDBC/expected/smalldatetime_date_cmp-13_9-14_6-15_2-vu-cleanup.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.