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
PgDatabaseMetaData.getIndexInfo breaks with certain custom operator configuration #2241
Comments
I'll make soon a PR to add |
6 tasks
davecramer
pushed a commit
that referenced
this issue
Sep 13, 2021
It is possible to break method PgDatabaseMetaData.getIndexInfo() by adding certain custom operators. This PR casts operands in a query so that PgDatabaseMetaData.getIndexInfo() works in presence of such operator config. Creating this operator triggers this issue: CREATE OR REPLACE FUNCTION f6(numeric, integer) returns integer as 'BEGIN return $1::integer & $2;END;' language plpgsql immutable; CREATE OPERATOR & (LEFTARG = numeric, RIGHTARG = integer, PROCEDURE = f6); Fixes #2241
PR against |
davecramer
pushed a commit
that referenced
this issue
Sep 13, 2021
…2253) It is possible to break method PgDatabaseMetaData.getIndexInfo() by adding certain custom operators. This PR casts operands in a query so that PgDatabaseMetaData.getIndexInfo() works in presence of such operator config. Creating this operator triggers this issue: CREATE OR REPLACE FUNCTION f6(numeric, integer) returns integer as 'BEGIN return $1::integer & $2;END;' language plpgsql immutable; CREATE OPERATOR & (LEFTARG = numeric, RIGHTARG = integer, PROCEDURE = f6); Fixes #2241
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the issue
It is possible to break method PgDatabaseMetaData.getIndexInfo() by adding certain custom operators.
This happened with a production database that was running Adobe Campaign product. That product defines a bunch of functions and operators for internal usage.
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L2531
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L2538
Driver Version?
Tested with 42.2.23, 42.2.12. But I expect the same issue be in wide range of versions.
Java Version?
OpenJDK 11
OS Version?
PostgreSQL Version?
AWS RDS 11.10
To Reproduce
Steps to reproduce the behaviour:
Create an
&
operator like this:call
getIndexInfo()
Expected behaviour
It is expected that
getIndexInfo()
works and returns the data.This is what happens:
getIndexInfo()
creates this kind of SQL query and then executes it.Executing the query fails with this error
This is the operator configuration:
The offending places in the code are these:
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L2531
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L2538
This kind of code:
A fix is to change it to this:
Other alternative would be to define some additional operator configuration such that postgres can resolve which operator to use in this case.
The text was updated successfully, but these errors were encountered: