forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix extension scripts to support all possible upgrade paths
This commit fixes and extends the extension SQL scripts in a few ways, to allow upgrades from all the possible versions down where the origin is based on PostgreSQL 10, which is the oldest version supported by pg_hint_plan currently. PostgreSQL allows since v10 the maintenance of an extension using as base script the oldest version supported in combination of incremental scripts. A full set of upgrade scripts is added by this commit, considering v10 as the oldest path supported. As origin versions may have a partial schema created for the hint table with partial definitions, the correct rules are enforced for each version when it comes to extension dumps and GRANT rules. The schema for the hint table is only created in the base script. Regression tests are added to cover all these upgrade paths. DATA in the Makefile is changed to hardcode all the SQL scripts that need to be installed. Per pull request yugabyte#111 and issues yugabyte#110 and yugabyte#60. Backpatch-through: 10
- Loading branch information
Showing
15 changed files
with
226 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
-- | ||
-- tests for upgrade paths | ||
-- | ||
CREATE EXTENSION pg_hint_plan VERSION "1.3.0"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.1"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.2"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.3"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.4"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.5"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.6"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.7"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.4"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.5"; | ||
\dx+ pg_hint_plan | ||
Objects in extension "pg_hint_plan" | ||
Object description | ||
--------------------------------- | ||
sequence hint_plan.hints_id_seq | ||
table hint_plan.hints | ||
(2 rows) | ||
|
||
DROP EXTENSION pg_hint_plan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
DROP ROLE IF EXISTS regress_super_user; | ||
DROP ROLE IF EXISTS regress_normal_user; | ||
DROP EXTENSION pg_hint_plan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.0--1.3.1.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.1'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.1--1.3.2.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.2'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.2--1.3.3.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.3'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.3--1.3.4.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.4'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.4--1.3.5.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.5'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.5--1.3.6.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.6'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.6--1.3.7.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.3.7'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.3.7--1.4.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.4'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* pg_hint_plan/pg_hint_plan--1.4--1.5.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use "ALTER EXTENSION pg_dbms_stats UPDATE TO '1.5'" to load this file. \quit | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); | ||
SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); | ||
|
||
GRANT SELECT ON hint_plan.hints TO PUBLIC; | ||
GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- | ||
-- tests for upgrade paths | ||
-- | ||
|
||
CREATE EXTENSION pg_hint_plan VERSION "1.3.0"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.1"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.2"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.3"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.4"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.5"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.6"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.7"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.4"; | ||
\dx+ pg_hint_plan | ||
ALTER EXTENSION pg_hint_plan UPDATE TO "1.5"; | ||
\dx+ pg_hint_plan | ||
DROP EXTENSION pg_hint_plan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
DROP ROLE IF EXISTS regress_super_user; | ||
DROP ROLE IF EXISTS regress_normal_user; | ||
DROP EXTENSION pg_hint_plan; |