@@ -3390,8 +3390,8 @@ get_insert_query_def(Query *query, deparse_context *context)
33903390get_with_clause (query ,context );
33913391
33923392/*
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 .
33953395 */
33963396foreach (l ,query -> rtable )
33973397{
@@ -3425,7 +3425,7 @@ get_insert_query_def(Query *query, deparse_context *context)
34253425context -> indentLevel += PRETTYINDENT_STD ;
34263426appendStringInfoChar (buf ,' ' );
34273427}
3428- appendStringInfo (buf ,"INSERT INTO %s( " ,
3428+ appendStringInfo (buf ,"INSERT INTO %s " ,
34293429generate_relation_name (rte -> relid ,NIL ));
34303430
34313431/*
@@ -3442,6 +3442,8 @@ get_insert_query_def(Query *query, deparse_context *context)
34423442values_cell = NULL ;
34433443strippedexprs = NIL ;
34443444sep = "" ;
3445+ if (query -> targetList )
3446+ appendStringInfoChar (buf ,'(' );
34453447foreach (l ,query -> targetList )
34463448{
34473449TargetEntry * tle = (TargetEntry * )lfirst (l );
@@ -3478,7 +3480,8 @@ get_insert_query_def(Query *query, deparse_context *context)
34783480context , true));
34793481}
34803482}
3481- appendStringInfo (buf ,") " );
3483+ if (query -> targetList )
3484+ appendStringInfo (buf ,") " );
34823485
34833486if (select_rte )
34843487{
@@ -3491,14 +3494,19 @@ get_insert_query_def(Query *query, deparse_context *context)
34913494/* Add the multi-VALUES expression lists */
34923495get_values_def (values_rte -> values_lists ,context );
34933496}
3494- else
3497+ else if ( strippedexprs )
34953498{
34963499/* Add the single-VALUES expression list */
34973500appendContextKeyword (context ,"VALUES (" ,
34983501- PRETTYINDENT_STD ,PRETTYINDENT_STD ,2 );
34993502get_rule_expr ((Node * )strippedexprs ,context , false);
35003503appendStringInfoChar (buf ,')' );
35013504}
3505+ else
3506+ {
3507+ /* No expressions, so it must be DEFAULT VALUES */
3508+ appendStringInfo (buf ,"DEFAULT VALUES" );
3509+ }
35023510
35033511/* Add RETURNING if present */
35043512if (query -> returningList )