From: Kris Jurka <books@ejurka.com>
To: Valery Meshkov <meshok2001-news@yahoo.com>
Cc: pgsql-bugs@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: Re: BUG #3106: A problem with escaping table name pattern for DatabaseMetaData.getColumns()
Date: Tue, 6 Mar 2007 11:49:05 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0703061135300.13161@leary.csoft.net> (raw)
In-Reply-To: <200703041900.l24J08aR034467@wwwmaster.postgresql.org>
References: <200703041900.l24J08aR034467@wwwmaster.postgresql.org>
On Sun, 4 Mar 2007, Valery Meshkov wrote:
> The following bug has been logged online:
>
> Bug reference: 3106
> PostgreSQL version: 8.2.3
> 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:
>
The problem is that there is a different search string escape depending on
whether you plan to interpolate it into a query or pass it as a parameter
to a PreparedStatement. The getSearchStringEscape method is assuming
you're going to interpolate it into a query and returns the doubled
version. getColumns is assuming you're passing a parameter that it
then interpolates and must escape itself.
The fact that the javadoc for getColumns has a see also for
getSearchStringEscape implies to me that our implementation is wrong and
it shouldn't return the doubled version and anyone interpolating text into
a query must escape it appropriately including the search string escape.
I'll put a fix for this into the next release.
Kris Jurka
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: books@ejurka.com, meshok2001-news@yahoo.com, pgsql-bugs@postgresql.org
Subject: Re: BUG #3106: A problem with escaping table name pattern for DatabaseMetaData.getColumns()
In-Reply-To: <Pine.BSO.4.64.0703061135300.13161@leary.csoft.net>
References: <200703041900.l24J08aR034467@wwwmaster.postgresql.org> <Pine.BSO.4.64.0703061135300.13161@leary.csoft.net>
* 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