]> granicus.if.org Git - postgresql/blobdiff - src/backend/utils/adt/tsquery_gist.c
Fix initialization of fake LSN for unlogged relations
[postgresql] / src / backend / utils / adt / tsquery_gist.c
index bef86036dc13dc8e100c12934e52f984802458db..91200eecf6efe13c05d9052b7ffbedac19976dd3 100644 (file)
@@ -3,7 +3,7 @@
  * tsquery_gist.c
  *       GiST index support for tsquery
  *
- * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  *
  *
  * IDENTIFICATION
 
 #include "postgres.h"
 
-#include "access/skey.h"
+#include "access/stratnum.h"
 #include "access/gist.h"
 #include "tsearch/ts_utils.h"
+#include "utils/builtins.h"
 
 #define GETENTRY(vec,pos) DatumGetTSQuerySign((vec)->vector[pos].key)
 
@@ -36,17 +37,16 @@ gtsquery_compress(PG_FUNCTION_ARGS)
 
                gistentryinit(*retval, TSQuerySignGetDatum(sign),
                                          entry->rel, entry->page,
-                                         entry->offset, FALSE);
+                                         entry->offset, false);
        }
 
        PG_RETURN_POINTER(retval);
 }
 
-Datum
-gtsquery_decompress(PG_FUNCTION_ARGS)
-{
-       PG_RETURN_DATUM(PG_GETARG_DATUM(0));
-}
+/*
+ * We do not need a decompress function, because the other gtsquery
+ * support functions work with the compressed representation.
+ */
 
 Datum
 gtsquery_consistent(PG_FUNCTION_ARGS)
@@ -79,7 +79,7 @@ gtsquery_consistent(PG_FUNCTION_ARGS)
                                retval = (key & sq) != 0;
                        break;
                default:
-                       retval = FALSE;
+                       retval = false;
        }
        PG_RETURN_BOOL(retval);
 }
@@ -150,16 +150,16 @@ gtsquery_penalty(PG_FUNCTION_ARGS)
 typedef struct
 {
        OffsetNumber pos;
-       int           cost;
+       int32           cost;
 } SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
 {
-       if (((SPLITCOST *) a)->cost == ((SPLITCOST *) b)->cost)
+       if (((const SPLITCOST *) a)->cost == ((const SPLITCOST *) b)->cost)
                return 0;
        else
-               return (((SPLITCOST *) a)->cost > ((SPLITCOST *) b)->cost) ? 1 : -1;
+               return (((const SPLITCOST *) a)->cost > ((const SPLITCOST *) b)->cost) ? 1 : -1;
 }
 
 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
@@ -174,11 +174,11 @@ gtsquery_picksplit(PG_FUNCTION_ARGS)
                                j;
        TSQuerySign datum_l,
                                datum_r;
-       int           size_alpha,
+       int32           size_alpha,
                                size_beta;
-       int           size_waste,
+       int32           size_waste,
                                waste = -1;
-       int           nbytes;
+       int32           nbytes;
        OffsetNumber seed_1 = 0,
                                seed_2 = 0;
        OffsetNumber *left,
@@ -262,3 +262,16 @@ gtsquery_picksplit(PG_FUNCTION_ARGS)
 
        PG_RETURN_POINTER(v);
 }
+
+/*
+ * Formerly, gtsquery_consistent was declared in pg_proc.h with arguments
+ * that did not match the documented conventions for GiST support functions.
+ * We fixed that, but we still need a pg_proc entry with the old signature
+ * to support reloading pre-9.6 contrib/tsearch2 opclass declarations.
+ * This compatibility function should go away eventually.
+ */
+Datum
+gtsquery_consistent_oldsig(PG_FUNCTION_ARGS)
+{
+       return gtsquery_consistent(fcinfo);
+}