From 649e72c0a4787430151b9a8c934ad2f24246aeaa Mon Sep 17 00:00:00 2001 From: Josh Kupershmidt Date: Mon, 26 May 2014 20:57:28 -0400 Subject: [PATCH] Add some ORDER BYs to queries fetching lists of tables/indexes to be repacked, in order to ensure consistent installcheck results. --- bin/pg_repack.c | 10 ++++------ regress/expected/repack.out | 6 +++--- regress/expected/tablespace.out | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index c33c553..af510ca 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -634,6 +634,8 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) { appendStringInfoString(&sql, "pkid IS NOT NULL"); } + /* Ensure the regression tests get a consistent ordering of tables */ + appendStringInfoString(&sql, " ORDER BY t.relname, t.schemaname"); /* double check the parameters array is sane */ if (iparam != num_params) @@ -1865,17 +1867,13 @@ repack_all_indexes(char *errbuf, size_t errsize) if (!preliminary_checks(errbuf, errsize)) goto cleanup; - /* XXX: tighten these ORDER BYs to avoid intermittent installcheck - * failures due to differently-ordered results for some of the - * --only-indexes tests. - */ if (r_index.head) { appendStringInfoString(&sql, "SELECT i.relname, idx.indexrelid, idx.indisvalid, idx.indrelid, idx.indrelid::regclass, n.nspname" " FROM pg_index idx JOIN pg_class i ON i.oid = idx.indexrelid" " JOIN pg_namespace n ON n.oid = i.relnamespace" - " WHERE idx.indexrelid = $1::regclass ORDER BY indisvalid DESC"); + " WHERE idx.indexrelid = $1::regclass ORDER BY indisvalid DESC, i.relname, n.nspname"); cell = r_index.head; } @@ -1885,7 +1883,7 @@ repack_all_indexes(char *errbuf, size_t errsize) "SELECT i.relname, idx.indexrelid, idx.indisvalid, idx.indrelid, $1::text, n.nspname" " FROM pg_index idx JOIN pg_class i ON i.oid = idx.indexrelid" " JOIN pg_namespace n ON n.oid = i.relnamespace" - " WHERE idx.indrelid = $1::regclass ORDER BY indisvalid DESC"); + " WHERE idx.indrelid = $1::regclass ORDER BY indisvalid DESC, i.relname, n.nspname"); cell = table_list.head; } diff --git a/regress/expected/repack.out b/regress/expected/repack.out index e5ab4e0..017d5a4 100644 --- a/regress/expected/repack.out +++ b/regress/expected/repack.out @@ -325,8 +325,8 @@ INFO: repacking table "tbl_pk_uk" -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_pk_uk --only-indexes INFO: repacking indexes of "tbl_pk_uk" -INFO: repacking index "public"."tbl_pk_uk_pkey" INFO: repacking index "public"."tbl_pk_uk_col2_col1_key" +INFO: repacking index "public"."tbl_pk_uk_pkey" -- => OK \! pg_repack --dbname=contrib_regression --table=tbl_nn_puk WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys @@ -377,10 +377,10 @@ INFO: repacking table "test_schema1.tbl1" INFO: repacking table "test_schema1.tbl2" -- => OK \! pg_repack --dbname=contrib_regression --schema=test_schema1 --schema=test_schema2 +INFO: repacking table "test_schema1.tbl1" +INFO: repacking table "test_schema1.tbl2" INFO: repacking table "test_schema2.tbl1" INFO: repacking table "test_schema2.tbl2" -INFO: repacking table "test_schema1.tbl2" -INFO: repacking table "test_schema1.tbl1" -- => ERROR \! pg_repack --dbname=contrib_regression --schema=test_schema1 --table=tbl1 ERROR: cannot repack specific table(s) in schema, use schema.table notation instead diff --git a/regress/expected/tablespace.out b/regress/expected/tablespace.out index 3076a43..ef0424e 100644 --- a/regress/expected/tablespace.out +++ b/regress/expected/tablespace.out @@ -135,8 +135,8 @@ INFO: repacking table "testts1" --move all indexes of the table to a tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_pkey" INFO: repacking index "public"."testts1_partial_idx" +INFO: repacking index "public"."testts1_pkey" INFO: repacking index "public"."testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace @@ -152,8 +152,8 @@ ORDER BY relname; --all indexes of tablespace remain in same tablespace \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_pkey" INFO: repacking index "public"."testts1_partial_idx" +INFO: repacking index "public"."testts1_pkey" INFO: repacking index "public"."testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace @@ -169,8 +169,8 @@ ORDER BY relname; --move all indexes of the table to pg_default \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default INFO: repacking indexes of "testts1" -INFO: repacking index "public"."testts1_pkey" INFO: repacking index "public"."testts1_partial_idx" +INFO: repacking index "public"."testts1_pkey" INFO: repacking index "public"."testts1_with_idx" SELECT relname, spcname FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace