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

Commita1da826

Browse files
author
Alexander Korotkov
committed
Make RUM work on 10devel
PostgreSQL 10devel was feature freezed. Thus, we should start thinking aboutproviding RUM for it. This commit adopts RUM to API changes yet introducedin 10devel. Macros are used to provide build on both 9.6 and 10.
1 parenteeb0a98 commita1da826

File tree

5 files changed

+68
-12
lines changed

5 files changed

+68
-12
lines changed

‎src/rum.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ extern IndexBuildResult *rumbuild(Relation heap, Relation index,
427427
externvoidrumbuildempty(Relationindex);
428428
externboolruminsert(Relationindex,Datum*values,bool*isnull,
429429
ItemPointerht_ctid,RelationheapRel,
430-
IndexUniqueCheckcheckUnique);
430+
IndexUniqueCheckcheckUnique
431+
#ifPG_VERSION_NUM >=100000
432+
,structIndexInfo*indexInfo
433+
#endif
434+
);
431435
externvoidrumEntryInsert(RumState*rumstate,
432436
OffsetNumberattnum,Datumkey,RumNullCategorycategory,
433437
RumKey*items,uint32nitem,GinStatsData*buildStats);

‎src/rum_ts_utils.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626

2727
#include<math.h>
2828

29+
/* Use TS_EXEC_PHRASE_AS_AND when TS_EXEC_PHRASE_NO_POS is not defined */
30+
#ifndefTS_EXEC_PHRASE_NO_POS
31+
#defineTS_EXEC_PHRASE_NO_POS TS_EXEC_PHRASE_AS_AND
32+
#endif
33+
2934
PG_FUNCTION_INFO_V1(rum_extract_tsvector);
3035
PG_FUNCTION_INFO_V1(rum_extract_tsvector_hash);
3136
PG_FUNCTION_INFO_V1(rum_extract_tsquery);
@@ -177,7 +182,7 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
177182

178183
res=TS_execute(GETQUERY(query),
179184
&gcv,
180-
TS_EXEC_PHRASE_AS_AND,
185+
TS_EXEC_PHRASE_NO_POS,
181186
pre_checkcondition_rum);
182187
}
183188

@@ -326,7 +331,7 @@ rum_tsquery_timestamp_consistent(PG_FUNCTION_ARGS)
326331
gcv.recheckPhrase= true;
327332

328333
res=TS_execute(GETQUERY(query),&gcv,
329-
TS_EXEC_CALC_NOT |TS_EXEC_PHRASE_AS_AND,
334+
TS_EXEC_CALC_NOT |TS_EXEC_PHRASE_NO_POS,
330335
checkcondition_rum);
331336
}
332337

‎src/ruminsert.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,11 @@ rumHeapTupleInsert(RumState * rumstate, OffsetNumber attnum,
788788
bool
789789
ruminsert(Relationindex,Datum*values,bool*isnull,
790790
ItemPointerht_ctid,RelationheapRel,
791-
IndexUniqueCheckcheckUnique)
791+
IndexUniqueCheckcheckUnique
792+
#ifPG_VERSION_NUM >=100000
793+
,structIndexInfo*indexInfo
794+
#endif
795+
)
792796
{
793797
RumStaterumstate;
794798
MemoryContextoldCtx;

‎src/rumsort.c

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ booltrace_sort = false;
154154
booloptimize_bounded_sort= true;
155155
#endif
156156

157+
#ifPG_VERSION_NUM<100000
158+
/* Provide fallback for old version of tape interface for 9.6 */
159+
#defineLogicalTapeRewindForRead(x,y,z) LogicalTapeRewind((x), (y), false)
160+
#defineLogicalTapeRewindForWrite(x,y) LogicalTapeRewind((x), (y), true)
161+
#endif
157162

158163
/*
159164
* The objects we actually sort are SortTuple structs. These contain
@@ -300,6 +305,9 @@ struct Tuplesortstate
300305
intmemtupsize;/* allocated length of memtuples array */
301306
boolgrowmemtuples;/* memtuples' growth still underway? */
302307

308+
/* Buffer size to use for reading input tapes, during merge. */
309+
size_tread_buffer_size;
310+
303311
/*
304312
* While building initial runs, this is the current output run number
305313
* (starting at 0). Afterwards, it is the number of initial runs we made.
@@ -2364,6 +2372,8 @@ mergeruns(Tuplesortstate *state)
23642372
svTape,
23652373
svRuns,
23662374
svDummy;
2375+
intnumTapes;
2376+
intnumInputTapes;
23672377

23682378
Assert(state->status==TSS_BUILDRUNS);
23692379
Assert(state->memtupcount==0);
@@ -2383,9 +2393,33 @@ mergeruns(Tuplesortstate *state)
23832393
return;
23842394
}
23852395

2396+
/*
2397+
* If we had fewer runs than tapes, refund the memory that we imagined we
2398+
* would need for the tape buffers of the unused tapes.
2399+
*
2400+
* numTapes and numInputTapes reflect the actual number of tapes we will
2401+
* use. Note that the output tape's tape number is maxTapes - 1, so the
2402+
* tape numbers of the used tapes are not consecutive, and you cannot just
2403+
* loop from 0 to numTapes to visit all used tapes!
2404+
*/
2405+
if (state->Level==1)
2406+
{
2407+
numInputTapes=state->currentRun;
2408+
numTapes=numInputTapes+1;
2409+
FREEMEM(state, (state->maxTapes-numTapes)*TAPE_BUFFER_OVERHEAD);
2410+
}
2411+
else
2412+
{
2413+
numInputTapes=state->tapeRange;
2414+
numTapes=state->maxTapes;
2415+
}
2416+
2417+
state->read_buffer_size=Max(state->availMem /numInputTapes,0);
2418+
USEMEM(state,state->read_buffer_size*numInputTapes);
2419+
23862420
/* End of step D2: rewind all output tapes to prepare for merging */
23872421
for (tapenum=0;tapenum<state->tapeRange;tapenum++)
2388-
LogicalTapeRewind(state->tapeset,tapenum,false);
2422+
LogicalTapeRewindForRead(state->tapeset,tapenum,state->read_buffer_size);
23892423

23902424
for (;;)
23912425
{
@@ -2448,11 +2482,10 @@ mergeruns(Tuplesortstate *state)
24482482
if (--state->Level==0)
24492483
break;
24502484
/* rewind output tape T to use as new input */
2451-
LogicalTapeRewind(state->tapeset,state->tp_tapenum[state->tapeRange],
2452-
false);
2485+
LogicalTapeRewindForRead(state->tapeset,state->tp_tapenum[state->tapeRange],
2486+
state->read_buffer_size);
24532487
/* rewind used-up input tape P, and prepare it for write pass */
2454-
LogicalTapeRewind(state->tapeset,state->tp_tapenum[state->tapeRange-1],
2455-
true);
2488+
LogicalTapeRewindForWrite(state->tapeset,state->tp_tapenum[state->tapeRange-1]);
24562489
state->tp_runs[state->tapeRange-1]=0;
24572490

24582491
/*
@@ -2818,9 +2851,9 @@ rum_tuplesort_rescan(Tuplesortstate *state)
28182851
state->markpos_eof= false;
28192852
break;
28202853
caseTSS_SORTEDONTAPE:
2821-
LogicalTapeRewind(state->tapeset,
2822-
state->result_tape,
2823-
false);
2854+
LogicalTapeRewindForRead(state->tapeset,
2855+
state->result_tape,
2856+
state->read_buffer_size);
28242857
state->eof_reached= false;
28252858
state->markpos_block=0L;
28262859
state->markpos_offset=0;
@@ -2883,11 +2916,18 @@ rum_tuplesort_restorepos(Tuplesortstate *state)
28832916
state->eof_reached=state->markpos_eof;
28842917
break;
28852918
caseTSS_SORTEDONTAPE:
2919+
#ifPG_VERSION_NUM<100000
28862920
if (!LogicalTapeSeek(state->tapeset,
28872921
state->result_tape,
28882922
state->markpos_block,
28892923
state->markpos_offset))
28902924
elog(ERROR,"rum_tuplesort_restorepos failed");
2925+
#else
2926+
LogicalTapeSeek(state->tapeset,
2927+
state->result_tape,
2928+
state->markpos_block,
2929+
state->markpos_offset);
2930+
#endif
28912931
state->eof_reached=state->markpos_eof;
28922932
break;
28932933
default:

‎src/rumvalidate.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include"catalog/pg_type.h"
2222
#include"utils/builtins.h"
2323
#include"utils/catcache.h"
24+
#ifPG_VERSION_NUM >=100000
25+
#include"utils/regproc.h"
26+
#endif
2427
#include"utils/syscache.h"
2528

2629
#include"rum.h"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp