diff --git a/ecrire/base/abstract_sql.php b/ecrire/base/abstract_sql.php index 536d70c7ef237e7fc609870ead1694213025ac7b..e469aff2a590ad4e35772f38ac13d046b889c301 100644 --- a/ecrire/base/abstract_sql.php +++ b/ecrire/base/abstract_sql.php @@ -245,7 +245,7 @@ function calcul_mysql_in($val, $valeurs, $not='') { // http://doc.spip.org/@description_table function description_table($nom){ - global $tables_principales, $tables_auxiliaires, $table_des_tables, $tables_des_serveurs_sql; + global $tables_principales, $tables_auxiliaires; static $tables_externes = array(); if (isset($tables_externes[$nom])) diff --git a/ecrire/base/db_pg.php b/ecrire/base/db_pg.php index ddeae40e5a24e9992ff8ececae81e8849757ac1d..023e1830ca1727e03aa9a9772fb764b23b46e453 100644 --- a/ecrire/base/db_pg.php +++ b/ecrire/base/db_pg.php @@ -553,12 +553,12 @@ function spip_pg_errno() { } // http://doc.spip.org/@spip_pg_showtable -function spip_pg_showtable($nom_table) +function spip_pg_showtable($nom_table, $serveur='') { $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; $link = $connexion['link']; - $res = pg_query($link, "SELECT column_name, column_default, data_type FROM information_schema.columns WHERE table_name=" . _q($nom_table)); + $res = pg_query($link, "SELECT column_name, column_default, data_type FROM information_schema.columns WHERE table_name ILIKE " . _q($nom_table)); if (!$res) return false; @@ -567,13 +567,13 @@ function spip_pg_showtable($nom_table) $fields[$field[0]] = $field[2] . (!$field[1] ? '' : (" DEFAULT " . $field[1])); } - $res = pg_query($link, "SELECT indexdef FROM pg_indexes WHERE tablename=" . _q($nom_table)); + $res = pg_query($link, "SELECT indexdef FROM pg_indexes WHERE tablename ILIKE " . _q($nom_table)); $keys = array(); while($index = pg_fetch_array($res, NULL, PGSQL_NUM)) { if (preg_match('/CREATE\s+(UNIQUE\s+)?INDEX.*\((.*)\)$/', $index[0],$r)) { $index = split(',', $r[2]); - $keys[($r[1] ? "PRIMARY KEY " : "KEY ") . $index[0]] = + $keys[($r[1] ? "PRIMARY KEY" : ("KEY " . $index[0]))] = $r[2]; } } @@ -667,7 +667,7 @@ function spip_pg_create($nom, $champs, $cles, $autoinc=false, $temporary=false, if (!$r) spip_log("table $nom deja la"); else { - foreach($keys as $index) {@pg_query($link, $index);} + foreach($keys as $index) {pg_query($link, $index);} } return $r; } diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php index 0c78925b3dab5813cd93667690d39965e1cf6b0b..c56b9abb56984d1491e6a43578b5f272a39200bc 100644 --- a/ecrire/public/criteres.php +++ b/ecrire/public/criteres.php @@ -1049,8 +1049,8 @@ function trouver_table($type, $boucle) if (!isset($tables_des_serveurs_sql[$s][$nom_table])) { $desc = sql_showtable($nom_table, $serveur, ($nom_table != $type)); - if (!$desc) { - erreur_squelette(_T('zbug_table_inconnue', array('table' => $type)), + if (!$desc OR !$desc['field']) { + erreur_squelette(_T('zbug_table_inconnue', array('table' => $s ? "$serveur:$type" : $type)), $boucle->id_boucle); return null; }