|
40 | 40 | # REINDEX operations. A set of relfilenodes is saved from the catalogs
|
41 | 41 | # and then compared with pg_class.
|
42 | 42 | $node->safe_psql('postgres',
|
43 |
| - 'CREATE TABLE toast_relfilenodes (parent regclass, indname regclass, relfilenode oid);' |
| 43 | + 'CREATE TABLE index_relfilenodes (parent regclass, indname regclass, relfilenode oid);' |
44 | 44 | );
|
45 | 45 | # Save the relfilenode of a set of toast indexes, one from the catalog
|
46 | 46 | # pg_constraint and one from the test table.
|
|
58 | 58 | JOIN pg_index i ON (i.indexrelid = a.oid)
|
59 | 59 | WHERE a.relname IN ('pg_constraint_oid_index', 'test1x')};
|
60 | 60 | my $save_relfilenodes =
|
61 |
| - "INSERT INTO toast_relfilenodes $fetch_toast_relfilenodes;" |
62 |
| - . "INSERT INTO toast_relfilenodes $fetch_index_relfilenodes;"; |
| 61 | + "INSERT INTO index_relfilenodes $fetch_toast_relfilenodes;" |
| 62 | + . "INSERT INTO index_relfilenodes $fetch_index_relfilenodes;"; |
63 | 63 |
|
64 | 64 | # Query to compare a set of relfilenodes saved with the contents of pg_class.
|
65 | 65 | # Note that this does not join using OIDs, as CONCURRENTLY would change them
|
|
68 | 68 | # based on the name is enough to ensure a fixed output, where the name of the
|
69 | 69 | # parent table is included to provide more context.
|
70 | 70 | my $compare_relfilenodes = qq(SELECT b.parent::regclass,
|
71 |
| - regexp_replace(b.indname::text, '(pg_toast.pg_toast_)\\d{4,5}(_index)', '\\1<oid>\\2'), |
| 71 | + regexp_replace(b.indname::text, '(pg_toast.pg_toast_)\\d+(_index)', '\\1<oid>\\2'), |
72 | 72 | CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged'
|
73 | 73 | ELSE 'relfilenode has changed' END
|
74 |
| - FROM toast_relfilenodes b |
| 74 | + FROM index_relfilenodes b |
75 | 75 | JOIN pg_class a ON b.indname::text = a.oid::regclass::text
|
76 | 76 | ORDER BY b.parent::text, b.indname::text);
|
77 | 77 |
|
|
91 | 91 |
|
92 | 92 | # Re-save and run the second one.
|
93 | 93 | $node->safe_psql('postgres',
|
94 |
| - "TRUNCATE toast_relfilenodes; $save_relfilenodes"); |
| 94 | + "TRUNCATE index_relfilenodes; $save_relfilenodes"); |
95 | 95 | $node->issues_sql_like(
|
96 | 96 | [ 'reindexdb', '-s', 'postgres' ],
|
97 | 97 | qr/statement: REINDEX SYSTEM postgres;/,
|
|
0 commit comments