Add some ORDER BYs to queries fetching lists of tables/indexes

to be repacked, in order to ensure consistent installcheck results.
This commit is contained in:
Josh Kupershmidt 2014-05-26 20:57:28 -04:00
parent e2c720b89c
commit 649e72c0a4
3 changed files with 10 additions and 12 deletions

View File

@ -634,6 +634,8 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
{ {
appendStringInfoString(&sql, "pkid IS NOT NULL"); 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 */ /* double check the parameters array is sane */
if (iparam != num_params) if (iparam != num_params)
@ -1865,17 +1867,13 @@ repack_all_indexes(char *errbuf, size_t errsize)
if (!preliminary_checks(errbuf, errsize)) if (!preliminary_checks(errbuf, errsize))
goto cleanup; 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) if (r_index.head)
{ {
appendStringInfoString(&sql, appendStringInfoString(&sql,
"SELECT i.relname, idx.indexrelid, idx.indisvalid, idx.indrelid, idx.indrelid::regclass, n.nspname" "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" " FROM pg_index idx JOIN pg_class i ON i.oid = idx.indexrelid"
" JOIN pg_namespace n ON n.oid = i.relnamespace" " 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; 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" "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" " FROM pg_index idx JOIN pg_class i ON i.oid = idx.indexrelid"
" JOIN pg_namespace n ON n.oid = i.relnamespace" " 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; cell = table_list.head;
} }

View File

@ -325,8 +325,8 @@ INFO: repacking table "tbl_pk_uk"
-- => OK -- => OK
\! pg_repack --dbname=contrib_regression --table=tbl_pk_uk --only-indexes \! pg_repack --dbname=contrib_regression --table=tbl_pk_uk --only-indexes
INFO: repacking indexes of "tbl_pk_uk" 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_col2_col1_key"
INFO: repacking index "public"."tbl_pk_uk_pkey"
-- => OK -- => OK
\! pg_repack --dbname=contrib_regression --table=tbl_nn_puk \! pg_repack --dbname=contrib_regression --table=tbl_nn_puk
WARNING: relation "tbl_nn_puk" must have a primary key or not-null unique keys 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" INFO: repacking table "test_schema1.tbl2"
-- => OK -- => OK
\! pg_repack --dbname=contrib_regression --schema=test_schema1 --schema=test_schema2 \! 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.tbl1"
INFO: repacking table "test_schema2.tbl2" INFO: repacking table "test_schema2.tbl2"
INFO: repacking table "test_schema1.tbl2"
INFO: repacking table "test_schema1.tbl1"
-- => ERROR -- => ERROR
\! pg_repack --dbname=contrib_regression --schema=test_schema1 --table=tbl1 \! pg_repack --dbname=contrib_regression --schema=test_schema1 --table=tbl1
ERROR: cannot repack specific table(s) in schema, use schema.table notation instead ERROR: cannot repack specific table(s) in schema, use schema.table notation instead

View File

@ -135,8 +135,8 @@ INFO: repacking table "testts1"
--move all indexes of the table to a tablespace --move all indexes of the table to a tablespace
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=testts
INFO: repacking indexes of "testts1" INFO: repacking indexes of "testts1"
INFO: repacking index "public"."testts1_pkey"
INFO: repacking index "public"."testts1_partial_idx" INFO: repacking index "public"."testts1_partial_idx"
INFO: repacking index "public"."testts1_pkey"
INFO: repacking index "public"."testts1_with_idx" INFO: repacking index "public"."testts1_with_idx"
SELECT relname, spcname SELECT relname, spcname
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace 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 --all indexes of tablespace remain in same tablespace
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes
INFO: repacking indexes of "testts1" INFO: repacking indexes of "testts1"
INFO: repacking index "public"."testts1_pkey"
INFO: repacking index "public"."testts1_partial_idx" INFO: repacking index "public"."testts1_partial_idx"
INFO: repacking index "public"."testts1_pkey"
INFO: repacking index "public"."testts1_with_idx" INFO: repacking index "public"."testts1_with_idx"
SELECT relname, spcname SELECT relname, spcname
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace 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 --move all indexes of the table to pg_default
\! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default \! pg_repack --dbname=contrib_regression --table=testts1 --only-indexes --tablespace=pg_default
INFO: repacking indexes of "testts1" INFO: repacking indexes of "testts1"
INFO: repacking index "public"."testts1_pkey"
INFO: repacking index "public"."testts1_partial_idx" INFO: repacking index "public"."testts1_partial_idx"
INFO: repacking index "public"."testts1_pkey"
INFO: repacking index "public"."testts1_with_idx" INFO: repacking index "public"."testts1_with_idx"
SELECT relname, spcname SELECT relname, spcname
FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace FROM pg_class JOIN pg_tablespace ts ON ts.oid = reltablespace