|
|
|
|
@ -3018,8 +3018,8 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
|
List *strippedexprs; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If it's an INSERT ... SELECT or VALUES (...), (...), ... there will be |
|
|
|
|
* a single RTE for the SELECT or VALUES. |
|
|
|
|
* If it's an INSERT ... SELECT or multi-row VALUES, there will be a |
|
|
|
|
* single RTE for the SELECT or VALUES. Plain VALUES has neither. |
|
|
|
|
*/ |
|
|
|
|
foreach(l, query->rtable) |
|
|
|
|
{ |
|
|
|
|
@ -3053,7 +3053,7 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
|
context->indentLevel += PRETTYINDENT_STD; |
|
|
|
|
appendStringInfoChar(buf, ' '); |
|
|
|
|
} |
|
|
|
|
appendStringInfo(buf, "INSERT INTO %s (", |
|
|
|
|
appendStringInfo(buf, "INSERT INTO %s ", |
|
|
|
|
generate_relation_name(rte->relid, NIL)); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@ -3070,6 +3070,8 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
|
values_cell = NULL; |
|
|
|
|
strippedexprs = NIL; |
|
|
|
|
sep = ""; |
|
|
|
|
if (query->targetList) |
|
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
|
foreach(l, query->targetList) |
|
|
|
|
{ |
|
|
|
|
TargetEntry *tle = (TargetEntry *) lfirst(l); |
|
|
|
|
@ -3106,6 +3108,7 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
|
context, true)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (query->targetList) |
|
|
|
|
appendStringInfo(buf, ") "); |
|
|
|
|
|
|
|
|
|
if (select_rte) |
|
|
|
|
@ -3121,7 +3124,7 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
|
/* Add the multi-VALUES expression lists */ |
|
|
|
|
get_values_def(values_rte->values_lists, context); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
else if (strippedexprs) |
|
|
|
|
{ |
|
|
|
|
/* A WITH clause is possible here */ |
|
|
|
|
get_with_clause(query, context); |
|
|
|
|
@ -3131,6 +3134,11 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
|
get_rule_expr((Node *) strippedexprs, context, false); |
|
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
/* No expressions, so it must be DEFAULT VALUES */ |
|
|
|
|
appendStringInfo(buf, "DEFAULT VALUES"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Add RETURNING if present */ |
|
|
|
|
if (query->returningList) |
|
|
|
|
|