cvs: pear /DB DB.php /DB/DB ibase.php ifx.php mssql.php odbc.php pgsql.php sqlite.php sybase.php /DB/tests errors.inc /DB/tests/driver
10errormap.phpt
| From: | Daniel Convissor | Date: | Wed, 18 Feb 2004 23:07:12 +0000 |
| Subject: | cvs: pear /DB DB.php /DB/DB ibase.php ifx.php mssql.php odbc.php pgsql.php sqlite.php sybase.php /DB/tests errors.inc /DB/tests/driver 10errormap.phpt |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-16657@lists.php.net to get a copy of this message | ||
danielc Wed Feb 18 18:07:12 2004 EDT
Modified files:
/pear/DB DB.php
/pear/DB/DB ibase.php ifx.php mssql.php odbc.php pgsql.php
sqlite.php sybase.php
/pear/DB/tests errors.inc
/pear/DB/tests/driver 10errormap.phpt
Log:
Map not null constraint errors to DB_ERROR_CONSTRAINT_NOT_NULL.
http://cvs.php.net/diff.php/pear/DB/DB.php?r1=1.54&r2=1.55&ty=u Index: pear/DB/DB.php diff -u pear/DB/DB.php:1.54 pear/DB/DB.php:1.55 --- pear/DB/DB.php:1.54 Wed Feb 18 14:26:52 2004 +++ pear/DB/DB.php Wed Feb 18 18:07:09 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.54 2004/02/18 19:26:52 danielc Exp $ +// $Id: DB.php,v 1.55 2004/02/18 23:07:09 danielc Exp $ // // Database independent query interface. @@ -63,6 +63,7 @@ define('DB_ERROR_EXTENSION_NOT_FOUND',-25); define('DB_ERROR_ACCESS_VIOLATION', -26); define('DB_ERROR_NOSUCHDB', -27); +define('DB_ERROR_CONSTRAINT_NOT_NULL',-29); // }}} @@ -263,7 +264,7 @@ * @author Stig Bakken <ssb@php.net> * @author Tomas V.V.Cox <cox@idecnet.com> * @since PHP 4.0 - * @version $Id: DB.php,v 1.54 2004/02/18 19:26:52 danielc Exp $ + * @version $Id: DB.php,v 1.55 2004/02/18 23:07:09 danielc Exp $ * @category Database */ class DB @@ -495,6 +496,7 @@ DB_ERROR_CANNOT_DELETE => 'can not delete', DB_ERROR_CANNOT_DROP => 'can not drop', DB_ERROR_CONSTRAINT => 'constraint violation', + DB_ERROR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint', DB_ERROR_DIVZERO => 'division by zero', DB_ERROR_INVALID => 'invalid', DB_ERROR_INVALID_DATE => 'invalid date or time', http://cvs.php.net/diff.php/pear/DB/DB/ibase.php?r1=1.61&r2=1.62&ty=u Index: pear/DB/DB/ibase.php diff -u pear/DB/DB/ibase.php:1.61 pear/DB/DB/ibase.php:1.62 --- pear/DB/DB/ibase.php:1.61 Wed Feb 18 00:37:31 2004 +++ pear/DB/DB/ibase.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.61 2004/02/18 05:37:31 danielc Exp $ +// $Id: ibase.php,v 1.62 2004/02/18 23:07:10 danielc Exp $ // Bugs: @@ -31,7 +31,7 @@ * extension. * * @package DB - * @version $Id: ibase.php,v 1.61 2004/02/18 05:37:31 danielc Exp $ + * @version $Id: ibase.php,v 1.62 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Sterling Hughes <sterling@php.net> */ @@ -751,6 +751,7 @@ $error_regexps = array( '/[tT]able not found/' => DB_ERROR_NOSUCHTABLE, '/[tT]able .* already exists/' => DB_ERROR_ALREADY_EXISTS, + '/validation error for column .* value "\*\*\* null/' => DB_ERROR_CONSTRAINT_NOT_NULL, '/violation of [\w ]+ constraint/' => DB_ERROR_CONSTRAINT, '/conversion error from string/' => DB_ERROR_INVALID_NUMBER, '/no permission for/' => DB_ERROR_ACCESS_VIOLATION, http://cvs.php.net/diff.php/pear/DB/DB/ifx.php?r1=1.41&r2=1.42&ty=u Index: pear/DB/DB/ifx.php diff -u pear/DB/DB/ifx.php:1.41 pear/DB/DB/ifx.php:1.42 --- pear/DB/DB/ifx.php:1.41 Wed Feb 18 00:37:31 2004 +++ pear/DB/DB/ifx.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: ifx.php,v 1.41 2004/02/18 05:37:31 danielc Exp $ +// $Id: ifx.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ // Legend: @@ -36,7 +36,7 @@ * extension. * * @package DB - * @version $Id: ifx.php,v 1.41 2004/02/18 05:37:31 danielc Exp $ + * @version $Id: ifx.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Tomas V.V.Cox <cox@idecnet.com> */ @@ -70,9 +70,12 @@ '-217' => DB_ERROR_NOSUCHFIELD, '-239' => DB_ERROR_CONSTRAINT, '-253' => DB_ERROR_SYNTAX, + '-292' => DB_ERROR_CONSTRAINT_NOT_NULL, '-310' => DB_ERROR_ALREADY_EXISTS, '-329' => DB_ERROR_NODBSELECTED, '-346' => DB_ERROR_CONSTRAINT, + '-386' => DB_ERROR_CONSTRAINT_NOT_NULL, + '-391' => DB_ERROR_CONSTRAINT_NOT_NULL, '-554' => DB_ERROR_SYNTAX, '-691' => DB_ERROR_CONSTRAINT, '-1204' => DB_ERROR_INVALID_DATE, http://cvs.php.net/diff.php/pear/DB/DB/mssql.php?r1=1.50&r2=1.51&ty=u Index: pear/DB/DB/mssql.php diff -u pear/DB/DB/mssql.php:1.50 pear/DB/DB/mssql.php:1.51 --- pear/DB/DB/mssql.php:1.50 Wed Feb 18 00:37:31 2004 +++ pear/DB/DB/mssql.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.50 2004/02/18 05:37:31 danielc Exp $ +// $Id: mssql.php,v 1.51 2004/02/18 23:07:10 danielc Exp $ require_once 'DB/common.php'; @@ -26,7 +26,7 @@ * extension. * * @package DB - * @version $Id: mssql.php,v 1.50 2004/02/18 05:37:31 danielc Exp $ + * @version $Id: mssql.php,v 1.51 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Sterling Hughes <sterling@php.net> */ @@ -62,6 +62,7 @@ 207 => DB_ERROR_NOSUCHFIELD, 208 => DB_ERROR_NOSUCHTABLE, 245 => DB_ERROR_INVALID_NUMBER, + 515 => DB_ERROR_CONSTRAINT_NOT_NULL, 547 => DB_ERROR_CONSTRAINT, 2627 => DB_ERROR_CONSTRAINT, 2714 => DB_ERROR_ALREADY_EXISTS, http://cvs.php.net/diff.php/pear/DB/DB/odbc.php?r1=1.41&r2=1.42&ty=u Index: pear/DB/DB/odbc.php diff -u pear/DB/DB/odbc.php:1.41 pear/DB/DB/odbc.php:1.42 --- pear/DB/DB/odbc.php:1.41 Wed Feb 18 14:26:53 2004 +++ pear/DB/DB/odbc.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: odbc.php,v 1.41 2004/02/18 19:26:53 danielc Exp $ +// $Id: odbc.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ // XXX legend: @@ -35,7 +35,7 @@ * extension. * * @package DB - * @version $Id: odbc.php,v 1.41 2004/02/18 19:26:53 danielc Exp $ + * @version $Id: odbc.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Stig Bakken <ssb@php.net> */ @@ -71,6 +71,7 @@ '22008' => DB_ERROR_INVALID_DATE, '22012' => DB_ERROR_DIVZERO, '23000' => DB_ERROR_CONSTRAINT, + '23502' => DB_ERROR_CONSTRAINT_NOT_NULL, '23503' => DB_ERROR_CONSTRAINT, '23505' => DB_ERROR_CONSTRAINT, '24000' => DB_ERROR_INVALID, @@ -86,6 +87,7 @@ 'S0012' => DB_ERROR_NOT_FOUND, 'S0021' => DB_ERROR_ALREADY_EXISTS, 'S0022' => DB_ERROR_NOSUCHFIELD, + 'S1000' => DB_ERROR_CONSTRAINT_NOT_NULL, 'S1009' => DB_ERROR_INVALID, 'S1090' => DB_ERROR_INVALID, 'S1C00' => DB_ERROR_NOT_CAPABLE http://cvs.php.net/diff.php/pear/DB/DB/pgsql.php?r1=1.70&r2=1.71&ty=u Index: pear/DB/DB/pgsql.php diff -u pear/DB/DB/pgsql.php:1.70 pear/DB/DB/pgsql.php:1.71 --- pear/DB/DB/pgsql.php:1.70 Wed Feb 18 00:37:32 2004 +++ pear/DB/DB/pgsql.php Wed Feb 18 18:07:10 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.70 2004/02/18 05:37:32 danielc Exp $ +// $Id: pgsql.php,v 1.71 2004/02/18 23:07:10 danielc Exp $ require_once 'DB/common.php'; @@ -27,7 +27,7 @@ * extension. * * @package DB - * @version $Id: pgsql.php,v 1.70 2004/02/18 05:37:32 danielc Exp $ + * @version $Id: pgsql.php,v 1.71 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Rui Hirokawa <hirokawa@php.net> * @author Stig Bakken <ssb@php.net> @@ -245,6 +245,7 @@ '/ttribute [\"\'].*[\"\'] not found$|[Rr]elation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, '/syntax error at/' => DB_ERROR_SYNTAX, + '/violates not-null constraint/' => DB_ERROR_CONSTRAINT_NOT_NULL, '/violates [\w ]+ constraint/' => DB_ERROR_CONSTRAINT, '/referential integrity violation/' => DB_ERROR_CONSTRAINT ); http://cvs.php.net/diff.php/pear/DB/DB/sqlite.php?r1=1.53&r2=1.54&ty=u Index: pear/DB/DB/sqlite.php diff -u pear/DB/DB/sqlite.php:1.53 pear/DB/DB/sqlite.php:1.54 --- pear/DB/DB/sqlite.php:1.53 Wed Feb 18 00:37:32 2004 +++ pear/DB/DB/sqlite.php Wed Feb 18 18:07:10 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.53 2004/02/18 05:37:32 danielc Exp $ +// $Id: sqlite.php,v 1.54 2004/02/18 23:07:10 danielc Exp $ // SQLite function set: @@ -75,7 +75,7 @@ * PECL extension. * * @package DB - * @version $Id: sqlite.php,v 1.53 2004/02/18 05:37:32 danielc Exp $ + * @version $Id: sqlite.php,v 1.54 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Urs Gehrig <urs@circle.ch> * @author Mika Tuupola <tuupola@appelsiini.net> @@ -427,6 +427,7 @@ '/^no such table:/' => DB_ERROR_NOSUCHTABLE, '/^table .* already exists$/' => DB_ERROR_ALREADY_EXISTS, '/PRIMARY KEY must be unique/i' => DB_ERROR_CONSTRAINT, + '/is not unique/' => DB_ERROR_CONSTRAINT, '/uniqueness constraint failed/' => DB_ERROR_CONSTRAINT, '/^no such column:/' => DB_ERROR_NOSUCHFIELD, '/^near ".*": syntax error$/' => DB_ERROR_SYNTAX http://cvs.php.net/diff.php/pear/DB/DB/sybase.php?r1=1.47&r2=1.48&ty=u Index: pear/DB/DB/sybase.php diff -u pear/DB/DB/sybase.php:1.47 pear/DB/DB/sybase.php:1.48 --- pear/DB/DB/sybase.php:1.47 Wed Feb 18 00:37:32 2004 +++ pear/DB/DB/sybase.php Wed Feb 18 18:07:10 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: sybase.php,v 1.47 2004/02/18 05:37:32 danielc Exp $ +// $Id: sybase.php,v 1.48 2004/02/18 23:07:10 danielc Exp $ // TODO @@ -33,7 +33,7 @@ * extension. * * @package DB - * @version $Id: sybase.php,v 1.47 2004/02/18 05:37:32 danielc Exp $ + * @version $Id: sybase.php,v 1.48 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Sterling Hughes <sterling@php.net> * @author Antônio Carlos Venâncio Júnior <floripa@php.net> @@ -191,6 +191,8 @@ => DB_ERROR_ALREADY_EXISTS, '/Invalid column name/' => DB_ERROR_NOSUCHFIELD, + '/does not allow null values/' + => DB_ERROR_CONSTRAINT_NOT_NULL, '/Command has been aborted/' => DB_ERROR_CONSTRAINT, ); http://cvs.php.net/diff.php/pear/DB/tests/errors.inc?r1=1.11&r2=1.12&ty=u Index: pear/DB/tests/errors.inc diff -u pear/DB/tests/errors.inc:1.11 pear/DB/tests/errors.inc:1.12 --- pear/DB/tests/errors.inc:1.11 Wed Feb 11 17:19:52 2004 +++ pear/DB/tests/errors.inc Wed Feb 18 18:07:11 2004 @@ -68,6 +68,16 @@ break; } + +print "Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL\n"; +$dbh->query('INSERT INTO a VALUES (NULL)'); +switch ($dbh->phptype) { + case 'sqlite': + print " $dbh->phptype doesn't consider this an error\n"; + break; +} + + print "Trying to provoke DB_ERROR_DIVZERO\n"; // Interbase detects the error on fetching $dbh->getAll("SELECT 0/0 FROM phptest"); http://cvs.php.net/diff.php/pear/DB/tests/driver/10errormap.phpt?r1=1.6&r2=1.7&ty=u Index: pear/DB/tests/driver/10errormap.phpt diff -u pear/DB/tests/driver/10errormap.phpt:1.6 pear/DB/tests/driver/10errormap.phpt:1.7 --- pear/DB/tests/driver/10errormap.phpt:1.6 Mon Feb 9 22:58:45 2004 +++ pear/DB/tests/driver/10errormap.phpt Wed Feb 18 18:07:11 2004 @@ -24,6 +24,8 @@ DB Error: constraint violation Trying to provoke DB_ERROR_CONSTRAINT for foreign key DB Error: constraint violation +Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL + DB Error: null value violates not-null constraint Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero Trying to provoke DB_ERROR_INVALID_NUMBER
http://cvs.php.net/diff.php/pear/DB/DB.php?r1=1.54&r2=1.55&ty=u Index: pear/DB/DB.php diff -u pear/DB/DB.php:1.54 pear/DB/DB.php:1.55 --- pear/DB/DB.php:1.54 Wed Feb 18 14:26:52 2004 +++ pear/DB/DB.php Wed Feb 18 18:07:09 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.54 2004/02/18 19:26:52 danielc Exp $ +// $Id: DB.php,v 1.55 2004/02/18 23:07:09 danielc Exp $ // // Database independent query interface. @@ -63,6 +63,7 @@ define('DB_ERROR_EXTENSION_NOT_FOUND',-25); define('DB_ERROR_ACCESS_VIOLATION', -26); define('DB_ERROR_NOSUCHDB', -27); +define('DB_ERROR_CONSTRAINT_NOT_NULL',-29); // }}} @@ -263,7 +264,7 @@ * @author Stig Bakken <ssb@php.net> * @author Tomas V.V.Cox <cox@idecnet.com> * @since PHP 4.0 - * @version $Id: DB.php,v 1.54 2004/02/18 19:26:52 danielc Exp $ + * @version $Id: DB.php,v 1.55 2004/02/18 23:07:09 danielc Exp $ * @category Database */ class DB @@ -495,6 +496,7 @@ DB_ERROR_CANNOT_DELETE => 'can not delete', DB_ERROR_CANNOT_DROP => 'can not drop', DB_ERROR_CONSTRAINT => 'constraint violation', + DB_ERROR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint', DB_ERROR_DIVZERO => 'division by zero', DB_ERROR_INVALID => 'invalid', DB_ERROR_INVALID_DATE => 'invalid date or time', http://cvs.php.net/diff.php/pear/DB/DB/ibase.php?r1=1.61&r2=1.62&ty=u Index: pear/DB/DB/ibase.php diff -u pear/DB/DB/ibase.php:1.61 pear/DB/DB/ibase.php:1.62 --- pear/DB/DB/ibase.php:1.61 Wed Feb 18 00:37:31 2004 +++ pear/DB/DB/ibase.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.61 2004/02/18 05:37:31 danielc Exp $ +// $Id: ibase.php,v 1.62 2004/02/18 23:07:10 danielc Exp $ // Bugs: @@ -31,7 +31,7 @@ * extension. * * @package DB - * @version $Id: ibase.php,v 1.61 2004/02/18 05:37:31 danielc Exp $ + * @version $Id: ibase.php,v 1.62 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Sterling Hughes <sterling@php.net> */ @@ -751,6 +751,7 @@ $error_regexps = array( '/[tT]able not found/' => DB_ERROR_NOSUCHTABLE, '/[tT]able .* already exists/' => DB_ERROR_ALREADY_EXISTS, + '/validation error for column .* value "\*\*\* null/' => DB_ERROR_CONSTRAINT_NOT_NULL, '/violation of [\w ]+ constraint/' => DB_ERROR_CONSTRAINT, '/conversion error from string/' => DB_ERROR_INVALID_NUMBER, '/no permission for/' => DB_ERROR_ACCESS_VIOLATION, http://cvs.php.net/diff.php/pear/DB/DB/ifx.php?r1=1.41&r2=1.42&ty=u Index: pear/DB/DB/ifx.php diff -u pear/DB/DB/ifx.php:1.41 pear/DB/DB/ifx.php:1.42 --- pear/DB/DB/ifx.php:1.41 Wed Feb 18 00:37:31 2004 +++ pear/DB/DB/ifx.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: ifx.php,v 1.41 2004/02/18 05:37:31 danielc Exp $ +// $Id: ifx.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ // Legend: @@ -36,7 +36,7 @@ * extension. * * @package DB - * @version $Id: ifx.php,v 1.41 2004/02/18 05:37:31 danielc Exp $ + * @version $Id: ifx.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Tomas V.V.Cox <cox@idecnet.com> */ @@ -70,9 +70,12 @@ '-217' => DB_ERROR_NOSUCHFIELD, '-239' => DB_ERROR_CONSTRAINT, '-253' => DB_ERROR_SYNTAX, + '-292' => DB_ERROR_CONSTRAINT_NOT_NULL, '-310' => DB_ERROR_ALREADY_EXISTS, '-329' => DB_ERROR_NODBSELECTED, '-346' => DB_ERROR_CONSTRAINT, + '-386' => DB_ERROR_CONSTRAINT_NOT_NULL, + '-391' => DB_ERROR_CONSTRAINT_NOT_NULL, '-554' => DB_ERROR_SYNTAX, '-691' => DB_ERROR_CONSTRAINT, '-1204' => DB_ERROR_INVALID_DATE, http://cvs.php.net/diff.php/pear/DB/DB/mssql.php?r1=1.50&r2=1.51&ty=u Index: pear/DB/DB/mssql.php diff -u pear/DB/DB/mssql.php:1.50 pear/DB/DB/mssql.php:1.51 --- pear/DB/DB/mssql.php:1.50 Wed Feb 18 00:37:31 2004 +++ pear/DB/DB/mssql.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.50 2004/02/18 05:37:31 danielc Exp $ +// $Id: mssql.php,v 1.51 2004/02/18 23:07:10 danielc Exp $ require_once 'DB/common.php'; @@ -26,7 +26,7 @@ * extension. * * @package DB - * @version $Id: mssql.php,v 1.50 2004/02/18 05:37:31 danielc Exp $ + * @version $Id: mssql.php,v 1.51 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Sterling Hughes <sterling@php.net> */ @@ -62,6 +62,7 @@ 207 => DB_ERROR_NOSUCHFIELD, 208 => DB_ERROR_NOSUCHTABLE, 245 => DB_ERROR_INVALID_NUMBER, + 515 => DB_ERROR_CONSTRAINT_NOT_NULL, 547 => DB_ERROR_CONSTRAINT, 2627 => DB_ERROR_CONSTRAINT, 2714 => DB_ERROR_ALREADY_EXISTS, http://cvs.php.net/diff.php/pear/DB/DB/odbc.php?r1=1.41&r2=1.42&ty=u Index: pear/DB/DB/odbc.php diff -u pear/DB/DB/odbc.php:1.41 pear/DB/DB/odbc.php:1.42 --- pear/DB/DB/odbc.php:1.41 Wed Feb 18 14:26:53 2004 +++ pear/DB/DB/odbc.php Wed Feb 18 18:07:10 2004 @@ -17,7 +17,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: odbc.php,v 1.41 2004/02/18 19:26:53 danielc Exp $ +// $Id: odbc.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ // XXX legend: @@ -35,7 +35,7 @@ * extension. * * @package DB - * @version $Id: odbc.php,v 1.41 2004/02/18 19:26:53 danielc Exp $ + * @version $Id: odbc.php,v 1.42 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Stig Bakken <ssb@php.net> */ @@ -71,6 +71,7 @@ '22008' => DB_ERROR_INVALID_DATE, '22012' => DB_ERROR_DIVZERO, '23000' => DB_ERROR_CONSTRAINT, + '23502' => DB_ERROR_CONSTRAINT_NOT_NULL, '23503' => DB_ERROR_CONSTRAINT, '23505' => DB_ERROR_CONSTRAINT, '24000' => DB_ERROR_INVALID, @@ -86,6 +87,7 @@ 'S0012' => DB_ERROR_NOT_FOUND, 'S0021' => DB_ERROR_ALREADY_EXISTS, 'S0022' => DB_ERROR_NOSUCHFIELD, + 'S1000' => DB_ERROR_CONSTRAINT_NOT_NULL, 'S1009' => DB_ERROR_INVALID, 'S1090' => DB_ERROR_INVALID, 'S1C00' => DB_ERROR_NOT_CAPABLE http://cvs.php.net/diff.php/pear/DB/DB/pgsql.php?r1=1.70&r2=1.71&ty=u Index: pear/DB/DB/pgsql.php diff -u pear/DB/DB/pgsql.php:1.70 pear/DB/DB/pgsql.php:1.71 --- pear/DB/DB/pgsql.php:1.70 Wed Feb 18 00:37:32 2004 +++ pear/DB/DB/pgsql.php Wed Feb 18 18:07:10 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.70 2004/02/18 05:37:32 danielc Exp $ +// $Id: pgsql.php,v 1.71 2004/02/18 23:07:10 danielc Exp $ require_once 'DB/common.php'; @@ -27,7 +27,7 @@ * extension. * * @package DB - * @version $Id: pgsql.php,v 1.70 2004/02/18 05:37:32 danielc Exp $ + * @version $Id: pgsql.php,v 1.71 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Rui Hirokawa <hirokawa@php.net> * @author Stig Bakken <ssb@php.net> @@ -245,6 +245,7 @@ '/ttribute [\"\'].*[\"\'] not found$|[Rr]elation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, '/syntax error at/' => DB_ERROR_SYNTAX, + '/violates not-null constraint/' => DB_ERROR_CONSTRAINT_NOT_NULL, '/violates [\w ]+ constraint/' => DB_ERROR_CONSTRAINT, '/referential integrity violation/' => DB_ERROR_CONSTRAINT ); http://cvs.php.net/diff.php/pear/DB/DB/sqlite.php?r1=1.53&r2=1.54&ty=u Index: pear/DB/DB/sqlite.php diff -u pear/DB/DB/sqlite.php:1.53 pear/DB/DB/sqlite.php:1.54 --- pear/DB/DB/sqlite.php:1.53 Wed Feb 18 00:37:32 2004 +++ pear/DB/DB/sqlite.php Wed Feb 18 18:07:10 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.53 2004/02/18 05:37:32 danielc Exp $ +// $Id: sqlite.php,v 1.54 2004/02/18 23:07:10 danielc Exp $ // SQLite function set: @@ -75,7 +75,7 @@ * PECL extension. * * @package DB - * @version $Id: sqlite.php,v 1.53 2004/02/18 05:37:32 danielc Exp $ + * @version $Id: sqlite.php,v 1.54 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Urs Gehrig <urs@circle.ch> * @author Mika Tuupola <tuupola@appelsiini.net> @@ -427,6 +427,7 @@ '/^no such table:/' => DB_ERROR_NOSUCHTABLE, '/^table .* already exists$/' => DB_ERROR_ALREADY_EXISTS, '/PRIMARY KEY must be unique/i' => DB_ERROR_CONSTRAINT, + '/is not unique/' => DB_ERROR_CONSTRAINT, '/uniqueness constraint failed/' => DB_ERROR_CONSTRAINT, '/^no such column:/' => DB_ERROR_NOSUCHFIELD, '/^near ".*": syntax error$/' => DB_ERROR_SYNTAX http://cvs.php.net/diff.php/pear/DB/DB/sybase.php?r1=1.47&r2=1.48&ty=u Index: pear/DB/DB/sybase.php diff -u pear/DB/DB/sybase.php:1.47 pear/DB/DB/sybase.php:1.48 --- pear/DB/DB/sybase.php:1.47 Wed Feb 18 00:37:32 2004 +++ pear/DB/DB/sybase.php Wed Feb 18 18:07:10 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: sybase.php,v 1.47 2004/02/18 05:37:32 danielc Exp $ +// $Id: sybase.php,v 1.48 2004/02/18 23:07:10 danielc Exp $ // TODO @@ -33,7 +33,7 @@ * extension. * * @package DB - * @version $Id: sybase.php,v 1.47 2004/02/18 05:37:32 danielc Exp $ + * @version $Id: sybase.php,v 1.48 2004/02/18 23:07:10 danielc Exp $ * @category Database * @author Sterling Hughes <sterling@php.net> * @author Antônio Carlos Venâncio Júnior <floripa@php.net> @@ -191,6 +191,8 @@ => DB_ERROR_ALREADY_EXISTS, '/Invalid column name/' => DB_ERROR_NOSUCHFIELD, + '/does not allow null values/' + => DB_ERROR_CONSTRAINT_NOT_NULL, '/Command has been aborted/' => DB_ERROR_CONSTRAINT, ); http://cvs.php.net/diff.php/pear/DB/tests/errors.inc?r1=1.11&r2=1.12&ty=u Index: pear/DB/tests/errors.inc diff -u pear/DB/tests/errors.inc:1.11 pear/DB/tests/errors.inc:1.12 --- pear/DB/tests/errors.inc:1.11 Wed Feb 11 17:19:52 2004 +++ pear/DB/tests/errors.inc Wed Feb 18 18:07:11 2004 @@ -68,6 +68,16 @@ break; } + +print "Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL\n"; +$dbh->query('INSERT INTO a VALUES (NULL)'); +switch ($dbh->phptype) { + case 'sqlite': + print " $dbh->phptype doesn't consider this an error\n"; + break; +} + + print "Trying to provoke DB_ERROR_DIVZERO\n"; // Interbase detects the error on fetching $dbh->getAll("SELECT 0/0 FROM phptest"); http://cvs.php.net/diff.php/pear/DB/tests/driver/10errormap.phpt?r1=1.6&r2=1.7&ty=u Index: pear/DB/tests/driver/10errormap.phpt diff -u pear/DB/tests/driver/10errormap.phpt:1.6 pear/DB/tests/driver/10errormap.phpt:1.7 --- pear/DB/tests/driver/10errormap.phpt:1.6 Mon Feb 9 22:58:45 2004 +++ pear/DB/tests/driver/10errormap.phpt Wed Feb 18 18:07:11 2004 @@ -24,6 +24,8 @@ DB Error: constraint violation Trying to provoke DB_ERROR_CONSTRAINT for foreign key DB Error: constraint violation +Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL + DB Error: null value violates not-null constraint Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero Trying to provoke DB_ERROR_INVALID_NUMBER