-
Notifications
You must be signed in to change notification settings - Fork 71
Introduce helper to dump Babelfish operator class defined over built-in data types #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce helper to dump Babelfish operator class defined over built-in data types #346
Conversation
destroyPQExpBuffer(query); | ||
|
||
if (strcasecmp(opclass, "\"sys\".\"int_numeric\"") == 0) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just a thought): Can't we somehow modify the original query in dumpOpclass
function so that it automatically dumps these operator classes which we want to dump? We have already done this in past, for example see fixCursorForBbfTableData
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since pg is not registeting dependency between pg_amop and pg_opclass, its impossible to find member functions/operators using any query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the only problem with this approach is that any change to opclass definition would require pg_dump utility changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! that is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are planning something to bring up this issue with pg community
fe31fbc
into
babelfish-for-postgresql:BABEL_4_X_DEV__PG_16_X
This commit fixes this issue by appropriately defining operator class and operators between int and numeric. This changes also requires engine changes (babelfish-for-postgresql/postgresql_modified_for_babelfish#346) in order to dump these Babelfish defined operator class correctly during pg_upgrade. Task: BABEL-3385 Signed-off-by: Dipesh Dhameliya [email protected]
…in data types (babelfish-for-postgresql#346) Extension changes - babelfish-for-postgresql/babelfish_extensions#2460 There is a bug (described below) in Postgres due to which it does not dump user-defined operator class over built-in data types. This commit fixed that issue by introducing helper function which will dump operator class and all of its members appropriately. Task: BABEL-3385 Signed-off-by: Dipesh Dhameliya [email protected]
…fish-for-postgresql#2460) This commit fixes this issue by appropriately defining operator class and operators between int and numeric. This changes also requires engine changes (babelfish-for-postgresql/postgresql_modified_for_babelfish#346) in order to dump these Babelfish defined operator class correctly during pg_upgrade. Task: BABEL-3385 Signed-off-by: Dipesh Dhameliya [email protected]
…r built-in data types (babelfish-for-postgresql#346)" This reverts commit fe31fbc.
… built-in data types (babelfish-for-postgresql#346) Extension changes - babelfish-for-postgresql/babelfish_extensions#2460 There is a bug (described below) in Postgres due to which it does not dump user-defined operator class over built-in data types. This commit fixed that issue by introducing helper function which will dump operator class and all of its members appropriately. Task: BABEL-3385 Signed-off-by: Dipesh Dhameliya [email protected]
… built-in data types (babelfish-for-postgresql#346) Extension changes - babelfish-for-postgresql/babelfish_extensions#2460 There is a bug (described below) in Postgres due to which it does not dump user-defined operator class over built-in data types. This commit fixed that issue by introducing helper function which will dump operator class and all of its members appropriately. Task: BABEL-3385 Signed-off-by: Dipesh Dhameliya [email protected]
… built-in data types (babelfish-for-postgresql#346) Extension changes - babelfish-for-postgresql/babelfish_extensions#2460 There is a bug (described below) in Postgres due to which it does not dump user-defined operator class over built-in data types. This commit fixed that issue by introducing helper function which will dump operator class and all of its members appropriately. Task: BABEL-3385 Signed-off-by: Dipesh Dhameliya [email protected]
Description
Extension changes - babelfish-for-postgresql/babelfish_extensions#2460
There is a bug (described below) in Postgres due to which it does not dump user-defined operator class over built-in data
types. This commit fixed that issue by introducing helper function which will dump operator class and all of its members
appropriately.
Task: BABEL-3385
Signed-off-by: Dipesh Dhameliya [email protected]
Issue details
Let's assume that we want to create certain operator between int (Oid = 23) and numeric (Oid = 1700). And we want to add this operator to existing operator family of integer (intger_ops (oid = 1976)) so that optimiser chooses index scan in certain situation over sequential scan. For this, one would follow following script to create operator class -
This CREATE OPERATOR CLASS would create unique entries in pg_amop for each of the member operators and will create entry in pg_amproc for each of the support function.
But PG does not store dependency of pg_amop or pg_amproc entry on pg_opclass or pg_opfamily . Reason for this is explain below.
^^ it just stores dependency on pg_operator (oid = 2617)
^^ it just stores dependency on pg_proc (oid = 1255)
This decision of not storing dependency of pg_amop on pg_opclass or pg_opfamily is causing two issues -
why does not PG store dependency of pg_amop or pg_amproc entry on pg_opclass or pg_opfamily ?
The answer lies with the invention of btadjustmembers (code link). Here, Postgres is not trying to register dependency of pg_amop entry on int_numeric (Operator class) but it rather tries to store dependency on integer_ops (oid = 1976 / Builtin operator family for integer datatype). And Oid = 1976 is pinned object and since Postgres does not register dependency on pinned object, recordDependencyOn will not add dependency entry.
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.