v42-0005-Skip-ALTER-TABLE-subcommands-generated-for-TableLike.patch
application/octet-stream
Filename: v42-0005-Skip-ALTER-TABLE-subcommands-generated-for-TableLike.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v42-0005
Subject: Skip ALTER TABLE subcommands generated for TableLikeClause in the DDL deparser
| File | + | − |
|---|---|---|
| src/backend/commands/ddl_deparse.c | 10 | 0 |
| src/backend/parser/parse_utilcmd.c | 1 | 0 |
| src/include/nodes/parsenodes.h | 1 | 0 |
From df9bad8c89b268015e655a16eed106febcfdb666 Mon Sep 17 00:00:00 2001 From: "Zheng (Zane) Li" <zhelli@amazon.com> Date: Fri, 2 Dec 2022 02:15:08 +0000 Subject: [PATCH 7/7] Skip ALTER TABLE subcommands generated for TableLikeClause in the DDL deparser --- src/backend/commands/ddl_deparse.c | 10 ++++++++++ src/backend/parser/parse_utilcmd.c | 1 + src/include/nodes/parsenodes.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/backend/commands/ddl_deparse.c b/src/backend/commands/ddl_deparse.c index d69d5566c0..789e7cff2b 100755 --- a/src/backend/commands/ddl_deparse.c +++ b/src/backend/commands/ddl_deparse.c @@ -3364,8 +3364,18 @@ deparse_AlterRelation(CollectedCommand *cmd) const char *reltype; bool istype = false; List *exprs = NIL; + AlterTableStmt *stmt = NULL; Assert(cmd->type == SCT_AlterTable); + stmt = (AlterTableStmt *) cmd->parsetree; + Assert(IsA(stmt, AlterTableStmt)); + + /* + * ALTER TABLE subcommands generated for TableLikeClause is processed in + * the top level CREATE TABLE command; return empty here. + */ + if (stmt->table_like) + return NULL; rel = relation_open(cmd->d.alterTable.objectId, AccessShareLock); dpcontext = deparse_context_for(RelationGetRelationName(rel), diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 36791d8817..cf93a6fae0 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1397,6 +1397,7 @@ expandTableLikeClause(RangeVar *heapRel, TableLikeClause *table_like_clause) atcmd->cmds = atsubcmds; atcmd->objtype = OBJECT_TABLE; atcmd->missing_ok = false; + atcmd->table_like = true; result = lcons(atcmd, result); } diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 6112cd85c8..90d508d504 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1948,6 +1948,7 @@ typedef struct AlterTableStmt List *cmds; /* list of subcommands */ ObjectType objtype; /* type of object */ bool missing_ok; /* skip error if table missing */ + bool table_like; /* internally generated for TableLikeClause */ } AlterTableStmt; typedef enum AlterTableType -- 2.37.1