]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Change some Datum to void * for opaque pass-through pointer
authorPeter Eisentraut <peter@eisentraut.org>
Sun, 28 Dec 2025 13:34:12 +0000 (14:34 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Sun, 28 Dec 2025 13:34:12 +0000 (14:34 +0100)
Here, Datum was used to pass around an opaque pointer between a group
of functions.  But one might as well use void * for that; the use of
Datum doesn't achieve anything here and is just distracting.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1c5d23cb-288b-4154-b1cd-191fe2301707%40eisentraut.org

src/backend/tsearch/to_tsany.c
src/backend/utils/adt/tsquery.c
src/include/tsearch/ts_utils.h

index b6efe108424f6073bc4f2949cde43a3bcc1c1b78..5e9eccd047500c881096bfc81d4d8a1f648fbe0b 100644 (file)
@@ -489,7 +489,7 @@ add_to_tsvector(void *_state, char *elem_value, int elem_len)
  * and different variants are ORed together.
  */
 static void
-pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
+pushval_morph(void *opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
 {
        int32           count = 0;
        ParsedText      prs;
@@ -498,7 +498,7 @@ pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval,
                                cntvar = 0,
                                cntpos = 0,
                                cnt = 0;
-       MorphOpaque *data = (MorphOpaque *) DatumGetPointer(opaque);
+       MorphOpaque *data = opaque;
 
        prs.lenwords = 4;
        prs.curwords = 0;
@@ -594,7 +594,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
 
        query = parse_tsquery(text_to_cstring(in),
                                                  pushval_morph,
-                                                 PointerGetDatum(&data),
+                                                 &data,
                                                  0,
                                                  NULL);
 
@@ -631,7 +631,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
 
        query = parse_tsquery(text_to_cstring(in),
                                                  pushval_morph,
-                                                 PointerGetDatum(&data),
+                                                 &data,
                                                  P_TSQ_PLAIN,
                                                  NULL);
 
@@ -669,7 +669,7 @@ phraseto_tsquery_byid(PG_FUNCTION_ARGS)
 
        query = parse_tsquery(text_to_cstring(in),
                                                  pushval_morph,
-                                                 PointerGetDatum(&data),
+                                                 &data,
                                                  P_TSQ_PLAIN,
                                                  NULL);
 
@@ -707,7 +707,7 @@ websearch_to_tsquery_byid(PG_FUNCTION_ARGS)
 
        query = parse_tsquery(text_to_cstring(in),
                                                  pushval_morph,
-                                                 PointerGetDatum(&data),
+                                                 &data,
                                                  P_TSQ_WEB,
                                                  NULL);
 
index a0c990fdfa03d74fafeb2ac7881ecf83250179a8..d42249679cc230f9e28d02c68fc8c55f56dcc4eb 100644 (file)
@@ -671,7 +671,7 @@ cleanOpStack(TSQueryParserState state,
 static void
 makepol(TSQueryParserState state,
                PushFunction pushval,
-               Datum opaque)
+               void *opaque)
 {
        int8            operator = 0;
        ts_tokentype type;
@@ -816,7 +816,7 @@ findoprnd(QueryItem *ptr, int size, bool *needcleanup)
 TSQuery
 parse_tsquery(char *buf,
                          PushFunction pushval,
-                         Datum opaque,
+                         void *opaque,
                          int flags,
                          Node *escontext)
 {
@@ -939,7 +939,7 @@ parse_tsquery(char *buf,
 }
 
 static void
-pushval_asis(Datum opaque, TSQueryParserState state, char *strval, int lenval,
+pushval_asis(void *opaque, TSQueryParserState state, char *strval, int lenval,
                         int16 weight, bool prefix)
 {
        pushValue(state, strval, lenval, weight, prefix);
@@ -956,7 +956,7 @@ tsqueryin(PG_FUNCTION_ARGS)
 
        PG_RETURN_TSQUERY(parse_tsquery(in,
                                                                        pushval_asis,
-                                                                       PointerGetDatum(NULL),
+                                                                       NULL,
                                                                        0,
                                                                        escontext));
 }
index 7debc85ed80fa183ff3d1a32539e21a083215faf..7817592908818fd173a10735b4830582f6cdf494 100644 (file)
@@ -54,7 +54,7 @@ extern void close_tsvector_parser(TSVectorParseState state);
 struct TSQueryParserStateData; /* private in backend/utils/adt/tsquery.c */
 typedef struct TSQueryParserStateData *TSQueryParserState;
 
-typedef void (*PushFunction) (Datum opaque, TSQueryParserState state,
+typedef void (*PushFunction) (void *opaque, TSQueryParserState state,
                                                          char *token, int tokenlen,
                                                          int16 tokenweights,   /* bitmap as described in
                                                                                                         * QueryOperand struct */
@@ -66,7 +66,7 @@ typedef void (*PushFunction) (Datum opaque, TSQueryParserState state,
 
 extern TSQuery parse_tsquery(char *buf,
                                                         PushFunction pushval,
-                                                        Datum opaque,
+                                                        void *opaque,
                                                         int flags,
                                                         Node *escontext);