pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: How to retrieve column names for tables with underscores
Date: Thu, 24 Mar 2011 14:10:29 -0700
Message-ID: <4D8BB345.8000206@ejurka.com> (raw)
In-Reply-To: <imgagk$h4a$1@dough.gmane.org>
References: <imgagk$h4a$1@dough.gmane.org>

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



view thread (8+ messages)  latest in thread

Message-ID: <4D8BB345.8000206@ejurka.com>
Permalink:  ../4D8BB345.8000206@ejurka.com/
Also on:    postgresql.org/message-id/4D8BB345.8000206@ejurka.com

 · 

reply

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, spam_eater@gmx.net
  Subject: Re: How to retrieve column names for tables with underscores
  In-Reply-To: <4D8BB345.8000206@ejurka.com>
  References: <imgagk$h4a$1@dough.gmane.org> <4D8BB345.8000206@ejurka.com>

* 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