Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E1D451337B4E for ; Thu, 24 Mar 2011 18:18:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 04835-05 for ; Thu, 24 Mar 2011 21:18:13 +0000 (UTC) X-Greylist: delayed 00:07:47.237197 by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 1E1581337BD3 for ; Thu, 24 Mar 2011 18:18:13 -0300 (ADT) Received: from [192.168.1.140] (adsl-71-128-101-241.dsl.irvnca.pacbell.net [71.128.101.241]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail63.csoft.net (Postfix) with ESMTPSA id 4D9C228436; Thu, 24 Mar 2011 17:10:25 -0400 (EDT) Message-ID: <4D8BB345.8000206@ejurka.com> Date: Thu, 24 Mar 2011 14:10:29 -0700 From: Kris Jurka User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: Thomas Kellerer CC: pgsql-jdbc@postgresql.org Subject: Re: How to retrieve column names for tables with underscores References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.386 tagged_above=-10 required=5 tests=BAYES_00=-1.9, URIBL_RHS_DOB=1.514 X-Spam-Level: X-Archive-Number: 201103/47 X-Sequence-Number: 21602 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