Add expected files for regression tests.
Due to compatibility break by the recent PostgreSQL core code changes
we need to split expected files into each minor releases rather than
each major releases.
Now the mapping between PostgreSQL version and expected file is
complicated as follows.
* version 10
* >= 10.3 : repack_3.out, tablespace_2.out
* < 10.3 : repack_2.out, tablespace.out
* version 9.6
* >= 9.6.8 : repack_4.out, tablespace_2.out
* < 9.6.8 : repack.out, tablespace.out
* version 9.5
* >= 9.5.12 : repack_4.out, tablespace_2.out
* < 9.5.12 : repack.out, tablespace_1.out
* version 9.4
* >= 9.4.17 : repack_5.out, tablespace_2.out
* < 9.4.17 : repack_1.out, tablespace_1.out
* version 9.3
* >= 9.3.22 : repack_6.out, tablespace_3.out
* < 9.3.22 : repack_1.out, tablespace_1.out
* version 9.2 : repack_1.out, tablespace_1.out
* version 9.1 : repack_1.out, tablespace_1.out
2018-03-09 13:43:04 +09:00
|
|
|
-- Setup function to get version number.
|
|
|
|
-- This function returns a value same as PG_VERSION_NUM.
|
|
|
|
CREATE OR REPLACE FUNCTION version_num() RETURNS int AS
|
|
|
|
$$
|
|
|
|
DECLARE
|
|
|
|
version_int int[];
|
|
|
|
version_str text;
|
|
|
|
BEGIN
|
|
|
|
SELECT string_to_array(split_part(version(), ' ', 2), '.')::int[] INTO version_int;
|
|
|
|
IF array_length(version_int, 1) = 2 THEN -- version 10 or higher
|
|
|
|
SELECT to_char(version_int[1], 'FM00') || '00' || to_char(version_int[2], 'FM00') INTO version_str;
|
|
|
|
ELSIF array_length(version_int, 1) = 3 THEN --version 9.6 or lower
|
|
|
|
SELECT to_char(version_int[1], 'FM00') || to_char(version_int[2], 'FM00') || to_char(version_int[3], 'FM00') INTO version_str;
|
|
|
|
ELSE
|
|
|
|
RAISE 'invalid version';
|
|
|
|
END IF;
|
|
|
|
RETURN version_str::int;
|
|
|
|
END;
|
|
|
|
$$
|
|
|
|
LANGUAGE plpgsql IMMUTABLE STRICT;
|
|
|
|
|
2017-04-25 15:26:35 +01:00
|
|
|
-- Test output file identifier.
|
Add expected files for regression tests.
Due to compatibility break by the recent PostgreSQL core code changes
we need to split expected files into each minor releases rather than
each major releases.
Now the mapping between PostgreSQL version and expected file is
complicated as follows.
* version 10
* >= 10.3 : repack_3.out, tablespace_2.out
* < 10.3 : repack_2.out, tablespace.out
* version 9.6
* >= 9.6.8 : repack_4.out, tablespace_2.out
* < 9.6.8 : repack.out, tablespace.out
* version 9.5
* >= 9.5.12 : repack_4.out, tablespace_2.out
* < 9.5.12 : repack.out, tablespace_1.out
* version 9.4
* >= 9.4.17 : repack_5.out, tablespace_2.out
* < 9.4.17 : repack_1.out, tablespace_1.out
* version 9.3
* >= 9.3.22 : repack_6.out, tablespace_3.out
* < 9.3.22 : repack_1.out, tablespace_1.out
* version 9.2 : repack_1.out, tablespace_1.out
* version 9.1 : repack_1.out, tablespace_1.out
2018-03-09 13:43:04 +09:00
|
|
|
SELECT
|
|
|
|
CASE
|
|
|
|
WHEN version_num >= 100000 THEN -- PostgreSQL 10
|
|
|
|
CASE
|
|
|
|
WHEN version_num >= 100003 THEN
|
|
|
|
'repack_3.out'
|
|
|
|
ELSE
|
|
|
|
'repack_2.out'
|
|
|
|
END
|
|
|
|
WHEN version_num >= 90600 THEN -- PostgrSQL 9.6
|
|
|
|
CASE
|
|
|
|
WHEN version_num >= 90608 THEN
|
|
|
|
'repack_4.out'
|
|
|
|
ELSE
|
|
|
|
'repack.out'
|
|
|
|
END
|
|
|
|
WHEN version_num >= 90500 THEN -- PostgreSQL 9.5
|
|
|
|
CASE
|
|
|
|
WHEN version_num >= 90512 THEN
|
|
|
|
'repack_4.out'
|
|
|
|
ELSE
|
|
|
|
'repack.out'
|
|
|
|
END
|
|
|
|
WHEN version_num >= 90400 THEN -- PostgreSQL 9.4
|
|
|
|
CASE
|
|
|
|
WHEN version_num >= 90417 THEN
|
|
|
|
'repack_5.out'
|
|
|
|
ELSE
|
|
|
|
'repack_1.out'
|
|
|
|
END
|
|
|
|
WHEN version_num >= 90300 THEN -- PostgreSQL 9.3
|
|
|
|
CASE
|
|
|
|
WHEN version_num >= 90322 THEN
|
|
|
|
'repack_5.out'
|
|
|
|
ELSE
|
|
|
|
'repack_6.out'
|
|
|
|
END
|
|
|
|
WHEN version_num >= 90200 THEN -- PostgreSQL 9.2
|
|
|
|
'repack_1.out'
|
|
|
|
WHEN version_num >= 90100 THEN -- PostgreSQL 9.1
|
|
|
|
'repack_1.out'
|
|
|
|
END
|
|
|
|
FROM version_num() as version_num;
|
2017-04-25 15:26:35 +01:00
|
|
|
|
2009-01-21 08:09:22 +00:00
|
|
|
SET client_min_messages = warning;
|
|
|
|
--
|
|
|
|
-- create table.
|
|
|
|
--
|
|
|
|
CREATE TABLE tbl_cluster (
|
|
|
|
col1 int,
|
2010-06-14 05:11:26 +00:00
|
|
|
"time" timestamp,
|
2009-12-28 08:25:00 +00:00
|
|
|
","")" text,
|
2010-02-05 03:24:22 +00:00
|
|
|
PRIMARY KEY (","")", col1) WITH (fillfactor = 75)
|
2009-01-21 08:09:22 +00:00
|
|
|
) WITH (fillfactor = 70);
|
|
|
|
|
2010-06-14 05:11:26 +00:00
|
|
|
CREATE INDEX ","") cluster" ON tbl_cluster ("time", length(","")"), ","")" text_pattern_ops) WITH (fillfactor = 75);
|
2009-12-28 08:25:00 +00:00
|
|
|
ALTER TABLE tbl_cluster CLUSTER ON ","") cluster";
|
2009-01-21 08:09:22 +00:00
|
|
|
|
|
|
|
CREATE TABLE tbl_only_pkey (
|
|
|
|
col1 int PRIMARY KEY,
|
2009-12-28 08:25:00 +00:00
|
|
|
","")" text
|
2009-01-21 08:09:22 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE tbl_only_ckey (
|
|
|
|
col1 int,
|
|
|
|
col2 timestamp,
|
2009-12-28 08:25:00 +00:00
|
|
|
","")" text
|
2009-01-21 08:09:22 +00:00
|
|
|
) WITH (fillfactor = 70);
|
|
|
|
|
2009-12-28 08:25:00 +00:00
|
|
|
CREATE INDEX cidx_only_ckey ON tbl_only_ckey (col2, ","")");
|
2009-01-21 08:09:22 +00:00
|
|
|
ALTER TABLE tbl_only_ckey CLUSTER ON cidx_only_ckey;
|
|
|
|
|
|
|
|
CREATE TABLE tbl_gistkey (
|
|
|
|
id integer PRIMARY KEY,
|
|
|
|
c circle
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX cidx_circle ON tbl_gistkey USING gist (c);
|
|
|
|
ALTER TABLE tbl_gistkey CLUSTER ON cidx_circle;
|
|
|
|
|
2009-07-02 09:50:58 +00:00
|
|
|
CREATE TABLE tbl_with_dropped_column (
|
|
|
|
d1 text,
|
|
|
|
c1 text,
|
|
|
|
id integer PRIMARY KEY,
|
|
|
|
d2 text,
|
|
|
|
c2 text,
|
|
|
|
d3 text
|
|
|
|
);
|
2010-02-05 03:24:22 +00:00
|
|
|
ALTER INDEX tbl_with_dropped_column_pkey SET (fillfactor = 75);
|
2009-07-02 09:50:58 +00:00
|
|
|
ALTER TABLE tbl_with_dropped_column CLUSTER ON tbl_with_dropped_column_pkey;
|
2010-02-05 03:24:22 +00:00
|
|
|
CREATE INDEX idx_c1c2 ON tbl_with_dropped_column (c1, c2) WITH (fillfactor = 75);
|
2009-07-02 09:50:58 +00:00
|
|
|
CREATE INDEX idx_c2c1 ON tbl_with_dropped_column (c2, c1);
|
|
|
|
|
2010-04-21 09:25:20 +00:00
|
|
|
CREATE TABLE tbl_with_dropped_toast (
|
|
|
|
i integer,
|
|
|
|
j integer,
|
|
|
|
t text,
|
|
|
|
PRIMARY KEY (i, j)
|
|
|
|
);
|
|
|
|
ALTER TABLE tbl_with_dropped_toast CLUSTER ON tbl_with_dropped_toast_pkey;
|
|
|
|
|
2012-10-16 23:29:36 +01:00
|
|
|
CREATE TABLE tbl_badindex (
|
|
|
|
id integer PRIMARY KEY,
|
|
|
|
n integer
|
|
|
|
);
|
|
|
|
|
2012-10-21 16:54:33 -07:00
|
|
|
CREATE TABLE tbl_idxopts (
|
|
|
|
i integer PRIMARY KEY,
|
|
|
|
t text
|
|
|
|
);
|
|
|
|
CREATE INDEX idxopts_t ON tbl_idxopts (t DESC NULLS LAST) WHERE (t != 'aaa');
|
|
|
|
|
2017-04-10 23:07:40 +01:00
|
|
|
-- Use this table to play with attribute options too
|
|
|
|
ALTER TABLE tbl_idxopts ALTER i SET STATISTICS 1;
|
|
|
|
ALTER TABLE tbl_idxopts ALTER t SET (n_distinct = -0.5);
|
2017-04-03 20:30:00 +09:00
|
|
|
CREATE TABLE tbl_with_toast (
|
|
|
|
i integer PRIMARY KEY,
|
|
|
|
c text
|
|
|
|
);
|
|
|
|
ALTER TABLE tbl_with_toast SET (AUTOVACUUM_VACUUM_SCALE_FACTOR = 30, AUTOVACUUM_VACUUM_THRESHOLD = 300);
|
|
|
|
ALTER TABLE tbl_with_toast SET (TOAST.AUTOVACUUM_VACUUM_SCALE_FACTOR = 40, TOAST.AUTOVACUUM_VACUUM_THRESHOLD = 400);
|
2017-04-03 18:52:17 +09:00
|
|
|
CREATE TABLE tbl_with_mod_column_storage (
|
|
|
|
id integer PRIMARY KEY,
|
|
|
|
c text
|
|
|
|
);
|
|
|
|
ALTER TABLE tbl_with_mod_column_storage ALTER c SET STORAGE MAIN;
|
2017-04-10 23:07:40 +01:00
|
|
|
|
2017-08-05 02:31:47 +09:00
|
|
|
CREATE TABLE tbl_order (c int primary key);
|
2009-01-23 02:33:11 +00:00
|
|
|
--
|
|
|
|
-- insert data
|
|
|
|
--
|
|
|
|
|
2009-01-21 08:09:22 +00:00
|
|
|
INSERT INTO tbl_cluster VALUES(1, '2008-12-31 10:00:00', 'admin');
|
|
|
|
INSERT INTO tbl_cluster VALUES(2, '2008-01-01 00:00:00', 'king');
|
|
|
|
INSERT INTO tbl_cluster VALUES(3, '2008-03-04 12:00:00', 'joker');
|
|
|
|
INSERT INTO tbl_cluster VALUES(4, '2008-03-05 15:00:00', 'queen');
|
|
|
|
INSERT INTO tbl_cluster VALUES(5, '2008-01-01 00:30:00', sqrt(2::numeric(1000,999))::text || sqrt(3::numeric(1000,999))::text);
|
|
|
|
|
2009-01-23 02:33:11 +00:00
|
|
|
INSERT INTO tbl_only_pkey VALUES(1, 'abc');
|
|
|
|
INSERT INTO tbl_only_pkey VALUES(2, 'def');
|
|
|
|
|
|
|
|
INSERT INTO tbl_only_ckey VALUES(1, '2008-01-01 00:00:00', 'abc');
|
|
|
|
INSERT INTO tbl_only_ckey VALUES(2, '2008-02-01 00:00:00', 'def');
|
|
|
|
|
|
|
|
INSERT INTO tbl_gistkey VALUES(1, '<(1,2),3>');
|
|
|
|
INSERT INTO tbl_gistkey VALUES(2, '<(4,5),6>');
|
|
|
|
|
2009-07-02 09:50:58 +00:00
|
|
|
INSERT INTO tbl_with_dropped_column VALUES('d1', 'c1', 2, 'd2', 'c2', 'd3');
|
|
|
|
INSERT INTO tbl_with_dropped_column VALUES('d1', 'c1', 1, 'd2', 'c2', 'd3');
|
|
|
|
ALTER TABLE tbl_with_dropped_column DROP COLUMN d1;
|
|
|
|
ALTER TABLE tbl_with_dropped_column DROP COLUMN d2;
|
|
|
|
ALTER TABLE tbl_with_dropped_column DROP COLUMN d3;
|
|
|
|
ALTER TABLE tbl_with_dropped_column ADD COLUMN c3 text;
|
2011-04-29 05:06:48 +00:00
|
|
|
CREATE VIEW view_for_dropped_column AS
|
|
|
|
SELECT * FROM tbl_with_dropped_column;
|
2010-04-21 09:25:20 +00:00
|
|
|
|
|
|
|
INSERT INTO tbl_with_dropped_toast VALUES(1, 10, 'abc');
|
|
|
|
INSERT INTO tbl_with_dropped_toast VALUES(2, 20, sqrt(2::numeric(1000,999))::text || sqrt(3::numeric(1000,999))::text);
|
|
|
|
ALTER TABLE tbl_with_dropped_toast DROP COLUMN t;
|
2012-10-16 23:29:36 +01:00
|
|
|
|
|
|
|
INSERT INTO tbl_badindex VALUES(1, 10);
|
|
|
|
INSERT INTO tbl_badindex VALUES(2, 10);
|
2012-11-11 23:38:38 +00:00
|
|
|
|
2017-04-03 18:52:17 +09:00
|
|
|
-- insert data that is always stored into the toast table if column type is extended.
|
2017-10-03 11:51:07 -07:00
|
|
|
SELECT setseed(0); INSERT INTO tbl_with_mod_column_storage SELECT 1, array_to_string(ARRAY(SELECT chr((random() * (127 - 32) + 32)::int) FROM generate_series(1, 3 * 1024) code), '');
|
2017-04-03 18:52:17 +09:00
|
|
|
|
2012-11-11 23:38:38 +00:00
|
|
|
-- This will fail. Silence the message as it's different across PG versions.
|
|
|
|
SET client_min_messages = fatal;
|
2012-10-16 23:29:36 +01:00
|
|
|
CREATE UNIQUE INDEX CONCURRENTLY idx_badindex_n ON tbl_badindex (n);
|
2012-11-11 23:38:38 +00:00
|
|
|
SET client_min_messages = warning;
|
2012-10-16 23:29:36 +01:00
|
|
|
|
2012-10-21 16:54:33 -07:00
|
|
|
INSERT INTO tbl_idxopts VALUES (0, 'abc'), (1, 'aaa'), (2, NULL), (3, 'bbb');
|
|
|
|
|
2017-08-05 02:31:47 +09:00
|
|
|
-- Insert no-ordered data
|
|
|
|
INSERT INTO tbl_order SELECT generate_series(100, 51, -1);
|
|
|
|
CLUSTER tbl_order USING tbl_order_pkey;
|
|
|
|
INSERT INTO tbl_order SELECT generate_series(50, 1, -1);
|
2009-07-02 09:50:58 +00:00
|
|
|
--
|
|
|
|
-- before
|
|
|
|
--
|
|
|
|
|
|
|
|
SELECT * FROM tbl_with_dropped_column;
|
2011-04-29 05:06:48 +00:00
|
|
|
SELECT * FROM view_for_dropped_column;
|
2010-04-21 09:25:20 +00:00
|
|
|
SELECT * FROM tbl_with_dropped_toast;
|
2009-07-02 09:50:58 +00:00
|
|
|
|
2009-01-21 08:09:22 +00:00
|
|
|
--
|
2012-11-10 22:33:57 +00:00
|
|
|
-- do repack
|
2009-01-21 08:09:22 +00:00
|
|
|
--
|
|
|
|
|
2013-04-17 18:56:50 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster
|
2013-04-17 01:42:22 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_badindex
|
2012-11-10 22:33:57 +00:00
|
|
|
\! pg_repack --dbname=contrib_regression
|
2009-01-21 08:09:22 +00:00
|
|
|
|
|
|
|
--
|
2009-07-02 09:50:58 +00:00
|
|
|
-- after
|
2009-01-21 08:09:22 +00:00
|
|
|
--
|
|
|
|
|
2009-01-23 02:33:11 +00:00
|
|
|
\d tbl_cluster
|
|
|
|
\d tbl_gistkey
|
|
|
|
\d tbl_only_ckey
|
|
|
|
\d tbl_only_pkey
|
2009-07-02 09:50:58 +00:00
|
|
|
\d tbl_with_dropped_column
|
2010-04-21 09:25:20 +00:00
|
|
|
\d tbl_with_dropped_toast
|
2012-10-21 16:54:33 -07:00
|
|
|
\d tbl_idxopts
|
2009-01-21 08:09:22 +00:00
|
|
|
|
2017-04-03 18:52:17 +09:00
|
|
|
SELECT col1, to_char("time", 'YYYY-MM-DD HH24:MI:SS'), ","")" FROM tbl_cluster ORDER BY 1, 2;
|
2009-01-23 02:33:11 +00:00
|
|
|
SELECT * FROM tbl_only_ckey ORDER BY 1;
|
|
|
|
SELECT * FROM tbl_only_pkey ORDER BY 1;
|
|
|
|
SELECT * FROM tbl_gistkey ORDER BY 1;
|
2011-04-29 05:06:48 +00:00
|
|
|
|
|
|
|
SET enable_seqscan = on;
|
|
|
|
SET enable_indexscan = off;
|
2017-04-03 18:52:17 +09:00
|
|
|
SELECT * FROM tbl_with_dropped_column ;
|
|
|
|
SELECT * FROM view_for_dropped_column ORDER BY 1, 2;
|
2011-04-29 05:06:48 +00:00
|
|
|
SELECT * FROM tbl_with_dropped_toast;
|
|
|
|
SET enable_seqscan = off;
|
|
|
|
SET enable_indexscan = on;
|
2017-04-03 18:52:17 +09:00
|
|
|
SELECT * FROM tbl_with_dropped_column ORDER BY 1, 2;
|
2011-04-29 05:06:48 +00:00
|
|
|
SELECT * FROM view_for_dropped_column;
|
2010-04-21 09:25:20 +00:00
|
|
|
SELECT * FROM tbl_with_dropped_toast;
|
2011-04-29 05:06:48 +00:00
|
|
|
RESET enable_seqscan;
|
|
|
|
RESET enable_indexscan;
|
2017-04-03 20:30:00 +09:00
|
|
|
-- check if storage option for both table and TOAST table didn't go away.
|
|
|
|
SELECT CASE relkind
|
|
|
|
WHEN 'r' THEN relname
|
|
|
|
WHEN 't' THEN 'toast_table'
|
|
|
|
END as table,
|
|
|
|
reloptions
|
|
|
|
FROM pg_class
|
2017-04-03 21:10:28 +09:00
|
|
|
WHERE relname = 'tbl_with_toast' OR relname = 'pg_toast_' || 'tbl_with_toast'::regclass::oid
|
|
|
|
ORDER BY 1;
|
2017-04-03 18:52:17 +09:00
|
|
|
SELECT pg_relation_size(reltoastrelid) = 0 as check_toast_rel_size FROM pg_class WHERE relname = 'tbl_with_mod_column_storage';
|
2010-04-21 09:25:20 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- check broken links or orphan toast relations
|
|
|
|
--
|
|
|
|
SELECT oid, relname
|
|
|
|
FROM pg_class
|
|
|
|
WHERE relkind = 't'
|
|
|
|
AND oid NOT IN (SELECT reltoastrelid FROM pg_class WHERE relkind = 'r');
|
|
|
|
|
|
|
|
SELECT oid, relname
|
|
|
|
FROM pg_class
|
|
|
|
WHERE relkind = 'r'
|
|
|
|
AND reltoastrelid <> 0
|
|
|
|
AND reltoastrelid NOT IN (SELECT oid FROM pg_class WHERE relkind = 't');
|
2011-01-06 09:35:15 +00:00
|
|
|
|
2017-04-10 23:07:40 +01:00
|
|
|
-- check columns options
|
|
|
|
SELECT attname, attstattarget, attoptions
|
|
|
|
FROM pg_attribute
|
|
|
|
WHERE attrelid = 'tbl_idxopts'::regclass
|
|
|
|
AND attnum > 0
|
|
|
|
ORDER BY attnum;
|
|
|
|
|
2011-01-06 09:35:15 +00:00
|
|
|
--
|
|
|
|
-- NOT NULL UNIQUE
|
|
|
|
--
|
|
|
|
CREATE TABLE tbl_nn (col1 int NOT NULL, col2 int NOT NULL);
|
|
|
|
CREATE TABLE tbl_uk (col1 int NOT NULL, col2 int , UNIQUE(col1, col2));
|
|
|
|
CREATE TABLE tbl_nn_uk (col1 int NOT NULL, col2 int NOT NULL, UNIQUE(col1, col2));
|
|
|
|
CREATE TABLE tbl_pk_uk (col1 int NOT NULL, col2 int NOT NULL, PRIMARY KEY(col1, col2), UNIQUE(col2, col1));
|
2012-11-15 00:16:38 +00:00
|
|
|
CREATE TABLE tbl_nn_puk (col1 int NOT NULL, col2 int NOT NULL);
|
|
|
|
CREATE UNIQUE INDEX tbl_nn_puk_pcol1_idx ON tbl_nn_puk(col1) WHERE col1 < 10;
|
2013-04-17 01:42:22 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_nn
|
2012-12-06 21:26:12 -07:00
|
|
|
-- => WARNING
|
2013-04-17 01:42:22 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_uk
|
2012-12-06 21:26:12 -07:00
|
|
|
-- => WARNING
|
2013-04-17 01:42:22 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_nn_uk
|
2011-01-06 09:35:15 +00:00
|
|
|
-- => OK
|
2013-04-17 01:42:22 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_pk_uk
|
2011-01-06 09:35:15 +00:00
|
|
|
-- => OK
|
2014-05-24 00:09:03 -04:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_pk_uk --only-indexes
|
|
|
|
-- => OK
|
2013-04-17 01:42:22 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_nn_puk
|
2012-12-06 21:26:12 -07:00
|
|
|
-- => WARNING
|
2013-04-18 01:22:24 +01:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Triggers handling
|
|
|
|
--
|
|
|
|
CREATE FUNCTION trgtest() RETURNS trigger AS
|
|
|
|
$$BEGIN RETURN NEW; END$$
|
|
|
|
LANGUAGE plpgsql;
|
|
|
|
CREATE TABLE trg1 (id integer PRIMARY KEY);
|
2017-01-24 14:09:05 +09:00
|
|
|
CREATE TRIGGER repack_trigger_1 AFTER UPDATE ON trg1 FOR EACH ROW EXECUTE PROCEDURE trgtest();
|
2013-04-18 01:22:24 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=trg1
|
|
|
|
CREATE TABLE trg2 (id integer PRIMARY KEY);
|
2017-01-24 14:09:05 +09:00
|
|
|
CREATE TRIGGER repack_trigger AFTER UPDATE ON trg2 FOR EACH ROW EXECUTE PROCEDURE trgtest();
|
2013-04-18 01:22:24 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=trg2
|
|
|
|
CREATE TABLE trg3 (id integer PRIMARY KEY);
|
2017-01-24 14:09:05 +09:00
|
|
|
CREATE TRIGGER repack_trigger_1 BEFORE UPDATE ON trg3 FOR EACH ROW EXECUTE PROCEDURE trgtest();
|
2013-04-18 01:22:24 +01:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=trg3
|
2014-01-30 12:53:48 +00:00
|
|
|
|
2017-08-05 02:31:47 +09:00
|
|
|
--
|
|
|
|
-- Table re-organization using specific column
|
|
|
|
--
|
|
|
|
|
|
|
|
-- reorganize table using cluster key. Sort in ascending order.
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_order
|
|
|
|
SELECT ctid, c FROM tbl_order WHERE ctid <= '(0,10)';
|
|
|
|
|
|
|
|
-- reorganize table using specific column order. Sort in descending order.
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_order -o "c DESC"
|
|
|
|
SELECT ctid, c FROM tbl_order WHERE ctid <= '(0,10)';
|
|
|
|
|
|
|
|
|
2014-01-30 12:53:48 +00:00
|
|
|
--
|
|
|
|
-- Dry run
|
|
|
|
--
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --dry-run
|
2014-05-24 15:42:24 -04:00
|
|
|
|
2014-01-31 08:22:12 +00:00
|
|
|
-- Test --schema
|
2014-01-30 12:19:21 +00:00
|
|
|
--
|
2014-01-30 12:27:32 +00:00
|
|
|
CREATE SCHEMA test_schema1;
|
|
|
|
CREATE TABLE test_schema1.tbl1 (id INTEGER PRIMARY KEY);
|
|
|
|
CREATE TABLE test_schema1.tbl2 (id INTEGER PRIMARY KEY);
|
|
|
|
CREATE SCHEMA test_schema2;
|
|
|
|
CREATE TABLE test_schema2.tbl1 (id INTEGER PRIMARY KEY);
|
|
|
|
CREATE TABLE test_schema2.tbl2 (id INTEGER PRIMARY KEY);
|
2014-01-31 08:22:12 +00:00
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --schema=test_schema1
|
|
|
|
-- => OK
|
2014-01-30 12:27:32 +00:00
|
|
|
\! pg_repack --dbname=contrib_regression --schema=test_schema1 --schema=test_schema2
|
2014-01-31 08:22:12 +00:00
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --schema=test_schema1 --table=tbl1
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --all --schema=test_schema1
|
2017-01-19 18:26:13 +09:00
|
|
|
|
|
|
|
--
|
|
|
|
-- don't kill backend
|
|
|
|
--
|
2017-02-22 03:49:04 +00:00
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-kill-backend
|
2017-03-02 02:58:41 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- no superuser check
|
|
|
|
--
|
|
|
|
DROP ROLE IF EXISTS nosuper;
|
|
|
|
CREATE ROLE nosuper WITH LOGIN;
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --no-superuser-check
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper --no-superuser-check
|
|
|
|
DROP ROLE IF EXISTS nosuper;
|
2017-03-22 15:04:27 +03:00
|
|
|
|
2017-03-23 16:26:46 +03:00
|
|
|
--
|
|
|
|
-- exclude extension check
|
|
|
|
--
|
|
|
|
CREATE SCHEMA exclude_extension_schema;
|
|
|
|
CREATE TABLE exclude_extension_schema.tbl(val integer primary key);
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=dummy_table --exclude-extension=dummy_extension
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=dummy_table --exclude-extension=dummy_extension -x
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --index=dummy_index --exclude-extension=dummy_extension
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension --exclude-extension=dummy_extension
|
2017-03-24 16:54:16 +03:00
|
|
|
|
2017-03-22 15:04:27 +03:00
|
|
|
--
|
|
|
|
-- table inheritance check
|
|
|
|
--
|
|
|
|
CREATE TABLE parent_a(val integer primary key);
|
|
|
|
CREATE TABLE child_a_1(val integer primary key) INHERITS(parent_a);
|
|
|
|
CREATE TABLE child_a_2(val integer primary key) INHERITS(parent_a);
|
|
|
|
CREATE TABLE parent_b(val integer primary key);
|
|
|
|
CREATE TABLE child_b_1(val integer primary key) INHERITS(parent_b);
|
|
|
|
CREATE TABLE child_b_2(val integer primary key) INHERITS(parent_b);
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --parent-table=dummy_table
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --parent-table=dummy_index --index=dummy_index
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --parent-table=dummy_table --schema=dummy_schema
|
|
|
|
-- => ERROR
|
|
|
|
\! pg_repack --dbname=contrib_regression --parent-table=dummy_table --all
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b --only-indexes
|
|
|
|
-- => OK
|
|
|
|
\! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b --only-indexes
|