Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1918a1d

Browse files
committed
When targetlist is NULL, ExecTargetList was passing back a
pointer to palloc'd but uninitialized memory. This is not cool; anyone lookingat the returned 'tuple' would at best coredump and at worst behave in abizarre and irreproducible way. Fix it to return a predictable value,namely a correctly-set-up palloc'd tuple containing zero attributes.I believe this fix is both safe and critical.
1 parent0c3281c commit1918a1d

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

‎src/backend/executor/execQual.c

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.52 1999/05/2522: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,
14321432
Datumconstvalue;
14331433
HeapTuplenewTuple;
14341434
boolisNull;
1435+
staticstructtupleDescNullTupleDesc;/* we assume this inits to zeroes */
14351436

14361437
/*
14371438
* debugging stuff
@@ -1441,35 +1442,15 @@ ExecTargetList(List *targetlist,
14411442
EV_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
*/
16521630
return (TupleTableSlot*)
16531631
ExecStoreTuple(newTuple,/* tuple to store */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp