forked from openGauss-Ecosystem/openGauss-server
!2150 Relation相关函数调用优化
Merge pull request !2150 from ljy/perf_relation_rebase
This commit is contained in:
commit
786262989d
|
@ -5424,7 +5424,7 @@ void ScanHeapInsertCBI(Relation parentRel, Relation heapRel, Relation idxRel, Oi
|
|||
tupleDesc = heapRel->rd_att;
|
||||
estate = CreateExecutorState();
|
||||
econtext = GetPerTupleExprContext(estate);
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(parentRel), false, GetTableAmRoutine(parentRel->rd_tam_type));
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(parentRel), false, parentRel->rd_tam_ops);
|
||||
econtext->ecxt_scantuple = slot;
|
||||
/* Set up execution state for predicate, if any. */
|
||||
predicate = (List*)ExecPrepareQual(idxInfo->ii_Predicate, estate);
|
||||
|
@ -5657,7 +5657,7 @@ void ScanPartitionInsertIndex(Relation partTableRel, Relation partRel, const Lis
|
|||
|
||||
if (PointerIsValid(indexRelList)) {
|
||||
estate = CreateExecutorState();
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(partTableRel), false, GetTableAmRoutine(partTableRel->rd_tam_type));
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(partTableRel), false, partTableRel->rd_tam_ops);
|
||||
}
|
||||
|
||||
scan = scan_handler_tbl_beginscan(partRel, SnapshotNow, 0, NULL);
|
||||
|
@ -5877,7 +5877,7 @@ void ScanPartitionDeleteGPITuples(Relation partTableRel, Relation partRel, const
|
|||
|
||||
if (PointerIsValid(indexRelList)) {
|
||||
estate = CreateExecutorState();
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(partTableRel), false, GetTableAmRoutine(partTableRel->rd_tam_type));
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(partTableRel), false, partTableRel->rd_tam_ops);
|
||||
}
|
||||
|
||||
scan = scan_handler_tbl_beginscan(partRel, SnapshotNow, 0, NULL);
|
||||
|
|
|
@ -429,7 +429,7 @@ Relation CopyRelationData(Relation newrel, Relation rel, MemoryContext rules_cxt
|
|||
* otherwise, do the copy work here
|
||||
* if the variable changed, there is no lock and no rel inval msg,
|
||||
* set it zero and reinit it when copy into local */
|
||||
Assert(sizeof(RelationData) == 520);
|
||||
Assert(sizeof(RelationData) == 512);
|
||||
/* all copied exclude pointer */
|
||||
*newrel = *rel;
|
||||
Assert(rel->rd_createSubid == InvalidSubTransactionId);
|
||||
|
|
|
@ -1266,7 +1266,7 @@ void UpdatePartrelPointer(Relation partrel, Relation rel, Partition part)
|
|||
partrel->rd_indextuple = rel->rd_indextuple;
|
||||
partrel->rd_am = rel->rd_am;
|
||||
partrel->rd_indnkeyatts = rel->rd_indnkeyatts;
|
||||
Assert(partrel->rd_tam_type == rel->rd_tam_type);
|
||||
Assert(partrel->rd_tam_ops == rel->rd_tam_ops);
|
||||
|
||||
partrel->rd_aminfo = rel->rd_aminfo;
|
||||
partrel->rd_opfamily = rel->rd_opfamily;
|
||||
|
@ -1391,7 +1391,7 @@ Relation partitionGetRelation(Relation rel, Partition part)
|
|||
relation->rd_indextuple = rel->rd_indextuple;
|
||||
relation->rd_am = rel->rd_am;
|
||||
relation->rd_indnkeyatts = rel->rd_indnkeyatts;
|
||||
relation->rd_tam_type = rel->rd_tam_type;
|
||||
relation->rd_tam_ops = rel->rd_tam_ops;
|
||||
|
||||
if (!OidIsValid(rel->rd_rel->relam)) {
|
||||
relation->rd_indexcxt = NULL;
|
||||
|
|
|
@ -1416,9 +1416,9 @@ static Relation AllocateRelationDesc(Form_pg_class relp)
|
|||
relation->rd_rel = relationForm;
|
||||
|
||||
/* and allocate attribute tuple form storage */
|
||||
relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts, relationForm->relhasoids, NULL);
|
||||
relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts, relationForm->relhasoids);
|
||||
//TODO:this should be TAM_invalid when merge ustore
|
||||
relation->rd_tam_type = TAM_HEAP;
|
||||
relation->rd_tam_ops = TableAmHeap;
|
||||
/* which we mark as a reference-counted tupdesc */
|
||||
relation->rd_att->tdrefcount = 1;
|
||||
|
||||
|
@ -1982,7 +1982,7 @@ static Relation CatalogRelationBuildDesc(const char* relationName, Oid relationR
|
|||
relation->rd_rel->relhasoids = hasoids;
|
||||
relation->rd_rel->relnatts = (int16)natts;
|
||||
// Catalog tables are heap table type.
|
||||
relation->rd_tam_type = TAM_HEAP;
|
||||
relation->rd_tam_ops = TableAmHeap;
|
||||
relation->rd_att = CreateTemplateTupleDesc(natts, hasoids);
|
||||
relation->rd_att->tdrefcount = 1; /* mark as refcounted */
|
||||
relation->rd_att->tdtypeid = relationReltype;
|
||||
|
@ -2200,9 +2200,9 @@ Relation RelationBuildDesc(Oid targetRelId, bool insertIt, bool buildkey)
|
|||
|
||||
/* get the table access method type from reloptions
|
||||
* and populate them in relation and tuple descriptor */
|
||||
relation->rd_tam_type =
|
||||
get_tableam_from_reloptions(relation->rd_options, relation->rd_rel->relkind, relation->rd_rel->relam);
|
||||
relation->rd_att->td_tam_ops = GetTableAmRoutine(relation->rd_tam_type);
|
||||
relation->rd_tam_ops = GetTableAmRoutine(
|
||||
get_tableam_from_reloptions(relation->rd_options, relation->rd_rel->relkind, relation->rd_rel->relam));
|
||||
relation->rd_att->td_tam_ops = relation->rd_tam_ops;
|
||||
|
||||
relation->rd_indexsplit = get_indexsplit_from_reloptions(relation->rd_options, relation->rd_rel->relam);
|
||||
|
||||
|
@ -2992,7 +2992,7 @@ extern void formrdesc(const char* relationName, Oid relationReltype, bool isshar
|
|||
pg_database, pg_authid, pg_auth_members, pg_class, pg_attribute, pg_proc, and pg_type
|
||||
*/
|
||||
relation->rd_att = CreateTemplateTupleDesc(natts, hasoids);
|
||||
relation->rd_tam_type = TAM_HEAP;
|
||||
relation->rd_tam_ops = TableAmHeap;
|
||||
relation->rd_att->tdrefcount = 1; /* mark as refcounted */
|
||||
|
||||
relation->rd_att->tdtypeid = relationReltype;
|
||||
|
@ -4352,6 +4352,7 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple
|
|||
int i;
|
||||
bool has_not_null = false;
|
||||
bool nailit = false;
|
||||
const TableAmRoutine* tam_ops = GetTableAmRoutine(tam_type);
|
||||
|
||||
AssertArg(natts >= 0);
|
||||
|
||||
|
@ -4427,9 +4428,9 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple
|
|||
* catalogs. We can copy attnotnull constraints here, however.
|
||||
*/
|
||||
rel->rd_att = CreateTupleDescCopy(tupDesc);
|
||||
rel->rd_tam_type = tam_type;
|
||||
rel->rd_tam_ops = tam_ops;
|
||||
rel->rd_indexsplit = relindexsplit;
|
||||
rel->rd_att->td_tam_ops = GetTableAmRoutine(tam_type);
|
||||
rel->rd_att->td_tam_ops = tam_ops;
|
||||
rel->rd_att->tdrefcount = 1; /* mark as refcounted */
|
||||
has_not_null = false;
|
||||
for (i = 0; i < natts; i++) {
|
||||
|
|
|
@ -3409,8 +3409,7 @@ static void copytup_heap(Tuplesortstate* state, SortTuple* stup, void* tup)
|
|||
/* set up first-column key value */
|
||||
htup.t_len = tuple->t_len + MINIMAL_TUPLE_OFFSET;
|
||||
htup.t_data = (HeapTupleHeader)((char*)tuple - MINIMAL_TUPLE_OFFSET);
|
||||
original = tableam_tops_tuple_getattr(&htup, state->sortKeys[0].ssup_attno, state->tupDesc, &stup->isnull1);
|
||||
|
||||
original = tableam_tops_tuple_getattr(&htup, state->sortKeys[0].ssup_attno, state->tupDesc, &stup->isnull1);
|
||||
if (!state->sortKeys->abbrev_converter || stup->isnull1) {
|
||||
/*
|
||||
* Store ordinary Datum representation, or NULL value. If there is a
|
||||
|
|
|
@ -708,7 +708,7 @@ void InsertOneTuple(Oid objectid)
|
|||
tupDesc = CreateTupleDesc(t_thrd.bootstrap_cxt.numattr,
|
||||
RelationGetForm(t_thrd.bootstrap_cxt.boot_reldesc)->relhasoids,
|
||||
t_thrd.bootstrap_cxt.attrtypes,
|
||||
GetTableAmRoutine(t_thrd.bootstrap_cxt.boot_reldesc->rd_tam_type));
|
||||
t_thrd.bootstrap_cxt.boot_reldesc->rd_tam_ops);
|
||||
tuple = (HeapTuple) tableam_tops_form_tuple(tupDesc, values, Nulls);
|
||||
if (objectid != (Oid)0)
|
||||
HeapTupleSetOid(tuple, objectid);
|
||||
|
|
|
@ -2653,7 +2653,7 @@ retry:
|
|||
}
|
||||
|
||||
/* TO DO: Need to switch this to inplaceheapam_scan_analyze_next_block after we have tableam. */
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(onerel), false, GetTableAmRoutine(onerel->rd_tam_type));
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(onerel), false, onerel->rd_tam_ops);
|
||||
maxoffset = UHeapPageGetMaxOffsetNumber(targpage);
|
||||
|
||||
/* Inner loop over all tuples on the selected page */
|
||||
|
|
|
@ -2349,7 +2349,7 @@ static void copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, int
|
|||
|
||||
if (isNull) {
|
||||
relfrozenxid = OldHeap->rd_rel->relfrozenxid;
|
||||
if (OldHeap->rd_tam_type == TAM_USTORE) {
|
||||
if (OldHeap->rd_tam_ops == TableAmUstore) {
|
||||
elog(ERROR, "cluster not supported in ustore");
|
||||
}
|
||||
|
||||
|
|
|
@ -4025,7 +4025,7 @@ static uint64 CopyFrom(CopyState cstate)
|
|||
estate->es_range_table = cstate->range_table;
|
||||
|
||||
/* Set up a tuple slot too */
|
||||
myslot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(cstate->rel->rd_tam_type));
|
||||
myslot = ExecInitExtraTupleSlot(estate, cstate->rel->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(myslot, tupDesc);
|
||||
/* Triggers might need a slot as well */
|
||||
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate);
|
||||
|
@ -4567,7 +4567,7 @@ static uint64 CopyFrom(CopyState cstate)
|
|||
#endif
|
||||
|
||||
/* And now we can form the input tuple. */
|
||||
tuple = (Tuple)tableam_tops_form_tuple(tupDesc, values, nulls, GetTableAmRoutine(cstate->rel->rd_tam_type));
|
||||
tuple = (Tuple)tableam_tops_form_tuple(tupDesc, values, nulls, cstate->rel->rd_tam_ops);
|
||||
|
||||
if (loaded_oid != InvalidOid)
|
||||
HeapTupleSetOid((HeapTuple)tuple, loaded_oid);
|
||||
|
|
|
@ -524,7 +524,7 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al
|
|||
CheckCompressOption(&indexCreateSupport);
|
||||
|
||||
/* Forbidden to create gin index on ustore table. */
|
||||
if (rel->rd_tam_type == TAM_USTORE) {
|
||||
if (rel->rd_tam_ops == TableAmUstore) {
|
||||
if (strcmp(stmt->accessMethod, "btree") == 0) {
|
||||
elog(ERROR, "btree index is not supported for ustore, please use ubtree instead");
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al
|
|||
}
|
||||
|
||||
if (strcmp(stmt->accessMethod, "ubtree") == 0 &&
|
||||
rel->rd_tam_type != TAM_USTORE) {
|
||||
rel->rd_tam_ops != TableAmUstore) {
|
||||
elog(ERROR, "ubtree index is only supported for ustore");
|
||||
}
|
||||
|
||||
|
|
|
@ -1190,7 +1190,7 @@ static void ExecCreateMatInc(QueryDesc*queryDesc, Query *query, Relation matview
|
|||
while ((tuple = (HeapTuple) tableam_scan_getnexttuple(scan, ForwardScanDirection)) != NULL) {
|
||||
HeapTuple tmpTuple = NULL;
|
||||
/* here we want handle every tuple. */
|
||||
if (rel->rd_tam_type == TAM_USTORE) {
|
||||
if (rel->rd_tam_ops == TableAmUstore) {
|
||||
tmpTuple = UHeapToHeap(rel->rd_att, (UHeapTuple)tuple);
|
||||
tmpTuple->t_xid_base = ((UHeapTuple)tuple)->t_xid_base;
|
||||
tmpTuple->t_data->t_choice.t_heap.t_xmin = ((UHeapTuple)tuple)->disk_tuple->xid;
|
||||
|
|
|
@ -8378,8 +8378,8 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat
|
|||
* tuples are the same, the tupDescs might not be (consider ADD COLUMN
|
||||
* without a default).
|
||||
*/
|
||||
oldslot = MakeSingleTupleTableSlot(oldTupDesc, false, GetTableAmRoutine(oldrel->rd_tam_type));
|
||||
newslot = MakeSingleTupleTableSlot(newTupDesc, false, GetTableAmRoutine(oldrel->rd_tam_type));
|
||||
oldslot = MakeSingleTupleTableSlot(oldTupDesc, false, oldrel->rd_tam_ops);
|
||||
newslot = MakeSingleTupleTableSlot(newTupDesc, false, oldrel->rd_tam_ops);
|
||||
|
||||
/* Preallocate values/isnull arrays */
|
||||
i = Max(newTupDesc->natts, oldTupDesc->natts);
|
||||
|
@ -10868,7 +10868,7 @@ static void ATExecAddConstraint(List** wqueue, AlteredTableInfo* tab, Relation r
|
|||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("column store unsupport constraint \"%s\"", GetConstraintType(newConstraint->contype))));
|
||||
|
||||
if (rel->rd_tam_type == TAM_USTORE && newConstraint->deferrable == true) {
|
||||
if (rel->rd_tam_ops == TableAmUstore && newConstraint->deferrable == true) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmodule(MOD_COMMAND),
|
||||
|
@ -12036,7 +12036,7 @@ static void validateCheckConstraint(Relation rel, HeapTuple constrtup)
|
|||
List* exprstate = ExecPrepareExprList(make_ands_implicit(origexpr), estate);
|
||||
ExprContext* econtext = GetPerTupleExprContext(estate);
|
||||
TupleDesc tupdesc = RelationGetDescr(rel);
|
||||
TupleTableSlot* slot = MakeSingleTupleTableSlot(tupdesc, false, GetTableAmRoutine(rel->rd_tam_type));
|
||||
TupleTableSlot* slot = MakeSingleTupleTableSlot(tupdesc, false, rel->rd_tam_ops);
|
||||
|
||||
econtext->ecxt_scantuple = slot;
|
||||
|
||||
|
|
|
@ -1399,7 +1399,7 @@ bool SkewInfo::canValuePassQual(List* varList, List* valueList, Expr* expr)
|
|||
rte = planner_rt_fetch(rel->relid, m_root);
|
||||
heaprel = heap_open(rte->relid, NoLock);
|
||||
tupdesc = RelationGetDescr(heaprel);
|
||||
slot = MakeSingleTupleTableSlot(tupdesc, false, GetTableAmRoutine(heaprel->rd_tam_type));
|
||||
slot = MakeSingleTupleTableSlot(tupdesc, false, heaprel->rd_tam_ops);
|
||||
slot->tts_nvalid = tupdesc->natts;
|
||||
heap_close(heaprel, NoLock);
|
||||
|
||||
|
|
|
@ -870,8 +870,8 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
|||
*op->resvalue = op->d.constval.value;
|
||||
|
||||
/* if a const cursor, copy cursor option data to econtext */
|
||||
if ((econtext->is_cursor || op->d.constval.is_cursor) && op->d.constval.con &&
|
||||
op->d.constval.con->consttype == REFCURSOROID) {
|
||||
if (unlikely((econtext->is_cursor || op->d.constval.is_cursor) && op->d.constval.con &&
|
||||
op->d.constval.con->consttype == REFCURSOROID)) {
|
||||
CopyCursorInfoData(&econtext->cursor_data, &op->d.constval.con->cursor_data);
|
||||
econtext->dno = op->d.constval.con->cursor_data.cur_dno;
|
||||
}
|
||||
|
@ -2443,8 +2443,8 @@ ExecJustConst(ExprState *state, ExprContext *econtext, bool *isnull)
|
|||
*isnull = op->d.constval.isnull;
|
||||
|
||||
/* if a const cursor, copy cursor option data to econtext */
|
||||
if ((econtext->is_cursor || op->d.constval.is_cursor) && op->d.constval.con &&
|
||||
op->d.constval.con->consttype == REFCURSOROID) {
|
||||
if (unlikely((econtext->is_cursor || op->d.constval.is_cursor) && op->d.constval.con &&
|
||||
op->d.constval.con->consttype == REFCURSOROID)) {
|
||||
CopyCursorInfoData(&econtext->cursor_data, &op->d.constval.con->cursor_data);
|
||||
econtext->dno = op->d.constval.con->cursor_data.cur_dno;
|
||||
}
|
||||
|
|
|
@ -669,7 +669,8 @@ Datum ExecFetchSlotTupleDatum(TupleTableSlot* slot)
|
|||
* to scribble on.
|
||||
* --------------------------------
|
||||
*/
|
||||
HeapTuple ExecMaterializeSlot(TupleTableSlot* slot)
|
||||
static FORCE_INLINE
|
||||
HeapTuple ExecMaterializeSlot_impl(TupleTableSlot* slot)
|
||||
{
|
||||
/*
|
||||
* sanity checks
|
||||
|
@ -680,6 +681,19 @@ HeapTuple ExecMaterializeSlot(TupleTableSlot* slot)
|
|||
return tableam_tslot_materialize(slot);
|
||||
}
|
||||
|
||||
|
||||
HeapTuple ExecMaterializeSlot(TupleTableSlot* slot)
|
||||
{
|
||||
return ExecMaterializeSlot_impl(slot);
|
||||
}
|
||||
|
||||
Tuple heap_slot_get_tuple_from_slot(TupleTableSlot* slot)
|
||||
{
|
||||
HeapTuple tuple = ExecMaterializeSlot_impl(slot);
|
||||
tuple->tupInfo = 0;
|
||||
return (Tuple) tuple;
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* ExecCopySlot
|
||||
* Copy the source slot's contents into the destination slot.
|
||||
|
|
|
@ -1881,7 +1881,7 @@ bool check_violation(Relation heap, Relation index, IndexInfo *indexInfo, ItemPo
|
|||
* to this slot. Be sure to save and restore caller's value for
|
||||
* scantuple.
|
||||
*/
|
||||
existing_slot = MakeSingleTupleTableSlot(RelationGetDescr(heap), false, GetTableAmRoutine(heap->rd_tam_type));
|
||||
existing_slot = MakeSingleTupleTableSlot(RelationGetDescr(heap), false, heap->rd_tam_ops);
|
||||
econtext = GetPerTupleExprContext(estate);
|
||||
save_scantuple = econtext->ecxt_scantuple;
|
||||
econtext->ecxt_scantuple = existing_slot;
|
||||
|
|
|
@ -802,8 +802,8 @@ BitmapHeapScanState* ExecInitBitmapHeapScan(BitmapHeapScan* node, EState* estate
|
|||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &scanstate->ss.ps, GetTableAmRoutine(currentRelation->rd_tam_type));
|
||||
ExecInitScanTupleSlot(estate, &scanstate->ss, GetTableAmRoutine(currentRelation->rd_tam_type));
|
||||
ExecInitResultTupleSlot(estate, &scanstate->ss.ps, currentRelation->rd_tam_ops);
|
||||
ExecInitScanTupleSlot(estate, &scanstate->ss, currentRelation->rd_tam_ops);
|
||||
|
||||
InitBitmapHeapScanNextMtd(scanstate);
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ static TupleTableSlot* IndexOnlyNext(IndexOnlyScanState* node)
|
|||
slot = node->ss.ss_ScanTupleSlot;
|
||||
isUHeap = RelationIsUstoreFormat(node->ss.ss_currentRelation);
|
||||
tmpslot = MakeSingleTupleTableSlot(RelationGetDescr(scandesc->heapRelation),
|
||||
false, GetTableAmRoutine(scandesc->heapRelation->rd_tam_type));
|
||||
false, scandesc->heapRelation->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* OK, now that we have what we need, fetch the next tuple.
|
||||
|
@ -584,8 +584,8 @@ IndexOnlyScanState* ExecInitIndexOnlyScan(IndexOnlyScan* node, EState* estate, i
|
|||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &indexstate->ss.ps, GetTableAmRoutine(currentRelation->rd_tam_type));
|
||||
ExecInitScanTupleSlot(estate, &indexstate->ss, GetTableAmRoutine(currentRelation->rd_tam_type));
|
||||
ExecInitResultTupleSlot(estate, &indexstate->ss.ps, currentRelation->rd_tam_ops);
|
||||
ExecInitScanTupleSlot(estate, &indexstate->ss, currentRelation->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* Build the scan tuple type using the indextlist generated by the
|
||||
|
|
|
@ -683,14 +683,14 @@ IndexScanState* ExecInitIndexScan(IndexScan* node, EState* estate, int eflags)
|
|||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &index_state->ss.ps, GetTableAmRoutine(current_relation->rd_tam_type));
|
||||
ExecInitScanTupleSlot(estate, &index_state->ss, GetTableAmRoutine(current_relation->rd_tam_type));
|
||||
ExecInitResultTupleSlot(estate, &index_state->ss.ps, current_relation->rd_tam_ops);
|
||||
ExecInitScanTupleSlot(estate, &index_state->ss, current_relation->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* get the scan type from the relation descriptor.
|
||||
*/
|
||||
ExecAssignScanType(&index_state->ss, CreateTupleDescCopy(RelationGetDescr(current_relation)));
|
||||
index_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(current_relation->rd_tam_type);
|
||||
index_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = current_relation->rd_tam_ops;
|
||||
|
||||
/*
|
||||
* Initialize result tuple type and projection info.
|
||||
|
|
|
@ -775,7 +775,7 @@ static Oid ExecUpsert(ModifyTableState* state, TupleTableSlot* slot, TupleTableS
|
|||
/* try to insert tuple into mlog-table. */
|
||||
if (targetrel != NULL && targetrel->rd_mlogoid != InvalidOid) {
|
||||
/* judge whether need to insert into mlog-table */
|
||||
if (targetrel->rd_tam_type == TAM_USTORE) {
|
||||
if (targetrel->rd_tam_ops == TableAmUstore) {
|
||||
tuple = (Tuple)UHeapToHeap(targetrel->rd_att, (UHeapTuple)tuple);
|
||||
}
|
||||
insert_into_mlog_table(targetrel, targetrel->rd_mlogoid, (HeapTuple)tuple,
|
||||
|
@ -961,7 +961,7 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple
|
|||
} else
|
||||
#endif
|
||||
if (useHeapMultiInsert) {
|
||||
TupleTableSlot* tmp_slot = MakeSingleTupleTableSlot(slot->tts_tupleDescriptor, false, GetTableAmRoutine(result_relation_desc->rd_tam_type));
|
||||
TupleTableSlot* tmp_slot = MakeSingleTupleTableSlot(slot->tts_tupleDescriptor, false, result_relation_desc->rd_tam_ops);
|
||||
|
||||
bool is_partition_rel = result_relation_desc->rd_rel->parttype == PARTTYPE_PARTITIONED_RELATION;
|
||||
Oid targetOid = InvalidOid;
|
||||
|
@ -1023,7 +1023,7 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple
|
|||
tuple = tableam_tops_form_tuple(slot->tts_tupleDescriptor,
|
||||
slot->tts_values,
|
||||
slot->tts_isnull,
|
||||
GetTableAmRoutine(result_relation_desc->rd_tam_type));
|
||||
result_relation_desc->rd_tam_ops);
|
||||
if (rel_isblockchain) {
|
||||
MemoryContext old_context = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
|
||||
tuple = set_user_tuple_hash((HeapTuple)tuple, result_relation_desc);
|
||||
|
@ -1222,7 +1222,7 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple
|
|||
/* try to insert tuple into mlog-table. */
|
||||
if (target_rel != NULL && target_rel->rd_mlogoid != InvalidOid) {
|
||||
/* judge whether need to insert into mlog-table */
|
||||
if (target_rel->rd_tam_type == TAM_USTORE) {
|
||||
if (target_rel->rd_tam_ops == TableAmUstore) {
|
||||
tuple = (Tuple)UHeapToHeap(target_rel->rd_att, (UHeapTuple)tuple);
|
||||
}
|
||||
insert_into_mlog_table(target_rel, target_rel->rd_mlogoid, (HeapTuple)tuple,
|
||||
|
@ -1587,7 +1587,7 @@ end:;
|
|||
if (slot->tts_tupleDescriptor != RelationGetDescr(result_relation_desc)) {
|
||||
ExecSetSlotDescriptor(slot, RelationGetDescr(result_relation_desc));
|
||||
}
|
||||
slot->tts_tam_ops = GetTableAmRoutine(result_relation_desc->rd_tam_type);
|
||||
slot->tts_tam_ops = result_relation_desc->rd_tam_ops;
|
||||
if (oldtuple != NULL) {
|
||||
Assert(!TTS_TABLEAM_IS_USTORE(slot));
|
||||
del_tuple.t_data = oldtuple;
|
||||
|
@ -2544,7 +2544,7 @@ ldelete:
|
|||
insert_into_mlog_table(result_relation_desc, result_relation_desc->rd_mlogoid,
|
||||
NULL, tupleid, tmfd.xmin, 'D');
|
||||
/* 2. insert new tuple */
|
||||
if (result_relation_desc->rd_tam_type == TAM_USTORE) {
|
||||
if (result_relation_desc->rd_tam_ops == TableAmUstore) {
|
||||
tuple = (Tuple)UHeapToHeap(result_relation_desc->rd_att, (UHeapTuple)tuple);
|
||||
}
|
||||
insert_into_mlog_table(result_relation_desc, result_relation_desc->rd_mlogoid,
|
||||
|
@ -2919,7 +2919,7 @@ static TupleTableSlot* ExecModifyTable(PlanState* state)
|
|||
|
||||
EvalPlanQualSetSlot(&node->mt_epqstate, plan_slot);
|
||||
slot = plan_slot;
|
||||
slot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type);
|
||||
slot->tts_tupleDescriptor->td_tam_ops = result_rel_info->ri_RelationDesc->rd_tam_ops;
|
||||
|
||||
if (operation == CMD_MERGE) {
|
||||
if (junk_filter == NULL) {
|
||||
|
@ -3352,7 +3352,7 @@ ModifyTableState* ExecInitModifyTable(ModifyTable* node, EState* estate, int efl
|
|||
* RETURNING list. We assume the rest will look the same.
|
||||
*/
|
||||
tup_desc = ExecTypeFromTL((List*)linitial(node->returningLists), false, false,
|
||||
GetTableAmRoutine(mt_state->resultRelInfo->ri_RelationDesc->rd_tam_type));
|
||||
mt_state->resultRelInfo->ri_RelationDesc->rd_tam_ops);
|
||||
|
||||
/* Set up a slot for the output of the RETURNING projection(s) */
|
||||
ExecInitResultTupleSlot(estate, &mt_state->ps);
|
||||
|
@ -3406,7 +3406,7 @@ ModifyTableState* ExecInitModifyTable(ModifyTable* node, EState* estate, int efl
|
|||
|
||||
/* initialize slot for the existing tuple */
|
||||
upsertState->us_existing =
|
||||
ExecInitExtraTupleSlot(mt_state->ps.state, GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type));
|
||||
ExecInitExtraTupleSlot(mt_state->ps.state, result_rel_info->ri_RelationDesc->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(upsertState->us_existing, result_rel_info->ri_RelationDesc->rd_att);
|
||||
|
||||
upsertState->us_excludedtlist = node->exclRelTlist;
|
||||
|
@ -3414,7 +3414,7 @@ ModifyTableState* ExecInitModifyTable(ModifyTable* node, EState* estate, int efl
|
|||
/* create target slot for UPDATE SET projection */
|
||||
tupDesc = ExecTypeFromTL((List*)node->updateTlist, result_rel_info->ri_RelationDesc->rd_rel->relhasoids);
|
||||
upsertState->us_updateproj =
|
||||
ExecInitExtraTupleSlot(mt_state->ps.state, GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type));
|
||||
ExecInitExtraTupleSlot(mt_state->ps.state, result_rel_info->ri_RelationDesc->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(upsertState->us_updateproj, tupDesc);
|
||||
|
||||
/* build UPDATE SET expression and projection state */
|
||||
|
@ -3544,7 +3544,7 @@ ModifyTableState* ExecInitModifyTable(ModifyTable* node, EState* estate, int efl
|
|||
|
||||
j = ExecInitJunkFilter(sub_plan->targetlist,
|
||||
result_rel_info->ri_RelationDesc->rd_att->tdhasoid,
|
||||
ExecInitExtraTupleSlot(estate, GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type)));
|
||||
ExecInitExtraTupleSlot(estate, result_rel_info->ri_RelationDesc->rd_tam_ops));
|
||||
|
||||
if (operation == CMD_UPDATE || operation == CMD_DELETE || operation == CMD_MERGE) {
|
||||
/* For UPDATE/DELETE, find the appropriate junk attr now */
|
||||
|
@ -3632,7 +3632,7 @@ ModifyTableState* ExecInitModifyTable(ModifyTable* node, EState* estate, int efl
|
|||
*/
|
||||
if (estate->es_trig_tuple_slot == NULL) {
|
||||
result_rel_info = mt_state->resultRelInfo;
|
||||
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type));
|
||||
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate, result_rel_info->ri_RelationDesc->rd_tam_ops);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -118,12 +118,12 @@ static inline UHeapTuple USampleFetchNextTuple(SeqScanState* node)
|
|||
TupleTableSlot* HeapSeqSampleNext(SeqScanState* node)
|
||||
{
|
||||
TupleTableSlot* slot = node->ss_ScanTupleSlot;
|
||||
node->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(node->ss_currentRelation->rd_tam_type);
|
||||
node->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = node->ss_currentRelation->rd_tam_ops;
|
||||
HeapTuple tuple = SampleFetchNextTuple(node);
|
||||
return ExecMakeTupleSlot(tuple,
|
||||
GetTableScanDesc(node->ss_currentScanDesc, node->ss_currentRelation),
|
||||
slot,
|
||||
GetTableAmRoutine(node->ss_currentRelation->rd_tam_type));
|
||||
node->ss_currentRelation->rd_tam_ops);
|
||||
}
|
||||
|
||||
TupleTableSlot* UHeapSeqSampleNext(SeqScanState* node)
|
||||
|
@ -176,11 +176,11 @@ TupleTableSlot* HbktSeqSampleNext(SeqScanState* node)
|
|||
(((RowTableSample*)node->sampleScanInfo.tsm_state)->resetSampleScan)();
|
||||
}
|
||||
|
||||
node->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(node->ss_currentRelation->rd_tam_type);
|
||||
node->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = node->ss_currentRelation->rd_tam_ops;
|
||||
return ExecMakeTupleSlot(
|
||||
(Tuple) tuple, GetTableScanDesc(node->ss_currentScanDesc, node->ss_currentRelation),
|
||||
slot,
|
||||
GetTableAmRoutine(node->ss_currentRelation->rd_tam_type));
|
||||
node->ss_currentRelation->rd_tam_ops);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -511,8 +511,8 @@ void InitScanRelation(SeqScanState* node, EState* estate, int eflags)
|
|||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &node->ps, GetTableAmRoutine(current_relation->rd_tam_type));
|
||||
ExecInitScanTupleSlot(estate, node, GetTableAmRoutine(current_relation->rd_tam_type));
|
||||
ExecInitResultTupleSlot(estate, &node->ps, current_relation->rd_tam_ops);
|
||||
ExecInitScanTupleSlot(estate, node, current_relation->rd_tam_ops);
|
||||
|
||||
if (((Scan*)node->ps.plan)->tablesample && node->sampleScanInfo.tsm_state == NULL) {
|
||||
if (isUstoreRel) {
|
||||
|
@ -697,7 +697,7 @@ static SeqScanState *ExecInitSeqScanBatchMode(SeqScan *node, SeqScanState* scans
|
|||
scanstate->scanBatchState = scanBatchState;
|
||||
scanstate->ps.subPlan = NULL;
|
||||
|
||||
if (scanstate->ss_currentRelation->rd_tam_type == TAM_HEAP) {
|
||||
if (scanstate->ss_currentRelation->rd_tam_ops == TableAmHeap) {
|
||||
HeapScanDesc heapDesc = (HeapScanDesc)(scanstate->ss_currentScanDesc);
|
||||
heapDesc->rs_ctupBatch = (HeapTupleData*)palloc(sizeof(HeapTupleData) * BatchMaxSize);
|
||||
} else {
|
||||
|
@ -709,7 +709,7 @@ static SeqScanState *ExecInitSeqScanBatchMode(SeqScan *node, SeqScanState* scans
|
|||
(TupleTableSlot**)palloc(sizeof(TupleTableSlot*) * BatchMaxSize);
|
||||
for (i = 0; i < BatchMaxSize; i++) {
|
||||
TupleTableSlot* slot = ExecAllocTableSlot(&estate->es_tupleTable,
|
||||
GetTableAmRoutine(scanstate->ss_currentRelation->rd_tam_type));
|
||||
scanstate->ss_currentRelation->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(slot, scanstate->ss_ScanTupleSlot->tts_tupleDescriptor);
|
||||
scanBatchState->scanBatch.scanTupleSlotInBatch[i] = slot;
|
||||
}
|
||||
|
@ -756,12 +756,12 @@ static inline void InitSeqNextMtd(SeqScan* node, SeqScanState* scanstate)
|
|||
if (!node->tablesample) {
|
||||
scanstate->ScanNextMtd = SeqNext;
|
||||
if(RELATION_OWN_BUCKET(scanstate->ss_currentRelation)) {
|
||||
if(scanstate->ss_currentRelation->rd_tam_type == TAM_HEAP)
|
||||
if(scanstate->ss_currentRelation->rd_tam_ops == TableAmHeap)
|
||||
scanstate->fillNextSlotFunc = seq_scan_getnext_template<TAM_HEAP, true>;
|
||||
else
|
||||
scanstate->fillNextSlotFunc = seq_scan_getnext_template<TAM_USTORE, true>;
|
||||
} else {
|
||||
if(scanstate->ss_currentRelation->rd_tam_type == TAM_HEAP)
|
||||
if(scanstate->ss_currentRelation->rd_tam_ops == TableAmHeap)
|
||||
scanstate->fillNextSlotFunc = seq_scan_getnext_template<TAM_HEAP, false>;
|
||||
else
|
||||
scanstate->fillNextSlotFunc = seq_scan_getnext_template<TAM_USTORE, false>;
|
||||
|
@ -961,7 +961,7 @@ SeqScanState* ExecInitSeqScan(SeqScan* node, EState* estate, int eflags)
|
|||
*/
|
||||
ExecAssignResultTypeFromTL(
|
||||
&scanstate->ps,
|
||||
GetTableAmRoutine(scanstate->ss_currentRelation->rd_tam_type));
|
||||
scanstate->ss_currentRelation->rd_tam_ops);
|
||||
|
||||
ExecAssignScanProjectionInfo(scanstate);
|
||||
|
||||
|
@ -1186,7 +1186,7 @@ void ExecReScanSeqScan(SeqScanState* node)
|
|||
scan_handler_tbl_rescan(scan, NULL, node->ss_currentRelation);
|
||||
}
|
||||
|
||||
if ((scan != NULL) && (scan->rs_rd->rd_tam_type == TAM_USTORE)) {
|
||||
if ((scan != NULL) && (scan->rs_rd->rd_tam_ops == TableAmUstore)) {
|
||||
scan->lastVar = -1;
|
||||
scan->boolArr = NULL;
|
||||
}
|
||||
|
@ -1294,7 +1294,7 @@ static void ExecInitNextPartitionForSeqScan(SeqScanState* node)
|
|||
}
|
||||
|
||||
if (node->scanBatchMode) {
|
||||
if (node->ss_currentRelation->rd_tam_type == TAM_HEAP) {
|
||||
if (node->ss_currentRelation->rd_tam_ops == TableAmHeap) {
|
||||
HeapScanDesc heapDesc = (HeapScanDesc)node->ss_currentScanDesc;
|
||||
heapDesc->rs_ctupBatch = (HeapTupleData*)palloc(sizeof(HeapTupleData) * BatchMaxSize);
|
||||
} else {
|
||||
|
|
|
@ -674,8 +674,8 @@ TidScanState* ExecInitTidScan(TidScan* node, EState* estate, int eflags)
|
|||
/*
|
||||
* tuple table initialization
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &tidstate->ss.ps, GetTableAmRoutine(current_relation->rd_tam_type));
|
||||
ExecInitScanTupleSlot(estate, &tidstate->ss, GetTableAmRoutine(current_relation->rd_tam_type));
|
||||
ExecInitResultTupleSlot(estate, &tidstate->ss.ps, current_relation->rd_tam_ops);
|
||||
ExecInitScanTupleSlot(estate, &tidstate->ss, current_relation->rd_tam_ops);
|
||||
|
||||
/* deal with partitioned table branch */
|
||||
if (node->scan.isPartTbl) {
|
||||
|
|
|
@ -77,6 +77,7 @@ void DeleteFusion::InitGlobals()
|
|||
m_global->m_tupDesc = CreateTupleDescCopy(RelationGetDescr(rel));
|
||||
m_global->m_is_bucket_rel = RELATION_OWN_BUCKET(rel);
|
||||
m_global->m_table_type = RelationIsUstoreFormat(rel) ? TAM_USTORE : TAM_HEAP;
|
||||
m_global->m_tupDesc->td_tam_ops = GetTableAmRoutine(m_global->m_table_type);
|
||||
m_global->m_exec_func_ptr = (OpFusionExecfuncType)&DeleteFusion::ExecDelete;
|
||||
heap_close(rel, AccessShareLock);
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ TupleTableSlot *IndexOnlyScanFusion::getTupleSlotInternal()
|
|||
bool bucket_changed = false;
|
||||
TupleTableSlot* tmpreslot = NULL;
|
||||
tmpreslot = MakeSingleTupleTableSlot(RelationGetDescr(m_scandesc->heapRelation),
|
||||
false, GetTableAmRoutine(m_scandesc->heapRelation->rd_tam_type));
|
||||
false, m_scandesc->heapRelation->rd_tam_ops);
|
||||
|
||||
while ((tid = scan_handler_idx_getnext_tid(m_scandesc, *m_direction, &bucket_changed)) != NULL) {
|
||||
HeapTuple tuple = NULL;
|
||||
|
|
|
@ -92,7 +92,7 @@ IndexScanFusion::IndexScanFusion(IndexScan* node, PlannedStmt* planstmt, ParamLi
|
|||
m_direction = (ScanDirection*)palloc0(sizeof(ScanDirection));
|
||||
|
||||
Relation rel = m_rel;
|
||||
m_tupDesc = ExecCleanTypeFromTL(m_targetList, false, GetTableAmRoutine(rel->rd_tam_type));
|
||||
m_tupDesc = ExecCleanTypeFromTL(m_targetList, false, rel->rd_tam_ops);
|
||||
m_attrno = (int16*)palloc(m_tupDesc->natts * sizeof(int16));
|
||||
m_values = (Datum*)palloc(RelationGetDescr(rel)->natts * sizeof(Datum));
|
||||
m_tmpvals = (Datum*)palloc(m_tupDesc->natts * sizeof(Datum));
|
||||
|
@ -167,7 +167,7 @@ void IndexScanFusion::Init(long max_rows)
|
|||
}
|
||||
|
||||
m_epq_indexqual = m_node->indexqualorig;
|
||||
m_reslot = MakeSingleTupleTableSlot(m_tupDesc, false, GetTableAmRoutine(m_rel->rd_tam_type));
|
||||
m_reslot = MakeSingleTupleTableSlot(m_tupDesc, false, m_rel->rd_tam_ops);
|
||||
}
|
||||
|
||||
HeapTuple IndexScanFusion::getTuple()
|
||||
|
|
|
@ -46,6 +46,7 @@ void InsertFusion::InitGlobals()
|
|||
m_global->m_natts = RelationGetDescr(rel)->natts;
|
||||
m_global->m_is_bucket_rel = RELATION_OWN_BUCKET(rel);
|
||||
m_global->m_tupDesc = CreateTupleDescCopy(RelationGetDescr(rel));
|
||||
m_global->m_tupDesc->td_tam_ops = GetTableAmRoutine(m_global->m_table_type);
|
||||
heap_close(rel, AccessShareLock);
|
||||
|
||||
/* init param func const */
|
||||
|
@ -196,7 +197,7 @@ unsigned long InsertFusion::ExecInsert(Relation rel, ResultRelInfo* result_rel_i
|
|||
* step 2: begin insert *
|
||||
************************/
|
||||
Tuple tuple = tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_values,
|
||||
m_local.m_isnull, GetTableAmRoutine(rel->rd_tam_type));
|
||||
m_local.m_isnull, rel->rd_tam_ops);
|
||||
Assert(tuple != NULL);
|
||||
if (RELATION_IS_PARTITIONED(rel)) {
|
||||
m_c_local.m_estate->esfRelations = NULL;
|
||||
|
@ -245,7 +246,7 @@ unsigned long InsertFusion::ExecInsert(Relation rel, ResultRelInfo* result_rel_i
|
|||
if (rel != NULL && rel->rd_mlogoid != InvalidOid) {
|
||||
/* judge whether need to insert into mlog-table */
|
||||
HeapTuple htuple = NULL;
|
||||
if (rel->rd_tam_type == TAM_USTORE) {
|
||||
if (rel->rd_tam_ops == TableAmUstore) {
|
||||
htuple = UHeapToHeap(rel->rd_att, (UHeapTuple)tuple);
|
||||
insert_into_mlog_table(rel, rel->rd_mlogoid, htuple, &htuple->t_self,
|
||||
GetCurrentTransactionId(), 'I');
|
||||
|
|
|
@ -100,9 +100,10 @@ void SelectForUpdateFusion::InitGlobals()
|
|||
Relation rel = heap_open(m_global->m_reloid, AccessShareLock);
|
||||
m_global->m_natts = RelationGetDescr(rel)->natts;
|
||||
Assert(list_length(targetList) >= 2);
|
||||
m_global->m_tupDesc = ExecCleanTypeFromTL(targetList, false, GetTableAmRoutine(rel->rd_tam_type));
|
||||
m_global->m_tupDesc = ExecCleanTypeFromTL(targetList, false, rel->rd_tam_ops);
|
||||
m_global->m_is_bucket_rel = RELATION_OWN_BUCKET(rel);
|
||||
m_global->m_table_type = RelationIsUstoreFormat(rel) ? TAM_USTORE : TAM_HEAP;
|
||||
m_global->m_tupDesc->td_tam_ops = GetTableAmRoutine(m_global->m_table_type);
|
||||
m_global->m_exec_func_ptr = (OpFusionExecfuncType)&SelectForUpdateFusion::ExecSelectForUpdate;
|
||||
|
||||
heap_close(rel, AccessShareLock);
|
||||
|
@ -249,7 +250,7 @@ unsigned long SelectForUpdateFusion::ExecSelectForUpdate(Relation rel, ResultRel
|
|||
}
|
||||
|
||||
tmptup = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_tmpvals, m_local.m_tmpisnull,
|
||||
GetTableAmRoutine(rel->rd_tam_type));
|
||||
rel->rd_tam_ops);
|
||||
if (bucket_rel) {
|
||||
bucketCloseRelation(bucket_rel);
|
||||
}
|
||||
|
@ -360,7 +361,7 @@ unsigned long SelectForUpdateFusion::ExecSelectForUpdate(Relation rel, ResultRel
|
|||
}
|
||||
|
||||
tmptup = tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_tmpvals, m_local.m_tmpisnull,
|
||||
GetTableAmRoutine(rel->rd_tam_type));
|
||||
rel->rd_tam_ops);
|
||||
Assert(tmptup != NULL);
|
||||
|
||||
(void)ExecStoreTuple(tmptup, /* tuple to store */
|
||||
|
|
|
@ -121,6 +121,7 @@ void UpdateFusion::InitGlobals()
|
|||
m_global->m_is_bucket_rel = RELATION_OWN_BUCKET(rel);
|
||||
m_global->m_natts = RelationGetDescr(rel)->natts;
|
||||
m_global->m_tupDesc = CreateTupleDescCopy(RelationGetDescr(rel));
|
||||
m_global->m_tupDesc->td_tam_ops = GetTableAmRoutine(m_global->m_table_type);
|
||||
hash_col_num = rel->rd_isblockchain ? 1 : 0;
|
||||
heap_close(rel, AccessShareLock);
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ DfsScanState* ExecInitDfsScan(DfsScan* node, Relation parentHeapRel, EState* est
|
|||
/*
|
||||
* Initialize result tuple type and projection info.
|
||||
*/
|
||||
ExecAssignResultTypeFromTL(&scanState->ps, GetTableAmRoutine(currentRelation->rd_tam_type));
|
||||
ExecAssignResultTypeFromTL(&scanState->ps, currentRelation->rd_tam_ops);
|
||||
|
||||
scanState->ps.vectorized = true;
|
||||
scanState->isPartTbl = node->isPartTbl;
|
||||
|
|
|
@ -255,7 +255,8 @@ void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, cha
|
|||
* heap_attisnull - returns TRUE iff tuple attribute is not present
|
||||
* ----------------
|
||||
*/
|
||||
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupDesc)
|
||||
static FORCE_INLINE
|
||||
bool heap_attisnull_impl(HeapTuple tup, int attnum, TupleDesc tupDesc)
|
||||
{
|
||||
if (attnum > (int)HeapTupleHeaderGetNatts(tup->t_data, tupDesc)) {
|
||||
return true;
|
||||
|
@ -291,6 +292,14 @@ bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupDesc)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupDesc) {
|
||||
return heap_attisnull_impl(tup, attnum, tupDesc);
|
||||
}
|
||||
|
||||
bool heapam_attisnull(Tuple tup, int attnum, TupleDesc tuple_desc) {
|
||||
return heap_attisnull_impl((HeapTuple)tup, attnum, tuple_desc);
|
||||
}
|
||||
|
||||
/* get init default value from tupleDesc.
|
||||
* attrinitdefvals of tupleDesc come from the attrinitdefval of pg_attribute
|
||||
*/
|
||||
|
@ -543,11 +552,13 @@ Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc)
|
|||
* has already determined that the attnum refers to a system attribute.
|
||||
* ----------------
|
||||
*/
|
||||
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
|
||||
static FORCE_INLINE
|
||||
Datum heap_getsysattr_impl(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
|
||||
{
|
||||
Datum result;
|
||||
|
||||
Assert(tup);
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tup)));
|
||||
|
||||
/* Currently, no sys attribute ever reads as NULL. */
|
||||
*isnull = false;
|
||||
|
@ -599,6 +610,14 @@ Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnu
|
|||
return result;
|
||||
}
|
||||
|
||||
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull) {
|
||||
return heap_getsysattr_impl(tup, attnum, tupleDesc, isnull);
|
||||
}
|
||||
|
||||
Datum heapam_getsysattr(Tuple tup, int attnum, TupleDesc tuple_desc, bool* isnull, Buffer buff) {
|
||||
return heap_getsysattr_impl((HeapTuple)tup, attnum, tuple_desc, isnull);
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* heap_copytuple && heapCopyCompressedTuple
|
||||
*
|
||||
|
@ -616,7 +635,8 @@ Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnu
|
|||
* And macro HEAP_COPY_TUPLE are provided, both wrapper for uncompressed and compressed tuples.
|
||||
* ----------------
|
||||
*/
|
||||
HeapTuple heap_copytuple(HeapTuple tuple)
|
||||
static FORCE_INLINE
|
||||
HeapTuple heap_copytuple_impl(HeapTuple tuple)
|
||||
{
|
||||
HeapTuple newTuple;
|
||||
errno_t rc = EOK;
|
||||
|
@ -684,6 +704,15 @@ void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
|
|||
securec_check(rc, "\0", "\0");
|
||||
}
|
||||
|
||||
HeapTuple heap_copytuple(HeapTuple tuple) {
|
||||
return heap_copytuple_impl(tuple);
|
||||
}
|
||||
|
||||
Tuple heapam_copytuple(Tuple tuple) {
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
return heap_copytuple((HeapTuple)tuple);
|
||||
}
|
||||
|
||||
/*
|
||||
* heap_form_tuple
|
||||
* construct a tuple from the given values[] and isnull[] arrays,
|
||||
|
@ -691,7 +720,8 @@ void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
|
|||
*
|
||||
* The result is allocated in the current memory context.
|
||||
*/
|
||||
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
|
||||
static FORCE_INLINE
|
||||
HeapTuple heap_form_tuple_impl(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
|
||||
{
|
||||
HeapTuple tuple; /* return tuple */
|
||||
HeapTupleHeader td; /* tuple data */
|
||||
|
@ -795,6 +825,16 @@ HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull
|
|||
return tuple;
|
||||
}
|
||||
|
||||
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
|
||||
{
|
||||
return heap_form_tuple_impl(tupleDescriptor, values, isnull);
|
||||
}
|
||||
|
||||
Tuple heapam_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
|
||||
{
|
||||
return (Tuple)heap_form_tuple_impl(tupleDescriptor, values, isnull);
|
||||
}
|
||||
|
||||
/*
|
||||
* heap_formtuple
|
||||
*
|
||||
|
@ -836,7 +876,8 @@ HeapTuple heap_formtuple(TupleDesc tupleDescriptor, Datum *values, const char *n
|
|||
*
|
||||
* The result is allocated in the current memory context.
|
||||
*/
|
||||
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, const bool *replIsnull,
|
||||
static FORCE_INLINE
|
||||
HeapTuple heap_modify_tuple_impl(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, const bool *replIsnull,
|
||||
const bool *doReplace)
|
||||
{
|
||||
int numberOfAttributes = tupleDesc->natts;
|
||||
|
@ -895,6 +936,18 @@ HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replVal
|
|||
return newTuple;
|
||||
}
|
||||
|
||||
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, const bool *replIsnull,
|
||||
const bool *doReplace)
|
||||
{
|
||||
return heap_modify_tuple_impl(tuple, tupleDesc, replValues, replIsnull, doReplace);
|
||||
}
|
||||
|
||||
Tuple heapam_modify_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* repl_values, const bool* repl_isnull, const bool* do_replace)
|
||||
{
|
||||
return (Tuple)heap_modify_tuple_impl((HeapTuple)tuple, tuple_desc, repl_values, repl_isnull, do_replace);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* heap_modifytuple
|
||||
*
|
||||
|
@ -945,7 +998,8 @@ HeapTuple heap_modifytuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValu
|
|||
* heap_getattr; the loop will become O(N^2) as soon as any
|
||||
* noncacheable attribute offsets are involved.
|
||||
*/
|
||||
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
|
||||
static FORCE_INLINE void
|
||||
heap_deform_tuple_impl(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
|
||||
{
|
||||
HeapTupleHeader tup = tuple->t_data;
|
||||
bool hasnulls = HeapTupleHasNulls(tuple);
|
||||
|
@ -1049,6 +1103,18 @@ void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool
|
|||
}
|
||||
}
|
||||
|
||||
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
|
||||
{
|
||||
heap_deform_tuple_impl(tuple, tupleDesc, values, isnull);
|
||||
}
|
||||
|
||||
void heapam_deform_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* values, bool* isnull)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
return heap_deform_tuple_impl((HeapTuple)tuple, tuple_desc, values, isnull);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* heap_deformtuple
|
||||
*
|
||||
|
@ -2653,7 +2719,8 @@ HeapTuple heap_form_cmprs_tuple(TupleDesc tupleDescriptor, FormCmprTupleData *cm
|
|||
* heap_getattr; the loop will become O(N^2) as soon as any
|
||||
* noncacheable attribute offsets are involved.
|
||||
*/
|
||||
void heap_deform_cmprs_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, char *cmprsInfo)
|
||||
static FORCE_INLINE void
|
||||
heap_deform_cmprs_tuple_impl(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, char *cmprsInfo)
|
||||
{
|
||||
HeapTupleHeader tup = tuple->t_data;
|
||||
bool hasnulls = HeapTupleHasNulls(tuple);
|
||||
|
@ -2736,7 +2803,21 @@ void heap_deform_cmprs_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values
|
|||
}
|
||||
}
|
||||
|
||||
void heap_deform_tuple2(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer)
|
||||
|
||||
void heap_deform_cmprs_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, char *cmprsInfo)
|
||||
{
|
||||
heap_deform_cmprs_tuple_impl(tuple, tupleDesc, values, isnull, cmprsInfo);
|
||||
}
|
||||
|
||||
void heapam_deform_cmprs_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* values, bool* isnull, char* cmprs_info)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
heap_deform_cmprs_tuple_impl((HeapTuple)tuple, tuple_desc, values, isnull, cmprs_info);
|
||||
}
|
||||
|
||||
|
||||
static FORCE_INLINE void
|
||||
heap_deform_tuple2_impl(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer)
|
||||
{
|
||||
Assert((tuple != NULL) && (tuple->t_data != NULL));
|
||||
if (!HEAP_TUPLE_IS_COMPRESSED(tuple->t_data)) {
|
||||
|
@ -2750,6 +2831,17 @@ void heap_deform_tuple2(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, boo
|
|||
heap_deform_cmprs_tuple(tuple, tupleDesc, values, isnull, (char *)getPageDict(page));
|
||||
}
|
||||
|
||||
void heap_deform_tuple2(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer)
|
||||
{
|
||||
return heap_deform_tuple2_impl(tuple, tupleDesc, values, isnull, buffer);
|
||||
}
|
||||
|
||||
void heapam_deform_tuple2(Tuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
return heap_deform_tuple2_impl((HeapTuple)tuple, tupleDesc, values, isnull, buffer);
|
||||
}
|
||||
|
||||
/* deform the passed heap tuple.
|
||||
* call heap_deform_tuple() if it's not compressed,
|
||||
* otherwise call heap_deform_cmprs_tuple().
|
||||
|
@ -3016,7 +3108,7 @@ void heap_slot_clear(TupleTableSlot *slot)
|
|||
*
|
||||
* @pram slot: slot to be materialized.
|
||||
*/
|
||||
void heap_slot_materialize(TupleTableSlot *slot)
|
||||
HeapTuple heap_slot_materialize(TupleTableSlot *slot)
|
||||
{
|
||||
/*
|
||||
* sanity checks
|
||||
|
@ -3030,7 +3122,7 @@ void heap_slot_materialize(TupleTableSlot *slot)
|
|||
* nothing to do.
|
||||
*/
|
||||
if (slot->tts_tuple && TTS_SHOULDFREE(slot) && !HEAP_TUPLE_IS_COMPRESSED(((HeapTuple)slot->tts_tuple)->t_data))
|
||||
return ;
|
||||
return (HeapTuple)slot->tts_tuple;;
|
||||
|
||||
/*
|
||||
* Otherwise, copy or build a physical tuple, and store it into the slot.
|
||||
|
@ -3077,6 +3169,7 @@ void heap_slot_materialize(TupleTableSlot *slot)
|
|||
slot->tts_dataLen = -1;
|
||||
}
|
||||
#endif
|
||||
return (HeapTuple)slot->tts_tuple;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3325,11 +3418,12 @@ HeapTuple heap_slot_copy_heap_tuple(TupleTableSlot *slot)
|
|||
* @param slot: slot to store tuple.
|
||||
* @param: should_free true if clear the slot's tuple contents by pfree_ext() during ExecClearTuple.
|
||||
*/
|
||||
void heap_slot_store_heap_tuple(HeapTuple tuple, TupleTableSlot* slot, Buffer buffer, bool should_free, bool batchMode)
|
||||
void heap_slot_store_heap_tuple(Tuple tup, TupleTableSlot* slot, Buffer buffer, bool should_free, bool batchMode)
|
||||
{
|
||||
/*
|
||||
* sanity checks
|
||||
*/
|
||||
HeapTuple tuple = HeapTuple(tup);
|
||||
Assert(tuple != NULL);
|
||||
Assert(slot != NULL);
|
||||
Assert(slot->tts_tupleDescriptor != NULL);
|
||||
|
|
|
@ -4142,7 +4142,7 @@ int heap_multi_insert(Relation relation, Relation parent, HeapTuple* tuples, int
|
|||
/* try to insert tuple into mlog-table. */
|
||||
if (relation != NULL && relation->rd_mlogoid != InvalidOid) {
|
||||
/* judge whether need to insert into mlog-table */
|
||||
if (relation->rd_tam_type == TAM_USTORE) {
|
||||
if (relation->rd_tam_ops == TableAmUstore) {
|
||||
heaptup = UHeapToHeap(relation->rd_att, (UHeapTuple)heaptup);
|
||||
}
|
||||
insert_into_mlog_table(relation, relation->rd_mlogoid,
|
||||
|
|
|
@ -746,7 +746,7 @@ bool IndexGetnextSlot(IndexScanDesc scan, ScanDirection direction, TupleTableSlo
|
|||
ItemPointer tid;
|
||||
TupleTableSlot* tmpslot = NULL;
|
||||
tmpslot = MakeSingleTupleTableSlot(RelationGetDescr(scan->heapRelation),
|
||||
false, GetTableAmRoutine(scan->heapRelation->rd_tam_type));
|
||||
false, scan->heapRelation->rd_tam_ops);
|
||||
for (;;) {
|
||||
/* IO collector and IO scheduler */
|
||||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
|
|
|
@ -51,192 +51,13 @@
|
|||
#include "access/ustore/knl_utuple.h"
|
||||
#include "access/ustore/knl_uvisibility.h"
|
||||
|
||||
bool tableam_tops_page_get_item(Relation rel, Tuple tuple, Page page,
|
||||
OffsetNumber tupleNo, BlockNumber destBlocks)
|
||||
{
|
||||
return g_tableam_routines[rel->rd_tam_type]->tops_page_get_item(rel, tuple, page, tupleNo, destBlocks);
|
||||
}
|
||||
OffsetNumber tableam_tops_page_get_max_offsetnumber(Relation rel, Page page)
|
||||
{
|
||||
return g_tableam_routines[rel->rd_tam_type]->tops_page_get_max_offsetnumber(page);
|
||||
}
|
||||
Size tableam_tops_page_get_freespace(Relation rel, Page page)
|
||||
{
|
||||
return g_tableam_routines[rel->rd_tam_type]->tops_page_get_freespace(page);
|
||||
}
|
||||
bool tableam_tops_tuple_fetch_row_version(TidScanState* node, Relation relation, ItemPointer tid,
|
||||
Snapshot snapshot, TupleTableSlot *slot)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tops_tuple_fetch_row_version(node, relation, tid, snapshot, slot);
|
||||
}
|
||||
|
||||
Tuple tableam_tops_copy_tuple(Tuple tuple)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_copy_tuple(tuple);
|
||||
}
|
||||
|
||||
MinimalTuple tableam_tops_copy_minimal_tuple(MinimalTuple mtup)
|
||||
{
|
||||
return heap_copy_minimal_tuple(mtup);
|
||||
}
|
||||
|
||||
void tableam_tops_free_minimal_tuple(MinimalTuple mtup)
|
||||
{
|
||||
heap_free_minimal_tuple(mtup);
|
||||
}
|
||||
|
||||
Tuple tableam_tops_new_tuple(Relation relation, ItemPointer tid)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tops_new_tuple(relation, tid);
|
||||
}
|
||||
|
||||
TransactionId tableam_tops_get_conflictXid(Relation relation, Tuple tup)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tops_get_conflictXid(tup);
|
||||
}
|
||||
|
||||
void tableam_tops_destroy_tuple(Relation relation, Tuple tuple)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tops_destroy_tuple(tuple);
|
||||
}
|
||||
|
||||
void tableam_tops_add_to_bulk_insert_select(Relation relation, CopyFromBulk bulk, Tuple tup,
|
||||
bool needCopy)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tops_add_to_bulk_insert_select(bulk, tup, needCopy);
|
||||
}
|
||||
|
||||
void tableam_tops_add_to_bulk(Relation relation,
|
||||
CopyFromBulk bulk, Tuple tup, bool needCopy)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tops_add_to_bulk(bulk, tup, needCopy);
|
||||
}
|
||||
|
||||
ItemPointer tableam_tops_get_t_self(Relation relation, Tuple tup)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tops_get_t_self(tup);
|
||||
}
|
||||
|
||||
void tableam_tops_exec_delete_index_tuples(TupleTableSlot *slot, Relation relation,
|
||||
ModifyTableState *node, ItemPointer tupleid, ExecIndexTuplesState exec_index_tuples_state,
|
||||
Bitmapset *modifiedIdxAttrs)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tops_exec_delete_index_tuples(slot, relation, node, tupleid,
|
||||
exec_index_tuples_state, modifiedIdxAttrs);
|
||||
}
|
||||
|
||||
List *tableam_tops_exec_update_index_tuples(TupleTableSlot *slot, TupleTableSlot *oldslot,
|
||||
Relation relation, ModifyTableState *node, Tuple tuple, ItemPointer tupleid,
|
||||
ExecIndexTuplesState exec_index_tuples_state, int2 bucketid, Bitmapset *modifiedIdxAttrs)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tops_exec_update_index_tuples(slot, oldslot, relation, node,
|
||||
tuple, tupleid, exec_index_tuples_state, bucketid, modifiedIdxAttrs);
|
||||
}
|
||||
|
||||
uint32 tableam_tops_get_tuple_type(Relation relation)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tops_get_tuple_type();
|
||||
}
|
||||
|
||||
void tableam_tops_copy_from_insert_batch(Relation rel, EState* estate, CommandId mycid, int hiOptions,
|
||||
ResultRelInfo* resultRelInfo, TupleTableSlot* myslot, BulkInsertState bistate, int nBufferedTuples,
|
||||
Tuple* bufferedTuples, Partition partition, int2 bucketId)
|
||||
{
|
||||
g_tableam_routines[rel->rd_tam_type]->tops_copy_from_insert_batch(rel, estate, mycid, hiOptions, resultRelInfo,
|
||||
myslot, bistate, nBufferedTuples, bufferedTuples, partition, bucketId);
|
||||
}
|
||||
|
||||
void tableam_tops_update_tuple_with_oid(Relation relation, Tuple tup, TupleTableSlot *slot)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tops_update_tuple_with_oid(relation, tup, slot);
|
||||
}
|
||||
|
||||
Datum HeapamTopsTupleFastGetattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null)
|
||||
static Datum heapam_fastgetattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null)
|
||||
{
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return fastgetattr((HeapTuple)tuple, att_num, tuple_desc, is_null);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* DQL AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
bool tableam_tuple_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf,
|
||||
bool keep_buf, Relation stats_relation)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_fetch(relation, snapshot, tuple, userbuf, keep_buf,
|
||||
stats_relation);
|
||||
}
|
||||
|
||||
bool tableam_tuple_satisfies_snapshot(Relation relation, HeapTuple tuple, Snapshot snapshot,
|
||||
Buffer buffer)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_satisfies_snapshot(relation, tuple, snapshot, buffer);
|
||||
}
|
||||
|
||||
void tableam_tuple_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_get_latest_tid(relation, snapshot, tid);
|
||||
}
|
||||
|
||||
Oid tableam_tuple_insert(Relation relation, Tuple tup, CommandId cid, int options,
|
||||
struct BulkInsertStateData *bistate)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_insert(relation, tup, cid, options, bistate);
|
||||
}
|
||||
|
||||
int tableam_tuple_multi_insert(Relation relation, Relation parent, Tuple *tuples, int ntuples,
|
||||
CommandId cid, int options, struct BulkInsertStateData *bistate, HeapMultiInsertExtraArgs *args)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_multi_insert(relation, parent, tuples, ntuples, cid,
|
||||
options, bistate, args);
|
||||
}
|
||||
|
||||
TM_Result tableam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid, Snapshot crosscheck,
|
||||
Snapshot snapshot, bool wait, TupleTableSlot **oldslot, TM_FailureData *tmfd, bool allow_delete_self)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_delete(relation, tid, cid, crosscheck, snapshot, wait,
|
||||
oldslot, tmfd, allow_delete_self);
|
||||
}
|
||||
|
||||
|
||||
TM_Result tableam_tuple_update(Relation relation, Relation parentRelation, ItemPointer otid, Tuple newtup,
|
||||
CommandId cid, Snapshot crosscheck, Snapshot snapshot, bool wait, TupleTableSlot **oldslot, TM_FailureData *tmfd,
|
||||
bool *update_indexes, Bitmapset **modifiedIdxAttrs, bool allow_update_self,
|
||||
bool allow_inplace_update, LockTupleMode *lockmode)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_update(relation, parentRelation, otid, newtup, cid,
|
||||
crosscheck, snapshot, wait, oldslot, tmfd, lockmode, update_indexes, modifiedIdxAttrs, allow_update_self,
|
||||
allow_inplace_update);
|
||||
}
|
||||
|
||||
TM_Result tableam_tuple_lock(Relation relation, Tuple tuple, Buffer *buffer, CommandId cid,
|
||||
LockTupleMode mode, bool nowait, TM_FailureData *tmfd, bool allow_lock_self, bool follow_updates, bool eval,
|
||||
Snapshot snapshot, ItemPointer tid, bool isSelectForUpdate, bool isUpsert, TransactionId conflictXid,
|
||||
int waitSec)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tuple_lock(relation, tuple, buffer, cid, mode, nowait, tmfd,
|
||||
allow_lock_self, follow_updates, eval, snapshot, tid, isSelectForUpdate, isUpsert, conflictXid,
|
||||
waitSec);
|
||||
}
|
||||
|
||||
Tuple tableam_tuple_lock_updated(CommandId cid, Relation relation, int lockmode, ItemPointer tid,
|
||||
TransactionId priorXmax, Snapshot snapshot, bool isSelectForUpdate)
|
||||
{
|
||||
return (Tuple)g_tableam_routines[relation->rd_tam_type]->tuple_lock_updated(cid, relation, lockmode, tid, priorXmax,
|
||||
snapshot, isSelectForUpdate);
|
||||
}
|
||||
|
||||
void tableam_tuple_check_visible(Relation relation, Snapshot snapshot, Tuple tuple, Buffer buffer)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tuple_check_visible(snapshot, tuple, buffer);
|
||||
}
|
||||
|
||||
void tableam_tuple_abort_speculative(Relation relation, Tuple tuple)
|
||||
{
|
||||
g_tableam_routines[relation->rd_tam_type]->tuple_abort_speculative(relation, tuple);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* SCAN AM APIS FOR HEAP
|
||||
* ------------------------------------------------------------------------
|
||||
|
@ -247,127 +68,21 @@ IndexFetchTableData *tableam_scan_index_fetch_begin(Relation rel)
|
|||
return HeapamScanIndexFetchBegin(rel);
|
||||
}
|
||||
|
||||
void tableam_scan_index_fetch_reset(IndexFetchTableData *scan)
|
||||
{
|
||||
heapam_index_fetch_reset(scan);
|
||||
}
|
||||
|
||||
void tableam_scan_index_fetch_end(IndexFetchTableData *scan)
|
||||
{
|
||||
HeapamScanIndexFetchEnd(scan);
|
||||
}
|
||||
|
||||
Tuple tableam_scan_index_fetch_tuple(IndexScanDesc scan, bool *all_dead)
|
||||
{
|
||||
return g_tableam_routines[scan->heapRelation->rd_tam_type]->scan_index_fetch_tuple(scan, all_dead);
|
||||
}
|
||||
|
||||
TableScanDesc tableam_scan_begin(Relation relation, Snapshot snapshot, int nkeys, ScanKey key,
|
||||
RangeScanInRedis rangeScanInRedis)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->scan_begin(relation, snapshot, nkeys, key, rangeScanInRedis);
|
||||
}
|
||||
|
||||
TableScanDesc tableam_scan_begin_bm(Relation relation, Snapshot snapshot, int nkeys, ScanKey key)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->scan_begin_bm(relation, snapshot, nkeys, key);
|
||||
}
|
||||
|
||||
TableScanDesc tableam_scan_begin_sampling(Relation relation, Snapshot snapshot, int nkeys, ScanKey key,
|
||||
bool allow_strat, bool allow_sync, RangeScanInRedis rangeScanInRedis)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->scan_begin_sampling(relation, snapshot, nkeys, key, allow_strat,
|
||||
allow_sync, rangeScanInRedis);
|
||||
}
|
||||
|
||||
Tuple tableam_scan_getnexttuple(TableScanDesc sscan, ScanDirection direction)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_getnexttuple(sscan, direction);
|
||||
}
|
||||
|
||||
bool tableam_scan_gettuplebatchmode(TableScanDesc sscan, ScanDirection direction)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_GetNextBatch(sscan, direction);
|
||||
}
|
||||
|
||||
void tableam_scan_getpage(TableScanDesc sscan, BlockNumber page)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_getpage(sscan, page);
|
||||
}
|
||||
|
||||
Tuple tableam_scan_gettuple_for_verify(TableScanDesc sscan, ScanDirection direction, bool isValidRelationPage)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_gettuple_for_verify(sscan,
|
||||
direction, isValidRelationPage);
|
||||
}
|
||||
|
||||
void tableam_scan_end(TableScanDesc sscan)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_end(sscan);
|
||||
}
|
||||
|
||||
void tableam_scan_rescan(TableScanDesc sscan, ScanKey key)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_rescan(sscan, key);
|
||||
}
|
||||
|
||||
void tableam_scan_restrpos(TableScanDesc sscan)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_restrpos(sscan);
|
||||
}
|
||||
|
||||
void tableam_scan_markpos(TableScanDesc sscan)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_markpos(sscan);
|
||||
}
|
||||
|
||||
void tableam_scan_init_parallel_seqscan(TableScanDesc sscan, int32 dop, ScanDirection dir)
|
||||
{
|
||||
return g_tableam_routines[sscan->rs_rd->rd_tam_type]->scan_init_parallel_seqscan(sscan, dop, dir);
|
||||
}
|
||||
|
||||
double tableam_index_build_scan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo,
|
||||
bool allow_sync, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
|
||||
{
|
||||
return g_tableam_routines[heapRelation->rd_tam_type]->index_build_scan(heapRelation, indexRelation, indexInfo,
|
||||
allow_sync, callback, callback_state, scan);
|
||||
}
|
||||
|
||||
|
||||
void tableam_index_validate_scan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo,
|
||||
Snapshot snapshot, v_i_state *state)
|
||||
{
|
||||
return g_tableam_routines[heapRelation->rd_tam_type]->index_validate_scan(heapRelation, indexRelation, indexInfo,
|
||||
snapshot, state);
|
||||
}
|
||||
|
||||
double tableam_relation_copy_for_cluster(Relation OldHeap, Relation OldIndex, Relation NewHeap,
|
||||
TransactionId OldestXmin, TransactionId FreezeXid, bool verbose, bool use_sort, AdaptMem *memUsage)
|
||||
{
|
||||
return g_tableam_routines[OldHeap->rd_tam_type]->relation_copy_for_cluster(OldHeap, OldIndex, NewHeap, OldestXmin,
|
||||
FreezeXid, verbose, use_sort, memUsage);
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of heap accessor methods.
|
||||
*/
|
||||
|
||||
Datum HeapamTopsGetsysattr(Tuple tup, int attnum, TupleDesc tuple_desc, bool* isnull, Buffer buff) {
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tup)));
|
||||
return heap_getsysattr((HeapTuple)tup, attnum, tuple_desc, isnull);
|
||||
}
|
||||
|
||||
Datum HeapamTopsTupleGetattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool* is_null)
|
||||
static Datum heapam_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool* is_null)
|
||||
{
|
||||
return heap_getattr((HeapTuple)tuple, att_num, tuple_desc, is_null);
|
||||
}
|
||||
|
||||
bool HeapamTopsTupleAttisnull(Tuple tup, int attnum, TupleDesc tuple_desc)
|
||||
{
|
||||
return heap_attisnull((HeapTuple)tup, attnum, tuple_desc);
|
||||
}
|
||||
|
||||
bool HeapamTopsPageGetItem(Relation rel, Tuple tuple, Page page, OffsetNumber tupleNo, BlockNumber destBlocks)
|
||||
static bool HeapamTopsPageGetItem(Relation rel, Tuple tuple, Page page, OffsetNumber tupleNo, BlockNumber destBlocks)
|
||||
{
|
||||
HeapTupleHeader tupleHeader = NULL;
|
||||
ItemId tupleItem = NULL;
|
||||
|
@ -387,13 +102,7 @@ bool HeapamTopsPageGetItem(Relation rel, Tuple tuple, Page page, OffsetNumber tu
|
|||
return true;
|
||||
}
|
||||
|
||||
Tuple HeapamTopsCopyTuple(Tuple tuple)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
return heap_copytuple((HeapTuple)tuple);
|
||||
}
|
||||
|
||||
Tuple HeapamTopsNewTuple(Relation relation, ItemPointer tid)
|
||||
static Tuple HeapamTopsNewTuple(Relation relation, ItemPointer tid)
|
||||
{
|
||||
HeapTuple tuple = heaptup_alloc(HEAPTUPLESIZE);
|
||||
tuple->t_data = NULL;
|
||||
|
@ -403,12 +112,12 @@ Tuple HeapamTopsNewTuple(Relation relation, ItemPointer tid)
|
|||
return (Tuple)tuple;
|
||||
}
|
||||
|
||||
TransactionId HeapamTopsGetConflictXid(Tuple tup)
|
||||
static TransactionId HeapamTopsGetConflictXid(Tuple tup)
|
||||
{
|
||||
return InvalidTransactionId;
|
||||
}
|
||||
|
||||
void HeapamTopsDestroyTuple(Tuple tuple)
|
||||
static void HeapamTopsDestroyTuple(Tuple tuple)
|
||||
{
|
||||
HeapTuple tup = (HeapTuple)tuple;
|
||||
if (tup->tupInfo == 1) {
|
||||
|
@ -417,27 +126,17 @@ void HeapamTopsDestroyTuple(Tuple tuple)
|
|||
pfree_ext(tup);
|
||||
}
|
||||
|
||||
void HeapamTopsAddToBulkInsertSelect(CopyFromBulk bulk, Tuple tup, bool needCopy)
|
||||
{
|
||||
HeapAddToBulkInsertSelect(bulk, tup, needCopy);
|
||||
}
|
||||
|
||||
void HeapamTopsAddToBulk(CopyFromBulk bulk, Tuple tup, bool needCopy)
|
||||
{
|
||||
HeapAddToBulk(bulk, tup, needCopy);
|
||||
}
|
||||
|
||||
void HeapamTopsUpdateTupleWithOid (Relation rel, Tuple tuple, TupleTableSlot *slot)
|
||||
static void HeapamTopsUpdateTupleWithOid (Relation rel, Tuple tuple, TupleTableSlot *slot)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemPointer HeapamTopsGetTSelf(Tuple tup)
|
||||
static ItemPointer HeapamTopsGetTSelf(Tuple tup)
|
||||
{
|
||||
return &(((HeapTuple)tup)->t_self);
|
||||
}
|
||||
|
||||
void HeapamTopsExecDeleteIndexTuples(TupleTableSlot *slot, Relation relation, ModifyTableState *node,
|
||||
static void HeapamTopsExecDeleteIndexTuples(TupleTableSlot *slot, Relation relation, ModifyTableState *node,
|
||||
ItemPointer tupleid, ExecIndexTuplesState exec_index_tuples_state, Bitmapset *modifiedIdxAttrs)
|
||||
{
|
||||
return;
|
||||
|
@ -457,7 +156,7 @@ List *HeapamTopsExecUpdateIndexTuples(TupleTableSlot *slot, TupleTableSlot *olds
|
|||
return recheckIndexes;
|
||||
}
|
||||
|
||||
uint32 HeapamTopsGetTupleType()
|
||||
static uint32 HeapamTopsGetTupleType()
|
||||
{
|
||||
return HEAP_TUPLE;
|
||||
}
|
||||
|
@ -470,132 +169,7 @@ void HeapamTopsCopyFromInsertBatch(Relation rel, EState* estate, CommandId mycid
|
|||
(HeapTuple*) bufferedTuples, partition, bucketId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears the contents of the table slot that contains heap table tuple data.
|
||||
*/
|
||||
void HeapamTslotClear(TupleTableSlot *slot)
|
||||
{
|
||||
return heap_slot_clear(slot);
|
||||
}
|
||||
|
||||
HeapTuple HeapamTslotMaterialize(TupleTableSlot *slot)
|
||||
{
|
||||
heap_slot_materialize(slot);
|
||||
return (HeapTuple)slot->tts_tuple;
|
||||
}
|
||||
|
||||
MinimalTuple HeapamTslotGetMinimalTuple(TupleTableSlot *slot)
|
||||
{
|
||||
return heap_slot_get_minimal_tuple(slot);
|
||||
}
|
||||
|
||||
MinimalTuple HeapamTslotCopyMinimalTuple(TupleTableSlot *slot)
|
||||
{
|
||||
return heap_slot_copy_minimal_tuple(slot);
|
||||
}
|
||||
|
||||
void HeapamTslotStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
|
||||
{
|
||||
heap_slot_store_minimal_tuple(mtup, slot, shouldFree);
|
||||
}
|
||||
|
||||
HeapTuple HeapamTslotGetHeapTuple(TupleTableSlot* slot)
|
||||
{
|
||||
return heap_slot_get_heap_tuple(slot);
|
||||
}
|
||||
|
||||
HeapTuple HeapamTslotCopyHeapTuple(TupleTableSlot *slot)
|
||||
{
|
||||
return heap_slot_copy_heap_tuple(slot);
|
||||
}
|
||||
|
||||
void HeapamTslotStoreHeapTuple(Tuple tuple, TupleTableSlot* slot, Buffer buffer, bool shouldFree, bool batchMode)
|
||||
{
|
||||
heap_slot_store_heap_tuple((HeapTuple)tuple, slot, buffer, shouldFree, batchMode);
|
||||
}
|
||||
|
||||
void HeapamTslotGetsomeattrs(TupleTableSlot *slot, int natts)
|
||||
{
|
||||
heap_slot_getsomeattrs(slot, natts);
|
||||
}
|
||||
|
||||
void HeapamTslotFormBatch(TupleTableSlot *slot, VectorBatch* batch, int cur_rows, int natts)
|
||||
{
|
||||
heap_slot_formbatch(slot, batch, cur_rows, natts);
|
||||
}
|
||||
|
||||
Datum HeapamTslotGetattr(TupleTableSlot* slot, int attnum, bool* isnull)
|
||||
{
|
||||
return heap_slot_getattr(slot, attnum, isnull);
|
||||
}
|
||||
|
||||
void HeapamTslotGetallattrs(TupleTableSlot* slot)
|
||||
{
|
||||
heap_slot_getallattrs(slot);
|
||||
}
|
||||
|
||||
bool HeapamTslotAttisnull(TupleTableSlot* slot, int attnum)
|
||||
{
|
||||
return heap_slot_attisnull(slot, attnum);
|
||||
}
|
||||
|
||||
FORCE_INLINE Tuple HeapamTslotGetTupleFromSlot(TupleTableSlot* slot)
|
||||
{
|
||||
HeapTuple tuple = ExecMaterializeSlot(slot);
|
||||
tuple->tupInfo = 0;
|
||||
return (Tuple) tuple;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* TABLE TUPLE AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MinimalTuple HeapamTopsFormMinimalTuple(
|
||||
TupleDesc tuple_descriptor, Datum* values, const bool* isnull, MinimalTuple in_tuple)
|
||||
{
|
||||
return heap_form_minimal_tuple(tuple_descriptor, values, isnull, in_tuple);
|
||||
}
|
||||
|
||||
Tuple HeapamTopsFormTuple(TupleDesc tuple_descriptor, Datum* values, bool* isnull)
|
||||
{
|
||||
return (Tuple)heap_form_tuple(tuple_descriptor, values, isnull);
|
||||
}
|
||||
|
||||
HeapTuple HeapamTopsFormCmprsTuple(TupleDesc tuple_descriptor, FormCmprTupleData* cmprs_info)
|
||||
{
|
||||
return heap_form_cmprs_tuple(tuple_descriptor, cmprs_info);
|
||||
}
|
||||
|
||||
void HeapamTopsDeformTuple(Tuple tuple, TupleDesc tuple_desc, Datum* values, bool* isnull)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
return heap_deform_tuple((HeapTuple)tuple, tuple_desc, values, isnull);
|
||||
}
|
||||
|
||||
void HeapamTopsDeformTuple2(Tuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
return heap_deform_tuple2((HeapTuple)tuple, tupleDesc, values, isnull, buffer);
|
||||
}
|
||||
|
||||
void HeapamTopsDeformCmprsTuple(Tuple tuple, TupleDesc tuple_desc, Datum* values, bool* isnull, char* cmprs_info)
|
||||
{
|
||||
Assert(TUPLE_IS_HEAP_TUPLE(HeapTuple(tuple)));
|
||||
heap_deform_cmprs_tuple((HeapTuple)tuple, tuple_desc, values, isnull, cmprs_info);
|
||||
}
|
||||
|
||||
void HeapamTopsFillTuple(TupleDesc tuple_desc, Datum* values, const bool* isnull, char* data, Size data_size, uint16* infomask, bits8* bit)
|
||||
{
|
||||
heap_fill_tuple(tuple_desc, values, isnull, data, data_size, infomask, bit);
|
||||
}
|
||||
|
||||
Tuple HeapamTopsModifyTuple(Tuple tuple, TupleDesc tuple_desc, Datum* repl_values, const bool* repl_isnull, const bool* do_replace)
|
||||
{
|
||||
return (Tuple)heap_modify_tuple((HeapTuple)tuple, tuple_desc, repl_values, repl_isnull, do_replace);
|
||||
}
|
||||
|
||||
Tuple HeapamTopsOpFusionModifyTuple(Tuple tuple, TupleDesc tuple_desc, Datum* repl_values,
|
||||
Tuple heapam_opfusion_modify_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* repl_values,
|
||||
bool* repl_isnull, UpdateFusion* opf)
|
||||
{
|
||||
Tuple newTuple;
|
||||
|
@ -840,45 +414,45 @@ static const TableAmRoutine g_heapam_methods = {
|
|||
* TABLE SLOT AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
tslot_clear : HeapamTslotClear,
|
||||
tslot_materialize : HeapamTslotMaterialize,
|
||||
tslot_get_minimal_tuple : HeapamTslotGetMinimalTuple,
|
||||
tslot_copy_minimal_tuple : HeapamTslotCopyMinimalTuple,
|
||||
tslot_store_minimal_tuple : HeapamTslotStoreMinimalTuple,
|
||||
tslot_get_heap_tuple : HeapamTslotGetHeapTuple,
|
||||
tslot_copy_heap_tuple : HeapamTslotCopyHeapTuple,
|
||||
tslot_store_tuple : HeapamTslotStoreHeapTuple,
|
||||
tslot_getsomeattrs : HeapamTslotGetsomeattrs,
|
||||
tslot_formbatch : HeapamTslotFormBatch,
|
||||
tslot_getattr : HeapamTslotGetattr,
|
||||
tslot_getallattrs : HeapamTslotGetallattrs,
|
||||
tslot_attisnull : HeapamTslotAttisnull,
|
||||
tslot_get_tuple_from_slot : HeapamTslotGetTupleFromSlot,
|
||||
tslot_clear : heap_slot_clear,
|
||||
tslot_materialize : heap_slot_materialize,
|
||||
tslot_get_minimal_tuple : heap_slot_get_minimal_tuple,
|
||||
tslot_copy_minimal_tuple : heap_slot_copy_minimal_tuple,
|
||||
tslot_store_minimal_tuple : heap_slot_store_minimal_tuple,
|
||||
tslot_get_heap_tuple : heap_slot_get_heap_tuple,
|
||||
tslot_copy_heap_tuple : heap_slot_copy_heap_tuple,
|
||||
tslot_store_tuple : heap_slot_store_heap_tuple,
|
||||
tslot_getsomeattrs : heap_slot_getsomeattrs,
|
||||
tslot_formbatch : heap_slot_formbatch,
|
||||
tslot_getattr : heap_slot_getattr,
|
||||
tslot_getallattrs : heap_slot_getallattrs,
|
||||
tslot_attisnull : heap_slot_attisnull,
|
||||
tslot_get_tuple_from_slot : heap_slot_get_tuple_from_slot,
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* TABLE TUPLE AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
tops_getsysattr : HeapamTopsGetsysattr,
|
||||
tops_form_minimal_tuple : HeapamTopsFormMinimalTuple,
|
||||
tops_form_tuple : HeapamTopsFormTuple,
|
||||
tops_form_cmprs_tuple : HeapamTopsFormCmprsTuple,
|
||||
tops_deform_tuple : HeapamTopsDeformTuple,
|
||||
tops_deform_tuple2 : HeapamTopsDeformTuple2,
|
||||
tops_deform_cmprs_tuple : HeapamTopsDeformCmprsTuple,
|
||||
tops_fill_tuple : HeapamTopsFillTuple,
|
||||
tops_modify_tuple : HeapamTopsModifyTuple,
|
||||
tops_opfusion_modify_tuple : HeapamTopsOpFusionModifyTuple,
|
||||
tops_tuple_getattr : HeapamTopsTupleGetattr,
|
||||
tops_tuple_fast_getattr : HeapamTopsTupleFastGetattr,
|
||||
tops_tuple_attisnull : HeapamTopsTupleAttisnull,
|
||||
tops_copy_tuple : HeapamTopsCopyTuple,
|
||||
tops_getsysattr : heapam_getsysattr,
|
||||
tops_form_minimal_tuple : heap_form_minimal_tuple,
|
||||
tops_form_tuple : heapam_form_tuple,
|
||||
tops_form_cmprs_tuple : heap_form_cmprs_tuple,
|
||||
tops_deform_tuple : heapam_deform_tuple,
|
||||
tops_deform_tuple2 : heapam_deform_tuple2,
|
||||
tops_deform_cmprs_tuple : heapam_deform_cmprs_tuple,
|
||||
tops_fill_tuple : heap_fill_tuple,
|
||||
tops_modify_tuple : heapam_modify_tuple,
|
||||
tops_opfusion_modify_tuple : heapam_opfusion_modify_tuple,
|
||||
tops_tuple_getattr : heapam_getattr,
|
||||
tops_tuple_fast_getattr : heapam_fastgetattr,
|
||||
tops_tuple_attisnull : heapam_attisnull,
|
||||
tops_copy_tuple : heapam_copytuple,
|
||||
tops_new_tuple : HeapamTopsNewTuple,
|
||||
tops_get_conflictXid : HeapamTopsGetConflictXid,
|
||||
tops_destroy_tuple : HeapamTopsDestroyTuple,
|
||||
tops_add_to_bulk_insert_select : HeapamTopsAddToBulkInsertSelect,
|
||||
tops_add_to_bulk : HeapamTopsAddToBulk,
|
||||
tops_add_to_bulk_insert_select : HeapAddToBulkInsertSelect,
|
||||
tops_add_to_bulk : HeapAddToBulk,
|
||||
tops_update_tuple_with_oid : HeapamTopsUpdateTupleWithOid,
|
||||
tops_get_t_self : HeapamTopsGetTSelf,
|
||||
tops_exec_delete_index_tuples : HeapamTopsExecDeleteIndexTuples,
|
||||
|
@ -1003,7 +577,7 @@ void UHeapamTslotGetsomeattrs(TupleTableSlot *slot, int natts)
|
|||
UHeapSlotGetSomeAttrs(slot, natts);
|
||||
}
|
||||
|
||||
void UHeapamTslotGetallattrs(TupleTableSlot *slot)
|
||||
void UHeapamTslotGetallattrs(TupleTableSlot *slot, bool need_transform_anyarray)
|
||||
{
|
||||
UHeapSlotGetAllAttrs(slot);
|
||||
}
|
||||
|
@ -1013,7 +587,7 @@ void UHeapamTslotFormBatch(TupleTableSlot *slot, VectorBatch* batch, int cur_row
|
|||
UHeapSlotFormBatch(slot, batch, cur_rows, natts);
|
||||
}
|
||||
|
||||
Datum UHeapamTslotGetattr(TupleTableSlot *slot, int attnum, bool *isnull)
|
||||
Datum UHeapamTslotGetattr(TupleTableSlot *slot, int attnum, bool *isnull, bool need_transform_anyarray)
|
||||
{
|
||||
return UHeapSlotGetAttr(slot, attnum, isnull);
|
||||
}
|
||||
|
@ -1563,7 +1137,7 @@ static const TableAmRoutine g_ustoream_methods = {
|
|||
tops_deform_tuple : UHeapamTopsDeformTuple,
|
||||
tops_deform_tuple2 : UHeapamTopsDeformTuple2,
|
||||
tops_deform_cmprs_tuple : UHeapamTopsDeformCmprsTuple, /* Not implemented yet */
|
||||
tops_fill_tuple : HeapamTopsFillTuple, /* Not implemented yet */
|
||||
tops_fill_tuple : heap_fill_tuple, /* Not implemented yet */
|
||||
tops_modify_tuple : UHeapamTopsModifyTuple,
|
||||
tops_opfusion_modify_tuple : UHeapamTopsOpFusionModifyTuple,
|
||||
tops_tuple_getattr : UHeapamTopsTupleGetattr,
|
||||
|
@ -1648,4 +1222,4 @@ const TableAmRoutine * const g_tableam_routines[] = {
|
|||
};
|
||||
|
||||
const TableAmRoutine* TableAmHeap = &g_heapam_methods;
|
||||
const TableAmRoutine* TableAmUstore = &g_ustoream_methods;
|
||||
const TableAmRoutine* TableAmUstore = &g_ustoream_methods;
|
||||
|
|
|
@ -731,7 +731,7 @@ static void UHeapinitscan(TableScanDesc sscan, ScanKey key, bool isRescan)
|
|||
scan->rs_base.rs_cbuf = InvalidBuffer;
|
||||
scan->rs_base.rs_cblock = InvalidBlockNumber;
|
||||
|
||||
if (scan->rs_base.rs_rd->rd_tam_type == TAM_USTORE) {
|
||||
if (scan->rs_base.rs_rd->rd_tam_ops == TableAmUstore) {
|
||||
scan->rs_base.lastVar = -1;
|
||||
scan->rs_base.boolArr = NULL;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ Oid UHeapGetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn
|
|||
ScanKeyData key;
|
||||
bool collides = false;
|
||||
Assert(RelationIsUstoreFormat(relation) || RelationIsToast(relation));
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(relation), false, GetTableAmRoutine(relation->rd_tam_type));
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(relation), false, relation->rd_tam_ops);
|
||||
/* Generate new OIDs until we find one not in the table */
|
||||
do {
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
@ -898,7 +898,7 @@ static void UHeapToastDeleteDatum(Relation rel, Datum value, int options)
|
|||
/* The toast table of ustore table should also be of ustore type */
|
||||
Assert(RelationIsUstoreFormat(toastrel));
|
||||
/* should index must be ustore format ? */
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, GetTableAmRoutine(toastrel->rd_tam_type));
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, toastrel->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* Setup a scan key to find chunks with matching va_valueid
|
||||
|
@ -961,7 +961,7 @@ struct varlena *UHeapInternalToastFetchDatum(struct varatt_external toastPointer
|
|||
SET_VARSIZE(result, ressize + VARHDRSZ);
|
||||
|
||||
toastTupDesc = toastrel->rd_att;
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, GetTableAmRoutine(toastrel->rd_tam_type));
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, toastrel->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* Setup a scan key to fetch from the index by va_valueid
|
||||
|
@ -1133,7 +1133,7 @@ struct varlena *UHeapInternalToastFetchDatumSlice(struct varatt_external toastPo
|
|||
* Open the toast relation and its index
|
||||
*/
|
||||
toastTupDesc = toastrel->rd_att;
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, GetTableAmRoutine(toastrel->rd_tam_type));
|
||||
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, toastrel->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* Setup a scan key to fetch from the index. This is either two keys or
|
||||
|
@ -1268,7 +1268,7 @@ static bool UHeapToastRelValueidExists(Relation toastrel, Oid valueid)
|
|||
SysScanDesc toastscan;
|
||||
TupleTableSlot *slot = NULL;
|
||||
Assert(RelationIsUstoreFormat(toastrel));
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, GetTableAmRoutine(toastrel->rd_tam_type));
|
||||
slot = MakeSingleTupleTableSlot(RelationGetDescr(toastrel), false, toastrel->rd_tam_ops);
|
||||
|
||||
/*
|
||||
* Setup a scan key to find chunks with matching va_valueid
|
||||
|
|
|
@ -176,7 +176,7 @@ static EState *create_estate_for_relation(LogicalRepRelMapEntry *rel)
|
|||
|
||||
/* Triggers might need a slot */
|
||||
if (resultRelInfo->ri_TrigDesc)
|
||||
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(rel->localrel->rd_tam_type));
|
||||
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate, rel->localrel->rd_tam_ops);
|
||||
|
||||
/* Prepare to catch AFTER triggers. */
|
||||
AfterTriggerBeginQuery();
|
||||
|
@ -558,7 +558,7 @@ static void apply_handle_insert(StringInfo s)
|
|||
|
||||
/* Initialize the executor state. */
|
||||
estate = create_estate_for_relation(rel);
|
||||
remoteslot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(rel->localrel->rd_tam_type));
|
||||
remoteslot = ExecInitExtraTupleSlot(estate, rel->localrel->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(remoteslot, RelationGetDescr(rel->localrel));
|
||||
|
||||
/* Input functions may need an active snapshot, so get one */
|
||||
|
@ -676,9 +676,9 @@ static void apply_handle_update(StringInfo s)
|
|||
|
||||
/* Initialize the executor state. */
|
||||
estate = create_estate_for_relation(rel);
|
||||
remoteslot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(rel->localrel->rd_tam_type));
|
||||
remoteslot = ExecInitExtraTupleSlot(estate, rel->localrel->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(remoteslot, RelationGetDescr(rel->localrel));
|
||||
localslot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(rel->localrel->rd_tam_type));
|
||||
localslot = ExecInitExtraTupleSlot(estate, rel->localrel->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(localslot, RelationGetDescr(rel->localrel));
|
||||
EvalPlanQualInit(&epqstate, estate, NULL, NIL, -1);
|
||||
|
||||
|
@ -786,9 +786,9 @@ static void apply_handle_delete(StringInfo s)
|
|||
|
||||
/* Initialize the executor state. */
|
||||
estate = create_estate_for_relation(rel);
|
||||
remoteslot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(rel->localrel->rd_tam_type));
|
||||
remoteslot = ExecInitExtraTupleSlot(estate, rel->localrel->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(remoteslot, RelationGetDescr(rel->localrel));
|
||||
localslot = ExecInitExtraTupleSlot(estate, GetTableAmRoutine(rel->localrel->rd_tam_type));
|
||||
localslot = ExecInitExtraTupleSlot(estate, rel->localrel->rd_tam_ops);
|
||||
ExecSetSlotDescriptor(localslot, RelationGetDescr(rel->localrel));
|
||||
EvalPlanQualInit(&epqstate, estate, NULL, NIL, -1);
|
||||
|
||||
|
|
|
@ -1304,7 +1304,7 @@ void TrRestoreDrop(const TimeCapsuleStmt *stmt)
|
|||
if (desc.relid != 0 && (desc.type == RB_OBJ_TABLE)) {
|
||||
stmt->relation->relname = desc.name;
|
||||
rel = heap_openrv(stmt->relation, AccessExclusiveLock);
|
||||
if (rel->rd_tam_type == TAM_HEAP) {
|
||||
if (rel->rd_tam_ops == TableAmHeap) {
|
||||
heap_close(rel, NoLock);
|
||||
elog(ERROR, "timecapsule does not support astore yet");
|
||||
return;
|
||||
|
|
|
@ -731,7 +731,7 @@ bool NeedTrComm(Oid relid)
|
|||
/* table is non ordinary table, or */
|
||||
classForm->relkind != RELKIND_RELATION ||
|
||||
/* is non heap table, or */
|
||||
rel->rd_tam_type == TAM_HEAP ||
|
||||
rel->rd_tam_ops == TableAmHeap ||
|
||||
/* is non regular table, or */
|
||||
classForm->relpersistence != RELPERSISTENCE_PERMANENT ||
|
||||
/* is shared table across databases, or */
|
||||
|
|
|
@ -445,7 +445,7 @@ void TrRestoreTruncate(const TimeCapsuleStmt *stmt)
|
|||
|
||||
rel = heap_openrv(stmt->relation, AccessExclusiveLock);
|
||||
relid = RelationGetRelid(rel);
|
||||
if (rel->rd_tam_type == TAM_HEAP) {
|
||||
if (rel->rd_tam_ops == TableAmHeap) {
|
||||
heap_close(rel, NoLock);
|
||||
elog(ERROR, "timecapsule does not support astore yet");
|
||||
return;
|
||||
|
|
|
@ -135,7 +135,7 @@ static bool TvFeatureSupport(Oid relid, char **errstr, bool isTimecapsuleTable)
|
|||
*errstr = "timecapsule feature does not support system table";
|
||||
} else if (classForm->relpersistence != RELPERSISTENCE_PERMANENT) {
|
||||
*errstr = "timecapsule feature does not support non-permanent table";
|
||||
} else if (rel->rd_tam_type == TAM_HEAP) {
|
||||
} else if (rel->rd_tam_ops == TableAmHeap) {
|
||||
*errstr = "timecapsule feature does not support heap table";
|
||||
} else if ((RELATION_HAS_BUCKET(rel) || RELATION_OWN_BUCKET(rel))) {
|
||||
*errstr = "timecapsule feature does not support hash-bucket table";
|
||||
|
@ -822,7 +822,7 @@ static void TvUheapInsertLostImpl(Relation rel, Relation partRel, Partition p,
|
|||
recheckIndexes = ExecInsertIndexTuples(myslot, &tuple->ctid, estate, partRel, p, InvalidBktId, NULL, NULL);
|
||||
if (relRel != NULL && relRel->rd_mlogoid != InvalidOid) {
|
||||
HeapTuple htup = NULL;
|
||||
Assert(relRel->rd_tam_type == TAM_USTORE);
|
||||
Assert(relRel->rd_tam_ops == TableAmUstore);
|
||||
htup = (HeapTuple)UHeapToHeap(relRel->rd_att, (UHeapTuple)tuple);
|
||||
insert_into_mlog_table(relRel, relRel->rd_mlogoid, (HeapTuple)tuple,
|
||||
&(((HeapTuple)tuple)->t_self), GetCurrentTransactionId(), 'I');
|
||||
|
|
|
@ -201,7 +201,7 @@ typedef struct TableAmRoutine {
|
|||
* @param attnum: index of the atribute to be extracted.
|
||||
* @param isnull: set to true, if the attribute is NULL.
|
||||
*/
|
||||
Datum (*tslot_getattr)(TupleTableSlot *slot, int attnum, bool *isnull);
|
||||
Datum (*tslot_getattr)(TupleTableSlot *slot, int attnum, bool *isnull, bool need_transform_anyarray);
|
||||
|
||||
/*
|
||||
* This function forces all the entries of slot's Datum/isnull array to be valid
|
||||
|
@ -210,7 +210,7 @@ typedef struct TableAmRoutine {
|
|||
*
|
||||
* @param slot: TableTuple slot from this attributes are extracted
|
||||
*/
|
||||
void (*tslot_getallattrs)(TupleTableSlot *slot);
|
||||
void (*tslot_getallattrs)(TupleTableSlot *slot, bool need_transform_anyarray);
|
||||
|
||||
/*
|
||||
* Detects if specified attribute is null without actually fetching it.
|
||||
|
@ -496,7 +496,6 @@ typedef struct TableAmRoutine {
|
|||
void (*tcap_insert_lost)(Relation relation, Snapshot snap);
|
||||
} TableAmRoutine;
|
||||
|
||||
|
||||
extern const TableAmRoutine * const g_tableam_routines[];
|
||||
extern void HeapamScanIndexFetchEnd(IndexFetchTableData *scan);
|
||||
extern void heapam_index_fetch_reset(IndexFetchTableData *scan);
|
||||
|
@ -508,12 +507,6 @@ static inline const TableAmRoutine* GetTableAmRoutine(TableAmType type)
|
|||
return type == TAM_HEAP ? TableAmHeap : TableAmUstore;
|
||||
}
|
||||
|
||||
static inline TableAmType GetTableAmType(const TableAmRoutine* ops)
|
||||
{
|
||||
Assert(ops == TableAmHeap || ops == TableAmUstore);
|
||||
return ops == TableAmHeap ? TAM_HEAP : TAM_USTORE;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* HEAP TABLE SLOT AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
|
@ -522,7 +515,7 @@ static inline TableAmType GetTableAmType(const TableAmRoutine* ops)
|
|||
static inline Tuple tableam_tslot_get_tuple_from_slot(Relation relation, TupleTableSlot *slot)
|
||||
{
|
||||
slot->tts_tupleDescriptor->tdhasuids = RELATION_HAS_UIDS(relation);
|
||||
return g_tableam_routines[relation->rd_tam_type]->tslot_get_tuple_from_slot(slot);
|
||||
return relation->rd_tam_ops->tslot_get_tuple_from_slot(slot);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -565,9 +558,11 @@ static inline HeapTuple tableam_tslot_copy_heap_tuple(TupleTableSlot *slot)
|
|||
|
||||
static inline void tableam_tslot_store_tuple(Tuple tuple, TupleTableSlot *slot, Buffer buffer, bool shouldFree, bool batchMode)
|
||||
{
|
||||
g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tslot_store_tuple(tuple, slot, buffer, shouldFree, batchMode);
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == slot->tts_tam_ops);
|
||||
slot->tts_tam_ops->tslot_store_tuple(tuple, slot, buffer, shouldFree, batchMode);
|
||||
}
|
||||
|
||||
|
||||
static inline void tableam_tslot_getsomeattrs(TupleTableSlot *slot, int natts)
|
||||
{
|
||||
slot->tts_tam_ops->tslot_getsomeattrs(slot, natts);
|
||||
|
@ -578,14 +573,14 @@ static inline void tableam_tslot_formbatch(TupleTableSlot* slot, VectorBatch* ba
|
|||
slot->tts_tam_ops->tslot_formbatch(slot, batch, cur_rows, natts);
|
||||
}
|
||||
|
||||
static inline Datum tableam_tslot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
|
||||
static inline Datum tableam_tslot_getattr(TupleTableSlot *slot, int attnum, bool *isnull, bool need_transform_anyarray = false)
|
||||
{
|
||||
return slot->tts_tam_ops->tslot_getattr(slot, attnum, isnull);
|
||||
return slot->tts_tam_ops->tslot_getattr(slot, attnum, isnull, need_transform_anyarray);
|
||||
}
|
||||
|
||||
static inline void tableam_tslot_getallattrs(TupleTableSlot *slot)
|
||||
static inline void tableam_tslot_getallattrs(TupleTableSlot *slot, bool need_transform_anyarray = false)
|
||||
{
|
||||
return slot->tts_tam_ops->tslot_getallattrs(slot);
|
||||
return slot->tts_tam_ops->tslot_getallattrs(slot, need_transform_anyarray);
|
||||
}
|
||||
|
||||
static inline bool tableam_tslot_attisnull(TupleTableSlot *slot, int attnum)
|
||||
|
@ -602,51 +597,53 @@ static inline Datum tableam_tops_getsysattr(Tuple tuple, int attnum, TupleDesc t
|
|||
Buffer buf = InvalidBuffer)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_getsysattr(tuple, attnum, tuple_desc, isnull, buf);
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_getsysattr(tuple, attnum, tuple_desc, isnull, buf);
|
||||
}
|
||||
|
||||
static inline MinimalTuple tableam_tops_form_minimal_tuple(TupleDesc tuple_descriptor, Datum *values,
|
||||
const bool *isnull, MinimalTuple in_tuple, const TableAmRoutine* tam_ops = TableAmHeap)
|
||||
{
|
||||
Assert(tuple_descriptor->td_tam_ops == tam_ops);
|
||||
return tuple_descriptor->td_tam_ops->tops_form_minimal_tuple(tuple_descriptor, values, isnull,
|
||||
return tam_ops->tops_form_minimal_tuple(tuple_descriptor, values, isnull,
|
||||
in_tuple);
|
||||
}
|
||||
|
||||
static inline Tuple tableam_tops_form_tuple(TupleDesc tuple_descriptor, Datum *values, bool *isnull,
|
||||
const TableAmRoutine* tam_ops = TableAmHeap)
|
||||
{
|
||||
Assert(tuple_descriptor->td_tam_ops == tam_ops);
|
||||
return tuple_descriptor->td_tam_ops->tops_form_tuple(tuple_descriptor, values, isnull);
|
||||
return tam_ops->tops_form_tuple(tuple_descriptor, values, isnull);
|
||||
}
|
||||
|
||||
static inline Tuple tableam_tops_form_cmprs_tuple(TupleDesc tuple_descriptor, FormCmprTupleData *cmprs_info,
|
||||
const TableAmRoutine* tam_ops = TableAmHeap)
|
||||
{
|
||||
Assert(tuple_descriptor->td_tam_ops == tam_ops);
|
||||
return tuple_descriptor->td_tam_ops->tops_form_cmprs_tuple(tuple_descriptor, cmprs_info);
|
||||
return tam_ops->tops_form_cmprs_tuple(tuple_descriptor, cmprs_info);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_deform_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_tuple(tuple, tuple_desc, values, isnull);
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_deform_tuple(tuple, tuple_desc, values, isnull);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_deform_tuple2(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull, Buffer buffer)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_tuple2(tuple, tuple_desc, values, isnull, buffer);
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_deform_tuple2(tuple, tuple_desc, values, isnull, buffer);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_deform_cmprs_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull,
|
||||
char *cmprs_info)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_cmprs_tuple(tuple, tuple_desc, values, isnull,
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_deform_cmprs_tuple(tuple, tuple_desc, values, isnull,
|
||||
cmprs_info);
|
||||
}
|
||||
|
||||
|
||||
static inline void tableam_tops_fill_tuple(TupleDesc tuple_desc, Datum *values, const bool *isnull, char *data,
|
||||
Size data_size, uint16 *infomask, bits8 *bit)
|
||||
{
|
||||
|
@ -662,7 +659,8 @@ static inline Tuple tableam_tops_modify_tuple(Tuple tuple, TupleDesc tuple_desc,
|
|||
const bool *repl_isnull, const bool *do_replace)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_modify_tuple(tuple, tuple_desc, repl_values,
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_modify_tuple(tuple, tuple_desc, repl_values,
|
||||
repl_isnull, do_replace);
|
||||
}
|
||||
|
||||
|
@ -670,7 +668,8 @@ static inline Tuple tableam_tops_opfusion_modify_tuple(Tuple tuple, TupleDesc tu
|
|||
Datum* repl_values, bool* repl_isnull, UpdateFusion* opf)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_opfusion_modify_tuple(tuple, tuple_desc,
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_opfusion_modify_tuple(tuple, tuple_desc,
|
||||
repl_values, repl_isnull, opf);
|
||||
}
|
||||
|
||||
|
@ -688,14 +687,16 @@ static inline Tuple tableam_tops_opfusion_modify_tuple(Tuple tuple, TupleDesc tu
|
|||
static inline Datum tableam_tops_tuple_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_getattr(tuple, att_num,
|
||||
//FIXME: Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return GetTableAmRoutine((TableAmType)(GetTabelAmIndexTuple(tuple)))->tops_tuple_getattr(tuple, att_num,
|
||||
tuple_desc, is_null);
|
||||
}
|
||||
|
||||
static inline Datum tableam_tops_tuple_fast_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_fast_getattr(tuple, att_num,
|
||||
Assert(g_tableam_routines[GetTabelAmIndexTuple(tuple)] == tuple_desc->td_tam_ops);
|
||||
return tuple_desc->td_tam_ops->tops_tuple_fast_getattr(tuple, att_num,
|
||||
tuple_desc, is_null);
|
||||
}
|
||||
|
||||
|
@ -705,61 +706,197 @@ static inline bool tableam_tops_tuple_attisnull(Tuple tuple, int attnum, TupleDe
|
|||
* We allow a NULL tupledesc for relations not expected to have missing
|
||||
* values, such as catalog relations and indexes.
|
||||
*/
|
||||
return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_attisnull(tuple, attnum, tuple_desc);
|
||||
return GetTableAmRoutine((TableAmType)(GetTabelAmIndexTuple(tuple)))->tops_tuple_attisnull(tuple, attnum, tuple_desc);
|
||||
}
|
||||
|
||||
static inline Tuple tableam_tops_copy_tuple(Tuple tuple)
|
||||
{
|
||||
AssertValidTuple(tuple);
|
||||
return GetTableAmRoutine((TableAmType)(GetTabelAmIndexTuple(tuple)))->tops_copy_tuple(tuple);
|
||||
}
|
||||
|
||||
|
||||
extern Tuple tableam_tops_copy_tuple(Tuple tuple);
|
||||
extern MinimalTuple tableam_tops_copy_minimal_tuple(MinimalTuple mtup);
|
||||
extern void tableam_tops_free_minimal_tuple(MinimalTuple mtup);
|
||||
extern Tuple tableam_tops_new_tuple(Relation relation, ItemPointer tid);
|
||||
extern TransactionId tableam_tops_get_conflictXid(Relation relation, Tuple tup);
|
||||
extern void tableam_tops_destroy_tuple(Relation relation, Tuple tuple);
|
||||
extern void tableam_tops_add_to_bulk_insert_select(Relation relation, CopyFromBulk bulk, Tuple tup,
|
||||
bool needCopy);
|
||||
extern void tableam_tops_add_to_bulk(Relation relation,
|
||||
CopyFromBulk bulk, Tuple tup, bool needCopy);
|
||||
extern ItemPointer tableam_tops_get_t_self(Relation relation, Tuple tup);
|
||||
extern void tableam_tops_exec_delete_index_tuples(TupleTableSlot *slot, Relation relation,
|
||||
static inline MinimalTuple tableam_tops_copy_minimal_tuple(MinimalTuple mtup)
|
||||
{
|
||||
return heap_copy_minimal_tuple(mtup);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_free_minimal_tuple(MinimalTuple mtup)
|
||||
{
|
||||
heap_free_minimal_tuple(mtup);
|
||||
}
|
||||
|
||||
static inline Tuple tableam_tops_new_tuple(Relation relation, ItemPointer tid)
|
||||
{
|
||||
return relation->rd_tam_ops->tops_new_tuple(relation, tid);
|
||||
}
|
||||
|
||||
static inline TransactionId tableam_tops_get_conflictXid(Relation relation, Tuple tup)
|
||||
{
|
||||
return relation->rd_tam_ops->tops_get_conflictXid(tup);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_destroy_tuple(Relation relation, Tuple tuple)
|
||||
{
|
||||
relation->rd_tam_ops->tops_destroy_tuple(tuple);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_add_to_bulk_insert_select(Relation relation, CopyFromBulk bulk, Tuple tup,
|
||||
bool needCopy)
|
||||
{
|
||||
relation->rd_tam_ops->tops_add_to_bulk_insert_select(bulk, tup, needCopy);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_add_to_bulk(Relation relation,
|
||||
CopyFromBulk bulk, Tuple tup, bool needCopy)
|
||||
{
|
||||
relation->rd_tam_ops->tops_add_to_bulk(bulk, tup, needCopy);
|
||||
}
|
||||
|
||||
static inline ItemPointer tableam_tops_get_t_self(Relation relation, Tuple tup)
|
||||
{
|
||||
return relation->rd_tam_ops->tops_get_t_self(tup);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_exec_delete_index_tuples(TupleTableSlot *slot, Relation relation,
|
||||
ModifyTableState *node, ItemPointer tupleid, ExecIndexTuplesState exec_index_tuples_state,
|
||||
Bitmapset *modifiedIdxAttrs);
|
||||
extern List *tableam_tops_exec_update_index_tuples(TupleTableSlot *slot, TupleTableSlot *oldslot,
|
||||
Bitmapset *modifiedIdxAttrs)
|
||||
{
|
||||
relation->rd_tam_ops->tops_exec_delete_index_tuples(slot, relation, node, tupleid,
|
||||
exec_index_tuples_state, modifiedIdxAttrs);
|
||||
}
|
||||
|
||||
static inline List *tableam_tops_exec_update_index_tuples(TupleTableSlot *slot, TupleTableSlot *oldslot,
|
||||
Relation relation, ModifyTableState *node, Tuple tuple, ItemPointer tupleid,
|
||||
ExecIndexTuplesState exec_index_tuples_state, int2 bucketid, Bitmapset *modifiedIdxAttrs);
|
||||
extern uint32 tableam_tops_get_tuple_type(Relation relation);
|
||||
extern void tableam_tops_copy_from_insert_batch(Relation rel, EState* estate, CommandId mycid, int hiOptions,
|
||||
ExecIndexTuplesState exec_index_tuples_state, int2 bucketid, Bitmapset *modifiedIdxAttrs)
|
||||
{
|
||||
return relation->rd_tam_ops->tops_exec_update_index_tuples(slot, oldslot, relation, node,
|
||||
tuple, tupleid, exec_index_tuples_state, bucketid, modifiedIdxAttrs);
|
||||
}
|
||||
|
||||
static inline uint32 tableam_tops_get_tuple_type(Relation relation)
|
||||
{
|
||||
return relation->rd_tam_ops->tops_get_tuple_type();
|
||||
}
|
||||
|
||||
static inline void tableam_tops_copy_from_insert_batch(Relation rel, EState* estate, CommandId mycid, int hiOptions,
|
||||
ResultRelInfo* resultRelInfo, TupleTableSlot* myslot, BulkInsertState bistate, int nBufferedTuples,
|
||||
Tuple* bufferedTuples, Partition partition, int2 bucketId);
|
||||
extern bool tableam_tops_page_get_item(Relation rel, Tuple tuple, Page page,
|
||||
OffsetNumber tupleNo, BlockNumber destBlocks);
|
||||
extern OffsetNumber tableam_tops_page_get_max_offsetnumber(Relation rel, Page page);
|
||||
extern Size tableam_tops_page_get_freespace(Relation rel, Page page);
|
||||
extern bool tableam_tops_tuple_fetch_row_version(TidScanState* node, Relation relation, ItemPointer tid,
|
||||
Snapshot snapshot, TupleTableSlot *slot);
|
||||
extern void tableam_tops_update_tuple_with_oid(Relation relation, Tuple tup, TupleTableSlot *slot);
|
||||
extern bool tableam_tuple_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf,
|
||||
bool keep_buf, Relation stats_relation);
|
||||
extern bool tableam_tuple_satisfies_snapshot(Relation relation, HeapTuple tuple, Snapshot snapshot,
|
||||
Buffer buffer);
|
||||
extern void tableam_tuple_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid);
|
||||
extern Oid tableam_tuple_insert(Relation relation, Tuple tup, CommandId cid, int options,
|
||||
struct BulkInsertStateData *bistate);
|
||||
extern int tableam_tuple_multi_insert(Relation relation, Relation parent, Tuple *tuples, int ntuples,
|
||||
CommandId cid, int options, struct BulkInsertStateData *bistate, HeapMultiInsertExtraArgs *args);
|
||||
extern TM_Result tableam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid, Snapshot crosscheck,
|
||||
Snapshot snapshot, bool wait, TupleTableSlot **oldslot, TM_FailureData *tmfd, bool allow_delete_self = false);
|
||||
extern TM_Result tableam_tuple_update(Relation relation, Relation parentRelation, ItemPointer otid, Tuple newtup,
|
||||
Tuple* bufferedTuples, Partition partition, int2 bucketId)
|
||||
{
|
||||
rel->rd_tam_ops->tops_copy_from_insert_batch(rel, estate, mycid, hiOptions, resultRelInfo,
|
||||
myslot, bistate, nBufferedTuples, bufferedTuples, partition, bucketId);
|
||||
}
|
||||
|
||||
static inline bool tableam_tops_page_get_item(Relation rel, Tuple tuple, Page page,
|
||||
OffsetNumber tupleNo, BlockNumber destBlocks)
|
||||
{
|
||||
return rel->rd_tam_ops->tops_page_get_item(rel, tuple, page, tupleNo, destBlocks);
|
||||
}
|
||||
|
||||
static inline OffsetNumber tableam_tops_page_get_max_offsetnumber(Relation rel, Page page)
|
||||
{
|
||||
return rel->rd_tam_ops->tops_page_get_max_offsetnumber(page);
|
||||
}
|
||||
|
||||
static inline Size tableam_tops_page_get_freespace(Relation rel, Page page)
|
||||
{
|
||||
return rel->rd_tam_ops->tops_page_get_freespace(page);
|
||||
}
|
||||
|
||||
static inline bool tableam_tops_tuple_fetch_row_version(TidScanState* node, Relation relation, ItemPointer tid,
|
||||
Snapshot snapshot, TupleTableSlot *slot)
|
||||
{
|
||||
return relation->rd_tam_ops->tops_tuple_fetch_row_version(node, relation, tid, snapshot, slot);
|
||||
}
|
||||
|
||||
static inline void tableam_tops_update_tuple_with_oid(Relation relation, Tuple tup, TupleTableSlot *slot)
|
||||
{
|
||||
relation->rd_tam_ops->tops_update_tuple_with_oid(relation, tup, slot);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* DQL AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
static inline bool tableam_tuple_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf,
|
||||
bool keep_buf, Relation stats_relation)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_fetch(relation, snapshot, tuple, userbuf, keep_buf,
|
||||
stats_relation);
|
||||
}
|
||||
|
||||
static inline bool tableam_tuple_satisfies_snapshot(Relation relation, HeapTuple tuple, Snapshot snapshot,
|
||||
Buffer buffer)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_satisfies_snapshot(relation, tuple, snapshot, buffer);
|
||||
}
|
||||
|
||||
static inline void tableam_tuple_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_get_latest_tid(relation, snapshot, tid);
|
||||
}
|
||||
|
||||
static inline Oid tableam_tuple_insert(Relation relation, Tuple tup, CommandId cid, int options,
|
||||
struct BulkInsertStateData *bistate)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_insert(relation, tup, cid, options, bistate);
|
||||
}
|
||||
|
||||
static inline int tableam_tuple_multi_insert(Relation relation, Relation parent, Tuple *tuples, int ntuples,
|
||||
CommandId cid, int options, struct BulkInsertStateData *bistate, HeapMultiInsertExtraArgs *args)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_multi_insert(relation, parent, tuples, ntuples, cid,
|
||||
options, bistate, args);
|
||||
}
|
||||
|
||||
static inline TM_Result tableam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid, Snapshot crosscheck,
|
||||
Snapshot snapshot, bool wait, TupleTableSlot **oldslot, TM_FailureData *tmfd, bool allow_delete_self = false)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_delete(relation, tid, cid, crosscheck, snapshot, wait,
|
||||
oldslot, tmfd, allow_delete_self);
|
||||
}
|
||||
|
||||
static inline TM_Result tableam_tuple_update(Relation relation, Relation parentRelation, ItemPointer otid, Tuple newtup,
|
||||
CommandId cid, Snapshot crosscheck, Snapshot snapshot, bool wait, TupleTableSlot **oldslot, TM_FailureData *tmfd,
|
||||
bool *update_indexes, Bitmapset **modifiedIdxAttrs, bool allow_update_self = false,
|
||||
bool allow_inplace_update = true, LockTupleMode *lockmode = NULL);
|
||||
extern TM_Result tableam_tuple_lock(Relation relation, Tuple tuple, Buffer *buffer, CommandId cid,
|
||||
bool allow_inplace_update = true, LockTupleMode *lockmode = NULL)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_update(relation, parentRelation, otid, newtup, cid,
|
||||
crosscheck, snapshot, wait, oldslot, tmfd, lockmode, update_indexes, modifiedIdxAttrs, allow_update_self,
|
||||
allow_inplace_update);
|
||||
}
|
||||
|
||||
|
||||
static inline TM_Result tableam_tuple_lock(Relation relation, Tuple tuple, Buffer *buffer, CommandId cid,
|
||||
LockTupleMode mode, bool nowait, TM_FailureData *tmfd, bool allow_lock_self, bool follow_updates, bool eval,
|
||||
Snapshot snapshot, ItemPointer tid, bool isSelectForUpdate, bool isUpsert = false,
|
||||
TransactionId conflictXid = InvalidTransactionId, int waitSec = 0);
|
||||
extern Tuple tableam_tuple_lock_updated(CommandId cid, Relation relation, int lockmode, ItemPointer tid,
|
||||
TransactionId priorXmax, Snapshot snapshot = NULL, bool isSelectForUpdate = false);
|
||||
extern void tableam_tuple_check_visible(Relation relation, Snapshot snapshot, Tuple tuple, Buffer buffer);
|
||||
extern void tableam_tuple_abort_speculative(Relation relation, Tuple tuple);
|
||||
TransactionId conflictXid = InvalidTransactionId, int waitSec = 0)
|
||||
{
|
||||
return relation->rd_tam_ops->tuple_lock(relation, tuple, buffer, cid, mode, nowait, tmfd,
|
||||
allow_lock_self, follow_updates, eval, snapshot, tid, isSelectForUpdate, isUpsert, conflictXid,
|
||||
waitSec);
|
||||
}
|
||||
|
||||
|
||||
static inline Tuple tableam_tuple_lock_updated(CommandId cid, Relation relation, int lockmode, ItemPointer tid,
|
||||
TransactionId priorXmax, Snapshot snapshot = NULL, bool isSelectForUpdate = false)
|
||||
{
|
||||
return (Tuple)relation->rd_tam_ops->tuple_lock_updated(cid, relation, lockmode, tid, priorXmax,
|
||||
snapshot, isSelectForUpdate);
|
||||
}
|
||||
|
||||
static inline void tableam_tuple_check_visible(Relation relation, Snapshot snapshot, Tuple tuple, Buffer buffer)
|
||||
{
|
||||
relation->rd_tam_ops->tuple_check_visible(snapshot, tuple, buffer);
|
||||
}
|
||||
|
||||
|
||||
static inline void tableam_tuple_abort_speculative(Relation relation, Tuple tuple)
|
||||
{
|
||||
relation->rd_tam_ops->tuple_abort_speculative(relation, tuple);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
* SCAN AM APIS FOR HEAP
|
||||
|
@ -767,51 +904,141 @@ extern void tableam_tuple_abort_speculative(Relation relation, Tuple tuple);
|
|||
*/
|
||||
|
||||
extern IndexFetchTableData *tableam_scan_index_fetch_begin(Relation rel);
|
||||
extern void tableam_scan_index_fetch_reset(IndexFetchTableData *scan);
|
||||
|
||||
static inline void tableam_scan_index_fetch_reset(IndexFetchTableData *scan)
|
||||
{
|
||||
heapam_index_fetch_reset(scan);
|
||||
}
|
||||
|
||||
extern void tableam_scan_index_fetch_end(IndexFetchTableData *scan);
|
||||
extern Tuple tableam_scan_index_fetch_tuple(IndexScanDesc scan, bool *all_dead);
|
||||
extern TableScanDesc tableam_scan_begin(Relation relation, Snapshot snapshot, int nkeys, ScanKey key,
|
||||
RangeScanInRedis rangeScanInRedis = { false, 0, 0 });
|
||||
extern TableScanDesc tableam_scan_begin_bm(Relation relation, Snapshot snapshot, int nkeys, ScanKey key);
|
||||
extern TableScanDesc tableam_scan_begin_sampling(Relation relation, Snapshot snapshot, int nkeys, ScanKey key,
|
||||
bool allow_strat, bool allow_sync, RangeScanInRedis rangeScanInRedis = { false, 0, 0 });
|
||||
extern Tuple tableam_scan_getnexttuple(TableScanDesc sscan, ScanDirection direction);
|
||||
extern bool tableam_scan_gettuplebatchmode(TableScanDesc sscan, ScanDirection direction);
|
||||
extern void tableam_scan_getpage(TableScanDesc sscan, BlockNumber page);
|
||||
extern Tuple tableam_scan_gettuple_for_verify(TableScanDesc sscan, ScanDirection direction, bool isValidRelationPage);
|
||||
extern void tableam_scan_end(TableScanDesc sscan);
|
||||
extern void tableam_scan_rescan(TableScanDesc sscan, ScanKey key);
|
||||
extern void tableam_scan_restrpos(TableScanDesc sscan);
|
||||
extern void tableam_scan_markpos(TableScanDesc sscan);
|
||||
extern void tableam_scan_init_parallel_seqscan(TableScanDesc sscan, int32 dop, ScanDirection dir);
|
||||
extern double tableam_index_build_scan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo,
|
||||
bool allow_sync, IndexBuildCallback callback, void *callback_state, TableScanDesc scan);
|
||||
extern void tableam_index_validate_scan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo,
|
||||
Snapshot snapshot, v_i_state *state);
|
||||
extern double tableam_relation_copy_for_cluster(Relation OldHeap, Relation OldIndex, Relation NewHeap,
|
||||
TransactionId OldestXmin, TransactionId FreezeXid, bool verbose, bool use_sort, AdaptMem *memUsage);
|
||||
|
||||
static inline Tuple tableam_scan_index_fetch_tuple(IndexScanDesc scan, bool *all_dead)
|
||||
{
|
||||
return scan->heapRelation->rd_tam_ops->scan_index_fetch_tuple(scan, all_dead);
|
||||
}
|
||||
|
||||
static inline TableScanDesc tableam_scan_begin(Relation relation, Snapshot snapshot, int nkeys, ScanKey key,
|
||||
RangeScanInRedis rangeScanInRedis = { false, 0, 0 })
|
||||
{
|
||||
return relation->rd_tam_ops->scan_begin(relation, snapshot, nkeys, key, rangeScanInRedis);
|
||||
}
|
||||
|
||||
static inline TableScanDesc tableam_scan_begin_bm(Relation relation, Snapshot snapshot, int nkeys, ScanKey key)
|
||||
{
|
||||
return relation->rd_tam_ops->scan_begin_bm(relation, snapshot, nkeys, key);
|
||||
}
|
||||
|
||||
static inline TableScanDesc tableam_scan_begin_sampling(Relation relation, Snapshot snapshot, int nkeys, ScanKey key,
|
||||
bool allow_strat, bool allow_sync, RangeScanInRedis rangeScanInRedis = { false, 0, 0 } )
|
||||
{
|
||||
return relation->rd_tam_ops->scan_begin_sampling(relation, snapshot, nkeys, key, allow_strat,
|
||||
allow_sync, rangeScanInRedis);
|
||||
}
|
||||
|
||||
static inline Tuple tableam_scan_getnexttuple(TableScanDesc sscan, ScanDirection direction)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_getnexttuple(sscan, direction);
|
||||
}
|
||||
|
||||
static inline bool tableam_scan_gettuplebatchmode(TableScanDesc sscan, ScanDirection direction)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_GetNextBatch(sscan, direction);
|
||||
}
|
||||
|
||||
static inline void tableam_scan_getpage(TableScanDesc sscan, BlockNumber page)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_getpage(sscan, page);
|
||||
}
|
||||
|
||||
static inline Tuple tableam_scan_gettuple_for_verify(TableScanDesc sscan, ScanDirection direction, bool isValidRelationPage)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_gettuple_for_verify(sscan,
|
||||
direction, isValidRelationPage);
|
||||
}
|
||||
|
||||
static inline void tableam_scan_end(TableScanDesc sscan)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_end(sscan);
|
||||
}
|
||||
|
||||
static inline void tableam_scan_rescan(TableScanDesc sscan, ScanKey key)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_rescan(sscan, key);
|
||||
}
|
||||
|
||||
static inline void tableam_scan_restrpos(TableScanDesc sscan)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_restrpos(sscan);
|
||||
}
|
||||
|
||||
static inline void tableam_scan_markpos(TableScanDesc sscan)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_markpos(sscan);
|
||||
}
|
||||
|
||||
static inline void tableam_scan_init_parallel_seqscan(TableScanDesc sscan, int32 dop, ScanDirection dir)
|
||||
{
|
||||
return sscan->rs_rd->rd_tam_ops->scan_init_parallel_seqscan(sscan, dop, dir);
|
||||
}
|
||||
|
||||
static inline double tableam_index_build_scan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo,
|
||||
bool allow_sync, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
|
||||
{
|
||||
return heapRelation->rd_tam_ops->index_build_scan(heapRelation, indexRelation, indexInfo,
|
||||
allow_sync, callback, callback_state, scan);
|
||||
}
|
||||
|
||||
static inline void tableam_index_validate_scan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo,
|
||||
Snapshot snapshot, v_i_state *state)
|
||||
{
|
||||
return heapRelation->rd_tam_ops->index_validate_scan(heapRelation, indexRelation, indexInfo,
|
||||
snapshot, state);
|
||||
}
|
||||
|
||||
static inline double tableam_relation_copy_for_cluster(Relation OldHeap, Relation OldIndex, Relation NewHeap,
|
||||
TransactionId OldestXmin, TransactionId FreezeXid, bool verbose, bool use_sort, AdaptMem *memUsage)
|
||||
{
|
||||
return OldHeap->rd_tam_ops->relation_copy_for_cluster(OldHeap, OldIndex, NewHeap, OldestXmin,
|
||||
FreezeXid, verbose, use_sort, memUsage);
|
||||
}
|
||||
|
||||
static inline void tableam_tcap_promote_lock(Relation relation, LOCKMODE *lockmode)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tcap_promote_lock(relation, lockmode);
|
||||
return relation->rd_tam_ops->tcap_promote_lock(relation, lockmode);
|
||||
}
|
||||
|
||||
static inline bool tableam_tcap_validate_snap(Relation relation, Snapshot snap)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tcap_validate_snap(relation, snap);
|
||||
return relation->rd_tam_ops->tcap_validate_snap(relation, snap);
|
||||
}
|
||||
|
||||
static inline void tableam_tcap_delete_delta(Relation relation, Snapshot snap)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tcap_delete_delta(relation, snap);
|
||||
return relation->rd_tam_ops->tcap_delete_delta(relation, snap);
|
||||
}
|
||||
|
||||
static inline void tableam_tcap_insert_lost(Relation relation, Snapshot snap)
|
||||
{
|
||||
return g_tableam_routines[relation->rd_tam_type]->tcap_insert_lost(relation, snap);
|
||||
return relation->rd_tam_ops->tcap_insert_lost(relation, snap);
|
||||
}
|
||||
|
||||
extern TM_Result HeapamTupleUpdate(Relation relation, Relation parentRelation, ItemPointer otid, Tuple newtup,
|
||||
CommandId cid, Snapshot crosscheck, Snapshot snapshot, bool wait, TM_FailureData *tmfd, bool *update_indexes,
|
||||
Bitmapset **modifiedIdxAttrs, bool allow_update_self = false, bool allow_inplace_update = true);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* HEAP AM APIs
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
extern Tuple heap_slot_get_tuple_from_slot(TupleTableSlot* slot);
|
||||
extern Datum heapam_getsysattr(Tuple tup, int attnum, TupleDesc tuple_desc, bool* isnull, Buffer buff);
|
||||
extern Tuple heapam_form_tuple(TupleDesc tuple_descriptor, Datum* values, bool* isnull);
|
||||
extern void heapam_deform_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* values, bool* isnull);
|
||||
extern void heapam_deform_tuple2(Tuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer);
|
||||
extern void heapam_deform_cmprs_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* values, bool* isnull, char* cmprs_info);
|
||||
extern void heapam_fill_tuple(TupleDesc tuple_desc, Datum* values, const bool* isnull, char* data, Size data_size, uint16* infomask, bits8* bit);
|
||||
extern Tuple heapam_modify_tuple(Tuple tuple, TupleDesc tuple_desc, Datum* repl_values, const bool* repl_isnull, const bool* do_replace);
|
||||
extern bool heapam_attisnull(Tuple tup, int attnum, TupleDesc tuple_desc);
|
||||
extern Tuple heapam_copytuple(Tuple tuple);
|
||||
#endif /* TABLEAM_H */
|
||||
|
|
|
@ -209,13 +209,13 @@ extern TupleTableSlot* ExecCopySlot(TupleTableSlot* dstslot, TupleTableSlot* src
|
|||
/* heap table specific slot/tuple operations*/
|
||||
/* definitions are found in access/common/heaptuple.c */
|
||||
extern void heap_slot_clear(TupleTableSlot* slot);
|
||||
extern void heap_slot_materialize(TupleTableSlot* slot);
|
||||
extern HeapTuple heap_slot_materialize(TupleTableSlot* slot);
|
||||
extern MinimalTuple heap_slot_get_minimal_tuple(TupleTableSlot *slot);
|
||||
extern MinimalTuple heap_slot_copy_minimal_tuple(TupleTableSlot *slot);
|
||||
extern void heap_slot_store_minimal_tuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree);
|
||||
extern HeapTuple heap_slot_get_heap_tuple (TupleTableSlot* slot);
|
||||
extern HeapTuple heap_slot_copy_heap_tuple (TupleTableSlot *slot);
|
||||
extern void heap_slot_store_heap_tuple(HeapTuple tuple, TupleTableSlot* slot, Buffer buffer, bool shouldFree, bool batchMode);
|
||||
extern void heap_slot_store_heap_tuple(Tuple tup, TupleTableSlot* slot, Buffer buffer, bool shouldFree, bool batchMode);
|
||||
extern Datum heap_slot_getattr(TupleTableSlot* slot, int attnum, bool* isnull, bool need_transform_anyarray = false);
|
||||
extern void heap_slot_getallattrs(TupleTableSlot* slot, bool need_transform_anyarray = false);
|
||||
extern void slot_getallattrsfast(TupleTableSlot *slot, int maxIdx);
|
||||
|
|
|
@ -134,6 +134,8 @@ typedef struct RelationData {
|
|||
char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 =
|
||||
* valid, 2 = temporarily forced */
|
||||
bool rd_islocaltemp; /* rel is a temp rel of this session */
|
||||
bool is_compressed;
|
||||
bool rd_isblockchain; /* relation is in blockchain schema */
|
||||
|
||||
/*
|
||||
* rd_createSubid is the ID of the highest subtransaction the rel has
|
||||
|
@ -150,8 +152,8 @@ typedef struct RelationData {
|
|||
|
||||
Form_pg_class rd_rel; /* RELATION tuple */
|
||||
TupleDesc rd_att; /* tuple descriptor */
|
||||
const TableAmRoutine* rd_tam_ops; /* implementation of table AM */
|
||||
Oid rd_id; /* relation's object id */
|
||||
bool rd_isblockchain; /* relation is in blockchain schema */
|
||||
|
||||
LockInfoData rd_lockInfo; /* lock mgr's info for locking relation */
|
||||
RuleLock* rd_rules; /* rewrite rules */
|
||||
|
@ -195,7 +197,6 @@ typedef struct RelationData {
|
|||
Form_pg_am rd_am; /* pg_am tuple for index's AM */
|
||||
|
||||
int rd_indnkeyatts; /* index relation's indexkey nums */
|
||||
TableAmType rd_tam_type; /*Table accessor method type*/
|
||||
int1 rd_indexsplit; /* determines the page split method to use */
|
||||
|
||||
/*
|
||||
|
@ -291,7 +292,6 @@ typedef struct RelationData {
|
|||
/* Is under the context of creating crossbucket index? */
|
||||
bool newcbi;
|
||||
|
||||
bool is_compressed;
|
||||
/* used only for gsc, keep it preserved if you modify the rel, otherwise set it null */
|
||||
struct LocalRelationEntry *entry;
|
||||
} RelationData;
|
||||
|
|
|
@ -305,7 +305,7 @@ static inline int8 get_indexsplit_from_reloptions(bytea *reloptions, Oid amoid)
|
|||
#define RelationIsUstoreFormat(relation) \
|
||||
((RELKIND_RELATION == relation->rd_rel->relkind || \
|
||||
RELKIND_TOASTVALUE == relation->rd_rel->relkind) && \
|
||||
relation->rd_tam_type == TAM_USTORE)
|
||||
relation->rd_tam_ops == TableAmUstore)
|
||||
|
||||
#define RelationIsUBTree(relation) (relation->rd_rel->relam == UBTREE_AM_OID)
|
||||
#define RelationIsUstoreIndex(relation) (RelationIsUBTree(relation))
|
||||
|
|
Loading…
Reference in New Issue