Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit823f83d

Browse files
committed
Fix ruleutils to print "INSERT INTO foo DEFAULT VALUES" correctly.
Per bug #7615 from Marko Tiikkaja. Apparently nobody ever tried thiscase before ...
1 parentd2a5f32 commit823f83d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,8 +3390,8 @@ get_insert_query_def(Query *query, deparse_context *context)
33903390
get_with_clause(query,context);
33913391

33923392
/*
3393-
* If it's an INSERT ... SELECT orVALUES (...), (...), ...there will be
3394-
*asingle RTE for the SELECT or VALUES.
3393+
* If it's an INSERT ... SELECT ormulti-row VALUES,there will be a
3394+
* single RTE for the SELECT or VALUES. Plain VALUES has neither.
33953395
*/
33963396
foreach(l,query->rtable)
33973397
{
@@ -3425,7 +3425,7 @@ get_insert_query_def(Query *query, deparse_context *context)
34253425
context->indentLevel+=PRETTYINDENT_STD;
34263426
appendStringInfoChar(buf,' ');
34273427
}
3428-
appendStringInfo(buf,"INSERT INTO %s(",
3428+
appendStringInfo(buf,"INSERT INTO %s ",
34293429
generate_relation_name(rte->relid,NIL));
34303430

34313431
/*
@@ -3442,6 +3442,8 @@ get_insert_query_def(Query *query, deparse_context *context)
34423442
values_cell=NULL;
34433443
strippedexprs=NIL;
34443444
sep="";
3445+
if (query->targetList)
3446+
appendStringInfoChar(buf,'(');
34453447
foreach(l,query->targetList)
34463448
{
34473449
TargetEntry*tle= (TargetEntry*)lfirst(l);
@@ -3478,7 +3480,8 @@ get_insert_query_def(Query *query, deparse_context *context)
34783480
context, true));
34793481
}
34803482
}
3481-
appendStringInfo(buf,") ");
3483+
if (query->targetList)
3484+
appendStringInfo(buf,") ");
34823485

34833486
if (select_rte)
34843487
{
@@ -3491,14 +3494,19 @@ get_insert_query_def(Query *query, deparse_context *context)
34913494
/* Add the multi-VALUES expression lists */
34923495
get_values_def(values_rte->values_lists,context);
34933496
}
3494-
else
3497+
elseif (strippedexprs)
34953498
{
34963499
/* Add the single-VALUES expression list */
34973500
appendContextKeyword(context,"VALUES (",
34983501
-PRETTYINDENT_STD,PRETTYINDENT_STD,2);
34993502
get_rule_expr((Node*)strippedexprs,context, false);
35003503
appendStringInfoChar(buf,')');
35013504
}
3505+
else
3506+
{
3507+
/* No expressions, so it must be DEFAULT VALUES */
3508+
appendStringInfo(buf,"DEFAULT VALUES");
3509+
}
35023510

35033511
/* Add RETURNING if present */
35043512
if (query->returningList)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp