@@ -3390,8 +3390,8 @@ get_insert_query_def(Query *query, deparse_context *context)
3390
3390
get_with_clause (query ,context );
3391
3391
3392
3392
/*
3393
- * If it's an INSERT ... SELECT orVALUES (...), (...), ... there will be
3394
- *a single 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 .
3395
3395
*/
3396
3396
foreach (l ,query -> rtable )
3397
3397
{
@@ -3425,7 +3425,7 @@ get_insert_query_def(Query *query, deparse_context *context)
3425
3425
context -> indentLevel += PRETTYINDENT_STD ;
3426
3426
appendStringInfoChar (buf ,' ' );
3427
3427
}
3428
- appendStringInfo (buf ,"INSERT INTO %s( " ,
3428
+ appendStringInfo (buf ,"INSERT INTO %s " ,
3429
3429
generate_relation_name (rte -> relid ,NIL ));
3430
3430
3431
3431
/*
@@ -3442,6 +3442,8 @@ get_insert_query_def(Query *query, deparse_context *context)
3442
3442
values_cell = NULL ;
3443
3443
strippedexprs = NIL ;
3444
3444
sep = "" ;
3445
+ if (query -> targetList )
3446
+ appendStringInfoChar (buf ,'(' );
3445
3447
foreach (l ,query -> targetList )
3446
3448
{
3447
3449
TargetEntry * tle = (TargetEntry * )lfirst (l );
@@ -3478,7 +3480,8 @@ get_insert_query_def(Query *query, deparse_context *context)
3478
3480
context , true));
3479
3481
}
3480
3482
}
3481
- appendStringInfo (buf ,") " );
3483
+ if (query -> targetList )
3484
+ appendStringInfo (buf ,") " );
3482
3485
3483
3486
if (select_rte )
3484
3487
{
@@ -3491,14 +3494,19 @@ get_insert_query_def(Query *query, deparse_context *context)
3491
3494
/* Add the multi-VALUES expression lists */
3492
3495
get_values_def (values_rte -> values_lists ,context );
3493
3496
}
3494
- else
3497
+ else if ( strippedexprs )
3495
3498
{
3496
3499
/* Add the single-VALUES expression list */
3497
3500
appendContextKeyword (context ,"VALUES (" ,
3498
3501
- PRETTYINDENT_STD ,PRETTYINDENT_STD ,2 );
3499
3502
get_rule_expr ((Node * )strippedexprs ,context , false);
3500
3503
appendStringInfoChar (buf ,')' );
3501
3504
}
3505
+ else
3506
+ {
3507
+ /* No expressions, so it must be DEFAULT VALUES */
3508
+ appendStringInfo (buf ,"DEFAULT VALUES" );
3509
+ }
3502
3510
3503
3511
/* Add RETURNING if present */
3504
3512
if (query -> returningList )