From e0bca0d4dc7239f2e66629a4446eec2cd45c8589 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 7 Jul 2024 12:37:28 +0200 Subject: [PATCH] simpler PostgreSQL table lookup query, fixes #1361 --- CHANGELOG.md | 1 + lib/Data/Database.php | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d9485a..d7727b26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.7.4 (not yet released) * CHANGED: Saving markdown pastes uses `.md` extension instead of `.txt` (#1293) * 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: Allow database schema upgrade to skip versions (#1343) * FIXED: `bootstrap5` dark mode toggle unset on dark browser preference (#1340) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index addc6c44..2fb209b0 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -598,18 +598,8 @@ class Database extends AbstractData $sql = 'SELECT table_name FROM all_tables'; break; case 'pgsql': - $sql = 'SELECT c."relname" AS "table_name" ' - . 'FROM "pg_class" c, "pg_user" u ' - . '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_'"; + $sql = 'SELECT "tablename" FROM "pg_catalog"."pg_tables" ' + . 'WHERE "schemaname" NOT IN (\'pg_catalog\', \'information_schema\')'; break; case 'sqlite': $sql = 'SELECT "name" FROM "sqlite_master" WHERE "type"=\'table\' '