Line data Source code
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 : */ 55 : typedef struct GinStatsData 56 : { 57 : BlockNumber nPendingPages; 58 : BlockNumber nTotalPages; 59 : BlockNumber nEntryPages; 60 : BlockNumber nDataPages; 61 : int64 nEntries; 62 : int32 ginVersion; 63 : } GinStatsData; 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 : */ 71 : typedef char GinTernaryValue; 72 : 73 : StaticAssertDecl(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 : 81 : static inline GinTernaryValue 82 968842 : DatumGetGinTernaryValue(Datum X) 83 : { 84 968842 : return (GinTernaryValue) X; 85 : } 86 : 87 : static inline Datum 88 968842 : GinTernaryValueGetDatum(GinTernaryValue X) 89 : { 90 968842 : return (Datum) X; 91 : } 92 : 93 : #define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x) 94 : 95 : /* GUC parameters */ 96 : extern PGDLLIMPORT int GinFuzzySearchLimit; 97 : extern PGDLLIMPORT int gin_pending_list_limit; 98 : 99 : /* ginutil.c */ 100 : extern void ginGetStats(Relation index, GinStatsData *stats); 101 : extern void ginUpdateStats(Relation index, const GinStatsData *stats, 102 : bool is_build); 103 : 104 : extern void _gin_parallel_build_main(dsm_segment *seg, shm_toc *toc); 105 : 106 : #endif /* GIN_H */