Re: getIndexInfo() throws NullPointerException

From: "Cormac Twomey" <cormac(at)bpallen(dot)com>
To: <Dave(at)micro-automation(dot)net>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: getIndexInfo() throws NullPointerException
Date: 2002-02-19 01:50:51
Message-ID: 00b401c1b8e7$ee89d0d0$6501a8c0@firbolg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Ok, I have one further issue, which I'm much less certain of - some of the indexes that I'm trying to obtain info about are
multi-column indexes, but the resultset for getIndexInfo is only returning the column name of one of those columns. For the other
columns, it's returning an empty string.

So, for example, given the following index:

create index foo_abc_idx on foo (a, b, c)

calling getIndexInfo on table foo, will return 3 results (as I expected) but with the following columns:

ORDINAL_POSITION | COLUMN_NAME
------------------------------
1 | c
2 |
3 |

The documentation for this call is sparse enough, so I'm not sure I'm not doing something wrong.... ideas?

Thanks,
--Cormac

----- Original Message -----
From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "'Cormac Twomey'" <cormac(at)bpallen(dot)com>; <pgsql-jdbc(at)postgresql(dot)org>; <Dave(at)micro-automation(dot)net>
Sent: Monday, February 18, 2002 4:54 PM
Subject: Re: [JDBC] getIndexInfo() throws NullPointerException

> I'd have to agree with your bet, thanks a lot
>
> Dave
>
> -----Original Message-----
> From: Cormac Twomey [mailto:cormac(at)bpallen(dot)com]
> Sent: Monday, February 18, 2002 7:40 PM
> To: pgsql-jdbc(at)postgresql(dot)org; Dave(at)micro-automation(dot)net
> Subject: [JDBC] getIndexInfo() throws NullPointerException
>
>
> Calling getIndexInfo against a postgresql-7.1 db with the 7.2 jdbc
> driver (or with 7.3dev built 2002-02-09 ), I get the following
> exception:
>
> Exception in thread "main" java.lang.NullPointerException
> at org.postgresql.jdbc2.ResultSet.getBytes(Unknown source)
> at org.postgresql.jdbc2.DatabaseMetaData.getIndexInfo(Unknown
> source)
> at foo.bar(foo.java:253)
> at foo.baz(foo.java:167)
> at foo.main(foo.java:46)
>
> I decided to poke around in the source code and found the following
> piece of questionable-looking code in
> org/postgresql/jdbc2/DatabaseMetaData.jar:
>
> ...
> if (columnNameRS.next())
> tuple[8] = columnNameRS.getBytes(1);
> else
> tuple[8] = "".getBytes();
> tuple[8] = columnNameRS.getBytes(1);
> ...
>
> Now, being willing to bet that that last line shouldn't be there, I
> commented it out and tried it again - and bingo! it worked fine.
>
> I see Dave Cramer's uid at the top of DatabaseMetaData.jar, so cc'ing
> him.
>
> Thanks,
> --Cormac Twomey
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-02-19 02:05:07 Re: getIndexInfo() throws NullPointerException
Previous Message Dave Cramer 2002-02-19 00:54:42 Re: getIndexInfo() throws NullPointerException