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
|
|
|
#ifndef __QUERY_UTIL_H__
|
|
|
|
#define __QUERY_UTIL_H__
|
|
|
|
|
|
|
|
#include "postgres.h"
|
|
|
|
#include "utils/memutils.h"
|
|
|
|
|
|
|
|
#include "query.h"
|
|
|
|
|
2005-11-23 02:17:34 +08:00
|
|
|
typedef struct QTNode
|
|
|
|
{
|
|
|
|
ITEM *valnode;
|
|
|
|
uint32 flags;
|
|
|
|
int4 nchild;
|
|
|
|
char *word;
|
|
|
|
uint32 sign;
|
|
|
|
struct QTNode **child;
|
|
|
|
} QTNode;
|
|
|
|
|
|
|
|
#define QTN_NEEDFREE 0x01
|
|
|
|
#define QTN_NOCHANGE 0x02
|
|
|
|
#define QTN_WORDFREE 0x04
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
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
|
|
|
PlainMemory,
|
|
|
|
SPIMemory,
|
|
|
|
AggMemory
|
2005-11-23 02:17:34 +08:00
|
|
|
} MemoryType;
|
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
|
|
|
QTNode *QT2QTN(ITEM * in, char *operand);
|
|
|
|
QUERYTYPE *QTN2QT(QTNode * in, MemoryType memtype);
|
|
|
|
void QTNFree(QTNode * in);
|
|
|
|
void QTNSort(QTNode * in);
|
|
|
|
void QTNTernary(QTNode * in);
|
|
|
|
void QTNBinary(QTNode * in);
|
|
|
|
int QTNodeCompare(QTNode * an, QTNode * bn);
|
|
|
|
QTNode *QTNCopy(QTNode * in, MemoryType memtype);
|
|
|
|
bool QTNEq(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
|
|
|
extern MemoryContext AggregateContext;
|
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
|
|
|
#define MEMALLOC(us, s) ( ((us)==SPIMemory) ? SPI_palloc(s) : ( ( (us)==PlainMemory ) ? palloc(s) : MemoryContextAlloc(AggregateContext, (s)) ) )
|
|
|
|
#define MEMFREE(us, p) ( ((us)==SPIMemory) ? SPI_pfree(p) : pfree(p) )
|
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
|
|
|
|
|
|
|
#endif
|