66 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77 * Portions Copyright (c) 1994, Regents of the University of California
88 *
9- *$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.331 2006/03/14 22:48:20 tgl Exp $
9+ *$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.332 2006/03/23 00:19:29 tgl Exp $
1010 *
1111 *-------------------------------------------------------------------------
1212 */
@@ -700,7 +700,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
700700
701701Assert (!tle -> resjunk );
702702updateTargetListEntry (pstate ,tle ,col -> name ,lfirst_int (attnos ),
703- col -> indirection );
703+ col -> indirection , col -> location );
704704
705705icols = lnext (icols );
706706attnos = lnext (attnos );
@@ -2360,6 +2360,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
23602360{
23612361TargetEntry * tle = (TargetEntry * )lfirst (tl );
23622362ResTarget * origTarget ;
2363+ int attrno ;
23632364
23642365if (tle -> resjunk )
23652366{
@@ -2378,10 +2379,20 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
23782379origTarget = (ResTarget * )lfirst (origTargetList );
23792380Assert (IsA (origTarget ,ResTarget ));
23802381
2382+ attrno = attnameAttNum (pstate -> p_target_relation ,
2383+ origTarget -> name , true);
2384+ if (attrno == InvalidAttrNumber )
2385+ ereport (ERROR ,
2386+ (errcode (ERRCODE_UNDEFINED_COLUMN ),
2387+ errmsg ("column \"%s\" of relation \"%s\" does not exist" ,
2388+ origTarget -> name ,
2389+ RelationGetRelationName (pstate -> p_target_relation )),
2390+ parser_errposition (pstate ,origTarget -> location )));
2391+
23812392updateTargetListEntry (pstate ,tle ,origTarget -> name ,
2382- attnameAttNum ( pstate -> p_target_relation ,
2383- origTarget -> name , true) ,
2384- origTarget -> indirection );
2393+ attrno ,
2394+ origTarget -> indirection ,
2395+ origTarget -> location );
23852396
23862397origTargetList = lnext (origTargetList );
23872398}