77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.52 1999/05/25 22:40:59 momjian Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.53 1999/06/12 19: 22:40 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -1432,6 +1432,7 @@ ExecTargetList(List *targetlist,
14321432Datum constvalue ;
14331433HeapTuple newTuple ;
14341434bool isNull ;
1435+ static struct tupleDesc NullTupleDesc ;/* we assume this inits to zeroes */
14351436
14361437/*
14371438 * debugging stuff
@@ -1441,35 +1442,15 @@ ExecTargetList(List *targetlist,
14411442EV_printf ("\n" );
14421443
14431444/*
1444- * Return a dummy tuple if the targetlist is empty. the dummy tuple is
1445- * necessary to differentiate between passing and failing the
1446- * qualification.
1445+ * There used to be some klugy and demonstrably broken code here that
1446+ * special-cased the situation where targetlist == NIL. Now we just
1447+ * fall through and return an empty-but-valid tuple. We do, however,
1448+ * have to cope with the possibility that targettype is NULL ---
1449+ * heap_formtuple won't like that, so pass a dummy descriptor with
1450+ * natts = 0 to deal with it.
14471451 */
1448- if (targetlist == NIL )
1449- {
1450-
1451- /*
1452- * I now think that the only time this makes any sense is when we
1453- * run a delete query.Then we need to return something other
1454- * than nil so we know to delete the tuple associated with the
1455- * saved tupleid.. see what ExecutePlan does with the returned
1456- * tuple.. -cim 9/21/89
1457- *
1458- * It could also happen in queries like: retrieve (foo.all) where
1459- * bar.a = 3
1460- *
1461- * is this a new phenomenon? it might cause bogus behavior if we try
1462- * to free this tuple later!! I put a hook in ExecProject to watch
1463- * out for this case -mer 24 Aug 1992
1464- *
1465- * We must return dummy tuple!!! Try select t1.x from t1, t2 where
1466- * t1.y = 1 and t2.y = 1 - t2 scan target list will be empty and
1467- * so no one tuple will be returned! But Mer was right - dummy
1468- * tuple must be palloced... - vadim 03/01/1999
1469- */
1470- * isDone = true;
1471- return (HeapTuple )palloc (1 );
1472- }
1452+ if (targettype == NULL )
1453+ targettype = & NullTupleDesc ;
14731454
14741455/*
14751456 * allocate an array of char's to hold the "null" information only if
@@ -1645,9 +1626,6 @@ ExecProject(ProjectionInfo *projInfo, bool *isDone)
16451626
16461627/*
16471628 * store the tuple in the projection slot and return the slot.
1648- *
1649- * If there's no projection target list we don't want to pfree the bogus
1650- * tuple that ExecTargetList passes back to us. -mer 24 Aug 1992
16511629 */
16521630return (TupleTableSlot * )
16531631ExecStoreTuple (newTuple ,/* tuple to store */