Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f463c44

Browse files
committed
Ensure consistent results when FormSortKeys fails to find
all the expected keys (it was returning uninitialized memory).
1 parent 9b3e2dd commit f463c44

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/executor/nodeSort.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.18 1999/02/13 23:15:27 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.19 1999/06/03 03:17:37 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
15+
#include <string.h>
1516

1617
#include "executor/executor.h"
1718
#include "executor/execdebug.h"
@@ -58,6 +59,7 @@ FormSortKeys(Sort *sortnode)
5859
if (keycount <= 0)
5960
elog(ERROR, "FormSortKeys: keycount <= 0");
6061
sortkeys = (ScanKey) palloc(keycount * sizeof(ScanKeyData));
62+
MemSet((char *) sortkeys, 0, keycount * sizeof(ScanKeyData));
6163

6264
/* ----------------
6365
* form each scan key from the resdom info in the target list
@@ -72,7 +74,7 @@ FormSortKeys(Sort *sortnode)
7274
reskey = resdom->reskey;
7375
reskeyop = resdom->reskeyop;
7476

75-
if (reskey > 0)
77+
if (reskey > 0) /* ignore TLEs that are not sort keys */
7678
{
7779
ScanKeyEntryInitialize(&sortkeys[reskey - 1],
7880
0,

0 commit comments

Comments
 (0)