BUG Faulty query escape in tableList()

This caused tables starting with "sql" to be excluded from
the tableList() results, where only "sql_" should be filtered.
An unescaped underscore in ANSI SQL pattern matching stands
for "any single character", the escape needed to be doubled
to account for PHP's own escape expanding.

This broke SQLQueryTest since the test data wasn't reset
between test runs.
This commit is contained in:
Ingo Schommer 2012-12-11 15:09:10 +01:00
parent fc7a21b567
commit cd7b761bed
1 changed files with 1 additions and 1 deletions

View File

@ -1264,7 +1264,7 @@ class PostgreSQLDatabase extends SS_Database {
public function tableList() {
$schema_SQL = pg_escape_string($this->dbConn, $this->schema);
$tables=array();
foreach($this->query("SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = '{$schema_SQL}' AND tablename NOT ILIKE 'pg\_%' AND tablename NOT ILIKE 'sql\_%'") as $record) {
foreach($this->query("SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = '{$schema_SQL}' AND tablename NOT ILIKE 'pg\\\_%' AND tablename NOT ILIKE 'sql\\\_%'") as $record) {
//$table = strtolower(reset($record));
$table = reset($record);
$tables[$table] = $table;