Skip site navigation (1) Skip section navigation (2)

BUG #3106: A problem with escaping table name pattern for DatabaseMetaData.getColumns()

From: "Valery Meshkov" <meshok2001-news(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3106: A problem with escaping table name pattern for DatabaseMetaData.getColumns()
Date: 2007-03-04 19:00:08
Message-ID: 200703041900.l24J08aR034467@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-jdbc
The following bug has been logged online:

Bug reference:      3106
Logged by:          Valery Meshkov
Email address:      meshok2001-news(at)yahoo(dot)com
PostgreSQL version: 8.2.3
Operating system:   Windows
Description:        A problem with escaping table name pattern for
DatabaseMetaData.getColumns()
Details: 

I am seeing a problem in the JDBC driver postgresql-8.2-504.jdbc3.jar with
getting columns of the table 'A_B'.  I am escaping  '_'  with the escape
value returned by DatabaseMetaData.getSearchStringEscape(), which in my case
is "\\\\"  (standard_conforming_strings is off).  When I pass the resulting
table name 'A\\_B' to DatabaseMetaData.getColumns() the number of
backslashes doubles again, resulting in 4 backslashes in the select
statement:

SELECT n.nspname,c.relname,a.attname,a.atttypid,a.attnotnull,a.atttypmod,
a.attlen,a.attnum,def.adsrc,dsc.description
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)
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
c.relname LIKE 'A\\\\_B'  ORDER BY nspname,relname,attnum

With this select no columns are found.  If I change the escape string in the
debugger to have just one backslash ("\\") everything works fine.  It is
also working with the 8.1-404 driver.

Responses

pgsql-bugs by date

Next:From: Randy IsbellDate: 2007-03-05 14:33:56
Subject: BUG #3110: Online Backup introduces Duplicate OIDs
Previous:From: Heikki LinnakangasDate: 2007-03-04 18:07:41
Subject: Re: BUG #3101: Error 1069

pgsql-jdbc by date

Next:From: peter royalDate: 2007-03-05 06:22:54
Subject: Re: statement caching proof of concept redux
Previous:From: Matthias KarlssonDate: 2007-03-04 14:12:26
Subject: Switching from MySQL to PostgreSQL, JDBC drivers behaving differently

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group