#32904 [Opn->Fbk]: pg_get_notify() ignores result_type param.
| From: | sniper@php.net | Date: | Fri, 06 May 2005 01:20:10 +0000 |
| Subject: | #32904 [Opn->Fbk]: pg_get_notify() ignores result_type param. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78680@lists.php.net to get a copy of this message | ||
ID: 32904
Updated by: sniper@php.net
Reported By: volkan dot yazici at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PostgreSQL related
Operating System: Debian GNU/Linux 3.0 (Unstable)
PHP Version: 5.0.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-05-01 17:11:39] volkan dot yazici at gmail dot com
:%s/Any of these calls act as/All of these calls act as/g
------------------------------------------------------------------------
[2005-05-01 14:50:24] volkan dot yazici at gmail dot com
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 this bug report at http://bugs.php.net/?id=32904&edit=1