mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user