Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebased Unpermitted node type #197

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/postgres_deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ static void deparseRuleActionStmt(StringInfo str, Node *node);
static void deparseExplainableStmt(StringInfo str, Node *node);
static void deparseStmt(StringInfo str, Node *node);
static void deparseValue(StringInfo str, union ValUnion *value, DeparseNodeContext context);
static void deparseTList(StringInfo str, List *tlist);


// "any_name" in gram.y
static void deparseAnyName(StringInfo str, List *parts)
Expand Down Expand Up @@ -785,7 +787,7 @@ static void deparseCreateGenericOptions(StringInfo str, List *options)
if (lnext(options, lc))
appendStringInfoString(str, ", ");
}
appendStringInfoString(str, ") ");
appendStringInfoString(str, ")");
}

// "common_func_opt_item" in gram.y
Expand Down Expand Up @@ -4902,14 +4904,32 @@ static void deparseCreateFunctionStmt(StringInfo str, CreateFunctionStmt *create
else
{
appendStringInfoString(str, "BEGIN ATOMIC ");
deparseExprList(str, castNode(List, create_function_stmt->sql_body));
if IsA(create_function_stmt->sql_body, List) {
foreach(lc, castNode(List, create_function_stmt->sql_body))
{
deparseTList(str, castNode(List, lfirst(lc)));
}
} else {
deparseExprList(str, castNode(List, create_function_stmt->sql_body));
}
emin100 marked this conversation as resolved.
Show resolved Hide resolved

appendStringInfoString(str, "END ");
}
}

removeTrailingSpace(str);
}

static void deparseTList(StringInfo str, List *tlist){

ListCell *lc;
foreach(lc, tlist)
{
deparseStmt(str, lfirst(lc));
appendStringInfoString(str, "; ");
}
}

static void deparseFunctionParameter(StringInfo str, FunctionParameter *function_parameter)
{
switch (function_parameter->mode)
Expand Down
1 change: 1 addition & 0 deletions test/deparse_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ const char* tests[] = {
"CREATE INDEX \"foo.index\" ON foo USING btree (bar)",
"CREATE TABLE distributors (did int, name varchar(40), UNIQUE (name) WITH (fillfactor=70)) WITH (fillfactor=70)",
"SHOW ALL",
"CREATE PROCEDURE insert_data(a int, b int) LANGUAGE sql BEGIN ATOMIC INSERT INTO tbl VALUES (a); INSERT INTO tbl VALUES (b); END",
emin100 marked this conversation as resolved.
Show resolved Hide resolved
};

size_t testsLength = __LINE__ - 4;