From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Bug in getIndexInfo() with 9.0 JDBC driver |
Date: | 2010-09-25 10:01:29 |
Message-ID: | i7kh9n$qql$1@dough.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Thomas Kellerer wrote on 25.09.2010 11:38:
> Hello,
>
> in my program I'm using DatabaseMetaData.getIndexInfo().
>
> This is working fine with the 8.4 driver on a 8.4 and 9.0 database.
>
> However when using the 9.0 driver (postgresql-9.0-801.jdbc4.jar) I'm getting the following exception when calling getIndexInfo():
>
> ERROR: argument to pg_get_expr() must come from system catalogs [SQL State=42501]
> org.postgresql.util.PSQLException: ERROR: argument to pg_get_expr() must come from system catalogs
I had a look at AbstractJdbc2DatabaseMetaData, and I think the solution would be to push down the call pg_get_expr() into the derived table to avoid the error:
So instead of the original statement:
SELECT ...
pg_catalog.pg_get_expr(i.indpred, i.indrelid) AS FILTER_CONDITION
FROM pg_catalog.pg_class ct
JOIN pg_catalog.pg_namespace n ON (ct.relnamespace = n.oid)
JOIN (SELECT i.indexrelid, i.indrelid, i.indoption,
i.indisunique, i.indisclustered, i.indpred,
i.indexprs,
information_schema._pg_expandarray(i.indkey) AS keys
FROM pg_catalog.pg_index i) i
ON (ct.oid = i.indrelid)
JOIN pg_catalog.pg_class ci ON (ci.oid = i.indexrelid)
JOIN pg_catalog.pg_am am ON (ci.relam = am.oid)
using
SELECT ...
i.filter_condition
FROM pg_catalog.pg_class ct
JOIN pg_catalog.pg_namespace n ON (ct.relnamespace = n.oid)
JOIN (SELECT i.indexrelid, i.indrelid, i.indoption,
i.indisunique, i.indisclustered,
pg_catalog.pg_get_expr(i.indpred, i.indrelid) AS filter_condition,
i.indexprs,
information_schema._pg_expandarray(i.indkey) AS keys
FROM pg_catalog.pg_index i) i
ON (ct.oid = i.indrelid)
JOIN pg_catalog.pg_class ci ON (ci.oid = i.indexrelid)
JOIN pg_catalog.pg_am am ON (ci.relam = am.oid)
seems to solve the problem.
I haven't checked if that works with 8.4 and 8.3 though.
Regards
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-09-25 19:10:49 | Re: Bug in getIndexInfo() with 9.0 JDBC driver |
Previous Message | Thomas Kellerer | 2010-09-25 09:38:04 | Bug in getIndexInfo() with 9.0 JDBC driver |