mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n).
This is a mechanical change in preparation for a later commit that will change the layout of TupleDesc. Introducing a macro to abstract the details of where attributes are stored will allow us to change that in separate step and revise it in future. Author: Thomas Munro, editorialized by Andres Freund Reviewed-By: Andres Freund Discussion: https://postgr.es/m/CAEepm=0ZtQ-SpsgCyzzYpsXS6e=kZWqk3g5Ygn3MDV7A8dabUA@mail.gmail.com
This commit is contained in:
@ -347,7 +347,7 @@ ExecBuildProjectionInfo(List *targetList,
|
||||
isSafeVar = true; /* can't check, just assume OK */
|
||||
else if (attnum <= inputDesc->natts)
|
||||
{
|
||||
Form_pg_attribute attr = inputDesc->attrs[attnum - 1];
|
||||
Form_pg_attribute attr = TupleDescAttr(inputDesc, attnum - 1);
|
||||
|
||||
/*
|
||||
* If user attribute is dropped or has a type mismatch, don't
|
||||
@ -1492,7 +1492,6 @@ ExecInitExprRec(Expr *node, PlanState *parent, ExprState *state,
|
||||
RowExpr *rowexpr = (RowExpr *) node;
|
||||
int nelems = list_length(rowexpr->args);
|
||||
TupleDesc tupdesc;
|
||||
Form_pg_attribute *attrs;
|
||||
int i;
|
||||
ListCell *l;
|
||||
|
||||
@ -1539,13 +1538,13 @@ ExecInitExprRec(Expr *node, PlanState *parent, ExprState *state,
|
||||
memset(scratch.d.row.elemnulls, true, sizeof(bool) * nelems);
|
||||
|
||||
/* Set up evaluation, skipping any deleted columns */
|
||||
attrs = tupdesc->attrs;
|
||||
i = 0;
|
||||
foreach(l, rowexpr->args)
|
||||
{
|
||||
Form_pg_attribute att = TupleDescAttr(tupdesc, i);
|
||||
Expr *e = (Expr *) lfirst(l);
|
||||
|
||||
if (!attrs[i]->attisdropped)
|
||||
if (!att->attisdropped)
|
||||
{
|
||||
/*
|
||||
* Guard against ALTER COLUMN TYPE on rowtype since
|
||||
@ -1553,12 +1552,12 @@ ExecInitExprRec(Expr *node, PlanState *parent, ExprState *state,
|
||||
* typmod too? Not sure we can be sure it'll be the
|
||||
* same.
|
||||
*/
|
||||
if (exprType((Node *) e) != attrs[i]->atttypid)
|
||||
if (exprType((Node *) e) != att->atttypid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("ROW() column has type %s instead of type %s",
|
||||
format_type_be(exprType((Node *) e)),
|
||||
format_type_be(attrs[i]->atttypid))));
|
||||
format_type_be(att->atttypid))));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1553,7 +1553,7 @@ CheckVarSlotCompatibility(TupleTableSlot *slot, int attnum, Oid vartype)
|
||||
elog(ERROR, "attribute number %d exceeds number of columns %d",
|
||||
attnum, slot_tupdesc->natts);
|
||||
|
||||
attr = slot_tupdesc->attrs[attnum - 1];
|
||||
attr = TupleDescAttr(slot_tupdesc, attnum - 1);
|
||||
|
||||
if (attr->attisdropped)
|
||||
ereport(ERROR,
|
||||
@ -2081,7 +2081,7 @@ ExecEvalRowNullInt(ExprState *state, ExprEvalStep *op,
|
||||
for (att = 1; att <= tupDesc->natts; att++)
|
||||
{
|
||||
/* ignore dropped columns */
|
||||
if (tupDesc->attrs[att - 1]->attisdropped)
|
||||
if (TupleDescAttr(tupDesc, att - 1)->attisdropped)
|
||||
continue;
|
||||
if (heap_attisnull(&tmptup, att))
|
||||
{
|
||||
@ -2494,7 +2494,7 @@ ExecEvalFieldSelect(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
|
||||
if (fieldnum > tupDesc->natts) /* should never happen */
|
||||
elog(ERROR, "attribute number %d exceeds number of columns %d",
|
||||
fieldnum, tupDesc->natts);
|
||||
attr = tupDesc->attrs[fieldnum - 1];
|
||||
attr = TupleDescAttr(tupDesc, fieldnum - 1);
|
||||
|
||||
/* Check for dropped column, and force a NULL result if so */
|
||||
if (attr->attisdropped)
|
||||
@ -3441,8 +3441,8 @@ ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
|
||||
|
||||
for (i = 0; i < var_tupdesc->natts; i++)
|
||||
{
|
||||
Form_pg_attribute vattr = var_tupdesc->attrs[i];
|
||||
Form_pg_attribute sattr = slot_tupdesc->attrs[i];
|
||||
Form_pg_attribute vattr = TupleDescAttr(var_tupdesc, i);
|
||||
Form_pg_attribute sattr = TupleDescAttr(slot_tupdesc, i);
|
||||
|
||||
if (vattr->atttypid == sattr->atttypid)
|
||||
continue; /* no worries */
|
||||
@ -3540,8 +3540,8 @@ ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
|
||||
|
||||
for (i = 0; i < var_tupdesc->natts; i++)
|
||||
{
|
||||
Form_pg_attribute vattr = var_tupdesc->attrs[i];
|
||||
Form_pg_attribute sattr = tupleDesc->attrs[i];
|
||||
Form_pg_attribute vattr = TupleDescAttr(var_tupdesc, i);
|
||||
Form_pg_attribute sattr = TupleDescAttr(tupleDesc, i);
|
||||
|
||||
if (!vattr->attisdropped)
|
||||
continue; /* already checked non-dropped cols */
|
||||
|
@ -168,7 +168,7 @@ ExecInitJunkFilterConversion(List *targetList,
|
||||
t = list_head(targetList);
|
||||
for (i = 0; i < cleanLength; i++)
|
||||
{
|
||||
if (cleanTupType->attrs[i]->attisdropped)
|
||||
if (TupleDescAttr(cleanTupType, i)->attisdropped)
|
||||
continue; /* map entry is already zero */
|
||||
for (;;)
|
||||
{
|
||||
|
@ -1950,8 +1950,9 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
|
||||
|
||||
for (attrChk = 1; attrChk <= natts; attrChk++)
|
||||
{
|
||||
if (tupdesc->attrs[attrChk - 1]->attnotnull &&
|
||||
slot_attisnull(slot, attrChk))
|
||||
Form_pg_attribute att = TupleDescAttr(tupdesc, attrChk - 1);
|
||||
|
||||
if (att->attnotnull && slot_attisnull(slot, attrChk))
|
||||
{
|
||||
char *val_desc;
|
||||
Relation orig_rel = rel;
|
||||
@ -1994,7 +1995,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NOT_NULL_VIOLATION),
|
||||
errmsg("null value in column \"%s\" violates not-null constraint",
|
||||
NameStr(orig_tupdesc->attrs[attrChk - 1]->attname)),
|
||||
NameStr(att->attname)),
|
||||
val_desc ? errdetail("Failing row contains %s.", val_desc) : 0,
|
||||
errtablecol(orig_rel, attrChk)));
|
||||
}
|
||||
@ -2261,9 +2262,10 @@ ExecBuildSlotValueDescription(Oid reloid,
|
||||
bool column_perm = false;
|
||||
char *val;
|
||||
int vallen;
|
||||
Form_pg_attribute att = TupleDescAttr(tupdesc, i);
|
||||
|
||||
/* ignore dropped columns */
|
||||
if (tupdesc->attrs[i]->attisdropped)
|
||||
if (att->attisdropped)
|
||||
continue;
|
||||
|
||||
if (!table_perm)
|
||||
@ -2274,9 +2276,9 @@ ExecBuildSlotValueDescription(Oid reloid,
|
||||
* for the column. If not, omit this column from the error
|
||||
* message.
|
||||
*/
|
||||
aclresult = pg_attribute_aclcheck(reloid, tupdesc->attrs[i]->attnum,
|
||||
aclresult = pg_attribute_aclcheck(reloid, att->attnum,
|
||||
GetUserId(), ACL_SELECT);
|
||||
if (bms_is_member(tupdesc->attrs[i]->attnum - FirstLowInvalidHeapAttributeNumber,
|
||||
if (bms_is_member(att->attnum - FirstLowInvalidHeapAttributeNumber,
|
||||
modifiedCols) || aclresult == ACLCHECK_OK)
|
||||
{
|
||||
column_perm = any_perm = true;
|
||||
@ -2286,7 +2288,7 @@ ExecBuildSlotValueDescription(Oid reloid,
|
||||
else
|
||||
write_comma_collist = true;
|
||||
|
||||
appendStringInfoString(&collist, NameStr(tupdesc->attrs[i]->attname));
|
||||
appendStringInfoString(&collist, NameStr(att->attname));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2299,7 +2301,7 @@ ExecBuildSlotValueDescription(Oid reloid,
|
||||
Oid foutoid;
|
||||
bool typisvarlena;
|
||||
|
||||
getTypeOutputInfo(tupdesc->attrs[i]->atttypid,
|
||||
getTypeOutputInfo(att->atttypid,
|
||||
&foutoid, &typisvarlena);
|
||||
val = OidOutputFunctionCall(foutoid, slot->tts_values[i]);
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ tuple_equals_slot(TupleDesc desc, HeapTuple tup, TupleTableSlot *slot)
|
||||
if (isnull[attrnum])
|
||||
continue;
|
||||
|
||||
att = desc->attrs[attrnum];
|
||||
att = TupleDescAttr(desc, attrnum);
|
||||
|
||||
typentry = lookup_type_cache(att->atttypid, TYPECACHE_EQ_OPR_FINFO);
|
||||
if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
|
||||
|
@ -903,8 +903,8 @@ tupledesc_match(TupleDesc dst_tupdesc, TupleDesc src_tupdesc)
|
||||
|
||||
for (i = 0; i < dst_tupdesc->natts; i++)
|
||||
{
|
||||
Form_pg_attribute dattr = dst_tupdesc->attrs[i];
|
||||
Form_pg_attribute sattr = src_tupdesc->attrs[i];
|
||||
Form_pg_attribute dattr = TupleDescAttr(dst_tupdesc, i);
|
||||
Form_pg_attribute sattr = TupleDescAttr(src_tupdesc, i);
|
||||
|
||||
if (IsBinaryCoercible(sattr->atttypid, dattr->atttypid))
|
||||
continue; /* no worries */
|
||||
|
@ -269,7 +269,7 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc
|
||||
/* Check the tlist attributes */
|
||||
for (attrno = 1; attrno <= numattrs; attrno++)
|
||||
{
|
||||
Form_pg_attribute att_tup = tupdesc->attrs[attrno - 1];
|
||||
Form_pg_attribute att_tup = TupleDescAttr(tupdesc, attrno - 1);
|
||||
Var *var;
|
||||
|
||||
if (tlist_item == NULL)
|
||||
|
@ -997,7 +997,8 @@ ExecTypeSetColNames(TupleDesc typeInfo, List *namesList)
|
||||
/* Guard against too-long names list */
|
||||
if (colno >= typeInfo->natts)
|
||||
break;
|
||||
attr = typeInfo->attrs[colno++];
|
||||
attr = TupleDescAttr(typeInfo, colno);
|
||||
colno++;
|
||||
|
||||
/* Ignore empty aliases (these must be for dropped columns) */
|
||||
if (cname[0] == '\0')
|
||||
@ -1090,13 +1091,15 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
|
||||
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
Form_pg_attribute att = TupleDescAttr(tupdesc, i);
|
||||
|
||||
/* Ignore dropped attributes */
|
||||
if (!tupdesc->attrs[i]->attisdropped)
|
||||
if (!att->attisdropped)
|
||||
{
|
||||
atttypeid = tupdesc->attrs[i]->atttypid;
|
||||
atttypeid = att->atttypid;
|
||||
getTypeInputInfo(atttypeid, &attinfuncid, &attioparams[i]);
|
||||
fmgr_info(attinfuncid, &attinfuncinfo[i]);
|
||||
atttypmods[i] = tupdesc->attrs[i]->atttypmod;
|
||||
atttypmods[i] = att->atttypmod;
|
||||
}
|
||||
}
|
||||
attinmeta->attinfuncs = attinfuncinfo;
|
||||
@ -1127,7 +1130,7 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
|
||||
/* Call the "in" function for each non-dropped attribute */
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
if (!tupdesc->attrs[i]->attisdropped)
|
||||
if (!TupleDescAttr(tupdesc, i)->attisdropped)
|
||||
{
|
||||
/* Non-dropped attributes */
|
||||
dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i],
|
||||
|
@ -917,9 +917,11 @@ GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
|
||||
attrno = InvalidAttrNumber;
|
||||
for (i = 0; i < tupDesc->natts; i++)
|
||||
{
|
||||
if (namestrcmp(&(tupDesc->attrs[i]->attname), attname) == 0)
|
||||
Form_pg_attribute att = TupleDescAttr(tupDesc, i);
|
||||
|
||||
if (namestrcmp(&(att->attname), attname) == 0)
|
||||
{
|
||||
attrno = tupDesc->attrs[i]->attnum;
|
||||
attrno = att->attnum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1759,7 +1759,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
|
||||
errmsg("return type mismatch in function declared to return %s",
|
||||
format_type_be(rettype)),
|
||||
errdetail("Final statement returns too many columns.")));
|
||||
attr = tupdesc->attrs[colindex - 1];
|
||||
attr = TupleDescAttr(tupdesc, colindex - 1);
|
||||
if (attr->attisdropped && modifyTargetList)
|
||||
{
|
||||
Expr *null_expr;
|
||||
@ -1816,7 +1816,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
|
||||
/* remaining columns in tupdesc had better all be dropped */
|
||||
for (colindex++; colindex <= tupnatts; colindex++)
|
||||
{
|
||||
if (!tupdesc->attrs[colindex - 1]->attisdropped)
|
||||
if (!TupleDescAttr(tupdesc, colindex - 1)->attisdropped)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
|
||||
errmsg("return type mismatch in function declared to return %s",
|
||||
|
@ -724,12 +724,16 @@ initialize_aggregate(AggState *aggstate, AggStatePerTrans pertrans,
|
||||
* process_ordered_aggregate_single.)
|
||||
*/
|
||||
if (pertrans->numInputs == 1)
|
||||
{
|
||||
Form_pg_attribute attr = TupleDescAttr(pertrans->sortdesc, 0);
|
||||
|
||||
pertrans->sortstates[aggstate->current_set] =
|
||||
tuplesort_begin_datum(pertrans->sortdesc->attrs[0]->atttypid,
|
||||
tuplesort_begin_datum(attr->atttypid,
|
||||
pertrans->sortOperators[0],
|
||||
pertrans->sortCollations[0],
|
||||
pertrans->sortNullsFirst[0],
|
||||
work_mem, false);
|
||||
}
|
||||
else
|
||||
pertrans->sortstates[aggstate->current_set] =
|
||||
tuplesort_begin_heap(pertrans->sortdesc,
|
||||
|
@ -95,7 +95,8 @@ ExecCheckPlanOutput(Relation resultRel, List *targetList)
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("table row type and query-specified row type do not match"),
|
||||
errdetail("Query has too many columns.")));
|
||||
attr = resultDesc->attrs[attno++];
|
||||
attr = TupleDescAttr(resultDesc, attno);
|
||||
attno++;
|
||||
|
||||
if (!attr->attisdropped)
|
||||
{
|
||||
|
@ -360,7 +360,7 @@ ExecScanSubPlan(SubPlanState *node,
|
||||
|
||||
found = true;
|
||||
/* stash away current value */
|
||||
Assert(subplan->firstColType == tdesc->attrs[0]->atttypid);
|
||||
Assert(subplan->firstColType == TupleDescAttr(tdesc, 0)->atttypid);
|
||||
dvalue = slot_getattr(slot, 1, &disnull);
|
||||
astate = accumArrayResultAny(astate, dvalue, disnull,
|
||||
subplan->firstColType, oldcontext);
|
||||
@ -992,7 +992,7 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext)
|
||||
|
||||
found = true;
|
||||
/* stash away current value */
|
||||
Assert(subplan->firstColType == tdesc->attrs[0]->atttypid);
|
||||
Assert(subplan->firstColType == TupleDescAttr(tdesc, 0)->atttypid);
|
||||
dvalue = slot_getattr(slot, 1, &disnull);
|
||||
astate = accumArrayResultAny(astate, dvalue, disnull,
|
||||
subplan->firstColType, oldcontext);
|
||||
|
@ -202,7 +202,7 @@ ExecInitTableFuncScan(TableFuncScan *node, EState *estate, int eflags)
|
||||
{
|
||||
Oid in_funcid;
|
||||
|
||||
getTypeInputInfo(tupdesc->attrs[i]->atttypid,
|
||||
getTypeInputInfo(TupleDescAttr(tupdesc, i)->atttypid,
|
||||
&in_funcid, &scanstate->typioparams[i]);
|
||||
fmgr_info(in_funcid, &scanstate->in_functions[i]);
|
||||
}
|
||||
@ -390,6 +390,7 @@ tfuncInitialize(TableFuncScanState *tstate, ExprContext *econtext, Datum doc)
|
||||
foreach(lc1, tstate->colexprs)
|
||||
{
|
||||
char *colfilter;
|
||||
Form_pg_attribute att = TupleDescAttr(tupdesc, colno);
|
||||
|
||||
if (colno != ordinalitycol)
|
||||
{
|
||||
@ -403,11 +404,11 @@ tfuncInitialize(TableFuncScanState *tstate, ExprContext *econtext, Datum doc)
|
||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||
errmsg("column filter expression must not be null"),
|
||||
errdetail("Filter for column \"%s\" is null.",
|
||||
NameStr(tupdesc->attrs[colno]->attname))));
|
||||
NameStr(att->attname))));
|
||||
colfilter = TextDatumGetCString(value);
|
||||
}
|
||||
else
|
||||
colfilter = NameStr(tupdesc->attrs[colno]->attname);
|
||||
colfilter = NameStr(att->attname);
|
||||
|
||||
routine->SetColumnFilter(tstate, colfilter, colno);
|
||||
}
|
||||
@ -453,6 +454,8 @@ tfuncLoadRows(TableFuncScanState *tstate, ExprContext *econtext)
|
||||
*/
|
||||
for (colno = 0; colno < natts; colno++)
|
||||
{
|
||||
Form_pg_attribute att = TupleDescAttr(tupdesc, colno);
|
||||
|
||||
if (colno == ordinalitycol)
|
||||
{
|
||||
/* Fast path for ordinality column */
|
||||
@ -465,8 +468,8 @@ tfuncLoadRows(TableFuncScanState *tstate, ExprContext *econtext)
|
||||
|
||||
values[colno] = routine->GetValue(tstate,
|
||||
colno,
|
||||
tupdesc->attrs[colno]->atttypid,
|
||||
tupdesc->attrs[colno]->atttypmod,
|
||||
att->atttypid,
|
||||
att->atttypmod,
|
||||
&isnull);
|
||||
|
||||
/* No value? Evaluate and apply the default, if any */
|
||||
@ -484,7 +487,7 @@ tfuncLoadRows(TableFuncScanState *tstate, ExprContext *econtext)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||
errmsg("null is not allowed in column \"%s\"",
|
||||
NameStr(tupdesc->attrs[colno]->attname))));
|
||||
NameStr(att->attname))));
|
||||
|
||||
nulls[colno] = isnull;
|
||||
}
|
||||
|
@ -95,7 +95,6 @@ ValuesNext(ValuesScanState *node)
|
||||
List *exprstatelist;
|
||||
Datum *values;
|
||||
bool *isnull;
|
||||
Form_pg_attribute *att;
|
||||
ListCell *lc;
|
||||
int resind;
|
||||
|
||||
@ -131,12 +130,13 @@ ValuesNext(ValuesScanState *node)
|
||||
*/
|
||||
values = slot->tts_values;
|
||||
isnull = slot->tts_isnull;
|
||||
att = slot->tts_tupleDescriptor->attrs;
|
||||
|
||||
resind = 0;
|
||||
foreach(lc, exprstatelist)
|
||||
{
|
||||
ExprState *estate = (ExprState *) lfirst(lc);
|
||||
Form_pg_attribute attr = TupleDescAttr(slot->tts_tupleDescriptor,
|
||||
resind);
|
||||
|
||||
values[resind] = ExecEvalExpr(estate,
|
||||
econtext,
|
||||
@ -150,7 +150,7 @@ ValuesNext(ValuesScanState *node)
|
||||
*/
|
||||
values[resind] = MakeExpandedObjectReadOnly(values[resind],
|
||||
isnull[resind],
|
||||
att[resind]->attlen);
|
||||
attr->attlen);
|
||||
|
||||
resind++;
|
||||
}
|
||||
|
@ -765,8 +765,10 @@ SPI_fnumber(TupleDesc tupdesc, const char *fname)
|
||||
|
||||
for (res = 0; res < tupdesc->natts; res++)
|
||||
{
|
||||
if (namestrcmp(&tupdesc->attrs[res]->attname, fname) == 0 &&
|
||||
!tupdesc->attrs[res]->attisdropped)
|
||||
Form_pg_attribute attr = TupleDescAttr(tupdesc, res);
|
||||
|
||||
if (namestrcmp(&attr->attname, fname) == 0 &&
|
||||
!attr->attisdropped)
|
||||
return res + 1;
|
||||
}
|
||||
|
||||
@ -793,7 +795,7 @@ SPI_fname(TupleDesc tupdesc, int fnumber)
|
||||
}
|
||||
|
||||
if (fnumber > 0)
|
||||
att = tupdesc->attrs[fnumber - 1];
|
||||
att = TupleDescAttr(tupdesc, fnumber - 1);
|
||||
else
|
||||
att = SystemAttributeDefinition(fnumber, true);
|
||||
|
||||
@ -823,7 +825,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
|
||||
return NULL;
|
||||
|
||||
if (fnumber > 0)
|
||||
typoid = tupdesc->attrs[fnumber - 1]->atttypid;
|
||||
typoid = TupleDescAttr(tupdesc, fnumber - 1)->atttypid;
|
||||
else
|
||||
typoid = (SystemAttributeDefinition(fnumber, true))->atttypid;
|
||||
|
||||
@ -865,7 +867,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
|
||||
}
|
||||
|
||||
if (fnumber > 0)
|
||||
typoid = tupdesc->attrs[fnumber - 1]->atttypid;
|
||||
typoid = TupleDescAttr(tupdesc, fnumber - 1)->atttypid;
|
||||
else
|
||||
typoid = (SystemAttributeDefinition(fnumber, true))->atttypid;
|
||||
|
||||
@ -901,7 +903,7 @@ SPI_gettypeid(TupleDesc tupdesc, int fnumber)
|
||||
}
|
||||
|
||||
if (fnumber > 0)
|
||||
return tupdesc->attrs[fnumber - 1]->atttypid;
|
||||
return TupleDescAttr(tupdesc, fnumber - 1)->atttypid;
|
||||
else
|
||||
return (SystemAttributeDefinition(fnumber, true))->atttypid;
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ TQSendRecordInfo(TQueueDestReceiver *tqueue, int32 typmod, TupleDesc tupledesc)
|
||||
appendBinaryStringInfo(&buf, (char *) &tupledesc->tdhasoid, sizeof(bool));
|
||||
for (i = 0; i < tupledesc->natts; i++)
|
||||
{
|
||||
appendBinaryStringInfo(&buf, (char *) tupledesc->attrs[i],
|
||||
appendBinaryStringInfo(&buf, (char *) TupleDescAttr(tupledesc, i),
|
||||
sizeof(FormData_pg_attribute));
|
||||
}
|
||||
|
||||
@ -1253,7 +1253,7 @@ BuildFieldRemapInfo(TupleDesc tupledesc, MemoryContext mycontext)
|
||||
tupledesc->natts * sizeof(TupleRemapInfo *));
|
||||
for (i = 0; i < tupledesc->natts; i++)
|
||||
{
|
||||
Form_pg_attribute attr = tupledesc->attrs[i];
|
||||
Form_pg_attribute attr = TupleDescAttr(tupledesc, i);
|
||||
|
||||
if (attr->attisdropped)
|
||||
{
|
||||
|
@ -49,7 +49,6 @@ tstoreStartupReceiver(DestReceiver *self, int operation, TupleDesc typeinfo)
|
||||
{
|
||||
TStoreState *myState = (TStoreState *) self;
|
||||
bool needtoast = false;
|
||||
Form_pg_attribute *attrs = typeinfo->attrs;
|
||||
int natts = typeinfo->natts;
|
||||
int i;
|
||||
|
||||
@ -58,9 +57,11 @@ tstoreStartupReceiver(DestReceiver *self, int operation, TupleDesc typeinfo)
|
||||
{
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
if (attrs[i]->attisdropped)
|
||||
Form_pg_attribute attr = TupleDescAttr(typeinfo, i);
|
||||
|
||||
if (attr->attisdropped)
|
||||
continue;
|
||||
if (attrs[i]->attlen == -1)
|
||||
if (attr->attlen == -1)
|
||||
{
|
||||
needtoast = true;
|
||||
break;
|
||||
@ -109,7 +110,6 @@ tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self)
|
||||
{
|
||||
TStoreState *myState = (TStoreState *) self;
|
||||
TupleDesc typeinfo = slot->tts_tupleDescriptor;
|
||||
Form_pg_attribute *attrs = typeinfo->attrs;
|
||||
int natts = typeinfo->natts;
|
||||
int nfree;
|
||||
int i;
|
||||
@ -127,10 +127,9 @@ tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self)
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
Datum val = slot->tts_values[i];
|
||||
Form_pg_attribute attr = TupleDescAttr(typeinfo, i);
|
||||
|
||||
if (!attrs[i]->attisdropped &&
|
||||
attrs[i]->attlen == -1 &&
|
||||
!slot->tts_isnull[i])
|
||||
if (!attr->attisdropped && attr->attlen == -1 && !slot->tts_isnull[i])
|
||||
{
|
||||
if (VARATT_IS_EXTERNAL(DatumGetPointer(val)))
|
||||
{
|
||||
|
Reference in New Issue
Block a user