mirror of
https://github.com/postgres/postgres.git
synced 2026-03-17 08:03:01 -04:00
PostgreSQL provides set of template index access methods, where opclasses have much freedom in the semantics of indexing. These index AMs are GiST, GIN, SP-GiST and BRIN. There opclasses define representation of keys, operations on them and supported search strategies. So, it's natural that opclasses may be faced some tradeoffs, which require user-side decision. This commit implements opclass parameters allowing users to set some values, which tell opclass how to index the particular dataset. This commit doesn't introduce new storage in system catalog. Instead it uses pg_attribute.attoptions, which is used for table column storage options but unused for index attributes. In order to evade changing signature of each opclass support function, we implement unified way to pass options to opclass support functions. Options are set to fn_expr as the constant bytea expression. It's possible due to the fact that opclass support functions are executed outside of expressions, so fn_expr is unused for them. This commit comes with some examples of opclass options usage. We parametrize signature length in GiST. That applies to multiple opclasses: tsvector_ops, gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and gist_hstore_ops. Also we parametrize maximum number of integer ranges for gist__int_ops. However, the main future usage of this feature is expected to be json, where users would be able to specify which way to index particular json parts. Catversion is bumped. Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru Author: Nikita Glukhov, revised by me Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
78 lines
2.1 KiB
C
78 lines
2.1 KiB
C
/*--------------------------------------------------------------------------
|
|
* gin.h
|
|
* Public header file for Generalized Inverted Index access method.
|
|
*
|
|
* Copyright (c) 2006-2020, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/access/gin.h
|
|
*--------------------------------------------------------------------------
|
|
*/
|
|
#ifndef GIN_H
|
|
#define GIN_H
|
|
|
|
#include "access/xlogreader.h"
|
|
#include "lib/stringinfo.h"
|
|
#include "storage/block.h"
|
|
#include "utils/relcache.h"
|
|
|
|
|
|
/*
|
|
* amproc indexes for inverted indexes.
|
|
*/
|
|
#define GIN_COMPARE_PROC 1
|
|
#define GIN_EXTRACTVALUE_PROC 2
|
|
#define GIN_EXTRACTQUERY_PROC 3
|
|
#define GIN_CONSISTENT_PROC 4
|
|
#define GIN_COMPARE_PARTIAL_PROC 5
|
|
#define GIN_TRICONSISTENT_PROC 6
|
|
#define GIN_OPTIONS_PROC 7
|
|
#define GINNProcs 7
|
|
|
|
/*
|
|
* searchMode settings for extractQueryFn.
|
|
*/
|
|
#define GIN_SEARCH_MODE_DEFAULT 0
|
|
#define GIN_SEARCH_MODE_INCLUDE_EMPTY 1
|
|
#define GIN_SEARCH_MODE_ALL 2
|
|
#define GIN_SEARCH_MODE_EVERYTHING 3 /* for internal use only */
|
|
|
|
/*
|
|
* GinStatsData represents stats data for planner use
|
|
*/
|
|
typedef struct GinStatsData
|
|
{
|
|
BlockNumber nPendingPages;
|
|
BlockNumber nTotalPages;
|
|
BlockNumber nEntryPages;
|
|
BlockNumber nDataPages;
|
|
int64 nEntries;
|
|
int32 ginVersion;
|
|
} GinStatsData;
|
|
|
|
/*
|
|
* A ternary value used by tri-consistent functions.
|
|
*
|
|
* This must be of the same size as a bool because some code will cast a
|
|
* pointer to a bool to a pointer to a GinTernaryValue.
|
|
*/
|
|
typedef char GinTernaryValue;
|
|
|
|
#define GIN_FALSE 0 /* item is not present / does not match */
|
|
#define GIN_TRUE 1 /* item is present / matches */
|
|
#define GIN_MAYBE 2 /* don't know if item is present / don't know
|
|
* if matches */
|
|
|
|
#define DatumGetGinTernaryValue(X) ((GinTernaryValue)(X))
|
|
#define GinTernaryValueGetDatum(X) ((Datum)(X))
|
|
#define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
|
|
|
|
/* GUC parameters */
|
|
extern PGDLLIMPORT int GinFuzzySearchLimit;
|
|
extern int gin_pending_list_limit;
|
|
|
|
/* ginutil.c */
|
|
extern void ginGetStats(Relation index, GinStatsData *stats);
|
|
extern void ginUpdateStats(Relation index, const GinStatsData *stats,
|
|
bool is_build);
|
|
|
|
#endif /* GIN_H */
|