PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/gist_private.h"
#include "access/htup_details.h"
#include "access/reloptions.h"
#include "common/pg_prng.h"
#include "storage/indexfsm.h"
#include "utils/float.h"
#include "utils/fmgrprotos.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Functions | |
void | gistfillbuffer (Page page, IndexTuple *itup, int len, OffsetNumber off) |
bool | gistnospace (Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace) |
bool | gistfitpage (IndexTuple *itvec, int len) |
IndexTuple * | gistextractpage (Page page, int *len) |
IndexTuple * | gistjoinvector (IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen) |
IndexTupleData * | gistfillitupvec (IndexTuple *vec, int veclen, int *memlen) |
void | gistMakeUnionItVec (GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull) |
IndexTuple | gistunion (Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate) |
void | gistMakeUnionKey (GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull) |
bool | gistKeyIsEQ (GISTSTATE *giststate, int attno, Datum a, Datum b) |
void | gistDeCompressAtt (GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull) |
IndexTuple | gistgetadjusted (Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate) |
OffsetNumber | gistchoose (Relation r, Page p, IndexTuple it, GISTSTATE *giststate) |
void | gistdentryinit (GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull) |
IndexTuple | gistFormTuple (GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf) |
void | gistCompressValues (GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt) |
static Datum | gistFetchAtt (GISTSTATE *giststate, int nkey, Datum k, Relation r) |
HeapTuple | gistFetchTuple (GISTSTATE *giststate, Relation r, IndexTuple tuple) |
float | gistpenalty (GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd) |
void | gistinitpage (Page page, uint32 f) |
void | GISTInitBuffer (Buffer b, uint32 f) |
void | gistcheckpage (Relation rel, Buffer buf) |
Buffer | gistNewBuffer (Relation r, Relation heaprel) |
bool | gistPageRecyclable (Page page) |
bytea * | gistoptions (Datum reloptions, bool validate) |
bool | gistproperty (Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull) |
XLogRecPtr | gistGetFakeLSN (Relation rel) |
Datum | gist_stratnum_identity (PG_FUNCTION_ARGS) |
StrategyNumber | GistTranslateStratnum (Oid opclass, StrategyNumber strat) |
Datum gist_stratnum_identity | ( | PG_FUNCTION_ARGS | ) |
Definition at line 785 of file gistutil.c.
References buf, BufferGetBlockNumber(), BufferGetPage(), ereport, errcode(), errhint(), errmsg(), ERROR, MAXALIGN, PageGetSpecialSize(), PageIsNew(), and RelationGetRelationName.
Referenced by gistBufferingFindCorrectParent(), gistdoinsert(), gistFindCorrectParent(), gistFindPath(), gistkillitems(), gistNewBuffer(), gistScanPage(), gistvacuum_delete_empty_pages(), and pgstat_gist_page().
OffsetNumber gistchoose | ( | Relation | r, |
Page | p, | ||
IndexTuple | it, | ||
GISTSTATE * | giststate | ||
) |
Definition at line 374 of file gistutil.c.
References Assert, FirstOffsetNumber, gistDeCompressAtt(), gistdentryinit(), GistPageIsLeaf, gistpenalty(), i, index_getattr(), INDEX_MAX_KEYS, IndexRelationGetNumberOfKeyAttributes, j, GISTSTATE::leafTupdesc, OffsetNumberNext, PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), pg_global_prng_state, and pg_prng_bool().
Referenced by gistdoinsert(), and gistProcessItup().
void gistCompressValues | ( | GISTSTATE * | giststate, |
Relation | r, | ||
const Datum * | attdata, | ||
const bool * | isnull, | ||
bool | isleaf, | ||
Datum * | compatt | ||
) |
Definition at line 596 of file gistutil.c.
References GISTSTATE::compressFn, DatumGetPointer(), FmgrInfo::fn_oid, FunctionCall1Coll(), gistentryinit, i, IndexRelationGetNumberOfKeyAttributes, GISTENTRY::key, TupleDescData::natts, OidIsValid, PointerGetDatum(), RelationData::rd_att, and GISTSTATE::supportCollation.
Referenced by gistFormTuple(), and gistSortedBuildCallback().
void gistDeCompressAtt | ( | GISTSTATE * | giststate, |
Relation | r, | ||
IndexTuple | tuple, | ||
Page | p, | ||
OffsetNumber | o, | ||
GISTENTRY * | attdata, | ||
bool * | isnull | ||
) |
Definition at line 296 of file gistutil.c.
References gistdentryinit(), i, index_getattr(), IndexRelationGetNumberOfKeyAttributes, and GISTSTATE::leafTupdesc.
Referenced by gistchoose(), gistgetadjusted(), gistRelocateBuildBuffersOnSplit(), and placeOne().
void gistdentryinit | ( | GISTSTATE * | giststate, |
int | nkey, | ||
GISTENTRY * | e, | ||
Datum | k, | ||
Relation | r, | ||
Page | pg, | ||
OffsetNumber | o, | ||
bool | l, | ||
bool | isNull | ||
) |
Definition at line 547 of file gistutil.c.
References DatumGetPointer(), GISTSTATE::decompressFn, FmgrInfo::fn_oid, FunctionCall1Coll(), gistentryinit, GISTENTRY::key, GISTENTRY::leafkey, GISTENTRY::offset, OidIsValid, GISTENTRY::page, PointerGetDatum(), GISTENTRY::rel, and GISTSTATE::supportCollation.
Referenced by gistchoose(), gistDeCompressAtt(), gistindex_keytest(), gistMakeUnionItVec(), and gistSplitByKey().
IndexTuple* gistextractpage | ( | Page | page, |
int * | len | ||
) |
Definition at line 95 of file gistutil.c.
References FirstOffsetNumber, i, len, OffsetNumberNext, PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), and palloc().
Referenced by gist_indexsortbuild_levelstate_flush(), and gistplacetopage().
Definition at line 646 of file gistutil.c.
References DatumGetPointer(), GISTSTATE::fetchFn, FunctionCall1Coll(), gistentryinit, GISTENTRY::key, PointerGetDatum(), and GISTSTATE::supportCollation.
Referenced by gistFetchTuple().
HeapTuple gistFetchTuple | ( | GISTSTATE * | giststate, |
Relation | r, | ||
IndexTuple | tuple | ||
) |
Definition at line 667 of file gistutil.c.
References GISTSTATE::compressFn, fetchatt, GISTSTATE::fetchFn, GISTSTATE::fetchTupdesc, FmgrInfo::fn_oid, gistFetchAtt(), heap_form_tuple(), i, index_getattr(), INDEX_MAX_KEYS, IndexRelationGetNumberOfKeyAttributes, InvalidOid, GISTSTATE::leafTupdesc, MemoryContextSwitchTo(), TupleDescData::natts, RelationData::rd_att, and GISTSTATE::tempCxt.
Referenced by gistScanPage().
void gistfillbuffer | ( | Page | page, |
IndexTuple * | itup, | ||
int | len, | ||
OffsetNumber | off | ||
) |
Definition at line 34 of file gistutil.c.
References elog, ERROR, FirstOffsetNumber, i, IndexTupleSize, InvalidOffsetNumber, len, OffsetNumberNext, PageAddItem, PageGetMaxOffsetNumber(), and PageIsEmpty().
Referenced by gist_indexsortbuild_levelstate_add(), gistplacetopage(), and gistRedoPageSplitRecord().
IndexTupleData* gistfillitupvec | ( | IndexTuple * | vec, |
int | veclen, | ||
int * | memlen | ||
) |
Definition at line 127 of file gistutil.c.
References i, IndexTupleSize, and palloc().
Referenced by gist_indexsortbuild_levelstate_flush(), gistplacetopage(), and gistSplit().
bool gistfitpage | ( | IndexTuple * | itvec, |
int | len | ||
) |
Definition at line 79 of file gistutil.c.
References GiSTPageSize, i, IndexTupleSize, len, and size.
Referenced by gistSplit().
IndexTuple gistFormTuple | ( | GISTSTATE * | giststate, |
Relation | r, | ||
const Datum * | attdata, | ||
const bool * | isnull, | ||
bool | isleaf | ||
) |
Definition at line 575 of file gistutil.c.
References gistCompressValues(), index_form_tuple(), INDEX_MAX_KEYS, ItemPointerSetOffsetNumber(), GISTSTATE::leafTupdesc, GISTSTATE::nonLeafTupdesc, and res.
Referenced by gistBuildCallback(), gistgetadjusted(), gistinsert(), gistSplit(), and gistunion().
IndexTuple gistgetadjusted | ( | Relation | r, |
IndexTuple | oldtup, | ||
IndexTuple | addtup, | ||
GISTSTATE * | giststate | ||
) |
Definition at line 316 of file gistutil.c.
References gistDeCompressAtt(), gistFormTuple(), gistKeyIsEQ(), gistMakeUnionKey(), i, INDEX_MAX_KEYS, IndexRelationGetNumberOfKeyAttributes, sort-test::key, and IndexTupleData::t_tid.
Referenced by gistdoinsert(), gistformdownlink(), gistProcessItup(), and gistRelocateBuildBuffersOnSplit().
XLogRecPtr gistGetFakeLSN | ( | Relation | rel | ) |
Definition at line 1016 of file gistutil.c.
References Assert, FirstNormalUnloggedLSN, GetFakeLSNForUnloggedRel(), GetXLogInsertRecPtr(), gistXLogAssignLSN(), InvalidXLogRecPtr, RelationData::rd_rel, RelationIsPermanent, RelationNeedsWAL, and XLogRecPtrIsInvalid.
Referenced by gistdeletepage(), gistplacetopage(), gistprunepage(), gistvacuumpage(), and gistvacuumscan().
Definition at line 773 of file gistutil.c.
References b, BufferGetPage(), and gistinitpage().
Referenced by gistbuild(), gistbuildempty(), gistplacetopage(), and gistRedoPageSplitRecord().
Definition at line 757 of file gistutil.c.
References GISTPageOpaqueData::flags, GISTPageOpaqueData::gist_page_id, GIST_PAGE_ID, GistPageGetOpaque, InvalidBlockNumber, PageInit(), and GISTPageOpaqueData::rightlink.
Referenced by gist_indexsortbuild(), gist_indexsortbuild_levelstate_add(), gist_indexsortbuild_levelstate_flush(), and GISTInitBuffer().
IndexTuple* gistjoinvector | ( | IndexTuple * | itvec, |
int * | len, | ||
IndexTuple * | additvec, | ||
int | addlen | ||
) |
Definition at line 114 of file gistutil.c.
References len, and repalloc().
Referenced by gist_indexsortbuild_levelstate_flush(), and gistplacetopage().
Definition at line 281 of file gistutil.c.
References a, b, GISTSTATE::equalFn, FunctionCall3Coll(), PointerGetDatum(), and GISTSTATE::supportCollation.
Referenced by gistgetadjusted(), and gistUserPicksplit().
void gistMakeUnionItVec | ( | GISTSTATE * | giststate, |
IndexTuple * | itvec, | ||
int | len, | ||
Datum * | attr, | ||
bool * | isnull | ||
) |
Definition at line 155 of file gistutil.c.
References FunctionCall2Coll(), GEVHDRSZ, gistdentryinit(), i, index_getattr(), j, GISTSTATE::leafTupdesc, len, GistEntryVector::n, TupleDescData::natts, GISTSTATE::nonLeafTupdesc, palloc(), PointerGetDatum(), GISTSTATE::supportCollation, GISTSTATE::unionFn, and GistEntryVector::vector.
Referenced by gistunion(), and gistunionsubkeyvec().
void gistMakeUnionKey | ( | GISTSTATE * | giststate, |
int | attno, | ||
GISTENTRY * | entry1, | ||
bool | isnull1, | ||
GISTENTRY * | entry2, | ||
bool | isnull2, | ||
Datum * | dst, | ||
bool * | dstisnull | ||
) |
Definition at line 233 of file gistutil.c.
References FunctionCall2Coll(), GEVHDRSZ, GistEntryVector::n, PointerGetDatum(), storage, GISTSTATE::supportCollation, GISTSTATE::unionFn, and GistEntryVector::vector.
Referenced by gistgetadjusted(), and supportSecondarySplit().
Definition at line 824 of file gistutil.c.
References BMR_REL, BufferGetPage(), ConditionalLockBuffer(), EB_LOCK_FIRST, ExtendBufferedRel(), GetFreeIndexPage(), GIST_UNLOCK, gistcheckpage(), GistPageGetDeleteXid(), gistPageRecyclable(), gistXLogPageReuse(), InvalidBlockNumber, LockBuffer(), MAIN_FORKNUM, PageIsNew(), ReadBuffer(), RelationNeedsWAL, ReleaseBuffer(), and XLogStandbyInfoActive.
Referenced by gistbuild(), and gistplacetopage().
bool gistnospace | ( | Page | page, |
IndexTuple * | itvec, | ||
int | len, | ||
OffsetNumber | todelete, | ||
Size | freespace | ||
) |
Definition at line 59 of file gistutil.c.
References i, IndexTupleSize, InvalidOffsetNumber, len, PageGetFreeSpace(), PageGetItem(), PageGetItemId(), and size.
Referenced by gistplacetopage().
Definition at line 912 of file gistutil.c.
References build_reloptions(), fillfactor, lengthof, RELOPT_KIND_GIST, RELOPT_TYPE_ENUM, and RELOPT_TYPE_INT.
Referenced by gisthandler().
bool gistPageRecyclable | ( | Page | page | ) |
Definition at line 888 of file gistutil.c.
References GistPageGetDeleteXid(), GistPageIsDeleted, GlobalVisCheckRemovableFullXid(), and PageIsNew().
Referenced by gistNewBuffer(), and gistvacuumpage().
float gistpenalty | ( | GISTSTATE * | giststate, |
int | attno, | ||
GISTENTRY * | orig, | ||
bool | isNullOrig, | ||
GISTENTRY * | add, | ||
bool | isNullAdd | ||
) |
Definition at line 724 of file gistutil.c.
References FmgrInfo::fn_strict, FunctionCall3Coll(), get_float4_infinity(), GISTSTATE::penaltyFn, PointerGetDatum(), and GISTSTATE::supportCollation.
Referenced by findDontCares(), gistchoose(), gistRelocateBuildBuffersOnSplit(), placeOne(), and supportSecondarySplit().
bool gistproperty | ( | Oid | index_oid, |
int | attno, | ||
IndexAMProperty | prop, | ||
const char * | propname, | ||
bool * | res, | ||
bool * | isnull | ||
) |
Definition at line 933 of file gistutil.c.
References AMPROP_DISTANCE_ORDERABLE, AMPROP_RETURNABLE, get_index_column_opclass(), get_opclass_opfamily_and_input_type(), GIST_COMPRESS_PROC, GIST_DISTANCE_PROC, GIST_FETCH_PROC, Int16GetDatum(), ObjectIdGetDatum(), OidIsValid, res, and SearchSysCacheExists4.
Referenced by gisthandler().
StrategyNumber GistTranslateStratnum | ( | Oid | opclass, |
StrategyNumber | strat | ||
) |
Definition at line 1081 of file gistutil.c.
References DatumGetUInt16(), get_opclass_opfamily_and_input_type(), get_opfamily_proc(), GIST_STRATNUM_PROC, InvalidOid, InvalidStrategy, OidFunctionCall1Coll(), OidIsValid, and UInt16GetDatum().
Referenced by ATAddForeignKeyConstraint(), and GetOperatorFromWellKnownStrategy().
IndexTuple gistunion | ( | Relation | r, |
IndexTuple * | itvec, | ||
int | len, | ||
GISTSTATE * | giststate | ||
) |
Definition at line 219 of file gistutil.c.
References gistFormTuple(), gistMakeUnionItVec(), INDEX_MAX_KEYS, and len.
Referenced by gist_indexsortbuild_levelstate_flush().