aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2014-12-11 22:54:05 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2014-12-11 22:54:05 +0000
commit2646d2d4a9d8b978fda0d0d1affae4788a30f604 (patch)
treeae2a71fe653d1a2f4cb9799e5bac2ed082156411 /src/backend/commands
parent0845264642d855d92c63c5d05a4ef83245ca16c5 (diff)
downloadpostgresql-2646d2d4a9d8b978fda0d0d1affae4788a30f604.tar.gz
postgresql-2646d2d4a9d8b978fda0d0d1affae4788a30f604.zip
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
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/indexcmds.c16
1 files changed, 10 insertions, 6 deletions
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;