6
6
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
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 $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -700,7 +700,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
700
700
701
701
Assert (!tle -> resjunk );
702
702
updateTargetListEntry (pstate ,tle ,col -> name ,lfirst_int (attnos ),
703
- col -> indirection );
703
+ col -> indirection , col -> location );
704
704
705
705
icols = lnext (icols );
706
706
attnos = lnext (attnos );
@@ -2360,6 +2360,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
2360
2360
{
2361
2361
TargetEntry * tle = (TargetEntry * )lfirst (tl );
2362
2362
ResTarget * origTarget ;
2363
+ int attrno ;
2363
2364
2364
2365
if (tle -> resjunk )
2365
2366
{
@@ -2378,10 +2379,20 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
2378
2379
origTarget = (ResTarget * )lfirst (origTargetList );
2379
2380
Assert (IsA (origTarget ,ResTarget ));
2380
2381
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
+
2381
2392
updateTargetListEntry (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 );
2385
2396
2386
2397
origTargetList = lnext (origTargetList );
2387
2398
}