[ticket/15319] Add IF EXISTS to Postgres DROP SEQUENCE query

This commit is contained in:
Serge Skripchuk 2017-08-13 15:33:04 +03:00
parent d9a5c8e918
commit 3aac61cfa7
2 changed files with 2 additions and 2 deletions

View file

@ -85,7 +85,7 @@ class postgres_extractor extends base_extractor
// We don't even care about storing the results. We already know the answer if we get rows back. // We don't even care about storing the results. We already know the answer if we get rows back.
if ($this->db->sql_fetchrow($result)) if ($this->db->sql_fetchrow($result))
{ {
$sql_data .= "DROP SEQUENCE {$table_name}_seq;\n"; $sql_data .= "DROP SEQUENCE IF EXISTS {$table_name}_seq;\n";
$sql_data .= "CREATE SEQUENCE {$table_name}_seq;\n"; $sql_data .= "CREATE SEQUENCE {$table_name}_seq;\n";
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);

View file

@ -448,7 +448,7 @@ class postgres extends tools
// We don't even care about storing the results. We already know the answer if we get rows back. // We don't even care about storing the results. We already know the answer if we get rows back.
if ($this->db->sql_fetchrow($result)) if ($this->db->sql_fetchrow($result))
{ {
$statements[] = "DROP SEQUENCE {$table_name}_seq;\n"; $statements[] = "DROP SEQUENCE IF EXISTS {$table_name}_seq;\n";
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);