@@ -3690,8 +3690,8 @@ get_insert_query_def(Query *query, deparse_context *context)
36903690get_with_clause (query ,context );
36913691
36923692/*
3693- * If it's an INSERT ... SELECT orVALUES (...), (...), ... there will be
3694- *a single 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 */
36963696foreach (l ,query -> rtable )
36973697{
@@ -3725,7 +3725,7 @@ get_insert_query_def(Query *query, deparse_context *context)
37253725context -> indentLevel += PRETTYINDENT_STD ;
37263726appendStringInfoChar (buf ,' ' );
37273727}
3728- appendStringInfo (buf ,"INSERT INTO %s( " ,
3728+ appendStringInfo (buf ,"INSERT INTO %s " ,
37293729generate_relation_name (rte -> relid ,NIL ));
37303730
37313731/*
@@ -3742,6 +3742,8 @@ get_insert_query_def(Query *query, deparse_context *context)
37423742values_cell = NULL ;
37433743strippedexprs = NIL ;
37443744sep = "" ;
3745+ if (query -> targetList )
3746+ appendStringInfoChar (buf ,'(' );
37453747foreach (l ,query -> targetList )
37463748{
37473749TargetEntry * tle = (TargetEntry * )lfirst (l );
@@ -3778,7 +3780,8 @@ get_insert_query_def(Query *query, deparse_context *context)
37783780context , true));
37793781}
37803782}
3781- appendStringInfo (buf ,") " );
3783+ if (query -> targetList )
3784+ appendStringInfo (buf ,") " );
37823785
37833786if (select_rte )
37843787{
@@ -3791,14 +3794,19 @@ get_insert_query_def(Query *query, deparse_context *context)
37913794/* Add the multi-VALUES expression lists */
37923795get_values_def (values_rte -> values_lists ,context );
37933796}
3794- else
3797+ else if ( strippedexprs )
37953798{
37963799/* Add the single-VALUES expression list */
37973800appendContextKeyword (context ,"VALUES (" ,
37983801- PRETTYINDENT_STD ,PRETTYINDENT_STD ,2 );
37993802get_rule_expr ((Node * )strippedexprs ,context , false);
38003803appendStringInfoChar (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 */
38043812if (query -> returningList )