From: ml-tb <ml-tb@emagixx.de>
To: pgsql-jdbc@postgresql.org
Subject: Issue getColumns(): Nonstandard use of \\ in a string literal
Date: Tue, 15 Feb 2011 18:08:06 +0100
Message-ID: <201102151808.06825.ml-tb@emagixx.de> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: ml-tb@emagixx.de
Subject: Re: Issue getColumns(): Nonstandard use of \\ in a string literal
In-Reply-To: <201102151808.06825.ml-tb@emagixx.de>
References: <201102151808.06825.ml-tb@emagixx.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox