#ifndef AMAPI_H
#define AMAPI_H
#include "access/genam.h"
struct PlannerInfo;
struct IndexPath;
struct IndexInfo;
typedef enum IndexAMProperty
{
AMPROP_UNKNOWN = 0,
AMPROP_ASC,
AMPROP_DESC,
AMPROP_NULLS_FIRST,
AMPROP_NULLS_LAST,
AMPROP_ORDERABLE,
AMPROP_DISTANCE_ORDERABLE,
AMPROP_RETURNABLE,
AMPROP_SEARCH_ARRAY,
AMPROP_SEARCH_NULLS,
AMPROP_CLUSTERABLE,
AMPROP_INDEX_SCAN,
AMPROP_BITMAP_SCAN,
AMPROP_BACKWARD_SCAN,
AMPROP_CAN_ORDER,
AMPROP_CAN_UNIQUE,
AMPROP_CAN_MULTI_COL,
AMPROP_CAN_EXCLUDE,
AMPROP_CAN_INCLUDE,
} IndexAMProperty;
typedef struct OpFamilyMember
{
bool is_func;
Oid object;
int number;
Oid lefttype;
Oid righttype;
Oid sortfamily;
bool ref_is_hard;
bool ref_is_family;
Oid refobjid;
} OpFamilyMember;
typedef IndexBuildResult *(*ambuild_function) (Relation heapRelation,
Relation indexRelation,
struct IndexInfo *indexInfo);
typedef void (*ambuildempty_function) (Relation indexRelation);
typedef bool (*aminsert_function) (Relation indexRelation,
Datum *values,
bool *isnull,
ItemPointer heap_tid,
Relation heapRelation,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
struct IndexInfo *indexInfo);
typedef void (*aminsertcleanup_function) (Relation indexRelation,
struct IndexInfo *indexInfo);
typedef IndexBulkDeleteResult *(*ambulkdelete_function) (IndexVacuumInfo *info,
IndexBulkDeleteResult *stats,
IndexBulkDeleteCallback callback,
void *callback_state);
typedef IndexBulkDeleteResult *(*amvacuumcleanup_function) (IndexVacuumInfo *info,
IndexBulkDeleteResult *stats);
typedef bool (*amcanreturn_function) (Relation indexRelation, int attno);
typedef void (*amcostestimate_function) (struct PlannerInfo *root,
struct IndexPath *path,
double loop_count,
Cost *indexStartupCost,
Cost *indexTotalCost,
Selectivity *indexSelectivity,
double *indexCorrelation,
double *indexPages);
typedef bytea *(*amoptions_function) (Datum reloptions,
bool validate);
typedef bool (*amproperty_function) (Oid index_oid, int attno,
IndexAMProperty prop, const char *propname,
bool *res, bool *isnull);
typedef char *(*ambuildphasename_function) (int64 phasenum);
typedef bool (*amvalidate_function) (Oid opclassoid);
typedef void (*amadjustmembers_function) (Oid opfamilyoid,
Oid opclassoid,
List *operators,
List *functions);
typedef IndexScanDesc (*ambeginscan_function) (Relation indexRelation,
int nkeys,
int norderbys);
typedef void (*amrescan_function) (IndexScanDesc scan,
ScanKey keys,
int nkeys,
ScanKey orderbys,
int norderbys);
typedef bool (*amgettuple_function) (IndexScanDesc scan,
ScanDirection direction);
typedef int64 (*amgetbitmap_function) (IndexScanDesc scan,
TIDBitmap *tbm);
typedef void (*amendscan_function) (IndexScanDesc scan);
typedef void (*ammarkpos_function) (IndexScanDesc scan);
typedef void (*amrestrpos_function) (IndexScanDesc scan);
typedef Size (*amestimateparallelscan_function) (int nkeys, int norderbys);
typedef void (*aminitparallelscan_function) (void *target);
typedef void (*amparallelrescan_function) (IndexScanDesc scan);
typedef struct IndexAmRoutine
{
NodeTag type;
uint16 amstrategies;
uint16 amsupport;
uint16 amoptsprocnum;
bool amcanorder;
bool amcanorderbyop;
bool amcanbackward;
bool amcanunique;
bool amcanmulticol;
bool amoptionalkey;
bool amsearcharray;
bool amsearchnulls;
bool amstorage;
bool amclusterable;
bool ampredlocks;
bool amcanparallel;
bool amcanbuildparallel;
bool amcaninclude;
bool amusemaintenanceworkmem;
bool amsummarizing;
uint8 amparallelvacuumoptions;
Oid amkeytype;
ambuild_function ambuild;
ambuildempty_function ambuildempty;
aminsert_function aminsert;
aminsertcleanup_function aminsertcleanup;
ambulkdelete_function ambulkdelete;
amvacuumcleanup_function amvacuumcleanup;
amcanreturn_function amcanreturn;
amcostestimate_function amcostestimate;
amoptions_function amoptions;
amproperty_function amproperty;
ambuildphasename_function ambuildphasename;
amvalidate_function amvalidate;
amadjustmembers_function amadjustmembers;
ambeginscan_function ambeginscan;
amrescan_function amrescan;
amgettuple_function amgettuple;
amgetbitmap_function amgetbitmap;
amendscan_function amendscan;
ammarkpos_function ammarkpos;
amrestrpos_function amrestrpos;
amestimateparallelscan_function amestimateparallelscan;
aminitparallelscan_function aminitparallelscan;
amparallelrescan_function amparallelrescan;
} IndexAmRoutine;
extern IndexAmRoutine *GetIndexAmRoutine(Oid amhandler);
extern IndexAmRoutine *GetIndexAmRoutineByAmId(Oid amoid, bool noerror);
#endif