simpler PostgreSQL table lookup query, fixes #1361

This commit is contained in:
El RIDO 2024-07-07 12:37:28 +02:00
parent f662640554
commit e0bca0d4dc
2 changed files with 3 additions and 12 deletions

View File

@ -3,6 +3,7 @@
## 1.7.4 (not yet released) ## 1.7.4 (not yet released)
* CHANGED: Saving markdown pastes uses `.md` extension instead of `.txt` (#1293) * CHANGED: Saving markdown pastes uses `.md` extension instead of `.txt` (#1293)
* CHANGED: Enable strict type checking in PHP (#1350) * CHANGED: Enable strict type checking in PHP (#1350)
* CHANGED: Simpler PostgreSQL table lookup query (#1361)
* FIXED: Reset password input field on creation of new paste (#1194) * FIXED: Reset password input field on creation of new paste (#1194)
* FIXED: Allow database schema upgrade to skip versions (#1343) * FIXED: Allow database schema upgrade to skip versions (#1343)
* FIXED: `bootstrap5` dark mode toggle unset on dark browser preference (#1340) * FIXED: `bootstrap5` dark mode toggle unset on dark browser preference (#1340)

View File

@ -598,18 +598,8 @@ class Database extends AbstractData
$sql = 'SELECT table_name FROM all_tables'; $sql = 'SELECT table_name FROM all_tables';
break; break;
case 'pgsql': case 'pgsql':
$sql = 'SELECT c."relname" AS "table_name" ' $sql = 'SELECT "tablename" FROM "pg_catalog"."pg_tables" '
. 'FROM "pg_class" c, "pg_user" u ' . 'WHERE "schemaname" NOT IN (\'pg_catalog\', \'information_schema\')';
. 'WHERE c."relowner" = u."usesysid" AND c."relkind" = \'r\' '
. 'AND NOT EXISTS (SELECT 1 FROM "pg_views" WHERE "viewname" = c."relname") '
. "AND c.\"relname\" !~ '^(pg_|sql_)' "
. 'UNION '
. 'SELECT c."relname" AS "table_name" '
. 'FROM "pg_class" c '
. "WHERE c.\"relkind\" = 'r' "
. 'AND NOT EXISTS (SELECT 1 FROM "pg_views" WHERE "viewname" = c."relname") '
. 'AND NOT EXISTS (SELECT 1 FROM "pg_user" WHERE "usesysid" = c."relowner") '
. "AND c.\"relname\" !~ '^pg_'";
break; break;
case 'sqlite': case 'sqlite':
$sql = 'SELECT "name" FROM "sqlite_master" WHERE "type"=\'table\' ' $sql = 'SELECT "name" FROM "sqlite_master" WHERE "type"=\'table\' '