diff options
| author | Teodor Sigaev | 2016-04-08 17:11:30 +0000 |
|---|---|---|
| committer | Teodor Sigaev | 2016-04-08 17:11:30 +0000 |
| commit | 1ec4c7c055ca045c5df6352a4cdacd9aa778e598 (patch) | |
| tree | 7bb889947d9cf11740ef3c0ebb130a421bc0ea25 /src/include | |
| parent | 76a1c97bf21c301f61bb41345e0cdd0d365b2086 (diff) | |
Restore original tsquery operation numbering.
As noticed by Tom Lane changing operation's number in commit
bb140506df605fab58f48926ee1db1f80bdafb59 causes on-disk format incompatibility.
Revert to previous numbering, that is reason to add special array to store
priorities of operation. Also it reverts order of tsquery to previous.
Author: Dmitry Ivanov
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/tsearch/ts_type.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/include/tsearch/ts_type.h b/src/include/tsearch/ts_type.h index ff3fef1f47..8d24b32fac 100644 --- a/src/include/tsearch/ts_type.h +++ b/src/include/tsearch/ts_type.h @@ -222,11 +222,15 @@ typedef struct * for query transformation! That's need to simplify * algorithm of query transformation. */ -#define OP_OR 1 +#define OP_NOT 1 #define OP_AND 2 -#define OP_NOT 3 +#define OP_OR 3 #define OP_PHRASE 4 -#define OP_NOT_PHRASE 5 /* +#define OP_COUNT 4 + +extern const int tsearch_op_priority[OP_COUNT]; + +#define NOT_PHRASE_P 5 /* * OP_PHRASE negation operations must have greater * priority in order to force infix() to surround * the whole OP_PHRASE expression with parentheses. @@ -234,8 +238,13 @@ typedef struct #define TOP_PRIORITY 6 /* highest priority for val nodes */ -#define OP_PRIORITY(x) (x) +/* get operation priority by its code*/ +#define OP_PRIORITY(x) ( tsearch_op_priority[(x) - 1] ) +/* get QueryOperator priority */ #define QO_PRIORITY(x) OP_PRIORITY(((QueryOperator *) (x))->oper) +/* special case: get QueryOperator priority for correct printing !(a <-> b>) */ +#define PRINT_PRIORITY(x) \ + ( (((QueryOperator *) (x))->oper == OP_NOT) ? NOT_PHRASE_P : QO_PRIORITY(x) ) typedef struct { |
