Index: src/backend/parser/analyze.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/analyze.c,v
retrieving revision 1.340
diff -c -r1.340 analyze.c
*** src/backend/parser/analyze.c	14 Jul 2006 14:52:21 -0000	1.340
--- src/backend/parser/analyze.c	19 Jul 2006 03:53:35 -0000
***************
*** 657,667 ****
  	}
  	else
  	{
  		/*
  		 * For INSERT ... VALUES, transform the given list of values to form a
! 		 * targetlist for the INSERT.
  		 */
! 		qry->targetList = transformTargetList(pstate, stmt->targetList);
  	}
  
  	/*
--- 657,699 ----
  	}
  	else
  	{
+ 		ListCell   *tlr;
+ 
  		/*
  		 * For INSERT ... VALUES, transform the given list of values to form a
! 		 * targetlist for the INSERT. In a multi-targetlist INSERT, append all
! 		 * but the first targetlist to extras_after to be processed later by
! 		 * do_parse_analyze
  		 */
! 		qry->targetList = NIL;
! 		foreach(tlr, stmt->targetList)
! 		{
! 			List *tgtlist = (List *) lfirst(tlr);
! 
! 			if (qry->targetList == NIL)
! 			{
! 				/* transform the first targetlist */
! 				qry->targetList = transformTargetList(pstate, tgtlist);
! 			}
! 			else
! 			{
! 				/*
! 				 * Create an InsertStmt node for each additional targetlist
! 				 * and append to extras_after
! 				 */
! 				InsertStmt *insnode = makeNode(InsertStmt);
! 
! 				insnode->cols = NIL;
! 				insnode->targetList = list_make1(tgtlist);
! 				insnode->selectStmt = NULL;
! 				insnode->relation = stmt->relation;
! 
! 				if (*extras_after == NIL)
! 					*extras_after = list_make1(insnode);
! 				else
! 					*extras_after = lappend(*extras_after, insnode);
! 			}
! 		}
  	}
  
  	/*
Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.551
diff -c -r2.551 gram.y
*** src/backend/parser/gram.y	3 Jul 2006 22:45:39 -0000	2.551
--- src/backend/parser/gram.y	19 Jul 2006 03:53:40 -0000
***************
*** 238,247 ****
  				qualified_name_list any_name any_name_list
  				any_operator expr_list attrs
  				target_list update_target_list insert_column_list
! 				insert_target_list def_list indirection opt_indirection
! 				group_clause TriggerFuncArgs select_limit
! 				opt_select_limit opclass_item_list
! 				transaction_mode_list_or_empty
  				TableFuncElementList
  				prep_type_clause prep_type_list
  				execute_param_clause using_clause
--- 238,247 ----
  				qualified_name_list any_name any_name_list
  				any_operator expr_list attrs
  				target_list update_target_list insert_column_list
! 				insert_target_els insert_target_list insert_target_lists
! 				def_list indirection opt_indirection group_clause
! 				TriggerFuncArgs select_limit opt_select_limit
! 				opclass_item_list transaction_mode_list_or_empty
  				TableFuncElementList
  				prep_type_clause prep_type_list
  				execute_param_clause using_clause
***************
*** 5349,5359 ****
  		;
  
  insert_rest:
! 			VALUES '(' insert_target_list ')'
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = NIL;
! 					$$->targetList = $3;
  					$$->selectStmt = NULL;
  				}
  			| DEFAULT VALUES
--- 5349,5359 ----
  		;
  
  insert_rest:
! 			VALUES insert_target_lists
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = NIL;
! 					$$->targetList = $2;
  					$$->selectStmt = NULL;
  				}
  			| DEFAULT VALUES
***************
*** 5370,5380 ****
  					$$->targetList = NIL;
  					$$->selectStmt = $1;
  				}
! 			| '(' insert_column_list ')' VALUES '(' insert_target_list ')'
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = $2;
! 					$$->targetList = $6;
  					$$->selectStmt = NULL;
  				}
  			| '(' insert_column_list ')' SelectStmt
--- 5370,5380 ----
  					$$->targetList = NIL;
  					$$->selectStmt = $1;
  				}
! 			| '(' insert_column_list ')' VALUES insert_target_lists
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = $2;
! 					$$->targetList = $5;
  					$$->selectStmt = NULL;
  				}
  			| '(' insert_column_list ')' SelectStmt
***************
*** 8189,8197 ****
  
  		;
  
  insert_target_list:
! 			insert_target_el						{ $$ = list_make1($1); }
! 			| insert_target_list ',' insert_target_el { $$ = lappend($1, $3); }
  		;
  
  insert_target_el:
--- 8189,8215 ----
  
  		;
  
+ insert_target_lists:
+ 			insert_target_list
+ 				{
+ 					$$ = list_make1($1);
+ 				}
+ 			| insert_target_lists ',' insert_target_list
+ 				{
+ 					$$ = lappend($1, $3);
+ 				}
+ 		;
+ 
  insert_target_list:
! 			'(' insert_target_els ')'
! 				{
! 					$$ = $2;
! 				}
! 		;
! 
! insert_target_els:
! 			insert_target_el						 { $$ = list_make1($1); }
! 			| insert_target_els ',' insert_target_el { $$ = lappend($1, $3); }
  		;
  
  insert_target_el: