Merge branch 'dev' of gitee.com:opengauss/openGauss-server into pjr_commit_sort3

Signed-off-by: cc_db_dev <chenjh2@vastdata.com.cn>
This commit is contained in:
cc_db_dev 2022-10-17 03:33:56 +00:00 committed by Gitee
commit 964fac0c6f
332 changed files with 4817 additions and 3964 deletions

View File

@ -1917,13 +1917,13 @@ static char* get_sql_insert(Relation rel, int* pkattnums, int pknumatts, char**
needComma = false;
for (i = 0; i < natts; i++) {
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
if (needComma)
appendStringInfo(&buf, ",");
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname)));
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[i].attname)));
needComma = true;
}
@ -1934,7 +1934,7 @@ static char* get_sql_insert(Relation rel, int* pkattnums, int pknumatts, char**
*/
needComma = false;
for (i = 0; i < natts; i++) {
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
if (needComma)
@ -1980,7 +1980,7 @@ static char* get_sql_delete(Relation rel, int* pkattnums, int pknumatts, char**
if (i > 0)
appendStringInfo(&buf, " AND ");
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum]->attname)));
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum].attname)));
if (tgt_pkattvals[i] != NULL)
appendStringInfo(&buf, " = %s", quote_literal_cstr(tgt_pkattvals[i]));
@ -2022,13 +2022,13 @@ static char* get_sql_update(Relation rel, int* pkattnums, int pknumatts, char**
*/
needComma = false;
for (i = 0; i < natts; i++) {
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
if (needComma)
appendStringInfo(&buf, ", ");
appendStringInfo(&buf, "%s = ", quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname)));
appendStringInfo(&buf, "%s = ", quote_ident_cstr(NameStr(tupdesc->attrs[i].attname)));
key = get_attnum_pk_pos(pkattnums, pknumatts, i);
@ -2053,7 +2053,7 @@ static char* get_sql_update(Relation rel, int* pkattnums, int pknumatts, char**
if (i > 0)
appendStringInfo(&buf, " AND ");
appendStringInfo(&buf, "%s", quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum]->attname)));
appendStringInfo(&buf, "%s", quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum].attname)));
val = tgt_pkattvals[i];
@ -2135,10 +2135,10 @@ static HeapTuple get_tuple_of_interest(Relation rel, int* pkattnums, int pknumat
if (i > 0)
appendStringInfoString(&buf, ", ");
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
appendStringInfoString(&buf, "NULL");
else
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname)));
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[i].attname)));
}
appendStringInfo(&buf, " FROM %s WHERE ", relname);
@ -2149,7 +2149,7 @@ static HeapTuple get_tuple_of_interest(Relation rel, int* pkattnums, int pknumat
if (i > 0)
appendStringInfo(&buf, " AND ");
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum]->attname)));
appendStringInfoString(&buf, quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum].attname)));
if (src_pkattvals[i] != NULL)
appendStringInfo(&buf, " = %s", quote_literal_cstr(src_pkattvals[i]));
@ -2523,7 +2523,7 @@ static void validate_pkattnums(
lnum = 0;
for (j = 0; j < natts; j++) {
/* dropped columns don't count */
if (tupdesc->attrs[j]->attisdropped)
if (tupdesc->attrs[j].attisdropped)
continue;
if (++lnum == pkattnum)

View File

@ -375,7 +375,7 @@ static List* get_file_fdw_attribute_options(Oid relid)
/* Retrieve FDW options for all user-defined attributes. */
for (attnum = 1; attnum <= natts; attnum++) {
Form_pg_attribute attr = tupleDesc->attrs[attnum - 1];
Form_pg_attribute attr = &tupleDesc->attrs[attnum - 1];
List* options = NIL;
ListCell* lc = NULL;

View File

@ -929,7 +929,7 @@ static void gcdeparseTargetList(StringInfo buf, PlannerInfo* root, Index rtindex
have_wholerow = bms_is_member(0 - FirstLowInvalidHeapAttributeNumber, attrs_used);
for (i = 1; i <= tupdesc->natts; i++) {
Form_pg_attribute attr = tupdesc->attrs[i - 1];
Form_pg_attribute attr = &tupdesc->attrs[i - 1];
/* Ignore dropped attributes. */
if (attr->attisdropped)

View File

@ -745,8 +745,8 @@ static void gcBeginForeignScan(ForeignScanState* node, int eflags)
fsstate->resultSlot->tts_isnull[i] = true;
}
fsstate->resultSlot->tts_isempty = false;
fsstate->scanSlot->tts_isempty = false;
fsstate->resultSlot->tts_flags &= ~TTS_FLAG_EMPTY;
fsstate->scanSlot->tts_flags &= ~TTS_FLAG_EMPTY;
fsstate->attinmeta = TupleDescGetAttInMetadata(fsstate->tupdesc);
@ -862,7 +862,7 @@ static void postgresConstructResultSlotWithArray(ForeignScanState* node)
for (scanAttr = 0, resultAttr = 0; resultAttr < resultDesc->natts; resultAttr++, scanAttr += map) {
Assert(list_length(colmap) == resultDesc->natts);
Oid typoid = resultDesc->attrs[resultAttr]->atttypid;
Oid typoid = resultDesc->attrs[resultAttr].atttypid;
Value* val = (Value*)list_nth(colmap, resultAttr);
map = val->val.ival;
@ -917,7 +917,7 @@ static void postgresConstructResultSlotWithArray(ForeignScanState* node)
}
resultSlot->tts_nvalid = resultDesc->natts;
resultSlot->tts_isempty = false;
resultSlot->tts_flags &= ~TTS_FLAG_EMPTY;
}
static void postgresMapResultFromScanSlot(ForeignScanState* node)
@ -956,7 +956,7 @@ static TupleTableSlot* gcIterateNormalForeignScan(ForeignScanState* node)
/* reset tupleslot on the begin */
(void)ExecClearTuple(fsstate->resultSlot);
fsstate->resultSlot->tts_isempty = false;
fsstate->resultSlot->tts_flags &= ~TTS_FLAG_EMPTY;
TupleTableSlot* slot = node->ss.ss_ScanTupleSlot;
@ -1811,17 +1811,17 @@ static void gcfdw_fetch_remote_table_info(
pq_sendint(&retbuf, tupdesc->natts, 4);
for (int i = 0; i < tupdesc->natts; i++) {
att_name_len = strlen(tupdesc->attrs[i]->attname.data);
att_name_len = strlen(tupdesc->attrs[i].attname.data);
pq_sendint(&retbuf, att_name_len, 4);
pq_sendbytes(&retbuf, tupdesc->attrs[i]->attname.data, att_name_len);
pq_sendbytes(&retbuf, tupdesc->attrs[i].attname.data, att_name_len);
Assert(InvalidOid != tupdesc->attrs[i]->atttypid);
Assert(InvalidOid != tupdesc->attrs[i].atttypid);
type_name = get_typename(tupdesc->attrs[i]->atttypid);
type_name = get_typename(tupdesc->attrs[i].atttypid);
type_name_len = strlen(type_name);
pq_sendint(&retbuf, type_name_len, 4);
pq_sendbytes(&retbuf, type_name, type_name_len);
pq_sendint(&retbuf, tupdesc->attrs[i]->atttypmod, 4);
pq_sendint(&retbuf, tupdesc->attrs[i].atttypmod, 4);
pfree(type_name);
}
@ -2366,7 +2366,7 @@ static void conversion_error_callback(void *arg)
TupleDesc tupdesc = RelationGetDescr(errpos->rel);
if (errpos->cur_attno > 0 && errpos->cur_attno <= tupdesc->natts) {
attname = NameStr(tupdesc->attrs[errpos->cur_attno - 1]->attname);
attname = NameStr(tupdesc->attrs[errpos->cur_attno - 1].attname);
} else if (errpos->cur_attno == SelfItemPointerAttributeNumber) {
attname = "ctid";
} else if (errpos->cur_attno == ObjectIdAttributeNumber) {
@ -2586,7 +2586,7 @@ static void GcFdwCopyRemoteInfo(PgFdwRemoteInfo* new_remote_info, PgFdwRemoteInf
bool hasSpecialArrayType(TupleDesc desc)
{
for (int i = 0; i < desc->natts; i++) {
Oid typoid = desc->attrs[i]->atttypid;
Oid typoid = desc->attrs[i].atttypid;
if (INT8ARRAYOID == typoid || FLOAT8ARRAYOID == typoid || FLOAT4ARRAYOID == typoid || NUMERICARRAY == typoid) {
return true;

View File

@ -1327,7 +1327,7 @@ static TupleTableSlot* HdfsIterateForeignScan(ForeignScanState* scanState)
* @hdfs
* Optimize foreign scan by using informational constraint.
*/
if (((ForeignScan*)scanState->ss.ps.plan)->scan.predicate_pushdown_optimized && false == tupleSlot->tts_isempty) {
if (((ForeignScan*)scanState->ss.ps.plan)->scan.predicate_pushdown_optimized && !TTS_EMPTY(tupleSlot)) {
/*
* If we find a suitable tuple, set is_scan_end value is true.
* It means that we do not find suitable tuple in the next iteration,
@ -1656,7 +1656,7 @@ int HdfsAcquireSampleRows(Relation relation, int logLevel, HeapTuple* sampleRows
SplitMap* fileMap = (SplitMap*)additionalData;
fileList = fileMap->splits;
columnList = CreateColList((Form_pg_attribute*)tupleDescriptor->attrs, columnCount);
columnList = CreateColList(tupleDescriptor->attrs, columnCount);
unsigned int totalFileNumbers = list_length(fileList);
/* description: change file -> stride: Jason's advice */
@ -1681,7 +1681,7 @@ int HdfsAcquireSampleRows(Relation relation, int logLevel, HeapTuple* sampleRows
* columnList changed in HdfsBeginForeignScan
*/
list_free(columnList);
columnList = CreateColList((Form_pg_attribute*)tupleDescriptor->attrs, columnCount);
columnList = CreateColList(tupleDescriptor->attrs, columnCount);
/* Put file information into SplitInfo struct */
SplitInfo* splitinfo = (SplitInfo*)list_nth(fileList, targFile);
@ -1767,7 +1767,7 @@ int HdfsAcquireSampleRows(Relation relation, int logLevel, HeapTuple* sampleRows
(void)MemoryContextSwitchTo(oldContext);
/* if there are no more records to read, break */
if (scanTupleSlot->tts_isempty) {
if (TTS_EMPTY(scanTupleSlot)) {
break;
}

View File

@ -705,7 +705,7 @@ List* CNSchedulingForAnalyze(unsigned int* totalFilesNum, unsigned int* numOfDns
srvType = getServerType(foreignTableId);
tupleDescriptor = RelationGetDescr(relation);
columnList = CreateColList((Form_pg_attribute*)tupleDescriptor->attrs, tupleDescriptor->natts);
columnList = CreateColList(tupleDescriptor->attrs, tupleDescriptor->natts);
RelationClose(relation);
@ -2261,7 +2261,7 @@ static bool PartitionFilterClause(SplitInfo* split, List* scanClauses, Var* valu
static void CollectPartPruneInfo(List*& prunningResult, int sum, int notprunning, int colno, Oid relOid)
{
Relation rel = heap_open(relOid, AccessShareLock);
char* attName = NameStr(rel->rd_att->attrs[colno - 1]->attname);
char* attName = NameStr(rel->rd_att->attrs[colno - 1].attname);
/*
* Add 16 here because we need to add some description words, three separate characters

View File

@ -700,15 +700,15 @@ Datum hstore_from_record(PG_FUNCTION_ARGS)
for (i = 0, j = 0; i < ncolumns; ++i) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
char* value = NULL;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
pairs[j].key = NameStr(tupdesc->attrs[i]->attname);
pairs[j].keylen = hstoreCheckKeyLen(strlen(NameStr(tupdesc->attrs[i]->attname)));
pairs[j].key = NameStr(tupdesc->attrs[i].attname);
pairs[j].keylen = hstoreCheckKeyLen(strlen(NameStr(tupdesc->attrs[i].attname)));
if (nulls == NULL || nulls[i]) {
pairs[j].val = NULL;
@ -862,18 +862,18 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS)
for (i = 0; i < ncolumns; ++i) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
char* value = NULL;
int idx;
int vallen;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
nulls[i] = true;
continue;
}
idx = hstoreFindKey(hs, 0, NameStr(tupdesc->attrs[i]->attname), strlen(NameStr(tupdesc->attrs[i]->attname)));
idx = hstoreFindKey(hs, 0, NameStr(tupdesc->attrs[i].attname), strlen(NameStr(tupdesc->attrs[i].attname)));
/*
* we can't just skip here if the key wasn't found since we might have
@ -901,7 +901,7 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS)
* checks are done
*/
values[i] =
InputFunctionCall(&column_info->proc, NULL, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
InputFunctionCall(&column_info->proc, NULL, column_info->typioparam, tupdesc->attrs[i].atttypmod);
nulls[i] = true;
} else {
vallen = HS_VALLEN(entries, idx);
@ -911,7 +911,7 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS)
value[vallen] = 0;
values[i] =
InputFunctionCall(&column_info->proc, value, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
InputFunctionCall(&column_info->proc, value, column_info->typioparam, tupdesc->attrs[i].atttypmod);
nulls[i] = false;
}
}

View File

@ -1530,7 +1530,7 @@ static void fill_pglog_planstate_from_logft_rel(pglogPlanState* pg_log, Relation
Assert(PGLOG_ATTR_MAX == tupdesc->natts);
for (int i = 0; i < PGLOG_ATTR_MAX; ++i) {
Form_pg_attribute att = tupdesc->attrs[i];
Form_pg_attribute att = &tupdesc->attrs[i];
pg_log->allattr_typmod[i] = att->atttypmod;
getTypeInputInfo(att->atttypid, &in_func_oid, &pg_log->allattr_typioparam[i]);
fmgr_info(in_func_oid, &pg_log->allattr_fmgrinfo[i]);

View File

@ -234,7 +234,7 @@ static void TupleToJsoninfo(
Datum origval = 0; /* possibly toasted Datum */
bool isnull = false; /* column is null? */
Form_pg_attribute attr = tupdesc->attrs[natt]; /* the attribute itself */
Form_pg_attribute attr = &tupdesc->attrs[natt]; /* the attribute itself */
/*
* don't print dropped columns, we can't be sure everything is

View File

@ -435,7 +435,7 @@ static void parse_compress_meta(StringInfo outputBuf, char* page_content, Relati
int size = PageGetSpecialSize(page_header);
TupleDesc desc = RelationGetDescr(rel);
Form_pg_attribute* att = desc->attrs;
FormData_pg_attribute* att = desc->attrs;
int attrno;
int attrnum = desc->natts;
@ -444,7 +444,7 @@ static void parse_compress_meta(StringInfo outputBuf, char* page_content, Relati
char mode = 0;
for (attrno = 0; attrno < attrnum && cmprsOff < size; ++attrno) {
Form_pg_attribute thisatt = att[attrno];
Form_pg_attribute thisatt = &att[attrno];
int metaSize = 0;
metaInfo = PageCompress::FetchAttrCmprMeta(start + cmprsOff, thisatt->attlen, &metaSize, &mode);

View File

@ -223,7 +223,7 @@ static void pgss_ExecutorStart(QueryDesc* queryDesc, int eflags);
static void pgss_ExecutorRun(QueryDesc* queryDesc, ScanDirection direction, long count);
static void pgss_ExecutorFinish(QueryDesc* queryDesc);
static void pgss_ExecutorEnd(QueryDesc* queryDesc);
static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamListInfo params, bool isTopLevel,
static void pgss_ProcessUtility(Node* parsetree, const char* queryString, bool readOnlyTree, ParamListInfo params, bool isTopLevel,
DestReceiver* dest,
#ifdef PGXC
bool sentToRemote,
@ -722,7 +722,7 @@ static void pgss_ExecutorEnd(QueryDesc* queryDesc)
/*
* ProcessUtility hook
*/
static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamListInfo params, bool isTopLevel,
static void pgss_ProcessUtility(Node* parsetree, const char* queryString, bool readOnlyTree, ParamListInfo params, bool isTopLevel,
DestReceiver* dest,
#ifdef PGXC
bool sentToRemote,
@ -756,6 +756,7 @@ static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamL
if (prev_ProcessUtility)
prev_ProcessUtility(parsetree,
queryString,
readOnlyTree,
params,
isTopLevel,
dest,
@ -766,6 +767,7 @@ static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamL
else
standard_ProcessUtility(parsetree,
queryString,
readOnlyTree,
params,
isTopLevel,
dest,
@ -819,6 +821,7 @@ static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamL
if (prev_ProcessUtility)
prev_ProcessUtility(parsetree,
queryString,
readOnlyTree,
params,
isTopLevel,
dest,
@ -829,6 +832,7 @@ static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamL
else
standard_ProcessUtility(parsetree,
queryString,
readOnlyTree,
params,
isTopLevel,
dest,

View File

@ -790,7 +790,7 @@ static void deparseTargetList(StringInfo buf, RangeTblEntry *rte, Index rtindex,
bool first = true;
for (i = 1; i <= tupdesc->natts; i++) {
Form_pg_attribute attr = tupdesc->attrs[i - 1];
Form_pg_attribute attr = &tupdesc->attrs[i - 1];
/* Ignore dropped attributes. */
if (attr->attisdropped) {
@ -1065,7 +1065,7 @@ void deparseAnalyzeSql(StringInfo buf, Relation rel, List **retrieved_attrs)
appendStringInfoString(buf, "SELECT ");
for (i = 0; i < tupdesc->natts; i++) {
/* Ignore dropped columns. */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
continue;
}
@ -1075,7 +1075,7 @@ void deparseAnalyzeSql(StringInfo buf, Relation rel, List **retrieved_attrs)
first = false;
/* Use attribute name or column_name option. */
char *colname = NameStr(tupdesc->attrs[i]->attname);
char *colname = NameStr(tupdesc->attrs[i].attname);
List *options = GetForeignColumnOptions(relid, i + 1);
foreach (lc, options) {

View File

@ -967,7 +967,7 @@ static List *postgresPlanForeignModify(PlannerInfo *root, ModifyTable *plan, Ind
int attnum;
for (attnum = 1; attnum <= tupdesc->natts; attnum++) {
Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
Form_pg_attribute attr = &tupdesc->attrs[attnum - 1];
if (!attr->attisdropped) {
targetAttrs = lappend_int(targetAttrs, attnum);
@ -1124,7 +1124,7 @@ static PgFdwModifyState *createForeignModify(EState *estate, RangeTblEntry *rte,
/* Set up for remaining transmittable parameters */
foreach (lc, fmstate->target_attrs) {
int attnum = lfirst_int(lc);
Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
Form_pg_attribute attr = &tupdesc->attrs[attnum - 1];
Assert(!attr->attisdropped);
@ -1161,7 +1161,7 @@ static TupleTableSlot *postgresExecForeignInsert(EState *estate, ResultRelInfo *
initStringInfo(&sql);
/* We transmit all columns that are defined in the foreign table. */
for (int attnum = 1; attnum <= tupdesc->natts; attnum++) {
Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
Form_pg_attribute attr = &tupdesc->attrs[attnum - 1];
if (!attr->attisdropped) {
targetAttrs = lappend_int(targetAttrs, attnum);
@ -2360,7 +2360,7 @@ static void conversion_error_callback(void *arg)
ConversionLocation *errpos = (ConversionLocation *)arg;
TupleDesc tupdesc = RelationGetDescr(errpos->rel);
if (errpos->cur_attno > 0 && errpos->cur_attno <= tupdesc->natts) {
errcontext("column \"%s\" of foreign table \"%s\"", NameStr(tupdesc->attrs[errpos->cur_attno - 1]->attname),
errcontext("column \"%s\" of foreign table \"%s\"", NameStr(tupdesc->attrs[errpos->cur_attno - 1].attname),
RelationGetRelationName(errpos->rel));
}
}

View File

@ -811,7 +811,7 @@ static void light_unified_audit_executor(const Query *query)
access_audit_policy_run(query->rtable, query->commandType);
}
static void gsaudit_ProcessUtility_hook(Node *parsetree, const char *queryString, ParamListInfoData *params,
static void gsaudit_ProcessUtility_hook(Node *parsetree, const char *queryString, bool readOnlyTree, ParamListInfoData *params,
bool isTopLevel, DestReceiver *dest, bool sentToRemote, char *completionTag, bool isCTAS = false)
{
/* do nothing when enable_security_policy is off */
@ -819,10 +819,10 @@ static void gsaudit_ProcessUtility_hook(Node *parsetree, const char *queryString
u_sess->proc_cxt.IsInnerMaintenanceTools || IsConnFromCoord() ||
!is_audit_policy_exist_load_policy_info()) {
if (next_ProcessUtility_hook) {
next_ProcessUtility_hook(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
next_ProcessUtility_hook(parsetree, queryString, readOnlyTree, params, isTopLevel, dest, sentToRemote, completionTag,
false);
} else {
standard_ProcessUtility(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
standard_ProcessUtility(parsetree, queryString, readOnlyTree, params, isTopLevel, dest, sentToRemote, completionTag,
false);
}
return;
@ -1615,10 +1615,10 @@ static void gsaudit_ProcessUtility_hook(Node *parsetree, const char *queryString
PG_TRY();
{
if (next_ProcessUtility_hook) {
next_ProcessUtility_hook(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
next_ProcessUtility_hook(parsetree, queryString, readOnlyTree, params, isTopLevel, dest, sentToRemote, completionTag,
false);
} else {
standard_ProcessUtility(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
standard_ProcessUtility(parsetree, queryString, readOnlyTree, params, isTopLevel, dest, sentToRemote, completionTag,
false);
}
flush_access_logs(AUDIT_OK);

View File

@ -242,7 +242,7 @@ static void sepgsql_executor_start(QueryDesc* queryDesc, int eflags)
* It tries to rough-grained control on utility commands; some of them can
* break whole of the things if nefarious user would use.
*/
static void sepgsql_utility_command(Node* parsetree, const char* queryString, ParamListInfo params, bool isTopLevel,
static void sepgsql_utility_command(Node* parsetree, const char* queryString, bool readOnlyTree, ParamListInfo params, bool isTopLevel,
DestReceiver* dest,
#ifdef PGXC
bool sentToRemote,
@ -302,6 +302,7 @@ static void sepgsql_utility_command(Node* parsetree, const char* queryString, Pa
if (next_ProcessUtility_hook)
(*next_ProcessUtility_hook)(parsetree,
queryString,
readOnlyTree,
params,
isTopLevel,
dest,
@ -312,6 +313,7 @@ static void sepgsql_utility_command(Node* parsetree, const char* queryString, Pa
else
standard_ProcessUtility(parsetree,
queryString,
readOnlyTree,
params,
isTopLevel,
dest,

View File

@ -312,7 +312,7 @@ Datum /* have to return HeapTuple to Executor */
snprintf(sql, sizeof(sql), "INSERT INTO %s VALUES (", relname);
for (i = 1; i <= natts; i++) {
ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
if (!(tupdesc->attrs[i - 1]->attisdropped)) /* skip dropped columns */
if (!(tupdesc->attrs[i - 1].attisdropped)) /* skip dropped columns */
{
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%c$%d", separ, i);
separ = ',';

View File

@ -302,7 +302,7 @@ static void TupleToStringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple,
Oid typoutput = 0; /* output function */
Datum origval = 0; /* possibly toasted Datum */
Form_pg_attribute attr = tupdesc->attrs[natt]; /* the attribute itself */
Form_pg_attribute attr = &tupdesc->attrs[natt]; /* the attribute itself */
if (attr->attisdropped || attr->attnum < 0) {
continue;
@ -358,7 +358,7 @@ static void TupleToStringinfoUpd(StringInfo s, TupleDesc tupdesc, HeapTuple tupl
bool isnull = false; /* column is null? */
bool typisvarlena = false;
Form_pg_attribute attr = tupdesc->attrs[natt]; /* the attribute itself */
Form_pg_attribute attr = &tupdesc->attrs[natt]; /* the attribute itself */
if (attr->attisdropped || attr->attnum < 0) {
continue;

View File

@ -1337,35 +1337,35 @@ static void validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool
}
/* check that the types of the first two columns match */
if (tupdesc->attrs[0]->atttypid != tupdesc->attrs[1]->atttypid)
if (tupdesc->attrs[0].atttypid != tupdesc->attrs[1].atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid return type"),
errdetail("First two columns must be the same type.")));
/* check that the type of the third column is INT4 */
if (tupdesc->attrs[2]->atttypid != INT4OID)
if (tupdesc->attrs[2].atttypid != INT4OID)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid return type"),
errdetail("Third column must be type %s.", format_type_be(INT4OID))));
/* check that the type of the fourth column is TEXT if applicable */
if (show_branch && tupdesc->attrs[3]->atttypid != TEXTOID)
if (show_branch && tupdesc->attrs[3].atttypid != TEXTOID)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid return type"),
errdetail("Fourth column must be type %s.", format_type_be(TEXTOID))));
/* check that the type of the fifth column is INT4 */
if (show_branch && show_serial && tupdesc->attrs[4]->atttypid != INT4OID)
if (show_branch && show_serial && tupdesc->attrs[4].atttypid != INT4OID)
elog(ERROR,
"query-specified return tuple not valid for Connectby: "
"fifth column must be type %s",
format_type_be(INT4OID));
/* check that the type of the fifth column is INT4 */
if (!show_branch && show_serial && tupdesc->attrs[3]->atttypid != INT4OID)
if (!show_branch && show_serial && tupdesc->attrs[3].atttypid != INT4OID)
elog(ERROR,
"query-specified return tuple not valid for Connectby: "
"fourth column must be type %s",
@ -1383,8 +1383,8 @@ static bool compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupde
Oid sql_atttypid;
/* check the key_fld types match */
ret_atttypid = ret_tupdesc->attrs[0]->atttypid;
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
ret_atttypid = ret_tupdesc->attrs[0].atttypid;
sql_atttypid = sql_tupdesc->attrs[0].atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@ -1393,8 +1393,8 @@ static bool compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupde
"not match return key field datatype.")));
/* check the parent_key_fld types match */
ret_atttypid = ret_tupdesc->attrs[1]->atttypid;
sql_atttypid = sql_tupdesc->attrs[1]->atttypid;
ret_atttypid = ret_tupdesc->attrs[1].atttypid;
sql_atttypid = sql_tupdesc->attrs[1].atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@ -1421,8 +1421,8 @@ static bool compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdes
return false;
/* check the rowid types match */
ret_atttypid = ret_tupdesc->attrs[0]->atttypid;
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
ret_atttypid = ret_tupdesc->attrs[0].atttypid;
sql_atttypid = sql_tupdesc->attrs[0].atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),

View File

@ -224,7 +224,7 @@ static void tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple
Datum origval; /* possibly toasted Datum */
bool isnull = true; /* column is null? */
attr = tupdesc->attrs[natt];
attr = &tupdesc->attrs[natt];
/*
* don't print dropped columns, we can't be sure everything is

View File

@ -729,11 +729,11 @@ void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, bool allow_system
*/
if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE && relkind != RELKIND_CONTQUERY) {
for (i = 0; i < natts; i++) {
if (SystemAttributeByName(NameStr(tupdesc->attrs[i]->attname), tupdesc->tdhasoid) != NULL)
if (SystemAttributeByName(NameStr(tupdesc->attrs[i].attname), tupdesc->tdhasoid) != NULL)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column name \"%s\" conflicts with a system column name",
NameStr(tupdesc->attrs[i]->attname))));
NameStr(tupdesc->attrs[i].attname))));
}
}
@ -742,10 +742,10 @@ void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, bool allow_system
*/
for (i = 1; i < natts; i++) {
for (j = 0; j < i; j++) {
if (strcmp(NameStr(tupdesc->attrs[j]->attname), NameStr(tupdesc->attrs[i]->attname)) == 0)
if (strcmp(NameStr(tupdesc->attrs[j].attname), NameStr(tupdesc->attrs[i].attname)) == 0)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column name \"%s\" specified more than once", NameStr(tupdesc->attrs[j]->attname))));
errmsg("column name \"%s\" specified more than once", NameStr(tupdesc->attrs[j].attname))));
}
}
@ -753,9 +753,9 @@ void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, bool allow_system
* next check the attribute types
*/
for (i = 0; i < natts; i++) {
CheckAttributeType(NameStr(tupdesc->attrs[i]->attname),
tupdesc->attrs[i]->atttypid,
tupdesc->attrs[i]->attcollation,
CheckAttributeType(NameStr(tupdesc->attrs[i].attname),
tupdesc->attrs[i].atttypid,
tupdesc->attrs[i].attcollation,
NIL, /* assume we're creating a new rowtype */
allow_system_table_mods);
}
@ -846,7 +846,7 @@ void CheckAttributeType(
tupdesc = RelationGetDescr(relation);
for (i = 0; i < tupdesc->natts; i++) {
Form_pg_attribute attr = tupdesc->attrs[i];
Form_pg_attribute attr = &tupdesc->attrs[i];
if (attr->attisdropped)
continue;
@ -1003,7 +1003,7 @@ static void AddNewAttributeTuples(Oid new_rel_oid, TupleDesc tupdesc, char relki
* add dependencies on their datatypes and collations.
*/
for (i = 0; i < natts; i++) {
attr = tupdesc->attrs[i];
attr = &tupdesc->attrs[i];
/* Fill in the correct relation OID */
attr->attrelid = new_rel_oid;
/* Make sure these are OK, too */
@ -1339,13 +1339,13 @@ static List* GetDistColsPos(DistributeBy* distributeBy, TupleDesc desc)
List* pos = NULL;
ListCell* cell = NULL;
char* colname = NULL;
Form_pg_attribute *attrs = desc->attrs;
FormData_pg_attribute *attrs = desc->attrs;
foreach (cell, distributeBy->colname) {
colname = strVal((Value*)lfirst(cell));
for (i = 0; i < desc->natts; i++) {
if (strcmp(colname, attrs[i]->attname.data) == 0) {
if (strcmp(colname, attrs[i].attname.data) == 0) {
break;
}
}
@ -1478,7 +1478,7 @@ static int GetTotalBoundariesNum(List* sliceList)
return result;
}
static void CheckDuplicateListSlices(List* pos, Form_pg_attribute* attrs, DistributeBy *distby)
static void CheckDuplicateListSlices(List* pos, FormData_pg_attribute* attrs, DistributeBy *distby)
{
List* boundary = NULL;
List* sliceList = NULL;
@ -1546,7 +1546,7 @@ static void CheckOneBoundaryValue(List* boundary, List* posList, TupleDesc desc)
Const* targetConst = NULL;
ListCell* boundaryCell = NULL;
ListCell* posCell = NULL;
Form_pg_attribute* attrs = desc->attrs;
FormData_pg_attribute* attrs = desc->attrs;
forboth(boundaryCell, boundary, posCell, posList) {
srcConst = (Const*)lfirst(boundaryCell);
@ -1555,7 +1555,7 @@ static void CheckOneBoundaryValue(List* boundary, List* posList, TupleDesc desc)
}
pos = lfirst_int(posCell);
targetConst = (Const*)GetTargetValue(attrs[pos], srcConst, false);
targetConst = (Const*)GetTargetValue(&attrs[pos], srcConst, false);
if (!PointerIsValid(targetConst)) {
ereport(ERROR,
(errcode(ERRCODE_INVALID_OPERATION),
@ -1796,7 +1796,7 @@ static void CheckSliceReferenceValidity(Oid relid, DistributeBy *distributeby, T
baseKeyType = get_atttype(distributeby->referenceoid, baseKeyIdx);
keyIdx = get_attnum(relid, colname);
keyType = descriptor->attrs[keyIdx - 1]->atttypid;
keyType = descriptor->attrs[keyIdx - 1].atttypid;
if (baseKeyType != keyType) {
FreeRelationLocInfo(baseLocInfo);
@ -2015,14 +2015,14 @@ static void CheckDistributeKeyAndType(Oid relid, DistributeBy *distributeby,
}
if (distributeby->disttype == DISTTYPE_LIST || distributeby->disttype == DISTTYPE_RANGE) {
if (!IsTypeDistributableForSlice(descriptor->attrs[localAttrNum - 1]->atttypid)) {
if (!IsTypeDistributableForSlice(descriptor->attrs[localAttrNum - 1].atttypid)) {
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("Column %s is not a %s distributable data type", colname,
GetDistributeTypeName(distributeby->disttype))));
}
} else {
if (!IsTypeDistributable(descriptor->attrs[localAttrNum - 1]->atttypid)) {
if (!IsTypeDistributable(descriptor->attrs[localAttrNum - 1].atttypid)) {
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("Column %s is not a %s distributable data type", colname,
@ -2054,14 +2054,14 @@ void GetRelationDistributionItems(Oid relid, DistributeBy* distributeby, TupleDe
* one based on primary key or foreign key, use first column with
* a supported data type.
*/
Form_pg_attribute attr;
FormData_pg_attribute attr;
int i;
local_locatortype = LOCATOR_TYPE_HASH;
for (i = 0; i < descriptor->natts; i++) {
attr = descriptor->attrs[i];
if (IsTypeDistributable(attr->atttypid)) {
if (IsTypeDistributable(attr.atttypid)) {
/* distribute on this column */
local_attnum = i + 1;
attnum[0] = local_attnum;
@ -2077,7 +2077,7 @@ void GetRelationDistributionItems(Oid relid, DistributeBy* distributeby, TupleDe
(errcode(ERRCODE_SUCCESSFUL_COMPLETION),
errmsg("The 'DISTRIBUTE BY' clause is not specified. Using '%s' as the distribution column "
"by default.",
attr->attname.data),
attr.attname.data),
errhint(
"Please use 'DISTRIBUTE BY' clause to specify suitable data distribution column.")));
break;
@ -2194,7 +2194,7 @@ HashBucketInfo* GetRelationBucketInfo(DistributeBy* distributeby,
bucketkey = buildint2vector(NULL, 1);
for (i = 0; i < nattr; i++) {
attr = tupledsc->attrs[i];
attr = &tupledsc->attrs[i];
if (IsTypeDistributable(attr->atttypid)) {
bucketkey->values[0] = attr->attnum;
bucketinfo->bucketcol = bucketkey;
@ -2231,7 +2231,7 @@ HashBucketInfo* GetRelationBucketInfo(DistributeBy* distributeby,
foreach (cell, distributeby->colname) {
colname = strVal(lfirst(cell));
for (j = 0; j < nattr; j++) {
attr = tupledsc->attrs[j];
attr = &tupledsc->attrs[j];
if (strcmp(colname, attr->attname.data) == 0) {
local_attnum = attr->attnum;
break;
@ -3931,7 +3931,7 @@ List* AddRelationNewConstraints(
*/
foreach (cell, newColDefaults) {
RawColumnDefault* colDef = (RawColumnDefault*)lfirst(cell);
Form_pg_attribute atp = rel->rd_att->attrs[colDef->attnum - 1];
Form_pg_attribute atp = &rel->rd_att->attrs[colDef->attnum - 1];
expr = cookDefault(pstate, colDef->raw_default, atp->atttypid, atp->atttypmod, NameStr(atp->attname),
colDef->generatedCol);
@ -4979,7 +4979,7 @@ int2vector* buildPartitionKey(List* keys, TupleDesc tupledsc)
int partkeyNum = keys->length;
char* columName = NULL;
bool finded = false;
Form_pg_attribute* attrs = tupledsc->attrs;
FormData_pg_attribute* attrs = tupledsc->attrs;
int2vector* partkey = NULL;
partkey = buildint2vector(NULL, partkeyNum);
@ -4988,8 +4988,8 @@ int2vector* buildPartitionKey(List* keys, TupleDesc tupledsc)
columName = ((Value*)linitial(col->fields))->val.str;
finded = false;
for (j = 0; j < attnum; j++) {
if (strcmp(columName, attrs[j]->attname.data) == 0) {
partkey->values[i] = attrs[j]->attnum;
if (strcmp(columName, attrs[j].attname.data) == 0) {
partkey->values[i] = attrs[j].attnum;
finded = true;
break;
}
@ -6828,7 +6828,7 @@ static void IsPartitionKeyContainTimestampwithzoneType(const PartitionState *par
char *columName = NULL;
int partKeyIdx = 0;
int attnum = tupledesc->natts;
Form_pg_attribute *attrs = tupledesc->attrs;
FormData_pg_attribute *attrs = tupledesc->attrs;
foreach (partKeyCell, partTableState->partitionKey) {
col = (ColumnRef *)lfirst(partKeyCell);
@ -6836,7 +6836,7 @@ static void IsPartitionKeyContainTimestampwithzoneType(const PartitionState *par
isTimestamptz[partKeyIdx] = false;
for (int i = 0; i < attnum; i++) {
if (TIMESTAMPTZOID == attrs[i]->atttypid && 0 == strcmp(columName, attrs[i]->attname.data)) {
if (TIMESTAMPTZOID == attrs[i].atttypid && 0 == strcmp(columName, attrs[i].attname.data)) {
isTimestamptz[partKeyIdx] = true;
break;
}
@ -7517,15 +7517,15 @@ char* make_column_map(TupleDesc tuple_desc)
{
#define COLS_IN_BYTE 8
Form_pg_attribute* attrs = tuple_desc->attrs;
FormData_pg_attribute* attrs = tuple_desc->attrs;
char* col_map = (char*)palloc0((MaxHeapAttributeNumber + COLS_IN_BYTE) / COLS_IN_BYTE);
int col_cnt;
Assert(tuple_desc->natts > 0);
for (col_cnt = 0; col_cnt < tuple_desc->natts; col_cnt++) {
if (!attrs[col_cnt]->attisdropped && attrs[col_cnt]->attnum > 0) {
col_map[attrs[col_cnt]->attnum >> 3] |= (1 << (attrs[col_cnt]->attnum % COLS_IN_BYTE));
if (!attrs[col_cnt].attisdropped && attrs[col_cnt].attnum > 0) {
col_map[attrs[col_cnt].attnum >> 3] |= (1 << (attrs[col_cnt].attnum % COLS_IN_BYTE));
}
}
@ -7549,7 +7549,7 @@ bool* CheckPartkeyHasTimestampwithzone(Relation partTableRel, bool isForSubParti
int16* attnums = NULL;
int relationAttNumber = 0;
TupleDesc relationTupleDesc = NULL;
Form_pg_attribute* relationAtts = NULL;
FormData_pg_attribute* relationAtts = NULL;
pgPartRel = relation_open(PartitionRelationId, AccessShareLock);
@ -7606,7 +7606,7 @@ bool* CheckPartkeyHasTimestampwithzone(Relation partTableRel, bool isForSubParti
for (int i = 0; i < n_key_column; i++) {
int attnum = (int)(attnums[i]);
if (attnum >= 1 && attnum <= relationAttNumber) {
if (relationAtts[attnum - 1]->atttypid == TIMESTAMPTZOID) {
if (relationAtts[attnum - 1].atttypid == TIMESTAMPTZOID) {
isTimestamptz[i] = true;
}
} else {

View File

@ -304,7 +304,7 @@ static TupleDesc ConstructTupleDescriptor(Relation heapRelation, IndexInfo* inde
/*
* allocate the new tuple descriptor
*/
indexTupDesc = CreateTemplateTupleDesc(numatts, false, TAM_HEAP);
indexTupDesc = CreateTemplateTupleDesc(numatts, false);
/*
* For simple index columns, we copy the pg_attribute row from the parent
@ -313,7 +313,7 @@ static TupleDesc ConstructTupleDescriptor(Relation heapRelation, IndexInfo* inde
*/
for (i = 0; i < numatts; i++) {
AttrNumber atnum = indexInfo->ii_KeyAttrNumbers[i];
Form_pg_attribute to = indexTupDesc->attrs[i];
Form_pg_attribute to = &indexTupDesc->attrs[i];
HeapTuple tuple;
Form_pg_type typeTup;
Form_pg_opclass opclassTup;
@ -336,7 +336,7 @@ static TupleDesc ConstructTupleDescriptor(Relation heapRelation, IndexInfo* inde
if (atnum > natts) /* safety check */
ereport(
ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid column number %d", atnum)));
from = heapTupDesc->attrs[AttrNumberGetAttrOffset(atnum)];
from = &heapTupDesc->attrs[AttrNumberGetAttrOffset(atnum)];
}
/*
@ -499,7 +499,7 @@ static void InitializeAttributeOids(Relation indexRelation, int numatts, Oid ind
tupleDescriptor = RelationGetDescr(indexRelation);
for (i = 0; i < numatts; i += 1)
tupleDescriptor->attrs[i]->attrelid = indexoid;
tupleDescriptor->attrs[i].attrelid = indexoid;
}
/* ----------------------------------------------------------------
@ -530,10 +530,10 @@ static void AppendAttributeTuples(Relation indexRelation, int numatts)
* There used to be very grotty code here to set these fields, but I
* think it's unnecessary. They should be set already.
*/
Assert(indexTupDesc->attrs[i]->attnum == i + 1);
Assert(indexTupDesc->attrs[i]->attcacheoff == -1);
Assert(indexTupDesc->attrs[i].attnum == i + 1);
Assert(indexTupDesc->attrs[i].attcacheoff == -1);
InsertPgAttributeTuple(pg_attribute, indexTupDesc->attrs[i], indstate);
InsertPgAttributeTuple(pg_attribute, &indexTupDesc->attrs[i], indstate);
}
CatalogCloseIndexes(indstate);
@ -3435,7 +3435,7 @@ double IndexBuildUHeapScan(Relation heapRelation, Relation indexRelation, IndexI
*/
estate = CreateExecutorState();
econtext = GetPerTupleExprContext(estate);
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation), false, TAM_USTORE);
slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation), false, TableAmUstore);
/* Arrange for econtext's scan tuple to be the tuple under test */
econtext->ecxt_scantuple = slot;
@ -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, 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, 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, partTableRel->rd_tam_type);
slot = MakeSingleTupleTableSlot(RelationGetDescr(partTableRel), false, partTableRel->rd_tam_ops);
}
scan = scan_handler_tbl_beginscan(partRel, SnapshotNow, 0, NULL);
@ -6169,7 +6169,7 @@ TupleDesc GetPsortTupleDesc(TupleDesc indexTupDesc)
/* Add key columns */
for (int i = 0; i < numatts - 1; i++) {
Form_pg_attribute from = indexTupDesc->attrs[i];
Form_pg_attribute from = &indexTupDesc->attrs[i];
AttrNumber attId = i + 1;
TupleDescInitEntry(psortTupDesc, attId, from->attname.data, from->atttypid, from->atttypmod, from->attndims);

View File

@ -4508,7 +4508,7 @@ static void InitTempTableNamespace(void)
ret = snprintf_s(
str, sizeof(str), sizeof(str) - 1, "CREATE SCHEMA %s AUTHORIZATION \"%s\"", namespaceName, bootstrap_username);
securec_check_ss(ret, "\0", "\0");
ProcessUtility((Node*)create_stmt, str, NULL, false, None_Receiver, false, NULL);
ProcessUtility((Node*)create_stmt, str, false, NULL, false, None_Receiver, false, NULL);
if (IS_PGXC_COORDINATOR)
if (PoolManagerSetCommand(POOL_CMD_TEMP, namespaceName) < 0)
@ -4561,7 +4561,7 @@ static void InitTempTableNamespace(void)
toastNamespaceName,
bootstrap_username);
securec_check_ss(ret, "\0", "\0");
ProcessUtility((Node*)create_stmt, str, NULL, false, None_Receiver, false, NULL);
ProcessUtility((Node*)create_stmt, str, false, NULL, false, None_Receiver, false, NULL);
/* Advance command counter to make namespace visible */
CommandCounterIncrement();
@ -5384,7 +5384,7 @@ dropExistTempNamespace(char *namespaceName)
ereport(NOTICE, (errmsg("Deleting invalid temp schema %s.", namespaceName)));
ret = snprintf_s(str, sizeof(str), sizeof(str) - 1, "DROP SCHEMA %s CASCADE", namespaceName);
securec_check_ss(ret, "\0", "\0");
ProcessUtility((Node*)drop_stmt, str, NULL, false, None_Receiver, false, NULL);
ProcessUtility((Node*)drop_stmt, str, false, NULL, false, None_Receiver, false, NULL);
CommandCounterIncrement();
}

View File

@ -998,7 +998,7 @@ int pgxc_find_primarykey(Oid relid, int16** indexed_col, bool check_is_immediate
* 1. skip expression index( it is an expression index when index attribute is zero )
* 2. skip the idex if the index key is null
*/
if (!idxKey || !rel->rd_att->attrs[idxKey - 1]->attnotnull) {
if (!idxKey || !rel->rd_att->attrs[idxKey - 1].attnotnull) {
equalPrimaryKey = false;
break;
}

View File

@ -888,8 +888,8 @@ static void get_interval_nextdate_by_spi(int4 job_id, bool ischeck, const char*
/* The result should be timestamp type or interval type. */
if (!(SPI_tuptable && SPI_tuptable->tupdesc &&
(SPI_tuptable->tupdesc->attrs[0]->atttypid == TIMESTAMPOID ||
SPI_tuptable->tupdesc->attrs[0]->atttypid == INTERVALOID))) {
(SPI_tuptable->tupdesc->attrs[0].atttypid == TIMESTAMPOID ||
SPI_tuptable->tupdesc->attrs[0].atttypid == INTERVALOID))) {
ereport(ERROR,
(errcode(ERRCODE_SPI_ERROR), errmsg("Execute job interval for get next_date error, job_id: %d.", job_id)));
}
@ -897,12 +897,12 @@ static void get_interval_nextdate_by_spi(int4 job_id, bool ischeck, const char*
/* We don't need get value if only check the interval is valid. */
if (!ischeck) {
/* If INTERVALOID, start_date+INTERVALOID=next_date */
if (INTERVALOID == SPI_tuptable->tupdesc->attrs[0]->atttypid) {
if (INTERVALOID == SPI_tuptable->tupdesc->attrs[0].atttypid) {
Datum new_interval = heap_getattr(SPI_tuptable->vals[0], 1, SPI_tuptable->tupdesc, &isnull);
MemoryContext oldcontext = MemoryContextSwitchTo(current_context);
new_interval = datumCopy(
new_interval, SPI_tuptable->tupdesc->attrs[0]->attbyval, SPI_tuptable->tupdesc->attrs[0]->attlen);
new_interval, SPI_tuptable->tupdesc->attrs[0].attbyval, SPI_tuptable->tupdesc->attrs[0].attlen);
*new_next_date = DirectFunctionCall2(timestamp_pl_interval, start_date, new_interval);
(void)MemoryContextSwitchTo(oldcontext);
} else {
@ -910,7 +910,7 @@ static void get_interval_nextdate_by_spi(int4 job_id, bool ischeck, const char*
}
} else {
/* The interval should greater than current time if it is timestamp. */
if (TIMESTAMPOID == SPI_tuptable->tupdesc->attrs[0]->atttypid) {
if (TIMESTAMPOID == SPI_tuptable->tupdesc->attrs[0].atttypid) {
Datum check_next_date;
check_next_date = heap_getattr(SPI_tuptable->vals[0], 1, SPI_tuptable->tupdesc, &isnull);

View File

@ -106,8 +106,8 @@ static void GetDistribColsTzFlag(DistributeBy *distributeby, TupleDesc desc, boo
colname = strVal(lfirst(cell));
isTimestampTz[i] = false;
for (int j = 0; j < desc->natts; j++) {
if (desc->attrs[j]->atttypid == TIMESTAMPTZOID &&
strcmp(colname, desc->attrs[j]->attname.data) == 0) {
if (desc->attrs[j].atttypid == TIMESTAMPTZOID &&
strcmp(colname, desc->attrs[j].attname.data) == 0) {
isTimestampTz[i] = true;
break;
}

View File

@ -351,11 +351,11 @@ static void CStoreRelDropStorage(Relation rel, RelFileNode* rnode, Oid ownerid)
TupleDesc desc = RelationGetDescr(rel);
int nattrs = desc->natts;
Form_pg_attribute* attrs = desc->attrs;
FormData_pg_attribute* attrs = desc->attrs;
/* add all the cu files to the list of stuff to delete at commit */
for (int i = 0; i < nattrs; ++i) {
InsertStorageIntoPendingList(rnode, attrs[i]->attnum, rel->rd_backend, ownerid, true);
InsertStorageIntoPendingList(rnode, attrs[i].attnum, rel->rd_backend, ownerid, true);
}
}

View File

@ -205,9 +205,9 @@ static bool create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Da
* toast :-(. This is essential for chunk_data because type bytea is
* toastable; hit the other two just to be sure.
*/
tupdesc->attrs[0]->attstorage = 'p';
tupdesc->attrs[1]->attstorage = 'p';
tupdesc->attrs[2]->attstorage = 'p';
tupdesc->attrs[0].attstorage = 'p';
tupdesc->attrs[1].attstorage = 'p';
tupdesc->attrs[2].attstorage = 'p';
/*
* Toast tables for regular relations go in pg_toast; those for temp
@ -525,7 +525,7 @@ static bool needs_toast_table(Relation rel)
bool maxlength_unknown = false;
bool has_toastable_attrs = false;
TupleDesc tupdesc;
Form_pg_attribute* att = NULL;
FormData_pg_attribute* att = NULL;
int32 tuple_length;
int i;
@ -548,19 +548,19 @@ static bool needs_toast_table(Relation rel)
att = tupdesc->attrs;
for (i = 0; i < tupdesc->natts; i++) {
if (att[i]->attisdropped)
if (att[i].attisdropped)
continue;
data_length = att_align_nominal(data_length, att[i]->attalign);
if (att[i]->attlen > 0) {
data_length = att_align_nominal(data_length, att[i].attalign);
if (att[i].attlen > 0) {
/* Fixed-length types are never toastable */
data_length += att[i]->attlen;
data_length += att[i].attlen;
} else {
int32 maxlen = type_maximum_size(att[i]->atttypid, att[i]->atttypmod);
int32 maxlen = type_maximum_size(att[i].atttypid, att[i].atttypmod);
if (maxlen < 0)
maxlength_unknown = true;
else
data_length += maxlen;
if (att[i]->attstorage != 'p')
if (att[i].attstorage != 'p')
has_toastable_attrs = true;
}
}
@ -741,7 +741,7 @@ static void InitTempToastNamespace(void)
toastNamespaceName,
bootstrap_username);
securec_check_ss(ret, "\0", "\0");
ProcessUtility((Node*)create_stmt, str, NULL, false, None_Receiver, false, NULL);
ProcessUtility((Node*)create_stmt, str, false, NULL, false, None_Receiver, false, NULL);
/* Advance command counter to make namespace visible */
CommandCounterIncrement();
@ -790,9 +790,9 @@ bool create_toast_by_sid(Oid *toastOid)
* toast :-(. This is essential for chunk_data because type bytea is
* toastable; hit the other two just to be sure.
*/
tupdesc->attrs[0]->attstorage = 'p';
tupdesc->attrs[1]->attstorage = 'p';
tupdesc->attrs[2]->attstorage = 'p';
tupdesc->attrs[0].attstorage = 'p';
tupdesc->attrs[1].attstorage = 'p';
tupdesc->attrs[2].attstorage = 'p';
if (OidIsValid(u_sess->catalog_cxt.myTempToastNamespace)) {
namespaceid = GetTempToastNamespace();
} else {

View File

@ -1333,7 +1333,7 @@ Datum get_client_info(PG_FUNCTION_ARGS)
Tuplestorestate* tupstore = NULL;
const int COLUMN_NUM = 2;
MemoryContext oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
tupdesc = CreateTemplateTupleDesc(COLUMN_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(COLUMN_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "sid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "client_info", TEXTOID, -1, 0);

View File

@ -1926,7 +1926,7 @@ List* BuildExcludedTargetlist(Relation targetrel, Index exclRelIndex)
* underlying relation, hence we need entries for dropped columns too.
*/
for (attno = 0; attno < RelationGetNumberOfAttributes(targetrel); attno++) {
Form_pg_attribute attr = targetrel->rd_att->attrs[attno];
Form_pg_attribute attr = &targetrel->rd_att->attrs[attno];
char* name = NULL;
if (attr->attisdropped) {

View File

@ -905,7 +905,7 @@ static Node* coerce_record_to_complex(
Oid exprtype;
/* Fill in NULLs for dropped columns in rowtype */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
/*
* can't use atttypid here, but it doesn't really matter what type
* the Const claims to be.
@ -926,8 +926,8 @@ static Node* coerce_record_to_complex(
cexpr = coerce_to_target_type(pstate,
expr,
exprtype,
tupdesc->attrs[i]->atttypid,
tupdesc->attrs[i]->atttypmod,
tupdesc->attrs[i].atttypid,
tupdesc->attrs[i].atttypmod,
ccontext,
COERCE_IMPLICIT_CAST,
-1);
@ -937,7 +937,7 @@ static Node* coerce_record_to_complex(
errmsg("cannot cast type %s to %s", format_type_be(RECORDOID), format_type_be(targetTypeId)),
errdetail("Cannot cast type %s to %s in column %d.",
format_type_be(exprtype),
format_type_be(tupdesc->attrs[i]->atttypid),
format_type_be(tupdesc->attrs[i].atttypid),
ucolno),
parser_coercion_errposition(pstate, location, expr)));
}

View File

@ -1925,7 +1925,7 @@ static Node* ParseComplexProjection(ParseState* pstate, char* funcname, Node* fi
AssertEreport(tupdesc, MOD_OPT, "");
for (i = 0; i < tupdesc->natts; i++) {
Form_pg_attribute att = tupdesc->attrs[i];
Form_pg_attribute att = &tupdesc->attrs[i];
if (strcmp(funcname, NameStr(att->attname)) == 0 && !att->attisdropped) {
/* Success, so generate a FieldSelect expression */

View File

@ -2687,13 +2687,13 @@ static void set_colinfo_by_relation(Oid relid, int location, SkewColumnInfo* col
relation = heap_open(relid, AccessShareLock);
Assert((location + 1) == relation->rd_att->attrs[location]->attnum);
Assert((location + 1) == relation->rd_att->attrs[location].attnum);
/* Set column info. */
column_info->relation_Oid = relation->rd_att->attrs[location]->attrelid;
column_info->relation_Oid = relation->rd_att->attrs[location].attrelid;
column_info->column_name = column_name;
column_info->attnum = relation->rd_att->attrs[location]->attnum;
column_info->column_typid = relation->rd_att->attrs[location]->atttypid;
column_info->attnum = relation->rd_att->attrs[location].attnum;
column_info->column_typid = relation->rd_att->attrs[location].atttypid;
column_info->expr = NULL;
heap_close(relation, AccessShareLock);

View File

@ -289,7 +289,7 @@ static Node* build_equal_expr(
RangeSubselect* range_subselect = (RangeSubselect*)stmt->source_relation;
char* target_aliasname = stmt->relation->alias->aliasname;
int attrno = index_info->ii_KeyAttrNumbers[index];
char* attname = pstrdup(NameStr(target_relation->rd_att->attrs[attrno - 1]->attname));
char* attname = pstrdup(NameStr(target_relation->rd_att->attrs[attrno - 1].attname));
char* source_aliasname = range_subselect->alias->aliasname;
/* build the left expr of the equal expr, which comes from the target relation's index */
@ -1651,7 +1651,7 @@ static void check_target_table_columns(ParseState* pstate, bool is_insert_update
"with column (%s) of unstable default value.",
is_insert_update ? "INSERT ... ON DUPLICATE KEY UPDATE" : "MERGE INTO",
RelationGetRelationName(target_relation),
NameStr(target_relation->rd_att->attrs[attrno - 1]->attname))));
NameStr(target_relation->rd_att->attrs[attrno - 1].attname))));
}
}
list_free_deep(rel_valid_cols);
@ -1814,7 +1814,7 @@ static Bitmapset* get_relation_default_attno_bitmap(Relation relation)
Bitmapset* bitmap = NULL;
Form_pg_attribute attr = NULL;
for (int i = 0; i < RelationGetNumberOfAttributes(relation); i++) {
attr = relation->rd_att->attrs[i];
attr = &relation->rd_att->attrs[i];
if (attr->atthasdef && !attr->attisdropped) {
bitmap = bms_add_member(bitmap, attr->attnum);

View File

@ -895,7 +895,7 @@ static void buildRelationAliases(TupleDesc tupdesc, Alias* alias, Alias* eref)
}
for (varattno = 0; varattno < maxattrs; varattno++) {
Form_pg_attribute attr = tupdesc->attrs[varattno];
Form_pg_attribute attr = &tupdesc->attrs[varattno];
Value* attrname = NULL;
if (attr->attisdropped) {
@ -2237,7 +2237,7 @@ static void expandTupleDesc(TupleDesc tupdesc, Alias* eref, int rtindex, int sub
int varattno;
for (varattno = 0; varattno < maxattrs; varattno++) {
Form_pg_attribute attr = tupdesc->attrs[varattno];
Form_pg_attribute attr = &tupdesc->attrs[varattno];
if (attr->attisdropped) {
if (include_dropped) {
@ -2517,7 +2517,7 @@ void get_rte_attribute_type(RangeTblEntry* rte, AttrNumber attnum, Oid* vartype,
errmsg("column %d of relation \"%s\" does not exist", attnum, rte->eref->aliasname)));
}
att_tup = tupdesc->attrs[attnum - 1];
att_tup = &tupdesc->attrs[attnum - 1];
/*
* If dropped column, pretend it ain't there. See notes
@ -2759,7 +2759,7 @@ int attnameAttNum(Relation rd, const char* attname, bool sysColOK)
int i;
for (i = 0; i < rd->rd_rel->relnatts; i++) {
Form_pg_attribute att = rd->rd_att->attrs[i];
Form_pg_attribute att = &rd->rd_att->attrs[i];
if (namestrcmp(&(att->attname), attname) == 0 && !att->attisdropped) {
return i + 1;
@ -2823,7 +2823,7 @@ Name attnumAttName(Relation rd, int attid)
if (attid > rd->rd_att->natts) {
ereport(ERROR, (errcode(ERRCODE_INVALID_ATTRIBUTE), errmsg("invalid attribute number %d", attid)));
}
return &rd->rd_att->attrs[attid - 1]->attname;
return &rd->rd_att->attrs[attid - 1].attname;
}
/*
@ -2845,7 +2845,7 @@ Oid attnumTypeId(Relation rd, int attid)
if (attid > rd->rd_att->natts) {
ereport(ERROR, (errcode(ERRCODE_INVALID_ATTRIBUTE), errmsg("invalid attribute number %d", attid)));
}
return rd->rd_att->attrs[attid - 1]->atttypid;
return rd->rd_att->attrs[attid - 1].atttypid;
}
/*
@ -2862,7 +2862,7 @@ Oid attnumCollationId(Relation rd, int attid)
if (attid > rd->rd_att->natts) {
ereport(ERROR, (errcode(ERRCODE_INVALID_ATTRIBUTE), errmsg("invalid attribute number %d", attid)));
}
return rd->rd_att->attrs[attid - 1]->attcollation;
return rd->rd_att->attrs[attid - 1].attcollation;
}
/*

View File

@ -398,8 +398,8 @@ Expr* transformAssignedExpr(ParseState* pstate, Expr* expr, ParseExprKind exprKi
parser_errposition(pstate, location)));
}
attrtype = attnumTypeId(rd, attrno);
attrtypmod = rd->rd_att->attrs[attrno - 1]->atttypmod;
attrcollation = rd->rd_att->attrs[attrno - 1]->attcollation;
attrtypmod = rd->rd_att->attrs[attrno - 1].atttypmod;
attrcollation = rd->rd_att->attrs[attrno - 1].attcollation;
/*
* If the expression is a DEFAULT placeholder, insert the attribute's
@ -857,7 +857,7 @@ List* checkInsertTargets(ParseState* pstate, List* cols, List** attrnos)
errmsg("pstate->p_target_relation is NULL unexpectedly")));
}
Form_pg_attribute* attr = pstate->p_target_relation->rd_att->attrs;
FormData_pg_attribute* attr = pstate->p_target_relation->rd_att->attrs;
int numcol = RelationGetNumberOfAttributes(pstate->p_target_relation);
int i;
is_blockchain_rel = pstate->p_target_relation->rd_isblockchain;
@ -865,7 +865,7 @@ List* checkInsertTargets(ParseState* pstate, List* cols, List** attrnos)
for (i = 0; i < numcol; i++) {
ResTarget* col = NULL;
if (attr[i]->attisdropped) {
if (attr[i].attisdropped) {
continue;
}
/* If the hidden column in timeseries relation, skip it */
@ -874,7 +874,7 @@ List* checkInsertTargets(ParseState* pstate, List* cols, List** attrnos)
}
col = makeNode(ResTarget);
col->name = pstrdup(NameStr(attr[i]->attname));
col->name = pstrdup(NameStr(attr[i].attname));
if (is_blockchain_rel && strcmp(col->name, "hash") == 0) {
continue;
}
@ -1263,7 +1263,7 @@ static List* ExpandRowReference(ParseState* pstate, Node* expr, bool targetlist)
/* Generate a list of references to the individual fields */
numAttrs = tupleDesc->natts;
for (i = 0; i < numAttrs; i++) {
Form_pg_attribute att = tupleDesc->attrs[i];
Form_pg_attribute att = &tupleDesc->attrs[i];
FieldSelect* fselect = NULL;
if (att->attisdropped) {

View File

@ -11,10 +11,6 @@
* Hence these functions are now called at the start of execution of their
* respective utility commands.
*
* NOTE: in general we must avoid scribbling on the passed-in raw parse
* tree, since it might be in a plan cache. The simplest solution is
* a quick copyObject() call before manipulating the query tree.
*
*
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
@ -169,7 +165,7 @@ static void check_partition_name_less_than(List* partitionList, bool isPartition
static void check_partition_name_start_end(List* partitionList, bool isPartition);
/* for range partition: start/end syntax */
static void precheck_start_end_defstate(List* pos, Form_pg_attribute* attrs,
static void precheck_start_end_defstate(List* pos, FormData_pg_attribute* attrs,
RangePartitionStartEndDefState* defState, bool isPartition);
static Datum get_partition_arg_value(Node* node, bool* isnull);
static Datum evaluate_opexpr(
@ -216,11 +212,6 @@ Oid *namespaceid, bool isFirstNode)
Oid existing_relid;
bool is_ledger_nsp = false;
bool is_row_table = is_ledger_rowstore(stmt->options);
/*
* We must not scribble on the passed-in CreateStmt, so copy it. (This is
* overkill, but easy.)
*/
stmt = (CreateStmt*)copyObject(stmt);
if (uuids != NIL) {
list_free_deep(stmt->uuids);
@ -1271,7 +1262,7 @@ static DistributeBy* GetHideTagDistribution(TupleDesc tupleDesc)
DistributeBy* distributeby = makeNode(DistributeBy);
distributeby->disttype = DISTTYPE_HASH;
for (int attno = 1; attno <= tupleDesc->natts; attno++) {
Form_pg_attribute attribute = tupleDesc->attrs[attno - 1];
Form_pg_attribute attribute = &tupleDesc->attrs[attno - 1];
char* attributeName = NameStr(attribute->attname);
if (attribute->attkvtype == ATT_KV_TAG) {
distributeby->colname = lappend(distributeby->colname, makeString(attributeName));
@ -1549,7 +1540,7 @@ static void transformTableLikeClause(
*/
bool hideTag = false;
for (parent_attno = 1; parent_attno <= tupleDesc->natts; parent_attno++) {
Form_pg_attribute attribute = tupleDesc->attrs[parent_attno - 1];
Form_pg_attribute attribute = &tupleDesc->attrs[parent_attno - 1];
char* attributeName = NameStr(attribute->attname);
ColumnDef* def = NULL;
@ -1815,7 +1806,7 @@ static void transformTableLikeClause(
for (pckNum = 0; pckNum < tupleDesc->constr->clusterKeyNum; pckNum++) {
AttrNumber attrNum = tupleDesc->constr->clusterKeys[pckNum];
Form_pg_attribute attribute = tupleDesc->attrs[attrNum - 1];
Form_pg_attribute attribute = &tupleDesc->attrs[attrNum - 1];
char* attrName = NameStr(attribute->attname);
n->contype = CONSTR_CLUSTER;
@ -2080,7 +2071,7 @@ static void transformTableLikePartitionKeys(
ColumnRef* c = NULL;
Relation partitionRel = NULL;
TupleDesc relationTupleDesc = NULL;
Form_pg_attribute* relationAtts = NULL;
FormData_pg_attribute* relationAtts = NULL;
int relationAttNumber = 0;
Datum partkey_raw = (Datum)0;
ArrayType* partkey_columns = NULL;
@ -2131,7 +2122,7 @@ static void transformTableLikePartitionKeys(
int attnum = (int)(attnums[i]);
if (attnum >= 1 && attnum <= relationAttNumber) {
c = makeNode(ColumnRef);
c->fields = list_make1(makeString(pstrdup(NameStr(relationAtts[attnum - 1]->attname))));
c->fields = list_make1(makeString(pstrdup(NameStr(relationAtts[attnum - 1].attname))));
*partKeyColumns = lappend(*partKeyColumns, c);
*partKeyPosList = lappend_int(*partKeyPosList, attnum - 1);
} else {
@ -2222,7 +2213,7 @@ static void transformTableLikePartitionBoundaries(
Value* boundaryValue = NULL;
Datum boundaryDatum = (Datum)0;
Node* boundaryNode = NULL;
Form_pg_attribute* relation_atts = NULL;
FormData_pg_attribute* relation_atts = NULL;
Form_pg_attribute att = NULL;
int partKeyPos = 0;
int16 typlen = 0;
@ -2247,7 +2238,7 @@ static void transformTableLikePartitionBoundaries(
{
boundaryValue = (Value*)lfirst(boundaryCell);
partKeyPos = (int)lfirst_int(partKeyCell);
att = relation_atts[partKeyPos];
att = &relation_atts[partKeyPos];
/* get the oid/mod/collation/ of partition key */
typid = att->atttypid;
@ -2305,7 +2296,7 @@ static void transformOfType(CreateStmtContext* cxt, TypeName* ofTypename)
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
for (i = 0; i < tupdesc->natts; i++) {
Form_pg_attribute attr = tupdesc->attrs[i];
Form_pg_attribute attr = &tupdesc->attrs[i];
ColumnDef* n = NULL;
if (attr->attisdropped)
@ -2416,7 +2407,7 @@ IndexStmt* generateClonedIndexStmt(
CreateStmtContext* cxt, Relation source_idx, const AttrNumber* attmap, int attmap_length, Relation rel, TransformTableType transformType)
{
Oid source_relid = RelationGetRelid(source_idx);
Form_pg_attribute* attrs = RelationGetDescr(source_idx)->attrs;
FormData_pg_attribute* attrs = RelationGetDescr(source_idx)->attrs;
HeapTuple ht_idxrel;
HeapTuple ht_idx;
Form_pg_class idxrelrec;
@ -2628,7 +2619,7 @@ IndexStmt* generateClonedIndexStmt(
}
/* Copy the original index column name */
iparam->indexcolname = pstrdup(NameStr(attrs[keyno]->attname));
iparam->indexcolname = pstrdup(NameStr(attrs[keyno].attname));
/* Add the collation name, if non-default */
iparam->collation = get_collation(indcollation->values[keyno], keycoltype);
@ -3178,7 +3169,7 @@ static IndexStmt* transformIndexConstraint(Constraint* constraint, CreateStmtCon
*/
if (attnum > 0) {
AssertEreport(attnum <= heap_rel->rd_att->natts, MOD_OPT, "");
attform = heap_rel->rd_att->attrs[attnum - 1];
attform = &heap_rel->rd_att->attrs[attnum - 1];
} else
attform = SystemAttributeDefinition(attnum, heap_rel->rd_rel->relhasoids, RELATION_HAS_BUCKET(heap_rel), RELATION_HAS_UIDS(heap_rel));
attname = pstrdup(NameStr(attform->attname));
@ -3283,7 +3274,7 @@ static IndexStmt* transformIndexConstraint(Constraint* constraint, CreateStmtCon
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("inherited relation \"%s\" is not a table", inh->relname)));
for (count = 0; count < rel->rd_att->natts; count++) {
Form_pg_attribute inhattr = rel->rd_att->attrs[count];
Form_pg_attribute inhattr = &rel->rd_att->attrs[count];
char* inhname = NameStr(inhattr->attname);
if (inhattr->attisdropped)
@ -3405,7 +3396,7 @@ static IndexStmt* transformIndexConstraint(Constraint* constraint, CreateStmtCon
errmsg("inherited relation \"%s\" is not a table or foreign table", inh->relname)));
}
for (count = 0; count < rel->rd_att->natts; count++) {
Form_pg_attribute inhattr = rel->rd_att->attrs[count];
Form_pg_attribute inhattr = &rel->rd_att->attrs[count];
char* inhname = NameStr(inhattr->attname);
if (inhattr->attisdropped)
@ -3580,12 +3571,6 @@ IndexStmt* transformIndexStmt(Oid relid, IndexStmt* stmt, const char* queryStrin
ListCell* l = NULL;
int crossbucketopt = -1; /* -1 means the SQL statement doesn't contain crossbucket option */
/*
* We must not scribble on the passed-in IndexStmt, so copy it. (This is
* overkill, but easy.)
*/
stmt = (IndexStmt*)copyObject(stmt);
/* Set up pstate */
pstate = make_parsestate(NULL);
pstate->p_sourcetext = queryString;
@ -3817,9 +3802,6 @@ static bool IsElementExisted(List* indexElements, IndexElem* ielem)
*
* actions and whereClause are output parameters that receive the
* transformed results.
*
* Note that we must not scribble on the passed-in RuleStmt, so we do
* copyObject() on the actions and WHERE clause.
*/
void transformRuleStmt(RuleStmt* stmt, const char* queryString, List** actions, Node** whereClause)
{
@ -3895,7 +3877,7 @@ void transformRuleStmt(RuleStmt* stmt, const char* queryString, List** actions,
}
/* take care of the where clause */
*whereClause = transformWhereClause(pstate, (Node*)copyObject(stmt->whereClause), EXPR_KIND_WHERE, "WHERE");
*whereClause = transformWhereClause(pstate, stmt->whereClause, EXPR_KIND_WHERE, "WHERE");
/* we have to fix its collations too */
assign_expr_collations(pstate, *whereClause);
@ -3966,7 +3948,7 @@ void transformRuleStmt(RuleStmt* stmt, const char* queryString, List** actions,
addRTEtoQuery(sub_pstate, newrte, false, true, false);
/* Transform the rule action statement */
top_subqry = transformStmt(sub_pstate, (Node*)copyObject(action));
top_subqry = transformStmt(sub_pstate, action);
/*
* We cannot support utility-statement actions (eg NOTIFY) with
* nonempty rule WHERE conditions, because there's no way to make
@ -4129,11 +4111,6 @@ List* transformAlterTableStmt(Oid relid, AlterTableStmt* stmt, const char* query
SplitPartitionState* splitDefState = NULL;
ListCell* cell = NULL;
/*
* We must not scribble on the passed-in AlterTableStmt, so copy it. (This
* is overkill, but easy.)
*/
stmt = (AlterTableStmt*)copyObject(stmt);
/* Caller is responsible for locking the relation */
rel = relation_open(relid, NoLock);
if (IS_FOREIGNTABLE(rel) || IS_STREAM_TABLE(rel)) {
@ -6109,7 +6086,7 @@ static Oid get_split_partition_oid(Relation partTableRel, SplitPartitionState* s
* precheck_start_end_defstate
* precheck start/end value of a range partition defstate
*/
static void precheck_start_end_defstate(List* pos, Form_pg_attribute* attrs,
static void precheck_start_end_defstate(List* pos, FormData_pg_attribute* attrs,
RangePartitionStartEndDefState* defState, bool isPartition)
{
ListCell* cell = NULL;
@ -6124,7 +6101,7 @@ static void precheck_start_end_defstate(List* pos, Form_pg_attribute* attrs,
foreach (cell, pos) {
int i = lfirst_int(cell);
switch (attrs[i]->atttypid) {
switch (attrs[i].atttypid) {
case INT2OID:
case INT4OID:
case INT8OID:
@ -6813,7 +6790,7 @@ static List* DividePartitionStartEndInterval(ParseState* pstate, Form_pg_attribu
*
* RETURN: a new partition list (wrote by "less/than" syntax).
*/
List* transformRangePartStartEndStmt(ParseState* pstate, List* partitionList, List* pos, Form_pg_attribute* attrs,
List* transformRangePartStartEndStmt(ParseState* pstate, List* partitionList, List* pos, FormData_pg_attribute* attrs,
int32 existPartNum, Const* lowBound, Const* upBound, bool needFree, bool isPartition)
{
ListCell* cell = NULL;
@ -6887,7 +6864,7 @@ List* transformRangePartStartEndStmt(ParseState* pstate, List* partitionList, Li
/* check: datatype of partition key */
foreach (cell, pos) {
i = lfirst_int(cell);
attr = attrs[i];
attr = &attrs[i];
target_type = attr->atttypid;
switch (target_type) {
@ -6910,7 +6887,7 @@ List* transformRangePartStartEndStmt(ParseState* pstate, List* partitionList, Li
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("datatype of column \"%s\" is unsupported for %s key in start/end clause.",
NameStr(attrs[i]->attname), (isPartition ? "partition" : "distribution")),
NameStr(attrs[i].attname), (isPartition ? "partition" : "distribution")),
errhint("Valid datatypes are: smallint, int, bigint, float4/real, float8/double, numeric, date "
"and timestamp [with time zone].")));
break;

View File

@ -160,12 +160,12 @@ char** CopyOps_RawDataToArrayField(TupleDesc tupdesc, char* message, int len)
char* line_end_ptr = NULL;
int fields = tupdesc->natts;
char** raw_fields = NULL;
Form_pg_attribute* attr = tupdesc->attrs;
FormData_pg_attribute* attr = tupdesc->attrs;
errno_t rc = 0;
/* Adjust number of fields depending on dropped attributes */
for (fieldno = 0; fieldno < tupdesc->natts; fieldno++) {
if (attr[fieldno]->attisdropped)
if (attr[fieldno].attisdropped)
fields--;
}
@ -356,7 +356,7 @@ char* CopyOps_BuildOneRowTo(TupleDesc tupdesc, Datum* values, const bool* nulls,
char* res = NULL;
int i;
FmgrInfo* out_functions = NULL;
Form_pg_attribute* attr = tupdesc->attrs;
FormData_pg_attribute* attr = tupdesc->attrs;
StringInfo buf;
/* Get info about the columns we need to process. */
@ -366,10 +366,10 @@ char* CopyOps_BuildOneRowTo(TupleDesc tupdesc, Datum* values, const bool* nulls,
bool isvarlena = false;
/* Do not need any information for dropped attributes */
if (attr[i]->attisdropped)
if (attr[i].attisdropped)
continue;
getTypeOutputInfo(attr[i]->atttypid, &out_func_oid, &isvarlena);
getTypeOutputInfo(attr[i].atttypid, &out_func_oid, &isvarlena);
fmgr_info(out_func_oid, &out_functions[i]);
}
@ -381,7 +381,7 @@ char* CopyOps_BuildOneRowTo(TupleDesc tupdesc, Datum* values, const bool* nulls,
bool isnull = nulls[i];
/* Do not need any information for dropped attributes */
if (attr[i]->attisdropped)
if (attr[i].attisdropped)
continue;
if (need_delim)

View File

@ -139,7 +139,7 @@ void RemoteCopy_BuildStatement(
if (state->is_from) {
for (attnum = 1; attnum <= tupDesc->natts; attnum++) {
/* Don't let dropped attributes go into the column list */
if (tupDesc->attrs[attnum - 1]->attisdropped)
if (tupDesc->attrs[attnum - 1].attisdropped)
continue;
if (!list_member_int(attnums, attnum)) {
@ -148,7 +148,7 @@ void RemoteCopy_BuildStatement(
if (defexpr && ((!pgxc_is_expr_shippable(expression_planner(defexpr), NULL)) ||
(list_member_int(state->idx_dist_by_col, attnum - 1)))) {
appendStringInfoString(
&state->query_buf, quote_identifier(NameStr(tupDesc->attrs[attnum - 1]->attname)));
&state->query_buf, quote_identifier(NameStr(tupDesc->attrs[attnum - 1].attname)));
appendStringInfoString(&state->query_buf, ", ");
}
}

View File

@ -484,7 +484,7 @@ static void distrib_copy_from(RedistribState* distribState, ExecNodes* exec_node
while (contains_tuple) {
char* data = NULL;
int len;
Form_pg_attribute* attr = tupdesc->attrs;
FormData_pg_attribute* attr = tupdesc->attrs;
TupleTableSlot* slot = NULL;
ExecNodes* local_execnodes = NULL;
@ -505,7 +505,7 @@ static void distrib_copy_from(RedistribState* distribState, ExecNodes* exec_node
/* Find value of distribution column if necessary */
for (int i = 0; i < tupdesc->natts; i++) {
att_type[i] = attr[i]->atttypid;
att_type[i] = attr[i].atttypid;
}
local_execnodes = GetRelationNodes(copyState->rel_loc,

View File

@ -650,7 +650,7 @@ static void HandleCopyDataRow(RemoteQueryState* combiner, char* msg_body, size_t
bool* nulls = NULL;
TupleDesc tupdesc = combiner->tuple_desc;
int i, dropped;
Form_pg_attribute* attr = tupdesc->attrs;
FormData_pg_attribute* attr = tupdesc->attrs;
FmgrInfo* in_functions = NULL;
Oid* typioparams = NULL;
char** fields = NULL;
@ -665,10 +665,10 @@ static void HandleCopyDataRow(RemoteQueryState* combiner, char* msg_body, size_t
Oid in_func_oid;
/* Do not need any information for dropped attributes */
if (attr[i]->attisdropped)
if (attr[i].attisdropped)
continue;
getTypeInputInfo(attr[i]->atttypid, &in_func_oid, &typioparams[i]);
getTypeInputInfo(attr[i].atttypid, &in_func_oid, &typioparams[i]);
fmgr_info(in_func_oid, &in_functions[i]);
}
@ -683,14 +683,14 @@ static void HandleCopyDataRow(RemoteQueryState* combiner, char* msg_body, size_t
for (i = 0; i < tupdesc->natts; i++) {
char* string = fields[i - dropped];
/* Do not need any information for dropped attributes */
if (attr[i]->attisdropped) {
if (attr[i].attisdropped) {
dropped++;
nulls[i] = true; /* Consider dropped parameter as NULL */
continue;
}
/* Find value */
values[i] = InputFunctionCall(&in_functions[i], string, typioparams[i], attr[i]->atttypmod);
values[i] = InputFunctionCall(&in_functions[i], string, typioparams[i], attr[i].atttypmod);
/* Setup value with NULL flag if necessary */
if (string == NULL)
nulls[i] = true;
@ -7927,10 +7927,10 @@ static void SetDataRowForIntParams(
tdesc = dataSlot->tts_tupleDescriptor;
int numatts = tdesc->natts;
for (attindex = 0; attindex < numatts; attindex++) {
rq_state->rqs_param_types[attindex] = tdesc->attrs[attindex]->atttypid;
rq_state->rqs_param_types[attindex] = tdesc->attrs[attindex].atttypid;
/* For unknown param type(maybe a const), we need to convert it to text */
if (tdesc->attrs[attindex]->atttypid == UNKNOWNOID) {
if (tdesc->attrs[attindex].atttypid == UNKNOWNOID) {
rq_state->rqs_param_types[attindex] = TEXTOID;
}
}
@ -8009,7 +8009,7 @@ static void SetDataRowForIntParams(
appendBinaryStringInfo(&buf, (char*)&n32, 4);
} else
/* It should switch memctx to ExprContext for makenode in ExecInitExpr */
pgxc_append_param_val(&buf, dataSlot->tts_values[attindex], tdesc->attrs[attindex]->atttypid);
pgxc_append_param_val(&buf, dataSlot->tts_values[attindex], tdesc->attrs[attindex].atttypid);
}
}
@ -9100,7 +9100,7 @@ static void FetchGlobalStatisticsFromDN(int dn_conn_count, PGXCNodeHandle** pgxc
bool typisvarlena = false;
char *corrs = NULL, *tmp = NULL;
getTypeOutputInfo(
scanslot->tts_tupleDescriptor->attrs[k]->atttypid, &foutoid, &typisvarlena);
scanslot->tts_tupleDescriptor->attrs[k].atttypid, &foutoid, &typisvarlena);
corrs = OidOutputFunctionCall(foutoid, scanslot->tts_values[k]);
while (corrs != NULL) {
if (*corrs == '{')
@ -9364,9 +9364,9 @@ bool PgfdwGetRelAttnum(int2vector* keys, PGFDWTableAnalyze* info)
for (int i = 0; i < tupdesc->natts; i++) {
for (int j = 0; j < attnum; j++) {
tup_attname = tupdesc->attrs[i]->attname.data;
tup_attname = tupdesc->attrs[i].attname.data;
if (tup_attname && strcmp(tup_attname, att_name[j]) == 0) {
real_attnum[total] = tupdesc->attrs[i]->attnum;
real_attnum[total] = tupdesc->attrs[i].attnum;
total++;
break;
}
@ -9411,9 +9411,9 @@ bool PgfdwGetRelAttnum(TupleTableSlot* slot, PGFDWTableAnalyze* info)
TupleDesc tupdesc = RelationGetDescr(rel);
for (int i = 0; i < tupdesc->natts; i++) {
tup_attname = tupdesc->attrs[i]->attname.data;
tup_attname = tupdesc->attrs[i].attname.data;
if (tup_attname && strcmp(tup_attname, att_name) == 0) {
real_attnum = tupdesc->attrs[i]->attnum;
real_attnum = tupdesc->attrs[i].attnum;
break;
}
}

View File

@ -489,7 +489,7 @@ Datum pg_pool_validate(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* construct a tuple descriptor for the result row. */
tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "pid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "node_name", TEXTOID, -1, 0);
funcctx->tuple_desc = BlessTupleDesc(tupdesc);

View File

@ -47,7 +47,7 @@ static void tt_setup_firstcall(FuncCallContext* funcctx, Oid prsid)
st->list = (LexDescr*)DatumGetPointer(OidFunctionCall1(prs->lextypeOid, (Datum)0));
funcctx->user_fctx = (void*)st;
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "tokid", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "alias", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "description", TEXTOID, -1, 0);
@ -185,7 +185,7 @@ static void prs_setup_firstcall(FuncCallContext* funcctx, Oid prsid, text* txt)
st->cur = 0;
funcctx->user_fctx = (void*)st;
tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "tokid", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "token", TEXTOID, -1, 0);

View File

@ -1731,7 +1731,7 @@ Datum aclexplode(PG_FUNCTION_ARGS)
* build tupdesc for result tuples (matches out parameters in pg_proc
* entry)
*/
tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "grantor", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "grantee", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "privilege_type", TEXTOID, -1, 0);

View File

@ -4091,7 +4091,7 @@ Datum pg_timezone_abbrevs(PG_FUNCTION_ARGS)
* build tupdesc for result tuples. This must match this function's
* pg_proc entry!
*/
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "abbrev", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "utc_offset", INTERVALOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "is_dst", BOOLOID, -1, 0);
@ -4182,7 +4182,7 @@ Datum pg_timezone_names(PG_FUNCTION_ARGS)
* build tupdesc for result tuples. This must match this function's
* pg_proc entry!
*/
tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "abbrev", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "utc_offset", INTERVALOID, -1, 0);

View File

@ -313,7 +313,7 @@ static double calculate_coltable_compress_ratio(Relation onerel)
CStoreScanDesc cstoreScanDesc = NULL;
TupleDesc tupdesc = onerel->rd_att;
int attrNum = tupdesc->natts;
Form_pg_attribute* attrs = tupdesc->attrs;
FormData_pg_attribute* attrs = tupdesc->attrs;
CUDesc cuDesc;
CU* cuPtr = NULL;
double total_source_size = 0;
@ -328,7 +328,7 @@ static double calculate_coltable_compress_ratio(Relation onerel)
double numericDataSize = 0;
for (int i = 0; i < attrNum; i++) {
colIdx[i] = attrs[i]->attnum;
colIdx[i] = attrs[i].attnum;
slotIdList[i] = CACHE_BLOCK_INVALID_IDX;
}
@ -346,13 +346,13 @@ static double calculate_coltable_compress_ratio(Relation onerel)
/*sample the first CU of each column, and calculate the compression ratio of this table.*/
for (int col = 0; col < attrNum; col++) {
// skip dropped column
if (attrs[col]->attisdropped) {
if (attrs[col].attisdropped) {
continue;
}
bool found = cstore->GetCUDesc(col, targetblock, &cuDesc, SnapshotNow);
if (found && cuDesc.cu_size != 0) {
cuPtr = cstore->GetCUData(&cuDesc, col, attrs[col]->attlen, slotIdList[col]);
cuPtr = cstore->GetCUData(&cuDesc, col, attrs[col].attlen, slotIdList[col]);
if ((cuPtr->m_infoMode & CU_IntLikeCompressed) && ATT_IS_NUMERIC_TYPE(cuPtr->m_atttypid)) {
numericExpandRatio = 1.5; /* default expand ratio */
numericDataSize = 0;
@ -853,8 +853,8 @@ int64 CalculateCStoreRelationSize(Relation rel, ForkNumber forknum)
} else {
for (int i = 0; i < RelationGetDescr(rel)->natts; i++) {
totalsize += calculate_relation_size(
&rel->rd_node, rel->rd_backend, ColumnId2ColForkNum(rel->rd_att->attrs[i]->attnum));
CFileNode tmpNode(rel->rd_node, rel->rd_att->attrs[i]->attnum, MAIN_FORKNUM);
&rel->rd_node, rel->rd_backend, ColumnId2ColForkNum(rel->rd_att->attrs[i].attnum));
CFileNode tmpNode(rel->rd_node, rel->rd_att->attrs[i].attnum, MAIN_FORKNUM);
CUStorage custore(tmpNode);
for (segcount = 0;; segcount++) {
struct stat fst;

View File

@ -380,7 +380,7 @@ static void ReadBinaryFileBlocksFirstCall(PG_FUNCTION_ARGS, int32 startBlockNum,
* build tupdesc for result tuples. This must match this function's
* pg_proc entry!
*/
TupleDesc tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "path", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "blocknum", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "len", INT4OID, -1, 0);
@ -466,7 +466,7 @@ Datum pg_stat_file(PG_FUNCTION_ARGS)
* This record type had better match the output parameters declared for me
* in pg_proc.h.
*/
tupdesc = CreateTemplateTupleDesc(6, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(6, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "size", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "access", TIMESTAMPTZOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "modification", TIMESTAMPTZOID, -1, 0);
@ -635,7 +635,7 @@ Datum pg_stat_file_recursive(PG_FUNCTION_ARGS)
* This record type had better match the output parameters declared for me
* in pg_proc.h.
*/
tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "path", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "filename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "size", INT8OID, -1, 0);

View File

@ -1360,7 +1360,7 @@ static void composite_to_json(Datum composite, StringInfo result, bool use_line_
bool typisvarlena = false;
Oid castfunc = InvalidOid;
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
continue;
}
if (needsep) {
@ -1368,16 +1368,16 @@ static void composite_to_json(Datum composite, StringInfo result, bool use_line_
}
needsep = true;
attname = NameStr(tupdesc->attrs[i]->attname);
attname = NameStr(tupdesc->attrs[i].attname);
escape_json(result, attname);
appendStringInfoChar(result, ':');
val = heap_getattr(tuple, i + 1, tupdesc, &isnull);
getTypeOutputInfo(tupdesc->attrs[i]->atttypid, &typoutput, &typisvarlena);
getTypeOutputInfo(tupdesc->attrs[i].atttypid, &typoutput, &typisvarlena);
if (tupdesc->attrs[i]->atttypid > FirstNormalObjectId) {
if (tupdesc->attrs[i].atttypid > FirstNormalObjectId) {
HeapTuple cast_tuple;
Form_pg_cast castForm;
cast_tuple = SearchSysCache2(CASTSOURCETARGET, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
cast_tuple = SearchSysCache2(CASTSOURCETARGET, ObjectIdGetDatum(tupdesc->attrs[i].atttypid),
ObjectIdGetDatum(JSONOID));
if (HeapTupleIsValid(cast_tuple)) {
castForm = (Form_pg_cast) GETSTRUCT(cast_tuple);
@ -1391,14 +1391,14 @@ static void composite_to_json(Datum composite, StringInfo result, bool use_line_
if (castfunc != InvalidOid) {
tcategory = TYPCATEGORY_JSON_CAST;
} else if (tupdesc->attrs[i]->atttypid == RECORDARRAYOID) {
} else if (tupdesc->attrs[i].atttypid == RECORDARRAYOID) {
tcategory = TYPCATEGORY_ARRAY;
} else if (tupdesc->attrs[i]->atttypid == RECORDOID) {
} else if (tupdesc->attrs[i].atttypid == RECORDOID) {
tcategory = TYPCATEGORY_COMPOSITE;
} else if (tupdesc->attrs[i]->atttypid == JSONOID || tupdesc->attrs[i]->atttypid == JSONBOID) {
} else if (tupdesc->attrs[i].atttypid == JSONOID || tupdesc->attrs[i].atttypid == JSONBOID) {
tcategory = TYPCATEGORY_JSON;
} else {
tcategory = TypeCategory(tupdesc->attrs[i]->atttypid);
tcategory = TypeCategory(tupdesc->attrs[i].atttypid);
}
datum_to_json(val, isnull, result, tcategory, typoutput, false);
}

View File

@ -1941,13 +1941,13 @@ static inline Datum populate_record_worker(FunctionCallInfo fcinfo, bool have_re
for (i = 0; i < ncolumns; ++i) {
ColumnIOData *column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
JsonbValue *v = NULL;
char fname[NAMEDATALEN];
JsonHashEntry *hashentry = NULL;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
nulls[i] = true;
continue;
}
@ -1955,11 +1955,11 @@ static inline Datum populate_record_worker(FunctionCallInfo fcinfo, bool have_re
if (jtype == JSONOID) {
rc = memset_s(fname, NAMEDATALEN, 0, NAMEDATALEN);
securec_check(rc, "\0", "\0");
rc = strncpy_s(fname, NAMEDATALEN, NameStr(tupdesc->attrs[i]->attname), NAMEDATALEN - 1);
rc = strncpy_s(fname, NAMEDATALEN, NameStr(tupdesc->attrs[i].attname), NAMEDATALEN - 1);
securec_check(rc, "\0", "\0");
hashentry = (JsonHashEntry *)hash_search(json_hash, fname, HASH_FIND, NULL);
} else {
char *key = NameStr(tupdesc->attrs[i]->attname);
char *key = NameStr(tupdesc->attrs[i].attname);
v = findJsonbValueFromSuperHeaderLen(VARDATA(jb), JB_FOBJECT, key, strlen(key));
}
@ -1991,7 +1991,7 @@ static inline Datum populate_record_worker(FunctionCallInfo fcinfo, bool have_re
* checks are done
*/
values[i] = InputFunctionCall(&column_info->proc, NULL, column_info->typioparam,
tupdesc->attrs[i]->atttypmod);
tupdesc->attrs[i].atttypmod);
nulls[i] = true;
} else {
char *s = NULL;
@ -2018,7 +2018,7 @@ static inline Datum populate_record_worker(FunctionCallInfo fcinfo, bool have_re
}
values[i] = InputFunctionCall(&column_info->proc, s,
column_info->typioparam, tupdesc->attrs[i]->atttypmod);
column_info->typioparam, tupdesc->attrs[i].atttypmod);
nulls[i] = false;
}
}
@ -2212,16 +2212,16 @@ static void make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *
for (i = 0; i < ncolumns; ++i) {
ColumnIOData *column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
JsonbValue *v = NULL;
char *key = NULL;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
nulls[i] = true;
continue;
}
key = NameStr(tupdesc->attrs[i]->attname);
key = NameStr(tupdesc->attrs[i].attname);
v = findJsonbValueFromSuperHeaderLen(VARDATA(element), JB_FOBJECT, key, strlen(key));
/*
@ -2250,7 +2250,7 @@ static void make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *
* checks are done
*/
values[i] = InputFunctionCall(&column_info->proc, NULL, column_info->typioparam,
tupdesc->attrs[i]->atttypmod);
tupdesc->attrs[i].atttypmod);
nulls[i] = true;
} else {
char *s = NULL;
@ -2271,7 +2271,7 @@ static void make_row_from_rec_and_jsonb(Jsonb *element, PopulateRecordsetState *
elog(ERROR, "invalid jsonb type");
}
values[i] = InputFunctionCall(&column_info->proc, s, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
values[i] = InputFunctionCall(&column_info->proc, s, column_info->typioparam, tupdesc->attrs[i].atttypmod);
nulls[i] = false;
}
}
@ -2512,18 +2512,18 @@ static void populate_recordset_object_end(void *state)
for (i = 0; i < ncolumns; ++i) {
ColumnIOData *column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
char *value = NULL;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
nulls[i] = true;
continue;
}
errno_t rc = memset_s(fname, NAMEDATALEN, 0, NAMEDATALEN);
securec_check(rc, "\0", "\0");
rc = strncpy_s(fname, NAMEDATALEN, NameStr(tupdesc->attrs[i]->attname), NAMEDATALEN - 1);
rc = strncpy_s(fname, NAMEDATALEN, NameStr(tupdesc->attrs[i].attname), NAMEDATALEN - 1);
securec_check(rc, "\0", "\0");
hashentry = (JsonHashEntry *)hash_search(json_hash, fname, HASH_FIND, NULL);
@ -2553,12 +2553,12 @@ static void populate_recordset_object_end(void *state)
* checks are done
*/
values[i] = InputFunctionCall(&column_info->proc, NULL, column_info->typioparam,
tupdesc->attrs[i]->atttypmod);
tupdesc->attrs[i].atttypmod);
nulls[i] = true;
} else {
value = hashentry->val;
values[i] = InputFunctionCall(&column_info->proc, value, column_info->typioparam,
tupdesc->attrs[i]->atttypmod);
tupdesc->attrs[i].atttypmod);
nulls[i] = false;
}
}

View File

@ -177,7 +177,7 @@ Datum pg_lock_status(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
/* this had better match pg_locks view in system_views.sql */
tupdesc = CreateTemplateTupleDesc(NUM_LOCK_STATUS_COLUMNS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_LOCK_STATUS_COLUMNS, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "locktype", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "database", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "relation", OIDOID, -1, 0);

View File

@ -842,7 +842,7 @@ Datum pg_get_keywords(PG_FUNCTION_ARGS)
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "word", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "catcode", CHAROID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "catdesc", TEXTOID, -1, 0);

View File

@ -3732,7 +3732,7 @@ Datum pg_stat_get_sql_count(PG_FUNCTION_ARGS)
i = 0;
/* init the tuple description */
tupdesc = CreateTemplateTupleDesc(SQL_COUNT_ATTR, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(SQL_COUNT_ATTR, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "user_name", TEXTOID, -1, 0);
@ -4028,7 +4028,7 @@ Datum pg_stat_get_env(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(7, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(7, false);
/* This should have been called 'pid'; can't change it. 2011-06-11 */
TupleDescInitEntry(tupdesc, (AttrNumber)1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "host", TEXTOID, -1, 0);
@ -4947,7 +4947,7 @@ Datum pg_stat_get_wlm_realtime_session_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_REALTIME_SESSION_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_REALTIME_SESSION_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "nodename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "threadid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "block_time", INT8OID, -1, 0);
@ -5163,7 +5163,7 @@ Datum pg_stat_get_wlm_realtime_ec_operator_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(OPERATOR_REALTIME_SESSION_EC_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(OPERATOR_REALTIME_SESSION_EC_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "queryid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "plan_node_id", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "plan_node_name", TEXTOID, -1, 0);
@ -5310,7 +5310,7 @@ Datum pg_stat_get_wlm_realtime_operator_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(OPERATOR_REALTIME_SESSION_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(OPERATOR_REALTIME_SESSION_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "queryid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "pid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "plan_node_id", INT4OID, -1, 0);
@ -5433,7 +5433,7 @@ Datum pg_stat_get_wlm_statistics(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_STATISTICS_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_STATISTICS_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "statement", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "block_time", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "elapsed_time", INT8OID, -1, 0);
@ -5822,7 +5822,7 @@ Datum pg_stat_get_wlm_io_wait_status(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(io_wait_status_attrnum, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(io_wait_status_attrnum, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "device_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "read_per_second", FLOAT8OID, -1, 0);
@ -5923,7 +5923,7 @@ Datum pg_stat_get_wlm_user_iostat_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_USER_IO_RESOURCE_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_USER_IO_RESOURCE_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "user_id", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "mincurr_iops", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "maxcurr_iops", INT4OID, -1, 0);
@ -5999,7 +5999,7 @@ Datum pg_stat_get_wlm_session_iostat_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_SESSION_IOSTAT_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_SESSION_IOSTAT_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "threadid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "maxcurr_iops", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "mincurr_iops", INT4OID, -1, 0);
@ -6088,7 +6088,7 @@ Datum pg_stat_get_wlm_node_resource_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_NODE_RESOURCE_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_NODE_RESOURCE_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "min_mem_util", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "max_mem_util", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "min_cpu_util", INT4OID, -1, 0);
@ -6174,7 +6174,7 @@ Datum pg_stat_get_wlm_session_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_SESSION_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_SESSION_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "datid", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "dbname", TEXTOID, -1, 0);
@ -6535,7 +6535,7 @@ Datum pg_stat_get_wlm_ec_operator_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(OPERATOR_SESSION_EC_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(OPERATOR_SESSION_EC_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "queryid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "plan_node_id", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "plan_node_name", TEXTOID, -1, 0);
@ -6805,7 +6805,7 @@ Datum pg_stat_get_wlm_operator_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(OPERATOR_SESSION_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(OPERATOR_SESSION_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "queryid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "pid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "plan_node_id", INT4OID, -1, 0);
@ -6923,7 +6923,7 @@ Datum pg_stat_get_wlm_instance_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_INSTANCE_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_INSTANCE_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "instancename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "timestamp", TIMESTAMPTZOID, -1, 0);
@ -7020,7 +7020,7 @@ Datum pg_stat_get_wlm_instance_info_with_cleanup(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_INSTANCE_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_INSTANCE_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "instancename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "timestamp", TIMESTAMPTZOID, -1, 0);
@ -7123,7 +7123,7 @@ Datum pg_stat_get_wlm_user_resource_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_USER_RESOURCE_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_USER_RESOURCE_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "user_id", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "used_memory", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "total_memory", INT4OID, -1, 0);
@ -7221,7 +7221,7 @@ Datum pg_stat_get_resource_pool_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_RESOURCE_POOL_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_RESOURCE_POOL_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "respool_oid", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "ref_count", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "active_points", INT4OID, -1, 0);
@ -7297,7 +7297,7 @@ Datum pg_stat_get_wlm_user_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_USER_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_USER_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "userid", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "sysadmin", BOOLOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "rpoid", OIDOID, -1, 0);
@ -7377,7 +7377,7 @@ Datum pg_stat_get_cgroup_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_CGROUP_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_CGROUP_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "cgroup_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "percent", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "usagepct", INT4OID, -1, 0);
@ -7488,7 +7488,7 @@ Datum pg_stat_get_workload_records(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(WLM_WORKLOAD_RECORDS_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(WLM_WORKLOAD_RECORDS_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "node_idx", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "query_pid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "start_time", INT8OID, -1, 0);
@ -8157,7 +8157,7 @@ Datum pv_os_run_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 3 columns */
tupdesc = CreateTemplateTupleDesc(5, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(5, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "id", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "name", TEXTOID, -1, 0);
@ -8231,7 +8231,7 @@ Datum pv_session_memory_detail(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
/* need a tuple descriptor representing 9 columns */
tupdesc = CreateTemplateTupleDesc(NUM_SESSION_MEMORY_DETAIL_ELEM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_SESSION_MEMORY_DETAIL_ELEM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "sessid", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "threadid", INT8OID, -1, 0);
@ -8505,7 +8505,7 @@ Datum pv_thread_memory_detail(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
/* need a tuple descriptor representing 9 columns */
tupdesc = CreateTemplateTupleDesc(NUM_THREAD_MEMORY_DETAIL_ELEM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_THREAD_MEMORY_DETAIL_ELEM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "threadid", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "tid", INT8OID, -1, 0);
@ -8548,7 +8548,7 @@ Datum pg_shared_memory_detail(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
/* need a tuple descriptor representing 9 columns */
tupdesc = CreateTemplateTupleDesc(NUM_SHARED_MEMORY_DETAIL_ELEM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_SHARED_MEMORY_DETAIL_ELEM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "contextname", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "level", INT2OID, -1, 0);
@ -8597,7 +8597,7 @@ Datum pg_buffercache_pages(PG_FUNCTION_ARGS)
fctx = (BufferCachePagesContext*)palloc(sizeof(BufferCachePagesContext));
/* Construct a tuple descriptor for the result rows. */
tupledesc = CreateTemplateTupleDesc(NUM_BUFFERCACHE_PAGES_ELEM, false, TAM_HEAP);
tupledesc = CreateTemplateTupleDesc(NUM_BUFFERCACHE_PAGES_ELEM, false);
TupleDescInitEntry(tupledesc, (AttrNumber)1, "bufferid", INT4OID, -1, 0);
TupleDescInitEntry(tupledesc, (AttrNumber)2, "relfilenode", OIDOID, -1, 0);
TupleDescInitEntry(tupledesc, (AttrNumber)3, "bucketid", INT4OID, -1, 0);
@ -8826,7 +8826,7 @@ Datum pv_instance_time(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 4 columns */
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "stat_id", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "stat_name", TEXTOID, -1, 0);
@ -8885,7 +8885,7 @@ Datum pg_stat_get_redo_stat(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
/* this had better match pv_plan view in system_views.sql */
tupdesc = CreateTemplateTupleDesc(7, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(7, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "phywrts", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "phyblkwrt", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "writetim", INT8OID, -1, 0);
@ -9108,7 +9108,7 @@ Datum pg_stat_get_file_stat(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
/* this had better match pv_plan view in system_views.sql */
tupdesc = CreateTemplateTupleDesc(13, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(13, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "filenum", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "dbid", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "spcid", OIDOID, -1, 0);
@ -9197,7 +9197,7 @@ Datum get_local_rel_iostat(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "phyrds", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "phywrts", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "phyblkrd", INT8OID, -1, 0);
@ -9689,7 +9689,7 @@ Datum gs_total_nodegroup_memory_detail(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "ngname", TEXTOID, -1, 0);
@ -9855,7 +9855,7 @@ Datum pv_total_memory_detail(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "nodename", TEXTOID, -1, 0);
@ -10011,7 +10011,7 @@ Datum pg_stat_get_pooler_status(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(ARG_NUMS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(ARG_NUMS, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_1, "database_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_2, "user_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_3, "threadid", INT8OID, -1, 0);
@ -10119,7 +10119,7 @@ void init_pgxc_comm_get_recv_stream(PG_FUNCTION_ARGS, FuncCallContext *funcctx,
TupleDesc tupdesc;
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(argNums, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(argNums, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_2, "local_tid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_3, "remote_name", TEXTOID, -1, 0);
@ -10230,7 +10230,7 @@ Datum pg_comm_recv_stream(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
ii = 1;
tupdesc = CreateTemplateTupleDesc(RECV_STREAM_TUPLE_NATTS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(RECV_STREAM_TUPLE_NATTS, false);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "local_tid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "remote_name", TEXTOID, -1, 0);
@ -10329,7 +10329,7 @@ Datum pg_comm_send_stream(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
ii = 1;
tupdesc = CreateTemplateTupleDesc(SEND_STREAM_TUPLE_NATTS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(SEND_STREAM_TUPLE_NATTS, false);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "local_tid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "remote_name", TEXTOID, -1, 0);
@ -10410,7 +10410,7 @@ void init_pgxc_comm_get_send_stream(PG_FUNCTION_ARGS, FuncCallContext *funcctx,
TupleDesc tupdesc;
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(argNums, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(argNums, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_2, "local_tid", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_3, "remote_name", TEXTOID, -1, 0);
@ -10517,7 +10517,7 @@ Datum pg_tde_info(PG_FUNCTION_ARGS)
int i = 0;
errno_t rc = 0;
TupleDesc tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "is_encrypt", BOOLOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "g_tde_algo", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "remain", TEXTOID, -1, 0);
@ -10557,7 +10557,7 @@ void init_pg_comm_status(PG_FUNCTION_ARGS, FuncCallContext *funcctx, const int a
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(argNums, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(argNums, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_2, "rxpck_rate", INT4OID, -1, 0);
@ -10646,7 +10646,7 @@ void init_pgxc_comm_get_status(PG_FUNCTION_ARGS, FuncCallContext *funcctx, const
TupleDesc tupdesc;
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(argNums, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(argNums, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_2, "rxpck_rate", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_3, "txpck_rate", INT4OID, -1, 0);
@ -10940,7 +10940,7 @@ Datum global_comm_get_client_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(CLIENT_INFO_TUPLE_NATTS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(CLIENT_INFO_TUPLE_NATTS, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_2, "app", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ARG_3, "tid", INT8OID, -1, 0);
@ -11011,7 +11011,7 @@ Datum pg_comm_delay(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
ii = 1;
tupdesc = CreateTemplateTupleDesc(DELAY_INFO_TUPLE_NATTS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DELAY_INFO_TUPLE_NATTS, false);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "remote_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)ii++, "remote_host", TEXTOID, -1, 0);
@ -11228,7 +11228,7 @@ Datum gs_control_group_info(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
/* this had better match pv_plan view in system_views.sql */
tupdesc = CreateTemplateTupleDesc(9, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(9, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "class", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "workload", TEXTOID, -1, 0);
@ -11350,7 +11350,7 @@ Datum gs_respool_exception_info(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(6, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(6, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "class", TEXTOID, -1, 0);
@ -11479,7 +11479,7 @@ Datum gs_all_control_group_info(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
/* this had better match pv_plan view in system_views.sql */
tupdesc = CreateTemplateTupleDesc(10, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(10, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "type", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "gid", INT8OID, -1, 0);
@ -11608,7 +11608,7 @@ Datum gs_all_nodegroup_control_group_info(PG_FUNCTION_ARGS)
/* build tupdesc for result tuples */
/* this had better match pv_plan view in system_views.sql */
tupdesc = CreateTemplateTupleDesc(NODEGROUP_CONTROL_GROUP_INFO_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NODEGROUP_CONTROL_GROUP_INFO_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "type", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)++i, "gid", INT8OID, -1, 0);
@ -11728,7 +11728,7 @@ Datum pv_compute_pool_workload(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 3 columns */
tupdesc = CreateTemplateTupleDesc(NUM_COMPUTE_POOL_WORKLOAD_ELEM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_COMPUTE_POOL_WORKLOAD_ELEM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "nodename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "rpinuse", INT4OID, -1, 0);
@ -12535,7 +12535,7 @@ Datum pg_total_autovac_tuples(PG_FUNCTION_ARGS)
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
oldcontext = MemoryContextSwitchTo(per_query_ctx);
tupdesc = CreateTemplateTupleDesc(AUTOVAC_TUPLES_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(AUTOVAC_TUPLES_ATTR_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "nodename", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "nspname", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "relname", NAMEOID, -1, 0);
@ -12737,7 +12737,7 @@ Datum pg_autovac_status(PG_FUNCTION_ARGS)
rc = memset_s(nulls, sizeof(nulls), 0, sizeof(nulls));
securec_check(rc, "\0", "\0");
tupdesc = CreateTemplateTupleDesc(STATUS_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(STATUS_ATTR_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "nspname", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "relname", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "nodename", TEXTOID, -1, 0);
@ -12887,7 +12887,7 @@ void check_dirty_percent_and_tuples(int dirty_pecent, int n_tuples)
void dirty_table_init_tupdesc(TupleDesc* tupdesc)
{
*tupdesc = CreateTemplateTupleDesc(7, false, TAM_HEAP);
*tupdesc = CreateTemplateTupleDesc(7, false);
TupleDescInitEntry(*tupdesc, (AttrNumber)1, "relname", NAMEOID, -1, 0);
TupleDescInitEntry(*tupdesc, (AttrNumber)2, "schemaname", NAMEOID, -1, 0);
TupleDescInitEntry(*tupdesc, (AttrNumber)3, "n_tup_ins", INT8OID, -1, 0);
@ -13056,7 +13056,7 @@ Datum all_table_distribution(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "schemaname", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "tablename", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "nodename", NAMEOID, -1, 0);
@ -13153,7 +13153,7 @@ Datum single_table_distribution(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
tupdesc = CreateTemplateTupleDesc(4, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(4, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "schemaname", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "tablename", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "nodename", NAMEOID, -1, 0);
@ -13223,7 +13223,7 @@ Datum pg_stat_bad_block(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples */
tupdesc = CreateTemplateTupleDesc(BAD_BLOCK_STAT_NATTS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(BAD_BLOCK_STAT_NATTS, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "nodename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "databaseid", INT4OID, -1, 0);
@ -13324,7 +13324,7 @@ HeapTuple form_function_tuple(int col_num, FuncName name)
rc = memset_s(nulls, sizeof(nulls), 1, sizeof(nulls));
securec_check(rc, "\0", "\0");
tupdesc = CreateTemplateTupleDesc(col_num, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(col_num, false);
switch (name) {
case PAGEWRITER_FUNC:
@ -13423,7 +13423,7 @@ void xc_stat_view(FuncCallContext* funcctx, int col_num, FuncName name)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
tupdesc = CreateTemplateTupleDesc(col_num, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(col_num, false);
switch (name) {
case PAGEWRITER_FUNC:
for (i = 0; i < col_num; i++) {
@ -13728,7 +13728,7 @@ Datum remote_single_flush_dw_stat(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(DW_SINGLE_VIEW_COL_NUM, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(DW_SINGLE_VIEW_COL_NUM, false);
for (uint32 i = 0; i < DW_SINGLE_VIEW_COL_NUM; i++) {
TupleDescInitEntry(
tupdesc, (AttrNumber)(i + 1), g_dw_single_view[i].name, g_dw_single_view[i].data_type, -1, 0);
@ -13813,7 +13813,7 @@ Datum local_double_write_stat(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
tupdesc = CreateTemplateTupleDesc(DW_VIEW_COL_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DW_VIEW_COL_NUM, false);
for (i = 0; i < col_num; i++) {
TupleDescInitEntry(tupdesc, (AttrNumber)(i + 1),
@ -13850,7 +13850,7 @@ Datum remote_double_write_stat(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(DW_VIEW_COL_NUM, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(DW_VIEW_COL_NUM, false);
for (uint32 i = 0; i < DW_VIEW_COL_NUM; i++) {
TupleDescInitEntry(
tupdesc, (AttrNumber)(i + 1), g_dw_view_col_arr[i].name, g_dw_view_col_arr[i].data_type, -1, 0);
@ -13970,7 +13970,7 @@ Datum local_redo_stat(PG_FUNCTION_ARGS)
uint32 i;
redo_fill_redo_event();
tupdesc = CreateTemplateTupleDesc(REDO_VIEW_COL_SIZE, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(REDO_VIEW_COL_SIZE, false);
for (i = 0; i < REDO_VIEW_COL_SIZE; i++) {
TupleDescInitEntry(tupdesc, (AttrNumber)(i + 1), g_redoViewArr[i].name, g_redoViewArr[i].data_type, -1, 0);
values[i] = g_redoViewArr[i].get_data();
@ -13999,7 +13999,7 @@ Datum remote_redo_stat(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(REDO_VIEW_COL_SIZE, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(REDO_VIEW_COL_SIZE, false);
for (uint32 i = 0; i < REDO_VIEW_COL_SIZE; i++) {
TupleDescInitEntry(tupdesc, (AttrNumber)(i + 1), g_redoViewArr[i].name, g_redoViewArr[i].data_type, -1, 0);
nulls[i] = false;
@ -14069,7 +14069,7 @@ Datum gs_threadpool_status(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 10 columns */
tupdesc = CreateTemplateTupleDesc(NUM_THREADPOOL_STATUS_ELEM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_THREADPOOL_STATUS_ELEM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "nodename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "groupid", INT4OID, -1, 0);
@ -14153,7 +14153,7 @@ Datum gs_globalplancache_status(PG_FUNCTION_ARGS)
#define GPC_TUPLES_ATTR_NUM 8
/* need a tuple descriptor representing 12 columns */
tupdesc = CreateTemplateTupleDesc(GPC_TUPLES_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(GPC_TUPLES_ATTR_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "nodename",
TEXTOID, -1, 0);
@ -14293,7 +14293,7 @@ Datum local_rto_stat(PG_FUNCTION_ARGS)
bool nulls[RTO_VIEW_COL_SIZE] = {false};
uint32 i;
tupdesc = CreateTemplateTupleDesc(RTO_VIEW_COL_SIZE, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(RTO_VIEW_COL_SIZE, false);
for (i = 0; i < RTO_VIEW_COL_SIZE; i++) {
TupleDescInitEntry(tupdesc, (AttrNumber)(i + 1), g_rtoViewArr[i].name, g_rtoViewArr[i].data_type, -1, 0);
values[i] = g_rtoViewArr[i].get_data();
@ -14323,7 +14323,7 @@ Datum remote_rto_stat(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(RTO_VIEW_COL_SIZE, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(RTO_VIEW_COL_SIZE, false);
for (i = 0; i < RTO_VIEW_COL_SIZE; i++) {
TupleDescInitEntry(tupdesc, (AttrNumber)(i + 1), g_rtoViewArr[i].name, g_rtoViewArr[i].data_type, -1, 0);
nulls[i] = false;
@ -14464,7 +14464,7 @@ Datum remote_recovery_status(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(RECOVERY_RTO_VIEW_COL, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(RECOVERY_RTO_VIEW_COL, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "standby_node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "source_ip", TEXTOID, -1, 0);
@ -14611,7 +14611,7 @@ Datum gs_hadr_remote_rto_and_rpo_stat(PG_FUNCTION_ARGS)
MemoryContext oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* build tupdesc for result tuples. */
TupleDesc tupdesc = CreateTemplateTupleDesc(HADR_RTO_RPO_VIEW_COL, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(HADR_RTO_RPO_VIEW_COL, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "hadr_sender_node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "hadr_receiver_node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "source_ip", TEXTOID, -1, 0);
@ -14731,7 +14731,7 @@ Datum track_memory_context_detail(PG_FUNCTION_ARGS)
TupleDesc get_index_status_view_frist_row()
{
TupleDesc tupdesc = NULL;
tupdesc = CreateTemplateTupleDesc(INDEX_STATUS_VIEW_COL_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(INDEX_STATUS_VIEW_COL_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "indisready", BOOLOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "indisvalid", BOOLOID, -1, 0);

View File

@ -131,11 +131,11 @@ Datum record_in(PG_FUNCTION_ARGS)
for (i = 0; i < ncolumns; i++) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
char* column_data = NULL;
/* Ignore dropped columns in datatype, but fill with nulls */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
values[i] = (Datum)0;
nulls[i] = true;
continue;
@ -208,7 +208,7 @@ Datum record_in(PG_FUNCTION_ARGS)
}
values[i] =
InputFunctionCall(&column_info->proc, column_data, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
InputFunctionCall(&column_info->proc, column_data, column_info->typioparam, tupdesc->attrs[i].atttypmod);
/*
* Prep for next column
@ -263,11 +263,11 @@ static void ProcessStr(TupleDesc tupdesc, Datum* values, bool* nulls, char** ptr
initStringInfo(&buf);
for (i = 0; i < nColumns; i++) {
Oid columnType = tupdesc->attrs[i]->atttypid;
Oid columnType = tupdesc->attrs[i].atttypid;
char* columnData = NULL;
/* Ignore dropped columns in datatype, but fill with nulls */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
values[i] = (Datum)0;
nulls[i] = true;
continue;
@ -453,14 +453,14 @@ Datum record_out(PG_FUNCTION_ARGS)
for (i = 0; i < ncolumns; i++) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
Datum attr;
char* value = NULL;
char* tmp = NULL;
bool nq = false;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
if (needComma)
@ -595,7 +595,7 @@ Datum record_recv(PG_FUNCTION_ARGS)
/* Need to scan to count nondeleted columns */
validcols = 0;
for (i = 0; i < ncolumns; i++) {
if (!tupdesc->attrs[i]->attisdropped)
if (!tupdesc->attrs[i].attisdropped)
validcols++;
}
if (usercols != validcols)
@ -606,7 +606,7 @@ Datum record_recv(PG_FUNCTION_ARGS)
/* Process each column */
for (i = 0; i < ncolumns; i++) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
Oid coltypoid;
int itemlen;
StringInfoData item_buf;
@ -614,7 +614,7 @@ Datum record_recv(PG_FUNCTION_ARGS)
char csave;
/* Ignore dropped columns in datatype, but fill with nulls */
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
values[i] = (Datum)0;
nulls[i] = true;
continue;
@ -667,7 +667,7 @@ Datum record_recv(PG_FUNCTION_ARGS)
}
values[i] =
ReceiveFunctionCall(&column_info->proc, bufptr, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
ReceiveFunctionCall(&column_info->proc, bufptr, column_info->typioparam, tupdesc->attrs[i].atttypmod);
if (bufptr) {
/* Trouble if it didn't eat the whole buffer */
@ -752,19 +752,19 @@ Datum record_send(PG_FUNCTION_ARGS)
/* Need to scan to count nondeleted columns */
validcols = 0;
for (i = 0; i < ncolumns; i++) {
if (!tupdesc->attrs[i]->attisdropped)
if (!tupdesc->attrs[i].attisdropped)
validcols++;
}
pq_sendint32(&buf, validcols);
for (i = 0; i < ncolumns; i++) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid column_type = tupdesc->attrs[i].atttypid;
Datum attr;
bytea* outputbytes = NULL;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
pq_sendint32(&buf, column_type);
@ -930,11 +930,11 @@ static int record_cmp(FunctionCallInfo fcinfo)
/*
* Skip dropped columns
*/
if (i1 < ncolumns1 && tupdesc1->attrs[i1]->attisdropped) {
if (i1 < ncolumns1 && tupdesc1->attrs[i1].attisdropped) {
i1++;
continue;
}
if (i2 < ncolumns2 && tupdesc2->attrs[i2]->attisdropped) {
if (i2 < ncolumns2 && tupdesc2->attrs[i2].attisdropped) {
i2++;
continue;
}
@ -944,28 +944,28 @@ static int record_cmp(FunctionCallInfo fcinfo)
/*
* Have two matching columns, they must be same type
*/
if (tupdesc1->attrs[i1]->atttypid != tupdesc2->attrs[i2]->atttypid)
if (tupdesc1->attrs[i1].atttypid != tupdesc2->attrs[i2].atttypid)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot compare dissimilar column types %s and %s at record column %d",
format_type_be(tupdesc1->attrs[i1]->atttypid),
format_type_be(tupdesc2->attrs[i2]->atttypid),
format_type_be(tupdesc1->attrs[i1].atttypid),
format_type_be(tupdesc2->attrs[i2].atttypid),
j + 1)));
/*
* If they're not same collation, we don't complain here, but the
* comparison function might.
*/
collation = tupdesc1->attrs[i1]->attcollation;
if (collation != tupdesc2->attrs[i2]->attcollation)
collation = tupdesc1->attrs[i1].attcollation;
if (collation != tupdesc2->attrs[i2].attcollation)
collation = InvalidOid;
/*
* Lookup the comparison function if not done already
*/
typentry = my_extra->columns[j].typentry;
if (typentry == NULL || typentry->type_id != tupdesc1->attrs[i1]->atttypid) {
typentry = lookup_type_cache(tupdesc1->attrs[i1]->atttypid, TYPECACHE_CMP_PROC_FINFO);
if (typentry == NULL || typentry->type_id != tupdesc1->attrs[i1].atttypid) {
typentry = lookup_type_cache(tupdesc1->attrs[i1].atttypid, TYPECACHE_CMP_PROC_FINFO);
if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
@ -1154,11 +1154,11 @@ Datum record_eq(PG_FUNCTION_ARGS)
/*
* Skip dropped columns
*/
if (i1 < ncolumns1 && tupdesc1->attrs[i1]->attisdropped) {
if (i1 < ncolumns1 && tupdesc1->attrs[i1].attisdropped) {
i1++;
continue;
}
if (i2 < ncolumns2 && tupdesc2->attrs[i2]->attisdropped) {
if (i2 < ncolumns2 && tupdesc2->attrs[i2].attisdropped) {
i2++;
continue;
}
@ -1168,28 +1168,28 @@ Datum record_eq(PG_FUNCTION_ARGS)
/*
* Have two matching columns, they must be same type
*/
if (tupdesc1->attrs[i1]->atttypid != tupdesc2->attrs[i2]->atttypid)
if (tupdesc1->attrs[i1].atttypid != tupdesc2->attrs[i2].atttypid)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot compare dissimilar column types %s and %s at record column %d",
format_type_be(tupdesc1->attrs[i1]->atttypid),
format_type_be(tupdesc2->attrs[i2]->atttypid),
format_type_be(tupdesc1->attrs[i1].atttypid),
format_type_be(tupdesc2->attrs[i2].atttypid),
j + 1)));
/*
* If they're not same collation, we don't complain here, but the
* equality function might.
*/
collation = tupdesc1->attrs[i1]->attcollation;
if (collation != tupdesc2->attrs[i2]->attcollation)
collation = tupdesc1->attrs[i1].attcollation;
if (collation != tupdesc2->attrs[i2].attcollation)
collation = InvalidOid;
/*
* Lookup the equality function if not done already
*/
typentry = my_extra->columns[j].typentry;
if (typentry == NULL || typentry->type_id != tupdesc1->attrs[i1]->atttypid) {
typentry = lookup_type_cache(tupdesc1->attrs[i1]->atttypid, TYPECACHE_EQ_OPR_FINFO);
if (typentry == NULL || typentry->type_id != tupdesc1->attrs[i1].atttypid) {
typentry = lookup_type_cache(tupdesc1->attrs[i1].atttypid, TYPECACHE_EQ_OPR_FINFO);
if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),

View File

@ -4028,7 +4028,7 @@ Datum pg_get_functiondef(PG_FUNCTION_ARGS)
int headerlines = 0;
errno_t rc = EOK;
tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "headerlines", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "definition", TEXTOID, -1, 0);
(void)BlessTupleDesc(tupdesc);
@ -6129,7 +6129,7 @@ static void get_target_list(Query* query, List* targetList, deparse_context* con
* Otherwise, just use what we can find in the TLE.
*/
if (resultDesc && colno <= resultDesc->natts)
colname = NameStr(resultDesc->attrs[colno - 1]->attname);
colname = NameStr(resultDesc->attrs[colno - 1].attname);
else
colname = tle->resname;
@ -8225,7 +8225,7 @@ static const char* get_name_for_var_field(Var* var, int fieldno, int levelsup, d
Assert(tupleDesc);
/* Got the tupdesc, so we can extract the field name */
Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
return NameStr(tupleDesc->attrs[fieldno - 1]->attname);
return NameStr(tupleDesc->attrs[fieldno - 1].attname);
}
/* Find appropriate nesting depth */
@ -8527,7 +8527,7 @@ static const char* get_name_for_var_field(Var* var, int fieldno, int levelsup, d
Assert(tupleDesc);
/* Got the tupdesc, so we can extract the field name */
Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
return NameStr(tupleDesc->attrs[fieldno - 1]->attname);
return NameStr(tupleDesc->attrs[fieldno - 1].attname);
}
/*
@ -9531,7 +9531,7 @@ static void get_rule_expr(Node* node, deparse_context* context, bool showimplici
foreach (arg, rowexpr->args) {
Node* e = (Node*)lfirst(arg);
if (tupdesc == NULL || !tupdesc->attrs[i]->attisdropped) {
if (tupdesc == NULL || !tupdesc->attrs[i].attisdropped) {
appendStringInfoString(buf, sep);
get_rule_expr(e, context, true, no_alias);
sep = ", ";
@ -9540,7 +9540,7 @@ static void get_rule_expr(Node* node, deparse_context* context, bool showimplici
}
if (tupdesc != NULL) {
while (i < tupdesc->natts) {
if (!tupdesc->attrs[i]->attisdropped) {
if (!tupdesc->attrs[i].attisdropped) {
appendStringInfoString(buf, sep);
appendStringInfo(buf, "NULL");
sep = ", ";

View File

@ -283,8 +283,8 @@ static Datum currtid_for_view(Relation viewrel, ItemPointer tid)
int i, natts = att->natts, tididx = -1;
for (i = 0; i < natts; i++) {
if (strcmp(NameStr(att->attrs[i]->attname), "ctid") == 0) {
if (att->attrs[i]->atttypid != TIDOID)
if (strcmp(NameStr(att->attrs[i].attname), "ctid") == 0) {
if (att->attrs[i].atttypid != TIDOID)
ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("ctid isn't of type TID")));
tididx = i;
break;

View File

@ -952,7 +952,7 @@ static void ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext* funcctx
}
Assert(stat->stackpos <= stat->maxdepth);
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "word", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "ndoc", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "nentry", INT4OID, -1, 0);

View File

@ -2923,12 +2923,12 @@ static const char* map_sql_table_to_xmlschema(
rowtypename);
for (i = 0; i < tupdesc->natts; i++) {
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
appendStringInfo(&result,
" <xsd:element name=\"%s\" type=\"%s\"%s></xsd:element>\n",
map_sql_identifier_to_xml_name(NameStr(tupdesc->attrs[i]->attname), true, false),
map_sql_type_to_xml_name(tupdesc->attrs[i]->atttypid, -1),
map_sql_identifier_to_xml_name(NameStr(tupdesc->attrs[i].attname), true, false),
map_sql_type_to_xml_name(tupdesc->attrs[i].atttypid, -1),
nulls ? " nillable=\"true\"" : " minOccurs=\"0\"");
}
@ -3179,9 +3179,9 @@ static const char* map_sql_typecoll_to_xmlschema_types(List* tupdesc_list)
TupleDesc tupdesc = (TupleDesc)lfirst(cell0);
for (i = 0; i < tupdesc->natts; i++) {
if (tupdesc->attrs[i]->attisdropped)
if (tupdesc->attrs[i].attisdropped)
continue;
uniquetypes = list_append_unique_oid(uniquetypes, tupdesc->attrs[i]->atttypid);
uniquetypes = list_append_unique_oid(uniquetypes, tupdesc->attrs[i].atttypid);
}
}

View File

@ -981,7 +981,7 @@ CatCache* InitCatCache(int id, Oid reloid, Oid indexoid, int nkeys, const int* k
i + 1, \
cache->cc_nkeys, \
cache->cc_keyno[i], \
tupdesc->attrs[cache->cc_keyno[i] - 1]->atttypid))); \
tupdesc->attrs[cache->cc_keyno[i] - 1].atttypid))); \
} else { \
ereport(DEBUG2, \
(errmsg("CatalogCacheInitializeCache: load %d/%d w/%d", i + 1, cache->cc_nkeys, cache->cc_keyno[i]))); \
@ -1056,7 +1056,7 @@ static void CatalogCacheInitializeCache(CatCache* cache)
CatalogCacheInitializeCache_DEBUG2;
if (cache->cc_keyno[i] > 0)
keytype = tupdesc->attrs[cache->cc_keyno[i] - 1]->atttypid;
keytype = tupdesc->attrs[cache->cc_keyno[i] - 1].atttypid;
else {
if (cache->cc_keyno[i] != ObjectIdAttributeNumber)
ereport(FATAL, (errmsg("only sys attr supported in caches is OID")));
@ -2384,7 +2384,7 @@ List* SearchBuiltinProcCacheList(CatCache* cache, int nkey, Datum* arguments, Li
TupleDesc CreateTupDesc4BuiltinFuncWithOid()
{
TupleDesc tupdesc = CreateTemplateTupleDesc(40, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(40, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "proname", NAMEOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "pronamespace", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "proowner", OIDOID, -1, 0);
@ -2965,7 +2965,7 @@ void CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, const int* attnos, Datum* ke
continue;
Assert(attnum > 0);
if (!tupdesc->attrs[attnum - 1]->attbyval) {
if (!tupdesc->attrs[attnum - 1].attbyval) {
void *ptr = DatumGetPointer(keys[i]);
pfree_ext(ptr);
keys[i] = (Datum)NULL;
@ -2993,7 +2993,7 @@ void CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, const int* attnos, Datum* sr
if (attnum == ObjectIdAttributeNumber) {
dstkeys[i] = srckeys[i];
} else {
Form_pg_attribute att = tupdesc->attrs[(attnum - 1)];
Form_pg_attribute att = &tupdesc->attrs[(attnum - 1)];
Datum src = srckeys[i];
NameData srcname;

View File

@ -1219,7 +1219,7 @@ int rd_att_to_datum(Datum *values, TupleDesc rd_att)
appendStringInfoString(&strinfo, ",");
}
appendStringInfoString(&strinfo, "'");
appendStringInfoString(&strinfo, rd_att->attrs[i]->attname.data);
appendStringInfoString(&strinfo, rd_att->attrs[i].attname.data);
appendStringInfoString(&strinfo, "'");
}
values[attrno++] = CStringGetTextDatum(strinfo.data);

View File

@ -1430,7 +1430,7 @@ void GlobalSysTupCache::InitRelationInfo()
Oid keytype;
RegProcedure eqfunc;
if (m_relinfo.cc_keyno[i] > 0)
keytype = m_relinfo.cc_tupdesc->attrs[m_relinfo.cc_keyno[i] - 1]->atttypid;
keytype = m_relinfo.cc_tupdesc->attrs[m_relinfo.cc_keyno[i] - 1].atttypid;
else {
if (m_relinfo.cc_keyno[i] != ObjectIdAttributeNumber)
ereport(FATAL, (errmsg("only sys attr supported in caches is OID")));

View File

@ -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);

View File

@ -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;

View File

@ -36,6 +36,7 @@
#include "access/reloptions.h"
#include "access/sysattr.h"
#include "access/transam.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "access/multixact.h"
@ -1415,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, TAM_INVALID);
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;
@ -1577,14 +1578,14 @@ static void RelationBuildTupleDesc(Relation relation, bool onlyLoadInitDefVal)
* Since relation->rd_att->atts palloc0 in function CreateTemplateTupleDesc,
* its attnum should be zero, use it to check if above scenario happened.
*/
if (relation->rd_att->attrs[attp->attnum - 1]->attnum != 0) {
if (relation->rd_att->attrs[attp->attnum - 1].attnum != 0) {
/* Panic if we hit here many times, plus 2 make sure it has enough room in err stack */
int eLevel = ((t_thrd.log_cxt.errordata_stack_depth + 2) < ERRORDATA_STACK_SIZE) ? ERROR : PANIC;
ereport(eLevel,(errmsg("Catalog attribute %d for relation \"%s\" has been updated concurrently",
attp->attnum, RelationGetRelationName(relation))));
}
errno_t rc = memcpy_s(
relation->rd_att->attrs[attp->attnum - 1], ATTRIBUTE_FIXED_PART_SIZE, attp, ATTRIBUTE_FIXED_PART_SIZE);
&relation->rd_att->attrs[attp->attnum - 1], ATTRIBUTE_FIXED_PART_SIZE, attp, ATTRIBUTE_FIXED_PART_SIZE);
securec_check(rc, "\0", "\0");
}
if (initdvals != NULL) {
@ -1636,7 +1637,7 @@ static void RelationBuildTupleDesc(Relation relation, bool onlyLoadInitDefVal)
/* find all missed attributes, and print them */
StringInfo missing_attnums = makeStringInfo();
for (int i = 0; i < RelationGetNumberOfAttributes(relation); i++) {
if (0 == relation->rd_att->attrs[i]->attnum) {
if (0 == relation->rd_att->attrs[i].attnum) {
appendStringInfo(missing_attnums, "%d ", (i + 1));
}
}
@ -1679,7 +1680,7 @@ static void RelationBuildTupleDesc(Relation relation, bool onlyLoadInitDefVal)
int i;
for (i = 0; i < RelationGetNumberOfAttributes(relation); i++)
Assert(relation->rd_att->attrs[i]->attcacheoff == -1);
Assert(relation->rd_att->attrs[i].attcacheoff == -1);
}
#endif
@ -1689,7 +1690,7 @@ static void RelationBuildTupleDesc(Relation relation, bool onlyLoadInitDefVal)
* for attnum=1 that used to exist in fastgetattr() and index_getattr().
*/
if (!RelationIsUstoreFormat(relation) && RelationGetNumberOfAttributes(relation) > 0)
relation->rd_att->attrs[0]->attcacheoff = 0;
relation->rd_att->attrs[0].attcacheoff = 0;
/*
* Set up constraint/default info
@ -1981,23 +1982,23 @@ 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_att = CreateTemplateTupleDesc(natts, hasoids, 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;
relation->rd_att->tdtypmod = -1;
has_not_null = false;
for (i = 0; i < natts; i++) {
errno_t rc = EOK;
rc = memcpy_s(relation->rd_att->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, &attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
rc = memcpy_s(&relation->rd_att->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, &attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
securec_check(rc, "\0", "\0");
has_not_null = has_not_null || attrs[i].attnotnull;
/* make sure attcacheoff is valid */
relation->rd_att->attrs[i]->attcacheoff = -1;
relation->rd_att->attrs[i].attcacheoff = -1;
}
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
relation->rd_att->attrs[0]->attcacheoff = 0;
relation->rd_att->attrs[0].attcacheoff = 0;
/* mark not-null status */
if (has_not_null) {
@ -2010,7 +2011,7 @@ static Relation CatalogRelationBuildDesc(const char* relationName, Oid relationR
/*
* initialize relation id from info in att array (my, this is ugly)
*/
RelationGetRelid(relation) = relation->rd_att->attrs[0]->attrelid;
RelationGetRelid(relation) = relation->rd_att->attrs[0].attrelid;
(void)MemoryContextSwitchTo(oldcxt);
@ -2199,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->tdTableAmType = 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);
@ -2385,7 +2386,7 @@ RelationInitBucketKey(Relation relation, HeapTuple tuple)
Oid *bkeytype = NULL;
int16 *attNum = NULL;
int nColumn;
Form_pg_attribute *rel_attrs = RelationGetDescr(relation)->attrs;
FormData_pg_attribute *rel_attrs = RelationGetDescr(relation)->attrs;
if (!RelationIsRelation(relation) ||
!OidIsValid(relation->rd_bucketoid)) {
@ -2413,8 +2414,8 @@ RelationInitBucketKey(Relation relation, HeapTuple tuple)
for (int i = 0; i < nColumn; i++) {
bkey->values[i] = attNum[i];
for (int j = 0; j < RelationGetDescr(relation)->natts; j++) {
if (attNum[i] == rel_attrs[j]->attnum) {
bkeytype[i] = rel_attrs[j]->atttypid;
if (attNum[i] == rel_attrs[j].attnum) {
bkeytype[i] = rel_attrs[j].atttypid;
break;
}
}
@ -2990,8 +2991,8 @@ extern void formrdesc(const char* relationName, Oid relationReltype, bool isshar
* Below Catalog tables are heap table type.
pg_database, pg_authid, pg_auth_members, pg_class, pg_attribute, pg_proc, and pg_type
*/
relation->rd_att = CreateTemplateTupleDesc(natts, hasoids, TAM_HEAP);
relation->rd_tam_type = TAM_HEAP;
relation->rd_att = CreateTemplateTupleDesc(natts, hasoids);
relation->rd_tam_ops = TableAmHeap;
relation->rd_att->tdrefcount = 1; /* mark as refcounted */
relation->rd_att->tdtypeid = relationReltype;
@ -3002,17 +3003,17 @@ extern void formrdesc(const char* relationName, Oid relationReltype, bool isshar
*/
has_not_null = false;
for (i = 0; i < natts; i++) {
errno_t rc = memcpy_s(relation->rd_att->attrs[i], ATTRIBUTE_FIXED_PART_SIZE,
errno_t rc = memcpy_s(&relation->rd_att->attrs[i], ATTRIBUTE_FIXED_PART_SIZE,
&attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
securec_check(rc, "", "");
has_not_null = has_not_null || attrs[i].attnotnull;
/* make sure attcacheoff is valid */
relation->rd_att->attrs[i]->attcacheoff = -1;
relation->rd_att->attrs[i].attcacheoff = -1;
}
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
if (!RelationIsUstoreFormat(relation))
relation->rd_att->attrs[0]->attcacheoff = 0;
relation->rd_att->attrs[0].attcacheoff = 0;
/* mark not-null status */
if (has_not_null) {
@ -3025,7 +3026,7 @@ extern void formrdesc(const char* relationName, Oid relationReltype, bool isshar
/*
* initialize relation id from info in att array (my, this is ugly)
*/
RelationGetRelid(relation) = relation->rd_att->attrs[0]->attrelid;
RelationGetRelid(relation) = relation->rd_att->attrs[0].attrelid;
/*
* All relations made with formrdesc are mapped. This is necessarily so
@ -4351,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);
@ -4426,14 +4428,14 @@ 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->tdTableAmType = 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++) {
rel->rd_att->attrs[i]->attnotnull = tupDesc->attrs[i]->attnotnull;
has_not_null = has_not_null || tupDesc->attrs[i]->attnotnull;
rel->rd_att->attrs[i].attnotnull = tupDesc->attrs[i].attnotnull;
has_not_null = has_not_null || tupDesc->attrs[i].attnotnull;
}
if (has_not_null) {
@ -4490,7 +4492,7 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple
RelationGetRelid(rel) = relid;
for (i = 0; i < natts; i++)
rel->rd_att->attrs[i]->attrelid = relid;
rel->rd_att->attrs[i].attrelid = relid;
rel->rd_rel->reltablespace = reltablespace;
@ -5429,19 +5431,19 @@ TupleDesc BuildHardcodedDescriptor(int natts, const FormData_pg_attribute* attrs
{
TupleDesc result;
int i;
result = CreateTemplateTupleDesc(natts, hasoids, TAM_HEAP);
result = CreateTemplateTupleDesc(natts, hasoids);
result->tdtypeid = RECORDOID; /* not right, but we don't care */
result->tdtypmod = -1;
for (i = 0; i < natts; i++) {
errno_t rc = memcpy_s(result->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, &attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
errno_t rc = memcpy_s(&result->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, &attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
securec_check(rc, "", "");
/* make sure attcacheoff is valid */
result->attrs[i]->attcacheoff = -1;
result->attrs[i].attcacheoff = -1;
}
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
result->attrs[0]->attcacheoff = 0;
result->attrs[0].attcacheoff = 0;
/* Note: we don't bother to set up a TupleConstr entry */
@ -5544,7 +5546,7 @@ static void AttrDefaultFetch(Relation relation)
if (attrdef[i].adbin != NULL)
ereport(WARNING, (errmsg("multiple attrdef records found for attr %s of rel %s",
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname), RelationGetRelationName(relation))));
NameStr(relation->rd_att->attrs[adform->adnum - 1].attname), RelationGetRelationName(relation))));
else
found++;
@ -5555,7 +5557,7 @@ static void AttrDefaultFetch(Relation relation)
val = fastgetattr(htup, Anum_pg_attrdef_adbin, adrel->rd_att, &isnull);
if (isnull)
ereport(WARNING, (errmsg("null adbin for attr %s of rel %s",
NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname), RelationGetRelationName(relation))));
NameStr(relation->rd_att->attrs[adform->adnum - 1].attname), RelationGetRelationName(relation))));
else
attrdef[i].adbin = MemoryContextStrdup(LocalMyDBCacheMemCxt(), TextDatumGetCString(val));
break;
@ -6965,7 +6967,7 @@ static bool load_relcache_init_file(bool shared)
/* initialize attribute tuple forms */
//XXTAM:
rel->rd_att = CreateTemplateTupleDesc(relform->relnatts, relform->relhasoids, TAM_HEAP);
rel->rd_att = CreateTemplateTupleDesc(relform->relnatts, relform->relhasoids);
rel->rd_att->tdrefcount = 1; /* mark as refcounted */
rel->rd_att->tdtypeid = relform->reltype;
@ -6979,12 +6981,12 @@ static bool load_relcache_init_file(bool shared)
goto read_failed;
if (len != ATTRIBUTE_FIXED_PART_SIZE)
goto read_failed;
if (fread(rel->rd_att->attrs[i], 1, len, fp) != len)
if (fread(&rel->rd_att->attrs[i], 1, len, fp) != len)
goto read_failed;
has_not_null = has_not_null || rel->rd_att->attrs[i]->attnotnull;
has_not_null = has_not_null || rel->rd_att->attrs[i].attnotnull;
if (rel->rd_att->attrs[i]->atthasdef) {
if (rel->rd_att->attrs[i].atthasdef) {
/*
* Caution! For autovacuum, catchup and walsender thread, they will return before
* calling RelationCacheInitializePhase3, so they cannot load default vaules of adding
@ -7371,7 +7373,7 @@ static void write_relcache_init_file(bool shared)
/* next, do all the attribute tuple form data entries */
for (i = 0; i < relform->relnatts; i++) {
write_item(rel->rd_att->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, fp);
write_item(&rel->rd_att->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, fp);
}
/* next, do the access method specific field */
@ -7916,24 +7918,24 @@ RelationMetaData* make_relmeta(Relation rel)
for (int i = 0; i < rel->rd_att->natts; i++) {
AttrMetaData* attr = makeNode(AttrMetaData);
attr->attalign = rel->rd_att->attrs[i]->attalign;
attr->attbyval = rel->rd_att->attrs[i]->attbyval;
attr->attkvtype = rel->rd_att->attrs[i]->attkvtype;
attr->attcmprmode = rel->rd_att->attrs[i]->attcmprmode;
attr->attcollation = rel->rd_att->attrs[i]->attcollation;
attr->atthasdef = rel->rd_att->attrs[i]->atthasdef;
attr->attinhcount = rel->rd_att->attrs[i]->attinhcount;
attr->attisdropped = rel->rd_att->attrs[i]->attisdropped;
attr->attislocal = rel->rd_att->attrs[i]->attislocal;
attr->attnotnull = rel->rd_att->attrs[i]->attnotnull;
attr->attlen = rel->rd_att->attrs[i]->attlen;
attr->attnum = rel->rd_att->attrs[i]->attnum;
attr->attstorage = rel->rd_att->attrs[i]->attstorage;
attr->atttypid = rel->rd_att->attrs[i]->atttypid;
attr->atttypmod = rel->rd_att->attrs[i]->atttypmod;
attr->attalign = rel->rd_att->attrs[i].attalign;
attr->attbyval = rel->rd_att->attrs[i].attbyval;
attr->attkvtype = rel->rd_att->attrs[i].attkvtype;
attr->attcmprmode = rel->rd_att->attrs[i].attcmprmode;
attr->attcollation = rel->rd_att->attrs[i].attcollation;
attr->atthasdef = rel->rd_att->attrs[i].atthasdef;
attr->attinhcount = rel->rd_att->attrs[i].attinhcount;
attr->attisdropped = rel->rd_att->attrs[i].attisdropped;
attr->attislocal = rel->rd_att->attrs[i].attislocal;
attr->attnotnull = rel->rd_att->attrs[i].attnotnull;
attr->attlen = rel->rd_att->attrs[i].attlen;
attr->attnum = rel->rd_att->attrs[i].attnum;
attr->attstorage = rel->rd_att->attrs[i].attstorage;
attr->atttypid = rel->rd_att->attrs[i].atttypid;
attr->atttypmod = rel->rd_att->attrs[i].atttypmod;
attr->attname = (char*)palloc0(NAMEDATALEN);
err = memcpy_s(attr->attname, NAMEDATALEN, rel->rd_att->attrs[i]->attname.data, NAMEDATALEN);
err = memcpy_s(attr->attname, NAMEDATALEN, rel->rd_att->attrs[i].attname.data, NAMEDATALEN);
securec_check_c(err, "\0", "\0");
node->attrs = lappend(node->attrs, attr);
@ -7982,23 +7984,23 @@ Relation get_rel_from_meta(RelationMetaData* node)
for (int i = 0; i < rel->rd_att->natts; i++) {
AttrMetaData* attr = (AttrMetaData*)list_nth(node->attrs, i);
rel->rd_att->attrs[i]->attalign = attr->attalign;
rel->rd_att->attrs[i]->attbyval = attr->attbyval;
rel->rd_att->attrs[i]->attkvtype = attr->attkvtype;
rel->rd_att->attrs[i]->attcmprmode = attr->attcmprmode;
rel->rd_att->attrs[i]->attcollation = attr->attcollation;
rel->rd_att->attrs[i]->atthasdef = attr->atthasdef;
rel->rd_att->attrs[i]->attinhcount = attr->attinhcount;
rel->rd_att->attrs[i]->attisdropped = attr->attisdropped;
rel->rd_att->attrs[i]->attislocal = attr->attislocal;
rel->rd_att->attrs[i]->attnotnull = attr->attnotnull;
rel->rd_att->attrs[i]->attlen = attr->attlen;
rel->rd_att->attrs[i]->attnum = attr->attnum;
rel->rd_att->attrs[i]->attstorage = attr->attstorage;
rel->rd_att->attrs[i]->atttypid = attr->atttypid;
rel->rd_att->attrs[i]->atttypmod = attr->atttypmod;
rel->rd_att->attrs[i].attalign = attr->attalign;
rel->rd_att->attrs[i].attbyval = attr->attbyval;
rel->rd_att->attrs[i].attkvtype = attr->attkvtype;
rel->rd_att->attrs[i].attcmprmode = attr->attcmprmode;
rel->rd_att->attrs[i].attcollation = attr->attcollation;
rel->rd_att->attrs[i].atthasdef = attr->atthasdef;
rel->rd_att->attrs[i].attinhcount = attr->attinhcount;
rel->rd_att->attrs[i].attisdropped = attr->attisdropped;
rel->rd_att->attrs[i].attislocal = attr->attislocal;
rel->rd_att->attrs[i].attnotnull = attr->attnotnull;
rel->rd_att->attrs[i].attlen = attr->attlen;
rel->rd_att->attrs[i].attnum = attr->attnum;
rel->rd_att->attrs[i].attstorage = attr->attstorage;
rel->rd_att->attrs[i].atttypid = attr->atttypid;
rel->rd_att->attrs[i].atttypmod = attr->atttypmod;
rc = memcpy_s(rel->rd_att->attrs[i]->attname.data, NAMEDATALEN, attr->attname, strlen(attr->attname));
rc = memcpy_s(rel->rd_att->attrs[i].attname.data, NAMEDATALEN, attr->attname, strlen(attr->attname));
securec_check(rc, "", "");
}

View File

@ -595,11 +595,11 @@ static void cache_record_field_properties(TypeCacheEntry* typentry)
for (i = 0; i < tupdesc->natts; i++) {
TypeCacheEntry* fieldentry = NULL;
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
continue;
}
fieldentry = lookup_type_cache(tupdesc->attrs[i]->atttypid, TYPECACHE_EQ_OPR | TYPECACHE_CMP_PROC);
fieldentry = lookup_type_cache(tupdesc->attrs[i].atttypid, TYPECACHE_EQ_OPR | TYPECACHE_CMP_PROC);
if (!OidIsValid(fieldentry->eq_opr)) {
newflags &= ~TCFLAGS_HAVE_FIELD_EQUALITY;
}
@ -752,7 +752,7 @@ void assign_record_type_typmod(TupleDesc tupDesc)
if (i >= REC_HASH_KEYS) {
break;
}
hashkey[i] = tupDesc->attrs[i]->atttypid;
hashkey[i] = tupDesc->attrs[i].atttypid;
}
recentry = (RecordCacheEntry*)hash_search(u_sess->tycache_cxt.RecordCacheHash, (void*)hashkey, HASH_ENTER, &found);
if (!found) {

View File

@ -540,7 +540,7 @@ static bool resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector* declared_a
/* See if there are any polymorphic outputs; quick out if not */
for (i = 0; i < natts; i++) {
switch (tupdesc->attrs[i]->atttypid) {
switch (tupdesc->attrs[i].atttypid) {
case ANYELEMENTOID:
have_anyelement_result = true;
break;
@ -656,21 +656,21 @@ static bool resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector* declared_a
/* And finally replace the tuple column types as needed */
for (i = 0; i < natts; i++) {
switch (tupdesc->attrs[i]->atttypid) {
switch (tupdesc->attrs[i].atttypid) {
case ANYELEMENTOID:
case ANYNONARRAYOID:
case ANYENUMOID:
TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyelement_type, -1, 0);
TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i].attname), anyelement_type, -1, 0);
TupleDescInitEntryCollation(tupdesc, i + 1, anycollation);
break;
case ANYARRAYOID:
TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyarray_type, -1, 0);
TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i].attname), anyarray_type, -1, 0);
TupleDescInitEntryCollation(tupdesc, i + 1, anycollation);
break;
case ANYRANGEOID:
TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyrange_type, -1, 0);
TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i].attname), anyrange_type, -1, 0);
/* no collation should be attached to a range type */
break;
@ -1327,7 +1327,7 @@ TupleDesc build_function_result_tupdesc_d(Datum proallargtypes, Datum proargmode
* functions use default heap tuple operations like heap_form_tuple, and they are
* accessed via tam type in tuple descriptor.
*/
desc = CreateTemplateTupleDesc(numoutargs, false, TAM_HEAP);
desc = CreateTemplateTupleDesc(numoutargs, false);
for (int i = 0; i < numoutargs; i++) {
if (outargtypes_orig != NULL) {
/* in case of a client-logic parameter, we pass the original data type in the typmod field */
@ -1408,7 +1408,7 @@ TupleDesc TypeGetTupleDesc(Oid typeoid, List* colaliases)
char* label = strVal(list_nth(colaliases, varattno));
if (label != NULL) {
(void)namestrcpy(&(tupdesc->attrs[varattno]->attname), label);
(void)namestrcpy(&(tupdesc->attrs[varattno].attname), label);
}
}
@ -1433,7 +1433,7 @@ TupleDesc TypeGetTupleDesc(Oid typeoid, List* colaliases)
/* OK, get the column alias */
attname = strVal(linitial(colaliases));
tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, attname, typeoid, -1, 0);
} else if (functypclass == TYPEFUNC_RECORD) {
/* XXX can't support this because typmod wasn't passed in ... */

View File

@ -9192,7 +9192,7 @@ TupleDesc GetPGVariableResultDesc(const char* name)
if (guc_name_compare(name, "all") == 0) {
/* need a tuple descriptor representing three TEXT columns */
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "setting", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "description", TEXTOID, -1, 0);
@ -9203,7 +9203,7 @@ TupleDesc GetPGVariableResultDesc(const char* name)
(void)GetConfigOptionByName(name, &varname);
/* need a tuple descriptor representing a single TEXT column */
tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, varname, TEXTOID, -1, 0);
}
@ -9224,7 +9224,7 @@ static void ShowGUCConfigOption(const char* name, DestReceiver* dest)
value = GetConfigOptionByName(name, &varname);
/* need a tuple descriptor representing a single TEXT column */
tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, varname, TEXTOID, -1, 0);
/* prepare for projection of tuples */
@ -9249,7 +9249,7 @@ static void ShowAllGUCConfig(const char* likename, DestReceiver* dest)
bool isnull[3] = {false, false, false};
/* need a tuple descriptor representing three TEXT columns */
tupdesc = CreateTemplateTupleDesc(3, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(3, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "setting", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "description", TEXTOID, -1, 0);
@ -9668,7 +9668,7 @@ Datum show_all_settings(PG_FUNCTION_ARGS)
* need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
* of the appropriate types
*/
tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "setting", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "unit", TEXTOID, -1, 0);

View File

@ -1428,6 +1428,56 @@ void* MemoryContextAllocHugeDebug(MemoryContext context, Size size, const char*
return ret;
}
/**
* @Description: Allocate (possibly-expansive) space within the specified context.
* See considerations in comment at MaxAllocHugeSize.
* @in context - the pointer of memory context
* @in size - the allocated size
* @in file - which file are allocating memory
* @in line - which line are allocating memory
*/
void* MemoryContextAllocHugeZeroDebug(MemoryContext context, Size size, const char* file, int line)
{
void* ret = NULL;
AssertArg(MemoryContextIsValid(context));
if (!AllocHugeSizeIsValid(size)) {
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid memory alloc request size %zu in %s:%d", size, file, line)));
}
context->isReset = false;
ret = (*context->methods->alloc)(context, 0, size, file, line);
if (ret == NULL)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_LOGICAL_MEMORY),
errmsg("memory is temporarily unavailable"),
errdetail("Failed on request of size %lu bytes under queryid %lu in %s:%d.",
(unsigned long)size,
u_sess->debug_query_id,
file,
line)));
#ifdef MEMORY_CONTEXT_CHECKING
/* check if the memory context is out of control */
MemoryContextCheckMaxSize(context, size, file, line);
#endif
/* check if the session used memory is beyond the limitation */
if (unlikely(STATEMENT_MAX_MEM)) {
MemoryContextCheckSessionMemory(context, size, file, line);
}
MemSetAligned(ret, 0, size);
InsertMemoryAllocInfo(ret, context, file, line, size);
return ret;
}
/**
* @Description: Adjust the size of a previously allocated chunk, permitting a large
* value. The previous allocation need not have been "huge".

View File

@ -1206,7 +1206,7 @@ Datum pg_cursor(PG_FUNCTION_ARGS)
* build tupdesc for result tuples. This must match the definition of the
* pg_cursors view in system_views.sql
*/
tupdesc = CreateTemplateTupleDesc(6, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(6, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "statement", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)3, "is_holdable", BOOLOID, -1, 0);

View File

@ -1853,7 +1853,7 @@ int CompareMultiColumn(const MultiColumns* a, const MultiColumns* b, Batchsortst
Assert(colIdx >= 0);
Form_pg_attribute attr = state->tupDesc->attrs[colIdx];
Form_pg_attribute attr = &state->tupDesc->attrs[colIdx];
Oid typeOid = attr->atttypid;
datum1Tmp = datum1 = a->m_values[colIdx];
@ -1969,7 +1969,7 @@ void ReadFromDataNode(Batchsortstate* state, MultiColumns& multiColumn, int tape
multiColumn.m_nulls[i] = flag;
if (!IS_NULL(flag)) {
if (state->NeedDecode(i)) {
Form_pg_attribute attr = state->tupDesc->attrs[i];
Form_pg_attribute attr = &state->tupDesc->attrs[i];
ScalarValue val = vecBatch->m_arr[i].m_vals[cursor];
Datum v = ScalarVector::Decode(val);
int typlen = 0;

View File

@ -813,7 +813,7 @@ void tuplestore_putvalues(Tuplestorestate* state, TupleDesc tdesc, Datum* values
MinimalTuple tuple;
MemoryContext oldcxt = MemoryContextSwitchTo(state->context);
tuple = tableam_tops_form_minimal_tuple(tdesc, values, isnull, NULL, HEAP_TUPLE);
tuple = tableam_tops_form_minimal_tuple(tdesc, values, isnull, NULL);
if (tuplestore_in_memory(state))
state->width += tuple->t_len;
USEMEM(state, GetMemoryChunkSpace(tuple));

View File

@ -1371,7 +1371,7 @@ Datum pg_export_snapshot_and_csn(PG_FUNCTION_ARGS)
* Construct a tuple descriptor for the result row. This must match this
* function's pg_proc entry!
*/
tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "snapshot_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "CSN", TEXTOID, -1, 0);
tupdesc = BlessTupleDesc(tupdesc);

View File

@ -8693,7 +8693,7 @@ make_execsql_stmt(int firsttoken, int location)
} else {
int nattr = rec_data->tupdesc->natts;
for (int i = 0; i < nattr; i++) {
Form_pg_attribute pg_att_form = rec_data->tupdesc->attrs[i];
Form_pg_attribute pg_att_form = TupleDescAttr(rec_data->tupdesc, i);
appendStringInfo(&ds, "%s.%s", rec_data->refname, NameStr(pg_att_form->attname));
if (i != (nattr - 1)) {
appendStringInfoString(&ds, ",");
@ -9515,7 +9515,7 @@ static AttrNumber get_assign_attrno(PLpgSQL_datum* target, char* attrname)
/* search the matched attribute */
for (int i = 0; i < elemtupledesc->natts; i++) {
if (namestrcmp(&(elemtupledesc->attrs[i]->attname), attrname) == 0) {
if (namestrcmp(&(elemtupledesc->attrs[i].attname), attrname) == 0) {
attrno = i;
break;
}
@ -10639,9 +10639,9 @@ static bool checkDuplicateAttrName(TupleDesc tupleDesc)
{
int attrnum = tupleDesc->natts;
for (int i = 0; i < attrnum; i++) {
Form_pg_attribute attr1 = tupleDesc->attrs[i];
Form_pg_attribute attr1 = &tupleDesc->attrs[i];
for (int j = i + 1; j < attrnum; j++) {
Form_pg_attribute attr2 = tupleDesc->attrs[j];
Form_pg_attribute attr2 = &tupleDesc->attrs[j];
if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) == 0) {
return true;
}
@ -10654,7 +10654,7 @@ static bool checkAllAttrName(TupleDesc tupleDesc)
{
int attrnum = tupleDesc->natts;
for (int i = 0; i < attrnum; i++) {
Form_pg_attribute pg_att_form = tupleDesc->attrs[i];
Form_pg_attribute pg_att_form = &tupleDesc->attrs[i];
char* att_name = NameStr(pg_att_form->attname);
if (strcmp(att_name, "?column?") != 0) {
return false;
@ -10699,7 +10699,7 @@ static Oid createCompositeTypeForCursor(PLpgSQL_var* var, PLpgSQL_expr* expr)
int attrnum = tupleDesc->natts;
for (int i = 0; i < attrnum; i++) {
ColumnDef *n = makeNode(ColumnDef);
Form_pg_attribute attr = tupleDesc->attrs[i];
Form_pg_attribute attr = &tupleDesc->attrs[i];
n->colname = pstrdup(NameStr(attr->attname));
n->typname = makeTypeNameFromOid(attr->atttypid, attr->atttypmod);
n->inhcount = 0;

View File

@ -3703,7 +3703,7 @@ PLpgSQL_row* build_row_from_class(Oid class_oid)
/*
* Get the attribute and check for dropped column
*/
attr_struct = row->rowtupdesc->attrs[i];
attr_struct = &row->rowtupdesc->attrs[i];
if (!attr_struct->attisdropped) {
char* attname = NULL;
@ -3813,7 +3813,7 @@ PLpgSQL_row* build_row_from_tuple_desc(const char* rowname, int lineno, TupleDes
row->default_val = NULL;
for (int i = 0; i < desc->natts; i++) {
Form_pg_attribute pg_att_form = desc->attrs[i];
Form_pg_attribute pg_att_form = &desc->attrs[i];
char* att_name = NameStr(pg_att_form->attname);
if (att_name == NULL || strcmp(att_name, "?column?") == 0) {
ereport(ERROR,

View File

@ -79,7 +79,7 @@ static Datum get_tuple_lineno_and_query(DebugClientInfo* client)
MemoryContext oldcontext = MemoryContextSwitchTo(client->context);
int DEBUG_NEXT_ATTR_NUM = 4;
tupdesc = CreateTemplateTupleDesc(DEBUG_NEXT_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_NEXT_ATTR_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "func_oid", OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "funcname", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "lineno", INT4OID, -1, 0);
@ -267,7 +267,7 @@ static Datum get_info_local_data(const char* var_name, const int frameno, Functi
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 4 columns */
tupdesc = CreateTemplateTupleDesc(DEBUG_LOCAL_VAR_TUPLE_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_LOCAL_VAR_TUPLE_ATTR_NUM, false);
int i = 0;
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "varname", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "vartype", TEXTOID, -1, 0);
@ -352,7 +352,7 @@ Datum debug_client_info_code(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 4 columns */
tupdesc = CreateTemplateTupleDesc(DEBUG_LOCAL_VAR_TUPLE_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_LOCAL_VAR_TUPLE_ATTR_NUM, false);
int i = 0;
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "lineno", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "code", TEXTOID, -1, 0);
@ -637,7 +637,7 @@ Datum debug_client_info_breakpoints(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 4 columns */
tupdesc = CreateTemplateTupleDesc(DEBUG_INFO_BP_TUPLE_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_INFO_BP_TUPLE_ATTR_NUM, false);
int i = 0;
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "breakpointno", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "funcoid", OIDOID, -1, 0);
@ -766,7 +766,7 @@ Datum debug_client_backtrace(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* need a tuple descriptor representing 4 columns */
tupdesc = CreateTemplateTupleDesc(DEBUG_BACKTRACE_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_BACKTRACE_ATTR_NUM, false);
int i = 0;
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "frameno", INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "funcname", TEXTOID, -1, 0);
@ -850,7 +850,7 @@ Datum local_debug_server_info(PG_FUNCTION_ARGS)
/* need a tuple descriptor representing 3 columns */
int i = 0;
tupdesc = CreateTemplateTupleDesc(DEBUG_SERVER_INFO_TUPLE_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_SERVER_INFO_TUPLE_ATTR_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "nodename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "port", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "funcoid", OIDOID, -1, 0);
@ -892,7 +892,7 @@ Datum debug_server_turn_on(PG_FUNCTION_ARGS)
TupleDesc tupdesc;
const int DEBUG_TURN_ON_ATTR_NUM = 2;
int i = 0;
tupdesc = CreateTemplateTupleDesc(DEBUG_TURN_ON_ATTR_NUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(DEBUG_TURN_ON_ATTR_NUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "nodename", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "port", INT4OID, -1, 0);
TupleDesc tuple_desc = BlessTupleDesc(tupdesc);

View File

@ -694,16 +694,16 @@ bool recheckTableofType(TupleDesc tupdesc, TupleDesc retdesc)
bool has_change = false;
for (int i = 0; i < n; i++) {
Form_pg_attribute att = tupdesc->attrs[i];
Form_pg_attribute att = &tupdesc->attrs[i];
if (att->attisdropped)
continue;
Oid baseOid = InvalidOid;
if (isTableofType(att->atttypid, &baseOid, NULL)) {
Oid typOid = baseOid;
char colname[NAMEDATALEN] = {0};
errno_t rc = memcpy_s(colname, NAMEDATALEN, tupdesc->attrs[i]->attname.data, NAMEDATALEN);
errno_t rc = memcpy_s(colname, NAMEDATALEN, tupdesc->attrs[i].attname.data, NAMEDATALEN);
securec_check(rc, "\0", "\0");
TupleDescInitEntry(tupdesc, i + 1, colname, typOid, retdesc->attrs[i]->atttypmod, 0);
TupleDescInitEntry(tupdesc, i + 1, colname, typOid, retdesc->attrs[i].atttypmod, 0);
has_change = true;
}
}
@ -1429,8 +1429,8 @@ Datum plpgsql_exec_function(PLpgSQL_function* func, FunctionCallInfo fcinfo, boo
securec_check(errorno, "\0", "\0");
}
if (estate.rettupdesc && i < estate.rettupdesc->natts &&
IsClientLogicType(estate.rettupdesc->attrs[i]->atttypid) && newm->datatype) {
newm->datatype->atttypmod = estate.rettupdesc->attrs[i]->atttypmod;
IsClientLogicType(estate.rettupdesc->attrs[i].atttypid) && newm->datatype) {
newm->datatype->atttypmod = estate.rettupdesc->attrs[i].atttypmod;
}
}
}
@ -3333,19 +3333,19 @@ static void plpgsql_set_outparam_value(PLpgSQL_execstate* estate, PLpgSQL_expr*
Datum paramval = values[1];
bool paramisnull = nulls[1];
/* If we have a single OUT param, it is not going to be a RECORD */
paramtupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
TupleDescInitEntry(paramtupdesc, (AttrNumber)1, NameStr(tupdesc->attrs[1]->attname),
tupdesc->attrs[1]->atttypid,
tupdesc->attrs[1]->atttypmod, 0);
paramtupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(paramtupdesc, (AttrNumber)1, NameStr(tupdesc->attrs[1].attname),
tupdesc->attrs[1].atttypid,
tupdesc->attrs[1].atttypmod, 0);
Datum vals[] = {paramval};
bool ns[] = {paramisnull};
tuple = heap_form_tuple(paramtupdesc, vals, ns);
} else {
/* Multiple OUT params */
paramtupdesc = CreateTemplateTupleDesc(attrsnum - 1, false, TAM_HEAP);
paramtupdesc = CreateTemplateTupleDesc(attrsnum - 1, false);
for (int i = 1; i < attrsnum; i++) {
TupleDescInitEntry(paramtupdesc, (AttrNumber)i, NameStr(tupdesc->attrs[i]->attname),
tupdesc->attrs[i]->atttypid, tupdesc->attrs[i]->atttypmod, 0);
TupleDescInitEntry(paramtupdesc, (AttrNumber)i, NameStr(tupdesc->attrs[i].attname),
tupdesc->attrs[i].atttypid, tupdesc->attrs[i].atttypmod, 0);
}
tuple = heap_form_tuple(paramtupdesc, (values + 1), (nulls + 1));
}
@ -4720,7 +4720,7 @@ static int exec_stmt_return(PLpgSQL_execstate* estate, PLpgSQL_stmt_return* stmt
if (estate->cursor_return_data != NULL) {
for (int i = 0,j = 0; i < row->rowtupdesc->natts; i++) {
if (row->rowtupdesc->attrs[i]->atttypid == REFCURSOROID) {
if (row->rowtupdesc->attrs[i].atttypid == REFCURSOROID) {
int dno = row->varnos[i];
ExecCopyDataFromDatum(estate->datums, dno, &estate->cursor_return_data[j]);
j = j + 1;
@ -4804,8 +4804,8 @@ static int exec_stmt_return_next(PLpgSQL_execstate* estate, PLpgSQL_stmt_return_
retval = exec_simple_cast_value(estate,
retval,
var->datatype->typoid,
tupdesc->attrs[0]->atttypid,
tupdesc->attrs[0]->atttypmod,
tupdesc->attrs[0].atttypid,
tupdesc->attrs[0].atttypmod,
isNull);
tuplestore_putvalues(estate->tuple_store, tupdesc, &retval, &isNull);
@ -4872,7 +4872,7 @@ static int exec_stmt_return_next(PLpgSQL_execstate* estate, PLpgSQL_stmt_return_
/* coerce type if needed */
retval = exec_simple_cast_value(
estate, retval, rettype, tupdesc->attrs[0]->atttypid, tupdesc->attrs[0]->atttypmod, isNull);
estate, retval, rettype, tupdesc->attrs[0].atttypid, tupdesc->attrs[0].atttypmod, isNull);
tuplestore_putvalues(estate->tuple_store, tupdesc, &retval, &isNull);
} else {
@ -7379,7 +7379,7 @@ void exec_assign_value(PLpgSQL_execstate* estate, PLpgSQL_datum* target, Datum v
* right type.
*/
atttype = SPI_gettypeid(rec->tupdesc, fno + 1);
atttypmod = rec->tupdesc->attrs[fno]->atttypmod;
atttypmod = rec->tupdesc->attrs[fno].atttypmod;
attisnull = *isNull;
values[fno] = exec_simple_cast_value(estate, value, valtype, atttype, atttypmod, attisnull);
nulls[fno] = attisnull;
@ -7545,7 +7545,7 @@ void exec_assign_value(PLpgSQL_execstate* estate, PLpgSQL_datum* target, Datum v
/* Coerce source value to match array element attribute type. */
if (elemtupledesc != NULL) {
coerced_attr_value = exec_simple_cast_value(estate, value, valtype,
elemtupledesc->attrs[attrno]->atttypid, elemtupledesc->attrs[attrno]->atttypmod, *isNull);
elemtupledesc->attrs[attrno].atttypid, elemtupledesc->attrs[attrno].atttypmod, *isNull);
} else {
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
@ -7831,7 +7831,7 @@ void exec_assign_value(PLpgSQL_execstate* estate, PLpgSQL_datum* target, Datum v
/* Coerce source value to match array element attribute type. */
if (elemtupledesc != NULL) {
coerced_attr_value = exec_simple_cast_value(estate, value, valtype,
elemtupledesc->attrs[attrno]->atttypid, elemtupledesc->attrs[attrno]->atttypmod, *isNull);
elemtupledesc->attrs[attrno].atttypid, elemtupledesc->attrs[attrno].atttypmod, *isNull);
} else {
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
@ -8121,8 +8121,8 @@ static Datum formDatumFromAttrTarget(PLpgSQL_execstate* estate, const PLpgSQL_te
errcause("incorrectly referencing variables"),
erraction("modify assign variable")));
}
Oid targettypoid = tupDesc->attrs[attnum]->atttypid;
int32 targettypmod = tupDesc->attrs[attnum]->atttypmod;
Oid targettypoid = tupDesc->attrs[attnum].atttypid;
int32 targettypmod = tupDesc->attrs[attnum].atttypmod;
bool attrisnull[tupDesc->natts];
Datum attrvalues[tupDesc->natts];
Datum coerced_value = exec_simple_cast_value(estate, value, *valtype, targettypoid, targettypmod, *isNull);
@ -8235,8 +8235,8 @@ static PLpgSQL_temp_assignvar* extractAttrValue(PLpgSQL_execstate* estate,
}
AttrNumber attrno = InvalidAttrNumber;
for (i = 0; i < tupDesc->natts; i++) {
if (namestrcmp(&(tupDesc->attrs[i]->attname), attrname) == 0) {
attrno = tupDesc->attrs[i]->attnum;
if (namestrcmp(&(tupDesc->attrs[i].attname), attrname) == 0) {
attrno = tupDesc->attrs[i].attnum;
break;
}
}
@ -8254,8 +8254,8 @@ static PLpgSQL_temp_assignvar* extractAttrValue(PLpgSQL_execstate* estate,
result = (PLpgSQL_temp_assignvar*)palloc0(sizeof(PLpgSQL_temp_assignvar));
result->isarrayelem = false;
result->isnull = target->isnull || isNull;
result->typoid = tupDesc->attrs[i]->atttypid;
result->typmod = tupDesc->attrs[i]->atttypmod;
result->typoid = tupDesc->attrs[i].atttypid;
result->typmod = tupDesc->attrs[i].atttypmod;
result->attnum = i;
result->value = resultvalue;
result->attrname = pstrdup(attrname);
@ -9024,7 +9024,7 @@ static void exec_eval_datum(PLpgSQL_execstate* estate, PLpgSQL_datum* datum, Oid
*typeId = SPI_gettypeid(rec->tupdesc, fno);
/* XXX there's no SPI_gettypmod, for some reason */
if (fno > 0) {
*typetypmod = rec->tupdesc->attrs[fno - 1]->atttypmod;
*typetypmod = rec->tupdesc->attrs[fno - 1].atttypmod;
} else {
*typetypmod = -1;
}
@ -9231,13 +9231,13 @@ void exec_get_datum_type_info(PLpgSQL_execstate* estate, PLpgSQL_datum* datum, O
*typeId = SPI_gettypeid(rec->tupdesc, fno);
/* XXX there's no SPI_gettypmod, for some reason */
if (fno > 0) {
*typmod = rec->tupdesc->attrs[fno - 1]->atttypmod;
*typmod = rec->tupdesc->attrs[fno - 1].atttypmod;
} else {
*typmod = -1;
}
/* XXX there's no SPI_getcollation either */
if (fno > 0) {
*collation = rec->tupdesc->attrs[fno - 1]->attcollation;
*collation = rec->tupdesc->attrs[fno - 1].attcollation;
} else {/* no system column types have collation */
*collation = InvalidOid;
}
@ -10118,7 +10118,7 @@ static bool CheckTypeIsCursor(PLpgSQL_row *row, Oid valtype, int fnum)
ereport(ERROR, (errcode(ERRCODE_UNEXPECTED_NULL_VALUE),
errmsg("Accessing unexpected null value when checking row type.")));
}
if (row->rowtupdesc->attrs[fnum]->atttypid == REFCURSOROID) {
if (row->rowtupdesc->attrs[fnum].atttypid == REFCURSOROID) {
return true;
}
}
@ -10142,7 +10142,7 @@ static Datum exec_tuple_get_composite(PLpgSQL_execstate* estate, TupleDesc tupde
int last_anum = 0;
bool first = true;
for (int anum = 0; anum < td_natts; anum++) {
if (tupdesc->attrs[anum]->attisdropped) {
if (tupdesc->attrs[anum].attisdropped) {
continue;
}
@ -10252,7 +10252,7 @@ static int bulk_collect_precheck(PLpgSQL_execstate* estate, PLpgSQL_row* row, Tu
* If td_natts is a positive number, tupdesc cannot be empty,
* so there is no need to double check here
*/
if (!tupdesc->attrs[i]->attisdropped) {
if (!tupdesc->attrs[i].attisdropped) {
anum++;
}
}
@ -10423,7 +10423,7 @@ static void exec_read_bulk_collect(PLpgSQL_execstate* estate, PLpgSQL_row* row,
} else {
/* skip dropped column in tuple */
t_natts = (HeapTupleIsValid(tup)) ? HeapTupleHeaderGetNatts(tup->t_data, context.tupdesc) : 0;
while (anum < td_natts && context.tupdesc->attrs[anum]->attisdropped) {
while (anum < td_natts && context.tupdesc->attrs[anum].attisdropped) {
anum++;
}
@ -10571,7 +10571,7 @@ static void exec_move_row(PLpgSQL_execstate* estate,
int m_natts = 0;
for (int i = 0; i < td_natts; i++) {
if (!tupdesc->attrs[i]->attisdropped) {
if (!tupdesc->attrs[i].attisdropped) {
m_natts++; /* skip dropped column in tuple */
}
}
@ -10588,7 +10588,7 @@ static void exec_move_row(PLpgSQL_execstate* estate,
/* for one dynamic statement only */
if (row->nfields > 0) {
Oid tupTypeOid = (tupdesc != NULL && tupdesc->attrs != NULL) ? tupdesc->attrs[0]->atttypid : InvalidOid;
Oid tupTypeOid = (tupdesc != NULL && tupdesc->attrs != NULL) ? tupdesc->attrs[0].atttypid : InvalidOid;
Oid rowTypeOid = (row->rowtupdesc != NULL) ? row->rowtupdesc->tdtypeid : InvalidOid;
bool needSplitByNattrs = (td_natts == 1 && row->nfields > 1) || (td_natts == 1 && row->nfields == 1);
@ -10631,7 +10631,7 @@ static void exec_move_row(PLpgSQL_execstate* estate,
#else
var = (PLpgSQL_var*)(estate->datums[row->varnos[fnum]]);
#endif
while (anum < td_natts && tupdesc->attrs[anum]->attisdropped) {
while (anum < td_natts && tupdesc->attrs[anum].attisdropped) {
anum++; /* skip dropped column in tuple */
}
@ -10688,7 +10688,7 @@ static void exec_move_row(PLpgSQL_execstate* estate,
var = (PLpgSQL_var*)(row->intodatums[fnum]);
while (anum < td_natts && tupdesc->attrs[anum]->attisdropped) {
while (anum < td_natts && tupdesc->attrs[anum].attisdropped) {
anum++; /* skip dropped column in tuple */
}
@ -10750,7 +10750,7 @@ HeapTuple make_tuple_from_row(PLpgSQL_execstate* estate, PLpgSQL_row* row, Tuple
Oid fieldtypeid;
int32 fieldtypmod;
if (tupdesc->attrs[i]->attisdropped) {
if (tupdesc->attrs[i].attisdropped) {
nulls[i] = true; /* leave the column as null */
continue;
}
@ -10800,9 +10800,9 @@ HeapTuple make_tuple_from_row(PLpgSQL_execstate* estate, PLpgSQL_row* row, Tuple
nulls[i] = true;
}
}
if (fieldtypeid != tupdesc->attrs[i]->atttypid) {
if (fieldtypeid != tupdesc->attrs[i].atttypid) {
/* if table of type should check its array type */
HeapTuple type_tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid));
HeapTuple type_tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i].atttypid));
if (HeapTupleIsValid(type_tup)) {
Oid refTypOid = ((Form_pg_type)GETSTRUCT(type_tup))->typelem;
char refTypType = ((Form_pg_type)GETSTRUCT(type_tup))->typtype;

View File

@ -651,7 +651,7 @@ static HeapTuple PLy_modify_tuple(PLyProcedure* proc, PyObject* pltd, TriggerDat
modattrs[i] = attn;
if (tupdesc->attrs[atti]->attisdropped) {
if (tupdesc->attrs[atti].attisdropped) {
modvalues[i] = (Datum)0;
modnulls[i] = 'n';
} else if (plval != Py_None) {

View File

@ -150,7 +150,7 @@ static PyObject* PLy_result_colnames(PyObject* self, PyObject* unused)
list = PyList_New(ob->tupdesc->natts);
for (i = 0; i < ob->tupdesc->natts; i++) {
PyList_SET_ITEM(list, i, PyString_FromString(NameStr(ob->tupdesc->attrs[i]->attname)));
PyList_SET_ITEM(list, i, PyString_FromString(NameStr(ob->tupdesc->attrs[i].attname)));
}
return list;
@ -169,7 +169,7 @@ static PyObject* PLy_result_coltypes(PyObject* self, PyObject* unused)
list = PyList_New(ob->tupdesc->natts);
for (i = 0; i < ob->tupdesc->natts; i++) {
PyList_SET_ITEM(list, i, PyInt_FromLong(ob->tupdesc->attrs[i]->atttypid));
PyList_SET_ITEM(list, i, PyInt_FromLong(ob->tupdesc->attrs[i].atttypid));
}
return list;
@ -188,7 +188,7 @@ static PyObject* PLy_result_coltypmods(PyObject* self, PyObject* unused)
list = PyList_New(ob->tupdesc->natts);
for (i = 0; i < ob->tupdesc->natts; i++) {
PyList_SET_ITEM(list, i, PyInt_FromLong(ob->tupdesc->attrs[i]->atttypmod));
PyList_SET_ITEM(list, i, PyInt_FromLong(ob->tupdesc->attrs[i].atttypmod));
}
return list;

View File

@ -166,20 +166,20 @@ void PLy_input_tuple_funcs(PLyTypeInfo* arg, TupleDesc desc)
for (i = 0; i < desc->natts; i++) {
HeapTuple typeTup;
if (desc->attrs[i]->attisdropped) {
if (desc->attrs[i].attisdropped) {
continue;
}
if (arg->in.r.atts[i].typoid == desc->attrs[i]->atttypid) {
if (arg->in.r.atts[i].typoid == desc->attrs[i].atttypid) {
continue; /* already set up this entry */
}
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(desc->attrs[i]->atttypid));
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(desc->attrs[i].atttypid));
if (!HeapTupleIsValid(typeTup)) {
elog(ERROR, "cache lookup failed for type %u", desc->attrs[i]->atttypid);
elog(ERROR, "cache lookup failed for type %u", desc->attrs[i].atttypid);
}
PLy_input_datum_func2(&(arg->in.r.atts[i]), desc->attrs[i]->atttypid, typeTup);
PLy_input_datum_func2(&(arg->in.r.atts[i]), desc->attrs[i].atttypid, typeTup);
ReleaseSysCache(typeTup);
}
@ -228,17 +228,17 @@ void PLy_output_tuple_funcs(PLyTypeInfo* arg, TupleDesc desc)
for (i = 0; i < desc->natts; i++) {
HeapTuple typeTup;
if (desc->attrs[i]->attisdropped) {
if (desc->attrs[i].attisdropped) {
continue;
}
if (arg->out.r.atts[i].typoid == desc->attrs[i]->atttypid) {
if (arg->out.r.atts[i].typoid == desc->attrs[i].atttypid) {
continue; /* already set up this entry */
}
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(desc->attrs[i]->atttypid));
typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(desc->attrs[i].atttypid));
if (!HeapTupleIsValid(typeTup)) {
elog(ERROR, "cache lookup failed for type %u", desc->attrs[i]->atttypid);
elog(ERROR, "cache lookup failed for type %u", desc->attrs[i].atttypid);
}
PLy_output_datum_func2(&(arg->out.r.atts[i]), typeTup);
@ -303,7 +303,7 @@ PyObject *PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc,
bool is_null = false;
PyObject* value = NULL;
if (desc->attrs[i]->attisdropped) {
if (desc->attrs[i].attisdropped) {
continue;
}
@ -313,7 +313,7 @@ PyObject *PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc,
continue;
}
key = NameStr(desc->attrs[i]->attname);
key = NameStr(desc->attrs[i].attname);
vattr = heap_getattr(tuple, (i + 1), desc, &is_null);
if (is_null || info->in.r.atts[i].func == NULL) {
@ -930,13 +930,13 @@ static Datum PLyMapping_ToComposite(PLyTypeInfo* info, TupleDesc desc, PyObject*
PyObject* volatile value = NULL;
PLyObToDatum* att = NULL;
if (desc->attrs[i]->attisdropped) {
if (desc->attrs[i].attisdropped) {
values[i] = (Datum)0;
nulls[i] = true;
continue;
}
key = NameStr(desc->attrs[i]->attname);
key = NameStr(desc->attrs[i].attname);
value = NULL;
att = &info->out.r.atts[i];
PG_TRY();
@ -991,7 +991,7 @@ static Datum PLySequence_ToComposite(PLyTypeInfo* info, TupleDesc desc, PyObject
*/
idx = 0;
for (i = 0; i < desc->natts; i++) {
if (!desc->attrs[i]->attisdropped) {
if (!desc->attrs[i].attisdropped) {
idx++;
}
}
@ -1014,7 +1014,7 @@ static Datum PLySequence_ToComposite(PLyTypeInfo* info, TupleDesc desc, PyObject
PyObject* volatile value = NULL;
PLyObToDatum* att = NULL;
if (desc->attrs[i]->attisdropped) {
if (desc->attrs[i].attisdropped) {
values[i] = (Datum)0;
nulls[i] = true;
continue;
@ -1075,13 +1075,13 @@ static Datum PLyGenericObject_ToComposite(PLyTypeInfo* info, TupleDesc desc, PyO
PyObject* volatile value = NULL;
PLyObToDatum* att = NULL;
if (desc->attrs[i]->attisdropped) {
if (desc->attrs[i].attisdropped) {
values[i] = (Datum)0;
nulls[i] = true;
continue;
}
key = NameStr(desc->attrs[i]->attname);
key = NameStr(desc->attrs[i].attname);
value = NULL;
att = &info->out.r.atts[i];
PG_TRY();

View File

@ -196,7 +196,7 @@ Boot_CreateStmt:
do_start();
tupdesc = CreateTupleDesc(t_thrd.bootstrap_cxt.numattr, !($6), t_thrd.bootstrap_cxt.attrtypes, TAM_HEAP);
tupdesc = CreateTupleDesc(t_thrd.bootstrap_cxt.numattr, !($6), t_thrd.bootstrap_cxt.attrtypes);
shared_relation = $5;

View File

@ -531,7 +531,7 @@ void boot_openrel(char* relname)
t_thrd.bootstrap_cxt.attrtypes[i] = AllocateAttribute();
rc = memmove_s((char*)t_thrd.bootstrap_cxt.attrtypes[i],
ATTRIBUTE_FIXED_PART_SIZE,
(char*)t_thrd.bootstrap_cxt.boot_reldesc->rd_att->attrs[i],
(char*)&t_thrd.bootstrap_cxt.boot_reldesc->rd_att->attrs[i],
ATTRIBUTE_FIXED_PART_SIZE);
securec_check(rc, "\0", "\0");
@ -708,8 +708,8 @@ void InsertOneTuple(Oid objectid)
tupDesc = CreateTupleDesc(t_thrd.bootstrap_cxt.numattr,
RelationGetForm(t_thrd.bootstrap_cxt.boot_reldesc)->relhasoids,
t_thrd.bootstrap_cxt.attrtypes,
t_thrd.bootstrap_cxt.boot_reldesc->rd_tam_type);
tuple = (HeapTuple) tableam_tops_form_tuple(tupDesc, values, Nulls, HEAP_TUPLE);
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);
pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
@ -745,7 +745,7 @@ void InsertOneValue(char* value, int i)
ereport(DEBUG4, (errmsg("inserting column %d value \"%s\"", i, value)));
typoid = t_thrd.bootstrap_cxt.boot_reldesc->rd_att->attrs[i]->atttypid;
typoid = t_thrd.bootstrap_cxt.boot_reldesc->rd_att->attrs[i].atttypid;
boot_get_type_io_data(typoid, &typlen, &typbyval, &typalign, &typdelim, &typioparam, &typinput, &typoutput);

View File

@ -519,7 +519,7 @@ Datum gs_comm_proxy_thread_status(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(rsinfo->econtext->ecxt_per_query_memory);
/* need a tuple descriptor representing 9 columns */
tupdesc = CreateTemplateTupleDesc(7, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(7, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "ProxyThreadId", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "ProxyCpuAffinity", TEXTOID, -1, 0);

View File

@ -72,7 +72,7 @@ THR_LOCAL SQLBindColAPI pSQLBindCol = NULL;
static StringInfo get_odbc_errmsg(StringInfo all_msg);
static void unload_libodbc();
static void load_libodbc(FunctionCallInfo fcinfo);
static void check_typeoid(Form_pg_attribute* attrs, int natts);
static void check_typeoid(FormData_pg_attribute* attrs, int natts);
static Datum odbc_type_2_Datum(Form_pg_attribute attr, void* buf, const char* encoding);
extern void clean_ec_conn();
extern void delete_ec_ctrl();
@ -363,10 +363,10 @@ static StringInfo get_odbc_errmsg(StringInfo all_msg)
* @IN value: attrs, the attribute array.
* @IN value: natts, the number of the items in attrs.
*/
static void check_typeoid(Form_pg_attribute* attrs, int natts)
static void check_typeoid(FormData_pg_attribute* attrs, int natts)
{
for (int i = 0; i < natts; i++) {
switch (attrs[i]->atttypid) {
switch (attrs[i].atttypid) {
case BOOLOID:
case INT1OID:
case INT2OID:
@ -392,7 +392,7 @@ static void check_typeoid(Form_pg_attribute* attrs, int natts)
(errmodule(MOD_EC),
errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("unsupport data type: [%s] found in record definition.",
format_type_with_typemod(attrs[i]->atttypid, attrs[i]->atttypmod))));
format_type_with_typemod(attrs[i].atttypid, attrs[i].atttypmod))));
}
}
}
@ -677,7 +677,7 @@ Datum fetch_odbc(const char* dsn, FuncCallContext* funcctx, bool& isEnd, const c
Datum* values = (Datum*)palloc0(cols * sizeof(Datum));
for (Size i = 0; i < cols; i++) {
oid_types[i] = funcctx->tuple_desc->attrs[i]->atttypid;
oid_types[i] = funcctx->tuple_desc->attrs[i].atttypid;
}
/* get one row from odbc */
ODBC_TRY() {
@ -694,7 +694,7 @@ Datum fetch_odbc(const char* dsn, FuncCallContext* funcctx, bool& isEnd, const c
/* build a tuple */
for (Size i = 0; i < cols; i++) {
if (!nulls[i]) {
values[i] = odbc_type_2_Datum(funcctx->tuple_desc->attrs[i], buffer[i], encoding);
values[i] = odbc_type_2_Datum(&funcctx->tuple_desc->attrs[i], buffer[i], encoding);
}
}
HeapTuple tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);

View File

@ -422,7 +422,7 @@ Datum get_instr_wait_event(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(INSTR_WAITEVENT_ATTRUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(INSTR_WAITEVENT_ATTRUM, false);
create_tuple_entry(tupdesc);

View File

@ -180,7 +180,7 @@ Datum dynamic_func_control(PG_FUNCTION_ARGS)
deconstruct_array(param_arr, TEXTOID, -1, false, 'i', &param_datums, NULL, &no_params);
}
TupleDesc tupdesc = CreateTemplateTupleDesc(INSTRUMENTS_DYNAMIC_FUNC_CTL_ATTRNUM, false, TAM_HEAP);
TupleDesc tupdesc = CreateTemplateTupleDesc(INSTRUMENTS_DYNAMIC_FUNC_CTL_ATTRNUM, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "node_name", TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "result", TEXTOID, -1, 0);

View File

@ -676,7 +676,7 @@ Datum get_instr_rt_percentile(PG_FUNCTION_ARGS)
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(NUM_PERCENTILE_COUNT, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(NUM_PERCENTILE_COUNT, false);
if (!(PercentileSpace::CheckQueryPercentile())) {
MemoryContextSwitchTo(oldcontext);
SRF_RETURN_DONE(funcctx);

View File

@ -1622,7 +1622,7 @@ Datum get_instr_unique_sql(PG_FUNCTION_ARGS)
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(INSTRUMENTS_UNIQUE_SQL_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(INSTRUMENTS_UNIQUE_SQL_ATTRNUM, false);
create_tuple_entry(tupdesc);
funcctx->tuple_desc = BlessTupleDesc(tupdesc);

View File

@ -342,7 +342,7 @@ Datum get_instr_user_login(PG_FUNCTION_ARGS)
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(INSTRUMENTS_USER_ATTRNUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(INSTRUMENTS_USER_ATTRNUM, false);
create_instr_user_tuple(tupdesc, &i);
funcctx->tuple_desc = BlessTupleDesc(tupdesc);

View File

@ -463,7 +463,7 @@ void DBlink::procResultSuccess(ReturnSetInfo* rsinfo, PGresult* res)
* need a tuple descriptor representing one TEXT column to return
* the command status string as our result tuple
*/
tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "status", TEXTOID, -1, 0);
attinmeta = TupleDescGetAttInMetadata(tupdesc);

View File

@ -918,9 +918,9 @@ void GenReport::get_query_data(char* query, bool with_column_name, List** cstrin
/* get colname */
if (with_column_name) {
for (int32 i = 0; i < SPI_tuptable->tupdesc->natts; i++) {
size_t maxSize = strlen(SPI_tuptable->tupdesc->attrs[i]->attname.data) + 1;
size_t maxSize = strlen(SPI_tuptable->tupdesc->attrs[i].attname.data) + 1;
char* strName = (char*)palloc(maxSize * sizeof(char));
errno_t rc = strncpy_s(strName, maxSize, SPI_tuptable->tupdesc->attrs[i]->attname.data, maxSize - 1);
errno_t rc = strncpy_s(strName, maxSize, SPI_tuptable->tupdesc->attrs[i].attname.data, maxSize - 1);
securec_check(rc, "\0", "\0");
colname_cstring = lappend(colname_cstring, strName);
}

View File

@ -626,7 +626,7 @@ void SnapshotNameSpace::GetQueryData(const char* query, bool with_column_name, L
/* get colname */
if (with_column_name) {
for (int32 i = 0; i < SPI_tuptable->tupdesc->natts; i++) {
char* strName = pstrdup(SPI_tuptable->tupdesc->attrs[i]->attname.data);
char* strName = pstrdup(SPI_tuptable->tupdesc->attrs[i].attname.data);
colname_cstring = lappend(colname_cstring, strName);
}
*cstring_values = lappend(*cstring_values, colname_cstring);

View File

@ -428,7 +428,7 @@ Datum get_instr_workload_info(PG_FUNCTION_ARGS)
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
tupdesc = CreateTemplateTupleDesc(INSTR_WORKLOAD_ATTRUM, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(INSTR_WORKLOAD_ATTRUM, false);
create_tuple_entry(tupdesc);

View File

@ -653,7 +653,7 @@ int2vector* getPartitionKeyAttrNo(
int n_key_column, i, j;
int2vector* partkey = NULL;
Oid* oidArr = NULL;
Form_pg_attribute* rel_attrs = base_table_tupledsc->attrs;
FormData_pg_attribute* rel_attrs = base_table_tupledsc->attrs;
Assert(PointerIsValid(typeOids));
@ -695,8 +695,8 @@ int2vector* getPartitionKeyAttrNo(
int16 attnum = attnums[i];
partkey->values[i] = attnum;
for (j = 0; j < base_table_tupledsc->natts; j++) {
if (attnum == rel_attrs[j]->attnum) {
oidArr[i] = rel_attrs[j]->atttypid;
if (attnum == rel_attrs[j].attnum) {
oidArr[i] = rel_attrs[j].atttypid;
break;
}
}
@ -1620,7 +1620,7 @@ Const* transformDatum2Const(TupleDesc tupledesc, int16 attnum, Datum datumValue,
Assert(attnum <= tupledesc->natts);
Assert(attnum >= 1);
attindex = attnum - 1;
att = tupledesc->attrs[attindex];
att = &tupledesc->attrs[attindex];
typid = att->atttypid;
typmod = att->atttypmod;

View File

@ -68,7 +68,7 @@ static explain_get_index_name_hook_type prev_explain_get_index_name_hook = NULL;
extern Oid GetIndexOpClass(List *opclass, Oid attrType, const char *accessMethodName, Oid accessMethodId);
extern void CheckPredicate(Expr *predicate);
extern bool CheckMutability(Expr *expr);
static void hypo_utility_hook(Node *parsetree, const char *queryString, ParamListInfo params, bool isTopLevel,
static void hypo_utility_hook(Node *parsetree, const char *queryString, bool readOnlyTree, ParamListInfo params, bool isTopLevel,
DestReceiver *dest, bool sentToRemote, char *completionTag, bool isCtas);
static void hypo_executorEnd_hook(QueryDesc *queryDesc);
static void hypo_get_relation_info_hook(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel);
@ -166,15 +166,15 @@ static Oid hypo_getNewOid(Oid relid)
/* This function setup the "isExplain" flag for next hooks.
* If this flag is setup, we can add hypothetical indexes.
*/
void hypo_utility_hook(Node *parsetree, const char *queryString, ParamListInfo params, bool isTopLevel,
void hypo_utility_hook(Node *parsetree, const char *queryString, bool readOnlyTree, ParamListInfo params, bool isTopLevel,
DestReceiver *dest, bool sentToRemote, char *completionTag, bool isCtas)
{
isExplain = query_or_expression_tree_walker(parsetree, (bool (*)())hypo_query_walker, NULL, 0);
if (prev_utility_hook) {
prev_utility_hook(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag, isCtas);
prev_utility_hook(parsetree, queryString, readOnlyTree, params, isTopLevel, dest, sentToRemote, completionTag, isCtas);
} else {
standard_ProcessUtility(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag, isCtas);
standard_ProcessUtility(parsetree, queryString, readOnlyTree, params, isTopLevel, dest, sentToRemote, completionTag, isCtas);
}
}

View File

@ -58,7 +58,7 @@
#define MAX_SAMPLE_ROWS 10000 /* sampling range for executing a query */
#define CARDINALITY_THRESHOLD 30 /* the threshold of index selection */
#define RelAttrName(__tupdesc, __attridx) (NameStr((__tupdesc)->attrs[(__attridx)]->attname))
#define RelAttrName(__tupdesc, __attridx) (NameStr((__tupdesc)->attrs[(__attridx)].attname))
#define IsSameRel(_schema1, _table1, _schema2, _table2) \
((!_schema1 || !_schema2 || strcasecmp(_schema1, _schema2) == 0) && strcasecmp(_table1, _table2) == 0)
@ -699,7 +699,7 @@ void receive(TupleTableSlot *slot, DestReceiver *self)
if (isnull) {
continue;
}
getTypeOutputInfo(typeinfo->attrs[i]->atttypid, &typoutput, &typisvarlena);
getTypeOutputInfo(typeinfo->attrs[i].atttypid, &typoutput, &typisvarlena);
if (typisvarlena) {
attr = PointerGetDatum(PG_DETOAST_DATUM(origattr));

View File

@ -422,8 +422,8 @@ void analyze_rel(Oid relid, VacuumStmt* vacstmt, BufferAccessStrategy bstrategy)
*/
if (RelationIsUstoreFormat(onerel)) {
for (int i = 0; i < onerel->rd_att->natts; i++) {
if (onerel->rd_att->attrs[i]->attcacheoff >= 0) {
onerel->rd_att->attrs[i]->attcacheoff = -1;
if (onerel->rd_att->attrs[i].attcacheoff >= 0) {
onerel->rd_att->attrs[i].attcacheoff = -1;
}
}
}
@ -1085,7 +1085,7 @@ static BlockNumber estimate_cstore_blocks(
/* just as get_rel_data_width */
for (i = 1; i <= RelationGetNumberOfAttributes(rel); i++) {
Form_pg_attribute att = rel->rd_att->attrs[i - 1];
Form_pg_attribute att = &rel->rd_att->attrs[i - 1];
int32 item_width = -1;
if (att->attisdropped)
@ -1157,7 +1157,7 @@ static BlockNumber estimate_tsstore_blocks(Relation rel, int attrCnt, double tot
/* just as get_rel_data_width */
for (i = 1; i <= attrCnt; i++) {
Form_pg_attribute att = rel->rd_att->attrs[i - 1];
Form_pg_attribute att = &rel->rd_att->attrs[i - 1];
int32 item_width = -1;
if (att->attisdropped)
@ -1225,10 +1225,10 @@ static BlockNumber estimate_psort_index_blocks(TupleDesc desc, double totalTuple
{
int totalWidth = 0;
int attrCnt = desc->natts;
Form_pg_attribute* attrs = desc->attrs;
FormData_pg_attribute* attrs = desc->attrs;
for (int attIdx = 0; attIdx < attrCnt; ++attIdx) {
Form_pg_attribute thisatt = attrs[attIdx];
Form_pg_attribute thisatt = &attrs[attIdx];
totalWidth += get_typavgwidth(thisatt->atttypid, thisatt->atttypmod);
}
@ -1247,12 +1247,12 @@ static BlockNumber estimate_btree_index_blocks(TupleDesc desc, double totalTuple
{
int totalWidth = 0;
int attrCnt = desc->natts;
Form_pg_attribute* attrs = desc->attrs;
FormData_pg_attribute* attrs = desc->attrs;
BlockNumber totalPages = 0; /* returning block number */
bool hasToast = false;
for (int attIdx = 0; attIdx < attrCnt; ++attIdx) {
Form_pg_attribute thisatt = attrs[attIdx];
Form_pg_attribute thisatt = &attrs[attIdx];
totalWidth += get_typavgwidth(thisatt->atttypid, thisatt->atttypmod);
AssertEreport(totalWidth > 0,
MOD_OPT,
@ -2114,7 +2114,7 @@ VacAttrStats* examine_attribute(Relation onerel, Bitmapset* bms_attnums, bool is
{
/* only analyze multi-column when each single column is valid */
for (int attnum = -1; (attnum = bms_next_member(bms_attnums, attnum)) > 0;) {
Form_pg_attribute attr = onerel->rd_att->attrs[attnum - 1];
Form_pg_attribute attr = &onerel->rd_att->attrs[attnum - 1];
if (!es_is_valid_column_to_analyze(attr)) {
return NULL;
}
@ -2139,7 +2139,7 @@ VacAttrStats* examine_attribute(Relation onerel, Bitmapset* bms_attnums, bool is
/* Set stats->attrs */
int index = 0;
for (int attnum = -1; (attnum = bms_next_member(bms_attnums, attnum)) > 0;) {
Form_pg_attribute attr = onerel->rd_att->attrs[attnum - 1];
Form_pg_attribute attr = &onerel->rd_att->attrs[attnum - 1];
stats->attrs[index] = (Form_pg_attribute)palloc0(ATTRIBUTE_FIXED_PART_SIZE);
@ -2176,7 +2176,7 @@ static VacAttrStats* examine_attribute(Relation onerel, int attnum, Node* index_
int i;
bool ok = false;
Form_pg_attribute attr = onerel->rd_att->attrs[attnum - 1];
Form_pg_attribute attr = &onerel->rd_att->attrs[attnum - 1];
/* Check wheather the column is valid to analyze */
if (!es_is_valid_column_to_analyze(attr)) {
@ -2647,13 +2647,13 @@ retry:
* reset to avoid their usage while reading heap tuples from rows array.
*/
for (int i = 0; i < onerel->rd_att->natts; i++) {
if (onerel->rd_att->attrs[i]->attcacheoff >= 0) {
onerel->rd_att->attrs[i]->attcacheoff = -1;
if (onerel->rd_att->attrs[i].attcacheoff >= 0) {
onerel->rd_att->attrs[i].attcacheoff = -1;
}
}
/* TO DO: Need to switch this to inplaceheapam_scan_analyze_next_block after we have tableam. */
TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(onerel), false, 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 */
@ -2809,8 +2809,8 @@ retry:
* reset to avoid their usage while reading heap tuples from rows array.
*/
for (int i = 0; i < onerel->rd_att->natts; i++) {
if (onerel->rd_att->attrs[i]->attcacheoff >= 0) {
onerel->rd_att->attrs[i]->attcacheoff = -1;
if (onerel->rd_att->attrs[i].attcacheoff >= 0) {
onerel->rd_att->attrs[i].attcacheoff = -1;
}
}
@ -3423,7 +3423,7 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
/* Prepare for sampling rows */
CStore* cstore = cstoreScanDesc->m_CStore;
Form_pg_attribute* attrs = cstore->m_relation->rd_att->attrs;
FormData_pg_attribute* attrs = cstore->m_relation->rd_att->attrs;
GetValFunc* getValFuncPtr = (GetValFunc*)palloc(sizeof(GetValFunc) * colTotalNum);
/* change sample rows pointer */
@ -3431,7 +3431,7 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
for (int col = 0; col < num_attnums; ++col) {
int colSeq = attrSeq[col] = colIdx[col] - 1;
InitGetValFunc(attrs[colSeq]->attlen, getValFuncPtr, colSeq);
InitGetValFunc(attrs[colSeq].attlen, getValFuncPtr, colSeq);
}
ADIO_RUN()
@ -3540,8 +3540,8 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
do { \
old_context = MemoryContextSwitchTo(sample_context); \
Datum dm = getValFuncPtr[colNum][funcIdx[colNum]](cuPtr[colNum], (offset)); \
int16 valueTyplen = attrs[(col_num)]->attlen; \
bool valueTypbyval = attrs[(col_num)]->attlen == 0 ? false : true; \
int16 valueTyplen = attrs[(col_num)].attlen; \
bool valueTypbyval = attrs[(col_num)].attlen == 0 ? false : true; \
if (valueTyplen < 0) \
(dest) = PointerGetDatum(PG_DETOAST_DATUM_COPY(dm)); \
else \
@ -3628,7 +3628,7 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
nullValues[colNum] = false;
old_context = MemoryContextSwitchTo(sample_context);
constValues[colNum] = CStore::CudescTupGetMinMaxDatum(&cuDesc, attrs[colNum], true, &shoulFree);
constValues[colNum] = CStore::CudescTupGetMinMaxDatum(&cuDesc, &attrs[colNum], true, &shoulFree);
(void)MemoryContextSwitchTo(old_context);
elog(DEBUG2,
"ANALYZE INFO - table \"%s\": attnum(%d), cuid(%u) is const value",
@ -3639,7 +3639,7 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
} else {
nullValues[colNum] = false;
constValues[colNum] = 0;
cuPtr[colNum] = cstore->GetCUData(&cuDesc, colNum, attrs[colNum]->attlen, slotIdList[col]);
cuPtr[colNum] = cstore->GetCUData(&cuDesc, colNum, attrs[colNum].attlen, slotIdList[col]);
funcIdx[colNum] = cuPtr[colNum]->HasNullValue() ? 1 : 0;
/* check vacuum delay each CU IO action. if it's enable to fetch cu data from cu cache, we should
* reduce the calling number AMAP. */
@ -3745,7 +3745,7 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
load_cu_data(0, num_attnums - 1, values, nulls, false);
tableam_tops_free_tuple(rows[location]);
rows[location] = (HeapTuple)tableam_tops_form_tuple(onerel->rd_att, values, nulls, HEAP_TUPLE);
rows[location] = (HeapTuple)tableam_tops_form_tuple(onerel->rd_att, values, nulls);
ItemPointerSet(&(rows[location])->t_self, targblock, targoffset + 1);
}
@ -3764,7 +3764,7 @@ static int64 AcquireSampleCStoreRows(Relation onerel, int elevel, HeapTuple* row
targoffset = lfirst_int(cell3);
tableam_tops_free_tuple(rows[location]);
rows[location] = (HeapTuple)tableam_tops_form_tuple(onerel->rd_att, st_cell->values, st_cell->nulls, HEAP_TUPLE);
rows[location] = (HeapTuple)tableam_tops_form_tuple(onerel->rd_att, st_cell->values, st_cell->nulls);
ItemPointerSet(&(rows[location])->t_self, targblock, targoffset + 1);
}
@ -3920,7 +3920,7 @@ static int64 AcquireSampleDfsStoreRows(Relation onerel, int elevel, HeapTuple* r
totalblocks = list_length(fileList);
/* create tuple slot for scanning */
scanTupleSlot = MakeTupleTableSlot(true, tupdesc->tdTableAmType);
scanTupleSlot = MakeTupleTableSlot(true, tupdesc->td_tam_ops);
scanTupleSlot->tts_tupleDescriptor = tupdesc;
scanTupleSlot->tts_values = columnValues;
scanTupleSlot->tts_isnull = columnNulls;
@ -3987,12 +3987,12 @@ static int64 AcquireSampleDfsStoreRows(Relation onerel, int elevel, HeapTuple* r
randomskip = (int)(skip_factor * anl_random_fract());
do {
dfs::reader::DFSGetNextTuple(scanState, scanTupleSlot);
} while (randomskip-- > 0 && !scanTupleSlot->tts_isempty);
} while (randomskip-- > 0 && !TTS_EMPTY(scanTupleSlot));
/*
* if there are no more records to read, break.
*/
if (scanTupleSlot->tts_isempty) {
if (TTS_EMPTY(scanTupleSlot)) {
(void)ExecClearTuple(scanTupleSlot);
break;
}
@ -4004,7 +4004,7 @@ static int64 AcquireSampleDfsStoreRows(Relation onerel, int elevel, HeapTuple* r
*/
if (numrows < targrows) {
rows[numrows++] = (HeapTuple)tableam_tops_form_tuple(tupdesc, columnValues, columnNulls, HEAP_TUPLE);
rows[numrows++] = (HeapTuple)tableam_tops_form_tuple(tupdesc, columnValues, columnNulls);
} else {
/*
@ -4025,7 +4025,7 @@ static int64 AcquireSampleDfsStoreRows(Relation onerel, int elevel, HeapTuple* r
rowIndex >= 0 && rowIndex < targrows, MOD_OPT, "index out of range when replacing tuple.");
tableam_tops_free_tuple(rows[rowIndex]);
rows[rowIndex] = (HeapTuple)tableam_tops_form_tuple(tupdesc, columnValues, columnNulls, HEAP_TUPLE);
rows[rowIndex] = (HeapTuple)tableam_tops_form_tuple(tupdesc, columnValues, columnNulls);
}
rowstoskip -= 1;
@ -4556,7 +4556,7 @@ static int64 acquirePartitionedSampleRows(Relation onerel, VacuumStmt* vacstmt,
Relation deltaRel = relation_open(partRel->rd_rel->reldeltarelid, AccessShareLock);
int16* colIdx = (int16*)palloc(sizeof(int16) * attrAnalyzeNum);
for (int i = 0; i < attrAnalyzeNum; ++i)
colIdx[i] = onerel->rd_att->attrs[vacattrstats[i]->tupattnum - 1]->attnum;
colIdx[i] = onerel->rd_att->attrs[vacattrstats[i]->tupattnum - 1].attnum;
CStoreScanDesc cstoreScanDesc = CStoreBeginScan(partRel, attrAnalyzeNum, colIdx, NULL, false);
@ -6583,7 +6583,7 @@ static void do_sampling_complex_by_secsample(Relation onerel, VacuumStmt* vacstm
* send the second sample rows num to cn,
* because cn will identify which rows belong dfs or delta from complex sample rows.
*/
tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, "DfsSecSampleRows", FLOAT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)2, "DeltaSecSampleRows", FLOAT8OID, -1, 0);
tstate = begin_tup_output_tupdesc(vacstmt->dest, tupdesc);
@ -6591,7 +6591,7 @@ static void do_sampling_complex_by_secsample(Relation onerel, VacuumStmt* vacstm
tstate->slot->tts_isnull[0] = false;
tstate->slot->tts_values[1] = pstDeltaSampleRows->secsamplerows;
tstate->slot->tts_isnull[1] = false;
tstate->slot->tts_tuple = (HeapTuple)tableam_tops_form_tuple(tupdesc, tstate->slot->tts_values, tstate->slot->tts_isnull, HEAP_TUPLE);
tstate->slot->tts_tuple = (HeapTuple)tableam_tops_form_tuple(tupdesc, tstate->slot->tts_values, tstate->slot->tts_isnull);
(vacstmt->dest->receiveSlot)(tstate->slot, vacstmt->dest);
/* Send sample rows to CN is end after delta table sampling the third times. */
@ -6717,8 +6717,8 @@ static bool equalTupleDescAttrsTypeid(TupleDesc tupdesc1, TupleDesc tupdesc2)
return false;
for (int i = 0; i < tupdesc1->natts; i++) {
Form_pg_attribute attr1 = tupdesc1->attrs[i];
Form_pg_attribute attr2 = tupdesc2->attrs[i];
Form_pg_attribute attr1 = &tupdesc1->attrs[i];
Form_pg_attribute attr2 = &tupdesc2->attrs[i];
if ((!attr1->attisdropped && !attr2->attisdropped) &&
((attr1->atttypid != attr2->atttypid) || (attr1->attlen != attr2->attlen)))
@ -7536,7 +7536,7 @@ static void spi_callback_get_sample_rows(void* clientData)
int dropped_num = 0;
for (int j = 0; j < spec->tupDesc->natts; j++) {
Form_pg_attribute attr1 = spec->tupDesc->attrs[j];
Form_pg_attribute attr1 = &spec->tupDesc->attrs[j];
if (attr1->attisdropped) {
nulls[j] = true;
@ -7547,7 +7547,7 @@ static void spi_callback_get_sample_rows(void* clientData)
}
AssertEreport(spec->tupDesc->natts == (SPI_tuptable->tupdesc->natts + dropped_num), MOD_OPT, "");
spec->samplerows[i] = (HeapTuple)tableam_tops_form_tuple(spec->tupDesc, values, nulls, HEAP_TUPLE);
spec->samplerows[i] = (HeapTuple)tableam_tops_form_tuple(spec->tupDesc, values, nulls);
}
}
@ -8047,7 +8047,7 @@ void dropSampleTable(const char* tableName)
static ArrayBuildState* spi_get_result_array(int attrno, MemoryContext memory_context)
{
ArrayBuildState* result = NULL;
Form_pg_attribute attribute = SPI_tuptable->tupdesc->attrs[attrno];
Form_pg_attribute attribute = &SPI_tuptable->tupdesc->attrs[attrno];
AssertEreport(attribute, MOD_OPT, "");
@ -8134,7 +8134,7 @@ static void spi_callback_get_singlerow(void* clientData)
} else {
AssertEreport(SPI_tuptable != NULL, MOD_OPT, "must have result"); /* must have result */
AssertEreport(SPI_processed == 1, MOD_OPT, "we expect only one tuple"); /* we expect only one tuple. */
AssertEreport(SPI_tuptable->tupdesc->attrs[0]->atttypid == INT8OID, MOD_OPT, "");
AssertEreport(SPI_tuptable->tupdesc->attrs[0].atttypid == INT8OID, MOD_OPT, "");
datum_f = tableam_tops_tuple_getattr(SPI_tuptable->vals[0], 1, SPI_tuptable->tupdesc, &isnull);
@ -8419,9 +8419,9 @@ static void analyze_compute_mcv(
* is the same with local attribute for analyzed or not.
*/
if (spec->stats->num_attrs == 1 && result.spi_tupDesc &&
(result.spi_tupDesc->attrs[0]->atttypid != spec->stats->attrs[0]->atttypid ||
result.spi_tupDesc->attrs[0]->atttypmod != spec->stats->attrs[0]->atttypmod ||
result.spi_tupDesc->attrs[0]->attlen != spec->stats->attrs[0]->attlen)) {
(result.spi_tupDesc->attrs[0].atttypid != spec->stats->attrs[0]->atttypid ||
result.spi_tupDesc->attrs[0].atttypmod != spec->stats->attrs[0]->atttypmod ||
result.spi_tupDesc->attrs[0].attlen != spec->stats->attrs[0]->attlen)) {
ereport(WARNING,
(errmsg("The tupleDesc analyzed on %s is different from tupleDesc which received from datanode "
"when computing mcv.",
@ -8429,7 +8429,7 @@ static void analyze_compute_mcv(
errdetail("Attribute \"%s\" of type %s does not match corresponding attribute of type %s.",
NameStr(spec->stats->attrs[0]->attname),
format_type_be(spec->stats->attrs[0]->atttypid),
format_type_be(result.spi_tupDesc->attrs[0]->atttypid))));
format_type_be(result.spi_tupDesc->attrs[0].atttypid))));
FreeTupleDesc(result.spi_tupDesc);
DEBUG_MOD_STOP_TIMER(MOD_AUTOVAC, "Compute MCV for table %s failed.", tableName);
@ -8536,7 +8536,7 @@ static void compute_histgram_internal(AnalyzeResultMultiColAsArraySpecInfo* spec
} \
} while (0)
get_typlenbyvalalign(tupDesc->attrs[VALUE_COLUMN - 1]->atttypid, &valueTyplen, &valueTypbyval, &valueTypalign);
get_typlenbyvalalign(tupDesc->attrs[VALUE_COLUMN - 1].atttypid, &valueTyplen, &valueTypbyval, &valueTypalign);
for (uint32 i = 0; i < SPI_processed; i++) {
vcount = tableam_tops_tuple_getattr(SPI_tuptable->vals[i], ROWCOUNT_COLUMN, tupDesc, &isnull);
@ -8719,13 +8719,13 @@ static void analyze_compute_histgram(int* slot_idx, const char* tableName, Analy
if (!CHAR_WIDTH_EXCEED_20(spec)) {
is_attr_diff =
result.spi_tupDesc && (result.spi_tupDesc->attrs[0]->atttypid != spec->stats->attrs[0]->atttypid ||
result.spi_tupDesc->attrs[0]->atttypmod != spec->stats->attrs[0]->atttypmod ||
result.spi_tupDesc->attrs[0]->attlen != spec->stats->attrs[0]->attlen);
result.spi_tupDesc && (result.spi_tupDesc->attrs[0].atttypid != spec->stats->attrs[0]->atttypid ||
result.spi_tupDesc->attrs[0].atttypmod != spec->stats->attrs[0]->atttypmod ||
result.spi_tupDesc->attrs[0].attlen != spec->stats->attrs[0]->attlen);
} else {
is_attr_diff = result.spi_tupDesc && (result.spi_tupDesc->attrs[0]->atttypid != TEXTOID ||
result.spi_tupDesc->attrs[0]->atttypmod != -1 ||
result.spi_tupDesc->attrs[0]->attlen != -1);
is_attr_diff = result.spi_tupDesc && (result.spi_tupDesc->attrs[0].atttypid != TEXTOID ||
result.spi_tupDesc->attrs[0].atttypmod != -1 ||
result.spi_tupDesc->attrs[0].attlen != -1);
}
/*
@ -8740,7 +8740,7 @@ static void analyze_compute_histgram(int* slot_idx, const char* tableName, Analy
errdetail("Attribute \"%s\" of type %s does not match corresponding attribute of type %s.",
NameStr(spec->stats->attrs[0]->attname),
format_type_be(spec->stats->attrs[0]->atttypid),
format_type_be(result.spi_tupDesc->attrs[0]->atttypid))));
format_type_be(result.spi_tupDesc->attrs[0].atttypid))));
FreeTupleDesc(result.spi_tupDesc);
return;

View File

@ -1356,7 +1356,7 @@ static void CopyPartialClusterKeyToNewRelation(Oid OIDNewHeap, TupleDesc tupleDe
/* get attribute name list for PCK */
for (pckCnt = 0; pckCnt < pckNum; ++pckCnt) {
AttrNumber attrNum = constr->clusterKeys[pckCnt];
Form_pg_attribute attribute = tupleDesc->attrs[attrNum - 1];
Form_pg_attribute attribute = &tupleDesc->attrs[attrNum - 1];
char* attrName = NameStr(attribute->attname);
pck->contype = CONSTR_CLUSTER;
@ -1689,7 +1689,7 @@ double CopyUHeapDataInternal(Relation oldHeap, Relation oldIndex, Relation newHe
values = (Datum *)palloc(natts * sizeof(Datum));
isnull = (bool *)palloc(natts * sizeof(bool));
slot = MakeSingleTupleTableSlot(oldTupDesc, false, oldTupDesc->tdTableAmType);
slot = MakeSingleTupleTableSlot(oldTupDesc, false, oldTupDesc->td_tam_ops);
/* Initialize the rewrite operation */
rwstate = begin_heap_rewrite(oldHeap, newHeap, oldestXmin, freezeXid, useWal);
@ -2339,7 +2339,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");
}
@ -3591,7 +3591,7 @@ static void reform_and_rewrite_tuple(HeapTuple tuple, TupleDesc oldTupDesc, Tupl
/* Be sure to null out any dropped columns */
for (i = 0; i < newTupDesc->natts; i++) {
if (newTupDesc->attrs[i]->attisdropped)
if (newTupDesc->attrs[i].attisdropped)
isnull[i] = true;
}
@ -3733,7 +3733,7 @@ ReformAndRewriteUTuple(UHeapTuple tuple,
/* Be sure to null out any dropped columns */
for (i = 0; i < newTupDesc->natts; i++)
{
if (newTupDesc->attrs[i]->attisdropped)
if (newTupDesc->attrs[i].attisdropped)
isnull[i] = true;
}
@ -3741,7 +3741,7 @@ ReformAndRewriteUTuple(UHeapTuple tuple,
if (usePrivateMemcxt)
oldMemCxt = MemoryContextSwitchTo(get_heap_rewrite_memcxt(rwstate));
copiedTuple = tableam_tops_form_tuple(newTupDesc, values, isnull, UHEAP_TUPLE);
copiedTuple = tableam_tops_form_tuple(newTupDesc, values, isnull, TableAmUstore);
{
RewriteUHeapTuple(rwstate, tuple, (UHeapTuple)copiedTuple);
@ -4251,7 +4251,7 @@ static void CopyCStoreData(Relation oldRel, Relation newRel, int freeze_min_age,
static void filter_batch(const TupleDesc oldTupDesc, const VectorBatch* pbatch)
{
for (int i = 0; i < oldTupDesc->natts; i++) {
if (!oldTupDesc->attrs[i]->attisdropped) {
if (!oldTupDesc->attrs[i].attisdropped) {
continue;
}
@ -4273,7 +4273,7 @@ static void DoCopyCUFormatData(Relation oldRel, Relation newRel, TupleDesc oldTu
CStoreInsert* cstoreOpt = NULL;
CStoreScanDesc scan = NULL;
int16* colIdx = NULL;
Form_pg_attribute* oldAttrs = NULL;
FormData_pg_attribute* oldAttrs = NULL;
MemInfoArg memInfo;
// Init CStore insertion.
@ -4292,7 +4292,7 @@ static void DoCopyCUFormatData(Relation oldRel, Relation newRel, TupleDesc oldTu
colIdx = (int16*)palloc0(sizeof(int16) * oldTupDesc->natts);
oldAttrs = oldTupDesc->attrs;
for (int i = 0; i < oldTupDesc->natts; i++)
colIdx[i] = oldAttrs[i]->attnum;
colIdx[i] = oldAttrs[i].attnum;
scan = CStoreBeginScan(oldRel, oldTupDesc->natts, colIdx, SnapshotNow, true);
/*
@ -4819,9 +4819,9 @@ void HbktTransferDeletePgAttributeTablebucketid(Oid relid, bool cboffIndex)
Relation rel1 = relation_open(relid, NoLock);
for (i = 0; i < rel1->rd_att->natts; i++) {
char *attr_name = pstrdup(NameStr(rel1->rd_att->attrs[i]->attname));
char *attr_name = pstrdup(NameStr(rel1->rd_att->attrs[i].attname));
if (strcmp(attr_name, "tablebucketid") == 0) {
attrnum = rel1->rd_att->attrs[i]->attnum;
attrnum = rel1->rd_att->attrs[i].attnum;
break;
}
}

View File

@ -352,7 +352,7 @@ static void SendCopyBegin(CopyState cstate)
pq_sendint16(&buf, natts);
TupleDesc tupDesc;
Form_pg_attribute *attr = NULL;
FormData_pg_attribute *attr = NULL;
ListCell *cur = NULL;
if (cstate->rel)
tupDesc = RelationGetDescr(cstate->rel);
@ -363,9 +363,9 @@ static void SendCopyBegin(CopyState cstate)
{
int16 fmt = format;
int attnum = lfirst_int(cur);
if (attr[attnum - 1]->atttypid == BYTEAWITHOUTORDERWITHEQUALCOLOID ||
attr[attnum - 1]->atttypid == BYTEAWITHOUTORDERCOLOID)
fmt = (int16)attr[attnum - 1]->atttypmod;
if (attr[attnum - 1].atttypid == BYTEAWITHOUTORDERWITHEQUALCOLOID ||
attr[attnum - 1].atttypid == BYTEAWITHOUTORDERCOLOID)
fmt = (int16)attr[attnum - 1].atttypmod;
pq_sendint16(&buf, fmt); /* per-column formats */
}
pq_endmessage(&buf);
@ -1200,7 +1200,7 @@ void VerifyEncoding(int encoding)
static void PrintDelimHeader(CopyState cstate)
{
TupleDesc tupDesc;
Form_pg_attribute* attr = NULL;
FormData_pg_attribute* attr = NULL;
ListCell* cur = NULL;
bool hdr_delim = false;
char* colname = NULL;
@ -1217,7 +1217,7 @@ static void PrintDelimHeader(CopyState cstate)
if (hdr_delim)
CopySendString(cstate, cstate->delim);
hdr_delim = true;
colname = NameStr(attr[attnum - 1]->attname);
colname = NameStr(attr[attnum - 1].attname);
CopyAttributeOutCSV(cstate, colname, false, list_length(cstate->attnumlist) == 1);
}
}
@ -1931,14 +1931,14 @@ static void TransformColExpr(CopyState cstate)
#endif
attroid = attnumTypeId(cstate->rel, attrno);
attrmod = cstate->rel->rd_att->attrs[attrno - 1]->atttypmod;
attrmod = cstate->rel->rd_att->attrs[attrno - 1].atttypmod;
if (col->typname != NULL) {
SetColInFunction(cstate, attrno, col->typname);
/* Build a ColumnRef in order to transform datatype */
if (col->colexpr == NULL &&
(attroid != cstate->trans_tupledesc->attrs[attrno - 1]->atttypid
(attroid != cstate->trans_tupledesc->attrs[attrno - 1].atttypid
|| attrmod != cstate->as_typemods[attrno - 1].typemod)) {
ColumnRef *cref = makeNode(ColumnRef);
@ -1985,13 +1985,13 @@ static void SetColInFunction(CopyState cstate, int attrno, const TypeName* type)
cstate->as_typemods[attrno - 1].assign = true;
cstate->as_typemods[attrno - 1].typemod = attrmod;
if (cstate->trans_tupledesc->attrs[attrno - 1]->atttypid != attroid) {
cstate->trans_tupledesc->attrs[attrno - 1]->atttypid = attroid;
cstate->trans_tupledesc->attrs[attrno - 1]->atttypmod = attrmod;
cstate->trans_tupledesc->attrs[attrno - 1]->attalign = ((Form_pg_type)GETSTRUCT(tup))->typalign;
cstate->trans_tupledesc->attrs[attrno - 1]->attlen = ((Form_pg_type)GETSTRUCT(tup))->typlen;
cstate->trans_tupledesc->attrs[attrno - 1]->attbyval = ((Form_pg_type)GETSTRUCT(tup))->typbyval;
cstate->trans_tupledesc->attrs[attrno - 1]->attstorage = ((Form_pg_type)GETSTRUCT(tup))->typstorage;
if (cstate->trans_tupledesc->attrs[attrno - 1].atttypid != attroid) {
cstate->trans_tupledesc->attrs[attrno - 1].atttypid = attroid;
cstate->trans_tupledesc->attrs[attrno - 1].atttypmod = attrmod;
cstate->trans_tupledesc->attrs[attrno - 1].attalign = ((Form_pg_type)GETSTRUCT(tup))->typalign;
cstate->trans_tupledesc->attrs[attrno - 1].attlen = ((Form_pg_type)GETSTRUCT(tup))->typlen;
cstate->trans_tupledesc->attrs[attrno - 1].attbyval = ((Form_pg_type)GETSTRUCT(tup))->typbyval;
cstate->trans_tupledesc->attrs[attrno - 1].attstorage = ((Form_pg_type)GETSTRUCT(tup))->typstorage;
}
ReleaseSysCache(tup);
@ -2027,9 +2027,9 @@ static ExprState* ExecInitCopyColExpr(CopyState cstate, int attrno, Oid attroid,
Var* value;
if (i == attrno - 1)
attr = cstate->trans_tupledesc->attrs[i];
attr = &cstate->trans_tupledesc->attrs[i];
else
attr = cstate->rel->rd_att->attrs[i];
attr = &cstate->rel->rd_att->attrs[i];
value = makeVar(0, i + 1, attr->atttypid, attr->atttypmod, attr->attcollation, 0);
@ -2090,14 +2090,14 @@ static void ProcessCopyNotAllowedOptions(CopyState cstate)
/*
* ProcessCopyErrorLogSetUps is used to set up necessary structures used for copy from error logging.
*/
static bool CheckCopyErrorTableDef(int nattrs, Form_pg_attribute* attr)
static bool CheckCopyErrorTableDef(int nattrs, FormData_pg_attribute* attr)
{
if (nattrs != COPY_ERROR_TABLE_NUM_COL) {
return false;
}
for (int attnum = 0; attnum < nattrs; attnum++) {
if (attr[attnum]->atttypid != copy_error_table_col_typid[attnum])
if (attr[attnum].atttypid != copy_error_table_col_typid[attnum])
return false;
}
return true;
@ -2146,7 +2146,7 @@ static void ProcessCopyErrorLogSetUps(CopyState cstate)
/* err_out_functions used when reading error info from cache files. */
int natts = RelationGetNumberOfAttributes(cstate->err_table);
TupleDesc tupDesc = RelationGetDescr(cstate->err_table);
Form_pg_attribute* attr = tupDesc->attrs;
FormData_pg_attribute* attr = tupDesc->attrs;
cstate->err_out_functions = (FmgrInfo*)palloc(natts * sizeof(FmgrInfo));
if (!CheckCopyErrorTableDef(natts, attr)) {
@ -2163,7 +2163,7 @@ static void ProcessCopyErrorLogSetUps(CopyState cstate)
Oid out_func_oid;
bool isvarlena = false;
getTypeOutputInfo(attr[attnum]->atttypid, &out_func_oid, &isvarlena);
getTypeOutputInfo(attr[attnum].atttypid, &out_func_oid, &isvarlena);
fmgr_info(out_func_oid, &cstate->err_out_functions[attnum]);
}
}
@ -2171,14 +2171,14 @@ static void ProcessCopyErrorLogSetUps(CopyState cstate)
/*
* ProcessCopySummaryLogSetUps is used to set up necessary structures used for copy from summary logging.
*/
static bool CheckCopySummaryTableDef(int nattrs, Form_pg_attribute *attr)
static bool CheckCopySummaryTableDef(int nattrs, FormData_pg_attribute *attr)
{
if (nattrs != COPY_SUMMARY_TABLE_NUM_COL) {
return false;
}
for (int attnum = 0; attnum < nattrs; attnum++) {
if (attr[attnum]->atttypid != copy_summary_table_col_typid[attnum])
if (attr[attnum].atttypid != copy_summary_table_col_typid[attnum])
return false;
}
return true;
@ -2210,7 +2210,7 @@ static void ProcessCopySummaryLogSetUps(CopyState cstate)
cstate->summary_table = relation_open(summary_table_reloid, RowExclusiveLock);
int natts = RelationGetNumberOfAttributes(cstate->summary_table);
TupleDesc tupDesc = RelationGetDescr(cstate->summary_table);
Form_pg_attribute *attr = tupDesc->attrs;
FormData_pg_attribute *attr = tupDesc->attrs;
if (!CheckCopySummaryTableDef(natts, attr)) {
ereport(ERROR,
@ -2312,14 +2312,8 @@ static CopyState BeginCopy(bool is_from, Relation rel, Node* raw_query, const ch
/*
* Run parse analysis and rewrite. Note this also acquires sufficient
* locks on the source table(s).
*
* Because the parser and planner tend to scribble on their input, we
* make a preliminary copy of the source querytree. This prevents
* problems in the case that the COPY is in a portal or plpgsql
* function and is executed repeatedly. (See also the same hack in
* DECLARE CURSOR and PREPARE.)
*/
rewritten = pg_analyze_and_rewrite((Node*)copyObject(raw_query), queryString, NULL, 0);
rewritten = pg_analyze_and_rewrite(raw_query, queryString, NULL, 0);
/* We don't expect more or less than one result query */
if (list_length(rewritten) != 1)
@ -2406,7 +2400,7 @@ static CopyState BeginCopy(bool is_from, Relation rel, Node* raw_query, const ch
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE QUOTE column \"%s\" not referenced by COPY",
NameStr(tupDesc->attrs[attnum - 1]->attname))));
NameStr(tupDesc->attrs[attnum - 1].attname))));
cstate->force_quote_flags[attnum - 1] = true;
}
}
@ -2426,7 +2420,7 @@ static CopyState BeginCopy(bool is_from, Relation rel, Node* raw_query, const ch
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("FORCE NOT NULL column \"%s\" not referenced by COPY",
NameStr(tupDesc->attrs[attnum - 1]->attname))));
NameStr(tupDesc->attrs[attnum - 1].attname))));
cstate->force_notnull_flags[attnum - 1] = true;
}
}
@ -2438,7 +2432,7 @@ static CopyState BeginCopy(bool is_from, Relation rel, Node* raw_query, const ch
/* find last valid column */
int i = num_phys_attrs - 1;
for (; i >= 0; i--) {
if (!tupDesc->attrs[i]->attisdropped)
if (!tupDesc->attrs[i].attisdropped)
break;
}
@ -2446,7 +2440,7 @@ static CopyState BeginCopy(bool is_from, Relation rel, Node* raw_query, const ch
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("fill_missing_fields can't be set while \"%s\" is NOT NULL",
NameStr(tupDesc->attrs[i]->attname))));
NameStr(tupDesc->attrs[i].attname))));
}
/* Use client encoding when ENCODING option is not specified. */
@ -2730,7 +2724,7 @@ static void DeformCopyTuple(
MemoryContext perBatchMcxt, CopyState cstate, VectorBatch* batch, TupleDesc tupDesc, Datum* values, bool* nulls)
{
errno_t rc = EOK;
Form_pg_attribute* attrs = tupDesc->attrs;
FormData_pg_attribute* attrs = tupDesc->attrs;
// deform values from vectorbatch.
for (int nrow = 0; nrow < batch->m_rows; nrow++) {
@ -2739,7 +2733,7 @@ static void DeformCopyTuple(
for (int ncol = 0; ncol < batch->m_cols; ncol++) {
/* If the column is dropped, skip deform values from vectorbatch */
if (attrs[ncol]->attisdropped) {
if (attrs[ncol].attisdropped) {
continue;
}
ScalarVector* pVec = &(batch->m_arr[ncol]);
@ -2754,12 +2748,12 @@ static void DeformCopyTuple(
Datum val = ScalarVector::Decode(pVal[nrow]);
MemoryContext oldmcxt = MemoryContextSwitchTo(perBatchMcxt);
if (attrs[ncol]->attlen > 8) {
if (attrs[ncol].attlen > 8) {
char* result = NULL;
result = (char*)val + VARHDRSZ_SHORT;
values[ncol] = datumCopy(PointerGetDatum(result), attrs[ncol]->attbyval, attrs[ncol]->attlen);
values[ncol] = datumCopy(PointerGetDatum(result), attrs[ncol].attbyval, attrs[ncol].attlen);
} else
values[ncol] = datumCopy(val, attrs[ncol]->attbyval, attrs[ncol]->attlen);
values[ncol] = datumCopy(val, attrs[ncol].attbyval, attrs[ncol].attlen);
MemoryContextSwitchTo(oldmcxt);
} else
@ -2842,7 +2836,7 @@ static uint64 CStoreCopyTo(CopyState cstate, TupleDesc tupDesc, Datum* values, b
CStoreScanDesc scandesc;
VectorBatch* batch = NULL;
int16* colIdx = (int16*)palloc0(sizeof(int16) * tupDesc->natts);
Form_pg_attribute* attrs = tupDesc->attrs;
FormData_pg_attribute* attrs = tupDesc->attrs;
MemoryContext perBatchMcxt = AllocSetContextCreate(CurrentMemoryContext,
"COPY TO PER BATCH",
ALLOCSET_DEFAULT_MINSIZE,
@ -2851,7 +2845,7 @@ static uint64 CStoreCopyTo(CopyState cstate, TupleDesc tupDesc, Datum* values, b
uint64 processed = 0;
for (int i = 0; i < tupDesc->natts; i++)
colIdx[i] = attrs[i]->attnum;
colIdx[i] = attrs[i].attnum;
scandesc = CStoreBeginScan(cstate->curPartionRel, tupDesc->natts, colIdx, GetActiveSnapshot(), true);
@ -2875,7 +2869,7 @@ static uint64 CopyTo(CopyState cstate, bool isFirst, bool isLast)
{
TupleDesc tupDesc;
int num_phys_attrs;
Form_pg_attribute* attr = NULL;
FormData_pg_attribute* attr = NULL;
ListCell* cur = NULL;
uint64 processed;
@ -2907,9 +2901,9 @@ static uint64 CopyTo(CopyState cstate, bool isFirst, bool isLast)
bool isvarlena = false;
if (IS_BINARY(cstate))
getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena);
getTypeBinaryOutputInfo(attr[attnum - 1].atttypid, &out_func_oid, &isvarlena);
else
getTypeOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena);
getTypeOutputInfo(attr[attnum - 1].atttypid, &out_func_oid, &isvarlena);
fmgr_info(out_func_oid, &cstate->out_functions[attnum - 1]);
}
@ -3719,7 +3713,7 @@ static void CStoreCopyConstraintsCheck(ResultRelInfo* resultRelInfo, Datum* valu
int attrChk;
for (attrChk = 1; attrChk <= natts; attrChk++) {
if (rel->rd_att->attrs[attrChk - 1]->attnotnull && nulls[attrChk - 1]) {
if (rel->rd_att->attrs[attrChk - 1].attnotnull && nulls[attrChk - 1]) {
HeapTuple tuple = heap_form_tuple(tupDesc, values, nulls);
TupleTableSlot* slot = ExecInitExtraTupleSlot(estate);
Bitmapset* modifiedCols = NULL;
@ -3737,7 +3731,7 @@ static void CStoreCopyConstraintsCheck(ResultRelInfo* resultRelInfo, Datum* valu
ereport(ERROR,
(errcode(ERRCODE_NOT_NULL_VIOLATION),
errmsg("null value in column \"%s\" violates not-null constraint",
NameStr(tupDesc->attrs[attrChk - 1]->attname)),
NameStr(tupDesc->attrs[attrChk - 1].attname)),
val_desc ? errdetail("Failing row contains %s.", val_desc) : 0));
}
}
@ -4031,7 +4025,7 @@ static uint64 CopyFrom(CopyState cstate)
estate->es_range_table = cstate->range_table;
/* Set up a tuple slot too */
myslot = ExecInitExtraTupleSlot(estate, 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);
@ -4494,7 +4488,7 @@ static uint64 CopyFrom(CopyState cstate)
* are to be inserted, append them onto the data row.
*/
if (IS_PGXC_COORDINATOR && cstate->remoteCopyState && cstate->remoteCopyState->rel_loc) {
Form_pg_attribute* attr = tupDesc->attrs;
FormData_pg_attribute* attr = tupDesc->attrs;
Oid* att_type = NULL;
RemoteCopyData* remoteCopyState = cstate->remoteCopyState;
ExecNodes* exec_nodes = NULL;
@ -4515,16 +4509,16 @@ static uint64 CopyFrom(CopyState cstate)
TsRelWithImplDistColumn(attr, dcolNum)) {
pseudoTsDistcol = true;
for (int i = 0; i < tupDesc->natts; i++) {
att_type[i] = attr[i]->atttypid;
att_type[i] = attr[i].atttypid;
/* collect all the tag columns info to taglist */
if (attr[i]->attkvtype == ATT_KV_TAG) {
if (attr[i].attkvtype == ATT_KV_TAG) {
taglist = lappend_int(taglist, i);
}
}
Assert(taglist != NULL);
} else {
for (int i = 0; i < tupDesc->natts; i++) {
att_type[i] = attr[i]->atttypid;
att_type[i] = attr[i].atttypid;
}
}
}
@ -4573,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, tableam_tops_get_tuple_type(cstate->rel));
tuple = (Tuple)tableam_tops_form_tuple(tupDesc, values, nulls, cstate->rel->rd_tam_ops);
if (loaded_oid != InvalidOid)
HeapTupleSetOid((HeapTuple)tuple, loaded_oid);
@ -4745,7 +4739,7 @@ static uint64 CopyFrom(CopyState cstate)
* Global Partition Index stores the partition's tableOid with the index
* tuple which is extracted from the tuple of the slot. Make sure it is set.
*/
if (slot->tts_tupslotTableAm != TAM_USTORE) {
if (!TTS_TABLEAM_IS_USTORE(slot)) {
((HeapTuple)slot->tts_tuple)->t_tableOid = RelationGetRelid(targetRel);
} else {
((UHeapTuple)slot->tts_tuple)->table_oid = RelationGetRelid(targetRel);
@ -5281,7 +5275,7 @@ void UHeapCopyFromInsertBatch(Relation rel, EState* estate, CommandId mycid, int
* Global Partition Index stores the partition's tableOid with the index
* tuple which is extracted from the tuple of the slot. Make sure it is set.
*/
if (myslot->tts_tupslotTableAm != TAM_USTORE) {
if (!TTS_TABLEAM_IS_USTORE(myslot)) {
((HeapTuple)myslot->tts_tuple)->t_tableOid = RelationGetRelid(rel);
} else {
((UHeapTuple)myslot->tts_tuple)->table_oid = RelationGetRelid(rel);
@ -5572,7 +5566,7 @@ CopyState BeginCopyFrom(Relation rel, const char* filename, List* attnamelist,
CopyState cstate;
bool pipe = (filename == NULL);
TupleDesc tupDesc;
Form_pg_attribute* attr = NULL;
FormData_pg_attribute* attr = NULL;
AttrNumber num_phys_attrs, num_defaults;
FmgrInfo* in_functions = NULL;
Oid* typioparams = NULL;
@ -5635,15 +5629,15 @@ CopyState BeginCopyFrom(Relation rel, const char* filename, List* attnamelist,
for (attnum = 1; attnum <= num_phys_attrs; attnum++) {
/* We don't need info for dropped attributes */
if (attr[attnum - 1]->attisdropped)
if (attr[attnum - 1].attisdropped)
continue;
accept_empty_str[attnum - 1] = IsTypeAcceptEmptyStr(attr[attnum - 1]->atttypid);
accept_empty_str[attnum - 1] = IsTypeAcceptEmptyStr(attr[attnum - 1].atttypid);
/* Fetch the input function and typioparam info */
if (IS_BINARY(cstate))
getTypeBinaryInputInfo(attr[attnum - 1]->atttypid, &in_func_oid, &typioparams[attnum - 1]);
getTypeBinaryInputInfo(attr[attnum - 1].atttypid, &in_func_oid, &typioparams[attnum - 1]);
else
getTypeInputInfo(attr[attnum - 1]->atttypid, &in_func_oid, &typioparams[attnum - 1]);
getTypeInputInfo(attr[attnum - 1].atttypid, &in_func_oid, &typioparams[attnum - 1]);
fmgr_info(in_func_oid, &in_functions[attnum - 1]);
/* Get default info if needed */
@ -5675,9 +5669,9 @@ CopyState BeginCopyFrom(Relation rel, const char* filename, List* attnamelist,
* values into output form before appending to data row.
*/
if (IS_BINARY(cstate))
getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena);
getTypeBinaryOutputInfo(attr[attnum - 1].atttypid, &out_func_oid, &isvarlena);
else
getTypeOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena);
getTypeOutputInfo(attr[attnum - 1].atttypid, &out_func_oid, &isvarlena);
fmgr_info(out_func_oid, &cstate->out_functions[attnum - 1]);
}
} else {
@ -5930,7 +5924,7 @@ static void ReportIllegalCharError(IllegalCharErrInfo* err_info)
* @in field_strings: each parsed field string
* @return: void
*/
static void BulkloadIllegalCharsErrorCheck(CopyState cstate, Form_pg_attribute* attr, char** field_strings)
static void BulkloadIllegalCharsErrorCheck(CopyState cstate, FormData_pg_attribute* attr, char** field_strings)
{
ListCell* cur = NULL;
ListCell* attr_cur = NULL;
@ -5958,7 +5952,7 @@ static void BulkloadIllegalCharsErrorCheck(CopyState cstate, Form_pg_attribute*
/*
* for non-char type attribute illegal chars error still be thrown.
*/
if (!IsCharType(attr[m]->atttypid)) {
if (!IsCharType(attr[m].atttypid)) {
/*
* reflush illegal chars error list for the next parsed line.
* no need extra pfree and depends on memory context reset.
@ -6092,7 +6086,7 @@ Datum InputFunctionCallForBulkload(CopyState cstate, FmgrInfo* flinfo, char* str
bool NextCopyFrom(CopyState cstate, ExprContext* econtext, Datum* values, bool* nulls, Oid* tupleOid)
{
TupleDesc tupDesc;
Form_pg_attribute* attr = NULL;
FormData_pg_attribute* attr = NULL;
AttrNumber num_phys_attrs;
AttrNumber attr_count;
AttrNumber num_defaults = cstate->num_defaults;
@ -6225,7 +6219,7 @@ bool NextCopyFrom(CopyState cstate, ExprContext* econtext, Datum* values, bool*
if (cstate->fill_missing_fields != -1){
if (fieldno > fldct || (!cstate->fill_missing_fields && fieldno == fldct))
ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
errmsg("missing data for column \"%s\"", NameStr(attr[m]->attname))));
errmsg("missing data for column \"%s\"", NameStr(attr[m].attname))));
}
if (fieldno < fldct) {
@ -6250,9 +6244,9 @@ bool NextCopyFrom(CopyState cstate, ExprContext* econtext, Datum* values, bool*
string = cstate->null_print;
}
cstate->cur_attname = NameStr(attr[m]->attname);
cstate->cur_attname = NameStr(attr[m].attname);
cstate->cur_attval = string;
atttypmod = (asTypemods != NULL && asTypemods[m].assign) ? asTypemods[m].typemod : attr[m]->atttypmod;
atttypmod = (asTypemods != NULL && asTypemods[m].assign) ? asTypemods[m].typemod : attr[m].atttypmod;
values[m] =
InputFunctionCallForBulkload(cstate, &in_functions[m], string, typioparams[m], atttypmod);
if (string != NULL)
@ -6359,9 +6353,9 @@ bool NextCopyFrom(CopyState cstate, ExprContext* econtext, Datum* values, bool*
/* Skip the hidden distribute column */
if (pseudoTsDistcol && m == tgt_col_num) continue;
cstate->cur_attname = NameStr(attr[m]->attname);
cstate->cur_attname = NameStr(attr[m].attname);
i++;
atttypmod = (asTypemods != NULL && asTypemods[m].assign) ? asTypemods[m].typemod : attr[m]->atttypmod;
atttypmod = (asTypemods != NULL && asTypemods[m].assign) ? asTypemods[m].typemod : attr[m].atttypmod;
values[m] =
CopyReadBinaryAttribute(cstate, i, &in_functions[m], typioparams[m], atttypmod, &nulls[m]);
cstate->cur_attname = NULL;
@ -8020,12 +8014,12 @@ static void CopyAttributeOutCSV(CopyState cstate, char* string, bool use_quote,
List* CopyGetAllAttnums(TupleDesc tupDesc, Relation rel)
{
List* attnums = NIL;
Form_pg_attribute* attr = tupDesc->attrs;
FormData_pg_attribute* attr = tupDesc->attrs;
int attr_count = tupDesc->natts;
int i;
for (i = 0; i < attr_count; i++) {
if (attr[i]->attisdropped)
if (attr[i].attisdropped)
continue;
attnums = lappend_int(attnums, i + 1);
}
@ -8053,12 +8047,12 @@ List* CopyGetAttnums(TupleDesc tupDesc, Relation rel, List* attnamelist)
if (attnamelist == NIL) {
/* Generate default column list */
Form_pg_attribute *attr = tupDesc->attrs;
FormData_pg_attribute *attr = tupDesc->attrs;
int attr_count = tupDesc->natts;
int i;
for (i = 0; i < attr_count; i++) {
if (attr[i]->attisdropped)
if (attr[i].attisdropped)
continue;
if (ISGENERATEDCOL(tupDesc, i))
continue;
@ -8076,15 +8070,15 @@ List* CopyGetAttnums(TupleDesc tupDesc, Relation rel, List* attnamelist)
/* Lookup column name */
attnum = InvalidAttrNumber;
for (i = 0; i < tupDesc->natts; i++) {
if (tupDesc->attrs[i]->attisdropped)
if (tupDesc->attrs[i].attisdropped)
continue;
if (namestrcmp(&(tupDesc->attrs[i]->attname), name) == 0) {
if (namestrcmp(&(tupDesc->attrs[i].attname), name) == 0) {
if (ISGENERATEDCOL(tupDesc, i)) {
ereport(ERROR, (errmodule(MOD_GEN_COL), errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("column \"%s\" is a generated column", name),
errdetail("Generated columns cannot be used in COPY.")));
}
attnum = tupDesc->attrs[i]->attnum;
attnum = tupDesc->attrs[i].attnum;
break;
}
}
@ -8118,10 +8112,10 @@ void SetFixedAlignment(TupleDesc tupDesc, Relation rel, FixFormatter* formatter,
// Validate the user-supplied list
//
for (int j = 0; j < tupDesc->natts; j++) {
if (tupDesc->attrs[j]->attisdropped)
if (tupDesc->attrs[j].attisdropped)
continue;
if (namestrcmp(&(tupDesc->attrs[j]->attname), name) == 0) {
attr = tupDesc->attrs[j];
if (namestrcmp(&(tupDesc->attrs[j].attname), name) == 0) {
attr = &tupDesc->attrs[j];
break;
}
}
@ -9298,7 +9292,7 @@ CopyState beginExport(
Assert(cstate->rel);
TupleDesc tupDesc = RelationGetDescr(cstate->rel);
Form_pg_attribute* attr = tupDesc->attrs;
FormData_pg_attribute* attr = tupDesc->attrs;
int num_phys_attrs = tupDesc->natts;
cstate->curPartionRel = cstate->rel;
@ -9360,9 +9354,9 @@ CopyState beginExport(
bool isvarlena = false;
if (IS_BINARY(cstate))
getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena);
getTypeBinaryOutputInfo(attr[attnum - 1].atttypid, &out_func_oid, &isvarlena);
else
getTypeOutputInfo(attr[attnum - 1]->atttypid, &out_func_oid, &isvarlena);
getTypeOutputInfo(attr[attnum - 1].atttypid, &out_func_oid, &isvarlena);
fmgr_info(out_func_oid, &cstate->out_functions[attnum - 1]);
}
@ -10069,10 +10063,10 @@ static void CopyGetWhenExprAttFieldno(CopyState cstate, LoadWhenExpr *when, List
}
tupDesc = RelationGetDescr(cstate->rel);
for (int i = 0; i < tupDesc->natts; i++) {
if (tupDesc->attrs[i]->attisdropped)
if (tupDesc->attrs[i].attisdropped)
continue;
if (namestrcmp(&(tupDesc->attrs[i]->attname), when->attname) == 0) {
when->attnum = tupDesc->attrs[i]->attnum; /* based 1 */
if (namestrcmp(&(tupDesc->attrs[i].attname), when->attname) == 0) {
when->attnum = tupDesc->attrs[i].attnum; /* based 1 */
return;
}
}
@ -10183,10 +10177,10 @@ static int CopyGetColumnListIndex(CopyState cstate, List *attnamelist, const cha
}
tupDesc = RelationGetDescr(cstate->rel);
for (int i = 0; i < tupDesc->natts; i++) {
if (tupDesc->attrs[i]->attisdropped)
if (tupDesc->attrs[i].attisdropped)
continue;
if (namestrcmp(&(tupDesc->attrs[i]->attname), colname) == 0) {
return tupDesc->attrs[i]->attnum; /* based 1 */
if (namestrcmp(&(tupDesc->attrs[i].attname), colname) == 0) {
return tupDesc->attrs[i].attnum; /* based 1 */
}
}
ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("Column name %s not find", colname)));

View File

@ -86,13 +86,8 @@ SetupForCreateTableAs(Query *query, IntoClause *into, const char *queryString,
* rewriter. We do not do AcquireRewriteLocks: we assume the query either
* came straight from the parser, or suitable locks were acquired by
* plancache.c.
*
* Because the rewriter and planner tend to scribble on the input, we make
* a preliminary copy of the source querytree. This prevents problems in
* the case that CTAS is in a portal or plpgsql function and is executed
* repeatedly. (See also the same hack in EXPLAIN and PREPARE.)
*/
rewritten = QueryRewrite((Query *) copyObject(query));
rewritten = QueryRewrite(query);
/* SELECT should never rewrite to more or less than one SELECT query */
if (list_length(rewritten) != 1) {
@ -338,7 +333,7 @@ static void intorel_startup(DestReceiver* self, int operation, TupleDesc typeinf
*/
lc = list_head(into->colNames);
for (attnum = 0; attnum < typeinfo->natts; attnum++) {
Form_pg_attribute attribute = typeinfo->attrs[attnum];
Form_pg_attribute attribute = &typeinfo->attrs[attnum];
ColumnDef* col = makeNode(ColumnDef);
TypeName* coltype = makeNode(TypeName);

View File

@ -434,15 +434,9 @@ void ExplainQuery(
* rewriter. We do not do AcquireRewriteLocks: we assume the query either
* came straight from the parser, or suitable locks were acquired by
* plancache.c.
*
* Because the rewriter and planner tend to scribble on the input, we make
* a preliminary copy of the source querytree. This prevents problems in
* the case that the EXPLAIN is in a portal or plpgsql function and is
* executed repeatedly. (See also the same hack in DECLARE CURSOR and
* PREPARE.)
*/
AssertEreport(IsA(stmt->query, Query), MOD_EXECUTOR, "unexpect query type");
rewritten = QueryRewrite((Query*)copyObject(stmt->query));
rewritten = QueryRewrite(castNode(Query, stmt->query));
/* emit opening boilerplate */
ExplainBeginOutput(&es);
@ -607,7 +601,7 @@ TupleDesc ExplainResultDesc(ExplainStmt* stmt)
if (!explain_plan) {
/* Need a tuple descriptor representing a single TEXT or XML column */
tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(1, false);
/* If current plan is set as random plan, explain desc should show random seed value */
if (u_sess->attr.attr_sql.plan_mode_seed != OPTIMIZE_PLAN) {
@ -9934,7 +9928,7 @@ TupleDesc PlanTable::getTupleDesc()
attnum = attnum - 1;
}
tupdesc = CreateTemplateTupleDesc(attnum, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(attnum, false);
for (int i = 0; i < SLOT_NUMBER; i++) {
bool add_slot = false;
@ -9978,7 +9972,7 @@ TupleDesc PlanTable::getTupleDesc_detail()
int attnum = EXPLAIN_TOTAL_ATTNUM;
int i = 1;
tupdesc = CreateTemplateTupleDesc(attnum, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(attnum, false);
TupleDescInitEntry(tupdesc, (AttrNumber)i++, "query id", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber)i++, "plan parent node id", INT4OID, -1, 0);
@ -10060,7 +10054,7 @@ TupleDesc PlanTable::getTupleDesc(const char* attname)
{
TupleDesc tupdesc;
tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP);
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber)1, attname, TEXTOID, -1, 0);
return tupdesc;
@ -10931,7 +10925,7 @@ void PlanTable::flush_data_to_file()
else
appendBinaryStringInfo(info_str, ",", 1);
} else {
typoid = m_desc->attrs[k]->atttypid;
typoid = m_desc->attrs[k].atttypid;
getTypeOutputInfo(typoid, &foutoid, &typisvarlena);

View File

@ -757,6 +757,7 @@ static void execute_sql_string(const char* sql, const char* filename)
} else {
ProcessUtility(stmt,
query_string,
false,
NULL,
false, /* not top level */
dest,

View File

@ -303,7 +303,7 @@ void PrintFixedHeader(CopyState cstate)
FixFormatter* formatter = (FixFormatter*)cstate->formatter;
FieldDesc* descs = formatter->fieldDesc;
TupleDesc tupDesc;
Form_pg_attribute* attr = NULL;
FormData_pg_attribute* attr = NULL;
char* colname = NULL;
if (cstate->rel)
@ -316,7 +316,7 @@ void PrintFixedHeader(CopyState cstate)
for (int i = 0; i < formatter->nfield; i++) {
int attnum = formatter->fieldDesc[i].attnum;
colname = pstrdup(NameStr(attr[attnum - 1]->attname));
colname = pstrdup(NameStr(attr[attnum - 1].attname));
AttributeOutFixed<true>(cstate, colname, descs + i);
pfree_ext(colname);
}
@ -334,11 +334,11 @@ void VerifyFixedFormatter(TupleDesc tupDesc, FixFormatter* formatter)
char* name = NULL;
bool found = false;
if (tupDesc->attrs[attnum]->attisdropped)
if (tupDesc->attrs[attnum].attisdropped)
continue;
for (int i = 0; i < formatter->nfield; i++) {
name = formatter->fieldDesc[i].fieldname;
if (namestrcmp(&(tupDesc->attrs[attnum]->attname), name) == 0) {
if (namestrcmp(&(tupDesc->attrs[attnum].attname), name) == 0) {
found = true;
break;
}

Some files were not shown because too many files have changed in this diff Show More