Fix parsing NOT sequence in tsquery
Digging around bug #14245 I found that commit 6734a1cacd44f5b731933cbc93182b135b167d0c missed that NOT operation is right associative in opposite to all other. This miss is resposible for tsquery parser fail on sequence of NOT operations
This commit is contained in:
parent
19d290155d
commit
00f304ce2d
@ -455,7 +455,9 @@ cleanOpStack(TSQueryParserState state,
|
|||||||
|
|
||||||
while(*lenstack)
|
while(*lenstack)
|
||||||
{
|
{
|
||||||
if (opPriority > OP_PRIORITY(stack[*lenstack - 1].op))
|
/* NOT is right associative unlike to others */
|
||||||
|
if ((op != OP_NOT && opPriority > OP_PRIORITY(stack[*lenstack - 1].op)) ||
|
||||||
|
(op == OP_NOT && opPriority >= OP_PRIORITY(stack[*lenstack - 1].op)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
(*lenstack)--;
|
(*lenstack)--;
|
||||||
|
@ -330,6 +330,42 @@ SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery;
|
|||||||
'a':* & 'nbb':*AC | 'doo':*A | 'goo'
|
'a':* & 'nbb':*AC | 'doo':*A | 'goo'
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SELECT '!!b'::tsquery;
|
||||||
|
tsquery
|
||||||
|
---------
|
||||||
|
!!'b'
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT '!!!b'::tsquery;
|
||||||
|
tsquery
|
||||||
|
---------
|
||||||
|
!!!'b'
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT '!(!b)'::tsquery;
|
||||||
|
tsquery
|
||||||
|
---------
|
||||||
|
!!'b'
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT 'a & !!b'::tsquery;
|
||||||
|
tsquery
|
||||||
|
-------------
|
||||||
|
'a' & !!'b'
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT '!!a & b'::tsquery;
|
||||||
|
tsquery
|
||||||
|
-------------
|
||||||
|
!!'a' & 'b'
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT '!!a & !!b'::tsquery;
|
||||||
|
tsquery
|
||||||
|
---------------
|
||||||
|
!!'a' & !!'b'
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- phrase transformation
|
-- phrase transformation
|
||||||
SELECT 'a <-> (b|c)'::tsquery;
|
SELECT 'a <-> (b|c)'::tsquery;
|
||||||
tsquery
|
tsquery
|
||||||
|
@ -57,6 +57,12 @@ SELECT '1&(2&(4&(5|!6)))'::tsquery;
|
|||||||
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
|
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
|
||||||
SELECT $$'\\as'$$::tsquery;
|
SELECT $$'\\as'$$::tsquery;
|
||||||
SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery;
|
SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery;
|
||||||
|
SELECT '!!b'::tsquery;
|
||||||
|
SELECT '!!!b'::tsquery;
|
||||||
|
SELECT '!(!b)'::tsquery;
|
||||||
|
SELECT 'a & !!b'::tsquery;
|
||||||
|
SELECT '!!a & b'::tsquery;
|
||||||
|
SELECT '!!a & !!b'::tsquery;
|
||||||
|
|
||||||
-- phrase transformation
|
-- phrase transformation
|
||||||
SELECT 'a <-> (b|c)'::tsquery;
|
SELECT 'a <-> (b|c)'::tsquery;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user