@@ -114,10 +114,20 @@ SELECT * FROM tbl_with_dropped_toast;
114
114
--
115
115
-- do repack
116
116
--
117
- \! pg_repack --dbname=contrib_regression --no-order
117
+ \! pg_repack --dbname=contrib_regression --table=tbl_cluster
118
+ INFO: repacking table "tbl_cluster"
119
+ \! pg_repack --dbname=contrib_regression --table=tbl_badindex
120
+ INFO: repacking table "tbl_badindex"
118
121
WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON tbl_badindex USING btree (n)
119
122
\! pg_repack --dbname=contrib_regression
120
- \! pg_repack --dbname=contrib_regression --table=tbl_cluster
123
+ INFO: repacking table "tbl_cluster"
124
+ INFO: repacking table "tbl_only_pkey"
125
+ INFO: repacking table "tbl_gistkey"
126
+ INFO: repacking table "tbl_with_dropped_column"
127
+ INFO: repacking table "tbl_with_dropped_toast"
128
+ INFO: repacking table "tbl_badindex"
129
+ WARNING: skipping invalid index: CREATE UNIQUE INDEX idx_badindex_n ON tbl_badindex USING btree (n)
130
+ INFO: repacking table "tbl_idxopts"
121
131
--
122
132
-- after
123
133
--
@@ -301,64 +311,44 @@ CREATE TABLE tbl_nn_uk (col1 int NOT NULL, col2 int NOT NULL, UNIQUE(col1, col2)
301
311
CREATE TABLE tbl_pk_uk (col1 int NOT NULL, col2 int NOT NULL, PRIMARY KEY(col1, col2), UNIQUE(col2, col1));
302
312
CREATE TABLE tbl_nn_puk (col1 int NOT NULL, col2 int NOT NULL);
303
313
CREATE UNIQUE INDEX tbl_nn_puk_pcol1_idx ON tbl_nn_puk(col1) WHERE col1 < 10;
304
- \! pg_repack --dbname=contrib_regression --no-order -- table=tbl_nn
314
+ \! pg_repack --dbname=contrib_regression --table=tbl_nn
305
315
WARNING: relation "tbl_nn" must have a primary key or not-null unique keys
306
316
-- => WARNING
307
- \! pg_repack --dbname=contrib_regression --no-order -- table=tbl_uk
317
+ \! pg_repack --dbname=contrib_regression --table=tbl_uk
308
318
WARNING: relation "tbl_uk" must have a primary key or not-null unique keys
309
319
-- => WARNING
310
- \! pg_repack --dbname=contrib_regression --no-order --table=tbl_nn_uk
320
+ \! pg_repack --dbname=contrib_regression --table=tbl_nn_uk
321
+ INFO: repacking table "tbl_nn_uk"
311
322
-- => OK
312
- \! pg_repack --dbname=contrib_regression --no-order --table=tbl_pk_uk
323
+ \! pg_repack --dbname=contrib_regression --table=tbl_pk_uk
324
+ INFO: repacking table "tbl_pk_uk"
313
325
-- => OK
314
- \! pg_repack --dbname=contrib_regression --no-order -- table=tbl_nn_puk
326
+ \! pg_repack --dbname=contrib_regression --table=tbl_nn_puk
315
327
WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys
316
328
-- => WARNING
317
329
--
318
- -- pg_repack issue #3
330
+ -- Triggers handling
319
331
--
320
- CREATE TABLE issue3_1 (col1 int NOT NULL, col2 text NOT NULL);
321
- CREATE UNIQUE INDEX issue3_1_idx ON issue3_1 (col1, col2 DESC);
322
- SELECT repack.get_order_by('issue3_1_idx'::regclass::oid, 'issue3_1'::regclass::oid);
323
- get_order_by
324
- -----------------
325
- col1, col2 DESC
326
- (1 row)
327
-
328
- \! pg_repack --dbname=contrib_regression --no-order --table=issue3_1
329
- CREATE TABLE issue3_2 (col1 int NOT NULL, col2 text NOT NULL);
330
- CREATE UNIQUE INDEX issue3_2_idx ON issue3_2 (col1 DESC, col2 text_pattern_ops);
331
- SELECT repack.get_order_by('issue3_2_idx'::regclass::oid, 'issue3_2'::regclass::oid);
332
- get_order_by
333
- ---------------------------
334
- col1 DESC, col2 USING ~<~
335
- (1 row)
336
-
337
- \! pg_repack --dbname=contrib_regression --no-order --table=issue3_2
338
- CREATE TABLE issue3_3 (col1 int NOT NULL, col2 text NOT NULL);
339
- CREATE UNIQUE INDEX issue3_3_idx ON issue3_3 (col1 DESC, col2 DESC);
340
- SELECT repack.get_order_by('issue3_3_idx'::regclass::oid, 'issue3_3'::regclass::oid);
341
- get_order_by
342
- ----------------------
343
- col1 DESC, col2 DESC
344
- (1 row)
345
-
346
- \! pg_repack --dbname=contrib_regression --no-order --table=issue3_3
347
- CREATE TABLE issue3_4 (col1 int NOT NULL, col2 text NOT NULL);
348
- CREATE UNIQUE INDEX issue3_4_idx ON issue3_4 (col1 NULLS FIRST, col2 text_pattern_ops DESC NULLS LAST);
349
- SELECT repack.get_order_by('issue3_4_idx'::regclass::oid, 'issue3_4'::regclass::oid);
350
- get_order_by
351
- --------------------------------------------------
352
- col1 NULLS FIRST, col2 DESC USING ~<~ NULLS LAST
353
- (1 row)
354
-
355
- \! pg_repack --dbname=contrib_regression --no-order --table=issue3_4
356
- CREATE TABLE issue3_5 (col1 int NOT NULL, col2 text NOT NULL);
357
- CREATE UNIQUE INDEX issue3_5_idx ON issue3_5 (col1 DESC NULLS FIRST, col2 COLLATE "POSIX" DESC);
358
- SELECT repack.get_order_by('issue3_5_idx'::regclass::oid, 'issue3_5'::regclass::oid);
359
- get_order_by
360
- --------------------------------------
361
- col1 DESC, col2 COLLATE "POSIX" DESC
362
- (1 row)
363
-
364
- \! pg_repack --dbname=contrib_regression --no-order --table=issue3_5
332
+ CREATE FUNCTION trgtest() RETURNS trigger AS
333
+ $$BEGIN RETURN NEW; END$$
334
+ LANGUAGE plpgsql;
335
+ CREATE TABLE trg1 (id integer PRIMARY KEY);
336
+ CREATE TRIGGER z_repack_triggeq BEFORE UPDATE ON trg1 FOR EACH ROW EXECUTE PROCEDURE trgtest();
337
+ \! pg_repack --dbname=contrib_regression --table=trg1
338
+ INFO: repacking table "trg1"
339
+ CREATE TABLE trg2 (id integer PRIMARY KEY);
340
+ CREATE TRIGGER z_repack_trigger BEFORE UPDATE ON trg2 FOR EACH ROW EXECUTE PROCEDURE trgtest();
341
+ \! pg_repack --dbname=contrib_regression --table=trg2
342
+ INFO: repacking table "trg2"
343
+ WARNING: the table "trg2" has already a trigger called "z_repack_trigger"
344
+ DETAIL: The trigger was probably installed during a previous attempt to run pg_repack on the table which was interrupted and for some reason failed to clean up the temporary objects. Please drop the trigger or drop and recreate the pg_repack extension altogether to remove all the temporary objects left over.
345
+ CREATE TABLE trg3 (id integer PRIMARY KEY);
346
+ CREATE TRIGGER z_repack_trigges BEFORE UPDATE ON trg3 FOR EACH ROW EXECUTE PROCEDURE trgtest();
347
+ \! pg_repack --dbname=contrib_regression --table=trg3
348
+ INFO: repacking table "trg3"
349
+ WARNING: trigger "z_repack_trigges" conflicting on table "trg3"
350
+ DETAIL: The trigger "z_repack_trigger" must be the last of the BEFORE triggers to fire on the table (triggers fire in alphabetical order). Please rename the trigger so that it sorts before "z_repack_trigger": you can use "ALTER TRIGGER z_repack_trigges ON trg3 RENAME TO newname".
351
+ CREATE TABLE trg4 (id integer PRIMARY KEY);
352
+ CREATE TRIGGER zzzzzz AFTER UPDATE ON trg4 FOR EACH ROW EXECUTE PROCEDURE trgtest();
353
+ \! pg_repack --dbname=contrib_regression --table=trg4
354
+ INFO: repacking table "trg4"
0 commit comments