From 37518342c65d1212abb85e10a191ae3057a1d63f Mon Sep 17 00:00:00 2001 From: Alfredo Ramos Date: Sat, 8 May 2021 01:12:46 -0500 Subject: [PATCH] [ticket/16773] Add missing constraints in PostgreSQL backups PHPBB3-16773 --- phpBB/phpbb/db/extractor/postgres_extractor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/db/extractor/postgres_extractor.php b/phpBB/phpbb/db/extractor/postgres_extractor.php index 07c4d38043..2b271104e8 100644 --- a/phpBB/phpbb/db/extractor/postgres_extractor.php +++ b/phpBB/phpbb/db/extractor/postgres_extractor.php @@ -208,7 +208,7 @@ class postgres_extractor extends base_extractor } // Generate constraint clauses for CHECK constraints - $sql_checks = "SELECT pc.conname AS index_name, pg_get_constraintdef(pc.oid) + $sql_checks = "SELECT pc.conname AS index_name, pg_get_expr(pc.conbin, pc.conrelid) AS constraint_expr FROM pg_constraint pc, pg_class bc WHERE pc.conrelid = bc.oid AND bc.relname = '" . $this->db->sql_escape($table_name) . "' @@ -225,9 +225,9 @@ class postgres_extractor extends base_extractor // Add the constraints to the sql file. while ($row = $this->db->sql_fetchrow($result)) { - if (!is_null($row['consrc'])) + if (!empty($row['constraint_expr'])) { - $lines[] = ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['consrc']; + $lines[] = ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['constraint_expr']; } } $this->db->sql_freeresult($result);