|
| 1 | +-- |
| 2 | +-- SQL queries for upgrade tests across different major versions. |
| 3 | +-- |
| 4 | +-- This file includes a set of SQL queries to make a cluster to-be-upgraded |
| 5 | +-- compatible with the version this file is based on. Note that this |
| 6 | +-- requires psql, as per-version queries are controlled with a set of \if |
| 7 | +-- clauses. |
| 8 | + |
| 9 | +-- This script is backward-compatible, so it is able to work with any version |
| 10 | +-- newer than 9.2 we are upgrading from, up to the branch this script is stored |
| 11 | +-- on (even if this would not run if running pg_upgrade with the same version |
| 12 | +-- for the origin and the target). |
| 13 | + |
| 14 | +-- \if accepts a simple boolean value, so all the version checks are |
| 15 | +-- saved based on this assumption. |
| 16 | +SELECT |
| 17 | + ver <= 902 AS oldpgversion_le92, |
| 18 | + ver <= 904 AS oldpgversion_le94, |
| 19 | + ver <= 906 AS oldpgversion_le96, |
| 20 | + ver <= 1000 AS oldpgversion_le10, |
| 21 | + ver <= 1100 AS oldpgversion_le11, |
| 22 | + ver <= 1300 AS oldpgversion_le13 |
| 23 | + FROM (SELECT current_setting('server_version_num')::int / 100 AS ver) AS v; |
| 24 | +\gset |
| 25 | + |
| 26 | +-- Objects last appearing in 9.2. |
| 27 | +\if :oldpgversion_le92 |
| 28 | +-- Note that those tables are removed from the regression tests in 9.3 |
| 29 | +-- and newer versions. |
| 30 | +DROP TABLE abstime_tbl; |
| 31 | +DROP TABLE reltime_tbl; |
| 32 | +DROP TABLE tinterval_tbl; |
| 33 | +\endif |
| 34 | + |
| 35 | +-- Objects last appearing in 9.4. |
| 36 | +\if :oldpgversion_le94 |
| 37 | +-- This aggregate has been fixed in 9.5 and later versions, so drop |
| 38 | +-- and re-create it. |
| 39 | +DROP AGGREGATE array_cat_accum(anyarray); |
| 40 | +CREATE AGGREGATE array_larger_accum (anyarray) ( |
| 41 | + sfunc = array_larger, |
| 42 | + stype = anyarray, |
| 43 | + initcond = $${}$$); |
| 44 | +-- This operator has been fixed in 9.5 and later versions, so drop and |
| 45 | +-- re-create it. |
| 46 | +DROP OPERATOR @#@ (NONE, bigint); |
| 47 | +CREATE OPERATOR @#@ (PROCEDURE = factorial, |
| 48 | + RIGHTARG = bigint); |
| 49 | +\endif |
| 50 | + |
| 51 | +-- Objects last appearing in 9.6. |
| 52 | +\if :oldpgversion_le96 |
| 53 | +DROP FUNCTION public.oldstyle_length(integer, text); |
| 54 | +\endif |
| 55 | + |
| 56 | +-- Objects last appearing in 10. |
| 57 | +\if :oldpgversion_le10 |
| 58 | +DROP FUNCTION IF EXISTS boxarea(box); |
| 59 | +DROP FUNCTION IF EXISTS funny_dup17(); |
| 60 | +\endif |
| 61 | + |
| 62 | +-- Objects last appearing in 11. |
| 63 | +\if :oldpgversion_le11 |
| 64 | +-- WITH OIDS is supported until v11, so remove its support for any |
| 65 | +-- relations marked as such. |
| 66 | +DO $stmt$ |
| 67 | + DECLARE |
| 68 | + rec text; |
| 69 | + BEGIN |
| 70 | + FOR rec in |
| 71 | + SELECT oid::regclass::text |
| 72 | + FROM pg_class |
| 73 | + WHERE relname !~ '^pg_' |
| 74 | + AND relhasoids |
| 75 | + AND relkind in ('r','m') |
| 76 | + ORDER BY 1 |
| 77 | + LOOP |
| 78 | + execute 'ALTER TABLE ' || rec || ' SET WITHOUT OIDS'; |
| 79 | + END LOOP; |
| 80 | + END; $stmt$; |
| 81 | +\endif |
| 82 | + |
| 83 | +-- Objects last appearing in 13. |
| 84 | +\if :oldpgversion_le13 |
| 85 | +-- Until v10, operators could only be dropped one at a time, so be careful |
| 86 | +-- to stick with one command for each drop here. |
| 87 | +DROP OPERATOR public.#@# (pg_catalog.int8, NONE); |
| 88 | +DROP OPERATOR public.#%# (pg_catalog.int8, NONE); |
| 89 | +DROP OPERATOR public.!=- (pg_catalog.int8, NONE); |
| 90 | +DROP OPERATOR public.#@%# (pg_catalog.int8, NONE); |
| 91 | +\endif |
0 commit comments