Обсуждение: JDBC driver and Postgres 9.6beta

Поиск
Список
Период
Сортировка

JDBC driver and Postgres 9.6beta

От
Thomas Kellerer
Дата:
while testing Postgres 9.6beta1 with the current JDBC driver I noticed that the driver fails to retrieve the indexes
fora table because the catalog table pg_am has changed in 9.6 

The error message is:

    ERROR: column am.amcanorder does not exist

Regards
Thomas


Re: JDBC driver and Postgres 9.6beta

От
Vladimir Sitnikov
Дата:
Thanks for the report,

I've commented out amcanorder for 9.6 here: https://github.com/pgjdbc/pgjdbc/pull/560

Does anybody know what is the proper way to tell if index column is ASC or DESC in 9.6+?

pgjdbc used something like
  CASE pg_am.amcanorder
    WHEN true THEN CASE pg_index.indoption[(pg_index.keys).n - 1] & 1 
      WHEN 1 THEN 'D' 
      ELSE 'A' 
    END 
    ELSE NULL 
  END AS ASC_OR_DESC, 

Vladimir

Re: JDBC driver and Postgres 9.6beta

От
Tom Lane
Дата:
Vladimir Sitnikov <sitnikov.vladimir@gmail.com> writes:
> Does anybody know what is the proper way to tell if index column is ASC or
> DESC in 9.6+?

Using pg_get_indexdef() would leave you much less vulnerable to cross-
version differences in the system catalogs.

            regards, tom lane


Re: JDBC driver and Postgres 9.6beta

От
Dave Cramer
Дата:
That means parsing the response.. I gather there is nothing machine readable ?


On 14 May 2016 at 10:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Vladimir Sitnikov <sitnikov.vladimir@gmail.com> writes:
> Does anybody know what is the proper way to tell if index column is ASC or
> DESC in 9.6+?

Using pg_get_indexdef() would leave you much less vulnerable to cross-
version differences in the system catalogs.

                        regards, tom lane


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Re: JDBC driver and Postgres 9.6beta

От
Tom Lane
Дата:
Dave Cramer <pg@fastcrypt.com> writes:
> On 14 May 2016 at 10:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Using pg_get_indexdef() would leave you much less vulnerable to cross-
>> version differences in the system catalogs.

> That means parsing the response..

True.  If it seems like too much churn, I think you wouldn't go very far
wrong by assuming that ASC/DESC is only relevant to btree indexes.

            regards, tom lane


Re: JDBC driver and Postgres 9.6beta

От
Vladimir Sitnikov
Дата:
Thanks for the report,

I've commented out amcanorder for 9.6 here: https://github.com/pgjdbc/pgjdbc/pull/560

Does anybody know what is the proper way to tell if index column is ASC or DESC in 9.6+?

pgjdbc used something like
  CASE pg_am.amcanorder
    WHEN true THEN CASE pg_index.indoption[(pg_index.keys).n - 1] & 1 
      WHEN 1 THEN 'D' 
      ELSE 'A' 
    END 
    ELSE NULL 
  END AS ASC_OR_DESC, 

Vladimir

Re: JDBC driver and Postgres 9.6beta

От
Tom Lane
Дата:
Vladimir Sitnikov <sitnikov.vladimir@gmail.com> writes:
> Does anybody know what is the proper way to tell if index column is ASC or
> DESC in 9.6+?

Using pg_get_indexdef() would leave you much less vulnerable to cross-
version differences in the system catalogs.

            regards, tom lane


Re: JDBC driver and Postgres 9.6beta

От
Dave Cramer
Дата:
That means parsing the response.. I gather there is nothing machine readable ?


On 14 May 2016 at 10:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Vladimir Sitnikov <sitnikov.vladimir@gmail.com> writes:
> Does anybody know what is the proper way to tell if index column is ASC or
> DESC in 9.6+?

Using pg_get_indexdef() would leave you much less vulnerable to cross-
version differences in the system catalogs.

                        regards, tom lane


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Re: JDBC driver and Postgres 9.6beta

От
Tom Lane
Дата:
Dave Cramer <pg@fastcrypt.com> writes:
> On 14 May 2016 at 10:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Using pg_get_indexdef() would leave you much less vulnerable to cross-
>> version differences in the system catalogs.

> That means parsing the response..

True.  If it seems like too much churn, I think you wouldn't go very far
wrong by assuming that ASC/DESC is only relevant to btree indexes.

            regards, tom lane


Re: JDBC driver and Postgres 9.6beta

От
Thomas Kellerer
Дата:
Vladimir Sitnikov schrieb am 14.05.2016 um 15:57:
> Thanks for the report,
>
> I've commented out amcanorder for 9.6 here: https://github.com/pgjdbc/pgjdbc/pull/560
>
> Does anybody know what is the proper way to tell if index column is ASC or DESC in 9.6+?

Based on Tom's statement that only btree indexes can be sorted, the following seems better then just returning NULL:

  CASE am.amname
     WHEN 'btree' THEN
       CASE i.indoption[(i.keys).n - 1] & 1
          WHEN 1 THEN 'D'
          ELSE 'A'
       END
       ELSE NULL
  END AS ASC_OR_DESC,

Re: JDBC driver and Postgres 9.6beta

От
Thomas Kellerer
Дата:
Vladimir Sitnikov schrieb am 14.05.2016 um 15:57:
> Thanks for the report,
>
> I've commented out amcanorder for 9.6 here: https://github.com/pgjdbc/pgjdbc/pull/560
>
> Does anybody know what is the proper way to tell if index column is ASC or DESC in 9.6+?

Based on Tom's statement that only btree indexes can be sorted, the following seems better then just returning NULL:

  CASE am.amname
     WHEN 'btree' THEN
       CASE i.indoption[(i.keys).n - 1] & 1
          WHEN 1 THEN 'D'
          ELSE 'A'
       END
       ELSE NULL
  END AS ASC_OR_DESC,

Re: JDBC driver and Postgres 9.6beta

От
Dave Cramer
Дата:


On 17 May 2016 at 02:10, Thomas Kellerer <spam_eater@gmx.net> wrote:
Vladimir Sitnikov schrieb am 14.05.2016 um 15:57:
> Thanks for the report,
>
> I've commented out amcanorder for 9.6 here: https://github.com/pgjdbc/pgjdbc/pull/560
>
> Does anybody know what is the proper way to tell if index column is ASC or DESC in 9.6+?

Based on Tom's statement that only btree indexes can be sorted, the following seems better then just returning NULL:

  CASE am.amname
     WHEN 'btree' THEN
       CASE i.indoption[(i.keys).n - 1] & 1
          WHEN 1 THEN 'D'
          ELSE 'A'
       END
       ELSE NULL
  END AS ASC_OR_DESC,



--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Re: JDBC driver and Postgres 9.6beta

От
Dave Cramer
Дата:


On 17 May 2016 at 02:10, Thomas Kellerer <spam_eater@gmx.net> wrote:
Vladimir Sitnikov schrieb am 14.05.2016 um 15:57:
> Thanks for the report,
>
> I've commented out amcanorder for 9.6 here: https://github.com/pgjdbc/pgjdbc/pull/560
>
> Does anybody know what is the proper way to tell if index column is ASC or DESC in 9.6+?

Based on Tom's statement that only btree indexes can be sorted, the following seems better then just returning NULL:

  CASE am.amname
     WHEN 'btree' THEN
       CASE i.indoption[(i.keys).n - 1] & 1
          WHEN 1 THEN 'D'
          ELSE 'A'
       END
       ELSE NULL
  END AS ASC_OR_DESC,



--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc