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

Commit9c7bf36

Browse files
author
Artur Zakirov
committed
Fix full-index scan for order by by addinfo from another column
1 parente000001 commit9c7bf36

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

‎expected/rum.out

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,68 @@ SELECT a FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER
184184
'bar':2,8 'foo':1,3,6 'qq':7
185185
(1 row)
186186

187+
-- Check full-index scan with order by
188+
SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
189+
?column?
190+
----------
191+
16.4493
192+
16.4493
193+
Infinity
194+
Infinity
195+
Infinity
196+
Infinity
197+
Infinity
198+
Infinity
199+
Infinity
200+
Infinity
201+
Infinity
202+
Infinity
203+
Infinity
204+
Infinity
205+
Infinity
206+
Infinity
207+
Infinity
208+
Infinity
209+
Infinity
210+
Infinity
211+
Infinity
212+
Infinity
213+
Infinity
214+
Infinity
215+
Infinity
216+
Infinity
217+
Infinity
218+
Infinity
219+
Infinity
220+
Infinity
221+
Infinity
222+
Infinity
223+
Infinity
224+
Infinity
225+
Infinity
226+
Infinity
227+
Infinity
228+
Infinity
229+
Infinity
230+
Infinity
231+
Infinity
232+
Infinity
233+
Infinity
234+
Infinity
235+
Infinity
236+
Infinity
237+
Infinity
238+
Infinity
239+
Infinity
240+
Infinity
241+
Infinity
242+
Infinity
243+
Infinity
244+
Infinity
245+
Infinity
246+
Infinity
247+
(56 rows)
248+
187249
CREATE TABLE tst (i int4, t tsvector);
188250
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
189251
CREATE INDEX tstidx ON tst USING rum (t rum_tsvector_ops);

‎rumget.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,13 +2076,17 @@ scanGetItemFull(IndexScanDesc scan, RumKey *advancePast,
20762076
RumKey*item,bool*recheck)
20772077
{
20782078
RumScanOpaqueso= (RumScanOpaque)scan->opaque;
2079+
RumScanKeykey;
20792080
RumScanEntryentry;
20802081
boolnextEntryList;
20812082
uint32i;
20822083

2083-
Assert(so->totalentries>0);
2084+
Assert(so->nkeys>0&&so->totalentries>0);
20842085
Assert(so->entries[0]->scanWithAddInfo);
20852086

2087+
/* Full-index scan key */
2088+
key=so->keys[0];
2089+
Assert(key->searchMode==GIN_SEARCH_MODE_EVERYTHING);
20862090
/*
20872091
* This is first entry of the first key, which is used for full-index
20882092
* scan.
@@ -2093,6 +2097,12 @@ scanGetItemFull(IndexScanDesc scan, RumKey *advancePast,
20932097
if (entry->isFinished== TRUE)
20942098
return false;
20952099

2100+
/* Fill outerAddInfo using callConstistentFn() */
2101+
key->entryRes[0]= TRUE;
2102+
key->addInfo[0]=entry->curRumKey.addInfo;
2103+
key->addInfoIsNull[0]=entry->curRumKey.addInfoIsNull;
2104+
callConsistentFn(&so->rumstate,key);
2105+
20962106
/* Move related order by entries */
20972107
if (nextEntryList)
20982108
for (i=1;i<so->totalentries;i++)

‎sql/rum.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'rat')
6464

6565
SELECT aFROM test_rumWHERE a @@ to_tsquery('pg_catalog.english','bar')ORDER BY a;
6666

67+
-- Check full-index scan with order by
68+
SELECT a<=> to_tsquery('pg_catalog.english','ever|wrote')FROM test_rumORDER BY a<=> to_tsquery('pg_catalog.english','ever|wrote');
69+
6770
CREATETABLEtst (i int4, t tsvector);
6871
INSERT INTO tstSELECT i%10, to_tsvector('simple', substr(md5(i::text),1,1))FROM generate_series(1,100000) i;
6972
CREATEINDEXtstidxON tst USING rum (t rum_tsvector_ops);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp