7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.85 1998/09/01 04:30:15 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.86 1998/09/03 14:21:06 thomas Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -269,8 +269,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
269
269
int ndef = pstate -> p_target_relation -> rd_att -> constr -> num_defval ;
270
270
271
271
/*
272
- * if stmt->cols == NIL then makeTargetNames returns list of all
273
- * attrs: have to shorter icolumns list...
272
+ * if stmt->cols == NIL then makeTargetNames returns list of all attrs.
273
+ * May have to shorten icolumns list...
274
274
*/
275
275
if (stmt -> cols == NIL )
276
276
{
@@ -279,11 +279,26 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
279
279
280
280
foreach (extrl , icolumns )
281
281
{
282
+ /*
283
+ * decrements first, so if we started with zero items
284
+ * it will now be negative
285
+ */
282
286
if (-- i <= 0 )
283
287
break ;
284
288
}
285
- freeList (lnext (extrl ));
286
- lnext (extrl ) = NIL ;
289
+ /*
290
+ * this an index into the targetList,
291
+ * so make sure we had one to start...
292
+ */
293
+ if (i >= 0 )
294
+ {
295
+ freeList (lnext (extrl ));
296
+ lnext (extrl ) = NIL ;
297
+ }
298
+ else
299
+ {
300
+ icolumns = NIL ;
301
+ }
287
302
}
288
303
289
304
while (ndef -- > 0 )
@@ -295,7 +310,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
295
310
foreach (tl , icolumns )
296
311
{
297
312
id = (Ident * ) lfirst (tl );
298
- if (! namestrcmp (& (att [defval [ndef ].adnum - 1 ]-> attname ), id -> name ))
313
+ if (namestrcmp (& (att [defval [ndef ].adnum - 1 ]-> attname ), id -> name ) == 0 )
299
314
break ;
300
315
}
301
316
if (tl != NIL ) /* something given for this attr */
0 commit comments