Thread: BUG #3480: JDBC driver: getIndexInfo() returns quotes around quoted column names

The following bug has been logged online:

Bug reference:      3480
Logged by:          Andrei Badea
Email address:      andrei.badea@sun.com
PostgreSQL version: 8.2.4
Operating system:   Debian GNU/Linux testing/lenny, Linux 2.6.17
Description:        JDBC driver: getIndexInfo() returns quotes around quoted
column names
Details:

JDBC3 driver 8.2-505 and JDBC4 driver 8.3dev-600.

The DatabaseMetaData.getIndexInfo() method returns quotes around quoted
column names, unlike the getColumns() method. To reproduce run the following
statement in a database named "test" and the "public" schema:

    create table "CUSTOMER" ("CUSTOMER_ID" int not null primary key);

connect to the database and execute the following code:

    // java.sql.Connection conn
    DatabaseMetaData dmd = conn.getMetaData();
    // print the columns
    ResultSet rs = dmd.getColumns("test", "public", "CUSTOMER", "%");
    try {
        while (rs.next()) {
            System.out.println(rs.getString("COLUMN_NAME"));
        }
    } finally {
        rs.close();
    }
    // print the primary key columns
    rs = dmd.getIndexInfo("test", "public", "CUSTOMER", true, true);
    try {
        while (rs.next()) {
            System.out.println(rs.getString("COLUMN_NAME"));
        }
    } finally {
        rs.close();
    }

The code prints

    CUSTOMER_ID
    "CUSTOMER_ID"

while it should probably have printed

    CUSTOMER_ID
    CUSTOMER_ID
On Mon, 23 Jul 2007, Andrei Badea wrote:

> The following bug has been logged online:
>
> Bug reference:      3480
> Description:        JDBC driver: getIndexInfo() returns quotes around quoted
> column names
> Details:
>
> The DatabaseMetaData.getIndexInfo() method returns quotes around quoted
> column names, unlike the getColumns() method. To reproduce run the following
> statement in a database named "test" and the "public" schema:
>

Fixed in CVS for 8.1, 8.2, and HEAD.

Thanks for the test case.

Kris Jurka