PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gin.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------
2 * gin.h
3 * Public header file for Generalized Inverted Index access method.
4 *
5 * Copyright (c) 2006-2025, 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 "nodes/execnodes.h"
16#include "storage/shm_toc.h"
17#include "storage/block.h"
18#include "utils/relcache.h"
19
20
21/*
22 * amproc indexes for inverted indexes.
23 */
24#define GIN_COMPARE_PROC 1
25#define GIN_EXTRACTVALUE_PROC 2
26#define GIN_EXTRACTQUERY_PROC 3
27#define GIN_CONSISTENT_PROC 4
28#define GIN_COMPARE_PARTIAL_PROC 5
29#define GIN_TRICONSISTENT_PROC 6
30#define GIN_OPTIONS_PROC 7
31#define GINNProcs 7
32
33/*
34 * searchMode settings for extractQueryFn.
35 */
36#define GIN_SEARCH_MODE_DEFAULT 0
37#define GIN_SEARCH_MODE_INCLUDE_EMPTY 1
38#define GIN_SEARCH_MODE_ALL 2
39#define GIN_SEARCH_MODE_EVERYTHING 3 /* for internal use only */
40
41/*
42 * Constant definition for progress reporting. Phase numbers must match
43 * ginbuildphasename.
44 */
45/* PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE is 1 (see progress.h) */
46#define PROGRESS_GIN_PHASE_INDEXBUILD_TABLESCAN 2
47#define PROGRESS_GIN_PHASE_PERFORMSORT_1 3
48#define PROGRESS_GIN_PHASE_MERGE_1 4
49#define PROGRESS_GIN_PHASE_PERFORMSORT_2 5
50#define PROGRESS_GIN_PHASE_MERGE_2 6
51
52/*
53 * GinStatsData represents stats data for planner use
54 */
55typedef struct GinStatsData
56{
64
65/*
66 * A ternary value used by tri-consistent functions.
67 *
68 * This must be of the same size as a bool because some code will cast a
69 * pointer to a bool to a pointer to a GinTernaryValue.
70 */
71typedef char GinTernaryValue;
72
73StaticAssertDecl(sizeof(GinTernaryValue) == sizeof(bool),
74 "sizes of GinTernaryValue and bool are not equal");
75
76#define GIN_FALSE 0 /* item is not present / does not match */
77#define GIN_TRUE 1 /* item is present / matches */
78#define GIN_MAYBE 2 /* don't know if item is present / don't know
79 * if matches */
80
81static inline GinTernaryValue
83{
84 return (GinTernaryValue) X;
85}
86
87static inline Datum
89{
90 return (Datum) X;
91}
93#define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
94
95/* GUC parameters */
98
99/* ginutil.c */
100extern void ginGetStats(Relation index, GinStatsData *stats);
101extern void ginUpdateStats(Relation index, const GinStatsData *stats,
102 bool is_build);
103
104extern void _gin_parallel_build_main(dsm_segment *seg, shm_toc *toc);
105
106#endif /* GIN_H */
uint32 BlockNumber
Definition: block.h:31
#define PGDLLIMPORT
Definition: c.h:1291
int64_t int64
Definition: c.h:499
int32_t int32
Definition: c.h:498
void ginGetStats(Relation index, GinStatsData *stats)
Definition: ginutil.c:628
static Datum GinTernaryValueGetDatum(GinTernaryValue X)
Definition: gin.h:87
static GinTernaryValue DatumGetGinTernaryValue(Datum X)
Definition: gin.h:81
char GinTernaryValue
Definition: gin.h:71
PGDLLIMPORT int gin_pending_list_limit
Definition: ginfast.c:39
void _gin_parallel_build_main(dsm_segment *seg, shm_toc *toc)
Definition: gininsert.c:2060
StaticAssertDecl(sizeof(GinTernaryValue)==sizeof(bool), "sizes of GinTernaryValue and bool are not equal")
PGDLLIMPORT int GinFuzzySearchLimit
Definition: ginget.c:27
void ginUpdateStats(Relation index, const GinStatsData *stats, bool is_build)
Definition: ginutil.c:655
struct GinStatsData GinStatsData
uintptr_t Datum
Definition: postgres.h:69
BlockNumber nDataPages
Definition: gin.h:60
BlockNumber nPendingPages
Definition: gin.h:57
BlockNumber nEntryPages
Definition: gin.h:59
int64 nEntries
Definition: gin.h:61
BlockNumber nTotalPages
Definition: gin.h:58
int32 ginVersion
Definition: gin.h:62
Definition: type.h:96