aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tsquery_cleanup.c
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2016-07-15 19:22:18 +0300
committerTeodor Sigaev <teodor@sigaev.ru>2016-07-15 19:22:18 +0300
commit19d290155d084754eeb5ebb2569654da06073ee8 (patch)
tree5d732d9e5d88087605083878100f5eaafd101e72 /src/backend/utils/adt/tsquery_cleanup.c
parentce150e7e0fc1a127fee7933d71f4204a79ecce04 (diff)
downloadpostgresql-19d290155d084754eeb5ebb2569654da06073ee8.tar.gz
postgresql-19d290155d084754eeb5ebb2569654da06073ee8.zip
Fix nested NOT operation cleanup in tsquery.
During normalization of tsquery tree it tries to simplify nested NOT operations but there it's obvioulsy missed that subsequent node could be a leaf node (value node) Bug #14245: Segfault on weird to_tsquery Reported by David Kellum.
Diffstat (limited to 'src/backend/utils/adt/tsquery_cleanup.c')
-rw-r--r--src/backend/utils/adt/tsquery_cleanup.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/utils/adt/tsquery_cleanup.c b/src/backend/utils/adt/tsquery_cleanup.c
index 1a90964ce79..8c2df73ea6b 100644
--- a/src/backend/utils/adt/tsquery_cleanup.c
+++ b/src/backend/utils/adt/tsquery_cleanup.c
@@ -406,6 +406,8 @@ normalize_phrase_tree(NODE *node)
if (node->valnode->qoperator.oper == OP_NOT)
{
+ NODE *orignode = node;
+
/* eliminate NOT sequence */
while (node->valnode->type == QI_OPR &&
node->valnode->qoperator.oper == node->right->valnode->qoperator.oper)
@@ -413,7 +415,11 @@ normalize_phrase_tree(NODE *node)
node = node->right->right;
}
- node->right = normalize_phrase_tree(node->right);
+ if (orignode != node)
+ /* current node isn't checked yet */
+ node = normalize_phrase_tree(node);
+ else
+ node->right = normalize_phrase_tree(node->right);
}
else if (node->valnode->qoperator.oper == OP_PHRASE)
{