summaryrefslogtreecommitdiff
path: root/adodb-error.inc.php
diff options
context:
space:
mode:
authorDamien Regad <dregad@mantisbt.org>2014-04-16 02:30:10 +0200
committerDamien Regad <dregad@mantisbt.org>2014-04-16 02:47:48 +0200
commitc6b61d57fbb1046b47e61fa678fa7a585cb356d6 (patch)
tree6c2ce729e92eec3d83e18982d736385f41c7c2db /adodb-error.inc.php
parent2d1e3bbe03d0539d644ebc92256d4c985829817b (diff)
downloadadodb-c6b61d57fbb1046b47e61fa678fa7a585cb356d6.tar.gz
adodb-c6b61d57fbb1046b47e61fa678fa7a585cb356d6.tar.bz2
adodb-c6b61d57fbb1046b47e61fa678fa7a585cb356d6.zip
Fix Postgres error messages mapping to ADOdb error codes
Added 'm' (multiline) flag to preg_match()
Diffstat (limited to 'adodb-error.inc.php')
-rw-r--r--adodb-error.inc.php40
1 files changed, 20 insertions, 20 deletions
diff --git a/adodb-error.inc.php b/adodb-error.inc.php
index bdad9dbd..58e9eac8 100644
--- a/adodb-error.inc.php
+++ b/adodb-error.inc.php
@@ -95,27 +95,27 @@ function adodb_error_pg($errormsg)
{
if (is_numeric($errormsg)) return (integer) $errormsg;
// Postgres has no lock-wait timeout. The best we could do would be to set a statement timeout.
- static $error_regexps = array(
- '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/i' => DB_ERROR_NOSUCHTABLE,
- '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint/i' => DB_ERROR_ALREADY_EXISTS,
- '/database ".+" does not exist$/i' => DB_ERROR_NOSUCHDB,
- '/(divide|division) by zero$/i' => DB_ERROR_DIVZERO,
- '/pg_atoi: error in .*: can\'t parse /i' => DB_ERROR_INVALID_NUMBER,
- '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD,
- '/(parser: parse|syntax) error at or near \"/i' => DB_ERROR_SYNTAX,
- '/referential integrity violation/i' => DB_ERROR_CONSTRAINT,
- '/deadlock detected$/i' => DB_ERROR_DEADLOCK,
- '/canceling statement due to statement timeout$/i' => DB_ERROR_STATEMENT_TIMEOUT,
- '/could not serialize access due to/i' => DB_ERROR_SERIALIZATION_FAILURE
- );
+ static $error_regexps = array(
+ '(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$' => DB_ERROR_NOSUCHTABLE,
+ 'Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint' => DB_ERROR_ALREADY_EXISTS,
+ 'database ".+" does not exist$' => DB_ERROR_NOSUCHDB,
+ '(divide|division) by zero$' => DB_ERROR_DIVZERO,
+ 'pg_atoi: error in .*: can\'t parse ' => DB_ERROR_INVALID_NUMBER,
+ 'ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']' => DB_ERROR_NOSUCHFIELD,
+ '(parser: parse|syntax) error at or near \"' => DB_ERROR_SYNTAX,
+ 'referential integrity violation' => DB_ERROR_CONSTRAINT,
+ 'deadlock detected$' => DB_ERROR_DEADLOCK,
+ 'canceling statement due to statement timeout$' => DB_ERROR_STATEMENT_TIMEOUT,
+ 'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE
+ );
reset($error_regexps);
- while (list($regexp,$code) = each($error_regexps)) {
- if (preg_match($regexp, $errormsg)) {
- return $code;
- }
- }
- // Fall back to DB_ERROR if there was no mapping.
- return DB_ERROR;
+ while (list($regexp,$code) = each($error_regexps)) {
+ if (preg_match("/$regexp/mi", $errormsg)) {
+ return $code;
+ }
+ }
+ // Fall back to DB_ERROR if there was no mapping.
+ return DB_ERROR;
}
function adodb_error_odbc()