? src/test/regress/expected/insert.out
? src/test/regress/sql/insert.sql
Index: src/backend/nodes/copyfuncs.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v
retrieving revision 1.174
diff -c -r1.174 copyfuncs.c
*** src/backend/nodes/copyfuncs.c	2002/03/29 19:06:08	1.174
--- src/backend/nodes/copyfuncs.c	2002/03/31 03:16:48
***************
*** 1947,1952 ****
--- 1947,1961 ----
  	return newnode;
  }
  
+ static InsertDefault *
+ _copyInsertDefault(InsertDefault *from)
+ {
+ 	InsertDefault *newnode = makeNode(InsertDefault);
+ 
+ 	return newnode;
+ }
+ 
+ 
  static ClosePortalStmt *
  _copyClosePortalStmt(ClosePortalStmt *from)
  {
***************
*** 3054,3059 ****
--- 3063,3071 ----
  			break;
  		case T_FuncWithArgs:
  			retval = _copyFuncWithArgs(from);
+ 			break;
+ 		case T_InsertDefault:
+ 			retval = _copyInsertDefault(from);
  			break;
  
  		default:
Index: src/backend/nodes/equalfuncs.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v
retrieving revision 1.122
diff -c -r1.122 equalfuncs.c
*** src/backend/nodes/equalfuncs.c	2002/03/29 19:06:08	1.122
--- src/backend/nodes/equalfuncs.c	2002/03/31 03:16:50
***************
*** 774,779 ****
--- 774,785 ----
  }
  
  static bool
+ _equalInsertDefault(InsertDefault *a, InsertDefault *b)
+ {
+ 	return true;
+ }
+ 
+ static bool
  _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
  {
  	if (!equalstr(a->portalname, b->portalname))
***************
*** 2214,2219 ****
--- 2220,2228 ----
  			break;
  		case T_FuncWithArgs:
  			retval = _equalFuncWithArgs(a, b);
+ 			break;
+ 		case T_InsertDefault:
+ 			retval = _equalInsertDefault(a, b);
  			break;
  
  		default:
Index: src/backend/parser/analyze.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/analyze.c,v
retrieving revision 1.224
diff -c -r1.224 analyze.c
*** src/backend/parser/analyze.c	2002/03/29 19:06:10	1.224
--- src/backend/parser/analyze.c	2002/03/31 03:16:54
***************
*** 519,531 ****
  		TargetEntry *tle = (TargetEntry *) lfirst(tl);
  		ResTarget   *col;
  
- 		Assert(!tle->resdom->resjunk);
  		if (icolumns == NIL || attnos == NIL)
  			elog(ERROR, "INSERT has more expressions than target columns");
  		col = (ResTarget *) lfirst(icolumns);
! 		Assert(IsA(col, ResTarget));
! 		updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
  							  col->indirection);
  		icolumns = lnext(icolumns);
  		attnos = lnext(attnos);
  	}
--- 519,547 ----
  		TargetEntry *tle = (TargetEntry *) lfirst(tl);
  		ResTarget   *col;
  
  		if (icolumns == NIL || attnos == NIL)
  			elog(ERROR, "INSERT has more expressions than target columns");
  		col = (ResTarget *) lfirst(icolumns);
! 
! 		/*
! 		 * When the value is to be set to the column default we can simply
! 		 * drop it now and handle it later on using methods for missing
! 		 * columns.
! 		 */
! 		if (!IsA(tle, InsertDefault))
! 		{
! 			Assert(IsA(col, ResTarget));
! 			Assert(!tle->resdom->resjunk);
! 			updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
  							  col->indirection);
+ 		}
+ 		else
+ 		{
+ 			icolumns = lremove(icolumns, icolumns);
+ 			attnos = lremove(attnos, attnos);
+ 			qry->targetList = lremove(tle, qry->targetList);
+ 		}
+ 
  		icolumns = lnext(icolumns);
  		attnos = lnext(attnos);
  	}
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.297
diff -c -r2.297 gram.y
*** src/backend/parser/gram.y	2002/03/29 19:06:10	2.297
--- src/backend/parser/gram.y	2002/03/31 03:17:06
***************
*** 202,207 ****
--- 202,208 ----
  		from_clause, from_list, opt_array_bounds, qualified_name_list,
  		any_name, any_name_list, expr_list, dotted_name, attrs,
  		target_list, update_target_list, insert_column_list,
+ 		insert_target_list,
  		def_list, opt_indirection, group_clause, TriggerFuncArgs,
  		select_limit, opt_select_limit
  
***************
*** 262,268 ****
  %type <node>	table_ref
  %type <jexpr>	joined_table
  %type <range>	relation_expr
! %type <target>	target_el, update_target_el
  
  %type <typnam>	Typename, SimpleTypename, ConstTypename
  				GenericType, Numeric, Character, ConstDatetime, ConstInterval, Bit
--- 263,269 ----
  %type <node>	table_ref
  %type <jexpr>	joined_table
  %type <range>	relation_expr
! %type <target>	target_el, insert_target_el, update_target_el
  
  %type <typnam>	Typename, SimpleTypename, ConstTypename
  				GenericType, Numeric, Character, ConstDatetime, ConstInterval, Bit
***************
*** 3478,3484 ****
  				}
  		;
  
! insert_rest:  VALUES '(' target_list ')'
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = NIL;
--- 3479,3485 ----
  				}
  		;
  
! insert_rest:  VALUES '(' insert_target_list ')'
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = NIL;
***************
*** 3499,3505 ****
  					$$->targetList = NIL;
  					$$->selectStmt = $1;
  				}
! 		| '(' insert_column_list ')' VALUES '(' target_list ')'
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = $2;
--- 3500,3506 ----
  					$$->targetList = NIL;
  					$$->selectStmt = $1;
  				}
! 		| '(' insert_column_list ')' VALUES '(' insert_target_list ')'
  				{
  					$$ = makeNode(InsertStmt);
  					$$->cols = $2;
***************
*** 5218,5224 ****
  					s->val.type = T_String;
  					s->val.val.str = "now";
  					s->typename = makeTypeName(xlateSqlType("text"));
- 
  					d = makeTypeName(xlateSqlType("timetz"));
  					if (($3 < 0) || ($3 > 13))
  						elog(ERROR,"CURRENT_TIME(%d) precision must be between %d and %d",
--- 5219,5224 ----
***************
*** 5694,5699 ****
--- 5694,5716 ----
  					$$->val = (Node *)$4;
  				}
  		;
+ 
+ insert_target_list:  insert_target_list ',' insert_target_el
+ 				{	$$ = lappend($1, $3);  }
+ 		| insert_target_el
+ 				{	$$ = makeList1($1);  }
+ 		;
+ 
+ insert_target_el:  target_el	{	$$ = $1;  }
+ 				| DEFAULT		{	
+ 									InsertDefault *def = makeNode(InsertDefault);
+ 									$$ = makeNode(ResTarget);
+ 									$$->name = NULL;
+ 									$$->indirection = NULL;
+ 									$$->val = (Node *)def;
+ 								}
+ 				;
+ 
  
  /*****************************************************************************
   *
Index: src/backend/parser/parse_target.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/parse_target.c,v
retrieving revision 1.80
diff -c -r1.80 parse_target.c
*** src/backend/parser/parse_target.c	2002/03/29 19:06:12	1.80
--- src/backend/parser/parse_target.c	2002/03/31 03:17:09
***************
*** 175,183 ****
  														false));
  			}
  		}
  		else
  		{
! 			/* Everything else but ColumnRef */
  			p_target = lappend(p_target,
  							   transformTargetEntry(pstate,
  													res->val,
--- 175,193 ----
  														false));
  			}
  		}
+ 		else if (IsA(res->val, InsertDefault))
+ 		{
+ 			InsertDefault *newnode = makeNode(InsertDefault);
+ 
+ 			/*
+ 			 * If this is a DEFAULT element, we make a junk entry
+ 			 * which will get dropped on return to transformInsertStmt().
+ 			 */
+ 			p_target = lappend(p_target, newnode);
+ 		}
  		else
  		{
! 			/* Everything else but ColumnRef and InsertDefault */
  			p_target = lappend(p_target,
  							   transformTargetEntry(pstate,
  													res->val,
Index: src/include/nodes/nodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/nodes/nodes.h,v
retrieving revision 1.103
diff -c -r1.103 nodes.h
*** src/include/nodes/nodes.h	2002/03/22 02:56:36	1.103
--- src/include/nodes/nodes.h	2002/03/31 03:17:10
***************
*** 229,234 ****
--- 229,235 ----
  	T_PrivGrantee,
  	T_FuncWithArgs,
  	T_PrivTarget,
+ 	T_InsertDefault,
  
  	/*
  	 * TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h)
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.166
diff -c -r1.166 parsenodes.h
*** src/include/nodes/parsenodes.h	2002/03/29 19:06:23	1.166
--- src/include/nodes/parsenodes.h	2002/03/31 03:17:12
***************
*** 360,365 ****
--- 360,373 ----
  } ResTarget;
  
  /*
+  * Empty node used as a marker for Default Columns
+  */
+ typedef struct InsertDefault
+ {
+ 	NodeTag		type;
+ } InsertDefault;
+ 
+ /*
   * SortGroupBy - for ORDER BY clause
   */
  typedef struct SortGroupBy
Index: src/test/regress/parallel_schedule
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/parallel_schedule,v
retrieving revision 1.8
diff -c -r1.8 parallel_schedule
*** src/test/regress/parallel_schedule	2002/03/19 02:18:24	1.8
--- src/test/regress/parallel_schedule	2002/03/31 03:17:13
***************
*** 21,26 ****
--- 21,27 ----
  # ----------
  # These four each depend on the previous one
  # ----------
+ test: insert
  test: create_function_1
  test: create_type
  test: create_table
Index: src/test/regress/serial_schedule
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/serial_schedule,v
retrieving revision 1.8
diff -c -r1.8 serial_schedule
*** src/test/regress/serial_schedule	2002/03/19 02:18:24	1.8
--- src/test/regress/serial_schedule	2002/03/31 03:17:13
***************
*** 37,42 ****
--- 37,43 ----
  test: opr_sanity
  test: geometry
  test: horology
+ test: insert
  test: create_function_1
  test: create_type
  test: create_table
