@@ -505,38 +505,44 @@ deparseInsertSql(StringInfo buf, PlannerInfo *root, Index rtindex,
505505
506506 appendStringInfoString (buf , "INSERT INTO " );
507507 deparseRelation (buf , rte -> relid );
508- appendStringInfoString (buf , "(" );
509508
510- first = true;
511- foreach (lc , targetAttrs )
509+ if (targetAttrs )
512510 {
513- int attnum = lfirst_int (lc );
514- Form_pg_attribute attr = tupdesc -> attrs [attnum - 1 ];
511+ appendStringInfoString (buf , "(" );
515512
516- Assert (!attr -> attisdropped );
513+ first = true;
514+ foreach (lc , targetAttrs )
515+ {
516+ int attnum = lfirst_int (lc );
517+ Form_pg_attribute attr = tupdesc -> attrs [attnum - 1 ];
517518
518- if (!first )
519- appendStringInfoString (buf , ", " );
520- first = false;
519+ Assert (!attr -> attisdropped );
521520
522- deparseColumnRef (buf , rtindex , attnum , root );
523- }
521+ if (!first )
522+ appendStringInfoString (buf , ", " );
523+ first = false;
524524
525- appendStringInfoString (buf , ") VALUES (" );
525+ deparseColumnRef (buf , rtindex , attnum , root );
526+ }
526527
527- pindex = 1 ;
528- first = true;
529- foreach (lc , targetAttrs )
530- {
531- if (!first )
532- appendStringInfoString (buf , ", " );
533- first = false;
528+ appendStringInfoString (buf , ") VALUES (" );
534529
535- appendStringInfo (buf , "$%d" , pindex );
536- pindex ++ ;
537- }
530+ pindex = 1 ;
531+ first = true;
532+ foreach (lc , targetAttrs )
533+ {
534+ if (!first )
535+ appendStringInfoString (buf , ", " );
536+ first = false;
537+
538+ appendStringInfo (buf , "$%d" , pindex );
539+ pindex ++ ;
540+ }
538541
539- appendStringInfoString (buf , ")" );
542+ appendStringInfoString (buf , ")" );
543+ }
544+ else
545+ appendStringInfoString (buf , " DEFAULT VALUES" );
540546
541547 if (returningList )
542548 deparseReturningList (buf , root , rtindex , rel , returningList );
0 commit comments