@@ -2837,9 +2837,53 @@ explain (costs off)
2837
2837
REINDEX SCHEMA schema_to_reindex; -- failure, schema does not exist
2838
2838
ERROR: schema "schema_to_reindex" does not exist
2839
2839
CREATE SCHEMA schema_to_reindex;
2840
- CREATE TABLE schema_to_reindex.table1(col1 SERIAL PRIMARY KEY);
2841
- CREATE TABLE schema_to_reindex.table2(col1 SERIAL PRIMARY KEY, col2 VARCHAR(100) NOT NULL);
2842
- CREATE INDEX ON schema_to_reindex.table2(col2);
2840
+ SET search_path = 'schema_to_reindex';
2841
+ CREATE TABLE table1(col1 SERIAL PRIMARY KEY);
2842
+ INSERT INTO table1 SELECT generate_series(1,400);
2843
+ CREATE TABLE table2(col1 SERIAL PRIMARY KEY, col2 TEXT NOT NULL);
2844
+ INSERT INTO table2 SELECT generate_series(1,400), 'abc';
2845
+ CREATE INDEX ON table2(col2);
2846
+ CREATE MATERIALIZED VIEW matview AS SELECT col1 FROM table2;
2847
+ CREATE INDEX ON matview(col1);
2848
+ CREATE VIEW view AS SELECT col2 FROM table2;
2849
+ CREATE TABLE reindex_before AS
2850
+ SELECT oid, relname, relfilenode, relkind, reltoastrelid
2851
+ FROM pg_class
2852
+ where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex');
2853
+ INSERT INTO reindex_before
2854
+ SELECT oid, 'pg_toast_TABLE', relfilenode, relkind, reltoastrelid
2855
+ FROM pg_class WHERE oid IN
2856
+ (SELECT reltoastrelid FROM reindex_before WHERE reltoastrelid > 0);
2857
+ INSERT INTO reindex_before
2858
+ SELECT oid, 'pg_toast_TABLE_index', relfilenode, relkind, reltoastrelid
2859
+ FROM pg_class where oid in
2860
+ (select indexrelid from pg_index where indrelid in
2861
+ (select reltoastrelid from reindex_before where reltoastrelid > 0));
2862
+ REINDEX SCHEMA schema_to_reindex;
2863
+ CREATE TABLE reindex_after AS SELECT oid, relname, relfilenode, relkind
2864
+ FROM pg_class
2865
+ 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;
2871
+ relname | relkind | case
2872
+ ----------------------+---------+--------------------------
2873
+ table1_col1_seq | S | relfilenode is unchanged
2874
+ table1 | r | relfilenode is unchanged
2875
+ table1_pkey | i | relfilenode has changed
2876
+ table2_col1_seq | S | relfilenode is unchanged
2877
+ table2 | r | relfilenode is unchanged
2878
+ table2_pkey | i | relfilenode has changed
2879
+ table2_col2_idx | i | relfilenode has changed
2880
+ matview | m | relfilenode is unchanged
2881
+ matview_col1_idx | i | relfilenode has changed
2882
+ view | v | relfilenode is unchanged
2883
+ pg_toast_TABLE | t | relfilenode is unchanged
2884
+ pg_toast_TABLE_index | i | relfilenode has changed
2885
+ (12 rows)
2886
+
2843
2887
REINDEX SCHEMA schema_to_reindex;
2844
2888
BEGIN;
2845
2889
REINDEX SCHEMA schema_to_reindex; -- failure, cannot run in a transaction
@@ -2854,6 +2898,10 @@ ERROR: must be owner of schema schema_to_reindex
2854
2898
RESET ROLE;
2855
2899
DROP ROLE regression_reindexuser;
2856
2900
DROP SCHEMA schema_to_reindex CASCADE;
2857
- NOTICE: drop cascades to 2 other objects
2858
- DETAIL: drop cascades to table schema_to_reindex.table1
2859
- drop cascades to table schema_to_reindex.table2
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
0 commit comments