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

Commit00f304c

Browse files
committed
Fix parsing NOT sequence in tsquery
Digging around bug #14245 I found that commit6734a1c missed that NOT operation isright associative in opposite to all other. This miss is resposible fortsquery parser fail on sequence of NOT operations
1 parent19d2901 commit00f304c

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

‎src/backend/utils/adt/tsquery.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,9 @@ cleanOpStack(TSQueryParserState state,
455455

456456
while(*lenstack)
457457
{
458-
if (opPriority>OP_PRIORITY(stack[*lenstack-1].op))
458+
/* NOT is right associative unlike to others */
459+
if ((op!=OP_NOT&&opPriority>OP_PRIORITY(stack[*lenstack-1].op))||
460+
(op==OP_NOT&&opPriority >=OP_PRIORITY(stack[*lenstack-1].op)))
459461
break;
460462

461463
(*lenstack)--;

‎src/test/regress/expected/tstypes.out

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,42 @@ SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery;
330330
'a':* & 'nbb':*AC | 'doo':*A | 'goo'
331331
(1 row)
332332

333+
SELECT '!!b'::tsquery;
334+
tsquery
335+
---------
336+
!!'b'
337+
(1 row)
338+
339+
SELECT '!!!b'::tsquery;
340+
tsquery
341+
---------
342+
!!!'b'
343+
(1 row)
344+
345+
SELECT '!(!b)'::tsquery;
346+
tsquery
347+
---------
348+
!!'b'
349+
(1 row)
350+
351+
SELECT 'a & !!b'::tsquery;
352+
tsquery
353+
-------------
354+
'a' & !!'b'
355+
(1 row)
356+
357+
SELECT '!!a & b'::tsquery;
358+
tsquery
359+
-------------
360+
!!'a' & 'b'
361+
(1 row)
362+
363+
SELECT '!!a & !!b'::tsquery;
364+
tsquery
365+
---------------
366+
!!'a' & !!'b'
367+
(1 row)
368+
333369
-- phrase transformation
334370
SELECT 'a <-> (b|c)'::tsquery;
335371
tsquery

‎src/test/regress/sql/tstypes.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ SELECT '1&(2&(4&(5|!6)))'::tsquery;
5757
SELECT E'1&(''2''&('' 4''&(\\|5 |''6\\'' !|&'')))'::tsquery;
5858
SELECT $$'\\as'$$::tsquery;
5959
SELECT'a:* & nbb:*ac | doo:a* | goo'::tsquery;
60+
SELECT'!!b'::tsquery;
61+
SELECT'!!!b'::tsquery;
62+
SELECT'!(!b)'::tsquery;
63+
SELECT'a & !!b'::tsquery;
64+
SELECT'!!a & b'::tsquery;
65+
SELECT'!!a & !!b'::tsquery;
6066

6167
-- phrase transformation
6268
SELECT'a <-> (b|c)'::tsquery;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp