Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #1089 postgresql "permission denied" error ignored when using PEAR_ERROR_RETURN mode
Submitted: 2004-03-29 15:14 UTC
From: arhuaco at yahoo dot com Assigned: danielc
Status: Bogus Package: DB
PHP Version: 4.3.4 OS: Debian GNU/Linux testing
Roadmaps: (Not assigned)    
Subscription  


 [2004-03-29 15:14 UTC] arhuaco at yahoo dot com
Description: ------------ An error gets ignored when I try to insert a record with an user who is not allowed to insert it. The error gets ignored when I use PEAR_ERROR_RETURN mode (An error object is not returned). If I use PEAR_ERROR_PRINT, I get the error "DB Error: unknown error" and if I use PEAR_ERROR_DIE the script dies with the same message. I'm using postgresql 7.3.4 and php 4.3.3. From the command line: psql -U kumaralogin --password -h 127.0.0.1 login login=> insert into usuarios (usuarios_login) values ('nelson'); ERROR: usuarios: permission denied login=> The print_r of the returned object is : db_pgsql Object ( [connection] => Resource id #10 [phptype] => pgsql [dbsyntax] => pgsql [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [transaction_opcount] => 0 [dsn] => Array ( [phptype] => pgsql [dbsyntax] => pgsql [username] => user [password] => pass [protocol] => tcp [hostspec] => localhost [port] => [socket] => [database] => login ) [row] => Array ( ) [num_rows] => Array ( ) [affected] => 0 [autocommit] => 1 [fetchmode] => 1 [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) [features] => Array ( [prepare] => [pconnect] => 1 [transactions] => 1 [limit] => alter ) [errorcode_map] => Array ( ) [type] => [prepared_queries] => Array ( ) [prepare_maxstmt] => 0 [last_query] => INSERT INTO usuarios (usuarios_login) VALUES ('nelson') [fetchmode_object_class] => stdClass [options] => Array ( [persistent] => [optimize] => performance [debug] => 2 [seqname_format] => %s_seq [autofree] => ) [dbh] => ) This configuration is the one of the Debian package php4-pear 4:4.3.4-3. '../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=php' '--with-config-file-path=/etc/php4/apache' '--disable-rpath' '--enable-memory-limit' '--disable-debug' '--with-layout=GNU' '--with-pear=/usr/share/php' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db4' '--with-iconv' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--disable-xml' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--with-kerberos=/usr' '--with-openssl=/usr' '--with-exec-dir=/usr/lib/php4/libexec' '--disable-static' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-dom-xslt=shared,/usr' '--with-dom-exslt=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-imap-ssl' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--with-mm' '--with-mysql=shared,/usr' '--with-unixODBC=shared,/usr' '--with-recode=shared,/usr' '--enable-xslt=shared' '--with-xslt-sablot=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-sybase-ct=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr' Reproduce code: --------------- PEAR::setErrorHandling(PEAR_ERROR_RETURN); //PEAR::setErrorHandling(PEAR_ERROR_PRINT); //PEAR::setErrorHandling(PEAR_ERROR_DIE); $db =& DB::connect($my_dsn, $my_options); if (DB::isError($db)) echo $db->getMessage(); $db->autoExecute('users', array ('users_login' => 'nelson'), DB_AUTOQUERY_INSERT); if (DB::isError($db)) echo "Detected error " . $db->getMessage(); echo " ... passed"; ... Expected result: ---------------- I expect to see: Detected error : DB Error: unknown error. Actual result: -------------- I see nothing: If I use PEAR_ERROR_PRINT, the error "DB Error: unknown error" gets printed. With PEAR_ERROR_DIE the script dies with the same message.

Comments

 [2004-03-29 15:29 UTC] arhuaco at yahoo dot com
I just tried with PHP 4.3.4 and the error persists. Thanks.
 [2004-03-30 01:03 UTC] danielc
Your example runs isError() on $db. You need to be checking the DB_result object: $result = $db->autoExecute(...); if (DB::isError($result)) echo "Detected error " . $result->getMessage(); I have updated the Auto Prepare / Auto Execute documentation to clarify this situation. The changes will show up on Sunday.