@@ -3196,8 +3196,8 @@ get_insert_query_def(Query *query, deparse_context *context)
31963196List * strippedexprs ;
31973197
31983198/*
3199- * If it's an INSERT ... SELECT orVALUES (...), (...), ... there will be
3200- *a single RTE for the SELECT or VALUES.
3199+ * If it's an INSERT ... SELECT ormulti-row VALUES, there will be a
3200+ * single RTE for the SELECT or VALUES. Plain VALUES has neither .
32013201 */
32023202foreach (l ,query -> rtable )
32033203{
@@ -3231,7 +3231,7 @@ get_insert_query_def(Query *query, deparse_context *context)
32313231context -> indentLevel += PRETTYINDENT_STD ;
32323232appendStringInfoChar (buf ,' ' );
32333233}
3234- appendStringInfo (buf ,"INSERT INTO %s( " ,
3234+ appendStringInfo (buf ,"INSERT INTO %s " ,
32353235generate_relation_name (rte -> relid ,NIL ));
32363236
32373237/*
@@ -3248,6 +3248,8 @@ get_insert_query_def(Query *query, deparse_context *context)
32483248values_cell = NULL ;
32493249strippedexprs = NIL ;
32503250sep = "" ;
3251+ if (query -> targetList )
3252+ appendStringInfoChar (buf ,'(' );
32513253foreach (l ,query -> targetList )
32523254{
32533255TargetEntry * tle = (TargetEntry * )lfirst (l );
@@ -3284,7 +3286,8 @@ get_insert_query_def(Query *query, deparse_context *context)
32843286context , true));
32853287}
32863288}
3287- appendStringInfo (buf ,") " );
3289+ if (query -> targetList )
3290+ appendStringInfo (buf ,") " );
32883291
32893292if (select_rte )
32903293{
@@ -3299,7 +3302,7 @@ get_insert_query_def(Query *query, deparse_context *context)
32993302/* Add the multi-VALUES expression lists */
33003303get_values_def (values_rte -> values_lists ,context );
33013304}
3302- else
3305+ else if ( strippedexprs )
33033306{
33043307/* A WITH clause is possible here */
33053308get_with_clause (query ,context );
@@ -3309,6 +3312,11 @@ get_insert_query_def(Query *query, deparse_context *context)
33093312get_rule_expr ((Node * )strippedexprs ,context , false);
33103313appendStringInfoChar (buf ,')' );
33113314}
3315+ else
3316+ {
3317+ /* No expressions, so it must be DEFAULT VALUES */
3318+ appendStringInfo (buf ,"DEFAULT VALUES" );
3319+ }
33123320
33133321/* Add RETURNING if present */
33143322if (query -> returningList )