pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Volkan YAZICI <volkan.yazici@gmail.com>
To: pgsql-php@postgresql.org
Subject: Fwd: Bug #32904: pg_get_notify() ignores result_type param.
Date: Sun, 1 May 2005 16:59:01 +0300
Message-ID: <7104a73705050106596dee2573@mail.gmail.com> (raw)
In-Reply-To: <bug-32904@bugs.php.net>
References: <bug-32904@bugs.php.net>

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_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)
}



Message-ID: <7104a73705050106596dee2573@mail.gmail.com>
Permalink:  ../7104a73705050106596dee2573@mail.gmail.com/
Also on:    postgresql.org/message-id/7104a73705050106596dee2573@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: volkan.yazici@gmail.com
  Subject: Re: Fwd: Bug #32904: pg_get_notify() ignores result_type param.
  In-Reply-To: <7104a73705050106596dee2573@mail.gmail.com>
  References: <bug-32904@bugs.php.net> <7104a73705050106596dee2573@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox