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

Commit97441e1

Browse files
committed
PGPRO-1572: Fix crash on empty table using index scan
1 parentd874e22 commit97441e1

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

‎expected/rum.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ CREATE TRIGGER tsvectorupdate
44
BEFORE UPDATE OR INSERT ON test_rum
55
FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't');
66
CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
7+
-- Check empty table using index scan
8+
SELECT
9+
a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'),
10+
rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
11+
*
12+
FROM test_rum
13+
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
14+
?column? | rum_ts_distance | t | a
15+
----------+-----------------+---+---
16+
(0 rows)
17+
18+
-- Fill the table with data
719
\copy test_rum(t) from 'data/rum.data';
820
CREATE INDEX failed_rumidx ON test_rum USING rum (a rum_tsvector_addon_ops);
921
ERROR: additional information attribute "a" is not found in index

‎sql/rum.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ BEFORE UPDATE OR INSERT ON test_rum
77
FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a','pg_catalog.english','t');
88
CREATEINDEXrumidxON test_rum USING rum (a rum_tsvector_ops);
99

10+
-- Check empty table using index scan
11+
SELECT
12+
a<=> to_tsquery('pg_catalog.english','way & (go | half)'),
13+
rum_ts_distance(a, to_tsquery('pg_catalog.english','way & (go | half)')),
14+
*
15+
FROM test_rum
16+
ORDER BY a<=> to_tsquery('pg_catalog.english','way & (go | half)')limit2;
17+
18+
-- Fill the table with data
1019
\copy test_rum(t)from'data/rum.data';
1120

1221
CREATEINDEXfailed_rumidxON test_rum USING rum (a rum_tsvector_addon_ops);

‎src/rumget.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,17 @@ startScanEntry(RumState * rumstate, RumScanEntry entry, Snapshot snapshot)
609609
(entry->queryCategory==RUM_CAT_EMPTY_QUERY&&
610610
entry->scanWithAddInfo))
611611
{
612-
IndexTupleitup= (IndexTuple)PageGetItem(page,PageGetItemId(page,stackEntry->off));
612+
IndexTupleitup;
613+
ItemIditemid=PageGetItemId(page,stackEntry->off);
614+
615+
/*
616+
* We don't want to crash if line pointer is not used.
617+
*/
618+
if (entry->queryCategory==RUM_CAT_EMPTY_QUERY&&
619+
!ItemIdHasStorage(itemid))
620+
gotoendScanEntry;
621+
622+
itup= (IndexTuple)PageGetItem(page,itemid);
613623

614624
if (RumIsPostingTree(itup))
615625
{
@@ -689,6 +699,7 @@ startScanEntry(RumState * rumstate, RumScanEntry entry, Snapshot snapshot)
689699
SCAN_ENTRY_GET_KEY(entry,rumstate,itup);
690700
}
691701

702+
endScanEntry:
692703
if (needUnlock)
693704
LockBuffer(stackEntry->buffer,RUM_UNLOCK);
694705
if (entry->stack==NULL)
@@ -2043,8 +2054,12 @@ scanGetItemFull(IndexScanDesc scan, RumItem *advancePast,
20432054
*/
20442055
entry=so->entries[0];
20452056

2057+
if (entry->isFinished)
2058+
return false;
2059+
20462060
entryGetItem(&so->rumstate,entry,&nextEntryList,scan->xs_snapshot);
2047-
if (entry->isFinished== true)
2061+
2062+
if (entry->isFinished)
20482063
return false;
20492064

20502065
/* Fill outerAddInfo */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp