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

Commitfe1a9c3

Browse files
committed
Repair some problems in GIST-index contrib modules. Patch from
Teodor Sigaev <teodor@stack.net>.
1 parente206ff5 commitfe1a9c3

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

‎contrib/intarray/_int.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,10 @@ _int_common_picksplit(bytea *entryvec,
14571457
v->spl_nleft=0;
14581458
right=v->spl_right;
14591459
v->spl_nright=0;
1460+
if (seed_1==0||seed_2==0 ) {
1461+
seed_1=1;
1462+
seed_2=2;
1463+
}
14601464

14611465
datum_alpha= (ArrayType*)DatumGetPointer(((GISTENTRY*)VARDATA(entryvec))[seed_1].key);
14621466
datum_l=copy_intArrayType(datum_alpha);

‎contrib/tsearch/README.tsearch

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,6 @@ Don't forget to do
198198
make clean; make; make install
199199

200200
2.
201-
As it was mentioned above we don't use explicitly ID of lexems
202-
as in OpenFTS but use hash function (crc32) instead to map lexem to
203-
integer. Our experiments show that probability of collision is quite small:
204-
for english text it's about 10**(-6) and 10**(-5) for russian collection.
205-
Default installation doesn't check for collisions but if your application
206-
does need to guarantee an exact (no collisions) search, you need
207-
to update system table to mark index islossy:
208-
209-
update pg_amop set amopreqcheck = true where amopclaid =
210-
(select oid from pg_opclass where opcname = 'gist_txtidx_ops');
211-
212-
If you don't bother about collisions :
213-
214-
update pg_amop set amopreqcheck = false where amopclaid =
215-
(select oid from pg_opclass where opcname = 'gist_txtidx_ops');
216-
217-
3.
218201
txtidx doesn't preserve words ordering (this is not critical for searching)
219202
for performance reason, for example:
220203

@@ -224,7 +207,7 @@ test=# select 'page two'::txtidx;
224207
'two' 'page'
225208
(1 row)
226209

227-
4.
210+
3.
228211
Indexed access provided by txtidx data type isn't always good
229212
because of internal data structure we use (RD-Tree). Particularly,
230213
queries like '!gist' will be slower than just a sequential scan,
@@ -265,7 +248,7 @@ test=# select querytree( '!gist'::query_txt );
265248
These two queries will be processed by scanning of full index !
266249
Very slow !
267250

268-
5.
251+
4.
269252
Following selects produce the same result
270253

271254
select title from titles where titleidx @@ 'patch&gist';

‎contrib/tsearch/gistidx.c

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include"utils/array.h"
1111
#include"utils/builtins.h"
1212
#include"storage/bufpage.h"
13+
#include"access/tuptoaster.h"
1314

1415
#include"txtidx.h"
1516
#include"query.h"
@@ -86,6 +87,15 @@ uniqueint( int4* a, int4 l ) {
8687
returnres+1-a;
8788
}
8889

90+
staticvoid
91+
makesign(BITVECPsign,GISTTYPE*a) {
92+
int4k,len=ARRNELEM(a );
93+
int4*ptr=GETARR(a );
94+
MemSet( (void*)sign,0,sizeof(BITVEC) );
95+
for(k=0;k<len;k++)
96+
HASH(sign,ptr[k] );
97+
}
98+
8999
Datum
90100
gtxtidx_compress(PG_FUNCTION_ARGS) {
91101
GISTENTRY*entry= (GISTENTRY*)PG_GETARG_POINTER(0);
@@ -110,8 +120,6 @@ gtxtidx_compress(PG_FUNCTION_ARGS) {
110120
*arr=crc32_sz( (uint8*)&words[ptr->pos ],ptr->len );
111121
arr++;ptr++;
112122
}
113-
if (val!=toastedval )
114-
pfree(val);
115123

116124
len=uniqueint(GETARR(res),val->size );
117125
if (len!=val->size ) {
@@ -120,7 +128,22 @@ gtxtidx_compress(PG_FUNCTION_ARGS) {
120128
len=CALCGTSIZE(ARRKEY,len );
121129
res= (GISTTYPE*)repalloc( (void*)res,len );
122130
res->len=len;
123-
}
131+
}
132+
if (val!=toastedval )
133+
pfree(val);
134+
135+
/* make signature, if array is too long */
136+
if (res->len>TOAST_INDEX_TARGET ) {
137+
GISTTYPE*ressign;
138+
139+
len=CALCGTSIZE(SIGNKEY,0 );
140+
ressign= (GISTTYPE*)palloc(len );
141+
ressign->len=len;
142+
ressign->flag=SIGNKEY;
143+
makesign(GETSIGN(ressign),res );
144+
pfree(res);
145+
res=ressign;
146+
}
124147

125148
retval= (GISTENTRY*)palloc(sizeof(GISTENTRY));
126149
gistentryinit(*retval,PointerGetDatum(res),
@@ -379,15 +402,6 @@ gtxtidx_penalty(PG_FUNCTION_ARGS) {
379402
PG_RETURN_POINTER(penalty );
380403
}
381404

382-
staticvoid
383-
makesign(BITVECPsign,GISTTYPE*a) {
384-
int4k,len=ARRNELEM(a );
385-
int4*ptr=GETARR(a );
386-
MemSet( (void*)sign,0,sizeof(BITVEC) );
387-
for(k=0;k<len;k++)
388-
HASH(sign,ptr[k] );
389-
}
390-
391405
typedefstruct {
392406
boolallistrue;
393407
BITVECsign;
@@ -503,6 +517,11 @@ gtxtidx_picksplit(PG_FUNCTION_ARGS) {
503517
right=v->spl_right;
504518
v->spl_nright=0;
505519

520+
if (seed_1==0||seed_2==0 ) {
521+
seed_1=1;
522+
seed_2=2;
523+
}
524+
506525
/* form initial .. */
507526
if (cache[seed_1].allistrue ) {
508527
datum_l= (GISTTYPE*)palloc(CALCGTSIZE(SIGNKEY|ALLISTRUE,0 ) );

‎contrib/tsearch/tsearch.sql.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ WHERE o.oprleft = t.oid and o.oprright=tq.oid
171171
and ( tq.typname='query_txt' or tq.typname='mquery_txt' );
172172

173173
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
174-
SELECT opcl.oid, 1,false, c.opoid
174+
SELECT opcl.oid, 1,true, c.opoid
175175
FROM pg_opclass opcl, txtidx_ops_tmp c
176176
WHERE
177177
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
178178
and opcname = 'gist_txtidx_ops'
179179
and c.oprname = '@@';
180180

181181
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
182-
SELECT opcl.oid, 2,false, c.opoid
182+
SELECT opcl.oid, 2,true, c.opoid
183183
FROM pg_opclass opcl, txtidx_ops_tmp c
184184
WHERE
185185
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp