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

Commit0d68950

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 parentda85727 commit0d68950

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
@@ -3690,8 +3690,8 @@ get_insert_query_def(Query *query, deparse_context *context)
36903690
get_with_clause(query,context);
36913691

36923692
/*
3693-
* If it's an INSERT ... SELECT orVALUES (...), (...), ...there will be
3694-
*asingle RTE for the SELECT or VALUES.
3693+
* If it's an INSERT ... SELECT ormulti-row VALUES,there will be a
3694+
* single RTE for the SELECT or VALUES. Plain VALUES has neither.
36953695
*/
36963696
foreach(l,query->rtable)
36973697
{
@@ -3725,7 +3725,7 @@ get_insert_query_def(Query *query, deparse_context *context)
37253725
context->indentLevel+=PRETTYINDENT_STD;
37263726
appendStringInfoChar(buf,' ');
37273727
}
3728-
appendStringInfo(buf,"INSERT INTO %s(",
3728+
appendStringInfo(buf,"INSERT INTO %s ",
37293729
generate_relation_name(rte->relid,NIL));
37303730

37313731
/*
@@ -3742,6 +3742,8 @@ get_insert_query_def(Query *query, deparse_context *context)
37423742
values_cell=NULL;
37433743
strippedexprs=NIL;
37443744
sep="";
3745+
if (query->targetList)
3746+
appendStringInfoChar(buf,'(');
37453747
foreach(l,query->targetList)
37463748
{
37473749
TargetEntry*tle= (TargetEntry*)lfirst(l);
@@ -3778,7 +3780,8 @@ get_insert_query_def(Query *query, deparse_context *context)
37783780
context, true));
37793781
}
37803782
}
3781-
appendStringInfo(buf,") ");
3783+
if (query->targetList)
3784+
appendStringInfo(buf,") ");
37823785

37833786
if (select_rte)
37843787
{
@@ -3791,14 +3794,19 @@ get_insert_query_def(Query *query, deparse_context *context)
37913794
/* Add the multi-VALUES expression lists */
37923795
get_values_def(values_rte->values_lists,context);
37933796
}
3794-
else
3797+
elseif (strippedexprs)
37953798
{
37963799
/* Add the single-VALUES expression list */
37973800
appendContextKeyword(context,"VALUES (",
37983801
-PRETTYINDENT_STD,PRETTYINDENT_STD,2);
37993802
get_rule_expr((Node*)strippedexprs,context, false);
38003803
appendStringInfoChar(buf,')');
38013804
}
3805+
else
3806+
{
3807+
/* No expressions, so it must be DEFAULT VALUES */
3808+
appendStringInfo(buf,"DEFAULT VALUES");
3809+
}
38023810

38033811
/* Add RETURNING if present */
38043812
if (query->returningList)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp