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

Commit8c49086

Browse files
committed
[PGPRO-8894] Correction of expression calculation for case recheckPhrase=true
1 parentc40b86e commit8c49086

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ REGRESS = security rum rum_validate rum_hash ruminv timestamp orderby orderby_ha
3030
int2 int4 int8 float4 float8 money oid\
3131
time timetz date interval\
3232
macaddr inet cidr text varchar char bytea bit varbit\
33-
numeric rum_weight
33+
numeric rum_weight expr
3434

3535
TAP_TESTS = 1
3636

‎expected/expr.out

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CREATE TABLE documents (
2+
en text not null,
3+
score float not null,
4+
textsearch_index_en_col tsvector
5+
);
6+
INSERT INTO documents VALUES ('the pet cat is in the shed', 56, to_tsvector('english', 'the pet cat is in the shed'));
7+
CREATE INDEX textsearch_index_en ON documents
8+
USING rum (textsearch_index_en_col rum_tsvector_addon_ops, score)
9+
WITH (attach = 'score', to = 'textsearch_index_en_col');
10+
SET enable_seqscan=off;
11+
-- should be 1 row
12+
SELECT * FROM documents WHERE textsearch_index_en_col @@ ('pet'::tsquery <-> ('dog'::tsquery || 'cat'::tsquery));
13+
en | score | textsearch_index_en_col
14+
----------------------------+-------+--------------------------
15+
the pet cat is in the shed | 56 | 'cat':3 'pet':2 'shed':7
16+
(1 row)
17+
18+
SET enable_seqscan=on;
19+
-- 1 row
20+
SELECT * FROM documents WHERE textsearch_index_en_col @@ ('pet'::tsquery <-> ('dog'::tsquery || 'cat'::tsquery));
21+
en | score | textsearch_index_en_col
22+
----------------------------+-------+--------------------------
23+
the pet cat is in the shed | 56 | 'cat':3 'pet':2 'shed':7
24+
(1 row)
25+
26+
DROP TABLE documents;

‎sql/expr.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CREATETABLEdocuments (
2+
entextnot null,
3+
score floatnot null,
4+
textsearch_index_en_col tsvector
5+
);
6+
7+
INSERT INTO documentsVALUES ('the pet cat is in the shed',56, to_tsvector('english','the pet cat is in the shed'));
8+
9+
CREATEINDEXtextsearch_index_enON documents
10+
USING rum (textsearch_index_en_col rum_tsvector_addon_ops, score)
11+
WITH (attach='score', to='textsearch_index_en_col');
12+
13+
SET enable_seqscan=off;
14+
-- should be 1 row
15+
SELECT*FROM documentsWHERE textsearch_index_en_col @@ ('pet'::tsquery<-> ('dog'::tsquery||'cat'::tsquery));
16+
17+
SET enable_seqscan=on;
18+
-- 1 row
19+
SELECT*FROM documentsWHERE textsearch_index_en_col @@ ('pet'::tsquery<-> ('dog'::tsquery||'cat'::tsquery));
20+
21+
DROPTABLE documents;

‎src/rum_ts_utils.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,14 @@ checkcondition_rum(void *checkval, QueryOperand *val, ExecPhraseData *data)
284284
* addInfo
285285
*/
286286
if (gcv->recheckPhrase)
287-
return ((val->weight) ?TS_MAYBE :TS_YES);
287+
{
288+
/*
289+
* We cannot return TS_YES here (if "val->weight > 0"), because
290+
* data->npos = 0 and we have incorrect porocessing of this result
291+
* at the upper levels. So return TS_MAYBE.
292+
*/
293+
returnTS_MAYBE;
294+
}
288295

289296
positions=DatumGetByteaP(gcv->addInfo[j]);
290297
ptrt= (char*)VARDATA_ANY(positions);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp