Home > Archive > PHP with PostgreSQL > May 2005 > Fwd: Bug #32904: pg_get_notify() ignores result_type param.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Fwd: Bug #32904: pg_get_notify() ignores result_type param.
Volkan YAZICI

2005-05-01, 9:25 am

From: PHP Bug Database <php-bugs@lists.php.net>
Date: May 1, 2005 3:50 PM
Subject: Bug #32904: pg_get_notify() ignores result_type param.
To: volkan.yazici@gmail.com


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_N
UM)
...
Line 4144: if (result_type & (PGSQL_NUM|PGSQL_BOT
H)) {
...
Line 4178: if (result_type & (PGSQL_ASSOC|PGSQL_B
OTH)) {

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_noti
fy($dbconn, PGSQL_BOTH));
*/
var_dump(pg_get_noti
fy($dbconn));
var_dump(pg_get_noti
fy($dbconn, PGSQL_NUM));
var_dump(pg_get_noti
fy($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)
}

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere
" to majordomo@postgresql
.org)

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com