@@ -75,7 +75,6 @@ SeqNext(SeqScanState *node)
75
75
76
76
if (scandesc == NULL )
77
77
{
78
- int nkeys = 0 ;
79
78
ScanKey keys = NULL ;
80
79
81
80
/*
@@ -84,15 +83,15 @@ SeqNext(SeqScanState *node)
84
83
* AM.
85
84
*/
86
85
if (gp_enable_runtime_filter_pushdown && !node -> filter_in_seqscan )
87
- keys = ScanKeyListToArray (node -> filters , & nkeys );
86
+ keys = ScanKeyListToArray (node -> filters , & node -> num_scan_keys );
88
87
89
88
/*
90
89
* We reach here if the scan is not parallel, or if we're serially
91
90
* executing a scan that was planned to be parallel.
92
91
*/
93
92
scandesc = table_beginscan_es (node -> ss .ss_currentRelation ,
94
93
estate -> es_snapshot ,
95
- nkeys , keys ,
94
+ node -> num_scan_keys , keys ,
96
95
NULL ,
97
96
& node -> ss .ps );
98
97
node -> ss .ss_currentScanDesc = scandesc ;
@@ -283,12 +282,27 @@ void
283
282
ExecReScanSeqScan (SeqScanState * node )
284
283
{
285
284
TableScanDesc scan ;
285
+ ScanKey keys ;
286
286
287
287
scan = node -> ss .ss_currentScanDesc ;
288
288
289
+ /*
290
+ * Clear all the pushdown scan keys.
291
+ */
292
+ keys = NULL ;
293
+ if (node -> num_scan_keys )
294
+ {
295
+ keys = (ScanKey )palloc (sizeof (ScanKeyData ) * node -> num_scan_keys );
296
+ for (int i = 0 ; i < node -> num_scan_keys ; ++ i )
297
+ keys [i ].sk_flags = SK_EMPYT ;
298
+ }
299
+
289
300
if (scan != NULL )
290
301
table_rescan (scan , /* scan desc */
291
- NULL ); /* new scan keys */
302
+ keys ); /* new scan keys */
303
+
304
+ if (keys )
305
+ pfree (keys );
292
306
293
307
ExecScanReScan ((ScanState * ) node );
294
308
}
@@ -455,7 +469,10 @@ ScanKeyListToArray(List *keys, int *num)
455
469
ScanKey sk ;
456
470
457
471
if (list_length (keys ) == 0 )
472
+ {
473
+ * num = 0 ;
458
474
return NULL ;
475
+ }
459
476
460
477
Assert (num );
461
478
* num = list_length (keys );
0 commit comments