Re: How to retrieve column names for tables with underscores

From: Kris Jurka <books(at)ejurka(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: How to retrieve column names for tables with underscores
Date: 2011-03-24 21:10:29
Message-ID: 4D8BB345.8000206@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas Kellerer 2011-03-24 21:41:58 Re: How to retrieve column names for tables with underscores
Previous Message Maciek Sakrejda 2011-03-24 21:02:07 Re: How to retrieve column names for tables with underscores