Re: How to retrieve column names for tables with underscores - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: How to retrieve column names for tables with underscores
Date
Msg-id 4D8BB345.8000206@ejurka.com
Whole thread Raw
In response to Re: How to retrieve column names for tables with underscores  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-jdbc
On 3/24/2011 1:45 PM, Thomas Kellerer wrote:
>
> Kris Jurka wrote on 24.03.2011 21:18:
>> The escape needed depends on the value of
>> standard_conforming_strings. You should use this call to find the
>> escape needed:
>>
>>
>> http://download.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getSearchStringEscape()
>
>>
>
> Interesting enough, the setting of standard_conforming_strings does
> not seem to affect this at all. Am I missing something?

Nope, that's my memory failing me.  The comment in getSearchStringEscape
escape gives some details on why this doesn't depend on
standard_conforming_strings.  Turning a search pattern into a literal
happens as a separate step and it's at that time you need to know the
value of s_c_s.

     public String getSearchStringEscape() throws SQLException
     {
         // This method originally returned "\\\\" assuming that it
         // would be fed directly into pg's input parser so it would
         // need two backslashes.  This isn't how it's supposed to be
         // used though.  If passed as a PreparedStatement parameter
         // or fed to a DatabaseMetaData method then double backslashes
         // are incorrect.  If you're feeding something directly into
         // a query you are responsible for correctly escaping it.
         // With 8.2+ this escaping is a little trickier because you
         // must know the setting of standard_conforming_strings, but
         // that's not our problem.

         return "\\";
     }

Kris Jurka

pgsql-jdbc by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Re: How to retrieve column names for tables with underscores
Next
From: Thomas Kellerer
Date:
Subject: Re: How to retrieve column names for tables with underscores