|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29709 pg_fieldname returns an unqualified name
Submitted: 2004-08-16 19:01 UTC Modified: 2004-08-17 00:16 UTC
From: hayk at mail dot ru Assigned:
Status: Not a bug Package: PostgreSQL related
PHP Version: 4.3.8 OS: FreeBSD 4.8
Private report: No CVE-ID: None
 [2004-08-16 19:01 UTC] hayk at mail dot ru
For "SELECT field1, field2 FROM table"
pg_field_name() returns "field1" and "field2", but for "SELECT 'field1', 'field2' FROM table" (when fields name in single quotes) returns "?column?" and "?column?".

PostgreSQL(libpq) Version  7.4.2

Reproduce code:
$pc = pg_connect("dbname=webmail");

$res = pg_query($pc, "SELECT 'userid', 'domainid' FROM users WHERE userid=1");
$num = pg_num_fields($res);
for ($i=0; $i<$num; $i++)
	$fieldname = pg_field_name($res, $i);
	echo "column $i: $fieldname <br>";

Expected result:
column 0: userid
column 1: domainid

Actual result:
column 0: ?column?
column 1: ?column?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-17 00:16 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Looks at what the same query produces when ran manually via 
psql. You are not selecting those columns, but 2 strings. 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 14:01:31 2024 UTC