2003-07-21 18:27:44 +08:00
|
|
|
#ifndef __QUERY_H__
|
|
|
|
#define __QUERY_H__
|
|
|
|
/*
|
|
|
|
#define BS_DEBUG
|
|
|
|
*/
|
|
|
|
|
2005-12-12 19:10:12 +08:00
|
|
|
#include "ts_locale.h"
|
2003-07-21 18:27:44 +08:00
|
|
|
/*
|
|
|
|
* item in polish notation with back link
|
|
|
|
* to left operand
|
|
|
|
*/
|
|
|
|
typedef struct ITEM
|
|
|
|
{
|
|
|
|
int8 type;
|
|
|
|
int8 weight;
|
|
|
|
int2 left;
|
|
|
|
int4 val;
|
|
|
|
/* user-friendly value, must correlate with WordEntry */
|
2003-08-04 08:43:34 +08:00
|
|
|
uint32
|
2005-11-23 02:17:34 +08:00
|
|
|
istrue:1, /* use for ranking in Cover */
|
2003-08-04 08:43:34 +08:00
|
|
|
length:11,
|
|
|
|
distance:20;
|
2003-07-21 18:27:44 +08:00
|
|
|
} ITEM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
*Storage:
|
|
|
|
* (len)(size)(array of ITEM)(array of operand in user-friendly form)
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2007-03-01 06:44:38 +08:00
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
2003-07-21 18:27:44 +08:00
|
|
|
int4 size;
|
|
|
|
char data[1];
|
|
|
|
} QUERYTYPE;
|
|
|
|
|
2007-03-01 06:44:38 +08:00
|
|
|
#define HDRSIZEQT ( VARHDRSZ + sizeof(int4) )
|
2005-05-26 05:40:43 +08:00
|
|
|
#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
|
2003-07-21 18:27:44 +08:00
|
|
|
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
|
2005-05-26 05:40:43 +08:00
|
|
|
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)(x))->size * sizeof(ITEM) )
|
2003-07-21 18:27:44 +08:00
|
|
|
|
2005-12-12 19:10:12 +08:00
|
|
|
#define ISOPERATOR(x) ( pg_mblen(x)==1 && ( *(x)=='!' || *(x)=='&' || *(x)=='|' || *(x)=='(' || *(x)==')' ) )
|
2003-07-21 18:27:44 +08:00
|
|
|
|
|
|
|
#define END 0
|
|
|
|
#define ERR 1
|
|
|
|
#define VAL 2
|
|
|
|
#define OPR 3
|
|
|
|
#define OPEN 4
|
|
|
|
#define CLOSE 5
|
2003-08-28 20:23:24 +08:00
|
|
|
#define VALSTOP 6 /* for stop words */
|
2003-07-21 18:27:44 +08:00
|
|
|
|
2006-10-04 08:30:14 +08:00
|
|
|
bool TS_execute(ITEM * curitem, void *checkval,
|
|
|
|
bool calcnot, bool (*chkcond) (void *checkval, ITEM * val));
|
2003-07-21 18:27:44 +08:00
|
|
|
|
|
|
|
#endif
|