|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-23 19:40 UTC] thuejk at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 19:00:01 2025 UTC |
Description: ------------ For some queries, pg_field_type() returns the wrong field type. It seems to happen when you do a "SELECT *" and there are more than one table in the FROM-clause, with common columns eliminated. I tested with postgresql 7.4 and postgresql 8.1, with the same result. Reproduce code: --------------- <?php $params = "host=localhost dbname=testdb user=testuser password=123456"; pg_pconnect($params); pg_query("begin"); pg_query("CREATE TABLE test1(a integer)"); pg_query("CREATE TABLE test2(a integer, c varchar)"); pg_query("INSERT INTO test1 VALUES (1)"); pg_query("INSERT INTO test2 VALUES (1,'aa')"); $res = pg_query("SELECT * FROM test1 INNER JOIN test2 ON test1.a=test2.a"); $row = pg_fetch_assoc($res); $col_i=0; foreach ($row as $field_name => $dummy) { var_dump($field_name); $type = pg_field_type($res, $col_i++); var_dump($type); if ($field_name == "c") { assert($type != "int4"); } } pg_query("rollback"); ?> Expected result: ---------------- The type of column "c" should be "varchar" Actual result: -------------- The type of column "c" is "int4"