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

Commit645984e

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 parentc567535 commit645984e

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
@@ -3506,8 +3506,8 @@ get_insert_query_def(Query *query, deparse_context *context)
35063506
get_with_clause(query,context);
35073507

35083508
/*
3509-
* If it's an INSERT ... SELECT orVALUES (...), (...), ...there will be
3510-
*asingle RTE for the SELECT or VALUES.
3509+
* If it's an INSERT ... SELECT ormulti-row VALUES,there will be a
3510+
* single RTE for the SELECT or VALUES. Plain VALUES has neither.
35113511
*/
35123512
foreach(l,query->rtable)
35133513
{
@@ -3541,7 +3541,7 @@ get_insert_query_def(Query *query, deparse_context *context)
35413541
context->indentLevel+=PRETTYINDENT_STD;
35423542
appendStringInfoChar(buf,' ');
35433543
}
3544-
appendStringInfo(buf,"INSERT INTO %s(",
3544+
appendStringInfo(buf,"INSERT INTO %s ",
35453545
generate_relation_name(rte->relid,NIL));
35463546

35473547
/*
@@ -3558,6 +3558,8 @@ get_insert_query_def(Query *query, deparse_context *context)
35583558
values_cell=NULL;
35593559
strippedexprs=NIL;
35603560
sep="";
3561+
if (query->targetList)
3562+
appendStringInfoChar(buf,'(');
35613563
foreach(l,query->targetList)
35623564
{
35633565
TargetEntry*tle= (TargetEntry*)lfirst(l);
@@ -3594,7 +3596,8 @@ get_insert_query_def(Query *query, deparse_context *context)
35943596
context, true));
35953597
}
35963598
}
3597-
appendStringInfo(buf,") ");
3599+
if (query->targetList)
3600+
appendStringInfo(buf,") ");
35983601

35993602
if (select_rte)
36003603
{
@@ -3607,14 +3610,19 @@ get_insert_query_def(Query *query, deparse_context *context)
36073610
/* Add the multi-VALUES expression lists */
36083611
get_values_def(values_rte->values_lists,context);
36093612
}
3610-
else
3613+
elseif (strippedexprs)
36113614
{
36123615
/* Add the single-VALUES expression list */
36133616
appendContextKeyword(context,"VALUES (",
36143617
-PRETTYINDENT_STD,PRETTYINDENT_STD,2);
36153618
get_rule_expr((Node*)strippedexprs,context, false);
36163619
appendStringInfoChar(buf,')');
36173620
}
3621+
else
3622+
{
3623+
/* No expressions, so it must be DEFAULT VALUES */
3624+
appendStringInfo(buf,"DEFAULT VALUES");
3625+
}
36183626

36193627
/* Add RETURNING if present */
36203628
if (query->returningList)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp