diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php index 4b207ed25c3..a3db901cad2 100644 --- a/htdocs/install/etape2.php +++ b/htdocs/install/etape2.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ */ /** - \file htdocs/install/etape2.php - \ingroup install - \brief Cree les tables, cles primaires, cles etrangeres, index et fonctions en base puis charge les donnees de reference - \version $Id$ -*/ + * \file htdocs/install/etape2.php + * \ingroup install + * \brief Cree les tables, cles primaires, cles etrangeres, index et fonctions en base puis charge les donnees de reference + * \version $Id$ + */ include("./inc.php"); require_once($dolibarr_main_document_root."/lib/databases/".$dolibarr_main_db_type.".lib.php"); @@ -289,8 +289,8 @@ if ($_POST["action"] == "set") else { print "".$langs->trans("CreateOtherKeysForTable",$name); - print "
".$langs->trans("Request").' '.$requestnb.' : '.$buffer; - print ""; + print "
\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror(); + print "\n"; print "".$langs->trans("Error")." ".$db->errno()." ".$db->error().""; $error++; } @@ -400,7 +400,7 @@ if ($_POST["action"] == "set") // Creation donnees $handle=opendir($dir); - dolibarr_install_syslog("Ouverture repertoire ".$dir." handle=".$handle,LOG_DEBUG); + dolibarr_install_syslog("Ouverture repertoire data ".$dir." handle=".$handle,LOG_DEBUG); while (($file = readdir($handle))!==false) { if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file)) @@ -439,7 +439,7 @@ if ($_POST["action"] == "set") } } closedir($handle); - + print "".$langs->trans("ReferenceDataLoading").""; if ($ok) { @@ -452,7 +452,7 @@ if ($_POST["action"] == "set") } } print ''; - + $db->close(); } diff --git a/htdocs/install/mysql/tables/llx_co_exp.key.sql b/htdocs/install/mysql/tables/llx_co_exp.key.sql new file mode 100644 index 00000000000..709f772d686 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_co_exp.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_co_exp ADD INDEX idx_co_exp_fk_commande (fk_commande); +ALTER TABLE llx_co_exp ADD INDEX idx_co_exp_fk_expedition (fk_expedition); diff --git a/htdocs/install/mysql/tables/llx_co_exp.sql b/htdocs/install/mysql/tables/llx_co_exp.sql index 2409f14889e..ea5ae5e0fc1 100644 --- a/htdocs/install/mysql/tables/llx_co_exp.sql +++ b/htdocs/install/mysql/tables/llx_co_exp.sql @@ -23,8 +23,5 @@ create table llx_co_exp ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_commande integer NOT NULL, - fk_expedition integer NOT NULL, - - key(fk_commande), - key(fk_expedition) + fk_expedition integer NOT NULL )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_co_fa.key.sql b/htdocs/install/mysql/tables/llx_co_fa.key.sql new file mode 100644 index 00000000000..88b78f8679a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_co_fa.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_co_fa ADD INDEX idx_co_fa_fk_commande (fk_commande); +ALTER TABLE llx_co_fa ADD INDEX idx_co_fa_fk_facture (fk_facture); diff --git a/htdocs/install/mysql/tables/llx_co_fa.sql b/htdocs/install/mysql/tables/llx_co_fa.sql index 79759700b4a..8f1c15d6355 100644 --- a/htdocs/install/mysql/tables/llx_co_fa.sql +++ b/htdocs/install/mysql/tables/llx_co_fa.sql @@ -22,8 +22,5 @@ create table llx_co_fa ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_commande integer NOT NULL, - fk_facture integer NOT NULL, - - key(fk_commande), - key(fk_facture) + fk_facture integer NOT NULL )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_co_liv.key.sql b/htdocs/install/mysql/tables/llx_co_liv.key.sql new file mode 100644 index 00000000000..7027c42fc35 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_co_liv.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_co_liv ADD INDEX idx_co_liv_fk_commande (fk_commande); +ALTER TABLE llx_co_liv ADD INDEX idx_co_liv_fk_livraison (fk_livraison); diff --git a/htdocs/install/mysql/tables/llx_co_liv.sql b/htdocs/install/mysql/tables/llx_co_liv.sql index f76d4532439..34c50c583d3 100644 --- a/htdocs/install/mysql/tables/llx_co_liv.sql +++ b/htdocs/install/mysql/tables/llx_co_liv.sql @@ -23,8 +23,5 @@ create table llx_co_liv ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_commande integer NOT NULL, - fk_livraison integer NOT NULL, - - key(fk_commande), - key(fk_livraison) + fk_livraison integer NOT NULL )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_co_pr.key.sql b/htdocs/install/mysql/tables/llx_co_pr.key.sql new file mode 100644 index 00000000000..9b1b5f16c0f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_co_pr.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_co_pr ADD INDEX idx_co_pr_fk_commande (fk_commande); +ALTER TABLE llx_co_pr ADD INDEX idx_co_pr_fk_propale (fk_propale); diff --git a/htdocs/install/mysql/tables/llx_pr_exp.key.sql b/htdocs/install/mysql/tables/llx_pr_exp.key.sql new file mode 100644 index 00000000000..3486e871897 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_pr_exp.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_pr_exp ADD INDEX idx_pr_exp_fk_propal (fk_propal); +ALTER TABLE llx_pr_exp ADD INDEX idx_pr_exp_fk_expedition (fk_expedition); diff --git a/htdocs/install/mysql/tables/llx_pr_exp.sql b/htdocs/install/mysql/tables/llx_pr_exp.sql index 8a13d05f9e4..5758cb2290d 100644 --- a/htdocs/install/mysql/tables/llx_pr_exp.sql +++ b/htdocs/install/mysql/tables/llx_pr_exp.sql @@ -23,8 +23,5 @@ create table llx_pr_exp ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_propal integer NOT NULL, - fk_expedition integer NOT NULL, - - key(fk_propal), - key(fk_expedition) + fk_expedition integer NOT NULL )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_pr_liv.key.sql b/htdocs/install/mysql/tables/llx_pr_liv.key.sql new file mode 100644 index 00000000000..61212e4c187 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_pr_liv.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_pr_liv ADD INDEX idx_pr_liv_fk_propal (fk_propal); +ALTER TABLE llx_pr_liv ADD INDEX idx_pr_liv_fk_livraison (fk_livraison); diff --git a/htdocs/install/mysql/tables/llx_pr_liv.sql b/htdocs/install/mysql/tables/llx_pr_liv.sql index b63a96afa93..69b39bbe55d 100644 --- a/htdocs/install/mysql/tables/llx_pr_liv.sql +++ b/htdocs/install/mysql/tables/llx_pr_liv.sql @@ -23,8 +23,5 @@ create table llx_pr_liv ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_propal integer NOT NULL, - fk_livraison integer NOT NULL, - - key(fk_propal), - key(fk_livraison) + fk_livraison integer NOT NULL )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_societe_commerciaux.key.sql b/htdocs/install/mysql/tables/llx_societe_commerciaux.key.sql new file mode 100644 index 00000000000..b9643f019c3 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_commerciaux.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2009 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- =================================================================== + +ALTER TABLE llx_societe_commerciaux ADD UNIQUE INDEX uk_societe_commerciaux (fk_soc, fk_user); diff --git a/htdocs/install/mysql/tables/llx_societe_commerciaux.sql b/htdocs/install/mysql/tables/llx_societe_commerciaux.sql index e4ace55fbb8..07c5266f9a9 100644 --- a/htdocs/install/mysql/tables/llx_societe_commerciaux.sql +++ b/htdocs/install/mysql/tables/llx_societe_commerciaux.sql @@ -1,5 +1,6 @@ -- ======================================================================== -- Copyright (C) 2005 Rodolphe Quiedeville +-- Copyright (C) 2009 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -22,8 +23,6 @@ create table llx_societe_commerciaux ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer, - fk_user integer, - - UNIQUE INDEX(fk_soc, fk_user) + fk_user integer )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_user_rights.key.sql b/htdocs/install/mysql/tables/llx_user_rights.key.sql index 2792f924fea..f21099e9c5e 100644 --- a/htdocs/install/mysql/tables/llx_user_rights.key.sql +++ b/htdocs/install/mysql/tables/llx_user_rights.key.sql @@ -20,8 +20,10 @@ -- =========================================================================== --- Supprimme orhpelins pour permettre montée de la clé +-- Supprimme orhpelins pour permettre mont�e de la cl� -- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL; ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); + +ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (fk_user, fk_id); diff --git a/htdocs/install/mysql/tables/llx_user_rights.sql b/htdocs/install/mysql/tables/llx_user_rights.sql index 0dad0470a5d..7d6c1e1c2fd 100644 --- a/htdocs/install/mysql/tables/llx_user_rights.sql +++ b/htdocs/install/mysql/tables/llx_user_rights.sql @@ -22,8 +22,6 @@ create table llx_user_rights ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_user integer NOT NULL, - fk_id integer NOT NULL, - - UNIQUE INDEX(fk_user,fk_id) + fk_id integer NOT NULL )type=innodb; diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 8b3e736550c..fe8895516e2 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -161,7 +161,8 @@ class DoliDb return $line; } if ($line != "") - { # we are inside create table statement so lets process datatypes + { + # we are inside create table statement so lets process datatypes if (preg_match('/(ISAM|innodb)/i',$line)) { # end of create table sequence $line=preg_replace('/\)[\s\t]*type=(MyISAM|innodb);/i',');',$line); $line=preg_replace('/\)[\s\t]*engine=(MyISAM|innodb);/i',');',$line); @@ -172,20 +173,7 @@ class DoliDb $line=preg_replace('/[\s\t]*([a-zA-Z_0-9]*)[\s\t]*.*int.*auto_increment[^,]*/i','\\1 SERIAL PRIMARY KEY',$line); } - # int type conversion - /* } elsif (/(\w*)int\(\d+\)/i) { - $size=$1; - $size =~ tr [A-Z] [a-z]; - if ($size eq "tiny" || $size eq "small") { - $out = "int2"; - } elsif ($size eq "big") { - $out = "int8"; - } else { - $out = "int4"; - } - s/\w*int\(\d+\)/$out/g; - } - */ + # tinyint type conversion $line=str_replace('tinyint','smallint',$line); # nuke unsigned @@ -223,78 +211,22 @@ class DoliDb $line=preg_replace('/^float/i','numeric',$line); $line=preg_replace('/(\s*)float/i','\\1numeric',$line); - # unique key(field1,field2) - /* if (/unique key\s*\((\w+\s*,\s*\w+)\)/i) { - s/unique key\s*\((\w+\s*,\s*\w+)\)/UNIQUE\($1\)/i; - $create_sql.=$_; - next; - } - */ - # unique index(field1,field2) + # unique index(field1,field2) if (preg_match('/unique index\s*\((\w+\s*,\s*\w+)\)/i',$line)) { $line=preg_replace('/unique index\s*\((\w+\s*,\s*\w+)\)/i','UNIQUE\(\\1\)',$line); } - # unique key [name] (field) - /* if (/unique key\s*(\w*)\s*\((\w+)\)/i) { - s/unique key\s*(\w*)\s*\((\w+)\)/UNIQUE\($2\)/i; - my $idxname=($1?"$1":"idx_${table}_$2"); - $create_sql.=$_; - $create_index .= "CREATE INDEX $idxname ON $table ($2);\n"; - next; + + # alter table create [unique] index (field1, field2 ...) + # ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version) + if (preg_match('/ALTER\s*TABLE\s*(.*)\s*ADD\s*(UNIQUE)?\s*(INDEX)?\s*(.*)\s*\(([\w,\s]+)\)/i',$line,$reg)) + { + $fieldlist=$reg[5]; + $idxname=$reg[4]; + $tablename=$reg[1]; + $line = "-- ".$line." replaced by --\n"; + $line.= "CREATE ".($reg[2]?$reg[2].' ':'')."INDEX ".$idxname." ON ".$tablename." (".$fieldlist.")"; } - */ - # unique index [name] (field) - /* if (/unique index\s*(\w*)\s*\((\w+)\)/i) { - s/unique index\s*(\w*)\s*\((\w+)\)/UNIQUE\($2\)/i; - my $idxname=($1?"$1":"idx_${table}_$2"); - $create_sql.=$_; - $create_index .= "CREATE INDEX $idxname ON $table ($2);\n"; - next; - } - */ - # unique (field) et unique (field1, field2 ...) - /* if (/unique\s*\(([\w,\s]+)\)/i) { - s/unique\s*\(([\w,\s]+)\)/UNIQUE\($1\)/i; - my $fieldlist="$1"; - my $idxname="idx_${table}_${fieldlist}"; - $idxname =~ s/\W/_/g; $idxname =~ tr/_/_/s; - $create_sql.=$_; - $create_index .= "CREATE INDEX $idxname ON $table ($fieldlist);\n"; - next; - } - */ - # index(field) - /* if (/index\s*(\w*)\s*\((\w+)\)/i) { - my $idxname=($1?"$1":"idx_${table}_$2"); - $create_index .= "CREATE INDEX $idxname ON $table ($2);\n"; - next; - } - */ - # primary key - /* if (/\bkey\b/i && !/^\s+primary key\s+/i) { - s/KEY(\s+)[^(]*(\s+)/$1 UNIQUE $2/i; # hack off name of the non-primary key - } - */ - # key(xxx) - /* if (/key\s*\((\w+)\)/i) { - my $idxname="idx_${table}_$1"; - $create_index .= "CREATE INDEX $idxname ON $table ($1);\n"; - next; - } - */ - # Quote column names - /* s/(^\s*)([^\s\-\(]+)(\s*)/$1"$2"$3/gi if (!/\bkey\b/i); - */ - # Remap colums with names of existing system attribute - /* if (/"oid"/i) { - s/"oid"/"_oid"/g; - print STDERR "WARNING: table $table uses column \"oid\" which is renamed to \"_oid\"\nYou should fix application manually! Press return to continue."; - my $wait=; - } - s/oid/_oid/i if (/key/i && /oid/i); # fix oid in key - $create_sql.=$_; - */ } # END of if ($create_sql ne "") i.e. were inside create table statement so processed datatypes else { # not inside create table #---- fix data in inserted data: (from MS world) @@ -503,7 +435,7 @@ class DoliDb $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); //print "\n>> ".$query."
\n"; - //print '>> '.$this->lasterrno.' - '.$this->lasterror.' - '.$this->laqtqueryerror."
\n"; + //print '>> '.$this->lasterrno.' - '.$this->lasterror.' - '.$this->lastqueryerror."
\n"; } $this->lastquery=$query; $this->results = $ret; @@ -758,7 +690,7 @@ class DoliDb 1051 => 'DB_ERROR_NOSUCHTABLE', 1054 => 'DB_ERROR_NOSUCHFIELD', 1060 => 'DB_ERROR_COLUMN_ALREADY_EXISTS', - 1061 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', + '42710' => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', 1062 => 'DB_ERROR_RECORD_ALREADY_EXISTS', '42704' => 'DB_ERROR_SYNTAX', '42601' => 'DB_ERROR_SYNTAX', @@ -786,30 +718,14 @@ class DoliDb $errno=$errorcode?$errorcode:$errorlabel; return ($errno?'DB_ERROR_'.$errno:'0'); } - - // TODO Virer cela - if (empty($error_regexps)) - { - $error_regexps = array( - '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => 'DB_ERROR_NOSUCHTABLE', - '/table [\"\'].*[\"\'] does not exist/' => 'DB_ERROR_NOSUCHTABLE', - '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => 'DB_ERROR_RECORD_ALREADY_EXISTS', - '/divide 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 error at or near \"/' => 'DB_ERROR_SYNTAX', - '/referential integrity violation/' => 'DB_ERROR_CONSTRAINT' - ); - } - print 'WW'.pg_last_error($this->db).'WW'; - $valerror=pg_last_error($this->db); - foreach ($error_regexps as $regexp => $code) { - if (preg_match($regexp,$valerror)) { - return $code; - } - } - $errno=$valerror; - return ($errno?'DB_ERROR':'0'); +// '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => 'DB_ERROR_NOSUCHTABLE', +// '/table [\"\'].*[\"\'] does not exist/' => 'DB_ERROR_NOSUCHTABLE', +// '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => 'DB_ERROR_RECORD_ALREADY_EXISTS', +// '/divide 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 error at or near \"/' => 'DB_ERROR_SYNTAX', +// '/referential integrity violation/' => 'DB_ERROR_CONSTRAINT' } /**