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
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;
(*lenstack)--;
'a':* & 'nbb':*AC | 'doo':*A | 'goo'
(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
SELECT 'a <-> (b|c)'::tsquery;
tsquery
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
SELECT $$'\\as'$$::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
SELECT 'a <-> (b|c)'::tsquery;