Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes16kdownloads
amapi.h293 linesDownload Raw Back to access
1/*-------------------------------------------------------------------------2 *3 * amapi.h4 *	  API for Postgres index access methods.5 *6 * Copyright (c) 2015-2023, PostgreSQL Global Development Group7 *8 * src/include/access/amapi.h9 *10 *-------------------------------------------------------------------------11 */12#ifndef AMAPI_H13#define AMAPI_H14 15#include "access/genam.h"16 17/*18 * We don't wish to include planner header files here, since most of an index19 * AM's implementation isn't concerned with those data structures.  To allow20 * declaring amcostestimate_function here, use forward struct references.21 */22struct PlannerInfo;23struct IndexPath;24 25/* Likewise, this file shouldn't depend on execnodes.h. */26struct IndexInfo;27 28 29/*30 * Properties for amproperty API.  This list covers properties known to the31 * core code, but an index AM can define its own properties, by matching the32 * string property name.33 */34typedef enum IndexAMProperty35{36	AMPROP_UNKNOWN = 0,			/* anything not known to core code */37	AMPROP_ASC,					/* column properties */38	AMPROP_DESC,39	AMPROP_NULLS_FIRST,40	AMPROP_NULLS_LAST,41	AMPROP_ORDERABLE,42	AMPROP_DISTANCE_ORDERABLE,43	AMPROP_RETURNABLE,44	AMPROP_SEARCH_ARRAY,45	AMPROP_SEARCH_NULLS,46	AMPROP_CLUSTERABLE,			/* index properties */47	AMPROP_INDEX_SCAN,48	AMPROP_BITMAP_SCAN,49	AMPROP_BACKWARD_SCAN,50	AMPROP_CAN_ORDER,			/* AM properties */51	AMPROP_CAN_UNIQUE,52	AMPROP_CAN_MULTI_COL,53	AMPROP_CAN_EXCLUDE,54	AMPROP_CAN_INCLUDE55} IndexAMProperty;56 57/*58 * We use lists of this struct type to keep track of both operators and59 * support functions while building or adding to an opclass or opfamily.60 * amadjustmembers functions receive lists of these structs, and are allowed61 * to alter their "ref" fields.62 *63 * The "ref" fields define how the pg_amop or pg_amproc entry should depend64 * on the associated objects (that is, which dependency type to use, and65 * which opclass or opfamily it should depend on).66 *67 * If ref_is_hard is true, the entry will have a NORMAL dependency on the68 * operator or support func, and an INTERNAL dependency on the opclass or69 * opfamily.  This forces the opclass or opfamily to be dropped if the70 * operator or support func is dropped, and requires the CASCADE option71 * to do so.  Nor will ALTER OPERATOR FAMILY DROP be allowed.  This is72 * the right behavior for objects that are essential to an opclass.73 *74 * If ref_is_hard is false, the entry will have an AUTO dependency on the75 * operator or support func, and also an AUTO dependency on the opclass or76 * opfamily.  This allows ALTER OPERATOR FAMILY DROP, and causes that to77 * happen automatically if the operator or support func is dropped.  This78 * is the right behavior for inessential ("loose") objects.79 */80typedef struct OpFamilyMember81{82	bool		is_func;		/* is this an operator, or support func? */83	Oid			object;			/* operator or support func's OID */84	int			number;			/* strategy or support func number */85	Oid			lefttype;		/* lefttype */86	Oid			righttype;		/* righttype */87	Oid			sortfamily;		/* ordering operator's sort opfamily, or 0 */88	bool		ref_is_hard;	/* hard or soft dependency? */89	bool		ref_is_family;	/* is dependency on opclass or opfamily? */90	Oid			refobjid;		/* OID of opclass or opfamily */91} OpFamilyMember;92 93 94/*95 * Callback function signatures --- see indexam.sgml for more info.96 */97 98/* build new index */99typedef IndexBuildResult *(*ambuild_function) (Relation heapRelation,100											   Relation indexRelation,101											   struct IndexInfo *indexInfo);102 103/* build empty index */104typedef void (*ambuildempty_function) (Relation indexRelation);105 106/* insert this tuple */107typedef bool (*aminsert_function) (Relation indexRelation,108								   Datum *values,109								   bool *isnull,110								   ItemPointer heap_tid,111								   Relation heapRelation,112								   IndexUniqueCheck checkUnique,113								   bool indexUnchanged,114								   struct IndexInfo *indexInfo);115 116/* bulk delete */117typedef IndexBulkDeleteResult *(*ambulkdelete_function) (IndexVacuumInfo *info,118														 IndexBulkDeleteResult *stats,119														 IndexBulkDeleteCallback callback,120														 void *callback_state);121 122/* post-VACUUM cleanup */123typedef IndexBulkDeleteResult *(*amvacuumcleanup_function) (IndexVacuumInfo *info,124															IndexBulkDeleteResult *stats);125 126/* can indexscan return IndexTuples? */127typedef bool (*amcanreturn_function) (Relation indexRelation, int attno);128 129/* estimate cost of an indexscan */130typedef void (*amcostestimate_function) (struct PlannerInfo *root,131										 struct IndexPath *path,132										 double loop_count,133										 Cost *indexStartupCost,134										 Cost *indexTotalCost,135										 Selectivity *indexSelectivity,136										 double *indexCorrelation,137										 double *indexPages);138 139/* parse index reloptions */140typedef bytea *(*amoptions_function) (Datum reloptions,141									  bool validate);142 143/* report AM, index, or index column property */144typedef bool (*amproperty_function) (Oid index_oid, int attno,145									 IndexAMProperty prop, const char *propname,146									 bool *res, bool *isnull);147 148/* name of phase as used in progress reporting */149typedef char *(*ambuildphasename_function) (int64 phasenum);150 151/* validate definition of an opclass for this AM */152typedef bool (*amvalidate_function) (Oid opclassoid);153 154/* validate operators and support functions to be added to an opclass/family */155typedef void (*amadjustmembers_function) (Oid opfamilyoid,156										  Oid opclassoid,157										  List *operators,158										  List *functions);159 160/* prepare for index scan */161typedef IndexScanDesc (*ambeginscan_function) (Relation indexRelation,162											   int nkeys,163											   int norderbys);164 165/* (re)start index scan */166typedef void (*amrescan_function) (IndexScanDesc scan,167								   ScanKey keys,168								   int nkeys,169								   ScanKey orderbys,170								   int norderbys);171 172/* next valid tuple */173typedef bool (*amgettuple_function) (IndexScanDesc scan,174									 ScanDirection direction);175 176/* fetch all valid tuples */177typedef int64 (*amgetbitmap_function) (IndexScanDesc scan,178									   TIDBitmap *tbm);179 180/* end index scan */181typedef void (*amendscan_function) (IndexScanDesc scan);182 183/* mark current scan position */184typedef void (*ammarkpos_function) (IndexScanDesc scan);185 186/* restore marked scan position */187typedef void (*amrestrpos_function) (IndexScanDesc scan);188 189/*190 * Callback function signatures - for parallel index scans.191 */192 193/* estimate size of parallel scan descriptor */194typedef Size (*amestimateparallelscan_function) (void);195 196/* prepare for parallel index scan */197typedef void (*aminitparallelscan_function) (void *target);198 199/* (re)start parallel index scan */200typedef void (*amparallelrescan_function) (IndexScanDesc scan);201 202/*203 * API struct for an index AM.  Note this must be stored in a single palloc'd204 * chunk of memory.205 */206typedef struct IndexAmRoutine207{208	NodeTag		type;209 210	/*211	 * Total number of strategies (operators) by which we can traverse/search212	 * this AM.  Zero if AM does not have a fixed set of strategy assignments.213	 */214	uint16		amstrategies;215	/* total number of support functions that this AM uses */216	uint16		amsupport;217	/* opclass options support function number or 0 */218	uint16		amoptsprocnum;219	/* does AM support ORDER BY indexed column's value? */220	bool		amcanorder;221	/* does AM support ORDER BY result of an operator on indexed column? */222	bool		amcanorderbyop;223	/* does AM support backward scanning? */224	bool		amcanbackward;225	/* does AM support UNIQUE indexes? */226	bool		amcanunique;227	/* does AM support multi-column indexes? */228	bool		amcanmulticol;229	/* does AM require scans to have a constraint on the first index column? */230	bool		amoptionalkey;231	/* does AM handle ScalarArrayOpExpr quals? */232	bool		amsearcharray;233	/* does AM handle IS NULL/IS NOT NULL quals? */234	bool		amsearchnulls;235	/* can index storage data type differ from column data type? */236	bool		amstorage;237	/* can an index of this type be clustered on? */238	bool		amclusterable;239	/* does AM handle predicate locks? */240	bool		ampredlocks;241	/* does AM support parallel scan? */242	bool		amcanparallel;243	/* does AM support columns included with clause INCLUDE? */244	bool		amcaninclude;245	/* does AM use maintenance_work_mem? */246	bool		amusemaintenanceworkmem;247	/* does AM store tuple information only at block granularity? */248	bool		amsummarizing;249	/* OR of parallel vacuum flags.  See vacuum.h for flags. */250	uint8		amparallelvacuumoptions;251	/* type of data stored in index, or InvalidOid if variable */252	Oid			amkeytype;253 254	/*255	 * If you add new properties to either the above or the below lists, then256	 * they should also (usually) be exposed via the property API (see257	 * IndexAMProperty at the top of the file, and utils/adt/amutils.c).258	 */259 260	/* interface functions */261	ambuild_function ambuild;262	ambuildempty_function ambuildempty;263	aminsert_function aminsert;264	ambulkdelete_function ambulkdelete;265	amvacuumcleanup_function amvacuumcleanup;266	amcanreturn_function amcanreturn;	/* can be NULL */267	amcostestimate_function amcostestimate;268	amoptions_function amoptions;269	amproperty_function amproperty; /* can be NULL */270	ambuildphasename_function ambuildphasename; /* can be NULL */271	amvalidate_function amvalidate;272	amadjustmembers_function amadjustmembers;	/* can be NULL */273	ambeginscan_function ambeginscan;274	amrescan_function amrescan;275	amgettuple_function amgettuple; /* can be NULL */276	amgetbitmap_function amgetbitmap;	/* can be NULL */277	amendscan_function amendscan;278	ammarkpos_function ammarkpos;	/* can be NULL */279	amrestrpos_function amrestrpos; /* can be NULL */280 281	/* interface functions to support parallel index scans */282	amestimateparallelscan_function amestimateparallelscan; /* can be NULL */283	aminitparallelscan_function aminitparallelscan; /* can be NULL */284	amparallelrescan_function amparallelrescan; /* can be NULL */285} IndexAmRoutine;286 287 288/* Functions in access/index/amapi.c */289extern IndexAmRoutine *GetIndexAmRoutine(Oid amhandler);290extern IndexAmRoutine *GetIndexAmRoutineByAmId(Oid amoid, bool noerror);291 292#endif							/* AMAPI_H */293 
codekingpro/portable-devtools · Team Ai