aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-10-04 21:05:21 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-10-04 21:05:21 +0000
commitfa09ee60263aa508b20efdc97e36fc725aaf7025 (patch)
tree0ebe72793ba9bb4f7434bf15026afe75374ba284 /doc/src
parentb833c3d4a468975bfea1abc11feee1ca47de84b1 (diff)
downloadpostgresql-fa09ee60263aa508b20efdc97e36fc725aaf7025.tar.gz
postgresql-fa09ee60263aa508b20efdc97e36fc725aaf7025.zip
Document the always-true-but-previously-undocumented fact that PQfnumber()
will downcase the supplied field name unless it is double-quoted. Also, upgrade the routine's handling of double quotes to match the backend, in particular support doubled double quotes within quoted identifiers. Per pgsql-interfaces discussion a couple weeks ago.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/libpq.sgml23
1 files changed, 20 insertions, 3 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 37e1fffb5fe..3bbad0c4599 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.138 2003/10/03 18:26:14 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.139 2003/10/04 21:05:20 tgl Exp $
-->
<chapter id="libpq">
@@ -1553,8 +1553,7 @@ NULL is returned if the column number is out of range.
<term><function>PQfnumber</function><indexterm><primary>PQfnumber</></></term>
<listitem>
<para>
- Returns the column number
- associated with the given column name.
+ Returns the column number associated with the given column name.
<synopsis>
int PQfnumber(const PGresult *res,
const char *column_name);
@@ -1564,6 +1563,24 @@ int PQfnumber(const PGresult *res,
<para>
-1 is returned if the given name does not match any column.
</para>
+
+<para>
+ The given name is treated like an identifier in an SQL command,
+ that is, it is downcased unless double-quoted. For example,
+ given a query result generated from the SQL command
+<programlisting>
+select 1 as FOO, 2 as "BAR";
+</programlisting>
+ we would have the results:
+<programlisting>
+PQfname(res, 0) <lineannotation>foo</lineannotation>
+PQfname(res, 1) <lineannotation>BAR</lineannotation>
+PQfnumber(res, "FOO") <lineannotation>0</lineannotation>
+PQfnumber(res, "foo") <lineannotation>0</lineannotation>
+PQfnumber(res, "BAR") <lineannotation>-1</lineannotation>
+PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
+</programlisting>
+</para>
</listitem>
</varlistentry>