Skip to content

Commit d982daa

Browse files
committed
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>
1 parent 83d0b9f commit d982daa

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/backend/tsearch/to_tsany.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.2 2007/09/07 15:09:55 teodor Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.3 2007/09/10 12:36:40 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -235,7 +235,7 @@ to_tsvector(PG_FUNCTION_ARGS)
235235
* and different variants are ORred together.
236236
*/
237237
static void
238-
pushval_morph(void *opaque, TSQueryParserState state, char *strval, int lenval, int2 weight)
238+
pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int2 weight)
239239
{
240240
int4 count = 0;
241241
ParsedText prs;
@@ -244,7 +244,7 @@ pushval_morph(void *opaque, TSQueryParserState state, char *strval, int lenval,
244244
cntvar = 0,
245245
cntpos = 0,
246246
cnt = 0;
247-
Oid cfg_id = (Oid) opaque; /* the input is actually an Oid, not a pointer */
247+
Oid cfg_id = DatumGetObjectId(opaque); /* the input is actually an Oid, not a pointer */
248248

249249
prs.lenwords = 4;
250250
prs.curwords = 0;
@@ -303,7 +303,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
303303
QueryItem *res;
304304
int4 len;
305305

306-
query = parse_tsquery(TextPGetCString(in), pushval_morph, (void *) cfgid, false);
306+
query = parse_tsquery(TextPGetCString(in), pushval_morph, ObjectIdGetDatum(cfgid), false);
307307

308308
if (query->size == 0)
309309
PG_RETURN_TSQUERY(query);
@@ -341,7 +341,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
341341
QueryItem *res;
342342
int4 len;
343343

344-
query = parse_tsquery(TextPGetCString(in), pushval_morph, (void *)cfgid, true);
344+
query = parse_tsquery(TextPGetCString(in), pushval_morph, ObjectIdGetDatum(cfgid), true);
345345

346346
if (query->size == 0)
347347
PG_RETURN_TSQUERY(query);

src/backend/utils/adt/tsquery.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.5 2007/09/07 16:03:40 teodor Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.6 2007/09/10 12:36:40 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -314,7 +314,7 @@ pushStop(TSQueryParserState state)
314314
static void
315315
makepol(TSQueryParserState state,
316316
PushFunction pushval,
317-
void *opaque)
317+
Datum opaque)
318318
{
319319
int8 operator = 0;
320320
ts_tokentype type;
@@ -460,7 +460,7 @@ findoprnd(QueryItem *ptr, int size)
460460
TSQuery
461461
parse_tsquery(char *buf,
462462
PushFunction pushval,
463-
void *opaque,
463+
Datum opaque,
464464
bool isplain)
465465
{
466466
struct TSQueryParserStateData state;
@@ -543,7 +543,7 @@ parse_tsquery(char *buf,
543543
}
544544

545545
static void
546-
pushval_asis(void *opaque, TSQueryParserState state, char *strval, int lenval,
546+
pushval_asis(Datum opaque, TSQueryParserState state, char *strval, int lenval,
547547
int16 weight)
548548
{
549549
pushValue(state, strval, lenval, weight);
@@ -559,7 +559,7 @@ tsqueryin(PG_FUNCTION_ARGS)
559559

560560
pg_verifymbstr(in, strlen(in), false);
561561

562-
PG_RETURN_TSQUERY(parse_tsquery(in, pushval_asis, NULL, false));
562+
PG_RETURN_TSQUERY(parse_tsquery(in, pushval_asis, PointerGetDatum(NULL), false));
563563
}
564564

565565
/*

src/include/tsearch/ts_utils.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1998-2007, PostgreSQL Global Development Group
77
*
8-
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.3 2007/09/07 15:09:56 teodor Exp $
8+
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.4 2007/09/10 12:36:41 teodor Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -38,11 +38,13 @@ extern void close_tsvector_parser(TSVectorParseState state);
3838
struct TSQueryParserStateData; /* private in backend/utils/adt/tsquery.c */
3939
typedef struct TSQueryParserStateData *TSQueryParserState;
4040

41-
typedef void (*PushFunction)(void *opaque, TSQueryParserState state, char *, int, int2);
41+
typedef void (*PushFunction)(Datum opaque, TSQueryParserState state,
42+
char *token, int tokenlen,
43+
int2 tokenweights /* bitmap as described in QueryOperand struct */ );
4244

4345
extern TSQuery parse_tsquery(char *buf,
4446
PushFunction pushval,
45-
void *opaque, bool isplain);
47+
Datum opaque, bool isplain);
4648

4749
/* Functions for use by PushFunction implementations */
4850
extern void pushValue(TSQueryParserState state,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy