php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32904 pg_get_notify() ignores result_type param.
Submitted: 2005-05-01 14:50 UTC Modified: 2005-05-10 22:14 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: volkan dot yazici at gmail dot com Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 5.0.3 OS: Debian GNU/Linux 3.0 (Unstable)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: volkan dot yazici at gmail dot com
New email:
PHP Version: OS:

 

 [2005-05-01 14:50 UTC] 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)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-01 17:11 UTC] volkan dot yazici at gmail dot com
:%s/Any of these calls act as/All of these calls act as/g
 [2005-05-06 12:55 UTC] volkan dot yazici at gmail dot com
I've tried the CVS snapshot (located at http://snaps.php.net/php5-latest.tar.gz [php5-200505060830]) and the result is same.

{{{ Related PHP script:
<?php
    $dbconn = pg_connect("dbname=test");

    pg_query("LISTEN test");
    sleep(5); // I'll type "NOTIFY test;" for three times
              // from psql in here.
    var_dump(pg_get_notify($dbconn));
    var_dump(pg_get_notify($dbconn, PGSQL_NUM));
    var_dump(pg_get_notify($dbconn, PGSQL_ASSOC));
?>
}}}

Expected and actual results are same as in the bug report.
 [2005-05-10 22:14 UTC] [email protected]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 30 04:00:03 2025 UTC