Commit d982daae authored by Teodor Sigaev's avatar Teodor Sigaev

Change void* opaque argument to Datum type, add argument's

name to PushFunction type definition.

Per suggestion by Tome Lane <tgl@sss.pgh.pa.us>
parent 83d0b9f3
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.2 2007/09/07 15:09:55 teodor Exp $ * $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.3 2007/09/10 12:36:40 teodor Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -235,7 +235,7 @@ to_tsvector(PG_FUNCTION_ARGS) ...@@ -235,7 +235,7 @@ to_tsvector(PG_FUNCTION_ARGS)
* and different variants are ORred together. * and different variants are ORred together.
*/ */
static void static void
pushval_morph(void *opaque, TSQueryParserState state, char *strval, int lenval, int2 weight) pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int2 weight)
{ {
int4 count = 0; int4 count = 0;
ParsedText prs; ParsedText prs;
...@@ -244,7 +244,7 @@ pushval_morph(void *opaque, TSQueryParserState state, char *strval, int lenval, ...@@ -244,7 +244,7 @@ pushval_morph(void *opaque, TSQueryParserState state, char *strval, int lenval,
cntvar = 0, cntvar = 0,
cntpos = 0, cntpos = 0,
cnt = 0; cnt = 0;
Oid cfg_id = (Oid) opaque; /* the input is actually an Oid, not a pointer */ Oid cfg_id = DatumGetObjectId(opaque); /* the input is actually an Oid, not a pointer */
prs.lenwords = 4; prs.lenwords = 4;
prs.curwords = 0; prs.curwords = 0;
...@@ -303,7 +303,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS) ...@@ -303,7 +303,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
QueryItem *res; QueryItem *res;
int4 len; int4 len;
query = parse_tsquery(TextPGetCString(in), pushval_morph, (void *) cfgid, false); query = parse_tsquery(TextPGetCString(in), pushval_morph, ObjectIdGetDatum(cfgid), false);
if (query->size == 0) if (query->size == 0)
PG_RETURN_TSQUERY(query); PG_RETURN_TSQUERY(query);
...@@ -341,7 +341,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS) ...@@ -341,7 +341,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
QueryItem *res; QueryItem *res;
int4 len; int4 len;
query = parse_tsquery(TextPGetCString(in), pushval_morph, (void *)cfgid, true); query = parse_tsquery(TextPGetCString(in), pushval_morph, ObjectIdGetDatum(cfgid), true);
if (query->size == 0) if (query->size == 0)
PG_RETURN_TSQUERY(query); PG_RETURN_TSQUERY(query);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.5 2007/09/07 16:03:40 teodor Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.6 2007/09/10 12:36:40 teodor Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -314,7 +314,7 @@ pushStop(TSQueryParserState state) ...@@ -314,7 +314,7 @@ pushStop(TSQueryParserState state)
static void static void
makepol(TSQueryParserState state, makepol(TSQueryParserState state,
PushFunction pushval, PushFunction pushval,
void *opaque) Datum opaque)
{ {
int8 operator = 0; int8 operator = 0;
ts_tokentype type; ts_tokentype type;
...@@ -460,7 +460,7 @@ findoprnd(QueryItem *ptr, int size) ...@@ -460,7 +460,7 @@ findoprnd(QueryItem *ptr, int size)
TSQuery TSQuery
parse_tsquery(char *buf, parse_tsquery(char *buf,
PushFunction pushval, PushFunction pushval,
void *opaque, Datum opaque,
bool isplain) bool isplain)
{ {
struct TSQueryParserStateData state; struct TSQueryParserStateData state;
...@@ -543,7 +543,7 @@ parse_tsquery(char *buf, ...@@ -543,7 +543,7 @@ parse_tsquery(char *buf,
} }
static void static void
pushval_asis(void *opaque, TSQueryParserState state, char *strval, int lenval, pushval_asis(Datum opaque, TSQueryParserState state, char *strval, int lenval,
int16 weight) int16 weight)
{ {
pushValue(state, strval, lenval, weight); pushValue(state, strval, lenval, weight);
...@@ -559,7 +559,7 @@ tsqueryin(PG_FUNCTION_ARGS) ...@@ -559,7 +559,7 @@ tsqueryin(PG_FUNCTION_ARGS)
pg_verifymbstr(in, strlen(in), false); pg_verifymbstr(in, strlen(in), false);
PG_RETURN_TSQUERY(parse_tsquery(in, pushval_asis, NULL, false)); PG_RETURN_TSQUERY(parse_tsquery(in, pushval_asis, PointerGetDatum(NULL), false));
} }
/* /*
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1998-2007, PostgreSQL Global Development Group * Copyright (c) 1998-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.3 2007/09/07 15:09:56 teodor Exp $ * $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.4 2007/09/10 12:36:41 teodor Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,11 +38,13 @@ extern void close_tsvector_parser(TSVectorParseState state); ...@@ -38,11 +38,13 @@ extern void close_tsvector_parser(TSVectorParseState state);
struct TSQueryParserStateData; /* private in backend/utils/adt/tsquery.c */ struct TSQueryParserStateData; /* private in backend/utils/adt/tsquery.c */
typedef struct TSQueryParserStateData *TSQueryParserState; typedef struct TSQueryParserStateData *TSQueryParserState;
typedef void (*PushFunction)(void *opaque, TSQueryParserState state, char *, int, int2); typedef void (*PushFunction)(Datum opaque, TSQueryParserState state,
char *token, int tokenlen,
int2 tokenweights /* bitmap as described in QueryOperand struct */ );
extern TSQuery parse_tsquery(char *buf, extern TSQuery parse_tsquery(char *buf,
PushFunction pushval, PushFunction pushval,
void *opaque, bool isplain); Datum opaque, bool isplain);
/* Functions for use by PushFunction implementations */ /* Functions for use by PushFunction implementations */
extern void pushValue(TSQueryParserState state, extern void pushValue(TSQueryParserState state,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment