From: volkan dot yazici at gmail dot com
Operating system: Debian GNU/Linux 3.0 (Unstable)
PHP version: 5.0.3
PHP Bug Type: PostgreSQL related
Bug description: pg_get_notify() ignores result_type param.
Description:
------------
Second parameter (result_type) used in pg_get_notify() is ignored. When we
look at ext/pgsql/pgsql.c (in revision 1.324, Wed Apr 13 18:11:35 2005 from
CVS):
Line 49: #define PGSQL_ASSOC 1<<0
Line 50: #define PGSQL_NUM 1<<1
Line 51: #define PGSQL_BOTH (PGSQL_ASSOC|PGSQL_NUM)
...
Line 4144: if (result_type & (PGSQL_NUM|PGSQL_BOTH)) {
...
Line 4178: if (result_type & (PGSQL_ASSOC|PGSQL_BOTH)) {
Both of the if conditions in the lines 4144 and 4178 returns true
(positive values) on any input. Thus, result_type param. always acts as
PGSQL_BOTH.
Line 4144 and 4178 may be replaced by below ones:
Line 4144: if (result_type & PGSQL_NUM) {
...
Line 4178: if (result_type & PGSQL_ASSOC) {
They're working well on my current system.
Reproduce code:
---------------
/*
* Any of these calls act as
* var_dump(pg_get_notify($dbconn, PGSQL_BOTH));
*/
var_dump(pg_get_notify($dbconn));
var_dump(pg_get_notify($dbconn, PGSQL_NUM));
var_dump(pg_get_notify($dbconn, PGSQL_ASSOC));
Expected result:
----------------
array(4) {
["message"]=>
string(1) "test"
["pid"]=>
int(2317)
}
array(4) {
[0]=>
string(1) "test"
[1]=>
int(2317)
}
array(4) {
["message"]=>
string(1) "test"
["pid"]=>
int(2317)
}
Actual result:
--------------
array(4) {
[0]=>
string(1) "test"
[1]=>
int(2317)
["message"]=>
string(1) "test"
["pid"]=>
int(2317)
}
array(4) {
[0]=>
string(1) "test"
[1]=>
int(2317)
["message"]=>
string(1) "test"
["pid"]=>
int(2317)
}
array(4) {
[0]=>
string(1) "test"
[1]=>
int(2317)
["message"]=>
string(1) "test"
["pid"]=>
int(2317)
}
--
Edit bug report at http://bugs.php.net/?id=32904&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32904&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32904&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32904&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32904&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32904&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32904&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32904&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32904&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32904&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32904&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32904&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32904&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32904&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32904&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32904&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32904&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32904&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32904&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32904&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32904&r=mysqlcfg