Hi,

My colleague Per Lejontand brought to my attention that when dumping views with circular dependencies from a postgres version older than 9.4 using a recent pg_dump, the SQL looks something like the following:

  create table qwr();
  create rule "_RETURN" as on select to qwr do instead select;

In this case the relreplident column in pg_class for the view ends up being 'd', instead of the 'n' normally used for views. Patch to update relreplident when turning a table into a view is attached; this makes sure that the identity is NOTHING regardless of how the view was created.

I consider this a bug fix, and suggest back patching to 9.4.


.m
diff --git a/src/backend/rewrite/rewriteDefine.c 
b/src/backend/rewrite/rewriteDefine.c
index f540432..a88d73e 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -597,6 +597,7 @@ DefineQueryRewrite(char *rulename,
                classForm->relhaspkey = false;
                classForm->relfrozenxid = InvalidTransactionId;
                classForm->relminmxid = InvalidMultiXactId;
+               classForm->relreplident = REPLICA_IDENTITY_NOTHING;
 
                simple_heap_update(relationRelation, &classTup->t_self, 
classTup);
                CatalogUpdateIndexes(relationRelation, classTup);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to