Skip to content

Commit f94cec6

Browse files
committed
Include partitioned indexes to system view pg_indexes
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
1 parent 3e514c1 commit f94cec6

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

src/backend/catalog/system_views.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ CREATE VIEW pg_indexes AS
162162
JOIN pg_class I ON (I.oid = X.indexrelid)
163163
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
164164
LEFT JOIN pg_tablespace T ON (T.oid = I.reltablespace)
165-
WHERE C.relkind IN ('r', 'm') AND I.relkind = 'i';
165+
WHERE C.relkind IN ('r', 'm', 'p') AND I.relkind IN ('i', 'I');
166166

167167
CREATE OR REPLACE VIEW pg_sequences AS
168168
SELECT

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201812141
56+
#define CATALOG_VERSION_NO 201812181
5757

5858
#endif

src/test/regress/expected/indexing.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ select relhassubclass from pg_class where relname = 'idxpart_idx';
1010
f
1111
(1 row)
1212

13+
-- Check that partitioned indexes are present in pg_indexes.
14+
select indexdef from pg_indexes where indexname like 'idxpart_idx%';
15+
indexdef
16+
-----------------------------------------------------------------
17+
CREATE INDEX idxpart_idx ON ONLY public.idxpart USING btree (a)
18+
(1 row)
19+
1320
drop index idxpart_idx;
1421
create table idxpart1 partition of idxpart for values from (0) to (10);
1522
create table idxpart2 partition of idxpart for values from (10) to (100)

src/test/regress/expected/rules.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ pg_indexes| SELECT n.nspname AS schemaname,
13581358
JOIN pg_class i ON ((i.oid = x.indexrelid)))
13591359
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
13601360
LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace)))
1361-
WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char"])) AND (i.relkind = 'i'::"char"));
1361+
WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char", 'p'::"char"])) AND (i.relkind = ANY (ARRAY['i'::"char", 'I'::"char"])));
13621362
pg_locks| SELECT l.locktype,
13631363
l.database,
13641364
l.relation,

src/test/regress/sql/indexing.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ create table idxpart (a int, b int, c text) partition by range (a);
66
-- It will be set after the first partition is created.
77
create index idxpart_idx on idxpart (a);
88
select relhassubclass from pg_class where relname = 'idxpart_idx';
9+
10+
-- Check that partitioned indexes are present in pg_indexes.
11+
select indexdef from pg_indexes where indexname like 'idxpart_idx%';
912
drop index idxpart_idx;
1013

1114
create table idxpart1 partition of idxpart for values from (0) to (10);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy