修复行存向量化在创建物化视图时结果不正确的问题
This commit is contained in:
@ -288,18 +288,60 @@ void ExecStoreTupleBatchMode(TableScanDesc scanDesc, TupleTableSlot** slot)
|
||||
}
|
||||
}
|
||||
|
||||
bool FetchEpqTupleBatchMode(ScanState* node)
|
||||
{
|
||||
EState* estate = node->ps.state;
|
||||
Index scan_rel_id = ((Scan*)node->ps.plan)->scanrelid;
|
||||
Assert(scan_rel_id > 0);
|
||||
|
||||
if (estate->es_epqTupleSet[scan_rel_id - 1]) {
|
||||
TupleTableSlot* slot = node->scanBatchState->scanBatch.scanTupleSlotInBatch[0];
|
||||
|
||||
/* Return empty slot if we already returned a tuple */
|
||||
if (estate->es_epqScanDone[scan_rel_id - 1]) {
|
||||
(void)ExecClearTuple(slot);
|
||||
return true;
|
||||
}
|
||||
/* Else mark to remember that we shouldn't return more */
|
||||
estate->es_epqScanDone[scan_rel_id - 1] = true;
|
||||
|
||||
/* Return empty slot if we haven't got a test tuple */
|
||||
if (estate->es_epqTuple[scan_rel_id - 1] == NULL) {
|
||||
(void)ExecClearTuple(slot);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Store test tuple in the plan node's scan slot */
|
||||
(void)ExecStoreTuple(estate->es_epqTuple[scan_rel_id - 1], slot, InvalidBuffer, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static ScanBatchResult *SeqNextBatchMode(SeqScanState *node)
|
||||
{
|
||||
TableScanDesc scanDesc;
|
||||
EState *estate = NULL;
|
||||
EState *estate = node->ps.state;
|
||||
ScanDirection direction;
|
||||
TupleTableSlot **slot = NULL;
|
||||
TupleTableSlot **slot = &(node->scanBatchState->scanBatch.scanTupleSlotInBatch[0]);
|
||||
|
||||
/* while inside an EvalPlanQual recheck, return a test tuple */
|
||||
if (estate->es_epqTuple != NULL && FetchEpqTupleBatchMode(node)) {
|
||||
if (TupIsNull(slot[0])) {
|
||||
node->scanBatchState->scanBatch.rows = 0;
|
||||
return NULL;
|
||||
} else {
|
||||
node->scanBatchState->scanBatch.rows = 1;
|
||||
return &node->scanBatchState->scanBatch;
|
||||
}
|
||||
}
|
||||
|
||||
/* get information from the estate and scan state */
|
||||
scanDesc = node->ss_currentScanDesc;
|
||||
estate = node->ps.state;
|
||||
direction = estate->es_direction;
|
||||
slot = &(node->scanBatchState->scanBatch.scanTupleSlotInBatch[0]);
|
||||
|
||||
/* get tuples from the table. */
|
||||
scanDesc->rs_maxScanRows = node->scanBatchState->scanTupleSlotMaxNum;
|
||||
|
||||
@ -47,6 +47,24 @@ explain (analyze on, timing off) select /*+ set(try_vector_engine_strategy force
|
||||
--?.*
|
||||
(13 rows)
|
||||
|
||||
set try_vector_engine_strategy=force;
|
||||
create table force_tb1(c1 int,c2 int);
|
||||
insert into force_tb1 values(1,1);
|
||||
insert into force_tb1 values(2,2);
|
||||
create incremental materialized view v_force as select * from force_tb1;
|
||||
select * from v_force order by 1;
|
||||
c1 | c2
|
||||
----+----
|
||||
1 | 1
|
||||
2 | 2
|
||||
(2 rows)
|
||||
|
||||
set try_vector_engine_strategy=off;
|
||||
drop table force_vector_test;
|
||||
drop schema test_force_vector2 cascade;
|
||||
NOTICE: drop cascades to table force_vector_partition
|
||||
NOTICE: drop cascades to 5 other objects
|
||||
DETAIL: drop cascades to table force_vector_partition
|
||||
drop cascades to table force_tb1
|
||||
drop cascades to materialized view v_force
|
||||
--?.*
|
||||
--?.*
|
||||
|
||||
@ -18,5 +18,13 @@ analyze force_vector_partition;
|
||||
explain (analyze on, timing off) select /*+ set(try_vector_engine_strategy force) */ id, val1*2, val2+val1 as val3 from force_vector_test where id < 5000 and val1 < 500 order by id limit 10;
|
||||
explain (analyze on, timing off) select /*+ set(try_vector_engine_strategy force) */ id, avg(val1), sum(val2) from force_vector_partition group by id order by id limit 10;
|
||||
|
||||
set try_vector_engine_strategy=force;
|
||||
create table force_tb1(c1 int,c2 int);
|
||||
insert into force_tb1 values(1,1);
|
||||
insert into force_tb1 values(2,2);
|
||||
create incremental materialized view v_force as select * from force_tb1;
|
||||
select * from v_force order by 1;
|
||||
set try_vector_engine_strategy=off;
|
||||
|
||||
drop table force_vector_test;
|
||||
drop schema test_force_vector2 cascade;
|
||||
|
||||
Reference in New Issue
Block a user