7
7
* Portions Copyright (c) 1994, Regents of the University of California
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.128 2003/08/08 21:41:56 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.129 2003/08/11 23:04:49 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -48,7 +48,8 @@ static Query *rewriteRuleAction(Query *parsetree,
48
48
static List * adjustJoinTreeList (Query * parsetree , bool removert , int rt_index );
49
49
static void rewriteTargetList (Query * parsetree , Relation target_relation );
50
50
static TargetEntry * process_matched_tle (TargetEntry * src_tle ,
51
- TargetEntry * prior_tle );
51
+ TargetEntry * prior_tle ,
52
+ const char * attrName );
52
53
static void markQueryForUpdate (Query * qry , bool skipOldNew );
53
54
static List * matchLocks (CmdType event , RuleLock * rulelocks ,
54
55
int varno , Query * parsetree );
@@ -312,8 +313,7 @@ rewriteTargetList(Query *parsetree, Relation target_relation)
312
313
continue ;
313
314
314
315
/*
315
- * Look for targetlist entries matching this attr. We match by
316
- * resno, but the resname should match too.
316
+ * Look for targetlist entries matching this attr.
317
317
*
318
318
* Junk attributes are not candidates to be matched.
319
319
*/
@@ -324,9 +324,8 @@ rewriteTargetList(Query *parsetree, Relation target_relation)
324
324
325
325
if (!resdom -> resjunk && resdom -> resno == attrno )
326
326
{
327
- Assert (strcmp (resdom -> resname ,
328
- NameStr (att_tup -> attname )) == 0 );
329
- new_tle = process_matched_tle (old_tle , new_tle );
327
+ new_tle = process_matched_tle (old_tle , new_tle ,
328
+ NameStr (att_tup -> attname ));
330
329
/* keep scanning to detect multiple assignments to attr */
331
330
}
332
331
}
@@ -424,11 +423,12 @@ rewriteTargetList(Query *parsetree, Relation target_relation)
424
423
* Convert a matched TLE from the original tlist into a correct new TLE.
425
424
*
426
425
* This routine detects and handles multiple assignments to the same target
427
- * attribute.
426
+ * attribute. (The attribute name is needed only for error messages.)
428
427
*/
429
428
static TargetEntry *
430
429
process_matched_tle (TargetEntry * src_tle ,
431
- TargetEntry * prior_tle )
430
+ TargetEntry * prior_tle ,
431
+ const char * attrName )
432
432
{
433
433
Resdom * resdom = src_tle -> resdom ;
434
434
Node * priorbottom ;
@@ -456,7 +456,7 @@ process_matched_tle(TargetEntry *src_tle,
456
456
ereport (ERROR ,
457
457
(errcode (ERRCODE_SYNTAX_ERROR ),
458
458
errmsg ("multiple assignments to same attribute \"%s\"" ,
459
- resdom -> resname )));
459
+ attrName )));
460
460
461
461
/*
462
462
* Prior TLE could be a nest of ArrayRefs if we do this more than
@@ -470,7 +470,7 @@ process_matched_tle(TargetEntry *src_tle,
470
470
ereport (ERROR ,
471
471
(errcode (ERRCODE_SYNTAX_ERROR ),
472
472
errmsg ("multiple assignments to same attribute \"%s\"" ,
473
- resdom -> resname )));
473
+ attrName )));
474
474
475
475
/*
476
476
* Looks OK to nest 'em.
0 commit comments