diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2005-11-21 12:27:57 +0000 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2005-11-21 12:27:57 +0000 |
commit | c52795d18a698d25b9cd7cd1ca9318a42b08fdb9 (patch) | |
tree | cc126dc4449b57de52c46497dfa3e0521ec76402 /contrib/tsearch2/wparser_def.c | |
parent | b91e6ed93e066c73324e08f3321bd3ac4d774fbd (diff) |
Text parser rewritten:
- supports multibyte encodings
- more strict rules for lexemes
- flex isn't used
Add:
- tsquery plainto_tsquery(text)
Function makes tsquery from plain text.
- &&, ||, !! operation for tsquery for combining
tsquery from it's parts: 'foo & bar' || 'asd' => 'foo & bar | asd'
Diffstat (limited to 'contrib/tsearch2/wparser_def.c')
-rw-r--r-- | contrib/tsearch2/wparser_def.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c index 66862578872..897ff2795e2 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -39,8 +39,7 @@ Datum prsd_start(PG_FUNCTION_ARGS); Datum prsd_start(PG_FUNCTION_ARGS) { - tsearch2_start_parse_str((char *) PG_GETARG_POINTER(0), PG_GETARG_INT32(1)); - PG_RETURN_POINTER(NULL); + PG_RETURN_POINTER(TParserInit( (char *) PG_GETARG_POINTER(0), PG_GETARG_INT32(1))); } PG_FUNCTION_INFO_V1(prsd_getlexeme); @@ -48,14 +47,17 @@ Datum prsd_getlexeme(PG_FUNCTION_ARGS); Datum prsd_getlexeme(PG_FUNCTION_ARGS) { - /* ParserState *p=(ParserState*)PG_GETARG_POINTER(0); */ + TParser *p=(TParser*)PG_GETARG_POINTER(0); char **t = (char **) PG_GETARG_POINTER(1); int *tlen = (int *) PG_GETARG_POINTER(2); - int type = tsearch2_yylex(); - *t = token; - *tlen = tokenlen; - PG_RETURN_INT32(type); + if ( !TParserGet(p) ) + PG_RETURN_INT32(0); + + *t = p->lexeme; + *tlen = p->lenbytelexeme; + + PG_RETURN_INT32(p->type); } PG_FUNCTION_INFO_V1(prsd_end); @@ -63,8 +65,8 @@ Datum prsd_end(PG_FUNCTION_ARGS); Datum prsd_end(PG_FUNCTION_ARGS) { - /* ParserState *p=(ParserState*)PG_GETARG_POINTER(0); */ - tsearch2_end_parse(); + TParser *p=(TParser*)PG_GETARG_POINTER(0); + TParserClose(p); PG_RETURN_VOID(); } |