diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-03-03 19:05:47 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-03-03 19:05:47 -0500 |
commit | b15a6da29217b14f02895af1d9271e84415a91ae (patch) | |
tree | b64150f2fc445ff79cb89846b173287d0c550e4b /src/backend/rewrite/rewriteSupport.c | |
parent | 2b78d101d1d6b1d8533a7b7aeff4d82b10a915f8 (diff) |
Get rid of any toast table when converting a table to a view.
Also make sure other fields of the view's pg_class entry are appropriate
for a view; it shouldn't have relfrozenxid set for instance.
This ancient omission isn't believed to have any serious consequences in
versions 8.4-9.2, so no backpatch. But let's fix it before it does bite
us in some serious way. It's just luck that the case doesn't cause
problems for autovacuum. (It did cause problems in 8.3, but that's out
of support.)
Andres Freund
Diffstat (limited to 'src/backend/rewrite/rewriteSupport.c')
-rw-r--r-- | src/backend/rewrite/rewriteSupport.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index 47295600adb..f481c531ac7 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -41,8 +41,7 @@ IsDefinedRewriteRule(Oid owningRel, const char *ruleName) /* * SetRelationRuleStatus - * Set the value of the relation's relhasrules field in pg_class; - * if the relation is becoming a view, also adjust its relkind. + * Set the value of the relation's relhasrules field in pg_class. * * NOTE: caller must be holding an appropriate lock on the relation. * @@ -53,8 +52,7 @@ IsDefinedRewriteRule(Oid owningRel, const char *ruleName) * row. */ void -SetRelationRuleStatus(Oid relationId, bool relHasRules, - bool relIsBecomingView) +SetRelationRuleStatus(Oid relationId, bool relHasRules) { Relation relationRelation; HeapTuple tuple; @@ -69,13 +67,10 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules, elog(ERROR, "cache lookup failed for relation %u", relationId); classForm = (Form_pg_class) GETSTRUCT(tuple); - if (classForm->relhasrules != relHasRules || - (relIsBecomingView && classForm->relkind != RELKIND_VIEW)) + if (classForm->relhasrules != relHasRules) { /* Do the update */ classForm->relhasrules = relHasRules; - if (relIsBecomingView) - classForm->relkind = RELKIND_VIEW; simple_heap_update(relationRelation, &tuple->t_self, tuple); |