mirror of
https://github.com/postgres/postgres.git
synced 2026-02-13 15:53:13 -05:00
Because we added StaticAssertStmt() first before StaticAssertDecl(), some uses as well as the instructions in c.h are now a bit backwards from the "native" way static assertions are meant to be used in C. This updates the guidance and moves some static assertions to better places. Specifically, since the addition of StaticAssertDecl(), we can put static assertions at the file level. This moves a number of static assertions out of function bodies, where they might have been stuck out of necessity, to perhaps better places at the file level or in header files. Also, when the static assertion appears in a position where a declaration is allowed, then using StaticAssertDecl() is more native than StaticAssertStmt(). Reviewed-by: John Naylor <john.naylor@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/941a04e7-dd6f-c0e4-8cdf-a33b3338cbda%40enterprisedb.com
91 lines
2.3 KiB
C
91 lines
2.3 KiB
C
/*--------------------------------------------------------------------------
|
|
* gin.h
|
|
* Public header file for Generalized Inverted Index access method.
|
|
*
|
|
* Copyright (c) 2006-2022, 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;
|
|
|
|
StaticAssertDecl(sizeof(GinTernaryValue) == sizeof(bool),
|
|
"sizes of GinTernaryValue and bool are not equal");
|
|
|
|
#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 */
|
|
|
|
static inline GinTernaryValue
|
|
DatumGetGinTernaryValue(Datum X)
|
|
{
|
|
return (GinTernaryValue) X;
|
|
}
|
|
|
|
static inline Datum
|
|
GinTernaryValueGetDatum(GinTernaryValue X)
|
|
{
|
|
return (Datum) X;
|
|
}
|
|
|
|
#define PG_RETURN_GIN_TERNARY_VALUE(x) return GinTernaryValueGetDatum(x)
|
|
|
|
/* GUC parameters */
|
|
extern PGDLLIMPORT int GinFuzzySearchLimit;
|
|
extern PGDLLIMPORT 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 */
|