From 2646d2d4a9d8b978fda0d0d1affae4788a30f604 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Thu, 11 Dec 2014 22:54:05 +0000 Subject: Further changes to REINDEX SCHEMA Ensure we reindex indexes built on Mat Views. Based on patch from Micheal Paquier Add thorough tests to check that indexes on tables, toast tables and mat views are reindexed. Simon Riggs --- src/backend/commands/indexcmds.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/backend/commands/indexcmds.c') diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index cf4de7281d4..2b45699107c 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1867,16 +1867,16 @@ ReindexObject(const char *objectName, ReindexObjectType objectKind) */ if (objectKind == REINDEX_OBJECT_SCHEMA) { - scan_keys = palloc(sizeof(ScanKeyData) * 2); + /* + * Return all objects in schema. We filter out + * inappropriate objects as we walk through results. + */ + num_keys = 1; + scan_keys = palloc(sizeof(ScanKeyData)); ScanKeyInit(&scan_keys[0], Anum_pg_class_relnamespace, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectOid)); - ScanKeyInit(&scan_keys[1], - Anum_pg_class_relkind, - BTEqualStrategyNumber, F_CHAREQ, - 'r'); - num_keys = 2; } else num_keys = 0; @@ -1894,6 +1894,10 @@ ReindexObject(const char *objectName, ReindexObjectType objectKind) Form_pg_class classtuple = (Form_pg_class) GETSTRUCT(tuple); Oid relid = HeapTupleGetOid(tuple); + /* + * Only regular tables and matviews can have indexes, + * so filter out any other kind of object. + */ if (classtuple->relkind != RELKIND_RELATION && classtuple->relkind != RELKIND_MATVIEW) continue; -- cgit v1.2.3