Skip to content

Commit

Permalink
Fix some missing temporary table drops in several old extension upgra…
Browse files Browse the repository at this point in the history
…de scripts. When updating the emaj extension, an error was sometimes raised with the message <relation "emaj_rlbk_old" already exists>. This happened when the upgrade chains several elementary upgrade scripts that created a temporary table with this same emaj_rlbk_old name.
  • Loading branch information
beaud76 committed Jun 6, 2020
1 parent 1401044 commit 40f6400
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ E-Maj - Change log


###Bug fixes:###


* Fix some missing temporary table drops in several old extension upgrade
scripts.

3.3.0 (2020-Mar-14)
------
Expand Down
3 changes: 3 additions & 0 deletions sql/emaj--2.0.1--2.1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ SELECT CASE WHEN EXISTS (SELECT 1 FROM emaj.emaj_rlbk)
THEN setval('emaj.emaj_rlbk_rlbk_id_seq', (SELECT max(rlbk_id) FROM emaj.emaj_rlbk))
END;

-- and finaly drop the temporary table
DROP TABLE emaj_rlbk_old;

--
-- add created or recreated tables and sequences to the list of content to save by pg_dump
--
Expand Down
6 changes: 6 additions & 0 deletions sql/emaj--2.1.0--2.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ CREATE INDEX emaj_relation_idx2 ON emaj.emaj_relation (rel_log_schema);
-- recreate the foreign keys that point on this table
-- there is no fkey for this table

-- and finaly drop the temporary table
DROP TABLE emaj_relation_old;

--
-- process the emaj_rlbk table
--
Expand Down Expand Up @@ -223,6 +226,9 @@ SELECT CASE WHEN EXISTS (SELECT 1 FROM emaj.emaj_rlbk)
THEN setval('emaj.emaj_rlbk_rlbk_id_seq', (SELECT max(rlbk_id) FROM emaj.emaj_rlbk))
END;

-- and finaly drop the temporary table
DROP TABLE emaj_rlbk_old;

--
-- process the emaj_alter_plan table
--
Expand Down
6 changes: 6 additions & 0 deletions sql/emaj--2.2.3--2.3.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ INSERT INTO emaj.emaj_alter_plan
-- recreate the foreign keys that point on this table
-- set the last value for the sequence associated to the serial column

-- and finaly drop the temporary table
DROP TABLE emaj_alter_plan_old;

--
-- add created or recreated tables and sequences to the list of content to save by pg_dump
--
Expand Down Expand Up @@ -210,6 +213,9 @@ INSERT INTO emaj.emaj_rlbk_plan (
-- recreate the foreign keys that point on this table
-- set the last value for the sequence associated to the serial column

-- and finaly drop the temporary table
DROP TABLE emaj_rlbk_plan_old;

--
-- add created or recreated tables and sequences to the list of content to save by pg_dump
--
Expand Down
3 changes: 3 additions & 0 deletions sql/emaj--3.0.0--3.1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ SELECT CASE WHEN EXISTS (SELECT 1 FROM emaj.emaj_rlbk)
THEN setval('emaj.emaj_rlbk_rlbk_id_seq', (SELECT max(rlbk_id) FROM emaj.emaj_rlbk))
END;

-- and finaly drop the temporary table
DROP TABLE emaj_rlbk_old;

--
-- change the emaj_rlbk_plan table structure
--
Expand Down
3 changes: 3 additions & 0 deletions sql/emaj--3.2.0--3.3.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ CREATE INDEX emaj_relation_idx2 ON emaj.emaj_relation (rel_log_schema);
-- recreate the foreign keys that point on this table
-- there is no fkey for this table

-- and finaly drop the temporary table
DROP TABLE emaj_relation_old;

--
-- add created or recreated tables and sequences to the list of content to save by pg_dump
--
Expand Down

0 comments on commit 40f6400

Please sign in to comment.