1/*-------------------------------------------------------------------------
4 * Index AM template main file.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/test/modules/dummy_index_am/dummy_index_am.c
12 *-------------------------------------------------------------------------
24/* parse table for fillRelOptions */
27/* Kind of relation options for dummy index */
36/* Dummy index options */
52 {(
const char *) NULL}
/* list terminator */
55/* Handler for index AM */
59 * Validation function for string relation options.
65 (
errmsg(
"new option value for string parameter %s",
70 * This function creates a full set of relation option types,
71 * with various patterns.
79 "Integer option for dummy_index_am",
86 "Real option for dummy_index_am",
93 "Boolean option for dummy_index_am",
100 "Enum option for dummy_index_am",
103 "Valid values are \"one\" and \"two\".",
110 "String option for dummy_index_am with non-NULL default",
116 option_string_val_offset);
119 * String option for dummy_index_am with NULL default, and without
123 NULL,
/* description */
129 option_string_null_offset);
143 /* let's pretend that no tuples were scanned */
145 /* and no index tuples were created (that is true) */
152 * Build an empty index for the initialization fork.
157 /* No need to build an init fork for a dummy index */
161 * Insert new tuple to index AM.
175 * Bulk deletion of all index entries pointing to a set of table tuples.
182 * There is nothing to delete. Return NULL as there is nothing to pass to
189 * Post-VACUUM cleanup for index AM.
194 /* Index has not been modified, so returning NULL is fine */
199 * Estimate cost of index AM.
203 Cost *indexStartupCost,
Cost *indexTotalCost,
204 Selectivity *indexSelectivity,
double *indexCorrelation,
207 /* Tell planner to never use this index! */
208 *indexStartupCost = 1.0e10;
209 *indexTotalCost = 1.0e10;
211 /* Do not care about the rest */
212 *indexSelectivity = 1;
213 *indexCorrelation = 0;
218 * Parse relation options for index AM, returning a DummyIndexOptions
219 * structure filled with option values.
231 * Validator for index AM.
236 /* Index is dummy so we are happy with any opclass */
241 * Begin scan of index AM.
248 /* Let's pretend we are doing something */
254 * Rescan of index AM.
258 ScanKey orderbys,
int norderbys)
264 * End scan of index AM.
273 * Index AM handler function: returns IndexAmRoutine with access method
274 * parameters and callbacks.
static bool validate(Port *port, const char *auth)
static Datum values[MAXATTR]
static bool divalidate(Oid opclassoid)
static void validate_string_option(const char *value)
static void diendscan(IndexScanDesc scan)
static void dibuildempty(Relation index)
static IndexBuildResult * dibuild(Relation heap, Relation index, IndexInfo *indexInfo)
static relopt_enum_elt_def dummyAmEnumValues[]
PG_FUNCTION_INFO_V1(dihandler)
static void create_reloptions_table(void)
static bytea * dioptions(Datum reloptions, bool validate)
static IndexBulkDeleteResult * dibulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
static IndexScanDesc dibeginscan(Relation r, int nkeys, int norderbys)
static bool diinsert(Relation index, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)
static void direscan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
static IndexBulkDeleteResult * divacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
struct DummyIndexOptions DummyIndexOptions
static void dicostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
static relopt_parse_elt di_relopt_tab[6]
Datum dihandler(PG_FUNCTION_ARGS)
static relopt_kind di_relopt_kind
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_RETURN_POINTER(x)
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
#define AccessExclusiveLock
void add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
void add_string_reloption(bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, LOCKMODE lockmode)
void add_enum_reloption(bits32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
void add_real_reloption(bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
void add_bool_reloption(bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
relopt_kind add_reloption_kind(void)
int option_string_val_offset
int option_string_null_offset
ambuildphasename_function ambuildphasename
ambuildempty_function ambuildempty
amvacuumcleanup_function amvacuumcleanup
amoptions_function amoptions
amestimateparallelscan_function amestimateparallelscan
amrestrpos_function amrestrpos
aminsert_function aminsert
amendscan_function amendscan
amparallelrescan_function amparallelrescan
bool amconsistentordering
amcostestimate_function amcostestimate
amgettuple_function amgettuple
amcanreturn_function amcanreturn
amgetbitmap_function amgetbitmap
amproperty_function amproperty
ambulkdelete_function ambulkdelete
amvalidate_function amvalidate
ammarkpos_function ammarkpos
bool amusemaintenanceworkmem
ambeginscan_function ambeginscan
amrescan_function amrescan
aminitparallelscan_function aminitparallelscan
uint8 amparallelvacuumoptions
amgettreeheight_function amgettreeheight
bool amconsistentequality
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
#define VACUUM_OPTION_NO_PARALLEL