Skip to content

Commit 1c5c70d

Browse files
committed
Avoid instability in output of new REINDEX SCHEMA test.
The planner seems to like to do this join query as a hash join, making the output ordering machine-dependent; worse, it's a hash on OIDs, so that it's a bit astonishing that the result doesn't change from run to run even on one machine. Add an ORDER BY to get consistent results. Per buildfarm. I also suppressed output from the final DROP SCHEMA CASCADE, to avoid occasional failures similar to those fixed in commit 81d815d. That hasn't been observed in the buildfarm yet, but it seems likely to happen in future if we leave it as-is.
1 parent 7e354ab commit 1c5c70d

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

src/test/regress/expected/create_index.out

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,29 +2859,30 @@ SELECT oid, 'pg_toast_TABLE_index', relfilenode, relkind, reltoastrelid
28592859
FROM pg_class where oid in
28602860
(select indexrelid from pg_index where indrelid in
28612861
(select reltoastrelid from reindex_before where reltoastrelid > 0));
2862-
REINDEX SCHEMA schema_to_reindex;
2862+
REINDEX SCHEMA schema_to_reindex;
28632863
CREATE TABLE reindex_after AS SELECT oid, relname, relfilenode, relkind
28642864
FROM pg_class
28652865
where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex');
2866-
SELECT b.relname,
2867-
b.relkind,
2868-
CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged'
2869-
ELSE 'relfilenode has changed' END
2870-
FROM reindex_before b JOIN pg_class a ON b.oid = a.oid;
2866+
SELECT b.relname,
2867+
b.relkind,
2868+
CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged'
2869+
ELSE 'relfilenode has changed' END
2870+
FROM reindex_before b JOIN pg_class a ON b.oid = a.oid
2871+
ORDER BY 1;
28712872
relname | relkind | case
28722873
----------------------+---------+--------------------------
2873-
table1_col1_seq | S | relfilenode is unchanged
2874+
matview | m | relfilenode is unchanged
2875+
matview_col1_idx | i | relfilenode has changed
2876+
pg_toast_TABLE | t | relfilenode is unchanged
2877+
pg_toast_TABLE_index | i | relfilenode has changed
28742878
table1 | r | relfilenode is unchanged
2879+
table1_col1_seq | S | relfilenode is unchanged
28752880
table1_pkey | i | relfilenode has changed
2876-
table2_col1_seq | S | relfilenode is unchanged
28772881
table2 | r | relfilenode is unchanged
2878-
table2_pkey | i | relfilenode has changed
2882+
table2_col1_seq | S | relfilenode is unchanged
28792883
table2_col2_idx | i | relfilenode has changed
2880-
matview | m | relfilenode is unchanged
2881-
matview_col1_idx | i | relfilenode has changed
2884+
table2_pkey | i | relfilenode has changed
28822885
view | v | relfilenode is unchanged
2883-
pg_toast_TABLE | t | relfilenode is unchanged
2884-
pg_toast_TABLE_index | i | relfilenode has changed
28852886
(12 rows)
28862887

28872888
REINDEX SCHEMA schema_to_reindex;
@@ -2897,11 +2898,6 @@ ERROR: must be owner of schema schema_to_reindex
28972898
-- Clean up
28982899
RESET ROLE;
28992900
DROP ROLE regression_reindexuser;
2901+
SET client_min_messages TO 'warning';
29002902
DROP SCHEMA schema_to_reindex CASCADE;
2901-
NOTICE: drop cascades to 6 other objects
2902-
DETAIL: drop cascades to table table1
2903-
drop cascades to table table2
2904-
drop cascades to materialized view matview
2905-
drop cascades to view view
2906-
drop cascades to table reindex_before
2907-
drop cascades to table reindex_after
2903+
RESET client_min_messages;

src/test/regress/sql/create_index.sql

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -992,15 +992,16 @@ SELECT oid, 'pg_toast_TABLE_index', relfilenode, relkind, reltoastrelid
992992
FROM pg_class where oid in
993993
(select indexrelid from pg_index where indrelid in
994994
(select reltoastrelid from reindex_before where reltoastrelid > 0));
995-
REINDEX SCHEMA schema_to_reindex;
995+
REINDEX SCHEMA schema_to_reindex;
996996
CREATE TABLE reindex_after AS SELECT oid, relname, relfilenode, relkind
997997
FROM pg_class
998998
where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex');
999-
SELECT b.relname,
1000-
b.relkind,
1001-
CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged'
1002-
ELSE 'relfilenode has changed' END
1003-
FROM reindex_before b JOIN pg_class a ON b.oid = a.oid;
999+
SELECT b.relname,
1000+
b.relkind,
1001+
CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged'
1002+
ELSE 'relfilenode has changed' END
1003+
FROM reindex_before b JOIN pg_class a ON b.oid = a.oid
1004+
ORDER BY 1;
10041005
REINDEX SCHEMA schema_to_reindex;
10051006
BEGIN;
10061007
REINDEX SCHEMA schema_to_reindex; -- failure, cannot run in a transaction
@@ -1014,4 +1015,6 @@ REINDEX SCHEMA schema_to_reindex;
10141015
-- Clean up
10151016
RESET ROLE;
10161017
DROP ROLE regression_reindexuser;
1018+
SET client_min_messages TO 'warning';
10171019
DROP SCHEMA schema_to_reindex CASCADE;
1020+
RESET client_min_messages;

0 commit comments

Comments
 (0)