Include partitioned indexes to system view pg_indexes
authorMichael Paquier <[email protected]>
Tue, 18 Dec 2018 07:37:51 +0000 (16:37 +0900)
committerMichael Paquier <[email protected]>
Tue, 18 Dec 2018 07:37:51 +0000 (16:37 +0900)
pg_tables already includes partitioned tables, so for consistency
pg_indexes should show partitioned indexes.

Author: Suraj Kharage
Reviewed-by: Amit Langote, Michael Paquier
Discussion: https://postgr.es/m/CAF1DzPVrYo4XNTEnc=PqVp6aLJc7LFYpYR4rX=_5pV=wJ2KdZg@mail.gmail.com

src/backend/catalog/system_views.sql
src/include/catalog/catversion.h
src/test/regress/expected/indexing.out
src/test/regress/expected/rules.out
src/test/regress/sql/indexing.sql

index 8630542bb34091a57d2f8122d818d2d435945104..5253837b5441dc50c3d9d306ceb29c708d17e85f 100644 (file)
@@ -162,7 +162,7 @@ CREATE VIEW pg_indexes AS
          JOIN pg_class I ON (I.oid = X.indexrelid)
          LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
          LEFT JOIN pg_tablespace T ON (T.oid = I.reltablespace)
-    WHERE C.relkind IN ('r', 'm') AND I.relkind = 'i';
+    WHERE C.relkind IN ('r', 'm', 'p') AND I.relkind IN ('i', 'I');
 
 CREATE OR REPLACE VIEW pg_sequences AS
     SELECT
index 838e927547f3929af17e0d1c1f67992a55c91fe3..3e38f2d9113b0017194f74e3917a53cfa6741dff 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     201812141
+#define CATALOG_VERSION_NO     201812181
 
 #endif
index 3e61f50e7ce3ec4582c405ba447521302649ba0d..caacf3f7991748df283765c4f782920dae984864 100644 (file)
@@ -10,6 +10,13 @@ select relhassubclass from pg_class where relname = 'idxpart_idx';
  f
 (1 row)
 
+-- Check that partitioned indexes are present in pg_indexes.
+select indexdef from pg_indexes where indexname like 'idxpart_idx%';
+                            indexdef                             
+-----------------------------------------------------------------
+ CREATE INDEX idxpart_idx ON ONLY public.idxpart USING btree (a)
+(1 row)
+
 drop index idxpart_idx;
 create table idxpart1 partition of idxpart for values from (0) to (10);
 create table idxpart2 partition of idxpart for values from (10) to (100)
index b68b8d273f32105e179dbe839dda99039e329de7..e384cd22798cd839612977a520b7d84a34b3774a 100644 (file)
@@ -1358,7 +1358,7 @@ pg_indexes| SELECT n.nspname AS schemaname,
      JOIN pg_class i ON ((i.oid = x.indexrelid)))
      LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
      LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace)))
-  WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char"])) AND (i.relkind = 'i'::"char"));
+  WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char", 'p'::"char"])) AND (i.relkind = ANY (ARRAY['i'::"char", 'I'::"char"])));
 pg_locks| SELECT l.locktype,
     l.database,
     l.relation,
index 400b7eb7ba39c42cf00bcf5fa86f5158c6bfb247..6878cde50986f38736dcaa9b8286360ee0349563 100644 (file)
@@ -6,6 +6,9 @@ create table idxpart (a int, b int, c text) partition by range (a);
 -- It will be set after the first partition is created.
 create index idxpart_idx on idxpart (a);
 select relhassubclass from pg_class where relname = 'idxpart_idx';
+
+-- Check that partitioned indexes are present in pg_indexes.
+select indexdef from pg_indexes where indexname like 'idxpart_idx%';
 drop index idxpart_idx;
 
 create table idxpart1 partition of idxpart for values from (0) to (10);