X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DDB5CD1B504 for ; Mon, 15 Sep 2003 07:59:56 +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 14213-06 for ; Mon, 15 Sep 2003 04:59:26 -0300 (ADT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id CE3F0D1B4F0 for ; Mon, 15 Sep 2003 04:59:23 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Mon Sep 15 09:59:23 2003 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA22186; Mon, 15 Sep 2003 09:59:22 +0200 (METDST) Message-ID: <3F65715A.BDCAD1FB@rodos.fzk.de> Date: Mon, 15 Sep 2003 09:59:22 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: alberto@unex.es, pgsql-interfaces@postgresql.org Subject: Re: ColumnName and ColumnNumber in libpq (C interface) Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char 9C hex) in message header 'Received' Received: \234by rodos.fzk.de... ^ X-Archive-Number: 200309/28 X-Sequence-Number: 4446 > > I think this behaviour is not fine: > I create a table with > CREATE TABLE foo ("Bar" VARCHAR(1)); > > I thougth running this helloworldish C program: > > #include > #include > =20 > int main(int argc,char **argv) > { > PGconn * conn =3D PQconnectdb("dbname=3Dpruebas"); > PGresult * res =3D PQexec(conn,"SELECT * from foo"); > printf("%s\n",PQfname(res,0)); > printf("%d\n",PQfnumber(res,"Bar")); > PQfinish(conn); > } > > should print=20 > > Bar > 0 > > but stdout shows > > Bar > -1 > > What is happening? Any ideas? Is this a bug, a feature or something I'm m= > issing? > It's something you're missing: All names are folded to lowercase, except enclosed in double quotes. So printf("%d\n",PQfnumber(res,"\"Bar\"")); gives you the right result. Regards, Christoph