From: | maxzor <maxzor(at)maxzor(dot)eu> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Patch for "CREATE TABLE ... (LIKE ... INCLUDING COMMENTS)" |
Date: | 2018-12-11 11:55:04 |
Message-ID: | 4f4ba3e2-1293-312d-f64f-07251d60a2b2@maxzor.eu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
This candidate patch is kind of a bug-solving patch, it applies to one
unique file : src/backend/parser/parse_utilcmd.c,
on function transformTableLikeClause.
Its aim is to include the "top-level" comment of the object (table,
view, matview...)
that is being copied ; alongside the lower-level comments already in place.
I believe the patch could be ready for application and master branch,
but obviously needs review.
It compiled successfully on master/228b0485f471480cf825b7b30ffa3d66bd692c57,
and "worked".
I did not run any regression test as this seems trivial to me.
I suppose it does not need integration in a commitFest either.
-------------------------------------------------------------------------------------------------------
$ diff -c parse_utilcmd_old.c parse_utilcmd.c
*** parse_utilcmd_old.c 2018-12-11 12:44:52.288309000 +0100
--- parse_utilcmd.c 2018-12-11 12:44:52.208308782 +0100
***************
*** 918,923 ****
--- 918,941 ----
RelationGetRelationName(relation));
}
+ /*
+ * Copy the comment on the object itself, if requested.
+ */
+ if ((table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS) &&
+ (comment = GetComment(relation->rd_id,
+ RelationRelationId,
+ 0)) != NULL)
+ {
+ CommentStmt *stmt = makeNode(CommentStmt);
+
+ stmt->objtype = get_relkind_objtype(relation->rd_rel->relkind);
+ stmt->object = (Node *)
list_make2(makeString(cxt->relation->schemaname),
+
makeString(cxt->relation->relname));
+ stmt->comment = comment;
+
+ cxt->alist = lappend(cxt->alist, stmt);
+ }
+
tupleDesc = RelationGetDescr(relation);
constr = tupleDesc->constr;
-------------------------------------------------------------------------------------------------------
Best regards,
Maxime Chambonnet
From | Date | Subject | |
---|---|---|---|
Next Message | maxzor | 2018-12-11 12:14:19 | Re: Patch for "CREATE TABLE ... (LIKE ... INCLUDING COMMENTS)" |
Previous Message | Adrien NAYRAT | 2018-12-11 11:46:56 | Re: No such file or directory in pg_replslot |