Issue getColumns(): Nonstandard use of \\ in a string literal

From: "ml-tb" <ml-tb(at)emagixx(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Issue getColumns(): Nonstandard use of \\ in a string literal
Date: 2011-02-15 17:08:06
Message-ID: 201102151808.06825.ml-tb@emagixx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

DB-Version: 9.0.2
Driver: 9.0-801

The metadata area of this driver seems to be a litte bit out of the
development or test focus (see also: Double quoted column name from
DatabaseMetaData.getIndexInfo).

I got the the warning message "nonstandard use of \\ in a string
literal" in the logfile from my postgresql server if i use the method
getColumns(...) from the DatabaseMetaData of a java.sql.Connection.

Following a example to reproduce this message:

SQL statemant to create a table.

CREATE TABLE "TEST_TABLE" ("COLUMN_A" VARCHAR(30), "COLUMN_B"
VARCHAR(30));

The Java code:

String tableName = "TEST_TABLE";
Connection con = this.getConnection();
String escape = con.getMetaData().getSearchStringEscape();

tableName = tableName.replace("_", escape + "_");
tableName = tableName.replace("%", escape + "%");

ResultSet rs = con.getMetaData().getColumns(catalog, schema, tableName,
null);

while (rs.next()) {
System.out.println("Column: " +
rs.getString("COLUMN_NAME"));
}

con.close();

After getting the Columns via the DatabaseMetaData the postgresql
database server log the following informations:

WARNING: nonstandard use of \\ in a string literal at character 912
HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
STATEMENT: SELECT * FROM (SELECT
n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull,a.atttypmod,a.attlen,row_number()
OVER (PARTITION BY a.attrelid ORDER BY a.attnum) AS attnum,
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS
adsrc,dsc.description,t.typbasetype,t.typtype FROM
pg_catalog.pg_namespace n JOIN pg_catalog.pg_class c ON (c.relnamespace
= n.oid) JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) JOIN
pg_catalog.pg_type t ON (a.atttypid = t.oid) LEFT JOIN
pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum =
def.adnum) LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid
AND a.attnum = dsc.objsubid) LEFT JOIN pg_catalog.pg_class dc ON
(dc.oid=dsc.classoid AND dc.relname='pg_class') LEFT JOIN
pg_catalog.pg_namespace dn ON (dc.relnamespace=dn.oid AND
dn.nspname='pg_catalog') WHERE a.attnum > 0 AND NOT a.attisdropped AND
n.nspname LIKE 'public' AND c.relname LIKE 'test\\_table' ) c WHERE
true ORDER BY nspname,c.relname,attnum

The result of the ReslutSet is correct but I'm wondering about the
message.

Bye Thomas

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Lukas Eder 2011-02-16 08:30:43 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Radosław Smogura 2011-02-15 15:50:38 Re: UDT arrays