Re: PQfnumber and quoted identifiers

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PQfnumber and quoted identifiers
Date: 2003-10-05 15:11:20
Message-ID: 3F803498.8080400@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-10-05 15:45:40 Re: pgsql-server/ oc/src/sgml/runtime.sgml rc/back ...
Previous Message Peter Eisentraut 2003-10-05 14:37:29 PQfnumber and quoted identifiers

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2003-10-05 17:00:07 Re: [HACKERS] PQfnumber and quoted identifiers
Previous Message Peter Eisentraut 2003-10-05 14:37:29 PQfnumber and quoted identifiers