New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
#include "postgres.h"
|
|
|
|
#include "executor/spi.h"
|
|
|
|
#include "query_util.h"
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
QTNode *
|
|
|
|
QT2QTN(ITEM * in, char *operand)
|
|
|
|
{
|
|
|
|
QTNode *node = (QTNode *) palloc0(sizeof(QTNode));
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
node->valnode = in;
|
2005-11-23 02:17:34 +08:00
|
|
|
|
|
|
|
if (in->type == OPR)
|
|
|
|
{
|
|
|
|
node->child = (QTNode **) palloc0(sizeof(QTNode *) * 2);
|
|
|
|
node->child[0] = QT2QTN(in + 1, operand);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
node->sign = node->child[0]->sign;
|
|
|
|
if (in->val == (int4) '!')
|
|
|
|
node->nchild = 1;
|
2005-11-23 02:17:34 +08:00
|
|
|
else
|
|
|
|
{
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
node->nchild = 2;
|
2005-11-23 02:17:34 +08:00
|
|
|
node->child[1] = QT2QTN(in + in->left, operand);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
node->sign |= node->child[1]->sign;
|
|
|
|
}
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
|
|
|
else if (operand)
|
|
|
|
{
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
node->word = operand + in->distance;
|
2005-11-23 02:17:34 +08:00
|
|
|
node->sign = 1 << (in->val % 32);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
2005-11-23 02:17:34 +08:00
|
|
|
|
|
|
|
return node;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
void
|
|
|
|
QTNFree(QTNode * in)
|
|
|
|
{
|
|
|
|
if (!in)
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return;
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->valnode->type == VAL && in->word && (in->flags & QTN_WORDFREE) != 0)
|
|
|
|
pfree(in->word);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->child)
|
|
|
|
{
|
|
|
|
if (in->valnode)
|
|
|
|
{
|
|
|
|
if (in->valnode->type == OPR && in->nchild > 0)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < in->nchild; i++)
|
|
|
|
QTNFree(in->child[i]);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->flags & QTN_NEEDFREE)
|
|
|
|
pfree(in->valnode);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
2005-11-23 02:17:34 +08:00
|
|
|
pfree(in->child);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
pfree(in);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-11-23 02:17:34 +08:00
|
|
|
QTNodeCompare(QTNode * an, QTNode * bn)
|
|
|
|
{
|
|
|
|
if (an->valnode->type != bn->valnode->type)
|
|
|
|
return (an->valnode->type > bn->valnode->type) ? -1 : 1;
|
|
|
|
else if (an->valnode->val != bn->valnode->val)
|
|
|
|
return (an->valnode->val > bn->valnode->val) ? -1 : 1;
|
|
|
|
else if (an->valnode->type == VAL)
|
|
|
|
{
|
|
|
|
if (an->valnode->length == bn->valnode->length)
|
|
|
|
return strncmp(an->word, bn->word, an->valnode->length);
|
|
|
|
else
|
|
|
|
return (an->valnode->length > bn->valnode->length) ? -1 : 1;
|
|
|
|
}
|
|
|
|
else if (an->nchild != bn->nchild)
|
|
|
|
{
|
|
|
|
return (an->nchild > bn->nchild) ? -1 : 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i,
|
|
|
|
res;
|
|
|
|
|
|
|
|
for (i = 0; i < an->nchild; i++)
|
|
|
|
if ((res = QTNodeCompare(an->child[i], bn->child[i])) != 0)
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return res;
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
|
|
|
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-11-23 02:17:34 +08:00
|
|
|
cmpQTN(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
return QTNodeCompare(*(QTNode **) a, *(QTNode **) b);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
void
|
|
|
|
QTNSort(QTNode * in)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (in->valnode->type != OPR)
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return;
|
2005-11-23 02:17:34 +08:00
|
|
|
|
|
|
|
for (i = 0; i < in->nchild; i++)
|
|
|
|
QTNSort(in->child[i]);
|
|
|
|
if (in->nchild > 1)
|
|
|
|
qsort((void *) in->child, in->nchild, sizeof(QTNode *), cmpQTN);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
bool
|
|
|
|
QTNEq(QTNode * a, QTNode * b)
|
|
|
|
{
|
|
|
|
uint32 sign = a->sign & b->sign;
|
|
|
|
|
|
|
|
if (!(sign == a->sign && sign == b->sign))
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return 0;
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
return (QTNodeCompare(a, b) == 0) ? true : false;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
void
|
|
|
|
QTNTernary(QTNode * in)
|
|
|
|
{
|
|
|
|
int i;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->valnode->type != OPR)
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return;
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
for (i = 0; i < in->nchild; i++)
|
|
|
|
QTNTernary(in->child[i]);
|
|
|
|
|
|
|
|
for (i = 0; i < in->nchild; i++)
|
|
|
|
{
|
|
|
|
if (in->valnode->type == in->child[i]->valnode->type && in->valnode->val == in->child[i]->valnode->val)
|
|
|
|
{
|
|
|
|
QTNode *cc = in->child[i];
|
|
|
|
int oldnchild = in->nchild;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
in->nchild += cc->nchild - 1;
|
|
|
|
in->child = (QTNode **) repalloc(in->child, in->nchild * sizeof(QTNode *));
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
if (i + 1 != oldnchild)
|
|
|
|
memmove(in->child + i + cc->nchild, in->child + i + 1,
|
|
|
|
(oldnchild - i - 1) * sizeof(QTNode *));
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
memcpy(in->child + i, cc->child, cc->nchild * sizeof(QTNode *));
|
|
|
|
i += cc->nchild - 1;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
pfree(cc);
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
void
|
|
|
|
QTNBinary(QTNode * in)
|
|
|
|
{
|
|
|
|
int i;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->valnode->type != OPR)
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
return;
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
for (i = 0; i < in->nchild; i++)
|
|
|
|
QTNBinary(in->child[i]);
|
|
|
|
|
|
|
|
if (in->nchild <= 2)
|
|
|
|
return;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
while (in->nchild > 2)
|
|
|
|
{
|
|
|
|
QTNode *nn = (QTNode *) palloc0(sizeof(QTNode));
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
nn->valnode = (ITEM *) palloc0(sizeof(ITEM));
|
|
|
|
nn->child = (QTNode **) palloc0(sizeof(QTNode *) * 2);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
nn->nchild = 2;
|
|
|
|
nn->flags = QTN_NEEDFREE;
|
|
|
|
|
|
|
|
nn->child[0] = in->child[0];
|
|
|
|
nn->child[1] = in->child[1];
|
|
|
|
nn->sign = nn->child[0]->sign | nn->child[1]->sign;
|
|
|
|
|
|
|
|
nn->valnode->type = in->valnode->type;
|
|
|
|
nn->valnode->val = in->valnode->val;
|
|
|
|
|
|
|
|
in->child[0] = nn;
|
2005-11-23 02:17:34 +08:00
|
|
|
in->child[1] = in->child[in->nchild - 1];
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
in->nchild--;
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-11-23 02:17:34 +08:00
|
|
|
cntsize(QTNode * in, int4 *sumlen, int4 *nnode)
|
|
|
|
{
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
*nnode += 1;
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->valnode->type == OPR)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < in->nchild; i++)
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
cntsize(in->child[i], sumlen, nnode);
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*sumlen += in->valnode->length + 1;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ITEM *curitem;
|
|
|
|
char *operand;
|
|
|
|
char *curoperand;
|
|
|
|
} QTN2QTState;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
static void
|
2005-11-23 02:17:34 +08:00
|
|
|
fillQT(QTN2QTState * state, QTNode * in)
|
|
|
|
{
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
*(state->curitem) = *(in->valnode);
|
2005-11-23 02:17:34 +08:00
|
|
|
|
|
|
|
if (in->valnode->type == VAL)
|
|
|
|
{
|
|
|
|
memcpy(state->curoperand, in->word, in->valnode->length);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
state->curitem->distance = state->curoperand - state->operand;
|
2005-11-23 02:17:34 +08:00
|
|
|
state->curoperand[in->valnode->length] = '\0';
|
|
|
|
state->curoperand += in->valnode->length + 1;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
state->curitem++;
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ITEM *curitem = state->curitem;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
Assert(in->nchild <= 2);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
state->curitem++;
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
fillQT(state, in->child[0]);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
if (in->nchild == 2)
|
|
|
|
{
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
curitem->left = state->curitem - curitem;
|
2005-11-23 02:17:34 +08:00
|
|
|
fillQT(state, in->child[1]);
|
|
|
|
}
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
QUERYTYPE *
|
|
|
|
QTN2QT(QTNode * in, MemoryType memtype)
|
|
|
|
{
|
|
|
|
QUERYTYPE *out;
|
|
|
|
int len;
|
|
|
|
int sumlen = 0,
|
|
|
|
nnode = 0;
|
|
|
|
QTN2QTState state;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
cntsize(in, &sumlen, &nnode);
|
2005-11-23 02:17:34 +08:00
|
|
|
len = COMPUTESIZE(nnode, sumlen);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
out = (QUERYTYPE *) MEMALLOC(memtype, len);
|
|
|
|
out->len = len;
|
|
|
|
out->size = nnode;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
state.curitem = GETQUERY(out);
|
|
|
|
state.operand = state.curoperand = GETOPERAND(out);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
fillQT(&state, in);
|
|
|
|
return out;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QTNode *
|
2005-11-23 02:17:34 +08:00
|
|
|
QTNCopy(QTNode * in, MemoryType memtype)
|
|
|
|
{
|
|
|
|
QTNode *out = (QTNode *) MEMALLOC(memtype, sizeof(QTNode));
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
*out = *in;
|
2005-11-23 02:17:34 +08:00
|
|
|
out->valnode = (ITEM *) MEMALLOC(memtype, sizeof(ITEM));
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
*(out->valnode) = *(in->valnode);
|
|
|
|
out->flags |= QTN_NEEDFREE;
|
2005-11-23 02:17:34 +08:00
|
|
|
|
|
|
|
if (in->valnode->type == VAL)
|
|
|
|
{
|
|
|
|
out->word = MEMALLOC(memtype, in->valnode->length + 1);
|
|
|
|
memcpy(out->word, in->word, in->valnode->length);
|
|
|
|
out->word[in->valnode->length] = '\0';
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
out->flags |= QTN_WORDFREE;
|
2005-11-23 02:17:34 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i;
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
out->child = (QTNode **) MEMALLOC(memtype, sizeof(QTNode *) * in->nchild);
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
for (i = 0; i < in->nchild; i++)
|
|
|
|
out->child[i] = QTNCopy(in->child[i], memtype);
|
|
|
|
}
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-09 01:08:46 +08:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|