1 | /*-------------------------------------------------------------------------- |
2 | * gin.h |
3 | * Public header file for Generalized Inverted Index access method. |
4 | * |
5 | * Copyright (c) 2006-2019, PostgreSQL Global Development Group |
6 | * |
7 | * src/include/access/gin.h |
8 | *-------------------------------------------------------------------------- |
9 | */ |
10 | #ifndef GIN_H |
11 | #define GIN_H |
12 | |
13 | #include "access/xlogreader.h" |
14 | #include "lib/stringinfo.h" |
15 | #include "storage/block.h" |
16 | #include "utils/relcache.h" |
17 | |
18 | |
19 | /* |
20 | * amproc indexes for inverted indexes. |
21 | */ |
22 | #define GIN_COMPARE_PROC 1 |
23 | #define 2 |
24 | #define 3 |
25 | #define GIN_CONSISTENT_PROC 4 |
26 | #define GIN_COMPARE_PARTIAL_PROC 5 |
27 | #define GIN_TRICONSISTENT_PROC 6 |
28 | #define GINNProcs 6 |
29 | |
30 | /* |
31 | * searchMode settings for extractQueryFn. |
32 | */ |
33 | #define GIN_SEARCH_MODE_DEFAULT 0 |
34 | #define GIN_SEARCH_MODE_INCLUDE_EMPTY 1 |
35 | #define GIN_SEARCH_MODE_ALL 2 |
36 | #define GIN_SEARCH_MODE_EVERYTHING 3 /* for internal use only */ |
37 | |
38 | /* |
39 | * GinStatsData represents stats data for planner use |
40 | */ |
41 | typedef struct GinStatsData |
42 | { |
43 | BlockNumber nPendingPages; |
44 | BlockNumber nTotalPages; |
45 | BlockNumber nEntryPages; |
46 | BlockNumber nDataPages; |
47 | int64 nEntries; |
48 | int32 ginVersion; |
49 | } GinStatsData; |
50 | |
51 | /* |
52 | * A ternary value used by tri-consistent functions. |
53 | * |
54 | * This must be of the same size as a bool because some code will cast a |
55 | * pointer to a bool to a pointer to a GinTernaryValue. |
56 | */ |
57 | typedef char GinTernaryValue; |
58 | |
59 | #define GIN_FALSE 0 /* item is not present / does not match */ |
60 | #define GIN_TRUE 1 /* item is present / matches */ |
61 | #define GIN_MAYBE 2 /* don't know if item is present / don't know |
62 | * if matches */ |
63 | |
64 | #define DatumGetGinTernaryValue(X) ((GinTernaryValue)(X)) |
65 | #define GinTernaryValueGetDatum(X) ((Datum)(X)) |
66 | #define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x) |
67 | |
68 | /* GUC parameters */ |
69 | extern PGDLLIMPORT int GinFuzzySearchLimit; |
70 | extern int gin_pending_list_limit; |
71 | |
72 | /* ginutil.c */ |
73 | extern void ginGetStats(Relation index, GinStatsData *stats); |
74 | extern void ginUpdateStats(Relation index, const GinStatsData *stats, |
75 | bool is_build); |
76 | |
77 | #endif /* GIN_H */ |
78 | |