ID:               32223
 Updated by:       [EMAIL PROTECTED]
 Reported By:      valiak at gmail dot com
 Status:           Open
 Bug Type:         PostgreSQL related
-Operating System: debian linux sarge
+Operating System: Irrelevant
 PHP Version:      5.0.3
 New Comment:

I'm reproducing the bug too.

I'm using PHP 5.0.0 (on Windows) and PostgreSQL 7.4.7 (on Linux):

PHP 5.0.0 (cli) (built: Jul 13 2004 21:39:58)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.0, Copyright (c) 1998-2004 Zend Technologies

Even without the exceptions pg_last_notice() doesn't work as expected.
Try the following code:

<?
define(TTT, pg_connect('user=test password=test dbname=test'));
include_once 'test.inc.php';

function tester() {
        global $t;
        $res = pg_query(TTT, 'SELECT test_notice()');
        $result = pg_fetch_row($res, 0);
        pg_free_result($res);
        var_dump(pg_last_notice(TTT));
}

tester();
?>

It gives me bool(false) on my windows server (PHP 5) and string(14)
"NOTICE:  11111" on a linux server (PHP 4.3.9).

If I comment the include line, or move the commands outside of the
function body, it works just fine.


Previous Comments:
------------------------------------------------------------------------

[2005-03-08 12:22:44] valiak at gmail dot com

I reproduced the problem on

Darwin ceco.local 7.8.0 Darwin Kernel Version 7.8.0: Wed Dec 22
14:26:17 PST 2004; root:xnu/xnu-517.11.1.obj~1/RELEASE_PPC  Power
Macintosh powerpc

with the same php and postgresql installed

------------------------------------------------------------------------

[2005-03-08 08:59:31] valiak at gmail dot com

the problem still exists :-(

[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ php test.php
1
[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ php -v
PHP 5.1.0-dev (cli) (built: Mar  8 2005 09:54:24)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies

------------------------------------------------------------------------

[2005-03-07 20:06:21] [EMAIL PROTECTED]

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



------------------------------------------------------------------------

[2005-03-07 18:13:54] valiak at gmail dot com

Description:
------------
i've tried to localize to as smallest code as I could
the correct result happens even if you comment the include line or the
global directive or not using exceptions ... (there are few other
modifications too)

it happens with the cli version and with the apache module version

[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ php -v
PHP 5.0.3 (cli) (built: Mar  2 2005 13:13:40)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies

compiled with
./configure --with-gettext --with-oci8 --with-apxs=/usr/bin/apxs
--with-gd --with-pgsql --with-readline --with-zlib --with-mysql=/usr
--with-
jpeg-dir --with-png-dir --enable-mbstring --enable-sockets
--enable-pcntl --enable-sigchild --with-exec-dir=/usr/bin
--with-config-file-path=
/etc/php5


pgsql

PostgreSQL Support => enabled
PostgreSQL(libpq) Version => 8.0.1
Multibyte character support => enabled
SSL support => disabled
Active Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
pgsql.allow_persistent => Off => Off
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off
pgsql.max_links => Unlimited => Unlimited
pgsql.max_persistent => Unlimited => Unlimited


if some more info is needed tell me what to do?

Reproduce code:
---------------
[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ cat test.inc.php
<?
?>
[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ cat test.php
<?

/*
this is a dummy pg function just to raise notice, called from this
file

CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS $$
begin
        RAISE NOTICE '11111';
        return 'f';
end;
$$ LANGUAGE plpgsql;
*/

        define(TTT, pg_connect('user=test password=test
dbname=test'));
        include_once 'test.inc.php';

function tester() {
        global $t;
        $res = pg_query(TTT, 'SELECT test_notice()');
        $result = pg_fetch_row($res, 0);
        pg_free_result($res);
        if ($result[0] == 'f') {
          throw new Exception(pg_last_notice(TTT));
        }
}

try {
echo tester();
echo 2;
}
catch (Exception $e) {
  echo $e->getMessage(), 1;
}

?>


Expected result:
----------------
[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ php test.php
NOTICE:  111111


Actual result:
--------------
[EMAIL PROTECTED] ~/tmp/pg_last_notice
$ php test.php
1



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32223&edit=1

Reply via email to