Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

21 views
Skip to first unread message

ml-tb

unread,
Feb 15, 2011, 12:08:06 PM2/15/11
to
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

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

Kris Jurka

unread,
Mar 19, 2011, 11:34:43 PM3/19/11
to

On Tue, 15 Feb 2011, ml-tb wrote:

> 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.

The warning can be safely ignored. The warning is to tell you that the
backslashes can mean different things depending on the setting of
standard_conforming_strings. But since the backslashes are generated
based upon the setting of standard_conforming_strings, it's OK. I have
committed a fix to CVS to avoid that warning in the future.

Kris Jurka

dv

unread,
Sep 9, 2011, 7:05:16 AM9/9/11
to
As of postgresql 9.1 defaulted to
standard_conforming_strings = on

These warnings are turned to the errors, so they cannot be ignored any more:

2011-09-09 14:41:06 MSD ERROR: invalid escape string
2011-09-09 14:41:06 MSD HINT: Escape string must be empty or one character.
2011-09-09 14:41:06 MSD STATEMENT: SELECT COUNT(a0.id) FROM country a0
WHERE a0."name" LIKE '%%' ESCAPE '\\'

--
Dmitry

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issue-getColumns-Nonstandard-use-of-in-a-string-literal-tp3386298p4785925.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

Kris Jurka

unread,
Sep 9, 2011, 10:18:53 AM9/9/11
to


On Fri, 9 Sep 2011, dv wrote:

> As of postgresql 9.1 defaulted to
> standard_conforming_strings = on
>
> These warnings are turned to the errors, so they cannot be ignored any more:
>
> 2011-09-09 14:41:06 MSD ERROR: invalid escape string
> 2011-09-09 14:41:06 MSD HINT: Escape string must be empty or one character.
> 2011-09-09 14:41:06 MSD STATEMENT: SELECT COUNT(a0.id) FROM country a0
> WHERE a0."name" LIKE '%%' ESCAPE '\\'
>

This certainly doesn't look like any JDBC driver generated SQL, so I'm not
sure what your specific complaint here is. It looks to me like you are
using a hardcoded and incorrect escape string. If you show the Java code
associated with this, perhaps some more concrete advice could be offered.

Kris Jurka
0 new messages