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

Commit56187be

Browse files
committed
minor refactoring for fetch_next_pair()
1 parentde99e0c commit56187be

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

‎init.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ extern void _PG_init(void);
2828

2929
staticset_join_pathlist_hook_typeset_join_pathlist_next;
3030

31+
typedefenum
32+
{
33+
FetchTidPairFinished=0,
34+
FetchTidPairInvalid,
35+
FetchTidPairReady
36+
}FetchTidPairState;
37+
3138
typedefstruct
3239
{
3340
CustomPathcpath;
@@ -528,7 +535,7 @@ crossmatch_begin(CustomScanState *node, EState *estate, int eflags)
528535
}
529536
}
530537

531-
staticbool
538+
staticFetchTidPairState
532539
fetch_next_pair(CrossmatchScanState*scan_state)
533540
{
534541
ScanState*ss=&scan_state->css.ss;
@@ -549,7 +556,7 @@ fetch_next_pair(CrossmatchScanState *scan_state)
549556

550557
if (!ItemPointerIsValid(&p_tids[0])|| !ItemPointerIsValid(&p_tids[1]))
551558
{
552-
returnfalse;
559+
returnFetchTidPairFinished;
553560
}
554561

555562
/* We don't have to fetch tuples if scan tlist is empty */
@@ -573,9 +580,11 @@ fetch_next_pair(CrossmatchScanState *scan_state)
573580
if (!htup_outer_ready)
574581
{
575582
htup_outer_ready= true;
576-
/* TODO: check result */
577-
heap_fetch(scan_state->outer,SnapshotSelf,
578-
&htup_outer,&buf1, false,NULL);
583+
if(!heap_fetch(scan_state->outer,SnapshotSelf,
584+
&htup_outer,&buf1, false,NULL))
585+
{
586+
returnFetchTidPairInvalid;
587+
}
579588
}
580589

581590
values[col_index]=heap_getattr(&htup_outer,var->varattno,
@@ -588,8 +597,11 @@ fetch_next_pair(CrossmatchScanState *scan_state)
588597
if (!htup_inner_ready)
589598
{
590599
htup_inner_ready= true;
591-
heap_fetch(scan_state->inner,SnapshotSelf,
592-
&htup_inner,&buf2, false,NULL);
600+
if(!heap_fetch(scan_state->inner,SnapshotSelf,
601+
&htup_inner,&buf2, false,NULL))
602+
{
603+
returnFetchTidPairInvalid;
604+
}
593605
}
594606

595607
values[col_index]=heap_getattr(&htup_inner,var->varattno,
@@ -611,7 +623,7 @@ fetch_next_pair(CrossmatchScanState *scan_state)
611623
ExecStoreTuple(htup,slot,InvalidBuffer, false);
612624
}
613625

614-
returntrue;
626+
returnFetchTidPairReady;
615627
}
616628

617629
staticTupleTableSlot*
@@ -620,12 +632,19 @@ crossmatch_exec(CustomScanState *node)
620632
CrossmatchScanState*scan_state= (CrossmatchScanState*)node;
621633
TupleTableSlot*scanSlot=node->ss.ss_ScanTupleSlot;
622634

623-
for(;;)
635+
for(;;)
624636
{
625637
if (!node->ss.ps.ps_TupFromTlist)
626638
{
627-
/* Fetch next tid pair if we're done with the SRF function */
628-
if (!fetch_next_pair(scan_state))
639+
FetchTidPairStatefetch_state;
640+
641+
do
642+
{
643+
fetch_state=fetch_next_pair(scan_state);
644+
}
645+
while (fetch_state==FetchTidPairInvalid);
646+
647+
if (fetch_state==FetchTidPairFinished)
629648
returnNULL;
630649
}
631650

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp