#45610 [NEW]: pg_field_type returns wrong type
| From: | thuejk at gmail dot com | Date: | Wed, 23 Jul 2008 19:33:30 +0000 |
| Subject: | #45610 [NEW]: pg_field_type returns wrong type | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-127213@lists.php.net to get a copy of this message | ||
From: thuejk at gmail dot com
Operating system: Linux (probably all)
PHP version: 5.2.6
PHP Bug Type: PostgreSQL related
Bug description: pg_field_type returns wrong type
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"
--
Edit bug report at http://bugs.php.net/?id=45610&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45610&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45610&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45610&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45610&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45610&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45610&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45610&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45610&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45610&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45610&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45610&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45610&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45610&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45610&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45610&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45610&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45610&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45610&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45610&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45610&r=mysqlcfg