X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 114B2D1B523 for ; Sun, 5 Oct 2003 15:12:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 42643-10 for ; Sun, 5 Oct 2003 12:11:16 -0300 (ADT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by svr1.postgresql.org (Postfix) with ESMTP id 965B2D1B55C for ; Sun, 5 Oct 2003 12:11:10 -0300 (ADT) Received: from [212.227.126.161] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1A6AXN-00023n-00; Sun, 05 Oct 2003 17:11:09 +0200 Received: from [80.129.138.89] (helo=pse-consulting.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1A6AXN-0006NV-00; Sun, 05 Oct 2003 17:11:09 +0200 Message-ID: <3F803498.8080400@pse-consulting.de> Date: Sun, 05 Oct 2003 17:11:20 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Peter Eisentraut Cc: PostgreSQL Development Subject: Re: PQfnumber and quoted identifiers References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/247 X-Sequence-Number: 44929 Peter Eisentraut wrote: >There was a discussion on -interfaces that might need more consideration. > >http://archives.postgresql.org/pgsql-interfaces/2003-09/msg00026.php > > >Apparently, it has so far been an undocumented feature of libpq's function >PGfnumber (return column number from column name) that the column name >needs to be double-quoted if it contains upper-case letters. That, is you >need to write > >PQfnumber(res, "\"Bar\"") > >I think this is completely bizarre and pointless. This is a C interface >and not SQL. Other libpq functions that accept names of SQL objects don't >do this. Also, PQfname and PQfnumber ought to be inverses. > >Since this behavior was undocumented and no one had noticed it in the last >10 years, I think we can away with removing it. > > I don't agree; you'll certainly break all libpq apps that contact databases with columns that have uppercase or special chars, and the failure might be very subtle because in most cases you wouldn't expect that this function call fails after you successfully created a rowset. There's no way how an app could determine which flavor of escaping is necessary for PQfnumber. I completely agree that PQfnumber should have been designed C-like right from the start, at least this is how C programmers would expect it. I had to learn the hard way that doesn't. While I don't have a problem with either version, IMHO now it's far too late to change the behaviour. As an alternative, a new function could be invented. BTW, I'd suggest that libpq gets a PQversion() function or macro, so that slight changes in behaviour could be taken in account on the app side if necessary. Regards, Andreas