diff --git a/contrib/dblink/dblink.cpp b/contrib/dblink/dblink.cpp index e903f4ffc..a2e487546 100644 --- a/contrib/dblink/dblink.cpp +++ b/contrib/dblink/dblink.cpp @@ -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) diff --git a/contrib/file_fdw/file_fdw.cpp b/contrib/file_fdw/file_fdw.cpp index f1f9cb77d..0063bd90e 100644 --- a/contrib/file_fdw/file_fdw.cpp +++ b/contrib/file_fdw/file_fdw.cpp @@ -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; diff --git a/contrib/gauss_connector/deparse.cpp b/contrib/gauss_connector/deparse.cpp index d276a8cf0..d1b2d50b9 100644 --- a/contrib/gauss_connector/deparse.cpp +++ b/contrib/gauss_connector/deparse.cpp @@ -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) diff --git a/contrib/gauss_connector/gc_fdw.cpp b/contrib/gauss_connector/gc_fdw.cpp index 172e4b203..6833d7674 100644 --- a/contrib/gauss_connector/gc_fdw.cpp +++ b/contrib/gauss_connector/gc_fdw.cpp @@ -702,7 +702,7 @@ static void gcBeginForeignScan(ForeignScanState* node, int eflags) for (int i = 0; i < list_length(fsstate->retrieved_attrs); i++) { int attidx = list_nth_int(fsstate->retrieved_attrs, i); - Form_pg_attribute attr = slot->tts_tupleDescriptor->attrs[attidx - 1]; + Form_pg_attribute attr = &slot->tts_tupleDescriptor->attrs[attidx - 1]; const char* attname = (const char*)(attr->attname.data); TupleDescInitEntry(scan_desc, i + 1, attname, attr->atttypid, attr->atttypmod, 0); } @@ -864,7 +864,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; @@ -1813,17 +1813,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); } @@ -2368,7 +2368,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) { @@ -2588,7 +2588,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; diff --git a/contrib/hstore/hstore_io.cpp b/contrib/hstore/hstore_io.cpp index 116ca2c66..48ea373c9 100644 --- a/contrib/hstore/hstore_io.cpp +++ b/contrib/hstore/hstore_io.cpp @@ -702,15 +702,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; @@ -864,18 +864,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 @@ -903,7 +903,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); @@ -913,7 +913,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; } } diff --git a/contrib/log_fdw/log_fdw.cpp b/contrib/log_fdw/log_fdw.cpp index 753c2b0dc..94a994b1a 100644 --- a/contrib/log_fdw/log_fdw.cpp +++ b/contrib/log_fdw/log_fdw.cpp @@ -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]); diff --git a/contrib/mppdb_decoding/mppdb_decoding.cpp b/contrib/mppdb_decoding/mppdb_decoding.cpp index a622e957a..ab75860da 100644 --- a/contrib/mppdb_decoding/mppdb_decoding.cpp +++ b/contrib/mppdb_decoding/mppdb_decoding.cpp @@ -241,7 +241,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 diff --git a/contrib/pageinspect/rawpage.cpp b/contrib/pageinspect/rawpage.cpp index c1442494b..1abcbf763 100644 --- a/contrib/pageinspect/rawpage.cpp +++ b/contrib/pageinspect/rawpage.cpp @@ -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); diff --git a/contrib/postgres_fdw/deparse.cpp b/contrib/postgres_fdw/deparse.cpp index f820c3923..e5a5836dd 100644 --- a/contrib/postgres_fdw/deparse.cpp +++ b/contrib/postgres_fdw/deparse.cpp @@ -2030,7 +2030,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; } @@ -2040,7 +2040,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) { diff --git a/contrib/postgres_fdw/postgres_fdw.cpp b/contrib/postgres_fdw/postgres_fdw.cpp index d47384f43..99f8e3cba 100644 --- a/contrib/postgres_fdw/postgres_fdw.cpp +++ b/contrib/postgres_fdw/postgres_fdw.cpp @@ -1328,7 +1328,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); @@ -1502,7 +1502,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); @@ -1539,7 +1539,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); diff --git a/contrib/spi/timetravel.cpp b/contrib/spi/timetravel.cpp index dea0ffc45..2c0dc7d3b 100644 --- a/contrib/spi/timetravel.cpp +++ b/contrib/spi/timetravel.cpp @@ -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 = ','; diff --git a/contrib/sql_decoding/sql_decoding.cpp b/contrib/sql_decoding/sql_decoding.cpp index 0b61f64c3..890a67a3d 100644 --- a/contrib/sql_decoding/sql_decoding.cpp +++ b/contrib/sql_decoding/sql_decoding.cpp @@ -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; diff --git a/contrib/tablefunc/tablefunc.cpp b/contrib/tablefunc/tablefunc.cpp index 9c484f0a8..a41c7b923 100644 --- a/contrib/tablefunc/tablefunc.cpp +++ b/contrib/tablefunc/tablefunc.cpp @@ -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), diff --git a/contrib/test_decoding/test_decoding.cpp b/contrib/test_decoding/test_decoding.cpp index e3f1cdf90..4a3107c74 100644 --- a/contrib/test_decoding/test_decoding.cpp +++ b/contrib/test_decoding/test_decoding.cpp @@ -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 diff --git a/src/common/backend/catalog/heap.cpp b/src/common/backend/catalog/heap.cpp index 4c6563435..5b888b99b 100644 --- a/src/common/backend/catalog/heap.cpp +++ b/src/common/backend/catalog/heap.cpp @@ -753,11 +753,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)))); } } @@ -766,10 +766,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)))); } } @@ -777,9 +777,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); } @@ -870,7 +870,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; @@ -1027,7 +1027,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 */ @@ -1363,13 +1363,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; } } @@ -1502,7 +1502,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; @@ -1570,7 +1570,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); @@ -1579,7 +1579,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), @@ -1820,7 +1820,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); @@ -2039,14 +2039,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, @@ -2078,14 +2078,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; @@ -2101,7 +2101,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; @@ -2218,7 +2218,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; @@ -2255,7 +2255,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; @@ -4170,7 +4170,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]; if (colDef->raw_default != NULL) { if (IsA(colDef->raw_default, AutoIncrement)) { @@ -5329,7 +5329,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); @@ -5344,8 +5344,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; } @@ -7196,7 +7196,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); @@ -7204,7 +7204,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; } @@ -7899,15 +7899,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)); } } @@ -7931,7 +7931,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); @@ -7988,7 +7988,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 { @@ -8019,7 +8019,7 @@ bool *CheckSubPartkeyHasTimestampwithzone(Relation partTableRel, List *subpartKe int partKeyIdx = 0; foreach (subpartKeyCell, subpartKeyPosList) { int pos = lfirst_int(subpartKeyCell); - if ((RelationGetDescr(partTableRel))->attrs[pos]->atttypid == TIMESTAMPTZOID) { + if ((RelationGetDescr(partTableRel))->attrs[pos].atttypid == TIMESTAMPTZOID) { isTimestamptzForSubPartKey[partKeyIdx] = true; } partKeyIdx++; diff --git a/src/common/backend/catalog/index.cpp b/src/common/backend/catalog/index.cpp index a616fe3f8..f870d68f7 100644 --- a/src/common/backend/catalog/index.cpp +++ b/src/common/backend/catalog/index.cpp @@ -305,7 +305,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 @@ -314,7 +314,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; @@ -337,7 +337,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)]; } /* @@ -500,7 +500,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; } /* ---------------------------------------------------------------- @@ -531,10 +531,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); @@ -4210,7 +4210,7 @@ double IndexBuildUHeapScan(Relation heapRelation, Relation indexRelation, IndexI */ estate = CreateExecutorState(); econtext = GetPerTupleExprContext(estate); - slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation), false, TableAmUstore); + slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation), false, GetTableAmRoutine(heapRelation->rd_tam_type)); /* Arrange for econtext's scan tuple to be the tuple under test */ econtext->ecxt_scantuple = slot; @@ -7061,7 +7061,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); diff --git a/src/common/backend/catalog/pg_constraint.cpp b/src/common/backend/catalog/pg_constraint.cpp index 150db4ec2..0848b85bc 100644 --- a/src/common/backend/catalog/pg_constraint.cpp +++ b/src/common/backend/catalog/pg_constraint.cpp @@ -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; } diff --git a/src/common/backend/catalog/pg_job.cpp b/src/common/backend/catalog/pg_job.cpp index a41784431..9a98ea28e 100644 --- a/src/common/backend/catalog/pg_job.cpp +++ b/src/common/backend/catalog/pg_job.cpp @@ -890,8 +890,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))); } @@ -899,12 +899,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 { @@ -912,7 +912,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); diff --git a/src/common/backend/catalog/pgxc_slice.cpp b/src/common/backend/catalog/pgxc_slice.cpp index 7eeeef904..a49bd3034 100644 --- a/src/common/backend/catalog/pgxc_slice.cpp +++ b/src/common/backend/catalog/pgxc_slice.cpp @@ -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; } diff --git a/src/common/backend/catalog/storage.cpp b/src/common/backend/catalog/storage.cpp index e9a6a8236..8b02109df 100644 --- a/src/common/backend/catalog/storage.cpp +++ b/src/common/backend/catalog/storage.cpp @@ -333,11 +333,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); } } diff --git a/src/common/backend/catalog/toasting.cpp b/src/common/backend/catalog/toasting.cpp index a367a04f6..aeda86583 100644 --- a/src/common/backend/catalog/toasting.cpp +++ b/src/common/backend/catalog/toasting.cpp @@ -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; } } @@ -801,9 +801,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.myLobTempToastNamespace)) { InitLobTempToastNamespace(); } diff --git a/src/common/backend/client_logic/client_logic.cpp b/src/common/backend/client_logic/client_logic.cpp index 479a84b4e..5d04034c8 100644 --- a/src/common/backend/client_logic/client_logic.cpp +++ b/src/common/backend/client_logic/client_logic.cpp @@ -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); diff --git a/src/common/backend/parser/analyze.cpp b/src/common/backend/parser/analyze.cpp index 68a40d0c9..e0eb53373 100644 --- a/src/common/backend/parser/analyze.cpp +++ b/src/common/backend/parser/analyze.cpp @@ -1541,17 +1541,17 @@ static void SetUpsertAttrnoState(ParseState* pstate, List *targetList) rstate->usExplicitAttrNos = (int*)palloc0(sizeof(int) * len); Relation relation = (Relation)linitial(pstate->p_target_relation); - Form_pg_attribute* attr = relation->rd_att->attrs; + FormData_pg_attribute* attr = relation->rd_att->attrs; int colNum = RelationGetNumberOfAttributes(relation); ListCell* target = list_head(targetList); for (int ni = 0; ni < len; ++ni) { ResTarget* res = (ResTarget*)lfirst(target); const char* name = res->name; for (int ci = 0; ci < colNum; ++ci) { - if (attr[ci]->attisdropped) { + if (attr[ci].attisdropped) { continue; } - if (strcmp(name, attr[ci]->attname.data) == 0) { + if (strcmp(name, attr[ci].attname.data) == 0) { rstate->usExplicitAttrNos[ni] = ci + 1; break; } @@ -2231,7 +2231,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) { diff --git a/src/common/backend/parser/parse_coerce.cpp b/src/common/backend/parser/parse_coerce.cpp index 5ed095a89..8331ebcda 100644 --- a/src/common/backend/parser/parse_coerce.cpp +++ b/src/common/backend/parser/parse_coerce.cpp @@ -1013,7 +1013,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. @@ -1034,8 +1034,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); @@ -1045,7 +1045,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))); } diff --git a/src/common/backend/parser/parse_expr.cpp b/src/common/backend/parser/parse_expr.cpp index a9d7d07f0..e1a77d588 100644 --- a/src/common/backend/parser/parse_expr.cpp +++ b/src/common/backend/parser/parse_expr.cpp @@ -245,7 +245,7 @@ static void AddDefaultExprNode(ParseState* pstate) context.estimate = false; for (int i = 0; i < fieldCnt; ++i) { - Form_pg_attribute attTup = rdAtt->attrs[i]; + FormData_pg_attribute *attTup = &rdAtt->attrs[i]; if (IsAutoIncrementColumn(rdAtt, i + 1)) { refState->constValues[i] = makeConst(attTup->atttypid, -1, attTup->attcollation, attTup->attlen, (Datum)0, false, attTup->attbyval); diff --git a/src/common/backend/parser/parse_func.cpp b/src/common/backend/parser/parse_func.cpp index 62b62bd3f..36a9bc92c 100644 --- a/src/common/backend/parser/parse_func.cpp +++ b/src/common/backend/parser/parse_func.cpp @@ -1956,7 +1956,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 */ diff --git a/src/common/backend/parser/parse_hint.cpp b/src/common/backend/parser/parse_hint.cpp index bd5f14e1b..e1b10d1a3 100755 --- a/src/common/backend/parser/parse_hint.cpp +++ b/src/common/backend/parser/parse_hint.cpp @@ -2704,13 +2704,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); diff --git a/src/common/backend/parser/parse_merge.cpp b/src/common/backend/parser/parse_merge.cpp index 2f1f613b4..fbd08341b 100644 --- a/src/common/backend/parser/parse_merge.cpp +++ b/src/common/backend/parser/parse_merge.cpp @@ -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 */ @@ -1649,7 +1649,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); @@ -1812,7 +1812,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); diff --git a/src/common/backend/parser/parse_relation.cpp b/src/common/backend/parser/parse_relation.cpp index 32bc762ff..08b0a2395 100755 --- a/src/common/backend/parser/parse_relation.cpp +++ b/src/common/backend/parser/parse_relation.cpp @@ -894,7 +894,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) { @@ -2243,7 +2243,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) { @@ -2522,7 +2522,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 @@ -2764,7 +2764,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; @@ -2828,7 +2828,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; } /* @@ -2850,7 +2850,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; } /* @@ -2867,7 +2867,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; } /* diff --git a/src/common/backend/parser/parse_target.cpp b/src/common/backend/parser/parse_target.cpp index 0f67a6a6c..53f6d23b2 100644 --- a/src/common/backend/parser/parse_target.cpp +++ b/src/common/backend/parser/parse_target.cpp @@ -389,8 +389,8 @@ Expr* transformAssignedExpr(ParseState* pstate, Expr* expr, char* colname, int a 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 @@ -524,9 +524,9 @@ Expr* transformAssignedExpr(ParseState* pstate, Expr* expr, char* colname, int a errhint("You will need to rewrite or cast the expression."), parser_errposition(pstate, exprLocation(orig_expr)))); } - expr = (Expr*)makeConst(attrtype, attrtypmod, attrcollation, rd->rd_att->attrs[attrno - 1]->attlen, - GetTypeZeroValue(rd->rd_att->attrs[attrno - 1]), false, - rd->rd_att->attrs[attrno - 1]->attbyval); + expr = (Expr*)makeConst(attrtype, attrtypmod, attrcollation, rd->rd_att->attrs[attrno - 1].attlen, + GetTypeZeroValue(&rd->rd_att->attrs[attrno - 1]), false, + rd->rd_att->attrs[attrno - 1].attbyval); ereport(WARNING, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column \"%s\" is of type %s" " but expression is of type %s. Data truncated automatically.", @@ -853,7 +853,7 @@ List* checkInsertTargets(ParseState* pstate, List* cols, List** attrnos) errmsg("targetrel is NULL unexpectedly"))); } - Form_pg_attribute* attr = targetrel->rd_att->attrs; + FormData_pg_attribute* attr = targetrel->rd_att->attrs; int numcol = RelationGetNumberOfAttributes(targetrel); int i; is_blockchain_rel = targetrel->rd_isblockchain; @@ -861,7 +861,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 */ @@ -870,7 +870,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; } @@ -1259,7 +1259,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) { diff --git a/src/common/backend/parser/parse_utilcmd.cpp b/src/common/backend/parser/parse_utilcmd.cpp index cebd1514b..dc9c97847 100644 --- a/src/common/backend/parser/parse_utilcmd.cpp +++ b/src/common/backend/parser/parse_utilcmd.cpp @@ -171,7 +171,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( @@ -1540,7 +1540,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)); @@ -1818,7 +1818,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; @@ -2124,7 +2124,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; @@ -2389,7 +2389,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; @@ -2440,7 +2440,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 { @@ -2531,7 +2531,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; @@ -2556,7 +2556,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; @@ -2614,7 +2614,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) @@ -2726,7 +2726,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; @@ -2938,7 +2938,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); @@ -3540,7 +3540,7 @@ static IndexStmt* transformIndexConstraint(Constraint* constraint, CreateStmtCon if (attnum > 0) { // simple index column 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]; idxElem->name = pstrdup(NameStr(attform->attname)); idxElem->expr = NULL; @@ -3624,7 +3624,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)); @@ -3716,7 +3716,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) @@ -3862,7 +3862,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) @@ -6608,7 +6608,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; @@ -6623,7 +6623,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: @@ -7312,7 +7312,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; @@ -7386,7 +7386,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) { @@ -7409,7 +7409,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; diff --git a/src/common/backend/pgxc_single/copy/copyops.cpp b/src/common/backend/pgxc_single/copy/copyops.cpp index 7410fda75..9946536a4 100644 --- a/src/common/backend/pgxc_single/copy/copyops.cpp +++ b/src/common/backend/pgxc_single/copy/copyops.cpp @@ -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) diff --git a/src/common/backend/pgxc_single/copy/remotecopy.cpp b/src/common/backend/pgxc_single/copy/remotecopy.cpp index b834096d7..fa302cedf 100644 --- a/src/common/backend/pgxc_single/copy/remotecopy.cpp +++ b/src/common/backend/pgxc_single/copy/remotecopy.cpp @@ -140,7 +140,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)) { @@ -149,7 +149,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, ", "); } } diff --git a/src/common/backend/pgxc_single/locator/redistrib.cpp b/src/common/backend/pgxc_single/locator/redistrib.cpp index ae5b1fcb1..3ac9db8d6 100644 --- a/src/common/backend/pgxc_single/locator/redistrib.cpp +++ b/src/common/backend/pgxc_single/locator/redistrib.cpp @@ -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, diff --git a/src/common/backend/pgxc_single/pool/execRemote.cpp b/src/common/backend/pgxc_single/pool/execRemote.cpp index 38815bd51..8b88d5d05 100755 --- a/src/common/backend/pgxc_single/pool/execRemote.cpp +++ b/src/common/backend/pgxc_single/pool/execRemote.cpp @@ -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; @@ -7826,10 +7826,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; } } @@ -7908,7 +7908,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); } } @@ -8950,7 +8950,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 == '{') @@ -9214,9 +9214,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; } @@ -9261,9 +9261,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; } } diff --git a/src/common/backend/pgxc_single/pool/poolutils.cpp b/src/common/backend/pgxc_single/pool/poolutils.cpp index 55e64f67a..ffa6f1515 100755 --- a/src/common/backend/pgxc_single/pool/poolutils.cpp +++ b/src/common/backend/pgxc_single/pool/poolutils.cpp @@ -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); diff --git a/src/common/backend/tsearch/wparser.cpp b/src/common/backend/tsearch/wparser.cpp index 87d5321d9..c67ce2f81 100644 --- a/src/common/backend/tsearch/wparser.cpp +++ b/src/common/backend/tsearch/wparser.cpp @@ -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); diff --git a/src/common/backend/utils/adt/acl.cpp b/src/common/backend/utils/adt/acl.cpp index 5d8b94e6f..f373a7285 100644 --- a/src/common/backend/utils/adt/acl.cpp +++ b/src/common/backend/utils/adt/acl.cpp @@ -1714,7 +1714,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); diff --git a/src/common/backend/utils/adt/datetime.cpp b/src/common/backend/utils/adt/datetime.cpp index 26b02cc20..4bac0164c 100644 --- a/src/common/backend/utils/adt/datetime.cpp +++ b/src/common/backend/utils/adt/datetime.cpp @@ -4129,7 +4129,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); @@ -4220,7 +4220,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); diff --git a/src/common/backend/utils/adt/dbsize.cpp b/src/common/backend/utils/adt/dbsize.cpp index 76b2cc899..d7fee808a 100644 --- a/src/common/backend/utils/adt/dbsize.cpp +++ b/src/common/backend/utils/adt/dbsize.cpp @@ -263,7 +263,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; @@ -278,7 +278,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; } @@ -296,13 +296,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; @@ -810,8 +810,8 @@ int64 CalculateCStoreRelationSize(Relation rel, ForkNumber forknum) */ 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; diff --git a/src/common/backend/utils/adt/genfile.cpp b/src/common/backend/utils/adt/genfile.cpp index 58584b72d..44a437a16 100644 --- a/src/common/backend/utils/adt/genfile.cpp +++ b/src/common/backend/utils/adt/genfile.cpp @@ -411,7 +411,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(6, false, TAM_HEAP); + TupleDesc tupdesc = CreateTemplateTupleDesc(6, false, TableAmHeap); int i = 1; TupleDescInitEntry(tupdesc, (AttrNumber)i++, "path", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "blocknum", INT4OID, -1, 0); @@ -525,7 +525,7 @@ Datum compress_address_details(PG_FUNCTION_ARGS) FuncCallContext* fctx = SRF_FIRSTCALL_INIT(); MemoryContext mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx); - TupleDesc tupdesc = CreateTemplateTupleDesc(6, false, TAM_HEAP); + TupleDesc tupdesc = CreateTemplateTupleDesc(6, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "extent", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "extent_block_number", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "block_number", INT8OID, -1, 0); @@ -607,7 +607,7 @@ Datum compress_address_header(PG_FUNCTION_ARGS) FuncCallContext* fctx = SRF_FIRSTCALL_INIT(); MemoryContext mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx); - TupleDesc tupdesc = CreateTemplateTupleDesc(5, false, TAM_HEAP); + TupleDesc tupdesc = CreateTemplateTupleDesc(5, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "extent", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "nblocks", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "alocated_chunks", INT4OID, -1, 0); @@ -661,7 +661,7 @@ Datum compress_address_header(PG_FUNCTION_ARGS) Datum compress_buffer_stat_info(PG_FUNCTION_ARGS) { int i = 1; - TupleDesc tupdesc = CreateTemplateTupleDesc(PCA_BUFFERS_STAT_INFO_COLS, false, TAM_HEAP); + TupleDesc tupdesc = CreateTemplateTupleDesc(PCA_BUFFERS_STAT_INFO_COLS, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "ctrl_cnt", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "main_cnt", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)i++, "free_cnt", INT8OID, -1, 0); @@ -746,7 +746,7 @@ Datum compress_ratio_info(PG_FUNCTION_ARGS) checkPath(path); // format the tupdesc - TupleDesc tupdesc = CreateTemplateTupleDesc(PCA_COMPRESS_RATIO_INFO_COLS, false, TAM_HEAP); + TupleDesc tupdesc = CreateTemplateTupleDesc(PCA_COMPRESS_RATIO_INFO_COLS, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "path", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "is_compress", BOOLOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "file_count", INT8OID, -1, 0); @@ -931,7 +931,7 @@ Datum compress_statistic_info(PG_FUNCTION_ARGS) } // format the tupdesc - TupleDesc tupdesc = CreateTemplateTupleDesc(PCA_COMPRESS_STATISTIC_INFO_COLS, false, TAM_HEAP); + TupleDesc tupdesc = CreateTemplateTupleDesc(PCA_COMPRESS_STATISTIC_INFO_COLS, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "path", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "extent_count", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "dispersion_count", INT8OID, -1, 0); @@ -1075,7 +1075,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); @@ -1252,7 +1252,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); diff --git a/src/common/backend/utils/adt/json.cpp b/src/common/backend/utils/adt/json.cpp index ba3e0a283..ba12288de 100644 --- a/src/common/backend/utils/adt/json.cpp +++ b/src/common/backend/utils/adt/json.cpp @@ -1380,7 +1380,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) { @@ -1388,16 +1388,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); @@ -1411,14 +1411,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); } diff --git a/src/common/backend/utils/adt/jsonfuncs.cpp b/src/common/backend/utils/adt/jsonfuncs.cpp index 8e763b631..adaec141a 100644 --- a/src/common/backend/utils/adt/jsonfuncs.cpp +++ b/src/common/backend/utils/adt/jsonfuncs.cpp @@ -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; } } @@ -2520,18 +2520,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); @@ -2561,12 +2561,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; } } diff --git a/src/common/backend/utils/adt/lockfuncs.cpp b/src/common/backend/utils/adt/lockfuncs.cpp index bea6b7692..4aecb5c28 100644 --- a/src/common/backend/utils/adt/lockfuncs.cpp +++ b/src/common/backend/utils/adt/lockfuncs.cpp @@ -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); diff --git a/src/common/backend/utils/adt/misc.cpp b/src/common/backend/utils/adt/misc.cpp index eb2b72e8a..66305da30 100644 --- a/src/common/backend/utils/adt/misc.cpp +++ b/src/common/backend/utils/adt/misc.cpp @@ -859,7 +859,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); diff --git a/src/common/backend/utils/adt/pgstatfuncs.cpp b/src/common/backend/utils/adt/pgstatfuncs.cpp index 177256e31..03012ef0f 100644 --- a/src/common/backend/utils/adt/pgstatfuncs.cpp +++ b/src/common/backend/utils/adt/pgstatfuncs.cpp @@ -3664,7 +3664,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); @@ -3960,7 +3960,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); @@ -4879,7 +4879,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); @@ -5095,7 +5095,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); @@ -5242,7 +5242,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); @@ -5365,7 +5365,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); @@ -5754,7 +5754,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); @@ -5855,7 +5855,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); @@ -5931,7 +5931,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); @@ -6020,7 +6020,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); @@ -6106,7 +6106,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); @@ -6467,7 +6467,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); @@ -6737,7 +6737,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); @@ -6855,7 +6855,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); @@ -6952,7 +6952,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); @@ -7055,7 +7055,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); @@ -7153,7 +7153,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); @@ -7229,7 +7229,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); @@ -7309,7 +7309,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); @@ -7420,7 +7420,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); @@ -8014,7 +8014,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); @@ -8088,7 +8088,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); @@ -8546,7 +8546,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); @@ -8589,7 +8589,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); @@ -8638,7 +8638,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); @@ -8867,7 +8867,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); @@ -8926,7 +8926,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); @@ -9149,7 +9149,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); @@ -9238,7 +9238,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); @@ -9730,7 +9730,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); @@ -9896,7 +9896,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); @@ -10052,7 +10052,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); @@ -10160,7 +10160,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); @@ -10271,7 +10271,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); @@ -10370,7 +10370,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); @@ -10451,7 +10451,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); @@ -10558,7 +10558,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); @@ -10598,7 +10598,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); @@ -10687,7 +10687,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); @@ -10981,7 +10981,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); @@ -11052,7 +11052,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); @@ -11269,7 +11269,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); @@ -11391,7 +11391,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); @@ -11520,7 +11520,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); @@ -11649,7 +11649,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); @@ -11769,7 +11769,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); @@ -12332,7 +12332,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); @@ -12534,7 +12534,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); @@ -12684,7 +12684,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); @@ -12853,7 +12853,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); @@ -12950,7 +12950,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); @@ -13020,7 +13020,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); @@ -13121,7 +13121,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: @@ -13220,7 +13220,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++) { @@ -13525,7 +13525,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); @@ -13609,7 +13609,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), @@ -13646,7 +13646,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); @@ -13766,7 +13766,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(); @@ -13795,7 +13795,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; @@ -13865,7 +13865,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); @@ -13949,7 +13949,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); @@ -14089,7 +14089,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(); @@ -14119,7 +14119,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; @@ -14260,7 +14260,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); @@ -14407,7 +14407,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); @@ -14527,7 +14527,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); diff --git a/src/common/backend/utils/adt/rowtypes.cpp b/src/common/backend/utils/adt/rowtypes.cpp index 05d8c1a2e..4e3d14283 100644 --- a/src/common/backend/utils/adt/rowtypes.cpp +++ b/src/common/backend/utils/adt/rowtypes.cpp @@ -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), diff --git a/src/common/backend/utils/adt/ruleutils.cpp b/src/common/backend/utils/adt/ruleutils.cpp index a6615b48a..957e07cf1 100644 --- a/src/common/backend/utils/adt/ruleutils.cpp +++ b/src/common/backend/utils/adt/ruleutils.cpp @@ -4351,7 +4351,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); @@ -6461,7 +6461,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; @@ -8563,7 +8563,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 */ @@ -8865,7 +8865,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); } /* @@ -9878,7 +9878,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 = ", "; @@ -9887,7 +9887,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 = ", "; diff --git a/src/common/backend/utils/adt/tid.cpp b/src/common/backend/utils/adt/tid.cpp index 84ee4fa9f..3a200870b 100644 --- a/src/common/backend/utils/adt/tid.cpp +++ b/src/common/backend/utils/adt/tid.cpp @@ -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; diff --git a/src/common/backend/utils/adt/tsvector_op.cpp b/src/common/backend/utils/adt/tsvector_op.cpp index 4e5bf8ff9..944c58645 100644 --- a/src/common/backend/utils/adt/tsvector_op.cpp +++ b/src/common/backend/utils/adt/tsvector_op.cpp @@ -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); diff --git a/src/common/backend/utils/adt/xml.cpp b/src/common/backend/utils/adt/xml.cpp index 9d3890757..78db5adff 100644 --- a/src/common/backend/utils/adt/xml.cpp +++ b/src/common/backend/utils/adt/xml.cpp @@ -2944,12 +2944,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, " \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\""); } @@ -3200,9 +3200,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); } } diff --git a/src/common/backend/utils/cache/catcache.cpp b/src/common/backend/utils/cache/catcache.cpp index a8491bdfd..7a4c35d40 100644 --- a/src/common/backend/utils/cache/catcache.cpp +++ b/src/common/backend/utils/cache/catcache.cpp @@ -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"))); @@ -2390,7 +2390,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); @@ -2971,7 +2971,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; @@ -2999,7 +2999,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; diff --git a/src/common/backend/utils/cache/knl_globalsysdbcache.cpp b/src/common/backend/utils/cache/knl_globalsysdbcache.cpp index 762512987..7f536f6c6 100644 --- a/src/common/backend/utils/cache/knl_globalsysdbcache.cpp +++ b/src/common/backend/utils/cache/knl_globalsysdbcache.cpp @@ -1291,7 +1291,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); diff --git a/src/common/backend/utils/cache/knl_globalsystupcache.cpp b/src/common/backend/utils/cache/knl_globalsystupcache.cpp index afb7f268e..b6fde19ba 100644 --- a/src/common/backend/utils/cache/knl_globalsystupcache.cpp +++ b/src/common/backend/utils/cache/knl_globalsystupcache.cpp @@ -1483,7 +1483,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"))); diff --git a/src/common/backend/utils/cache/relcache.cpp b/src/common/backend/utils/cache/relcache.cpp index a668e3546..a0f493c38 100644 --- a/src/common/backend/utils/cache/relcache.cpp +++ b/src/common/backend/utils/cache/relcache.cpp @@ -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" @@ -1433,7 +1434,7 @@ 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, NULL); //TODO:this should be TAM_invalid when merge ustore relation->rd_tam_type = TAM_HEAP; /* which we mark as a reference-counted tupdesc */ @@ -1600,14 +1601,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) { @@ -1664,7 +1665,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)); } } @@ -1707,7 +1708,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 @@ -1717,7 +1718,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 @@ -2013,7 +2014,7 @@ static Relation CatalogRelationBuildDesc(const char* relationName, Oid relationR 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_att = CreateTemplateTupleDesc(natts, hasoids, TableAmHeap); relation->rd_att->tdrefcount = 1; /* mark as refcounted */ relation->rd_att->tdtypeid = relationReltype; relation->rd_att->tdtypmod = -1; @@ -2022,15 +2023,15 @@ static Relation CatalogRelationBuildDesc(const char* relationName, Oid relationR 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) { @@ -2043,7 +2044,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); @@ -2243,7 +2244,7 @@ Relation RelationBuildDesc(Oid targetRelId, bool insertIt, bool buildkey) * 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_att->td_tam_ops = GetTableAmRoutine(relation->rd_tam_type); relation->rd_indexsplit = get_indexsplit_from_reloptions(relation->rd_options, relation->rd_rel->relam); @@ -2427,7 +2428,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)) { @@ -2455,8 +2456,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; } } @@ -3033,7 +3034,7 @@ 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_att = CreateTemplateTupleDesc(natts, hasoids); relation->rd_tam_type = TAM_HEAP; relation->rd_att->tdrefcount = 1; /* mark as refcounted */ @@ -3045,17 +3046,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) { @@ -3068,7 +3069,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 @@ -3149,7 +3150,7 @@ Relation RelationIdGetRelation(Oid relationId) if (EnableLocalSysCache()) { Relation rel = t_thrd.lsc_cxt.lsc->tabdefcache.RelationIdGetRelation(relationId); if (rel != NULL) { - rel->rd_att->tdTableAmType = rel->rd_tam_type; + rel->rd_att->td_tam_ops = GetTableAmRoutine(rel->rd_tam_type); } return rel; } @@ -3183,7 +3184,7 @@ Relation RelationIdGetRelation(Oid relationId) if (rd->rd_rel->relpersistence == RELPERSISTENCE_TEMP) (void)checkGroup(relationId, RELATION_IS_OTHER_TEMP(rd)); - rd->rd_att->tdTableAmType = rd->rd_tam_type; + rd->rd_att->td_tam_ops = GetTableAmRoutine(rd->rd_tam_type); return rd; } @@ -3201,7 +3202,7 @@ Relation RelationIdGetRelation(Oid relationId) } if (rd != NULL) { - rd->rd_att->tdTableAmType = rd->rd_tam_type; + rd->rd_att->td_tam_ops = GetTableAmRoutine(rd->rd_tam_type); } return rd; } @@ -4507,12 +4508,12 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple rel->rd_att = CreateTupleDescCopy(tupDesc); rel->rd_tam_type = tam_type; rel->rd_indexsplit = relindexsplit; - rel->rd_att->tdTableAmType = tam_type; + rel->rd_att->td_tam_ops = GetTableAmRoutine(tam_type); 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) { @@ -4576,7 +4577,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; @@ -5529,19 +5530,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 */ @@ -5703,7 +5704,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++; @@ -5716,7 +5717,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)); if (!attrdef[i].has_on_update) { @@ -7276,7 +7277,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; @@ -7290,12 +7291,12 @@ static bool load_relcache_init_file(bool shared) goto read_failed; if (len != ATTRIBUTE_FIXED_PART_SIZE) goto read_failed; - if (fread_wrap(rel->rd_att->attrs[i], 1, len, fp) != len) + if (fread_wrap(&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 @@ -7702,7 +7703,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 */ @@ -8288,24 +8289,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); @@ -8354,23 +8355,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, "", ""); } diff --git a/src/common/backend/utils/cache/typcache.cpp b/src/common/backend/utils/cache/typcache.cpp index affa315d6..380f5199b 100644 --- a/src/common/backend/utils/cache/typcache.cpp +++ b/src/common/backend/utils/cache/typcache.cpp @@ -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) { diff --git a/src/common/backend/utils/error/elog.cpp b/src/common/backend/utils/error/elog.cpp index 8397c2108..3d399a2c8 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -5341,7 +5341,7 @@ void gramShowWarningsErrors(int offset, int count, DestReceiver *dest, bool isSh TupleDesc tupdesc; /* need a tuple descriptor representing three TEXT columns */ - tupdesc = CreateTemplateTupleDesc(NUM_SHOW_WARNINGS_COLUMNS, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(NUM_SHOW_WARNINGS_COLUMNS, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "level", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "code", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "message", TEXTOID, -1, 0); @@ -5419,7 +5419,7 @@ void gramShowWarningsErrorsCount(DestReceiver *dest, bool isShowErrors) bool isnull[1] = {false}; /* need a tuple descriptor representing three TEXT columns */ - tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(1, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "count", INT4OID, -1, 0); /* prepare for projection of tuples */ diff --git a/src/common/backend/utils/fmgr/funcapi.cpp b/src/common/backend/utils/fmgr/funcapi.cpp index 5fc166829..7ff67b35b 100644 --- a/src/common/backend/utils/fmgr/funcapi.cpp +++ b/src/common/backend/utils/fmgr/funcapi.cpp @@ -548,7 +548,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; @@ -664,21 +664,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; @@ -1335,7 +1335,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 */ @@ -1416,7 +1416,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); } } @@ -1441,7 +1441,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 ... */ diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index 95a5c6f40..529d04f22 100755 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -9548,17 +9548,17 @@ 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); } else if (guc_name_compare(name, "show_warnings") == 0 || guc_name_compare(name, "show_errors") == 0) { - tupdesc = CreateTemplateTupleDesc(NUM_SHOW_WARNINGS_COLUMNS, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(NUM_SHOW_WARNINGS_COLUMNS, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "level", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "code", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "message", TEXTOID, -1, 0); } else if (guc_name_compare(name, "show_warnings_count") == 0 || guc_name_compare(name, "show_errors_count") == 0) { - tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(1, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "count", INT4OID, -1, 0); } else { const char* varname = NULL; @@ -9567,7 +9567,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); } @@ -9588,7 +9588,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 */ @@ -9613,7 +9613,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); @@ -10069,7 +10069,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); diff --git a/src/common/backend/utils/mmgr/portalmem.cpp b/src/common/backend/utils/mmgr/portalmem.cpp index c658c54e8..9e711477a 100755 --- a/src/common/backend/utils/mmgr/portalmem.cpp +++ b/src/common/backend/utils/mmgr/portalmem.cpp @@ -1210,7 +1210,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); diff --git a/src/common/backend/utils/sort/batchsort.cpp b/src/common/backend/utils/sort/batchsort.cpp index e67116699..15d258174 100644 --- a/src/common/backend/utils/sort/batchsort.cpp +++ b/src/common/backend/utils/sort/batchsort.cpp @@ -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; diff --git a/src/common/backend/utils/sort/tuplestore.cpp b/src/common/backend/utils/sort/tuplestore.cpp index 4535ba48c..dc580eae9 100644 --- a/src/common/backend/utils/sort/tuplestore.cpp +++ b/src/common/backend/utils/sort/tuplestore.cpp @@ -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)); diff --git a/src/common/backend/utils/time/snapmgr.cpp b/src/common/backend/utils/time/snapmgr.cpp index c14d14d27..a64d768b5 100644 --- a/src/common/backend/utils/time/snapmgr.cpp +++ b/src/common/backend/utils/time/snapmgr.cpp @@ -1413,7 +1413,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); diff --git a/src/common/pl/plpgsql/src/gram.y b/src/common/pl/plpgsql/src/gram.y index f3b5b1cea..dd0ca89a1 100755 --- a/src/common/pl/plpgsql/src/gram.y +++ b/src/common/pl/plpgsql/src/gram.y @@ -9603,7 +9603,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, ","); @@ -10435,7 +10435,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; } @@ -11591,9 +11591,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; } @@ -11606,7 +11606,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; @@ -11651,7 +11651,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; diff --git a/src/common/pl/plpgsql/src/pl_comp.cpp b/src/common/pl/plpgsql/src/pl_comp.cpp index fed6e814f..f73349dc7 100644 --- a/src/common/pl/plpgsql/src/pl_comp.cpp +++ b/src/common/pl/plpgsql/src/pl_comp.cpp @@ -3730,7 +3730,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; @@ -3840,7 +3840,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, diff --git a/src/common/pl/plpgsql/src/pl_debugger_api.cpp b/src/common/pl/plpgsql/src/pl_debugger_api.cpp index be78dbc51..ac846efa0 100644 --- a/src/common/pl/plpgsql/src/pl_debugger_api.cpp +++ b/src/common/pl/plpgsql/src/pl_debugger_api.cpp @@ -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); diff --git a/src/common/pl/plpgsql/src/pl_exec.cpp b/src/common/pl/plpgsql/src/pl_exec.cpp index 66314f199..75e46d8ad 100644 --- a/src/common/pl/plpgsql/src/pl_exec.cpp +++ b/src/common/pl/plpgsql/src/pl_exec.cpp @@ -851,16 +851,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; } } @@ -1617,8 +1617,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; } } } @@ -3563,19 +3563,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)); } @@ -4951,7 +4951,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; @@ -5035,8 +5035,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); @@ -5103,7 +5103,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 { @@ -7667,7 +7667,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; @@ -7833,7 +7833,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), @@ -8133,7 +8133,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), @@ -8423,8 +8423,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); @@ -8537,8 +8537,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; } } @@ -8556,8 +8556,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); @@ -9320,7 +9320,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; } @@ -9529,8 +9529,8 @@ 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 and no SPI_getcollation, for some reason */ if (fno > 0) { - *typmod = rec->tupdesc->attrs[fno - 1]->atttypmod; - *collation = rec->tupdesc->attrs[fno - 1]->attcollation; + *typmod = rec->tupdesc->attrs[fno - 1].atttypmod; + *collation = rec->tupdesc->attrs[fno - 1].attcollation; } else { *typmod = -1; *collation = InvalidOid; @@ -10418,7 +10418,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; } } @@ -10447,12 +10447,12 @@ static TupleConversionMap *convert_tuples_for_bulk_collect(TupleDesc indesc, Tup nincols = noutcols = 0; /* these count non-dropped attributes */ same = true; for (i = 0; i < n; i++) { - Form_pg_attribute att = outdesc->attrs[i]; + Form_pg_attribute att = &outdesc->attrs[i]; if (att->attisdropped) continue; /* attrMap[i] is already 0 */ noutcols++; for (; j < indesc->natts; j++) { - att = indesc->attrs[j]; + att = &indesc->attrs[j]; if (att->attisdropped) continue; nincols++; @@ -10466,7 +10466,7 @@ static TupleConversionMap *convert_tuples_for_bulk_collect(TupleDesc indesc, Tup /* Check for unused input columns */ for (; j < indesc->natts; j++) { - if (indesc->attrs[j]->attisdropped) + if (indesc->attrs[j].attisdropped) continue; nincols++; same = false; /* we'll complain below */ @@ -10509,7 +10509,7 @@ static int get_bulk_collect_record_attnum(TupleDesc tupdesc, HeapTuple tup, Oid int t_natts = (HeapTupleIsValid(tup)) ? HeapTupleHeaderGetNatts(tup->t_data, tupdesc) : 0; for (int anum = 0; anum < td_natts; anum++) { - if (tupdesc->attrs[anum]->attisdropped) { + if (tupdesc->attrs[anum].attisdropped) { continue; } @@ -10600,7 +10600,7 @@ static Datum exec_tuple_get_composite(PLpgSQL_execstate* estate, TupleDesc tupde continue; } outvalues[i] = exec_simple_cast_value(estate, invalues[j], SPI_gettypeid(tupdesc, j), - outTupdesc->attrs[i]->atttypid, outTupdesc->attrs[i]->atttypmod, inisnull[j]); + outTupdesc->attrs[i].atttypid, outTupdesc->attrs[i].atttypmod, inisnull[j]); outisnull[i] = inisnull[j]; } @@ -10669,7 +10669,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++; } } @@ -10857,7 +10857,7 @@ static void exec_read_bulk_collect(PLpgSQL_execstate* estate, PLpgSQL_row* row, } /* 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++; } @@ -11009,7 +11009,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 */ } } @@ -11026,7 +11026,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); @@ -11069,7 +11069,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 */ } @@ -11126,7 +11126,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 */ } @@ -11188,7 +11188,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; } @@ -11238,9 +11238,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; diff --git a/src/common/pl/plpython/plpy_exec.cpp b/src/common/pl/plpython/plpy_exec.cpp index d8c4160cc..9545a443c 100644 --- a/src/common/pl/plpython/plpy_exec.cpp +++ b/src/common/pl/plpython/plpy_exec.cpp @@ -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) { diff --git a/src/common/pl/plpython/plpy_resultobject.cpp b/src/common/pl/plpython/plpy_resultobject.cpp index f6ccb9ae3..c4be01acd 100644 --- a/src/common/pl/plpython/plpy_resultobject.cpp +++ b/src/common/pl/plpython/plpy_resultobject.cpp @@ -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; diff --git a/src/common/pl/plpython/plpy_typeio.cpp b/src/common/pl/plpython/plpy_typeio.cpp index daca09ebd..3a47b0e57 100644 --- a/src/common/pl/plpython/plpy_typeio.cpp +++ b/src/common/pl/plpython/plpy_typeio.cpp @@ -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(); diff --git a/src/gausskernel/bootstrap/bootparse.y b/src/gausskernel/bootstrap/bootparse.y index 44052a01a..8fd857ce7 100755 --- a/src/gausskernel/bootstrap/bootparse.y +++ b/src/gausskernel/bootstrap/bootparse.y @@ -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; diff --git a/src/gausskernel/bootstrap/bootstrap.cpp b/src/gausskernel/bootstrap/bootstrap.cpp index f50713ddb..139f4507d 100755 --- a/src/gausskernel/bootstrap/bootstrap.cpp +++ b/src/gausskernel/bootstrap/bootstrap.cpp @@ -549,7 +549,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"); @@ -740,8 +740,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); + GetTableAmRoutine(t_thrd.bootstrap_cxt.boot_reldesc->rd_tam_type)); + 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 */ @@ -777,7 +777,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); diff --git a/src/gausskernel/cbb/communication/comm_proxy/comm_dfx.cpp b/src/gausskernel/cbb/communication/comm_proxy/comm_dfx.cpp index 153ed79a0..057beb6ad 100644 --- a/src/gausskernel/cbb/communication/comm_proxy/comm_dfx.cpp +++ b/src/gausskernel/cbb/communication/comm_proxy/comm_dfx.cpp @@ -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); diff --git a/src/gausskernel/cbb/extension/connector/odbc_connector.cpp b/src/gausskernel/cbb/extension/connector/odbc_connector.cpp index cfdd5c723..2efdbb632 100644 --- a/src/gausskernel/cbb/extension/connector/odbc_connector.cpp +++ b/src/gausskernel/cbb/extension/connector/odbc_connector.cpp @@ -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); diff --git a/src/gausskernel/cbb/instruments/event/instr_waitevent.cpp b/src/gausskernel/cbb/instruments/event/instr_waitevent.cpp index c0fdaab09..6dc546a8a 100644 --- a/src/gausskernel/cbb/instruments/event/instr_waitevent.cpp +++ b/src/gausskernel/cbb/instruments/event/instr_waitevent.cpp @@ -480,7 +480,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); diff --git a/src/gausskernel/cbb/instruments/func_control/instr_func_control.cpp b/src/gausskernel/cbb/instruments/func_control/instr_func_control.cpp index cd8732e2c..d6358225c 100644 --- a/src/gausskernel/cbb/instruments/func_control/instr_func_control.cpp +++ b/src/gausskernel/cbb/instruments/func_control/instr_func_control.cpp @@ -180,7 +180,7 @@ Datum dynamic_func_control(PG_FUNCTION_ARGS) deconstruct_array(param_arr, TEXTOID, -1, false, 'i', ¶m_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); diff --git a/src/gausskernel/cbb/instruments/percentile/percentile.cpp b/src/gausskernel/cbb/instruments/percentile/percentile.cpp index df81de733..b8af55149 100755 --- a/src/gausskernel/cbb/instruments/percentile/percentile.cpp +++ b/src/gausskernel/cbb/instruments/percentile/percentile.cpp @@ -679,7 +679,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); diff --git a/src/gausskernel/cbb/instruments/statement/instr_mfchain.cpp b/src/gausskernel/cbb/instruments/statement/instr_mfchain.cpp index 52db25926..b24c1778e 100644 --- a/src/gausskernel/cbb/instruments/statement/instr_mfchain.cpp +++ b/src/gausskernel/cbb/instruments/statement/instr_mfchain.cpp @@ -794,8 +794,8 @@ static ChainActionState ReCreateMFChainSDesc(MemFileChain* mfchain, Oid oid, Rel sizeof(int) + sizeof(Oid) * desc->natts); sDesc->natts = desc->natts; for (int i = 0; i < desc->natts; i++) { - sDesc->attrs[i] = desc->attrs[i]->atttypid; - if (desc->attrs[i]->atttypmod != -1) { + sDesc->attrs[i] = desc->attrs[i].atttypid; + if (desc->attrs[i].atttypmod != -1) { res = CHAIN_CREATE_TYPEMOD_ERR; break; } diff --git a/src/gausskernel/cbb/instruments/statement/instr_statement.cpp b/src/gausskernel/cbb/instruments/statement/instr_statement.cpp index bae9e72fb..f9b6db261 100755 --- a/src/gausskernel/cbb/instruments/statement/instr_statement.cpp +++ b/src/gausskernel/cbb/instruments/statement/instr_statement.cpp @@ -2815,10 +2815,10 @@ static TupleDesc create_sstmthist_tuple_entry(FunctionCallInfo fcinfo) ereport(ERROR, (errmsg("function standby_statement_history does not match relation statement_history."))); } - TupleDesc tmpDesc = CreateTemplateTupleDesc(desc->natts, false, TAM_HEAP); + TupleDesc tmpDesc = CreateTemplateTupleDesc(desc->natts, false, TableAmHeap); for (int i = 0; i < desc->natts; i++) { TupleDescInitEntry(tmpDesc, (AttrNumber)(i + 1), - NameStr(desc->attrs[i]->attname), desc->attrs[i]->atttypid, -1, 0); + NameStr(desc->attrs[i].attname), desc->attrs[i].atttypid, -1, 0); } heap_close(rel, AccessShareLock); diff --git a/src/gausskernel/cbb/instruments/unique_sql/instr_unique_sql.cpp b/src/gausskernel/cbb/instruments/unique_sql/instr_unique_sql.cpp index 70115c610..7cae9d41f 100755 --- a/src/gausskernel/cbb/instruments/unique_sql/instr_unique_sql.cpp +++ b/src/gausskernel/cbb/instruments/unique_sql/instr_unique_sql.cpp @@ -1625,7 +1625,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); diff --git a/src/gausskernel/cbb/instruments/user/instr_user.cpp b/src/gausskernel/cbb/instruments/user/instr_user.cpp index 77f0051bb..bef11cc12 100644 --- a/src/gausskernel/cbb/instruments/user/instr_user.cpp +++ b/src/gausskernel/cbb/instruments/user/instr_user.cpp @@ -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); diff --git a/src/gausskernel/cbb/instruments/wdr/dblink_query.cpp b/src/gausskernel/cbb/instruments/wdr/dblink_query.cpp index af7021f9a..ac5e467ce 100644 --- a/src/gausskernel/cbb/instruments/wdr/dblink_query.cpp +++ b/src/gausskernel/cbb/instruments/wdr/dblink_query.cpp @@ -464,7 +464,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); diff --git a/src/gausskernel/cbb/instruments/wdr/generate_report.cpp b/src/gausskernel/cbb/instruments/wdr/generate_report.cpp index c37d8f2c4..c0491cccc 100644 --- a/src/gausskernel/cbb/instruments/wdr/generate_report.cpp +++ b/src/gausskernel/cbb/instruments/wdr/generate_report.cpp @@ -1011,9 +1011,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); } diff --git a/src/gausskernel/cbb/instruments/wdr/snapshot.cpp b/src/gausskernel/cbb/instruments/wdr/snapshot.cpp index bc6d25052..0e12f6a29 100755 --- a/src/gausskernel/cbb/instruments/wdr/snapshot.cpp +++ b/src/gausskernel/cbb/instruments/wdr/snapshot.cpp @@ -627,7 +627,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); diff --git a/src/gausskernel/cbb/instruments/workload/instr_workload.cpp b/src/gausskernel/cbb/instruments/workload/instr_workload.cpp index 0c431542b..82cb24de2 100755 --- a/src/gausskernel/cbb/instruments/workload/instr_workload.cpp +++ b/src/gausskernel/cbb/instruments/workload/instr_workload.cpp @@ -430,7 +430,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); diff --git a/src/gausskernel/cbb/utils/partition/partitionmap.cpp b/src/gausskernel/cbb/utils/partition/partitionmap.cpp index 2af8abb05..b9e7a9cfa 100644 --- a/src/gausskernel/cbb/utils/partition/partitionmap.cpp +++ b/src/gausskernel/cbb/utils/partition/partitionmap.cpp @@ -660,7 +660,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)); @@ -702,8 +702,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; } } @@ -1974,7 +1974,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; diff --git a/src/gausskernel/dbmind/kernel/index_advisor.cpp b/src/gausskernel/dbmind/kernel/index_advisor.cpp index 5941dfe25..bdeb78ac3 100644 --- a/src/gausskernel/dbmind/kernel/index_advisor.cpp +++ b/src/gausskernel/dbmind/kernel/index_advisor.cpp @@ -57,7 +57,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) @@ -748,7 +748,7 @@ void receive(TupleTableSlot *slot, DestReceiver *self) } result->isnulls[i] = false; - getTypeOutputInfo(typeinfo->attrs[i]->atttypid, &typoutput, &typisvarlena); + getTypeOutputInfo(typeinfo->attrs[i].atttypid, &typoutput, &typisvarlena); if (typisvarlena) { attr = PointerGetDatum(PG_DETOAST_DATUM(origattr)); @@ -758,7 +758,7 @@ void receive(TupleTableSlot *slot, DestReceiver *self) value = OidOutputFunctionCall(typoutput, attr); values = lappend(values, value); - result->atttypids[i] = typeinfo->attrs[i]->atttypid; + result->atttypids[i] = typeinfo->attrs[i].atttypid; /* Clean up detoasted copy, if any */ if (DatumGetPointer(attr) != DatumGetPointer(origattr)) { diff --git a/src/gausskernel/optimizer/aioptimizer/aianalyze.cpp b/src/gausskernel/optimizer/aioptimizer/aianalyze.cpp index ebec44b52..c33dcf3bc 100644 --- a/src/gausskernel/optimizer/aioptimizer/aianalyze.cpp +++ b/src/gausskernel/optimizer/aioptimizer/aianalyze.cpp @@ -294,7 +294,7 @@ typedef struct { static ArrayBuildState* spi_get_result_array_sample(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, ""); @@ -409,9 +409,9 @@ static void prepare_samplerows( * 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 data counts.", @@ -419,7 +419,7 @@ static void prepare_samplerows( 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, "Load samples from table %s failed.", tableName); pfree_ext(spiResult); @@ -479,10 +479,10 @@ bool analyze_compute_bayesnet(int *slot_idx, Relation onerel, AnalyzeMode analyz return false; } for (uint32_t i = 0; i < spec->stats->num_attrs; i++) { - if (!isSupport(tupdesc->attrs[i]->atttypid)) { + if (!isSupport(tupdesc->attrs[i].atttypid)) { ereport(WARNING, (errmsg("[AI Stats] Unsupported attribute types %d.\n (Support only %s)", - tupdesc->attrs[i]->atttypid, supported_typed_readable))); + tupdesc->attrs[i].atttypid, supported_typed_readable))); return false; } } diff --git a/src/gausskernel/optimizer/commands/analyze.cpp b/src/gausskernel/optimizer/commands/analyze.cpp index 6d2bdf3ee..7e9a383bc 100755 --- a/src/gausskernel/optimizer/commands/analyze.cpp +++ b/src/gausskernel/optimizer/commands/analyze.cpp @@ -372,8 +372,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; } } } @@ -1007,7 +1007,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) @@ -1079,7 +1079,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) @@ -1147,10 +1147,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); } @@ -1169,12 +1169,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, @@ -2032,7 +2032,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; } @@ -2057,7 +2057,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); @@ -2094,7 +2094,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)) { @@ -2565,8 +2565,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; } } @@ -2727,8 +2727,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; } } @@ -3334,7 +3334,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 */ @@ -3342,7 +3342,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() @@ -3451,8 +3451,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 \ @@ -3539,7 +3539,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", @@ -3550,7 +3550,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. */ @@ -3656,7 +3656,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); } @@ -3675,7 +3675,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); } @@ -4149,7 +4149,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); @@ -5933,8 +5933,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))) @@ -6695,7 +6695,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; @@ -6706,7 +6706,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); } } @@ -7387,7 +7387,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, ""); @@ -7474,7 +7474,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); @@ -7759,9 +7759,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.", @@ -7769,7 +7769,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); @@ -7876,7 +7876,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); @@ -8059,13 +8059,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); } /* @@ -8080,7 +8080,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; diff --git a/src/gausskernel/optimizer/commands/cluster.cpp b/src/gausskernel/optimizer/commands/cluster.cpp index 86ace69d0..afa644a4f 100755 --- a/src/gausskernel/optimizer/commands/cluster.cpp +++ b/src/gausskernel/optimizer/commands/cluster.cpp @@ -1368,7 +1368,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; @@ -1699,7 +1699,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, GetTableAmRoutine(oldTupDesc->tdTableAmType)); + slot = MakeSingleTupleTableSlot(oldTupDesc, false, oldTupDesc->td_tam_ops); /* Initialize the rewrite operation */ rwstate = begin_heap_rewrite(oldHeap, newHeap, oldestXmin, freezeXid, useWal); @@ -2173,7 +2173,7 @@ double copy_heap_data_internal(Relation OldHeap, Relation OldIndex, Relation New /* Be sure to null out any dropped columns */ for (int i = 0; i < newTupDesc->natts; i++) { - if (newTupDesc->attrs[i]->attisdropped) + if (newTupDesc->attrs[i].attisdropped) isnull[i] = true; } @@ -3626,7 +3626,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; } @@ -3768,7 +3768,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; } @@ -3776,7 +3776,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); @@ -4228,7 +4228,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; } @@ -4250,7 +4250,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. @@ -4269,7 +4269,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); /* @@ -4610,9 +4610,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; } } diff --git a/src/gausskernel/optimizer/commands/copy.cpp b/src/gausskernel/optimizer/commands/copy.cpp index aac612543..babc1f3b4 100644 --- a/src/gausskernel/optimizer/commands/copy.cpp +++ b/src/gausskernel/optimizer/commands/copy.cpp @@ -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); @@ -1256,7 +1256,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; @@ -1273,7 +1273,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); } } @@ -1987,14 +1987,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); @@ -2041,13 +2041,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); @@ -2083,9 +2083,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); @@ -2146,14 +2146,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; @@ -2202,7 +2202,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)) { @@ -2219,7 +2219,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]); } } @@ -2227,14 +2227,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; @@ -2266,7 +2266,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, @@ -2456,7 +2456,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; } } @@ -2476,7 +2476,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; } } @@ -2488,7 +2488,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; } @@ -2496,7 +2496,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. */ @@ -2780,7 +2780,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++) { @@ -2789,7 +2789,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]); @@ -2804,12 +2804,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 @@ -2841,7 +2841,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, @@ -2850,7 +2850,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); @@ -2874,7 +2874,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; @@ -2906,9 +2906,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]); } @@ -3725,7 +3725,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; @@ -3743,7 +3743,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)); } } @@ -4484,7 +4484,7 @@ 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; @@ -4505,16 +4505,16 @@ 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; } } } @@ -4563,7 +4563,7 @@ 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, GetTableAmRoutine(cstate->rel->rd_tam_type)); if (loaded_oid != InvalidOid) HeapTupleSetOid((HeapTuple)tuple, loaded_oid); @@ -5523,7 +5523,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; @@ -5586,15 +5586,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 */ @@ -5626,9 +5626,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 { @@ -5883,7 +5883,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; @@ -5911,7 +5911,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. @@ -6045,7 +6045,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; @@ -6178,7 +6178,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) { @@ -6203,9 +6203,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) @@ -6312,9 +6312,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; @@ -8005,12 +8005,12 @@ static void CopyNonEncodingAttributeOut(CopyState cstate, char* string, bool use 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); } @@ -8038,12 +8038,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; @@ -8061,15 +8061,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; } } @@ -8103,10 +8103,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; } } @@ -9288,7 +9288,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; @@ -9350,9 +9350,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]); } @@ -10064,10 +10064,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; } } @@ -10178,10 +10178,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))); diff --git a/src/gausskernel/optimizer/commands/createas.cpp b/src/gausskernel/optimizer/commands/createas.cpp index 9134c78dc..e1e0ed4d6 100644 --- a/src/gausskernel/optimizer/commands/createas.cpp +++ b/src/gausskernel/optimizer/commands/createas.cpp @@ -333,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); diff --git a/src/gausskernel/optimizer/commands/explain.cpp b/src/gausskernel/optimizer/commands/explain.cpp index aae2b52bf..b7d0ea7a2 100755 --- a/src/gausskernel/optimizer/commands/explain.cpp +++ b/src/gausskernel/optimizer/commands/explain.cpp @@ -602,7 +602,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) { @@ -9698,7 +9698,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; @@ -9742,7 +9742,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); @@ -9824,7 +9824,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; @@ -10695,7 +10695,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); diff --git a/src/gausskernel/optimizer/commands/formatter.cpp b/src/gausskernel/optimizer/commands/formatter.cpp index 9a810d03f..a6c812eec 100644 --- a/src/gausskernel/optimizer/commands/formatter.cpp +++ b/src/gausskernel/optimizer/commands/formatter.cpp @@ -339,7 +339,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) @@ -352,7 +352,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(cstate, colname, descs + i); pfree_ext(colname); } @@ -370,11 +370,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; } diff --git a/src/gausskernel/optimizer/commands/indexcmds.cpp b/src/gausskernel/optimizer/commands/indexcmds.cpp old mode 100755 new mode 100644 index fe0211950..15a7a839c --- a/src/gausskernel/optimizer/commands/indexcmds.cpp +++ b/src/gausskernel/optimizer/commands/indexcmds.cpp @@ -280,7 +280,7 @@ bool CheckIndexCompatible(Oid oldId, char* accessMethodName, List* attributeList irel = index_open(oldId, AccessShareLock); /* caller probably has a lock */ for (i = 0; i < old_natts; i++) { if (IsPolymorphicType(get_opclass_input_type(classObjectId[i])) && - irel->rd_att->attrs[i]->atttypid != typeObjectId[i]) { + irel->rd_att->attrs[i].atttypid != typeObjectId[i]) { ret = false; break; } @@ -302,7 +302,7 @@ bool CheckIndexCompatible(Oid oldId, char* accessMethodName, List* attributeList op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right); if ((IsPolymorphicType(left) || IsPolymorphicType(right)) && - irel->rd_att->attrs[i]->atttypid != typeObjectId[i]) { + irel->rd_att->attrs[i].atttypid != typeObjectId[i]) { ret = false; break; } @@ -325,7 +325,7 @@ static void CheckPartitionUniqueKey(Relation rel, int2vector *partKey, IndexStmt for (j = 0; j < partKey->dim1; j++) { int2 attNum = partKey->values[j]; - Form_pg_attribute att_tup = rel->rd_att->attrs[attNum - 1]; + Form_pg_attribute att_tup = &rel->rd_att->attrs[attNum - 1]; if (!columnIsExist(rel, att_tup, stmt->indexParams)) { ereport( @@ -5417,7 +5417,7 @@ static bool CheckIdxParamsOwnPartKey(Relation rel, const List* indexParams) int2vector* partKey = ((RangePartitionMap*)rel->partMap)->partitionKey; for (int i = 0; i < partKey->dim1; i++) { int2 attNum = partKey->values[i]; - Form_pg_attribute attTup = rel->rd_att->attrs[attNum - 1]; + Form_pg_attribute attTup = &rel->rd_att->attrs[attNum - 1]; if (!columnIsExist(rel, attTup, indexParams)) { return false; } diff --git a/src/gausskernel/optimizer/commands/matview.cpp b/src/gausskernel/optimizer/commands/matview.cpp index 4c8cfa249..299979d6e 100755 --- a/src/gausskernel/optimizer/commands/matview.cpp +++ b/src/gausskernel/optimizer/commands/matview.cpp @@ -603,7 +603,7 @@ static bool mlog_form_tuple(Relation mlog, HeapTuple mlogTup, Relation rel, Heap Datum rel_values[rel->rd_att->natts] = {0}; bool rel_nulls[rel->rd_att->natts] = {0}; for (i = 0, j = 0; i < rel->rd_att->natts; i++) { - if (rel->rd_att->attrs[i]->attisdropped) { + if (rel->rd_att->attrs[i].attisdropped) { rel_nulls[i] = true; } else { rel_values[i] = values[MlogAttributeNum + j]; @@ -1613,12 +1613,12 @@ static Oid create_mlog_table(Oid relid) tablespaceid = rel->rd_rel->reltablespace; TupleDesc relDesc = rel->rd_att; - Form_pg_attribute* relAtts = relDesc->attrs; + FormData_pg_attribute* relAtts = relDesc->attrs; int relAttnumAll = relDesc->natts; int relAttnum = relDesc->natts; for (i = 0; i < relAttnumAll; i++) { - if (relAtts[i]->attisdropped) { + if (relAtts[i].attisdropped) { relAttnum--; } } @@ -1630,20 +1630,20 @@ static Oid create_mlog_table(Oid relid) TupleDescInitEntry(tupdesc, (AttrNumber)MlogAttributeXid, "xid", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)MlogAttributeSeqno, "seqno", INT8OID, -1, 0); - tupdesc->attrs[MlogAttributeAction - 1]->attstorage = 'p'; - tupdesc->attrs[MlogAttributeTime - 1]->attstorage = 'p'; - tupdesc->attrs[MlogAttributeCtid - 1]->attstorage = 'p'; - tupdesc->attrs[MlogAttributeXid - 1]->attstorage = 'p'; - tupdesc->attrs[MlogAttributeSeqno - 1]->attstorage = 'p'; + tupdesc->attrs[MlogAttributeAction - 1].attstorage = 'p'; + tupdesc->attrs[MlogAttributeTime - 1].attstorage = 'p'; + tupdesc->attrs[MlogAttributeCtid - 1].attstorage = 'p'; + tupdesc->attrs[MlogAttributeXid - 1].attstorage = 'p'; + tupdesc->attrs[MlogAttributeSeqno - 1].attstorage = 'p'; for (i = 1, j = 1; i <= relAttnumAll; i++) { - if (relAtts[i - 1]->attisdropped) { + if (relAtts[i - 1].attisdropped) { continue; } TupleDescInitEntry(tupdesc, (AttrNumber)MlogAttributeNum + j, - NameStr(relAtts[i - 1]->attname), relAtts[i - 1]->atttypid, - relAtts[i - 1]->atttypmod, relAtts[i - 1]->attndims); - tupdesc->attrs[MlogAttributeNum + j - 1]->attstorage = relAtts[i - 1]->attstorage; + NameStr(relAtts[i - 1].attname), relAtts[i - 1].atttypid, + relAtts[i - 1].atttypmod, relAtts[i - 1].attndims); + tupdesc->attrs[MlogAttributeNum + j - 1].attstorage = relAtts[i - 1].attstorage; j++; } @@ -1738,7 +1738,7 @@ static Oid create_mlog_table(Oid relid) List *colnames = NIL; for (int i = 0; i < tupdesc->natts; i++) { - Form_pg_attribute attr = tupdesc->attrs[i]; + Form_pg_attribute attr = &tupdesc->attrs[i]; if(IsTypeDistributable(attr->atttypid)) { Value *colValue = makeString(pstrdup(attr->attname.data)); colnames = lappend(colnames, colValue); @@ -1866,11 +1866,11 @@ Oid create_matview_map(Oid matviewoid) TupleDescInitEntry(tupdesc, (AttrNumber)MatMapAttributeRelctid, "rel_ctid", TIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)MatMapAttributeRelxid, "rel_xid", XIDOID, -1, 0); - tupdesc->attrs[0]->attstorage = 'p'; - tupdesc->attrs[1]->attstorage = 'p'; - tupdesc->attrs[2]->attstorage = 'p'; - tupdesc->attrs[3]->attstorage = 'p'; - tupdesc->attrs[4]->attstorage = 'p'; + tupdesc->attrs[0].attstorage = 'p'; + tupdesc->attrs[1].attstorage = 'p'; + tupdesc->attrs[2].attstorage = 'p'; + tupdesc->attrs[3].attstorage = 'p'; + tupdesc->attrs[4].attstorage = 'p'; /* add internal_mask_enable */ reloptions = AddInternalOption(reloptions, INTERNAL_MASK_DDELETE | @@ -2097,7 +2097,7 @@ void insert_into_mlog_table(Relation rel, Oid mlogid, HeapTuple tuple, ItemPoint int relAttnumAll = relDesc->natts; int relAttnum = relDesc->natts; for (i = 0; i < relAttnumAll; i++) { - if (relDesc->attrs[i]->attisdropped) { + if (relDesc->attrs[i].attisdropped) { relAttnum--; } } @@ -2144,7 +2144,7 @@ void insert_into_mlog_table(Relation rel, Oid mlogid, HeapTuple tuple, ItemPoint heap_deform_tuple(tuple, relDesc, rel_values, rel_isnulls); for (i = 0, j = 0; i < relAttnumAll; i++) { - if (relDesc->attrs[i]->attisdropped) { + if (relDesc->attrs[i].attisdropped) { ereport(DEBUG5, (errmodule(MOD_OPT), errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Skip dropped column %d on base table when insert into mlog table", i))); diff --git a/src/gausskernel/optimizer/commands/prepare.cpp b/src/gausskernel/optimizer/commands/prepare.cpp index a91ebb96d..a83afe0d6 100755 --- a/src/gausskernel/optimizer/commands/prepare.cpp +++ b/src/gausskernel/optimizer/commands/prepare.cpp @@ -1408,7 +1408,7 @@ Datum pg_prepared_statement(PG_FUNCTION_ARGS) * build tupdesc for result tuples. This must match the definition of the * pg_prepared_statements view in system_views.sql */ - tupdesc = CreateTemplateTupleDesc(5, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(5, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "name", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "statement", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "prepare_time", TIMESTAMPTZOID, -1, 0); diff --git a/src/gausskernel/optimizer/commands/sequence/sequence.cpp b/src/gausskernel/optimizer/commands/sequence/sequence.cpp index b6d95a22e..784f556d2 100644 --- a/src/gausskernel/optimizer/commands/sequence/sequence.cpp +++ b/src/gausskernel/optimizer/commands/sequence/sequence.cpp @@ -289,7 +289,7 @@ void gen_uuid_for_CreateStmt(CreateStmt* stmt, List* uuids) constr = tupleDesc->constr; for (int 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]; if (attribute->attisdropped && !u_sess->attr.attr_sql.enable_cluster_resize) continue; @@ -2468,7 +2468,7 @@ Datum pg_sequence_parameters(PG_FUNCTION_ARGS) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied for sequence %s", RelationGetRelationName(seqrel)))); - tupdesc = CreateTemplateTupleDesc(5, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(5, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "start_value", INT16OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "minimum_value", INT16OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "maximum_value", INT16OID, -1, 0); @@ -2527,7 +2527,7 @@ Datum pg_sequence_last_value(PG_FUNCTION_ARGS) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied for sequence %s", RelationGetRelationName(seqrel)))); - tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "cache_value", INT16OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "last_value", INT16OID, -1, 0); diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index ff57ec77c..43043b71f 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -628,17 +628,17 @@ static void RangeVarCallbackForAlterRelation( static bool isQueryUsingTempRelation_walker(Node *node, void *context); static bool CheckRangePartitionKeyType(Oid typoid); -static void CheckRangePartitionKeyType(Form_pg_attribute* attrs, List* pos); +static void CheckRangePartitionKeyType(FormData_pg_attribute* attrs, List* pos); static bool CheckListPartitionKeyType(Oid typoid); -static void CheckListPartitionKeyType(Form_pg_attribute* attrs, List* pos); +static void CheckListPartitionKeyType(FormData_pg_attribute* attrs, List* pos); static bool CheckHashPartitionKeyType(Oid typoid); -static void CheckHashPartitionKeyType(Form_pg_attribute* attrs, List* pos); +static void CheckHashPartitionKeyType(FormData_pg_attribute* attrs, List* pos); -static void CheckIntervalPartitionKeyType(Form_pg_attribute* attrs, List* pos); +static void CheckIntervalPartitionKeyType(FormData_pg_attribute* attrs, List* pos); static void CheckIntervalValue( - const Form_pg_attribute* attrs, const List* pos, const IntervalPartitionDefState* intervalPartDef); + const FormData_pg_attribute* attrs, const List* pos, const IntervalPartitionDefState* intervalPartDef); static void CheckPartitionTablespace(const char* spcname, Oid owner); static Const* GetListPartitionValue(Form_pg_attribute attrs, List* value, bool partkeyIsFunc = false); static bool ConfirmTypeInfo(Oid* target_oid, int* target_mod, Const* src, Form_pg_attribute attrs, bool isinterval); @@ -2657,7 +2657,7 @@ Oid DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId, bool isCTAS) #ifdef ENABLE_MOT if (isMot) { - DetermineColumnCollationForMOTTable(&descriptor->attrs[attnum - 1]->attcollation); + DetermineColumnCollationForMOTTable(&descriptor->attrs[attnum - 1].attcollation); } #endif @@ -2715,7 +2715,7 @@ Oid DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId, bool isCTAS) rawEnt->generatedCol = colDef->generatedCol; rawEnt->update_expr = colDef->update_default; rawDefaults = lappend(rawDefaults, rawEnt); - descriptor->attrs[attnum - 1]->atthasdef = true; + descriptor->attrs[attnum - 1].atthasdef = true; } else if (colDef->cooked_default != NULL || colDef->update_default != NULL) { CookedConstraint* cooked = NULL; @@ -2734,7 +2734,7 @@ Oid DefineRelation(CreateStmt* stmt, char relkind, Oid ownerId, bool isCTAS) cooked->is_no_inherit = false; cooked->update_expr = colDef->update_default; cookedDefaults = lappend(cookedDefaults, cooked); - descriptor->attrs[attnum - 1]->atthasdef = true; + descriptor->attrs[attnum - 1].atthasdef = true; } if (colDef->clientLogicColumnRef != NULL) { CeHeapInfo *ceHeapInfo = NULL; @@ -3089,8 +3089,8 @@ static List *TryGetTypeNeedDrop(Relation rel) TupleDesc tupDesc = rel->rd_att; for (int i = 0; i < tupDesc->natts; i++) { - if (!tupDesc->attrs[i]->attisdropped && type_is_set(tupDesc->attrs[i]->atttypid)) { - typlist = lappend(typlist, &tupDesc->attrs[i]->atttypid); + if (!tupDesc->attrs[i].attisdropped && type_is_set(tupDesc->attrs[i].atttypid)) { + typlist = lappend(typlist, &tupDesc->attrs[i].atttypid); } } @@ -5069,7 +5069,7 @@ static List* MergeAttributes( newattno = (AttrNumber*)palloc0(tupleDesc->natts * sizeof(AttrNumber)); 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); int exist_attno; ColumnDef* def = NULL; @@ -8959,7 +8959,7 @@ static T EvaluateGenExpr(AlteredTableInfo* tab, T tuple, if (amtype == TAM_HEAP) { tup = (T)heap_form_tuple(newTupDesc, values, isnull); } else { - tup = (T)tableam_tops_form_tuple(newTupDesc, values, isnull, UHEAP_TUPLE); + tup = (T)tableam_tops_form_tuple(newTupDesc, values, isnull, TableAmUstore); } } } @@ -9051,7 +9051,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat * pretty cheap test anyway. */ for (i = 0; i < newTupDesc->natts; i++) { - if (newTupDesc->attrs[i]->attnotnull && !newTupDesc->attrs[i]->attisdropped) + if (newTupDesc->attrs[i].attnotnull && !newTupDesc->attrs[i].attisdropped) notnull_attrs = lappend_int(notnull_attrs, i); } if (notnull_attrs != NULL) @@ -9114,7 +9114,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat * attributes to avoid needing to do so in the per-tuple loop. */ for (i = 0; i < newTupDesc->natts; i++) { - if (newTupDesc->attrs[i]->attisdropped) + if (newTupDesc->attrs[i].attisdropped) dropped_attrs = lappend_int(dropped_attrs, i); } @@ -9135,7 +9135,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat * dependent on each tuple. */ isnull[i] = false; - values[i] = fetchatt(newTupDesc->attrs[i], defvals[i].datum); + values[i] = fetchatt(&newTupDesc->attrs[i], defvals[i].datum); } } } @@ -9196,7 +9196,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat * Form the new tuple. Note that we don't explicitly pfree it, * since the per-tuple memory context will be reset shortly. */ - utuple = (UHeapTuple)tableam_tops_form_tuple(newTupDesc, values, isnull, UHEAP_TUPLE); + utuple = (UHeapTuple)tableam_tops_form_tuple(newTupDesc, values, isnull, TableAmUstore); } /* Now check any constraints on the possibly-changed tuple */ @@ -9221,7 +9221,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), errmsg("column \"%s\" contains null values", - NameStr(newTupDesc->attrs[attn]->attname)))); + NameStr(newTupDesc->attrs[attn].attname)))); } foreach(l, tab->constraints) @@ -9299,7 +9299,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat if (ex->is_generated) { continue; } - if (ex->is_autoinc && newTupDesc->attrs[ex->attnum - 1]->attnotnull) { + if (ex->is_autoinc && newTupDesc->attrs[ex->attnum - 1].attnotnull) { values[ex->attnum - 1] = GetAutoIncrementDatum(oldrel, newTupDesc); isnull[ex->attnum - 1] = false; } else { @@ -9338,7 +9338,7 @@ static void ATRewriteTableInternal(AlteredTableInfo* tab, Relation oldrel, Relat */ if (relationAttIsNull(tuple, attn + 1, newTupDesc)) ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), - errmsg("column \"%s\" contains null values", NameStr(newTupDesc->attrs[attn]->attname)))); + errmsg("column \"%s\" contains null values", NameStr(newTupDesc->attrs[attn].attname)))); } foreach (l, tab->constraints) { @@ -9452,7 +9452,7 @@ static void ATOnlyCheckCStoreTable(const AlteredTableInfo* tab, Relation rel) * If we added any new NOT NULL constraints, check all not-null constraints. */ for (int i = 0; i < newTupDesc->natts; i++) { - if (newTupDesc->attrs[i]->attnotnull && !newTupDesc->attrs[i]->attisdropped) + if (newTupDesc->attrs[i].attnotnull && !newTupDesc->attrs[i].attisdropped) notnullAttrs = lappend_int(notnullAttrs, i); } if (notnullAttrs != NULL) @@ -9488,7 +9488,7 @@ static void ATOnlyCheckCStoreTable(const AlteredTableInfo* tab, Relation rel) if (vec[attn].IsNull(rowIdx)) { ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), - errmsg("column \"%s\" contains null values", NameStr(newTupDesc->attrs[attn]->attname)))); + errmsg("column \"%s\" contains null values", NameStr(newTupDesc->attrs[attn].attname)))); } } } @@ -9767,7 +9767,7 @@ void find_composite_type_dependencies(Oid typeOid, Relation origRelation, const continue; rel = relation_open(pg_depend->objid, AccessShareLock); - att = rel->rd_att->attrs[pg_depend->objsubid - 1]; + att = &rel->rd_att->attrs[pg_depend->objsubid - 1]; if (rel->rd_rel->relkind == RELKIND_RELATION || rel->rd_rel->relkind == RELKIND_MATVIEW) { if (origTypeName != NULL) @@ -11179,7 +11179,7 @@ static void ATPrepDropColumn( static bool CheckLastColumn(Relation rel, AttrNumber attrnum) { for (int col = 0; col < rel->rd_att->natts; ++col) { - if (rel->rd_att->attrs[col]->attisdropped) + if (rel->rd_att->attrs[col].attisdropped) continue; if (ISGENERATEDCOL(rel->rd_att, col)) continue; @@ -12219,7 +12219,7 @@ static void ATAddForeignKeyConstraint(AlteredTableInfo* tab, Relation rel, Const * column types to the right (foreign) operand type of the pfeqop. * We may assume that pg_constraint.conkey is not changing. */ - old_fktype = tab->oldDesc->attrs[fkattnum[i] - 1]->atttypid; + old_fktype = tab->oldDesc->attrs[fkattnum[i] - 1].atttypid; new_fktype = fktype; old_pathtype = findFkeyCast(pfeqop_right, old_fktype, &old_castfunc); new_pathtype = findFkeyCast(pfeqop_right, new_fktype, &new_castfunc); @@ -13428,7 +13428,7 @@ static void CheckHugeToastInternal(TupleDesc reldesc, Relation rel, AttrNumber a void CheckHugeToast(AlteredTableInfo *tab, Relation rel, AttrNumber attnum) { TupleDesc reldesc = tab->oldDesc; - Form_pg_attribute attr = reldesc->attrs[attnum - 1]; + Form_pg_attribute attr = &reldesc->attrs[attnum - 1]; if (attr->atttypid != CLOBOID && attr->atttypid != BLOBOID) { return; @@ -13826,8 +13826,8 @@ static void ATExecAlterColumnType(AlteredTableInfo* tab, Relation rel, AlterTabl } /* Check for multiple ALTER TYPE on same column --- can't cope */ - if (attTup->atttypid != tab->oldDesc->attrs[attnum - 1]->atttypid || - attTup->atttypmod != tab->oldDesc->attrs[attnum - 1]->atttypmod) + if (attTup->atttypid != tab->oldDesc->attrs[attnum - 1].atttypid || + attTup->atttypmod != tab->oldDesc->attrs[attnum - 1].atttypmod) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot alter type of column \"%s\" twice", colName))); @@ -14659,8 +14659,8 @@ static void AlterTypeOwnerByTbl(Relation target_rel, Oid newOwnerId) Form_pg_type typeForm; for (int i = 0; i < tupDesc->natts; i++) { - if (!tupDesc->attrs[i]->attisdropped && type_is_set(tupDesc->attrs[i]->atttypid)) { - Oid atttypid = tupDesc->attrs[i]->atttypid; + if (!tupDesc->attrs[i].attisdropped && type_is_set(tupDesc->attrs[i].atttypid)) { + Oid atttypid = tupDesc->attrs[i].atttypid; tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(atttypid)); if (!HeapTupleIsValid(tuple)) { @@ -16590,7 +16590,7 @@ static void mergeHeapBlock(Relation src, Relation dest, ForkNumber forkNum, char struct varlena* value = NULL; value = (struct varlena*)DatumGetPointer(values[i]); - if (srcTupleDesc->attrs[i]->attlen == -1 && !isNull[i] && VARATT_IS_EXTERNAL(value)) { + if (srcTupleDesc->attrs[i].attlen == -1 && !isNull[i] && VARATT_IS_EXTERNAL(value)) { struct varatt_external* toastPointer = NULL; toastPointer = (varatt_external*)(VARDATA_EXTERNAL((varattrib_1b_e*)(value))); @@ -17069,7 +17069,7 @@ static void MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel) parent_natts = tupleDesc->natts; for (parent_attno = 1; parent_attno <= parent_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); /* Ignore dropped columns in the parent. */ @@ -17499,7 +17499,7 @@ static void ATExecAddOf(Relation rel, const TypeName* ofTypename, LOCKMODE lockm const char* table_attname = NULL; /* Get the next non-dropped type attribute. */ - type_attr = typeTupleDesc->attrs[type_attno - 1]; + type_attr = &typeTupleDesc->attrs[type_attno - 1]; if (type_attr->attisdropped) continue; type_attname = NameStr(type_attr->attname); @@ -17509,7 +17509,7 @@ static void ATExecAddOf(Relation rel, const TypeName* ofTypename, LOCKMODE lockm if (table_attno > tableTupleDesc->natts) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("table is missing column \"%s\"", type_attname))); - table_attr = tableTupleDesc->attrs[table_attno++ - 1]; + table_attr = &tableTupleDesc->attrs[table_attno++ - 1]; } while (table_attr->attisdropped); table_attname = NameStr(table_attr->attname); @@ -17532,7 +17532,7 @@ static void ATExecAddOf(Relation rel, const TypeName* ofTypename, LOCKMODE lockm /* Any remaining columns at the end of the table had better be dropped. */ for (; table_attno <= tableTupleDesc->natts; table_attno++) { - Form_pg_attribute table_attr = tableTupleDesc->attrs[table_attno - 1]; + Form_pg_attribute table_attr = &tableTupleDesc->attrs[table_attno - 1]; if (!table_attr->attisdropped) ereport(ERROR, @@ -17835,7 +17835,7 @@ static void ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt* stmt, LOCKM ((errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("internal column %d in unique index \"%s\"", attno, RelationGetRelationName(indexRel))))); - attr = rel->rd_att->attrs[attno - 1]; + attr = &rel->rd_att->attrs[attno - 1]; if (!attr->attnotnull) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -18336,7 +18336,7 @@ static bool checkColumnTypeIsBytea(Relation rel) TupleDesc tupdesc = RelationGetDescr(rel); for (tupIndex = 0; tupIndex < tupdesc->natts; tupIndex++) { - Form_pg_attribute attr = tupdesc->attrs[tupIndex]; + Form_pg_attribute attr = &tupdesc->attrs[tupIndex]; if (BYTEAOID == attr->atttypid) { return true; } @@ -18773,8 +18773,8 @@ void AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid, Object /* Change the table's set type too */ TupleDesc tupDesc = rel->rd_att; for (int i = 0; i < tupDesc->natts; i++) { - if (!tupDesc->attrs[i]->attisdropped && type_is_set(tupDesc->attrs[i]->atttypid)) { - (void)AlterTypeNamespaceInternal(tupDesc->attrs[i]->atttypid, nspOid, false, false, objsMoved); + if (!tupDesc->attrs[i].attisdropped && type_is_set(tupDesc->attrs[i].atttypid)) { + (void)AlterTypeNamespaceInternal(tupDesc->attrs[i].atttypid, nspOid, false, false, objsMoved); } } @@ -19542,7 +19542,7 @@ List* GetPartitionkeyPos(List* partitionkeys, List* schema, bool* partkeyIsFunc) * Description : * Notes : */ -static void CheckRangePartitionKeyType(Form_pg_attribute* attrs, List* pos) +static void CheckRangePartitionKeyType(FormData_pg_attribute* attrs, List* pos) { int location = 0; ListCell* cell = NULL; @@ -19551,7 +19551,7 @@ static void CheckRangePartitionKeyType(Form_pg_attribute* attrs, List* pos) bool result = false; location = lfirst_int(cell); - typoid = attrs[location]->atttypid; + typoid = attrs[location].atttypid; /* check datatype for range partitionkey */ result = CheckRangePartitionKeyType(typoid); @@ -19560,12 +19560,12 @@ static void CheckRangePartitionKeyType(Form_pg_attribute* attrs, List* pos) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column %s cannot serve as a range partitioning column because of its datatype", - NameStr(attrs[location]->attname)))); + NameStr(attrs[location].attname)))); } } } -static void CheckListPartitionKeyType(Form_pg_attribute* attrs, List* pos) +static void CheckListPartitionKeyType(FormData_pg_attribute* attrs, List* pos) { if (pos == NULL || attrs == NULL) { ereport(ERROR, (errcode(ERRCODE_INVALID_OPERATION), errmsg("invalid list partiiton table definition"))); @@ -19573,14 +19573,14 @@ static void CheckListPartitionKeyType(Form_pg_attribute* attrs, List* pos) Oid typeOid = InvalidOid; ListCell* lhead = pos->head; int location = lfirst_int(lhead); - typeOid = attrs[location]->atttypid; + typeOid = attrs[location].atttypid; /* 1. Check datatype for head of partitionkey list */ if (!CheckListPartitionKeyType(typeOid)) { list_free_ext(pos); ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column %s cannot serve as a list partitioning column because of its datatype", - NameStr(attrs[location]->attname)))); + NameStr(attrs[location].attname)))); } /* 2. Check if datatype of partition keys are same */ @@ -19588,16 +19588,16 @@ static void CheckListPartitionKeyType(Form_pg_attribute* attrs, List* pos) ListCell* cell = NULL; foreach (cell, pos) { location = lfirst_int(cell); - if (!can_coerce_type(1, &(attrs[location]->atttypid), &typeOid, COERCION_IMPLICIT)) { + if (!can_coerce_type(1, &(attrs[location].atttypid), &typeOid, COERCION_IMPLICIT)) { list_free_ext(pos); ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column %s cannot serve as a list partitioning column because of its datatype", - NameStr(attrs[location]->attname)))); + NameStr(attrs[location].attname)))); } } } -static void CheckHashPartitionKeyType(Form_pg_attribute* attrs, List* pos) +static void CheckHashPartitionKeyType(FormData_pg_attribute* attrs, List* pos) { int location = 0; ListCell* cell = NULL; @@ -19605,43 +19605,43 @@ static void CheckHashPartitionKeyType(Form_pg_attribute* attrs, List* pos) foreach (cell, pos) { location = lfirst_int(cell); - typeOid = attrs[location]->atttypid; + typeOid = attrs[location].atttypid; /* Check datatype for hash partitionkey */ if (!CheckHashPartitionKeyType(typeOid)) { list_free_ext(pos); ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column %s cannot serve as a hash partitioning column because of its datatype", - NameStr(attrs[location]->attname)))); + NameStr(attrs[location].attname)))); } } } -static void CheckIntervalPartitionKeyType(Form_pg_attribute* attrs, List* pos) +static void CheckIntervalPartitionKeyType(FormData_pg_attribute* attrs, List* pos) { /* must be one partitionkey for interval partition, have checked before */ Assert(pos->length == 1); ListCell* cell = list_head(pos); int location = lfirst_int(cell); - Oid typoid = attrs[location]->atttypid; + Oid typoid = attrs[location].atttypid; if (typoid != TIMESTAMPOID && typoid != TIMESTAMPTZOID && typoid != DATEOID) { list_free_ext(pos); ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column %s cannot serve as a interval partitioning column because of its datatype", - NameStr(attrs[location]->attname)))); + NameStr(attrs[location].attname)))); } } static void CheckIntervalValue( - const Form_pg_attribute* attrs, const List* pos, const IntervalPartitionDefState* intervalPartDef) + const FormData_pg_attribute* attrs, const List* pos, const IntervalPartitionDefState* intervalPartDef) { /* must be one partitionkey for interval partition, have checked before */ Assert(pos->length == 1); ListCell* cell = list_head(pos); int location = lfirst_int(cell); - Oid typoid = attrs[location]->atttypid; + Oid typoid = attrs[location].atttypid; if (typoid != DATEOID) { return; } @@ -19665,7 +19665,7 @@ static void CheckIntervalValue( * Description : * Notes : */ -void CheckValuePartitionKeyType(Form_pg_attribute* attrs, List* pos) +void CheckValuePartitionKeyType(FormData_pg_attribute* attrs, List* pos) { int location = 0; ListCell* cell = NULL; @@ -19673,7 +19673,7 @@ void CheckValuePartitionKeyType(Form_pg_attribute* attrs, List* pos) foreach (cell, pos) { location = lfirst_int(cell); - typoid = attrs[location]->atttypid; + typoid = attrs[location].atttypid; /* * Check datatype for partitionkey NOTE: currently we reuse distribution * key's restriction as value-based parition is equal-evaluated we can't @@ -19689,8 +19689,8 @@ void CheckValuePartitionKeyType(Form_pg_attribute* attrs, List* pos) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("column \"%s\" cannot be served as a value-partitioning column because of its datatype [%s]", - NameStr(attrs[location]->attname), - format_type_with_typemod(attrs[location]->atttypid, attrs[location]->atttypmod)))); + NameStr(attrs[location].attname), + format_type_with_typemod(attrs[location].atttypid, attrs[location].atttypmod)))); } } } @@ -19922,7 +19922,7 @@ static Const* GetListPartitionValue(Form_pg_attribute attrs, List* value, bool p * Description : * Notes : the invoker should free the arry */ -Const* GetPartitionValue(List* pos, Form_pg_attribute* attrs, List* value, bool isinterval, bool isPartition, bool partkeyIsFunc) +Const* GetPartitionValue(List* pos, FormData_pg_attribute* attrs, List* value, bool isinterval, bool isPartition, bool partkeyIsFunc) { Const* result = NULL; Const* cell = NULL; @@ -19964,7 +19964,7 @@ Const* GetPartitionValue(List* pos, Form_pg_attribute* attrs, List* value, bool } /* transform the const to target datatype */ - target_expr = (Const*)GetTargetValue(attrs[valuepos], cell, isinterval, partkeyIsFunc); + target_expr = (Const*)GetTargetValue(&attrs[valuepos], cell, isinterval, partkeyIsFunc); if (target_expr == NULL) { pfree_ext(result); list_free_ext(pos); @@ -19980,7 +19980,7 @@ Const* GetPartitionValue(List* pos, Form_pg_attribute* attrs, List* value, bool int target_mod = -1; result[count].constcollid = GetPartkeyExprType(&target_oid, &target_mod); } else { - result[count].constcollid = attrs[valuepos]->attcollation; + result[count].constcollid = attrs[valuepos].attcollation; } count++; @@ -20112,7 +20112,7 @@ static void ReportListPartitionIntersect(const List* partitionList, Const* value } } -void CompareListValue(const List* pos, Form_pg_attribute* attrs, List *partitionList, bool partkeyIsFunc) +void CompareListValue(const List* pos, FormData_pg_attribute* attrs, List *partitionList, bool partkeyIsFunc) { if (pos == NULL || attrs == NULL) { ereport(ERROR, (errcode(ERRCODE_INVALID_OPERATION), errmsg("invalid list partiiton table definition"))); @@ -20121,7 +20121,7 @@ void CompareListValue(const List* pos, Form_pg_attribute* attrs, List *partition Oid typeOid = InvalidOid; ListCell* lhead = pos->head; int location = lfirst_int(lhead); - typeOid = attrs[location]->atttypid; + typeOid = attrs[location].atttypid; List* partValue = NIL; ListCell* valueCell = NULL; @@ -20154,7 +20154,7 @@ void CompareListValue(const List* pos, Form_pg_attribute* attrs, List *partition } } partValueLen[partListIdx] = partValue->length; - valueArray[partListIdx] = GetListPartitionValue(attrs[location], partValue, partkeyIsFunc); + valueArray[partListIdx] = GetListPartitionValue(&attrs[location], partValue, partkeyIsFunc); ++partListIdx; } @@ -20198,7 +20198,7 @@ void CompareListValue(const List* pos, Form_pg_attribute* attrs, List *partition * Description : * Notes : */ -void ComparePartitionValue(List* pos, Form_pg_attribute* attrs, List *partitionList, bool isPartition, bool partkeyIsFunc) +void ComparePartitionValue(List* pos, FormData_pg_attribute* attrs, List *partitionList, bool isPartition, bool partkeyIsFunc) { Const* pre_value = NULL; Const* cur_value = NULL; @@ -23385,7 +23385,7 @@ static void replaceRepeatChunkId(HTAB* chunkIdHashTable, List* srcPartToastRels) HeapTuple copyTuple = NULL; values[0] = mapping->newChunkId; - copyTuple = (HeapTuple)tableam_tops_form_tuple(tupleDesc, values, isNull, tupleDesc->tdTableAmType); + copyTuple = (HeapTuple)tableam_tops_form_tuple(tupleDesc, values, isNull, tupleDesc->td_tam_ops); simple_heap_delete(srcPartToastRel, &((HeapTuple)tuple)->t_self); (void)simple_heap_insert(srcPartToastRel, copyTuple); @@ -23413,7 +23413,7 @@ static void replaceRepeatChunkId(HTAB* chunkIdHashTable, List* srcPartToastRels) values[0] = newChunkId; - copyTuple = (HeapTuple)tableam_tops_form_tuple(tupleDesc, values, isNull, tupleDesc->tdTableAmType); + copyTuple = (HeapTuple)tableam_tops_form_tuple(tupleDesc, values, isNull, tupleDesc->td_tam_ops); simple_heap_delete(srcPartToastRel, &((HeapTuple)tuple)->t_self); (void)simple_heap_insert(srcPartToastRel, copyTuple); @@ -24606,7 +24606,7 @@ static void checkValidationForExchangeCStore(Relation partTableRel, Relation ord ScalarValue* pVals = NULL; Datum* values = NULL; bool* nulls = NULL; - Form_pg_attribute* attrs = ordTableRel->rd_att->attrs; + FormData_pg_attribute* attrs = ordTableRel->rd_att->attrs; Const consts[RANGE_PARTKEYMAXNUM]; Const* partKeyValues[RANGE_PARTKEYMAXNUM]; @@ -24630,7 +24630,7 @@ static void checkValidationForExchangeCStore(Relation partTableRel, Relation ord scanAttrNumbers = (AttrNumber*)palloc(sizeof(AttrNumber) * scanColNum); for (int i = 0; i < (scanColNum - 2); i++) { - scanAttrNumbers[i] = attrs[i]->attnum; + scanAttrNumbers[i] = attrs[i].attnum; } // ctid for delete @@ -24695,10 +24695,10 @@ static void checkValidationForExchangeCStore(Relation partTableRel, Relation ord if (pVec->m_desc.encoded == false) values[partkeyIdx] = pVals[row]; else { - Assert(attrs[col]->attlen < 0 || attrs[col]->attlen > 8); + Assert(attrs[col].attlen < 0 || attrs[col].attlen > 8); Datum v = ScalarVector::Decode(pVals[row]); values[partkeyIdx] = - (attrs[col]->attlen < 0) ? v : PointerGetDatum((char*)v + VARHDRSZ_SHORT); + (attrs[col].attlen < 0) ? v : PointerGetDatum((char*)v + VARHDRSZ_SHORT); } } @@ -26447,7 +26447,7 @@ static void readTuplesAndInsert(Relation tempTableRel, Relation partTableRel) } } -List* transformIntoTargetType(Form_pg_attribute* attrs, int2 keypos, List* boundary) +List* transformIntoTargetType(FormData_pg_attribute* attrs, int2 keypos, List* boundary) { Node* nodeBoundaryItem = NULL; Const* constBoundaryItem = NULL; @@ -26462,15 +26462,15 @@ List* transformIntoTargetType(Form_pg_attribute* attrs, int2 keypos, List* bound if (constBoundaryItem->ismaxvalue) { targetConstBoundaryItem = constBoundaryItem; } else { - targetConstBoundaryItem = (Const*)GetTargetValue(attrs[keypos - 1], constBoundaryItem, false); + targetConstBoundaryItem = (Const*)GetTargetValue(&attrs[keypos - 1], constBoundaryItem, false); if (!PointerIsValid(targetConstBoundaryItem)) { list_free_ext(newBoundaryList); ereport(ERROR, (errcode(ERRCODE_INVALID_OPERATION), errmsg("partition key value must be const or const-evaluable expression"))); } - if (!OidIsValid(targetConstBoundaryItem->constcollid) && OidIsValid(attrs[keypos - 1]->attcollation)) { - targetConstBoundaryItem->constcollid = attrs[keypos - 1]->attcollation; + if (!OidIsValid(targetConstBoundaryItem->constcollid) && OidIsValid(attrs[keypos - 1].attcollation)) { + targetConstBoundaryItem->constcollid = attrs[keypos - 1].attcollation; } } Assert(nodeTag(targetConstBoundaryItem) == T_Const); @@ -26487,7 +26487,7 @@ List* transformIntoTargetType(Form_pg_attribute* attrs, int2 keypos, List* bound * Description : * Notes : */ -List* transformConstIntoTargetType(Form_pg_attribute* attrs, int2vector* partitionKey, List* boundary) +List* transformConstIntoTargetType(FormData_pg_attribute* attrs, int2vector* partitionKey, List* boundary) { int counter = 0; int2 partKeyPos = 0; @@ -26514,15 +26514,15 @@ List* transformConstIntoTargetType(Form_pg_attribute* attrs, int2vector* partiti if (constBoundaryItem->ismaxvalue) { targetConstBoundaryItem = constBoundaryItem; } else { - targetConstBoundaryItem = (Const*)GetTargetValue(attrs[partKeyPos - 1], constBoundaryItem, false); + targetConstBoundaryItem = (Const*)GetTargetValue(&attrs[partKeyPos - 1], constBoundaryItem, false); if (!PointerIsValid(targetConstBoundaryItem)) { list_free_ext(newBoundaryList); ereport(ERROR, (errcode(ERRCODE_INVALID_OPERATION), errmsg("partition key value must be const or const-evaluable expression"))); } - if (!OidIsValid(targetConstBoundaryItem->constcollid) && OidIsValid(attrs[partKeyPos - 1]->attcollation)) { - targetConstBoundaryItem->constcollid = attrs[partKeyPos - 1]->attcollation; + if (!OidIsValid(targetConstBoundaryItem->constcollid) && OidIsValid(attrs[partKeyPos - 1].attcollation)) { + targetConstBoundaryItem->constcollid = attrs[partKeyPos - 1].attcollation; } } Assert(nodeTag(targetConstBoundaryItem) == T_Const); @@ -27068,7 +27068,7 @@ static void ATExecSetCompress(Relation rel, const char* cmprsId) /* CStore Rewrite Table Methods */ #include "access/cstore_rewrite.h" -#define RelAttrName(__tupdesc, __attridx) (NameStr((__tupdesc)->attrs[(__attridx)]->attname)) +#define RelAttrName(__tupdesc, __attridx) (NameStr((__tupdesc)->attrs[(__attridx)].attname)) // get all the attributes to be checked or rewrited. // @@ -27186,7 +27186,7 @@ static void ATCStoreRewriteTable(AlteredTableInfo* tab, Relation oldHeapRel, LOC /* set NOT NULL constraint for updated columns. */ if (tab->rewrite || tab->new_notnull) { for (int i = 0; i < maxCols; ++i) { - if (rewriteInfo[i] != NULL && !rewriteInfo[i]->isDropped && newTupDesc->attrs[i]->attnotnull) { + if (rewriteInfo[i] != NULL && !rewriteInfo[i]->isDropped && newTupDesc->attrs[i].attnotnull) { rewriteInfo[i]->notNull = true; } } @@ -27250,7 +27250,7 @@ static void ATCStoreRewriteTable(AlteredTableInfo* tab, Relation oldHeapRel, LOC RelationGetRelationName(oldHeapRel)); for (int i = 0; i < maxCols; ++i) { - Form_pg_attribute thisattr = newTupDesc->attrs[i]; + Form_pg_attribute thisattr = &newTupDesc->attrs[i]; /* skip the dropped and rewritted columns */ if (!thisattr->attisdropped && !rewriteFlags[i]) { @@ -27614,7 +27614,7 @@ List* make_not_null_attrs(TupleDesc tuple_desc) { List* not_null_attrs = NIL; for (int i = 0; i < tuple_desc->natts; i++) { - if (tuple_desc->attrs[i]->attnotnull && !tuple_desc->attrs[i]->attisdropped) + if (tuple_desc->attrs[i].attnotnull && !tuple_desc->attrs[i].attisdropped) not_null_attrs = lappend_int(not_null_attrs, i); } diff --git a/src/gausskernel/optimizer/commands/typecmds.cpp b/src/gausskernel/optimizer/commands/typecmds.cpp index e0deed82e..ec06b7969 100644 --- a/src/gausskernel/optimizer/commands/typecmds.cpp +++ b/src/gausskernel/optimizer/commands/typecmds.cpp @@ -2392,7 +2392,7 @@ void AlterDomainNotNull(List* names, bool notNull) ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), errmsg("column \"%s\" of table \"%s\" contains null values", - NameStr(tupdesc->attrs[attnum - 1]->attname), + NameStr(tupdesc->attrs[attnum - 1].attname), RelationGetRelationName(testrel)))); } } @@ -2732,7 +2732,7 @@ static void validateDomainConstraint(Oid domainoid, char* ccbin) ereport(ERROR, (errcode(ERRCODE_CHECK_VIOLATION), errmsg("column \"%s\" of table \"%s\" contains values that violate the new constraint", - NameStr(tupdesc->attrs[attnum - 1]->attname), + NameStr(tupdesc->attrs[attnum - 1].attname), RelationGetRelationName(testrel)))); } @@ -2873,7 +2873,7 @@ static List* get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) */ if (pg_depend->objsubid > RelationGetNumberOfAttributes(rtc->rel)) continue; - pg_att = rtc->rel->rd_att->attrs[pg_depend->objsubid - 1]; + pg_att = &rtc->rel->rd_att->attrs[pg_depend->objsubid - 1]; if (pg_att->attisdropped || pg_att->atttypid != domainOid) continue; diff --git a/src/gausskernel/optimizer/commands/verify.cpp b/src/gausskernel/optimizer/commands/verify.cpp index 13526c57c..6dcc1a189 100644 --- a/src/gausskernel/optimizer/commands/verify.cpp +++ b/src/gausskernel/optimizer/commands/verify.cpp @@ -1695,7 +1695,7 @@ static void VerifyColRelFast(Relation rel) TupleDesc tupleDesc; CStoreScanDesc scan = NULL; int16* colIdx = NULL; - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; int attno = rel->rd_rel->relnatts; int col = 0; @@ -1717,7 +1717,7 @@ static void VerifyColRelFast(Relation rel) colIdx = (int16*)palloc0(sizeof(int16) * tupleDesc->natts); attrs = tupleDesc->attrs; for (int i = 0; i < tupleDesc->natts; i++) { - colIdx[i] = attrs[i]->attnum; + colIdx[i] = attrs[i].attnum; } scan = CStoreBeginScan(rel, tupleDesc->natts, colIdx, GetActiveSnapshot(), true); @@ -1786,7 +1786,7 @@ static void VerifyColRelComplete(Relation rel) VerifyColRelFast(rel); int attrNum = rel->rd_att->natts; - Form_pg_attribute* attrs = rel->rd_att->attrs; + FormData_pg_attribute* attrs = rel->rd_att->attrs; CUDesc cuDesc; CU* cuPtr = NULL; BlockNumber cuId = FirstCUID + 1; @@ -1805,7 +1805,7 @@ static void VerifyColRelComplete(Relation rel) int slotId = CACHE_BLOCK_INVALID_IDX; for (int i = 0; i < attrNum; i++) { - colIdx[i] = attrs[i]->attnum; + colIdx[i] = attrs[i].attnum; } CStoreScanDesc cstoreScanDesc = CStoreBeginScan(rel, attrNum, colIdx, GetActiveSnapshot(), false); @@ -1816,7 +1816,7 @@ static void VerifyColRelComplete(Relation rel) for (cuId = FirstCUID + 1; cuId <= maxCuId; cuId++) { for (int col = 0; col < attrNum; col++) { /* skip dropped column */ - if (attrs[col]->attisdropped) { + if (attrs[col].attisdropped) { continue; } @@ -1824,7 +1824,7 @@ static void VerifyColRelComplete(Relation rel) if (found && cuDesc.cu_size != 0) { PG_TRY(); { - cuPtr = cstore->GetCUData(&cuDesc, col, attrs[col]->attlen, slotId); + cuPtr = cstore->GetCUData(&cuDesc, col, attrs[col].attlen, slotId); if (IsValidCacheSlotID(slotId)) { CUCache->UnPinDataBlock(slotId); } diff --git a/src/gausskernel/optimizer/commands/view.cpp b/src/gausskernel/optimizer/commands/view.cpp index 670954355..a390efee8 100644 --- a/src/gausskernel/optimizer/commands/view.cpp +++ b/src/gausskernel/optimizer/commands/view.cpp @@ -255,7 +255,7 @@ static Oid DefineVirtualRelation(RangeVar* relation, List* tlist, bool replace, for (int dropcolno = rel->rd_att->natts - 1; dropcolno >= list_length(attrList); dropcolno--) { atcmd = makeNode(AlterTableCmd); atcmd->subtype = AT_DropColumn; - atcmd->name = rel->rd_att->attrs[dropcolno]->attname.data; + atcmd->name = rel->rd_att->attrs[dropcolno].attname.data; atcmd->behavior = DROP_RESTRICT; atcmd->missing_ok = true; atcmds = lappend(atcmds, atcmd); @@ -380,8 +380,8 @@ static void checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("cannot drop columns from view"))); /* we can ignore tdhasoid */ for (i = 0; i < olddesc->natts; i++) { - Form_pg_attribute newattr = newdesc->attrs[i]; - Form_pg_attribute oldattr = olddesc->attrs[i]; + Form_pg_attribute newattr = &newdesc->attrs[i]; + Form_pg_attribute oldattr = &olddesc->attrs[i]; /* XXX msg not right, but we don't support DROP COL on view anyway */ if (newattr->attisdropped != oldattr->attisdropped) diff --git a/src/gausskernel/optimizer/plan/createplan.cpp b/src/gausskernel/optimizer/plan/createplan.cpp index fd1564229..6c3a8eb8f 100755 --- a/src/gausskernel/optimizer/plan/createplan.cpp +++ b/src/gausskernel/optimizer/plan/createplan.cpp @@ -3581,7 +3581,7 @@ static List* build_one_column_tlist(PlannerInfo* root, RelOptInfo* rel) Var* varnode = NULL; for (varattno = 0; varattno < maxattrs; varattno++) { - Form_pg_attribute attr = tupdesc->attrs[varattno]; + Form_pg_attribute attr = &tupdesc->attrs[varattno]; if (attr->attisdropped || !IsTypeDistributable(attr->atttypid)) { continue; diff --git a/src/gausskernel/optimizer/plan/planner.cpp b/src/gausskernel/optimizer/plan/planner.cpp index 327a5b1cd..404351989 100755 --- a/src/gausskernel/optimizer/plan/planner.cpp +++ b/src/gausskernel/optimizer/plan/planner.cpp @@ -13029,8 +13029,8 @@ uint64 adjust_plsize(Oid relid, uint64 plan_width, uint64 pl_size, uint64* width TupleDesc desc = rel->rd_att; for (int i = 0; i < desc->natts; i++) { - Oid typoid = desc->attrs[i]->atttypid; - int32 typmod = desc->attrs[i]->atttypmod; + Oid typoid = desc->attrs[i].atttypid; + int32 typmod = desc->attrs[i].atttypmod; rel_width += get_typavgwidth(typoid, typmod); } @@ -13741,7 +13741,7 @@ static void save_implicit_cast_var(Node* node, void* context) new_node->indexcol = false; new_node->relname = pstrdup(rtable->relname); - new_node->attname = pstrdup(rel->rd_att->attrs[var->varattno - 1]->attname.data); + new_node->attname = pstrdup(rel->rd_att->attrs[var->varattno - 1].attname.data); heap_close(rel, AccessShareLock); diff --git a/src/gausskernel/optimizer/plan/streamplan_utils.cpp b/src/gausskernel/optimizer/plan/streamplan_utils.cpp index 333d0bc0c..ff939c07d 100755 --- a/src/gausskernel/optimizer/plan/streamplan_utils.cpp +++ b/src/gausskernel/optimizer/plan/streamplan_utils.cpp @@ -1305,7 +1305,7 @@ static bool judge_lockrows_need_redistribute_keyLen_equal( AttrNumber distributeKeyIdx = target_classForm->pcattnum.values[i]; Node* subKey = (Node*)list_nth(subplan->distributed_keys, i); Var* subVar = locate_distribute_var((Expr*)subKey); - attTup = rel->rd_att->attrs[distributeKeyIdx - 1]; + attTup = &rel->rd_att->attrs[distributeKeyIdx - 1]; /* * Call pfree_ext to free the lockrelvar created in this loop and * we don't need check null outside as its check inside. diff --git a/src/gausskernel/optimizer/prep/preptlist.cpp b/src/gausskernel/optimizer/prep/preptlist.cpp index 67e99870c..9f0096637 100644 --- a/src/gausskernel/optimizer/prep/preptlist.cpp +++ b/src/gausskernel/optimizer/prep/preptlist.cpp @@ -243,7 +243,7 @@ List* preprocess_targetlist(PlannerInfo* root, List* tlist) int32 vartypmod = -1; Oid varCollid = InvalidOid; if (is_hdfs_ftbl) { - Form_pg_attribute attr = tupdesc->attrs[varattno]; + Form_pg_attribute attr = &tupdesc->attrs[varattno]; vartype = attr->atttypid; varCollid = attr->attcollation; vartypmod = attr->atttypmod; @@ -366,7 +366,7 @@ static List* expand_targetlist(List* tlist, int command_type, List* resultRelati numattrs = RelationGetNumberOfAttributes(rel); for (attrno = 1; attrno <= numattrs; attrno++) { - Form_pg_attribute att_tup = rel->rd_att->attrs[attrno - 1]; + Form_pg_attribute att_tup = &rel->rd_att->attrs[attrno - 1]; TargetEntry* new_tle = NULL; if (tlist_item != NULL) { @@ -559,7 +559,7 @@ static List* add_distribute_column(List* tlist, Index result_relation, List* ran for (int i = 0; i < len; i++) { if (isExist[i] == false) { no = disattrno->values[i]; - Form_pg_attribute att_tup = rel->rd_att->attrs[no - 1]; + Form_pg_attribute att_tup = &rel->rd_att->attrs[no - 1]; Node* new_expr = (Node*)makeVar(result_relation, no, att_tup->atttypid, att_tup->atttypmod, att_tup->attcollation, 0); TargetEntry* tle = diff --git a/src/gausskernel/optimizer/prep/prepunion.cpp b/src/gausskernel/optimizer/prep/prepunion.cpp index 95349d512..bc01f3bfd 100644 --- a/src/gausskernel/optimizer/prep/prepunion.cpp +++ b/src/gausskernel/optimizer/prep/prepunion.cpp @@ -1653,7 +1653,7 @@ void make_inh_translation_list(Relation oldrelation, Relation newrelation, Index Oid attcollation; int new_attno; - att = old_tupdesc->attrs[old_attno]; + att = &old_tupdesc->attrs[old_attno]; if (att->attisdropped) { /* Just put NULL into this list entry */ vars = lappend(vars, NULL); @@ -1685,13 +1685,13 @@ void make_inh_translation_list(Relation oldrelation, Relation newrelation, Index * Since the idea of inherited table to achieve DFS table, so ther following * logic must be covered. */ - if (old_attno < newnatts && (att = new_tupdesc->attrs[old_attno]) != NULL && + if (old_attno < newnatts && (att = &new_tupdesc->attrs[old_attno]) != NULL && (att->attisdropped && att->attinhcount != 0) && strcmp(attname, NameStr(att->attname)) == 0) new_attno = old_attno; else { for (new_attno = 0; new_attno < newnatts; new_attno++) { - att = new_tupdesc->attrs[new_attno]; + att = &new_tupdesc->attrs[new_attno]; if (!att->attisdropped && att->attinhcount != 0 && strcmp(attname, NameStr(att->attname)) == 0) break; } diff --git a/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp b/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp index c9c3af3b1..b58949057 100644 --- a/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteDefine.cpp @@ -689,7 +689,7 @@ static void checkRuleResultList(List* targetList, TupleDesc resultDesc, bool isS isSelect ? errmsg("SELECT rule's target list has too many entries") : errmsg("RETURNING list has too many entries"))); - attr = resultDesc->attrs[i - 1]; + attr = &resultDesc->attrs[i - 1]; attname = NameStr(attr->attname); /* diff --git a/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp b/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp index fc0a01904..cc5026c36 100644 --- a/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp @@ -677,7 +677,7 @@ static List* rewriteTargetListIU(List* targetList, CmdType commandType, Relation ereport(ERROR, (errcode(ERRCODE_OPTIMIZER_INCONSISTENT_STATE), errmsg("bogus resno %d in targetlist", attrno))); } - att_tup = target_relation->rd_att->attrs[attrno - 1]; + att_tup = &target_relation->rd_att->attrs[attrno - 1]; /* put attrno into attrno_list even if it's dropped */ if (attrno_list != NULL && IsA(old_tle->expr, Var)) @@ -714,7 +714,7 @@ static List* rewriteTargetListIU(List* targetList, CmdType commandType, Relation bool applyDefault = false; bool generateCol = ISGENERATEDCOL(target_relation->rd_att, attrno - 1); - att_tup = target_relation->rd_att->attrs[attrno - 1]; + att_tup = &target_relation->rd_att->attrs[attrno - 1]; /* We can (and must) ignore deleted attributes */ if (att_tup->attisdropped) @@ -856,7 +856,7 @@ static void rewriteTargetListMutilUpdate(Query* parsetree, List* rtable, List* r (errcode(ERRCODE_OPTIMIZER_INCONSISTENT_STATE), errmsg("bogus resno %d in targetlist", attrno))); } - att_tup = target_relation->rd_att->attrs[attrno - 1]; + att_tup = &target_relation->rd_att->attrs[attrno - 1]; /* We can (and must) ignore deleted attributes */ if (att_tup->attisdropped) { @@ -891,7 +891,7 @@ static void rewriteTargetListMutilUpdate(Query* parsetree, List* rtable, List* r bool applyDefault = new_tle != NULL && new_tle->expr != NULL && IsA(new_tle->expr, SetToDefault); bool generateCol = ISGENERATEDCOL(target_relation->rd_att, attrno - 1); - att_tup = target_relation->rd_att->attrs[attrno - 1]; + att_tup = &target_relation->rd_att->attrs[attrno - 1]; /* We can (and must) ignore deleted attributes */ if (att_tup->attisdropped) @@ -1150,7 +1150,7 @@ static bool check_sequence_return_numeric_walker(Node *node, int *ret) Node* build_column_default(Relation rel, int attrno, bool isInsertCmd, bool needOnUpdate) { TupleDesc rd_att = rel->rd_att; - Form_pg_attribute att_tup = rd_att->attrs[attrno - 1]; + Form_pg_attribute att_tup = &rd_att->attrs[attrno - 1]; Oid atttype = att_tup->atttypid; int32 atttypmod = att_tup->atttypmod; Node* expr = NULL; @@ -1283,7 +1283,7 @@ static void checkGenDefault(RangeTblEntry* rte, Relation target_relation, List* forboth (lc2, sublist, lc3, attrnos) { Node* col = (Node*)lfirst(lc2); int attrno = lfirst_int(lc3); - Form_pg_attribute att_tup = target_relation->rd_att->attrs[attrno - 1]; + Form_pg_attribute att_tup = &target_relation->rd_att->attrs[attrno - 1]; bool generatedCol = ISGENERATEDCOL(target_relation->rd_att, attrno - 1); bool applyDefault = IsA(col, SetToDefault); @@ -1402,7 +1402,7 @@ static bool rewriteValuesRTE(Query* parsetree, RangeTblEntry* rte, Relation targ { Node *col = (Node *)lfirst(lc2); int attrno = lfirst_int(lc3); - Form_pg_attribute att_tup = target_relation->rd_att->attrs[attrno - 1]; + Form_pg_attribute att_tup = &target_relation->rd_att->attrs[attrno - 1]; bool generatedCol = ISGENERATEDCOL(target_relation->rd_att, attrno - 1); bool applyDefault = IsA(col, SetToDefault); @@ -1576,7 +1576,7 @@ static void rewriteTargetListUD(Query* parsetree, RangeTblEntry* target_rte, Rel continue; } - att_tup = target_relation->rd_att->attrs[var->varattno - 1]; + att_tup = &target_relation->rd_att->attrs[var->varattno - 1]; tle = makeTargetEntry( (Expr*)var, list_length(parsetree->targetList) + 1, pstrdup(NameStr(att_tup->attname)), true); tle->rtindex = rtindex; @@ -1604,7 +1604,7 @@ static void rewriteTargetListUD(Query* parsetree, RangeTblEntry* target_rte, Rel TargetEntry* new_tle = NULL; if (att_no > 0) { - att_tup = target_relation->rd_att->attrs[att_no - 1]; + att_tup = &target_relation->rd_att->attrs[att_no - 1]; } else { heaptuple = SearchSysCache2(ATTNUM, ObjectIdGetDatum(RelationGetRelid(target_relation)), Int16GetDatum(att_no)); @@ -2455,7 +2455,7 @@ static List* rewriteTargetListMergeInto( ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_COLUMN), errmsg("bogus resno %d in targetlist", attrno))); } - att_tup = target_relation->rd_att->attrs[attrno - 1]; + att_tup = &target_relation->rd_att->attrs[attrno - 1]; /* put attrno into attrno_list even if it's dropped */ if (attrno_list != NULL) @@ -2490,7 +2490,7 @@ static List* rewriteTargetListMergeInto( TargetEntry* new_tle = new_tles[attrno - 1]; bool apply_default = false; - att_tup = target_relation->rd_att->attrs[attrno - 1]; + att_tup = &target_relation->rd_att->attrs[attrno - 1]; /* We can (and must) ignore deleted attributes */ if (att_tup->attisdropped) diff --git a/src/gausskernel/optimizer/sqladvisor/sqladvisor_extract.cpp b/src/gausskernel/optimizer/sqladvisor/sqladvisor_extract.cpp index 5ae6f538f..9ff94dccf 100644 --- a/src/gausskernel/optimizer/sqladvisor/sqladvisor_extract.cpp +++ b/src/gausskernel/optimizer/sqladvisor/sqladvisor_extract.cpp @@ -772,7 +772,7 @@ static List* extractVecSubplan(Expr* node, List* resSubplan, List* subplans) } break; case T_RowExpr: { RowExpr* rowexpr = (RowExpr*)node; - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; ListCell* l = NULL; int i; TupleDesc tupdesc = NULL; @@ -802,19 +802,19 @@ static List* extractVecSubplan(Expr* node, List* resSubplan, List* subplans) foreach (l, rowexpr->args) { Expr* e = (Expr*)lfirst(l); - if (!attrs[i]->attisdropped) { + if (!attrs[i].attisdropped) { /* * Guard against ALTER COLUMN TYPE on rowtype since * the RowExpr was created. XXX should we check * typmod too? Not sure we can be sure it'll be the * same. */ - if (exprType((Node*)e) != attrs[i]->atttypid) { + if (exprType((Node*)e) != attrs[i].atttypid) { ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("ROW() column has type %s instead of type %s", format_type_be(exprType((Node*)e)), - format_type_be(attrs[i]->atttypid)))); + format_type_be(attrs[i].atttypid)))); } } else { /* @@ -967,7 +967,7 @@ static List* extractSubplan(Expr* node, List* resSubplan, List* subplans) } break; case T_RowExpr: { RowExpr* rowexpr = (RowExpr*)node; - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; ListCell* l = NULL; int i; TupleDesc tupdesc = NULL; @@ -987,19 +987,19 @@ static List* extractSubplan(Expr* node, List* resSubplan, List* subplans) foreach (l, rowexpr->args) { Expr* e = (Expr*)lfirst(l); - if (!attrs[i]->attisdropped) { + if (!attrs[i].attisdropped) { /* * Guard against ALTER COLUMN TYPE on rowtype since * the RowExpr was created. XXX should we check * typmod too? Not sure we can be sure it'll be the * same. */ - if (exprType((Node*)e) != attrs[i]->atttypid) + if (exprType((Node*)e) != attrs[i].atttypid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("ROW() column has type %s instead of type %s", format_type_be(exprType((Node*)e)), - format_type_be(attrs[i]->atttypid)))); + format_type_be(attrs[i].atttypid)))); } else { /* * Ignore original expression and insert a NULL. We diff --git a/src/gausskernel/optimizer/sqlpatch/sqlpatch.cpp b/src/gausskernel/optimizer/sqlpatch/sqlpatch.cpp index 87ea2bdc8..c18ad0ec5 100644 --- a/src/gausskernel/optimizer/sqlpatch/sqlpatch.cpp +++ b/src/gausskernel/optimizer/sqlpatch/sqlpatch.cpp @@ -379,7 +379,7 @@ Datum show_sql_patch(PG_FUNCTION_ARGS) HeapTuple resTup = NULL; TupleDesc tupdesc = NULL; int SQL_PATCH_INFO_ATTR_NUM = 4; - tupdesc = CreateTemplateTupleDesc(SQL_PATCH_INFO_ATTR_NUM, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(SQL_PATCH_INFO_ATTR_NUM, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "unique_sql_id", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "enable", BOOLOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) ++i, "abort", BOOLOID, -1, 0); diff --git a/src/gausskernel/optimizer/util/clauses.cpp b/src/gausskernel/optimizer/util/clauses.cpp index f91f441c2..fcd60db22 100644 --- a/src/gausskernel/optimizer/util/clauses.cpp +++ b/src/gausskernel/optimizer/util/clauses.cpp @@ -2161,7 +2161,7 @@ static bool rowtype_field_matches( ReleaseTupleDesc(tupdesc); return false; } - attr = tupdesc->attrs[fieldnum - 1]; + attr = &tupdesc->attrs[fieldnum - 1]; if (attr->attisdropped || attr->atttypid != expectedtype || attr->atttypmod != expectedtypmod || attr->attcollation != expectedcollation) { ReleaseTupleDesc(tupdesc); diff --git a/src/gausskernel/optimizer/util/dataskew.cpp b/src/gausskernel/optimizer/util/dataskew.cpp index 36ae2ab9f..ed6a39fe4 100755 --- a/src/gausskernel/optimizer/util/dataskew.cpp +++ b/src/gausskernel/optimizer/util/dataskew.cpp @@ -1409,7 +1409,7 @@ bool SkewInfo::canValuePassQual(List* varList, List* valueList, Expr* expr) var = (Var*)list_nth(varList, j); con = (Const*)list_nth(valueList, j); - if (tupdesc->attrs[i]->attnum == var->varattno) { + if (tupdesc->attrs[i].attnum == var->varattno) { if (con == NULL) { slot->tts_isnull[i] = true; } else { diff --git a/src/gausskernel/optimizer/util/pgxcship.cpp b/src/gausskernel/optimizer/util/pgxcship.cpp index 3e1f604fb..97ac5c035 100644 --- a/src/gausskernel/optimizer/util/pgxcship.cpp +++ b/src/gausskernel/optimizer/util/pgxcship.cpp @@ -961,14 +961,14 @@ static List* ts_get_taglist(Oid relid) { Relation rel = relation_open(relid, AccessShareLock); TupleDesc tup_desc = RelationGetDescr(rel); - Form_pg_attribute* attr = tup_desc->attrs; + FormData_pg_attribute* attr = tup_desc->attrs; List* tag_name_list = NIL; bool valid_ts_table = false; char* str = NULL; for (int i = 0; i < tup_desc->natts; i++) { - if (attr[i]->attkvtype == ATT_KV_TAG && IsTypeDistributable(attr[i]->atttypid)) { - str = pstrdup(NameStr(attr[i]->attname)); + if (attr[i].attkvtype == ATT_KV_TAG && IsTypeDistributable(attr[i].atttypid)) { + str = pstrdup(NameStr(attr[i].attname)); if (str != NULL) { tag_name_list = lappend(tag_name_list, makeString(str)); } else { @@ -976,7 +976,7 @@ static List* ts_get_taglist(Oid relid) errmsg("Timeseries relation %u cloud not find tag column %d", relid, i))); } } - if (attr[i]->attkvtype == ATT_KV_HIDE) { + if (attr[i].attkvtype == ATT_KV_HIDE) { valid_ts_table = true; } } diff --git a/src/gausskernel/optimizer/util/plancat.cpp b/src/gausskernel/optimizer/util/plancat.cpp index 7f901201a..995d8e109 100755 --- a/src/gausskernel/optimizer/util/plancat.cpp +++ b/src/gausskernel/optimizer/util/plancat.cpp @@ -1004,7 +1004,7 @@ static int32 get_rel_data_width(Relation rel, int32* attr_widths, bool vectorize bool hasencoded = false; 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; int4 att_typmod = att->atttypmod; Oid att_typid = att->atttypid; @@ -1105,10 +1105,10 @@ int32 getIdxDataWidth(Relation rel, IndexInfo* info, bool vectorized) item_width = get_attavgwidth(RelationGetRelid(rel), attnum, isPartition); if (item_width <= 0) { item_width = get_typavgwidth( - REL_GET_ITH_ATT(rel, attnum - 1)->atttypid, REL_GET_ITH_ATT(rel, attnum - 1)->atttypmod); + REL_GET_ITH_ATT(rel, attnum - 1).atttypid, REL_GET_ITH_ATT(rel, attnum - 1).atttypmod); AssertEreport(item_width > 0, MOD_OPT, ""); } - typid = REL_GET_ITH_ATT(rel, attnum - 1)->atttypid; + typid = REL_GET_ITH_ATT(rel, attnum - 1).atttypid; } else if (expr_i < list_length(info->ii_Expressions)) { Node* expr = (Node*)list_nth(info->ii_Expressions, expr_i); typid = exprType(expr); @@ -1210,7 +1210,7 @@ static List* get_relation_constraints(PlannerInfo* root, Oid relationObjectId, R int natts = relation->rd_att->natts; for (i = 1; i <= natts; i++) { - Form_pg_attribute att = relation->rd_att->attrs[i - 1]; + Form_pg_attribute att = &relation->rd_att->attrs[i - 1]; if (att->attnotnull && !att->attisdropped) { NullTest* ntest = makeNode(NullTest); @@ -1359,7 +1359,7 @@ List* build_physical_tlist(PlannerInfo* root, RelOptInfo* rel) numattrs = RelationGetNumberOfAttributes(relation); for (attrno = 1; attrno <= numattrs; attrno++) { - Form_pg_attribute att_tup = relation->rd_att->attrs[attrno - 1]; + Form_pg_attribute att_tup = &relation->rd_att->attrs[attrno - 1]; if (att_tup->attisdropped) { /* found a dropped col, so punt */ @@ -1525,7 +1525,7 @@ List* build_index_tlist(PlannerInfo* root, IndexOptInfo* index, Relation heapRel att_tup = SystemAttributeDefinition(indexkey, heapRelation->rd_rel->relhasoids, RELATION_HAS_BUCKET(heapRelation), RELATION_HAS_UIDS(heapRelation)); } else { - att_tup = heapRelation->rd_att->attrs[indexkey - 1]; + att_tup = &heapRelation->rd_att->attrs[indexkey - 1]; } indexvar = (Expr*)makeVar(varno, indexkey, att_tup->atttypid, att_tup->atttypmod, att_tup->attcollation, 0); diff --git a/src/gausskernel/process/postmaster/gaussdb_version.cpp b/src/gausskernel/process/postmaster/gaussdb_version.cpp index ce973902f..7d54c400f 100644 --- a/src/gausskernel/process/postmaster/gaussdb_version.cpp +++ b/src/gausskernel/process/postmaster/gaussdb_version.cpp @@ -120,7 +120,7 @@ static bool isInitialized = false; * And reset after the package operation. * Please do not modify it. */ -const char *sha256_digests[SHA256_DIGESTS_COUNT] = {NULL, NULL}; +const char *sha256_digests[SHA256_DIGESTS_COUNT] = {"5237e9ad5b6ecf8d0abba664972bdcb106595b9ec2f52083915e7c829d348f0d", "06354c2857fbf21e5862005a7e60ad210dc4b635dbde891d6e60cbddea465b16"}; /* The product control file information. */ static LicenseControl versionControl = {PRODUCT_VERSION_FILE, PRODUCT_VERSION_UNKNOWN, {{0}}, false}; /* The license control file information. */ diff --git a/src/gausskernel/process/stream/streamProducer.cpp b/src/gausskernel/process/stream/streamProducer.cpp index fa2f0c6e5..2c4006924 100644 --- a/src/gausskernel/process/stream/streamProducer.cpp +++ b/src/gausskernel/process/stream/streamProducer.cpp @@ -261,7 +261,7 @@ void StreamProducer::init(TupleDesc desc, StreamTxnContext txnCxt, ParamListInfo redistributeStreamInitType(m_desc, m_colsType); for (int i = 0; i < m_desc->natts; i++) { - if (m_desc->attrs[i]->atttypid == NUMERICOID) + if (m_desc->attrs[i].atttypid == NUMERICOID) numericCols++; } @@ -557,7 +557,7 @@ void StreamProducer::BindingRedisFunction() Oid dataType; m_hashFun = (hashFun*)palloc0(sizeof(hashFun) * len); for (int i = 0; i < len; i++) { - dataType = m_desc->attrs[m_distributeIdx[i]]->atttypid; + dataType = m_desc->attrs[m_distributeIdx[i]].atttypid; switch (dataType) { case INT8OID: m_hashFun[i] = &computeHashT; @@ -1153,7 +1153,7 @@ void StreamProducer::redistributeBatchChannelForSlice(VectorBatch* batch) pDistributeVec = &batch->m_arr[m_distributeIdx[j]]; data = pDistributeVec->m_vals[i]; keyNulls[j] = pDistributeVec->IsNull(i); - KeyAttrs[j] = m_desc->attrs[m_distributeIdx[j]]->atttypid; + KeyAttrs[j] = m_desc->attrs[m_distributeIdx[j]].atttypid; keyValues[j] = data; colMap[j] = j; @@ -1278,7 +1278,7 @@ void StreamProducer::redistributeTupleChannelForSlice(TupleTableSlot* tuple) for (int i = 0; i < keyNum; i++) { colMap[i] = i; keyValues[i] = tableam_tslot_getattr(tuple, m_distributeIdx[i] + 1, &keyNulls[i]); - keyAttrs[i] = m_desc->attrs[m_distributeIdx[i]]->atttypid; + keyAttrs[i] = m_desc->attrs[m_distributeIdx[i]].atttypid; } ConstructConstFromValues(keyValues, keyNulls, keyAttrs, colMap, keyNum, consts, constPointers); diff --git a/src/gausskernel/process/tcop/pquery.cpp b/src/gausskernel/process/tcop/pquery.cpp index 3fff533a1..3d451c4c3 100644 --- a/src/gausskernel/process/tcop/pquery.cpp +++ b/src/gausskernel/process/tcop/pquery.cpp @@ -813,7 +813,7 @@ void PortalStart(Portal portal, ParamListInfo params, int eflags, Snapshot snaps pstmt = (PlannedStmt*)PortalGetPrimaryStmt(portal); AssertEreport(IsA(pstmt, PlannedStmt), MOD_EXECUTOR, "pstmt is not a PlannedStmt"); - portal->tupDesc = ExecCleanTypeFromTL(pstmt->planTree->targetlist, false, TAM_HEAP); + portal->tupDesc = ExecCleanTypeFromTL(pstmt->planTree->targetlist, false); } /* @@ -839,7 +839,7 @@ void PortalStart(Portal portal, ParamListInfo params, int eflags, Snapshot snaps if (portal->tupDesc != NULL) { - portal->tupDesc->tdTableAmType = TAM_HEAP; + portal->tupDesc->td_tam_ops = TableAmHeap; } } diff --git a/src/gausskernel/runtime/codegen/vecexecutor/vecexprcodegen.cpp b/src/gausskernel/runtime/codegen/vecexecutor/vecexprcodegen.cpp index 06cb669d4..ccbbd4045 100644 --- a/src/gausskernel/runtime/codegen/vecexecutor/vecexprcodegen.cpp +++ b/src/gausskernel/runtime/codegen/vecexecutor/vecexprcodegen.cpp @@ -4085,7 +4085,7 @@ llvm::Value* VecExprCodeGen::VarCodeGen(ExprCodeGenArgs* args) if ((args->parent != NULL) && IsA(args->parent, CStoreScanState)) { CStoreScanState* scanstate = (CStoreScanState*)args->parent; if (!scanstate->isPartTbl && scanstate->ss_currentRelation) { - attr = scanstate->ss_currentRelation->rd_att->attrs[var->varattno - 1]; + attr = &scanstate->ss_currentRelation->rd_att->attrs[var->varattno - 1]; is_notnull = attr->attnotnull; } } diff --git a/src/gausskernel/runtime/codegen/vecexecutor/vechashjoincodegen.cpp b/src/gausskernel/runtime/codegen/vecexecutor/vechashjoincodegen.cpp index 86fe2a2ec..9e819e0ca 100644 --- a/src/gausskernel/runtime/codegen/vecexecutor/vechashjoincodegen.cpp +++ b/src/gausskernel/runtime/codegen/vecexecutor/vechashjoincodegen.cpp @@ -96,7 +96,7 @@ Var* VecHashJoinCodeGen::GetSimpHashCondExpr( Oid namespaceOid = get_rel_namespace(relid); if (RelationIsValid(base_relation) && namespaceOid > FirstNormalObjectId) { if (var->varoattno <= base_relation->rd_att->natts) { - attr = base_relation->rd_att->attrs[var->varoattno - 1]; + attr = &base_relation->rd_att->attrs[var->varoattno - 1]; if (attr == NULL || !attr->attnotnull) *enable_fast_keyMatch = 0; } else diff --git a/src/gausskernel/runtime/codegen/vecexecutor/vecsortcodegen.cpp b/src/gausskernel/runtime/codegen/vecexecutor/vecsortcodegen.cpp index 04a4de7b4..a83193f46 100644 --- a/src/gausskernel/runtime/codegen/vecexecutor/vecsortcodegen.cpp +++ b/src/gausskernel/runtime/codegen/vecexecutor/vecsortcodegen.cpp @@ -59,7 +59,7 @@ bool VecSortCodeGen::JittableCompareMultiColumn(VecSortState* node) for (i = 0; i < plannode->numCols; i++) { colIdx = plannode->sortColIdx[i] - 1; - Form_pg_attribute attr = tupDesc->attrs[colIdx]; + Form_pg_attribute attr = &tupDesc->attrs[colIdx]; Oid typeOid = attr->atttypid; Oid opno = plannode->sortOperators[i]; switch (typeOid) { @@ -135,7 +135,7 @@ bool VecSortCodeGen::JittableSortAggMatchKey(VecAggState* node) for (i = 0; i < plannode->numCols; i++) { colIdx = plannode->grpColIdx[i] - 1; - Form_pg_attribute attr = tupDesc->attrs[colIdx]; + Form_pg_attribute attr = &tupDesc->attrs[colIdx]; Oid opoid = plannode->grpOperators[i]; switch (opoid) { case INT4EQOID: @@ -275,7 +275,7 @@ llvm::Function* VecSortCodeGen::CompareMultiColumnCodeGen(VecSortState* node, bo Oid opno = plannode->sortOperators[i]; colIdx = plannode->sortColIdx[i] - 1; - Form_pg_attribute attr = tupDesc->attrs[colIdx]; + Form_pg_attribute attr = &tupDesc->attrs[colIdx]; Oid typeOid = attr->atttypid; builder.SetInsertPoint(bb_keys1[i]); @@ -327,7 +327,7 @@ llvm::Function* VecSortCodeGen::CompareMultiColumnCodeGen(VecSortState* node, bo if (i < numKeys - 1) { /* prefetch the next key if it is BPCHAR or NUMERIC data */ int next_colIdx = plannode->sortColIdx[i + 1] - 1; - Form_pg_attribute next_attr = tupDesc->attrs[next_colIdx]; + Form_pg_attribute next_attr = &tupDesc->attrs[next_colIdx]; if (next_attr->atttypid == VARCHAROID || next_attr->atttypid == TEXTOID || next_attr->atttypid == BPCHAROID || next_attr->atttypid == NUMERICOID) { llvm::Value* next_val_colIdx = llvmCodeGen->getIntConstant(INT8OID, next_colIdx); @@ -622,7 +622,7 @@ llvm::Function* VecSortCodeGen::CompareMultiColumnCodeGen_TOPN(VecSortState* nod /* reverse order for TopN */ nullsFirst = !nullsFirst; colIdx = plannode->sortColIdx[i] - 1; - Form_pg_attribute attr = tupDesc->attrs[colIdx]; + Form_pg_attribute attr = &tupDesc->attrs[colIdx]; Oid typeOid = attr->atttypid; builder.SetInsertPoint(bb_keys1[i]); @@ -664,7 +664,7 @@ llvm::Function* VecSortCodeGen::CompareMultiColumnCodeGen_TOPN(VecSortState* nod /* prefetch the next key if it is bpchar or numeric data */ if (i < numKeys - 1) { int next_colIdx = plannode->sortColIdx[i + 1] - 1; - Form_pg_attribute next_attr = tupDesc->attrs[next_colIdx]; + Form_pg_attribute next_attr = &tupDesc->attrs[next_colIdx]; if (next_attr->atttypid == VARCHAROID || next_attr->atttypid == TEXTOID || next_attr->atttypid == BPCHAROID || next_attr->atttypid == NUMERICOID) { llvm::Value* next_val_colIdx = llvmCodeGen->getIntConstant(INT8OID, next_colIdx); @@ -3673,7 +3673,7 @@ llvm::Function* VecSortCodeGen::SortAggMatchKeyCodeGen(VecAggState* node) /* Codegen for each key comparison */ for (i = 0; i < numKeys; i++) { int val_keyIdx = plannode->grpColIdx[i] - 1; - Form_pg_attribute attr = tupDesc->attrs[val_keyIdx]; + Form_pg_attribute attr = &tupDesc->attrs[val_keyIdx]; Oid opno = plannode->grpOperators[i]; builder.SetInsertPoint(bb_keyStart[i]); diff --git a/src/gausskernel/runtime/executor/execGrouping.cpp b/src/gausskernel/runtime/executor/execGrouping.cpp index 505986cfe..a4204bb01 100644 --- a/src/gausskernel/runtime/executor/execGrouping.cpp +++ b/src/gausskernel/runtime/executor/execGrouping.cpp @@ -115,7 +115,7 @@ bool execTuplesUnequal(TupleTableSlot* slot1, TupleTableSlot* slot2, int numCols bool result = false; int i; - Assert(slot1->tts_tupleDescriptor->tdTableAmType == slot2->tts_tupleDescriptor->tdTableAmType); + Assert(slot1->tts_tupleDescriptor->td_tam_ops == slot2->tts_tupleDescriptor->td_tam_ops); /* Reset and switch into the temp context. */ MemoryContextReset(evalContext); diff --git a/src/gausskernel/runtime/executor/execJunk.cpp b/src/gausskernel/runtime/executor/execJunk.cpp index d250f3566..a1b188ac3 100644 --- a/src/gausskernel/runtime/executor/execJunk.cpp +++ b/src/gausskernel/runtime/executor/execJunk.cpp @@ -60,7 +60,7 @@ * of whether to include room for an OID or not. * An optional resultSlot can be passed as well. */ -JunkFilter* ExecInitJunkFilter(List* targetList, bool hasoid, TupleTableSlot* slot, TableAmType tam) +JunkFilter* ExecInitJunkFilter(List* targetList, bool hasoid, TupleTableSlot* slot, const TableAmRoutine* tam_ops) { JunkFilter* junkfilter = NULL; TupleDesc cleanTupType; @@ -72,7 +72,7 @@ JunkFilter* ExecInitJunkFilter(List* targetList, bool hasoid, TupleTableSlot* sl /* * Compute the tuple descriptor for the cleaned tuple. */ - cleanTupType = ExecCleanTypeFromTL(targetList, hasoid, tam); + cleanTupType = ExecCleanTypeFromTL(targetList, hasoid, tam_ops); /* * Use the given slot, or make a new slot if we weren't given one. @@ -162,7 +162,7 @@ JunkFilter* ExecInitJunkFilterConversion(List* targetList, TupleDesc cleanTupTyp cleanMap = (AttrNumber*)palloc0(cleanLength * sizeof(AttrNumber)); t = list_head(targetList); for (i = 0; i < cleanLength; i++) { - if (cleanTupType->attrs[i]->attisdropped) + if (cleanTupType->attrs[i].attisdropped) continue; /* map entry is already zero */ for (;;) { TargetEntry* tle = (TargetEntry*)lfirst(t); @@ -208,7 +208,7 @@ void ExecInitJunkAttr(EState* estate, CmdType operation, List* targetlist, Resul j = ExecInitJunkFilter(targetlist, result_rel_info->ri_RelationDesc->rd_att->tdhasoid, - ExecInitExtraTupleSlot(estate, GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type))); + ExecInitExtraTupleSlot(estate, GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type)), TableAmHeap); if (operation == CMD_UPDATE || operation == CMD_DELETE || operation == CMD_MERGE) { /* For UPDATE/DELETE, find the appropriate junk attr now */ @@ -461,7 +461,7 @@ void ExecSetjunkFilteDescriptor(JunkFilter* junkfilter, TupleDesc tupdesc) for (i = 0; i < cleanLength; i++) { int j = cleanMap[i]; if (j > 0) - resultslotTupType->attrs[i]->atttypid = tupdesc->attrs[j - 1]->atttypid; + resultslotTupType->attrs[i].atttypid = tupdesc->attrs[j - 1].atttypid; } } diff --git a/src/gausskernel/runtime/executor/execMain.cpp b/src/gausskernel/runtime/executor/execMain.cpp index 255e4299a..a25e031e3 100755 --- a/src/gausskernel/runtime/executor/execMain.cpp +++ b/src/gausskernel/runtime/executor/execMain.cpp @@ -1555,7 +1555,7 @@ void InitPlan(QueryDesc *queryDesc, int eflags) if (junk_filter_needed) { JunkFilter *j = NULL; - j = ExecInitJunkFilter(planstate->plan->targetlist, tupType->tdhasoid, ExecInitExtraTupleSlot(estate), tupType->tdTableAmType); + j = ExecInitJunkFilter(planstate->plan->targetlist, tupType->tdhasoid, ExecInitExtraTupleSlot(estate), tupType->td_tam_ops); estate->es_junkFilter = j; /* Want to return the cleaned tuple type */ @@ -2531,7 +2531,7 @@ bool ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState int attrChk; for (attrChk = 1; attrChk <= natts; attrChk++) { - if (tupdesc->attrs[attrChk - 1]->attnotnull && tableam_tslot_attisnull(slot, attrChk)) { + if (tupdesc->attrs[attrChk - 1].attnotnull && tableam_tslot_attisnull(slot, attrChk)) { /* Skip auto_increment attribute not null check, ExecAutoIncrement will deal with it. */ if (skipAutoInc && constr->cons_autoinc && constr->cons_autoinc->attnum == attrChk) { continue; @@ -2551,7 +2551,7 @@ bool ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState bool can_ignore = estate->es_plannedstmt && estate->es_plannedstmt->hasIgnore; ereport(can_ignore ? WARNING : 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)); return false; } @@ -2712,7 +2712,7 @@ char *ExecBuildSlotValueDescription(Oid reloid, TupleTableSlot *slot, TupleDesc int vallen; /* ignore dropped columns */ - if (tupdesc->attrs[i]->attisdropped) { + if (tupdesc->attrs[i].attisdropped) { continue; } @@ -2723,8 +2723,8 @@ char *ExecBuildSlotValueDescription(Oid reloid, TupleTableSlot *slot, TupleDesc * data for the column. If not, omit this column from the error * message. */ - aclresult = pg_attribute_aclcheck(reloid, tupdesc->attrs[i]->attnum, GetUserId(), ACL_SELECT); - if (bms_is_member(tupdesc->attrs[i]->attnum - FirstLowInvalidHeapAttributeNumber, modifiedCols) || + aclresult = pg_attribute_aclcheck(reloid, tupdesc->attrs[i].attnum, GetUserId(), ACL_SELECT); + if (bms_is_member(tupdesc->attrs[i].attnum - FirstLowInvalidHeapAttributeNumber, modifiedCols) || aclresult == ACLCHECK_OK) { column_perm = any_perm = true; @@ -2734,7 +2734,7 @@ char *ExecBuildSlotValueDescription(Oid reloid, TupleTableSlot *slot, TupleDesc write_comma_collist = true; } - appendStringInfoString(&collist, NameStr(tupdesc->attrs[i]->attname)); + appendStringInfoString(&collist, NameStr(tupdesc->attrs[i].attname)); } } @@ -2745,7 +2745,7 @@ char *ExecBuildSlotValueDescription(Oid reloid, TupleTableSlot *slot, TupleDesc Oid foutoid; bool typisvarlena = false; - getTypeOutputInfo(tupdesc->attrs[i]->atttypid, &foutoid, &typisvarlena); + getTypeOutputInfo(tupdesc->attrs[i].atttypid, &foutoid, &typisvarlena); val = OidOutputFunctionCall(foutoid, slot->tts_values[i]); } @@ -3439,20 +3439,20 @@ void EvalPlanQualFetchRowMarksUHeap(EPQState *epqstate) HeapTupleData tuple; MemoryContext oldcxt; TupleDesc tupdesc; + Form_pg_attribute attrs[erm->numAttrs]; Datum *data = (Datum *)palloc0(sizeof(Datum) * erm->numAttrs); bool *null = (bool *)palloc0(sizeof(bool) * erm->numAttrs); - oldcxt = MemoryContextSwitchTo(u_sess->cache_mem_cxt); - tupdesc = (TupleDesc)palloc0(sizeof(tupleDesc)); - MemoryContextSwitchTo(oldcxt); - for (int i = 0; i < erm->numAttrs; i++) { data[i] = ExecGetJunkAttribute(epqstate->origslot, aerm->wholeAttNo + i, &null[i]); + attrs[i] = &epqstate->origslot->tts_tupleDescriptor->attrs[aerm->wholeAttNo - 1 + i]; } + oldcxt = MemoryContextSwitchTo(u_sess->cache_mem_cxt); + tupdesc = CreateTupleDesc(erm->numAttrs, false, attrs); + MemoryContextSwitchTo(oldcxt); tupdesc->natts = erm->numAttrs; - tupdesc->attrs = &epqstate->origslot->tts_tupleDescriptor->attrs[aerm->wholeAttNo - 1]; tupdesc->tdhasoid = false; ExecSetSlotDescriptor(slot, tupdesc); @@ -3619,12 +3619,16 @@ void EvalPlanQualFetchRowMarks(EPQState *epqstate) Assert(erm->markType == ROW_MARK_COPY_DATUM); Datum *data = (Datum *)palloc0(sizeof(Datum) * erm->numAttrs); bool *null = (bool *)palloc0(sizeof(bool) * erm->numAttrs); + Form_pg_attribute attrs[erm->numAttrs]; + TupleDesc tupdesc = (TupleDesc)palloc0(sizeof(tupleDesc)); for (int i = 0; i < erm->numAttrs; i++) { data[i] = ExecGetJunkAttribute(epqstate->origslot, aerm->wholeAttNo + i, &null[i]); + attrs[i] = &epqstate->origslot->tts_tupleDescriptor->attrs[aerm->wholeAttNo - 1 + i]; } + + tupdesc = CreateTupleDesc(erm->numAttrs, false, attrs); tupdesc->natts = erm->numAttrs; - tupdesc->attrs = &epqstate->origslot->tts_tupleDescriptor->attrs[aerm->wholeAttNo - 1]; tupdesc->tdhasoid = false; tupdesc->tdisredistable = false; td = (HeapTupleHeader)((char *)heap_form_tuple(tupdesc, data, null) + HEAPTUPLESIZE); diff --git a/src/gausskernel/runtime/executor/execMerge.cpp b/src/gausskernel/runtime/executor/execMerge.cpp index d8a22d430..9aa8f0064 100644 --- a/src/gausskernel/runtime/executor/execMerge.cpp +++ b/src/gausskernel/runtime/executor/execMerge.cpp @@ -189,7 +189,7 @@ static TupleTableSlot* ExtractConstraintTuple( case CMD_UPDATE: constrSlot = mtstate->mt_update_constr_slot; for (i = 0; i < originTupleDesc->natts; i++) { - if (strstr(originTupleDesc->attrs[i]->attname.data, "action UPDATE target")) { + if (strstr(originTupleDesc->attrs[i].attname.data, "action UPDATE target")) { values[index] = slot->tts_values[i]; isnull[index] = slot->tts_isnull[i]; index++; @@ -199,7 +199,7 @@ static TupleTableSlot* ExtractConstraintTuple( case CMD_INSERT: constrSlot = mtstate->mt_insert_constr_slot; for (i = 0; i < originTupleDesc->natts; i++) { - if (strstr(originTupleDesc->attrs[i]->attname.data, "action INSERT target")) { + if (strstr(originTupleDesc->attrs[i].attname.data, "action INSERT target")) { values[index] = slot->tts_values[i]; isnull[index] = slot->tts_isnull[i]; index++; @@ -210,8 +210,8 @@ static TupleTableSlot* ExtractConstraintTuple( Assert(0); } - Assert(constrSlot->tts_tupleDescriptor->tdTableAmType == originTupleDesc->tdTableAmType); - tempTuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, values, isnull, HEAP_TUPLE); + Assert(constrSlot->tts_tupleDescriptor->td_tam_ops == originTupleDesc->td_tam_ops); + tempTuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, values, isnull); (void)ExecStoreTuple(tempTuple, constrSlot, InvalidBuffer, false); return constrSlot; @@ -247,7 +247,7 @@ TupleTableSlot* ExtractScanTuple(ModifyTableState* mtstate, TupleTableSlot* slot } for (index = 0; index < tupDesc->natts; index++) { - if (tupDesc->attrs[index]->attisdropped == true) { + if (tupDesc->attrs[index].attisdropped == true) { isnull[index] = true; continue; } @@ -257,7 +257,7 @@ TupleTableSlot* ExtractScanTuple(ModifyTableState* mtstate, TupleTableSlot* slot startIdx++; } - tempTuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, values, isnull, HEAP_TUPLE); + tempTuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, values, isnull); (void)ExecStoreTuple(tempTuple, scanSlot, InvalidBuffer, false); return scanSlot; @@ -563,7 +563,7 @@ void ExecInitMerge(ModifyTableState* mtstate, EState* estate, ResultRelInfo* res action_state->whenqual = ExecInitExpr((Expr*)action->qual, &mtstate->ps); /* create target slot for this action's projection */ - tupDesc = ExecTypeFromTL((List*)action->targetList, false, true, relationDesc->tdTableAmType); + tupDesc = ExecTypeFromTL((List*)action->targetList, false, true, relationDesc->td_tam_ops); action_state->tupDesc = tupDesc; if (IS_PGXC_DATANODE && CMD_UPDATE == action->commandType) { diff --git a/src/gausskernel/runtime/executor/execQual.cpp b/src/gausskernel/runtime/executor/execQual.cpp index 10a4afc88..4751c9737 100644 --- a/src/gausskernel/runtime/executor/execQual.cpp +++ b/src/gausskernel/runtime/executor/execQual.cpp @@ -666,7 +666,7 @@ static Datum ExecEvalScalarVar(ExprState* exprstate, ExprContext* econtext, bool errmodule(MOD_EXECUTOR), errmsg("attribute number %d exceeds number of columns %d", attnum, slot_tupdesc->natts))); - attr = slot_tupdesc->attrs[attnum - 1]; + attr = &slot_tupdesc->attrs[attnum - 1]; /* can't check type if dropped, since atttypid is probably 0 */ if (!attr->attisdropped) { @@ -814,7 +814,8 @@ static Datum ExecEvalWholeRowVar( oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_query_memory); wrvstate->wrv_junkFilter = ExecInitJunkFilter(subplan->plan->targetlist, ExecGetResultType(subplan)->tdhasoid, - ExecInitExtraTupleSlot(wrvstate->parent->state)); + ExecInitExtraTupleSlot(wrvstate->parent->state), + TableAmHeap); MemoryContextSwitchTo(oldcontext); } } @@ -860,8 +861,8 @@ static Datum ExecEvalWholeRowVar( var_tupdesc->natts))); for (i = 0; i < var_tupdesc->natts; i++) { - Form_pg_attribute vattr = var_tupdesc->attrs[i]; - Form_pg_attribute sattr = slot_tupdesc->attrs[i]; + Form_pg_attribute vattr = &var_tupdesc->attrs[i]; + Form_pg_attribute sattr = &slot_tupdesc->attrs[i]; if (vattr->atttypid == sattr->atttypid) continue; /* no worries */ @@ -1034,8 +1035,8 @@ static Datum ExecEvalWholeRowSlow( /* Check to see if any dropped attributes are non-null */ for (i = 0; i < var_tupdesc->natts; i++) { - Form_pg_attribute vattr = var_tupdesc->attrs[i]; - Form_pg_attribute sattr = tupleDesc->attrs[i]; + Form_pg_attribute vattr = &var_tupdesc->attrs[i]; + Form_pg_attribute sattr = &tupleDesc->attrs[i]; if (!vattr->attisdropped) continue; /* already checked non-dropped cols */ @@ -1405,8 +1406,8 @@ Datum GetAttributeByName(HeapTupleHeader tuple, const char* attname, bool* isNul attrno = InvalidAttrNumber; for (i = 0; i < tupDesc->natts; i++) { - if (namestrcmp(&(tupDesc->attrs[i]->attname), attname) == 0) { - attrno = tupDesc->attrs[i]->attnum; + if (namestrcmp(&(tupDesc->attrs[i].attname), attname) == 0) { + attrno = tupDesc->attrs[i].attnum; break; } } @@ -1667,7 +1668,7 @@ static void init_fcache( fcache->funcReturnsTuple = true; } else if (functypclass == TYPEFUNC_SCALAR) { /* Base data type, i.e. scalar */ - tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(1, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)1, NULL, funcrettype, -1, 0); fcache->funcResultDesc = tupdesc; fcache->funcReturnsTuple = false; @@ -1923,8 +1924,8 @@ static void tupledesc_match(TupleDesc dst_tupdesc, TupleDesc src_tupdesc) dst_tupdesc->natts))); for (i = 0; i < dst_tupdesc->natts; i++) { - Form_pg_attribute dattr = dst_tupdesc->attrs[i]; - Form_pg_attribute sattr = src_tupdesc->attrs[i]; + Form_pg_attribute dattr = &dst_tupdesc->attrs[i]; + Form_pg_attribute sattr = &src_tupdesc->attrs[i]; if (IsBinaryCoercible(sattr->atttypid, dattr->atttypid)) continue; /* no worries */ @@ -3021,7 +3022,7 @@ Tuplestorestate* ExecMakeTableFunctionResult( /* * Scalar type, so make a single-column descriptor */ - tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(1, false, TableAmHeap); TupleDescInitEntry(tupdesc, (AttrNumber)1, "column", funcrettype, -1, 0); } tupstore = tuplestore_begin_heap(randomAccess, false, u_sess->attr.attr_memory.work_mem); @@ -4147,7 +4148,7 @@ static Datum ExecEvalRow(RowExprState* rstate, ExprContext* econtext, bool* isNu i++; } - tuple = (HeapTuple)tableam_tops_form_tuple(rstate->tupdesc, values, isnull, HEAP_TUPLE); + tuple = (HeapTuple)tableam_tops_form_tuple(rstate->tupdesc, values, isnull); pfree_ext(values); pfree_ext(isnull); @@ -4551,7 +4552,7 @@ static Datum CheckRowTypeIsNull(TupleDesc tupDesc, HeapTupleData tmptup, NullTes for (att = 1; att <= tupDesc->natts; att++) { /* ignore dropped columns */ - if (tupDesc->attrs[att - 1]->attisdropped) + if (tupDesc->attrs[att - 1].attisdropped) continue; if (tableam_tops_tuple_attisnull(&tmptup, att, tupDesc)) { /* null field disproves IS NOT NULL */ @@ -4573,7 +4574,7 @@ static Datum CheckRowTypeIsNullForAFormat(TupleDesc tupDesc, HeapTupleData tmptu for (att = 1; att <= tupDesc->natts; att++) { /* ignore dropped columns */ - if (tupDesc->attrs[att - 1]->attisdropped) + if (tupDesc->attrs[att - 1].attisdropped) continue; if (!tableam_tops_tuple_attisnull(&tmptup, att, tupDesc)) { /* non-null field disproves IS NULL */ @@ -4961,7 +4962,7 @@ static Datum ExecEvalFieldSelect(FieldSelectState* fstate, ExprContext* econtext (errcode(ERRCODE_INVALID_ATTRIBUTE), errmodule(MOD_EXECUTOR), errmsg("attribute number %d exceeds number of columns %d", fieldnum, tupDesc->natts))); - attr = tupDesc->attrs[fieldnum - 1]; + attr = &tupDesc->attrs[fieldnum - 1]; /* Check for dropped column, and force a NULL result if so */ if (attr->attisdropped) { @@ -5076,7 +5077,7 @@ static Datum ExecEvalFieldStore(FieldStoreState* fstate, ExprContext* econtext, econtext->caseValue_datum = save_datum; econtext->caseValue_isNull = save_isNull; - tuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, values, isnull, HEAP_TUPLE); + tuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, values, isnull); pfree_ext(values); pfree_ext(isnull); @@ -5676,7 +5677,7 @@ ExprState* ExecInitExpr(Expr* node, PlanState* parent) case T_RowExpr: { RowExpr* rowexpr = (RowExpr*)node; RowExprState* rstate = makeNode(RowExprState); - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; List* outlist = NIL; ListCell* l = NULL; int i; @@ -5685,7 +5686,7 @@ ExprState* ExecInitExpr(Expr* node, PlanState* parent) /* Build tupdesc to describe result tuples */ if (rowexpr->row_typeid == RECORDOID) { /* generic record, use runtime type assignment */ - rstate->tupdesc = ExecTypeFromExprList(rowexpr->args, rowexpr->colnames, TAM_HEAP); + rstate->tupdesc = ExecTypeFromExprList(rowexpr->args, rowexpr->colnames); BlessTupleDesc(rstate->tupdesc); /* we won't need to redo this at runtime */ } else { @@ -5700,19 +5701,19 @@ ExprState* ExecInitExpr(Expr* node, PlanState* parent) Expr* e = (Expr*)lfirst(l); ExprState* estate = NULL; - if (!attrs[i]->attisdropped) { + if (!attrs[i].attisdropped) { /* * Guard against ALTER COLUMN TYPE on rowtype since * the RowExpr was created. XXX should we check * typmod too? Not sure we can be sure it'll be the * same. */ - if (exprType((Node*)e) != attrs[i]->atttypid) + if (exprType((Node*)e) != attrs[i].atttypid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("ROW() column has type %s instead of type %s", format_type_be(exprType((Node*)e)), - format_type_be(attrs[i]->atttypid)))); + format_type_be(attrs[i].atttypid)))); } else { /* * Ignore original expression and insert a NULL. We diff --git a/src/gausskernel/runtime/executor/execReplication.cpp b/src/gausskernel/runtime/executor/execReplication.cpp index d22a119bb..14a07cbd8 100644 --- a/src/gausskernel/runtime/executor/execReplication.cpp +++ b/src/gausskernel/runtime/executor/execReplication.cpp @@ -423,7 +423,7 @@ static bool tuple_equals_slot(TupleDesc desc, const Tuple tup, TupleTableSlot *s if (isnull[attrnum]) continue; - att = desc->attrs[attrnum]; + att = &desc->attrs[attrnum]; typentry = eq[attrnum]; if (typentry == NULL) { typentry = lookup_type_cache(att->atttypid, TYPECACHE_EQ_OPR_FINFO); diff --git a/src/gausskernel/runtime/executor/execScan.cpp b/src/gausskernel/runtime/executor/execScan.cpp index 73e6e95db..a2303d41b 100644 --- a/src/gausskernel/runtime/executor/execScan.cpp +++ b/src/gausskernel/runtime/executor/execScan.cpp @@ -322,7 +322,7 @@ bool tlist_matches_tupdesc(PlanState* ps, List* tlist, Index var_no, TupleDesc t /* Check the tlist attributes */ for (attr_no = 1; attr_no <= num_attrs; attr_no++) { - Form_pg_attribute att_tup = tup_desc->attrs[attr_no - 1]; + Form_pg_attribute att_tup = &tup_desc->attrs[attr_no - 1]; Var* var = NULL; if (tlist_item == NULL) diff --git a/src/gausskernel/runtime/executor/execTuples.cpp b/src/gausskernel/runtime/executor/execTuples.cpp index 752d47b29..a6dcf08cb 100644 --- a/src/gausskernel/runtime/executor/execTuples.cpp +++ b/src/gausskernel/runtime/executor/execTuples.cpp @@ -100,7 +100,7 @@ #include "access/ustore/knl_utuple.h" -static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool skip_junk, bool mark_dropped = false, TableAmType tam = TAM_HEAP); +static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool skip_junk, bool mark_dropped, const TableAmRoutine* tam_ops); /* ---------------------------------------------------------------- * tuple table create/delete functions @@ -779,9 +779,9 @@ TupleTableSlot* ExecInitNullTupleSlot(EState* estate, TupleDesc tup_type) * be rewritten to call BuildDesc(). * ---------------------------------------------------------------- */ -TupleDesc ExecTypeFromTL(List* target_list, bool has_oid, bool mark_dropped, TableAmType tam) +TupleDesc ExecTypeFromTL(List* target_list, bool has_oid, bool mark_dropped, const TableAmRoutine* tam_ops) { - return ExecTypeFromTLInternal(target_list, has_oid, false, mark_dropped, tam); + return ExecTypeFromTLInternal(target_list, has_oid, false, mark_dropped, tam_ops); } /* ---------------------------------------------------------------- @@ -790,12 +790,12 @@ TupleDesc ExecTypeFromTL(List* target_list, bool has_oid, bool mark_dropped, Tab * Same as above, but resjunk columns are omitted from the result. * ---------------------------------------------------------------- */ -TupleDesc ExecCleanTypeFromTL(List* target_list, bool has_oid, TableAmType tam) +TupleDesc ExecCleanTypeFromTL(List* target_list, bool has_oid, const TableAmRoutine* tam_ops) { - return ExecTypeFromTLInternal(target_list, has_oid, true, false, tam); + return ExecTypeFromTLInternal(target_list, has_oid, true, false, tam_ops); } -static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool skip_junk, bool mark_dropped, TableAmType tam) +static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool skip_junk, bool mark_dropped, const TableAmRoutine* tam_ops) { TupleDesc type_info; ListCell* l = NULL; @@ -806,7 +806,7 @@ static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool sk len = ExecCleanTargetListLength(target_list); else len = ExecTargetListLength(target_list); - type_info = CreateTemplateTupleDesc(len, has_oid, tam); + type_info = CreateTemplateTupleDesc(len, has_oid, tam_ops); foreach (l, target_list) { TargetEntry* tle = (TargetEntry*)lfirst(l); @@ -820,7 +820,7 @@ static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool sk /* mark dropped column, maybe we can find another way some day */ if (mark_dropped && strstr(tle->resname, "........pg.dropped.")) { - type_info->attrs[cur_resno - 1]->attisdropped = true; + type_info->attrs[cur_resno - 1].attisdropped = true; } cur_resno++; @@ -834,7 +834,7 @@ static TupleDesc ExecTypeFromTLInternal(List* target_list, bool has_oid, bool sk * * Caller must also supply a list of field names (String nodes). */ -TupleDesc ExecTypeFromExprList(List* expr_list, List* names_list, TableAmType tam) +TupleDesc ExecTypeFromExprList(List* expr_list, List* names_list, const TableAmRoutine* tam_ops) { TupleDesc type_info; ListCell* le = NULL; @@ -843,7 +843,7 @@ TupleDesc ExecTypeFromExprList(List* expr_list, List* names_list, TableAmType t Assert(list_length(expr_list) == list_length(names_list)); - type_info = CreateTemplateTupleDesc(list_length(expr_list), false, tam); + type_info = CreateTemplateTupleDesc(list_length(expr_list), false, tam_ops); forboth(le, expr_list, ln, names_list) { @@ -925,11 +925,11 @@ AttInMetadata* TupleDescGetAttInMetadata(TupleDesc tup_desc) for (i = 0; i < natts; i++) { /* Ignore dropped attributes */ - if (!tup_desc->attrs[i]->attisdropped) { - att_type_id = tup_desc->attrs[i]->atttypid; + if (!tup_desc->attrs[i].attisdropped) { + att_type_id = tup_desc->attrs[i].atttypid; getTypeInputInfo(att_type_id, &att_in_func_id, &att_io_params[i]); fmgr_info(att_in_func_id, &att_in_func_info[i]); - att_typ_mods[i] = tup_desc->attrs[i]->atttypmod; + att_typ_mods[i] = tup_desc->attrs[i].atttypmod; } } att_in_meta->attinfuncs = att_in_func_info; @@ -958,7 +958,7 @@ HeapTuple BuildTupleFromCStrings(AttInMetadata* att_in_meta, char** values) /* Call the "in" function for each non-dropped attribute */ for (i = 0; i < natts; i++) { - if (!tup_desc->attrs[i]->attisdropped) { + if (!tup_desc->attrs[i].attisdropped) { /* Non-dropped attributes */ d_values[i] = InputFunctionCall( &att_in_meta->attinfuncs[i], values[i], att_in_meta->attioparams[i], att_in_meta->atttypmods[i]); @@ -974,7 +974,7 @@ HeapTuple BuildTupleFromCStrings(AttInMetadata* att_in_meta, char** values) /* * Form a tuple */ - tuple = (HeapTuple)tableam_tops_form_tuple(tup_desc, d_values, nulls, HEAP_TUPLE); + tuple = (HeapTuple)tableam_tops_form_tuple(tup_desc, d_values, nulls); /* * Release locally palloc'd space. XXX would probably be good to pfree diff --git a/src/gausskernel/runtime/executor/execUtils.cpp b/src/gausskernel/runtime/executor/execUtils.cpp index 2dec62fa4..c7ca021ae 100644 --- a/src/gausskernel/runtime/executor/execUtils.cpp +++ b/src/gausskernel/runtime/executor/execUtils.cpp @@ -468,7 +468,7 @@ void ExecAssignResultType(PlanState* planstate, TupleDesc tupDesc) * ExecAssignResultTypeFromTL * ---------------- */ -void ExecAssignResultTypeFromTL(PlanState* planstate, TableAmType tam) +void ExecAssignResultTypeFromTL(PlanState* planstate, const TableAmRoutine* tam_ops) { bool hasoid = false; TupleDesc tupDesc; @@ -485,7 +485,7 @@ void ExecAssignResultTypeFromTL(PlanState* planstate, TableAmType tam) * list of ExprStates. This is good because some plan nodes don't bother * to set up planstate->targetlist ... */ - tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid, false, tam); + tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid, false, tam_ops); ExecAssignResultType(planstate, tupDesc); } @@ -675,7 +675,7 @@ ProjectionInfo* ExecBuildVecProjectionInfo( else if (variable->varattno <= inputDesc->natts) { Form_pg_attribute attr; - attr = inputDesc->attrs[variable->varattno - 1]; + attr = &inputDesc->attrs[variable->varattno - 1]; if (!attr->attisdropped && variable->vartype == attr->atttypid) isSimpleVar = true; } @@ -830,7 +830,7 @@ ProjectionInfo* ExecBuildProjectionInfo( else if (variable->varattno <= inputDesc->natts) { Form_pg_attribute attr; - attr = inputDesc->attrs[variable->varattno - 1]; + attr = &inputDesc->attrs[variable->varattno - 1]; if (!attr->attisdropped && variable->vartype == attr->atttypid) isSimpleVar = true; } @@ -1512,7 +1512,7 @@ Tuple ExecAutoIncrement(Relation rel, EState* estate, TupleTableSlot* slot, Tupl if (is_null) { autoinc = 0; - modify_tuple = rel->rd_att->attrs[attnum - 1]->attnotnull; + modify_tuple = rel->rd_att->attrs[attnum - 1].attnotnull; } else { autoinc = datum2autoinc(cons_autoinc, datum); modify_tuple = (autoinc == 0); @@ -2760,8 +2760,8 @@ Tuple ReplaceTupleNullCol(TupleDesc tupleDesc, TupleTableSlot *slot) int attrChk; for (attrChk = 1; attrChk <= natts; attrChk++) { - if (tupleDesc->attrs[attrChk - 1]->attnotnull && tableam_tslot_attisnull(slot, attrChk)) { - values[attrChk - 1] = GetTypeZeroValue(tupleDesc->attrs[attrChk - 1]); + if (tupleDesc->attrs[attrChk - 1].attnotnull && tableam_tslot_attisnull(slot, attrChk)) { + values[attrChk - 1] = GetTypeZeroValue(&tupleDesc->attrs[attrChk - 1]); replaces[attrChk - 1] = true; } } diff --git a/src/gausskernel/runtime/executor/functions.cpp b/src/gausskernel/runtime/executor/functions.cpp index f2c161d33..2e38c3ea9 100644 --- a/src/gausskernel/runtime/executor/functions.cpp +++ b/src/gausskernel/runtime/executor/functions.cpp @@ -1270,8 +1270,8 @@ Datum fmgr_sql(PG_FUNCTION_ARGS) if (IsClientLogicType(fcache->rettype)) { for (int i = 0; i < rsi->expectedDesc->natts; i++) { - if (IsClientLogicType(rsi->expectedDesc->attrs[i]->atttypid)) { - rsi->expectedDesc->attrs[i]->atttypmod = fcache->rettype_orig; + if (IsClientLogicType(rsi->expectedDesc->attrs[i].atttypid)) { + rsi->expectedDesc->attrs[i].atttypmod = fcache->rettype_orig; } } } @@ -1692,7 +1692,7 @@ bool check_sql_fn_retval(Oid func_id, Oid ret_type, List* query_tree_list, bool* /* Set up junk filter if needed */ if (junk_filter != NULL) - *junk_filter = ExecInitJunkFilter(tlist, false, NULL); + *junk_filter = ExecInitJunkFilter(tlist, false, NULL, TableAmHeap); } else if (fn_type == TYPTYPE_COMPOSITE || ret_type == RECORDOID) { /* Returns a rowtype */ TupleDesc tup_desc; @@ -1730,7 +1730,7 @@ bool check_sql_fn_retval(Oid func_id, Oid ret_type, List* query_tree_list, bool* } /* Set up junk filter if needed */ if (junk_filter != NULL) - *junk_filter = ExecInitJunkFilter(tlist, false, NULL); + *junk_filter = ExecInitJunkFilter(tlist, false, NULL, TableAmHeap); return false; /* NOT returning whole tuple */ } } @@ -1742,7 +1742,7 @@ bool check_sql_fn_retval(Oid func_id, Oid ret_type, List* query_tree_list, bool* * what the caller expects will happen at runtime. */ if (junk_filter != NULL) - *junk_filter = ExecInitJunkFilter(tlist, false, NULL); + *junk_filter = ExecInitJunkFilter(tlist, false, NULL, TableAmHeap); return true; } Assert(tup_desc); @@ -1778,7 +1778,7 @@ bool check_sql_fn_retval(Oid func_id, Oid ret_type, List* query_tree_list, bool* (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(ret_type)), errdetail("Final statement returns too many columns."))); - attr = tup_desc->attrs[col_index - 1]; + attr = &tup_desc->attrs[col_index - 1]; if (attr->attisdropped && modify_target_list) { Expr* null_expr = NULL; @@ -1831,7 +1831,7 @@ bool check_sql_fn_retval(Oid func_id, Oid ret_type, List* query_tree_list, bool* for (int j = 0; j < col_index - 1; j++) { all_types_orig[j] = -1; - all_types[j] = ObjectIdGetDatum(tup_desc->attrs[j]->atttypid); + all_types[j] = ObjectIdGetDatum(tup_desc->attrs[j].atttypid); } } all_types_orig[col_index - 1] = ObjectIdGetDatum(att_type); @@ -1869,7 +1869,7 @@ bool check_sql_fn_retval(Oid func_id, Oid ret_type, List* query_tree_list, bool* /* remaining columns in tupdesc had better all be dropped */ for (col_index++; col_index <= tup_natts; col_index++) { - if (!tup_desc->attrs[col_index - 1]->attisdropped) + if (!tup_desc->attrs[col_index - 1].attisdropped) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(ret_type)), diff --git a/src/gausskernel/runtime/executor/nodeAgg.cpp b/src/gausskernel/runtime/executor/nodeAgg.cpp index 4b7772e2b..8a3b5c135 100644 --- a/src/gausskernel/runtime/executor/nodeAgg.cpp +++ b/src/gausskernel/runtime/executor/nodeAgg.cpp @@ -295,7 +295,7 @@ static void initialize_aggregate(AggState* aggstate, AggStatePerAgg peraggstate, */ if (peraggstate->numInputs == 1) { peraggstate->sortstates[aggstate->current_set] = - tuplesort_begin_datum(peraggstate->evaldesc->attrs[0]->atttypid, + tuplesort_begin_datum(peraggstate->evaldesc->attrs[0].atttypid, peraggstate->sortOperators[0], peraggstate->sortCollations[0], peraggstate->sortNullsFirst[0], @@ -2093,7 +2093,7 @@ AggState* ExecInitAgg(Agg* node, EState* estate, int eflags) * Result tuple slot of Aggregation always contains a virtual tuple, * Default tableAMtype for this slot is Heap. */ - ExecAssignResultTypeFromTL(&aggstate->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&aggstate->ss.ps); ExecAssignProjectionInfo(&aggstate->ss.ps, NULL); aggstate->ss.ps.ps_TupFromTlist = false; diff --git a/src/gausskernel/runtime/executor/nodeAppend.cpp b/src/gausskernel/runtime/executor/nodeAppend.cpp index f5cd48631..550b222dd 100644 --- a/src/gausskernel/runtime/executor/nodeAppend.cpp +++ b/src/gausskernel/runtime/executor/nodeAppend.cpp @@ -165,7 +165,7 @@ AppendState* ExecInitAppend(Append* node, EState* estate, int eflags) * Result tuple slot of Append always contains a virtual tuple, * Default tableAMtype for this slot is Heap. */ - ExecAssignResultTypeFromTL(&appendstate->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&appendstate->ps); appendstate->ps.ps_ProjInfo = NULL; /* diff --git a/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp b/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp index 9d6aa6b78..b2c287b1a 100644 --- a/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp +++ b/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp @@ -898,11 +898,11 @@ BitmapHeapScanState* ExecInitBitmapHeapScan(BitmapHeapScan* node, EState* estate */ ExecAssignResultTypeFromTL( &scanstate->ss.ps, - scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfo(&scanstate->ss); - Assert(scanstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(scanstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * initialize child nodes diff --git a/src/gausskernel/runtime/executor/nodeCtescan.cpp b/src/gausskernel/runtime/executor/nodeCtescan.cpp index c84d95490..0ec427375 100644 --- a/src/gausskernel/runtime/executor/nodeCtescan.cpp +++ b/src/gausskernel/runtime/executor/nodeCtescan.cpp @@ -260,10 +260,10 @@ CteScanState* ExecInitCteScan(CteScan* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &scanstate->ss.ps, - scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfo(&scanstate->ss); - Assert(scanstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(scanstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); scanstate->ss.ps.ps_TupFromTlist = false; diff --git a/src/gausskernel/runtime/executor/nodeExtensible.cpp b/src/gausskernel/runtime/executor/nodeExtensible.cpp index 7f83626da..709b96a92 100644 --- a/src/gausskernel/runtime/executor/nodeExtensible.cpp +++ b/src/gausskernel/runtime/executor/nodeExtensible.cpp @@ -143,7 +143,7 @@ ExtensiblePlanState* ExecInitExtensiblePlan(ExtensiblePlan* eplan, EState* estat if (eplan->extensible_plan_tlist != NIL || scan_rel == NULL) { TupleDesc scan_tupdesc; - scan_tupdesc = ExecTypeFromTL(eplan->extensible_plan_tlist, false, false, TAM_HEAP); + scan_tupdesc = ExecTypeFromTL(eplan->extensible_plan_tlist, false, false); ExecAssignScanType(&extensionPlanState->ss, scan_tupdesc); /* Node's targetlist will contain Vars with varno = INDEX_VAR */ tlistvarno = INDEX_VAR; @@ -158,9 +158,9 @@ ExtensiblePlanState* ExecInitExtensiblePlan(ExtensiblePlan* eplan, EState* estat */ ExecAssignResultTypeFromTL( &extensionPlanState->ss.ps, - extensionPlanState->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + extensionPlanState->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfoWithVarno(&extensionPlanState->ss, tlistvarno); - Assert(extensionPlanState->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(extensionPlanState->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * The callback of extensible-scan provider applies the final initialization diff --git a/src/gausskernel/runtime/executor/nodeForeignscan.cpp b/src/gausskernel/runtime/executor/nodeForeignscan.cpp index 3ca0060b7..113e9c20e 100644 --- a/src/gausskernel/runtime/executor/nodeForeignscan.cpp +++ b/src/gausskernel/runtime/executor/nodeForeignscan.cpp @@ -229,7 +229,7 @@ ForeignScanState* ExecInitForeignScan(ForeignScan* node, EState* estate, int efl */ ExecAssignResultTypeFromTL( &scanstate->ss.ps, - scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfoWithVarno(&scanstate->ss, tlistvarno); scanstate->fdwroutine = fdwroutine; diff --git a/src/gausskernel/runtime/executor/nodeFunctionscan.cpp b/src/gausskernel/runtime/executor/nodeFunctionscan.cpp index 11122c254..40fa50a4d 100644 --- a/src/gausskernel/runtime/executor/nodeFunctionscan.cpp +++ b/src/gausskernel/runtime/executor/nodeFunctionscan.cpp @@ -154,22 +154,22 @@ FunctionScanState* ExecInitFunctionScan(FunctionScan* node, EState* estate, int Assert(tupdesc); /* Must copy it out of typcache for safety */ tupdesc = CreateTupleDescCopy(tupdesc); - if (tupdesc->tdTableAmType != TAM_HEAP) { + if (tupdesc->td_tam_ops != TableAmHeap) { /* For function scan, we need tupdesc type to be heap, * and invalidate attcacheoff, since other storage type * uses different offset values than heap. */ int i; for (i = 0; i < tupdesc->natts; i++) { - tupdesc->attrs[i]->attcacheoff = -1; + tupdesc->attrs[i].attcacheoff = -1; } - tupdesc->tdTableAmType = TAM_HEAP; + tupdesc->td_tam_ops = TableAmHeap; } } else if (functypclass == TYPEFUNC_SCALAR) { /* Base data type, i.e. scalar */ char* attname = strVal(linitial(node->funccolnames)); - tupdesc = CreateTemplateTupleDesc(1, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(1, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, attname, funcrettype, -1, 0); TupleDescInitEntryCollation(tupdesc, (AttrNumber)1, exprCollation(node->funcexpr)); } else if (functypclass == TYPEFUNC_RECORD) { @@ -204,11 +204,11 @@ FunctionScanState* ExecInitFunctionScan(FunctionScan* node, EState* estate, int */ ExecAssignResultTypeFromTL( &scanstate->ss.ps, - scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + scanstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfo(&scanstate->ss); - Assert(scanstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(scanstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); return scanstate; } diff --git a/src/gausskernel/runtime/executor/nodeGroup.cpp b/src/gausskernel/runtime/executor/nodeGroup.cpp index 499225edb..fcb0fbe44 100644 --- a/src/gausskernel/runtime/executor/nodeGroup.cpp +++ b/src/gausskernel/runtime/executor/nodeGroup.cpp @@ -233,7 +233,7 @@ GroupState* ExecInitGroup(Group* node, EState* estate, int eflags) * Group node result tuple slot always holds virtual tuple, so * default tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&grpstate->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&grpstate->ss.ps); ExecAssignProjectionInfo(&grpstate->ss.ps, NULL); diff --git a/src/gausskernel/runtime/executor/nodeHash.cpp b/src/gausskernel/runtime/executor/nodeHash.cpp index 3b3b56693..447e4adf4 100644 --- a/src/gausskernel/runtime/executor/nodeHash.cpp +++ b/src/gausskernel/runtime/executor/nodeHash.cpp @@ -247,11 +247,11 @@ HashState* ExecInitHash(Hash* node, EState* estate, int eflags) * this node doesn't do projections */ TupleDesc resultDesc = ExecGetResultType(outerPlanState(hashstate)); - ExecAssignResultTypeFromTL(&hashstate->ps, resultDesc->tdTableAmType); + ExecAssignResultTypeFromTL(&hashstate->ps, resultDesc->td_tam_ops); hashstate->ps.ps_ProjInfo = NULL; - Assert(hashstate->ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(hashstate->ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); return hashstate; } diff --git a/src/gausskernel/runtime/executor/nodeHashjoin.cpp b/src/gausskernel/runtime/executor/nodeHashjoin.cpp index 829b1f280..01b83edc4 100755 --- a/src/gausskernel/runtime/executor/nodeHashjoin.cpp +++ b/src/gausskernel/runtime/executor/nodeHashjoin.cpp @@ -631,7 +631,7 @@ HashJoinState* ExecInitHashJoin(HashJoin* node, EState* estate, int eflags) * result tupleSlot only contains virtual tuple, so the default * tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&hjstate->js.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&hjstate->js.ps); ExecAssignProjectionInfo(&hjstate->js.ps, NULL); ExecSetSlotDescriptor(hjstate->hj_OuterTupleSlot, ExecGetResultType(outerPlanState(hjstate))); diff --git a/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp b/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp index 222bdfbc1..8034c7b6e 100644 --- a/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp +++ b/src/gausskernel/runtime/executor/nodeIndexonlyscan.cpp @@ -599,7 +599,7 @@ IndexOnlyScanState* ExecInitIndexOnlyScan(IndexOnlyScan* node, EState* estate, i * types of the original datums. (It's the AM's responsibility to return * suitable data anyway.) */ - tupDesc = ExecTypeFromTL(node->indextlist, false, false, TAM_HEAP); + tupDesc = ExecTypeFromTL(node->indextlist, false, false); ExecAssignScanType(&indexstate->ss, tupDesc); /* @@ -607,11 +607,11 @@ IndexOnlyScanState* ExecInitIndexOnlyScan(IndexOnlyScan* node, EState* estate, i */ ExecAssignResultTypeFromTL( &indexstate->ss.ps, - indexstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + indexstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfo(&indexstate->ss); - Assert(indexstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(indexstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop diff --git a/src/gausskernel/runtime/executor/nodeIndexscan.cpp b/src/gausskernel/runtime/executor/nodeIndexscan.cpp index f4af00871..451303826 100644 --- a/src/gausskernel/runtime/executor/nodeIndexscan.cpp +++ b/src/gausskernel/runtime/executor/nodeIndexscan.cpp @@ -700,19 +700,19 @@ IndexScanState* ExecInitIndexScan(IndexScan* node, EState* estate, int eflags) * get the scan type from the relation descriptor. */ ExecAssignScanType(&index_state->ss, CreateTupleDescCopy(RelationGetDescr(current_relation))); - index_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType = current_relation->rd_tam_type; + index_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(current_relation->rd_tam_type); /* * Initialize result tuple type and projection info. */ ExecAssignResultTypeFromTL(&index_state->ss.ps); - index_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType = - index_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType; + index_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops = + index_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops; ExecAssignScanProjectionInfo(&index_state->ss); - Assert(index_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(index_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop diff --git a/src/gausskernel/runtime/executor/nodeLimit.cpp b/src/gausskernel/runtime/executor/nodeLimit.cpp index b402b697f..f0f34417e 100644 --- a/src/gausskernel/runtime/executor/nodeLimit.cpp +++ b/src/gausskernel/runtime/executor/nodeLimit.cpp @@ -390,7 +390,7 @@ LimitState* ExecInitLimit(Limit* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &limit_state->ps, - ExecGetResultType(outerPlanState(limit_state))->tdTableAmType); + ExecGetResultType(outerPlanState(limit_state))->td_tam_ops); limit_state->ps.ps_ProjInfo = NULL; diff --git a/src/gausskernel/runtime/executor/nodeLockRows.cpp b/src/gausskernel/runtime/executor/nodeLockRows.cpp index 62e7aa4d3..cb6458b89 100755 --- a/src/gausskernel/runtime/executor/nodeLockRows.cpp +++ b/src/gausskernel/runtime/executor/nodeLockRows.cpp @@ -468,11 +468,11 @@ LockRowsState* ExecInitLockRows(LockRows* node, EState* estate, int eflags) * this node appropriately */ TupleDesc resultDesc = ExecGetResultType(outerPlanState(lrstate)); - ExecAssignResultTypeFromTL(&lrstate->ps, resultDesc->tdTableAmType); + ExecAssignResultTypeFromTL(&lrstate->ps, resultDesc->td_tam_ops); lrstate->ps.ps_ProjInfo = NULL; - Assert(lrstate->ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(lrstate->ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * Locate the ExecRowMark(s) that this node is responsible for, and diff --git a/src/gausskernel/runtime/executor/nodeMaterial.cpp b/src/gausskernel/runtime/executor/nodeMaterial.cpp index 7173cd572..f3c2dd595 100644 --- a/src/gausskernel/runtime/executor/nodeMaterial.cpp +++ b/src/gausskernel/runtime/executor/nodeMaterial.cpp @@ -357,11 +357,11 @@ MaterialState* ExecInitMaterial(Material* node, EState* estate, int eflags) ExecAssignResultTypeFromTL( &mat_state->ss.ps, - mat_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + mat_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); mat_state->ss.ps.ps_ProjInfo = NULL; - Assert(mat_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(mat_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * Lastly, if this Material node is under subplan and used for materializing diff --git a/src/gausskernel/runtime/executor/nodeMergeAppend.cpp b/src/gausskernel/runtime/executor/nodeMergeAppend.cpp index c6da728bb..be9a035ff 100644 --- a/src/gausskernel/runtime/executor/nodeMergeAppend.cpp +++ b/src/gausskernel/runtime/executor/nodeMergeAppend.cpp @@ -121,7 +121,7 @@ MergeAppendState* ExecInitMergeAppend(MergeAppend* node, EState* estate, int efl * src/gausskernel/runtime/executor/nodeMergeAppend.cpp * set to default value HEAP */ - ExecAssignResultTypeFromTL(&merge_state->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&merge_state->ps); merge_state->ps.ps_ProjInfo = NULL; /* diff --git a/src/gausskernel/runtime/executor/nodeMergejoin.cpp b/src/gausskernel/runtime/executor/nodeMergejoin.cpp index 281ffe912..e5baa3efe 100644 --- a/src/gausskernel/runtime/executor/nodeMergejoin.cpp +++ b/src/gausskernel/runtime/executor/nodeMergejoin.cpp @@ -1529,7 +1529,7 @@ MergeJoinState* ExecInitMergeJoin(MergeJoin* node, EState* estate, int eflags) * result table tuple slot for merge join contains virtual tuple, so the * default tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&merge_state->js.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&merge_state->js.ps, TableAmHeap); ExecAssignProjectionInfo(&merge_state->js.ps, NULL); /* * preprocess the merge clauses diff --git a/src/gausskernel/runtime/executor/nodeModifyTable.cpp b/src/gausskernel/runtime/executor/nodeModifyTable.cpp index 902d19e43..b93cde5b8 100644 --- a/src/gausskernel/runtime/executor/nodeModifyTable.cpp +++ b/src/gausskernel/runtime/executor/nodeModifyTable.cpp @@ -218,7 +218,7 @@ void ExecCheckPlanOutput(Relation resultRel, List* targetList) errmodule(MOD_EXECUTOR), errmsg("table row type and query-specified row type do not match"), errdetail("Query has too many columns."))); - attr = result_desc->attrs[attno++]; + attr = &result_desc->attrs[attno++]; if (!attr->attisdropped) { /* Normal case: demand type match */ @@ -1282,7 +1282,7 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple tuple = tableam_tops_form_tuple(slot->tts_tupleDescriptor, slot->tts_values, slot->tts_isnull, - RelationGetTupleType(result_relation_desc)); + GetTableAmRoutine(result_relation_desc->rd_tam_type)); if (rel_isblockchain) { MemoryContext old_context = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate)); tuple = set_user_tuple_hash((HeapTuple)tuple, result_relation_desc); @@ -3219,7 +3219,7 @@ static TupleTableSlot* ExecReplace(EState* estate, ModifyTableState* node, Tuple /* REPLACE INTO not support sequence, check columns to report ERROR */ for (int attrno=1; attrno<=rel->rd_att->natts; ++attrno) { - att_tup = rel->rd_att->attrs[attrno-1]; + att_tup = &rel->rd_att->attrs[attrno-1]; errno_t rc; char *nspname = get_namespace_name(rel->rd_rel->relnamespace); char tableName[NAMEDATALEN*2+2] = {0}; @@ -3531,7 +3531,7 @@ static TupleTableSlot* ExecModifyTable(PlanState* state) if (estate->result_rel_index == 0) EvalPlanQualSetSlot(&node->mt_epqstate, plan_slot); slot = plan_slot; - slot->tts_tupleDescriptor->tdTableAmType = result_rel_info->ri_RelationDesc->rd_tam_type; + slot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(result_rel_info->ri_RelationDesc->rd_tam_type); if (operation == CMD_MERGE) { if (junk_filter == NULL) { @@ -4055,7 +4055,8 @@ ModifyTableState* ExecInitModifyTable(ModifyTable* node, EState* estate, int efl * Initialize result tuple slot and assign its rowtype using the first * RETURNING list. We assume the rest will look the same. */ - tup_desc = ExecTypeFromTL((List*)linitial(node->returningLists), false, false, mt_state->resultRelInfo->ri_RelationDesc->rd_tam_type); + tup_desc = ExecTypeFromTL((List*)linitial(node->returningLists), false, false, + GetTableAmRoutine(mt_state->resultRelInfo->ri_RelationDesc->rd_tam_type)); /* Set up a slot for the output of the RETURNING projection(s) */ ExecInitResultTupleSlot(estate, &mt_state->ps); diff --git a/src/gausskernel/runtime/executor/nodeNestloop.cpp b/src/gausskernel/runtime/executor/nodeNestloop.cpp index dfe3e12f0..0bfab53b3 100644 --- a/src/gausskernel/runtime/executor/nodeNestloop.cpp +++ b/src/gausskernel/runtime/executor/nodeNestloop.cpp @@ -403,7 +403,7 @@ NestLoopState* ExecInitNestLoop(NestLoop* node, EState* estate, int eflags) * initialize tuple type and projection info * the result in this case would hold only virtual data. */ - ExecAssignResultTypeFromTL(&nlstate->js.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&nlstate->js.ps, TableAmHeap); ExecAssignProjectionInfo(&nlstate->js.ps, NULL); /* diff --git a/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp b/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp index c894b288b..c52e05b80 100644 --- a/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp +++ b/src/gausskernel/runtime/executor/nodeRecursiveunion.cpp @@ -584,7 +584,7 @@ RecursiveUnionState* ExecInitRecursiveUnion(RecursiveUnion* node, EState* estate * set up the result type before initializing child nodes, because * nodeWorktablescan.c expects it to be valid.) */ - ExecAssignResultTypeFromTL(&rustate->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&rustate->ps); rustate->ps.ps_ProjInfo = NULL; /* diff --git a/src/gausskernel/runtime/executor/nodeResult.cpp b/src/gausskernel/runtime/executor/nodeResult.cpp index db482c403..73cde6049 100644 --- a/src/gausskernel/runtime/executor/nodeResult.cpp +++ b/src/gausskernel/runtime/executor/nodeResult.cpp @@ -267,7 +267,7 @@ ResultState* ExecInitResult(BaseResult* node, EState* estate, int eflags) * no relations are involved in nodeResult, set the default * tableAm type to HEAP */ - ExecAssignResultTypeFromTL(&resstate->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&resstate->ps); ExecAssignProjectionInfo(&resstate->ps, NULL); diff --git a/src/gausskernel/runtime/executor/nodeSamplescan.cpp b/src/gausskernel/runtime/executor/nodeSamplescan.cpp index 630df3815..221c8e3f3 100644 --- a/src/gausskernel/runtime/executor/nodeSamplescan.cpp +++ b/src/gausskernel/runtime/executor/nodeSamplescan.cpp @@ -116,7 +116,7 @@ static inline UHeapTuple USampleFetchNextTuple(SeqScanState* node) TupleTableSlot* HeapSeqSampleNext(SeqScanState* node) { TupleTableSlot* slot = node->ss_ScanTupleSlot; - node->ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType = node->ss_currentRelation->rd_tam_type; + node->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(node->ss_currentRelation->rd_tam_type); HeapTuple tuple = SampleFetchNextTuple(node); return ExecMakeTupleSlot(tuple, GetTableScanDesc(node->ss_currentScanDesc, node->ss_currentRelation), @@ -174,7 +174,7 @@ TupleTableSlot* HbktSeqSampleNext(SeqScanState* node) (((RowTableSample*)node->sampleScanInfo.tsm_state)->resetSampleScan)(); } - node->ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType = node->ss_currentRelation->rd_tam_type; + node->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops = GetTableAmRoutine(node->ss_currentRelation->rd_tam_type); return ExecMakeTupleSlot( (Tuple) tuple, GetTableScanDesc(node->ss_currentScanDesc, node->ss_currentRelation), slot, @@ -968,7 +968,7 @@ void ColumnTableSample::getMaxOffset() curBlockMaxoffset = InvalidOffsetNumber; /* If the first column has dropped, we should change the index of first column. */ - if (vecsampleScanState->ss_currentRelation->rd_att->attrs[0]->attisdropped) { + if (vecsampleScanState->ss_currentRelation->rd_att->attrs[0].attisdropped) { fstColIdx = CStoreGetfstColIdx(vecsampleScanState->ss_currentRelation); } diff --git a/src/gausskernel/runtime/executor/nodeSeqscan.cpp b/src/gausskernel/runtime/executor/nodeSeqscan.cpp index 6cbe203db..cacd745f8 100644 --- a/src/gausskernel/runtime/executor/nodeSeqscan.cpp +++ b/src/gausskernel/runtime/executor/nodeSeqscan.cpp @@ -1011,7 +1011,7 @@ SeqScanState* ExecInitSeqScan(SeqScan* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &scanstate->ps, - scanstate->ss_currentRelation->rd_tam_type); + GetTableAmRoutine(scanstate->ss_currentRelation->rd_tam_type)); ExecAssignScanProjectionInfo(scanstate); @@ -1027,7 +1027,7 @@ SeqScanState* ExecInitSeqScan(SeqScan* node, EState* estate, int eflags) /* if partial sequential scan is disabled by GUC, or table is not ustore, or partition table, skip */ if ((!u_sess->attr.attr_storage.enable_ustore_partial_seqscan) || - (scanstate->ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_USTORE) || + (scanstate->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops != TableAmUstore) || (scanstate->ss_currentScanDesc == NULL) || (scanstate->ss_currentScanDesc->rs_rd == NULL) || (!RelationIsNonpartitioned(scanstate->ss_currentScanDesc->rs_rd)) || (RelationIsPartition(scanstate->ss_currentScanDesc->rs_rd))) { diff --git a/src/gausskernel/runtime/executor/nodeSetOp.cpp b/src/gausskernel/runtime/executor/nodeSetOp.cpp index 6a50ae45b..04182367c 100644 --- a/src/gausskernel/runtime/executor/nodeSetOp.cpp +++ b/src/gausskernel/runtime/executor/nodeSetOp.cpp @@ -647,7 +647,7 @@ SetOpState* ExecInitSetOp(SetOp* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &setopstate->ps, - ExecGetResultType(outerPlanState(setopstate))->tdTableAmType); + ExecGetResultType(outerPlanState(setopstate))->td_tam_ops); setopstate->ps.ps_ProjInfo = NULL; diff --git a/src/gausskernel/runtime/executor/nodeSort.cpp b/src/gausskernel/runtime/executor/nodeSort.cpp index 3a1a502da..6ce479f00 100644 --- a/src/gausskernel/runtime/executor/nodeSort.cpp +++ b/src/gausskernel/runtime/executor/nodeSort.cpp @@ -274,11 +274,11 @@ SortState* ExecInitSort(Sort* node, EState* estate, int eflags) ExecAssignResultTypeFromTL( &sortstate->ss.ps, - sortstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + sortstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); sortstate->ss.ps.ps_ProjInfo = NULL; - Assert(sortstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(sortstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); SO1_printf("ExecInitSort: %s\n", "sort node initialized"); diff --git a/src/gausskernel/runtime/executor/nodeStartWithOp.cpp b/src/gausskernel/runtime/executor/nodeStartWithOp.cpp index 12cf91ee3..cb9bb0826 100644 --- a/src/gausskernel/runtime/executor/nodeStartWithOp.cpp +++ b/src/gausskernel/runtime/executor/nodeStartWithOp.cpp @@ -291,7 +291,7 @@ StartWithOpState* ExecInitStartWithOp(StartWithOp* node, EState* estate, int efl * no relations are involved in nodeResult, set the default * tableAm type to HEAP */ - ExecAssignResultTypeFromTL(&state->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&state->ps); ExecAssignProjectionInfo(&state->ps, NULL); @@ -1844,7 +1844,7 @@ static const char *GetKeyEntryArrayStr(RecursiveUnionState *state, TupleTableSlo */ elog(WARNING, "The internal key column[%d]:%s with NULL value.", te->resno, - scanSlot->tts_tupleDescriptor->attrs[i]->attname.data); + scanSlot->tts_tupleDescriptor->attrs[i].attname.data); } if (i == 0) { @@ -1873,7 +1873,7 @@ static const char *GetCurrentValue(TupleTableSlot *slot, AttrNumber attnum) TupleDesc tupDesc = slot->tts_tupleDescriptor; HeapTuple tup = ExecFetchSlotTuple(slot); bool isnull = true; - Oid atttypid = tupDesc->attrs[attnum - 1]->atttypid; + Oid atttypid = tupDesc->attrs[attnum - 1].atttypid; Datum d = heap_getattr(tup, attnum, tupDesc, &isnull); char *value_str = NULL; @@ -1983,7 +1983,7 @@ static const char *GetCurrentValue(TupleTableSlot *slot, AttrNumber attnum) break; default: { elog(ERROR, "unspported type for attname:%s (typid:%u typname:%s)", - tupDesc->attrs[attnum - 1]->attname.data, + tupDesc->attrs[attnum - 1].attname.data, atttypid, get_typename(atttypid)); } } diff --git a/src/gausskernel/runtime/executor/nodeStub.cpp b/src/gausskernel/runtime/executor/nodeStub.cpp index 3308d10ce..a25d50122 100644 --- a/src/gausskernel/runtime/executor/nodeStub.cpp +++ b/src/gausskernel/runtime/executor/nodeStub.cpp @@ -106,7 +106,7 @@ PlanState* ExecInitNodeStubNorm(Plan* node, EState* estate, int eflags) /* Result tuple initialization */ ExecInitResultTupleSlot(estate, ps); - ExecAssignResultTypeFromTL(ps, TAM_HEAP); + ExecAssignResultTypeFromTL(ps); return ps; } diff --git a/src/gausskernel/runtime/executor/nodeSubplan.cpp b/src/gausskernel/runtime/executor/nodeSubplan.cpp index 3824854d9..ff8145a76 100644 --- a/src/gausskernel/runtime/executor/nodeSubplan.cpp +++ b/src/gausskernel/runtime/executor/nodeSubplan.cpp @@ -329,7 +329,7 @@ static Datum ExecScanSubPlan(SubPlanState* node, ExprContext* econtext, bool* is found = true; /* stash away current value */ - Assert(sub_plan->firstColType == tdesc->attrs[0]->atttypid); + Assert(sub_plan->firstColType == tdesc->attrs[0].atttypid); dvalue = tableam_tslot_getattr(slot, 1, &disnull); astate = accumArrayResult(astate, dvalue, disnull, sub_plan->firstColType, oldcontext); /* keep scanning subplan to collect all values */ @@ -832,13 +832,13 @@ SubPlanState* ExecInitSubPlan(SubPlan* subplan, PlanState* parent) * own innerecontext. */ // slot contains virtual tuple, so set the default tableAm type to HEAP - tup_desc = ExecTypeFromTL(leftptlist, false, false, TAM_HEAP); + tup_desc = ExecTypeFromTL(leftptlist, false, false, TableAmHeap); slot = ExecInitExtraTupleSlot(estate); ExecSetSlotDescriptor(slot, tup_desc); sstate->projLeft = ExecBuildProjectionInfo(lefttlist, NULL, slot, NULL); // slot contains virtual tuple, so set the default tableAm type to HEAP - tup_desc = ExecTypeFromTL(rightptlist, false, false, TAM_HEAP); + tup_desc = ExecTypeFromTL(rightptlist, false, false, TableAmHeap); slot = ExecInitExtraTupleSlot(estate); ExecSetSlotDescriptor(slot, tup_desc); sstate->projRight = ExecBuildProjectionInfo(righttlist, sstate->innerecontext, slot, NULL); @@ -925,7 +925,7 @@ void ExecSetParamPlan(SubPlanState* node, ExprContext* econtext) found = true; /* stash away current value */ - Assert(subplan->firstColType == tdesc->attrs[0]->atttypid); + Assert(subplan->firstColType == tdesc->attrs[0].atttypid); dvalue = tableam_tslot_getattr(slot, 1, &disnull); astate = accumArrayResult(astate, dvalue, disnull, subplan->firstColType, oldcontext); /* keep scanning subplan to collect all values */ diff --git a/src/gausskernel/runtime/executor/nodeSubqueryscan.cpp b/src/gausskernel/runtime/executor/nodeSubqueryscan.cpp index fb4c9c041..3b0e40ead 100644 --- a/src/gausskernel/runtime/executor/nodeSubqueryscan.cpp +++ b/src/gausskernel/runtime/executor/nodeSubqueryscan.cpp @@ -142,11 +142,11 @@ SubqueryScanState* ExecInitSubqueryScan(SubqueryScan* node, EState* estate, int */ ExecAssignResultTypeFromTL( &sub_query_state->ss.ps, - sub_query_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + sub_query_state->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfo(&sub_query_state->ss); - Assert(sub_query_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(sub_query_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); return sub_query_state; } diff --git a/src/gausskernel/runtime/executor/nodeTidscan.cpp b/src/gausskernel/runtime/executor/nodeTidscan.cpp index fb6d4594f..60535116a 100644 --- a/src/gausskernel/runtime/executor/nodeTidscan.cpp +++ b/src/gausskernel/runtime/executor/nodeTidscan.cpp @@ -673,11 +673,11 @@ TidScanState* ExecInitTidScan(TidScan* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &tidstate->ss.ps, - tidstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + tidstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignScanProjectionInfo(&tidstate->ss); - Assert(tidstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->tdTableAmType != TAM_INVALID); + Assert(tidstate->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor->td_tam_ops); /* * all done. diff --git a/src/gausskernel/runtime/executor/nodeTrainModel.cpp b/src/gausskernel/runtime/executor/nodeTrainModel.cpp index d1d8b3c8c..af2d72f96 100644 --- a/src/gausskernel/runtime/executor/nodeTrainModel.cpp +++ b/src/gausskernel/runtime/executor/nodeTrainModel.cpp @@ -121,9 +121,9 @@ TrainModelState* ExecInitTrainModel(TrainModel* pnode, EState* estate, int eflag pstate->tuple.typbyval = (bool *)palloc(sizeof(bool) * pstate->tuple.ncolumns); pstate->tuple.typlen = (int16 *)palloc(sizeof(int16) * pstate->tuple.ncolumns); for (int c = 0; c < pstate->tuple.ncolumns; c++) { - pstate->tuple.typid[c] = tupdesc->attrs[c]->atttypid; - pstate->tuple.typbyval[c] = tupdesc->attrs[c]->attbyval; - pstate->tuple.typlen[c] = tupdesc->attrs[c]->attlen; + pstate->tuple.typid[c] = tupdesc->attrs[c].atttypid; + pstate->tuple.typbyval[c] = tupdesc->attrs[c].attbyval; + pstate->tuple.typlen[c] = tupdesc->attrs[c].attlen; } pstate->row_allocated = false; diff --git a/src/gausskernel/runtime/executor/nodeUnique.cpp b/src/gausskernel/runtime/executor/nodeUnique.cpp index ad1bf1fd8..b08f2e3b5 100644 --- a/src/gausskernel/runtime/executor/nodeUnique.cpp +++ b/src/gausskernel/runtime/executor/nodeUnique.cpp @@ -142,7 +142,7 @@ UniqueState* ExecInitUnique(Unique* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &unique_state->ps, - ExecGetResultType(outerPlanState(unique_state))->tdTableAmType); + ExecGetResultType(outerPlanState(unique_state))->td_tam_ops); unique_state->ps.ps_ProjInfo = NULL; diff --git a/src/gausskernel/runtime/executor/nodeValuesscan.cpp b/src/gausskernel/runtime/executor/nodeValuesscan.cpp index 3b80328c1..e995b7dab 100644 --- a/src/gausskernel/runtime/executor/nodeValuesscan.cpp +++ b/src/gausskernel/runtime/executor/nodeValuesscan.cpp @@ -241,7 +241,7 @@ ValuesScanState* ExecInitValuesScan(ValuesScan* node, EState* estate, int eflags * get info about values list * value lists scan, no relation is involved, default tableAm type is set to HEAP. */ - tupdesc = ExecTypeFromExprList((List*)linitial(node->values_lists), rte->eref->colnames, TAM_HEAP); + tupdesc = ExecTypeFromExprList((List*)linitial(node->values_lists), rte->eref->colnames); ExecAssignScanType(&scan_state->ss, tupdesc); @@ -265,7 +265,7 @@ ValuesScanState* ExecInitValuesScan(ValuesScan* node, EState* estate, int eflags * Initialize result tuple type and projection info. * value lists result tuple is set to default tableAm type HEAP. */ - ExecAssignResultTypeFromTL(&scan_state->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&scan_state->ss.ps); ExecAssignScanProjectionInfo(&scan_state->ss); diff --git a/src/gausskernel/runtime/executor/nodeWindowAgg.cpp b/src/gausskernel/runtime/executor/nodeWindowAgg.cpp index 0694a1a2b..80e37ba74 100644 --- a/src/gausskernel/runtime/executor/nodeWindowAgg.cpp +++ b/src/gausskernel/runtime/executor/nodeWindowAgg.cpp @@ -1231,7 +1231,7 @@ WindowAggState* ExecInitWindowAgg(WindowAgg* node, EState* estate, int eflags) * Initialize result tuple type and projection info. * result Tuple Table Slot contains virtual tuple, default tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&winstate->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&winstate->ss.ps); ExecAssignProjectionInfo(&winstate->ss.ps, NULL); diff --git a/src/gausskernel/runtime/executor/nodeWorktablescan.cpp b/src/gausskernel/runtime/executor/nodeWorktablescan.cpp index 49cbeeec7..bfee88c8d 100755 --- a/src/gausskernel/runtime/executor/nodeWorktablescan.cpp +++ b/src/gausskernel/runtime/executor/nodeWorktablescan.cpp @@ -260,7 +260,7 @@ WorkTableScanState* ExecInitWorkTableScan(WorkTableScan* node, EState* estate, i /* * Initialize result tuple type, but not yet projection info. */ - ExecAssignResultTypeFromTL(&scan_state->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&scan_state->ss.ps); scan_state->ss.ps.ps_TupFromTlist = false; diff --git a/src/gausskernel/runtime/executor/route.cpp b/src/gausskernel/runtime/executor/route.cpp index 89c41208d..8a3cf9cb1 100644 --- a/src/gausskernel/runtime/executor/route.cpp +++ b/src/gausskernel/runtime/executor/route.cpp @@ -338,7 +338,7 @@ int SendRouter::CountNodeId(struct RouteMsg* attr) int dist_idx = list_nth_int(rel_loc_info->partAttrNum, t) - 1; for (i = 0; i < tupdesc->natts; i++) { if (dist_idx == i) { - col_type[t] = tupdesc->attrs[i]->atttypid; + col_type[t] = tupdesc->attrs[i].atttypid; Type typ = typeidType(col_type[t]); col_typemode[t] = ((Form_pg_type)GETSTRUCT(typ))->typtypmod; ReleaseSysCache(typ); diff --git a/src/gausskernel/runtime/executor/spi.cpp b/src/gausskernel/runtime/executor/spi.cpp index 84fad4e31..066d357d1 100644 --- a/src/gausskernel/runtime/executor/spi.cpp +++ b/src/gausskernel/runtime/executor/spi.cpp @@ -1289,7 +1289,7 @@ int SPI_fnumber(TupleDesc tupdesc, const char *fname) Form_pg_attribute sys_att; for (res = 0; res < tupdesc->natts; res++) { - if (namestrcmp(&tupdesc->attrs[res]->attname, fname) == 0) { + if (namestrcmp(&tupdesc->attrs[res].attname, fname) == 0) { return res + 1; } } @@ -1314,7 +1314,7 @@ char *SPI_fname(TupleDesc tupdesc, int fnumber) } if (fnumber > 0) { - attr = tupdesc->attrs[fnumber - 1]; + attr = &tupdesc->attrs[fnumber - 1]; } else { attr = SystemAttributeDefinition(fnumber, true, false, false); } @@ -1344,7 +1344,7 @@ char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) } if (fnumber > 0) { - typoid = tupdesc->attrs[fnumber - 1]->atttypid; + typoid = tupdesc->attrs[fnumber - 1].atttypid; } else { typoid = (SystemAttributeDefinition(fnumber, true, false, false))->atttypid; } @@ -1397,7 +1397,7 @@ char *SPI_gettype(TupleDesc tupdesc, int fnumber) } if (fnumber > 0) { - typoid = tupdesc->attrs[fnumber - 1]->atttypid; + typoid = tupdesc->attrs[fnumber - 1].atttypid; } else { typoid = (SystemAttributeDefinition(fnumber, true, false, false))->atttypid; } @@ -1423,7 +1423,7 @@ Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber) } if (fnumber > 0) { - return tupdesc->attrs[fnumber - 1]->atttypid; + return tupdesc->attrs[fnumber - 1].atttypid; } else { return (SystemAttributeDefinition(fnumber, true, false, false))->atttypid; } diff --git a/src/gausskernel/runtime/executor/tstoreReceiver.cpp b/src/gausskernel/runtime/executor/tstoreReceiver.cpp index c013a76bf..86a84e99e 100644 --- a/src/gausskernel/runtime/executor/tstoreReceiver.cpp +++ b/src/gausskernel/runtime/executor/tstoreReceiver.cpp @@ -45,17 +45,17 @@ static void tstoreStartupReceiver(DestReceiver *self, int operation, TupleDesc t { TStoreState *my_stat = (TStoreState *)self; bool need_toast = false; - Form_pg_attribute *attrs = typeinfo->attrs; + FormData_pg_attribute *attrs = typeinfo->attrs; int natts = typeinfo->natts; int i; /* Check if any columns require detoast work */ if (my_stat->detoast) { for (i = 0; i < natts; i++) { - if (attrs[i]->attisdropped) { + if (attrs[i].attisdropped) { continue; } - if (attrs[i]->attlen == -1) { + if (attrs[i].attlen == -1) { need_toast = true; break; } @@ -93,7 +93,7 @@ static void tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self) { TStoreState *my_stat = (TStoreState *)self; TupleDesc typeinfo = slot->tts_tupleDescriptor; - Form_pg_attribute *attrs = typeinfo->attrs; + FormData_pg_attribute *attrs = typeinfo->attrs; int natts = typeinfo->natts; int nfree; int i; @@ -115,7 +115,7 @@ static void tstoreReceiveSlot_detoast(TupleTableSlot *slot, DestReceiver *self) for (i = 0; i < natts; i++) { Datum val = slot->tts_values[i]; - if (!attrs[i]->attisdropped && attrs[i]->attlen == -1 && !slot->tts_isnull[i]) { + if (!attrs[i].attisdropped && attrs[i].attlen == -1 && !slot->tts_isnull[i]) { if (VARATT_IS_EXTERNAL(DatumGetPointer(val))) { val = PointerGetDatum(heap_tuple_fetch_attr((struct varlena *)DatumGetPointer(val))); my_stat->tofree[nfree++] = val; diff --git a/src/gausskernel/runtime/opfusion/opfusion_agg.cpp b/src/gausskernel/runtime/opfusion/opfusion_agg.cpp index 1b46d4704..44d51cc40 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_agg.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_agg.cpp @@ -146,7 +146,7 @@ bool AggFusion::execute(long max_rows, char *completionTag) } } - HeapTuple tmptup = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, values, isnull, HEAP_TUPLE); + HeapTuple tmptup = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, values, isnull); (void)ExecStoreTuple(tmptup, reslot, InvalidBuffer, false); tableam_tslot_getsomeattrs(reslot, m_global->m_tupDesc->natts); diff --git a/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp b/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp index 4dd85a812..6d518bf0d 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_indexonlyscan.cpp @@ -155,7 +155,7 @@ void IndexOnlyScanFusion::Init(long max_rows) *m_direction = NoMovementScanDirection; } - m_reslot = MakeSingleTupleTableSlot(m_tupDesc, false, GetTableAmRoutine(m_tupDesc->tdTableAmType)); + m_reslot = MakeSingleTupleTableSlot(m_tupDesc, false, m_tupDesc->td_tam_ops); ScanState* scanstate = makeNode(ScanState); // need release scanstate->ps.plan = (Plan *)m_node; diff --git a/src/gausskernel/runtime/opfusion/opfusion_indexscan.cpp b/src/gausskernel/runtime/opfusion/opfusion_indexscan.cpp index 7a47a7e0f..51868ecb4 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_indexscan.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_indexscan.cpp @@ -93,7 +93,7 @@ IndexScanFusion::IndexScanFusion(IndexScan* node, PlannedStmt* planstmt, ParamLi m_direction = (ScanDirection*)palloc0(sizeof(ScanDirection)); Relation rel = m_rel; - m_tupDesc = ExecCleanTypeFromTL(m_targetList, false, rel->rd_tam_type); + m_tupDesc = ExecCleanTypeFromTL(m_targetList, false, GetTableAmRoutine(rel->rd_tam_type)); m_attrno = (int16*)palloc(m_tupDesc->natts * sizeof(int16)); m_values = (Datum*)palloc(RelationGetDescr(rel)->natts * sizeof(Datum)); m_tmpvals = (Datum*)palloc(m_tupDesc->natts * sizeof(Datum)); @@ -234,7 +234,7 @@ TupleTableSlot* IndexScanFusion::getTupleSlot() m_tmpisnull[i] = m_isnull[m_attrno[i] - 1]; } - Tuple tup = tableam_tops_form_tuple(m_tupDesc, m_tmpvals, m_tmpisnull, isUstore ? UHEAP_TUPLE : HEAP_TUPLE); + Tuple tup = tableam_tops_form_tuple(m_tupDesc, m_tmpvals, m_tmpisnull, isUstore ? TableAmUstore : TableAmHeap); Assert(tup != NULL); (void)ExecStoreTuple(tup, /* tuple to store */ m_reslot, /* slot to store in */ diff --git a/src/gausskernel/runtime/opfusion/opfusion_insert.cpp b/src/gausskernel/runtime/opfusion/opfusion_insert.cpp index 9bdabaaa1..369165aec 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_insert.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_insert.cpp @@ -281,7 +281,7 @@ unsigned long InsertFusion::ExecInsert(Relation rel, ResultRelInfo* result_rel_i * step 2: begin insert * ************************/ Tuple tuple = tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_values, - m_local.m_isnull, tableam_tops_get_tuple_type(rel)); + m_local.m_isnull, GetTableAmRoutine(rel->rd_tam_type)); Assert(tuple != NULL); if (RELATION_IS_PARTITIONED(rel)) { m_c_local.m_estate->esfRelations = NULL; diff --git a/src/gausskernel/runtime/opfusion/opfusion_selectforupdate.cpp b/src/gausskernel/runtime/opfusion/opfusion_selectforupdate.cpp index ee553f5b2..cb8169637 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_selectforupdate.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_selectforupdate.cpp @@ -100,7 +100,7 @@ void SelectForUpdateFusion::InitGlobals() Relation rel = heap_open(m_global->m_reloid, AccessShareLock); m_global->m_natts = RelationGetDescr(rel)->natts; Assert(list_length(targetList) >= 2); - m_global->m_tupDesc = ExecCleanTypeFromTL(targetList, false, rel->rd_tam_type); + m_global->m_tupDesc = ExecCleanTypeFromTL(targetList, false, GetTableAmRoutine(rel->rd_tam_type)); m_global->m_is_bucket_rel = RELATION_OWN_BUCKET(rel); m_global->m_table_type = RelationIsUstoreFormat(rel) ? TAM_USTORE : TAM_HEAP; m_global->m_exec_func_ptr = (OpFusionExecfuncType)&SelectForUpdateFusion::ExecSelectForUpdate; @@ -253,7 +253,7 @@ unsigned long SelectForUpdateFusion::ExecSelectForUpdate(Relation rel, ResultRel } tmptup = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_tmpvals, m_local.m_tmpisnull, - tableam_tops_get_tuple_type(rel)); + GetTableAmRoutine(rel->rd_tam_type)); if (bucket_rel) { bucketCloseRelation(bucket_rel); } @@ -378,7 +378,7 @@ unsigned long SelectForUpdateFusion::ExecSelectForUpdate(Relation rel, ResultRel } tmptup = tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_tmpvals, m_local.m_tmpisnull, - tableam_tops_get_tuple_type(rel)); + GetTableAmRoutine(rel->rd_tam_type)); Assert(tmptup != NULL); (void)ExecStoreTuple(tmptup, /* tuple to store */ diff --git a/src/gausskernel/runtime/opfusion/opfusion_sort.cpp b/src/gausskernel/runtime/opfusion/opfusion_sort.cpp index c1c1e0c2f..9c9b2690f 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_sort.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_sort.cpp @@ -50,11 +50,11 @@ void SortFusion::InitLocals(ParamListInfo params) m_local.m_isInsideRec = true; m_local.m_scan = ScanFusion::getScanFusion((Node*)sortnode->plan.lefttree, m_global->m_planstmt, m_local.m_outParams ? m_local.m_outParams : m_local.m_params); - m_c_local.m_scanDesc->tdTableAmType = m_local.m_scan->m_tupDesc->tdTableAmType; + m_c_local.m_scanDesc->td_tam_ops = m_local.m_scan->m_tupDesc->td_tam_ops; if (!IsGlobal()) - m_global->m_tupDesc->tdTableAmType = m_local.m_scan->m_tupDesc->tdTableAmType; + m_global->m_tupDesc->td_tam_ops = m_local.m_scan->m_tupDesc->td_tam_ops; - m_local.m_reslot = MakeSingleTupleTableSlot(m_global->m_tupDesc, false, GetTableAmRoutine(m_local.m_scan->m_tupDesc->tdTableAmType)); + m_local.m_reslot = MakeSingleTupleTableSlot(m_global->m_tupDesc, false, m_local.m_scan->m_tupDesc->td_tam_ops); m_local.m_values = (Datum*)palloc0(m_global->m_tupDesc->natts * sizeof(Datum)); m_local.m_isnull = (bool*)palloc0(m_global->m_tupDesc->natts * sizeof(bool)); } @@ -143,7 +143,7 @@ bool SortFusion::execute(long max_rows, char *completionTag) } HeapTuple tmptup = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, values, isnull, - TableAMGetTupleType(m_global->m_tupDesc->tdTableAmType)); + m_global->m_tupDesc->td_tam_ops); (void)ExecStoreTuple(tmptup, reslot, InvalidBuffer, false); (*m_local.m_receiver->receiveSlot)(reslot, m_local.m_receiver); tableam_tops_free_tuple(tmptup); diff --git a/src/gausskernel/runtime/opfusion/opfusion_uheaptablescan.cpp b/src/gausskernel/runtime/opfusion/opfusion_uheaptablescan.cpp index cf0452f13..c36fcda85 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_uheaptablescan.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_uheaptablescan.cpp @@ -100,7 +100,7 @@ TupleTableSlot *UHeapTableScanFusion::getTupleSlot() m_tmpisnull[i] = m_isnull[m_attrno[i] - 1]; } - HeapTuple tmptup = (HeapTuple)tableam_tops_form_tuple(m_tupDesc, m_tmpvals, m_tmpisnull, HEAP_TUPLE); + HeapTuple tmptup = (HeapTuple)tableam_tops_form_tuple(m_tupDesc, m_tmpvals, m_tmpisnull); Assert(tmptup != NULL); (void)ExecStoreTuple(tmptup, /* tuple to store */ diff --git a/src/gausskernel/runtime/opfusion/opfusion_update.cpp b/src/gausskernel/runtime/opfusion/opfusion_update.cpp index 320df81ef..146ef63f3 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_update.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_update.cpp @@ -41,7 +41,7 @@ UHeapTuple UpdateFusion::uheapModifyTuple(UHeapTuple tuple, Relation rel) * create a new tuple from the values and isnull arrays */ newTuple = (UHeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_values, - m_local.m_isnull, UHEAP_TUPLE); + m_local.m_isnull, TableAmUstore); /* * copy the identification info of the old tuple: t_ctid, t_self, and OID @@ -68,7 +68,7 @@ HeapTuple UpdateFusion::heapModifyTuple(HeapTuple tuple) /* * create a new tuple from the values and isnull arrays */ - new_tuple = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_values, m_local.m_isnull, HEAP_TUPLE); + new_tuple = (HeapTuple)tableam_tops_form_tuple(m_global->m_tupDesc, m_local.m_values, m_local.m_isnull); /* * copy the identification info of the old tuple: t_ctid, t_self, and OID diff --git a/src/gausskernel/runtime/opfusion/opfusion_util.cpp b/src/gausskernel/runtime/opfusion/opfusion_util.cpp index 6292691c1..74602e4ef 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_util.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_util.cpp @@ -963,15 +963,15 @@ FusionType getInsertFusionType(List *stmt_list, ParamListInfo params) Relation rel = heap_open(relid, AccessShareLock); for (int i = 0; i < rel->rd_att->natts; i++) { - if (rel->rd_att->attrs[i]->attisdropped) { + if (rel->rd_att->attrs[i].attisdropped) { continue; } /* check whether the attrs of */ - HeapTuple tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rel->rd_att->attrs[i]->atttypid)); + HeapTuple tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rel->rd_att->attrs[i].atttypid)); if (!HeapTupleIsValid(tuple)) { /* should not happen */ ereport(ERROR, (errcode(ERRCODE_CACHE_LOOKUP_FAILED), - errmsg("cache lookup failed for type %u", rel->rd_att->attrs[i]->atttypid))); + errmsg("cache lookup failed for type %u", rel->rd_att->attrs[i].atttypid))); } Form_pg_type type_form = (Form_pg_type)GETSTRUCT(tuple); ReleaseSysCache(tuple); diff --git a/src/gausskernel/runtime/vecexecutor/vecexpression.cpp b/src/gausskernel/runtime/vecexecutor/vecexpression.cpp index fa5fd5f61..e74f03346 100644 --- a/src/gausskernel/runtime/vecexecutor/vecexpression.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecexpression.cpp @@ -3032,7 +3032,7 @@ ExprState* ExecInitVecExpr(Expr* node, PlanState* parent) case T_RowExpr: { RowExpr* rowexpr = (RowExpr*)node; RowExprState* rstate = makeNode(RowExprState); - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; List* outlist = NIL; ListCell* l = NULL; int i; @@ -3048,7 +3048,7 @@ ExprState* ExecInitVecExpr(Expr* node, PlanState* parent) /* Build tupdesc to describe result tuples */ if (rowexpr->row_typeid == RECORDOID) { /* generic record, use runtime type assignment */ - rstate->tupdesc = ExecTypeFromExprList(rowexpr->args, rowexpr->colnames, TAM_HEAP); + rstate->tupdesc = ExecTypeFromExprList(rowexpr->args, rowexpr->colnames); BlessTupleDesc(rstate->tupdesc); /* we won't need to redo this at runtime */ } else { @@ -3067,19 +3067,19 @@ ExprState* ExecInitVecExpr(Expr* node, PlanState* parent) Expr* e = (Expr*)lfirst(l); ExprState* estate = NULL; - if (!attrs[i]->attisdropped) { + if (!attrs[i].attisdropped) { /* * Guard against ALTER COLUMN TYPE on rowtype since * the RowExpr was created. XXX should we check * typmod too? Not sure we can be sure it'll be the * same. */ - if (exprType((Node*)e) != attrs[i]->atttypid) + if (exprType((Node*)e) != attrs[i].atttypid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("ROW() column has type %s instead of type %s", format_type_be(exprType((Node*)e)), - format_type_be(attrs[i]->atttypid)))); + format_type_be(attrs[i].atttypid)))); } else { /* * Ignore original expression and insert a NULL. We diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecagg.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecagg.cpp index 967cb2939..492b8322f 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecagg.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecagg.cpp @@ -216,7 +216,7 @@ VecAggState* ExecInitVecAggregation(VecAgg* node, EState* estate, int eflags) * Result tuple slot of Aggregation always contains a virtual tuple, * Default tableAMtype for this slot is Heap. */ - ExecAssignResultTypeFromTL(&aggstate->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&aggstate->ss.ps); aggstate->ss.ps.ps_ProjInfo = ExecBuildVecProjectionInfo(aggstate->ss.ps.targetlist, node->plan.qual, @@ -998,8 +998,8 @@ void BaseAggRunner::build_batch() TupleDesc out_desc = outerPlanState(m_runtime)->ps_ResultTupleSlot->tts_tupleDescriptor; for (i = 0; i < m_cellVarLen; i++) { - type_arr[i].typeId = out_desc->attrs[m_cellBatchMap[i]]->atttypid; - type_arr[i].typeMod = out_desc->attrs[m_cellBatchMap[i]]->atttypmod; + type_arr[i].typeId = out_desc->attrs[m_cellBatchMap[i]].atttypid; + type_arr[i].typeMod = out_desc->attrs[m_cellBatchMap[i]].atttypmod; type_arr[i].encoded = COL_IS_ENCODE(type_arr[i].typeId); if (type_arr[i].encoded) { m_keySimple = false; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecappend.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecappend.cpp index fa984fbab..527339c59 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecappend.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecappend.cpp @@ -95,7 +95,7 @@ VecAppendState* ExecInitVecAppend(VecAppend* node, EState* estate, int eflags) * Result tuple slot of Append always contains a virtual tuple, * Default tableAMtype for this slot is Heap. */ - ExecAssignResultTypeFromTL(&appendstate->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&appendstate->ps); appendstate->ps.ps_ProjInfo = NULL; /* diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecconstraints.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecconstraints.cpp index f0bd5374a..274993f7b 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecconstraints.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecconstraints.cpp @@ -94,7 +94,7 @@ void ExecVecConstraints(ResultRelInfo* resultRelInfo, VectorBatch* batch, EState int attrChk; for (attrChk = 1; attrChk <= natts; attrChk++) { - if (rel->rd_att->attrs[attrChk - 1]->attnotnull) { + if (rel->rd_att->attrs[attrChk - 1].attnotnull) { int nrow = batch->m_rows; ScalarVector* pVector = &(batch->m_arr[attrChk - 1]); for (int i = 0; i < nrow; i++) @@ -102,7 +102,7 @@ void ExecVecConstraints(ResultRelInfo* resultRelInfo, VectorBatch* batch, EState ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), errmsg("null value in column \"%s\" violates not-null constraint", - NameStr(rel->rd_att->attrs[attrChk - 1]->attname)), + NameStr(rel->rd_att->attrs[attrChk - 1].attname)), errdetail("Failing row contains %s.", ExecBuildBatchValueDescription(batch, i, 64)))); } } diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp index de52ee261..5ea616bec 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp @@ -714,7 +714,7 @@ CStoreScanState* ExecInitCStoreScan( */ ExecAssignResultTypeFromTL( &scan_stat->ps, - scan_stat->ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + scan_stat->ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); if (node->isPartTbl && scan_stat->ss_currentRelation == NULL) { // no data ,just return; @@ -739,7 +739,7 @@ CStoreScanState* ExecInitCStoreScan( New(CurrentMemoryContext) VectorBatch(CurrentMemoryContext, scan_stat->ss_currentRelation->rd_att); for (int vecIndex = 0; vecIndex < scan_stat->m_pScanBatch->m_cols; vecIndex++) { FormData_pg_attribute* attr = NULL; - attr = scan_stat->ss_currentRelation->rd_att->attrs[vecIndex]; + attr = &scan_stat->ss_currentRelation->rd_att->attrs[vecIndex]; // Hack!! move me out to update pg_attribute instead // diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexctidscan.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexctidscan.cpp index acab1ce30..f52e3d43d 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexctidscan.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexctidscan.cpp @@ -62,8 +62,8 @@ static List* FixIndexCtidScanTargetList(List* idxTargetList, Oid idxRelId, bool ListCell* cell = NULL; Relation indexRel = index_open(idxRelId, AccessShareLock); Relation heapRel = relation_open(indexRel->rd_index->indrelid, AccessShareLock); - Form_pg_attribute* heapRelAttrs = heapRel->rd_att->attrs; - Form_pg_attribute* idxRelAttrs = indexRel->rd_att->attrs; + FormData_pg_attribute* heapRelAttrs = heapRel->rd_att->attrs; + FormData_pg_attribute* idxRelAttrs = indexRel->rd_att->attrs; idxAttNo = indexRel->rd_att->natts; foreach (cell, idxTargetList) { @@ -71,12 +71,12 @@ static List* FixIndexCtidScanTargetList(List* idxTargetList, Oid idxRelId, bool Assert(IsA(tle->expr, Var)); int pos = ((Var*)tle->expr)->varattno - 1; for (int col = 0; col < idxAttNo; ++col) { - if (strcmp(NameStr(idxRelAttrs[col]->attname), NameStr(heapRelAttrs[pos]->attname)) == 0) { + if (strcmp(NameStr(idxRelAttrs[col].attname), NameStr(heapRelAttrs[pos].attname)) == 0) { Expr* idxVar = (Expr*)makeVar(((Var*)tle->expr)->varno, col + 1, - idxRelAttrs[col]->atttypid, - idxRelAttrs[col]->atttypmod, - idxRelAttrs[col]->attcollation, + idxRelAttrs[col].atttypid, + idxRelAttrs[col].atttypmod, + idxRelAttrs[col].attcollation, 0); newTargetList = lappend(newTargetList, makeTargetEntry(idxVar, num + 1, NULL, false)); ++num; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexscan.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexscan.cpp index d3434a2f3..0311777c9 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexscan.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/veccstoreindexscan.cpp @@ -562,8 +562,8 @@ static List* FixIndexScanTargetList(CStoreIndexScan* node, CStoreIndexScanState* if (node->scan.isPartTbl && indexScanState->ss_currentRelation == NULL) return NULL; - Form_pg_attribute* heapAttrs = heapRel->rd_att->attrs; - Form_pg_attribute* IdxRelAttrs = indexRel->rd_att->attrs; + FormData_pg_attribute* heapAttrs = heapRel->rd_att->attrs; + FormData_pg_attribute* IdxRelAttrs = indexRel->rd_att->attrs; indexScanState->m_indexOutBaseTabAttr = (int*)palloc0(sizeof(int) * list_length(idxTargetList)); int* outKeyId = indexScanState->m_indexOutBaseTabAttr; @@ -582,12 +582,12 @@ static List* FixIndexScanTargetList(CStoreIndexScan* node, CStoreIndexScanState* Assert(IsA(tle->expr, Var)); int pos = ((Var*)tle->expr)->varattno - 1; for (int col = 0; col < idxAttNo; ++col) { - if (strcmp(NameStr(IdxRelAttrs[col]->attname), NameStr(heapAttrs[pos]->attname)) == 0) { + if (strcmp(NameStr(IdxRelAttrs[col].attname), NameStr(heapAttrs[pos].attname)) == 0) { Expr* idxVar = (Expr*)makeVar(((Var*)tle->expr)->varno, col + 1, - IdxRelAttrs[col]->atttypid, - IdxRelAttrs[col]->atttypmod, - IdxRelAttrs[col]->attcollation, + IdxRelAttrs[col].atttypid, + IdxRelAttrs[col].atttypmod, + IdxRelAttrs[col].attcollation, 0); newTargetList = lappend(newTargetList, makeTargetEntry(idxVar, num + 1, NULL, false)); outKeyId[num] = pos + 1; @@ -946,7 +946,7 @@ Batchsortstate* InitTidSortState(TupleDesc sortTupDesc, int tidAttNo, int sortMe TypeCacheEntry* typeEntry = lookup_type_cache(TIDOID, TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); attNums[0] = tidAttNo; - sortCollations[0] = sortTupDesc->attrs[tidAttNo - 1]->attcollation; + sortCollations[0] = sortTupDesc->attrs[tidAttNo - 1].attcollation; nullsFirstFlags[0] = false; sortState = batchsort_begin_heap( diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecgroup.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecgroup.cpp index 6b889d9da..d032dcd3a 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecgroup.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecgroup.cpp @@ -195,7 +195,7 @@ VecGroupState* ExecInitVecGroup(VecGroup* node, EState* estate, int eflags) * Group node result tuple slot always holds virtual tuple, so * default tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&grp_state->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&grp_state->ss.ps); grp_state->ss.ps.ps_ProjInfo = ExecBuildVecProjectionInfo(grp_state->ss.ps.targetlist, node->plan.qual, diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vechashjoin.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vechashjoin.cpp index 3aeed2eb5..f5ba51b82 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vechashjoin.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vechashjoin.cpp @@ -121,7 +121,7 @@ VecHashJoinState* ExecInitVecHashJoin(VecHashJoin* node, EState* estate, int efl * result tupleSlot only contains virtual tuple, so the default * tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&hash_state->js.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&hash_state->js.ps); /* * Check if the following exprs can be codegened or not. diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vechashtable.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vechashtable.cpp index 729ea8635..7b2ca0830 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vechashtable.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vechashtable.cpp @@ -542,8 +542,8 @@ hashFileSource::hashFileSource(VectorBatch* batch, MemoryContext context, int ce */ ScalarDesc* type_arr = (ScalarDesc*)palloc(sizeof(ScalarDesc) * (m_cols + 1)); for (i = 0; i < m_cols; i++) { - type_arr[i].typeId = tuple_desc->attrs[i]->atttypid; - type_arr[i].typeMod = tuple_desc->attrs[i]->atttypmod; + type_arr[i].typeId = tuple_desc->attrs[i].atttypid; + type_arr[i].typeMod = tuple_desc->attrs[i].atttypmod; type_arr[i].encoded = COL_IS_ENCODE(type_arr[i].typeId); } /* attributes of last column, its typeId we dont care */ @@ -559,7 +559,7 @@ hashFileSource::hashFileSource(VectorBatch* batch, MemoryContext context, int ce m_funType = (int*)palloc(m_cols * sizeof(int)); m_stripFunArray = (stripValFun*)palloc(sizeof(stripValFun) * m_cols); for (i = 0; i < m_cols; i++) { - Oid typid = tuple_desc->attrs[i]->atttypid; + Oid typid = tuple_desc->attrs[i].atttypid; if (COL_IS_ENCODE(typid)) { m_funType[i] = VAR_FUN; } else { @@ -659,7 +659,7 @@ hashFileSource::hashFileSource(VectorBatch* batch, MemoryContext context, int ce m_tupleSize = 100; m_tuple = (MinimalTuple)palloc(m_tupleSize); m_tuple->t_len = m_tupleSize; - m_hashTupleSlot = MakeTupleTableSlot(true, GetTableAmRoutine(tuple_desc->tdTableAmType)); + m_hashTupleSlot = MakeTupleTableSlot(true, tuple_desc->td_tam_ops); ExecSetSlotDescriptor(m_hashTupleSlot, tuple_desc); } @@ -675,7 +675,7 @@ hashFileSource::hashFileSource(TupleTableSlot* hash_slot, int file_num) m_context = NULL; if (m_hashTupleSlot->tts_tupleDescriptor == NULL) { ExecSetSlotDescriptor(m_hashTupleSlot, hash_slot->tts_tupleDescriptor); - m_hashTupleSlot->tts_tam_ops = GetTableAmRoutine(hash_slot->tts_tupleDescriptor->tdTableAmType); + m_hashTupleSlot->tts_tam_ops = hash_slot->tts_tupleDescriptor->td_tam_ops; } m_cols = 0; @@ -1202,7 +1202,7 @@ size_t hashFileSource::writeCellCompress(hashCell* cell, int file_idx) /* restore the len */ m_tuple->t_len = m_tupleSize; - m_tuple = tableam_tops_form_minimal_tuple(m_hashTupleSlot->tts_tupleDescriptor, m_values, m_isnull, m_tuple, HEAP_TUPLE); + m_tuple = tableam_tops_form_minimal_tuple(m_hashTupleSlot->tts_tupleDescriptor, m_values, m_isnull, m_tuple); m_tupleSize = (m_tuple->t_len > m_tupleSize) ? m_tuple->t_len : m_tupleSize; writeTupCompress(m_tuple, file_idx); @@ -1285,7 +1285,7 @@ size_t hashFileSource::writeBatchCompress(VectorBatch* batch, int idx, int file_ /* restore the len */ m_tuple->t_len = m_tupleSize; - m_tuple = tableam_tops_form_minimal_tuple(m_hashTupleSlot->tts_tupleDescriptor, m_values, m_isnull, m_tuple, HEAP_TUPLE); + m_tuple = tableam_tops_form_minimal_tuple(m_hashTupleSlot->tts_tupleDescriptor, m_values, m_isnull, m_tuple); m_tupleSize = (m_tuple->t_len > m_tupleSize) ? m_tuple->t_len : m_tupleSize; writeTupCompress(m_tuple, file_idx); @@ -1393,7 +1393,7 @@ void hashFileSource::assembleBatch(TupleTableSlot* slot, int idx) pVector->m_vals[idx] = DatumToScalarInContext(m_context, slot->tts_values[i], pVector->m_desc.typeId); } else { /* for vector engine, pVector->m_desc.typeId is INT8OID, not TIDOID */ - if (slot->tts_tupleDescriptor->attrs[i]->atttypid == TIDOID) { + if (slot->tts_tupleDescriptor->attrs[i].atttypid == TIDOID) { pVector->m_vals[idx] = 0; ItemPointer destTid = (ItemPointer)&pVector->m_vals[idx]; ItemPointer srcTid = (ItemPointer)DatumGetPointer(slot->tts_values[i]); @@ -1597,7 +1597,7 @@ hashCell* hashFileSource::getCellCompress() cell->m_val[i].val = DatumToScalarInContext(m_context, slot->tts_values[i], pVector->m_desc.typeId); } else { /* for vector engine, pVector->m_desc.typeId is INT8OID, not TIDOID */ - if (TIDOID == slot->tts_tupleDescriptor->attrs[i]->atttypid) { + if (TIDOID == slot->tts_tupleDescriptor->attrs[i].atttypid) { ItemPointer destTid = (ItemPointer)&cell->m_val[i].val; ItemPointer srcTid = (ItemPointer)DatumGetPointer(slot->tts_values[i]); *destTid = *srcTid; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/veclimit.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/veclimit.cpp index 31692c229..1ef518a0b 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/veclimit.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/veclimit.cpp @@ -309,7 +309,7 @@ VecLimitState* ExecInitVecLimit(VecLimit* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &limit_state->ps, - ExecGetResultType(outerPlanState(limit_state))->tdTableAmType); + ExecGetResultType(outerPlanState(limit_state))->td_tam_ops); limit_state->ps.ps_ProjInfo = NULL; limit_state->subBatch = NULL; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecmaterial.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecmaterial.cpp index 0b9fce218..113a2ba6f 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecmaterial.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecmaterial.cpp @@ -356,7 +356,7 @@ VecMaterialState* ExecInitVecMaterial(VecMaterial* node, EState* estate, int efl ExecAssignResultTypeFromTL( &matstate->ss.ps, - matstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + matstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); matstate->ss.ps.ps_ProjInfo = NULL; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecmergeinto.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecmergeinto.cpp index 35d00c93d..72552e1e4 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecmergeinto.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecmergeinto.cpp @@ -70,7 +70,7 @@ static VectorBatch* extract_scan_batch( } for (index = 0; index < tup_desc->natts; index++) { - if (tup_desc->attrs[index]->attisdropped == true) { + if (tup_desc->attrs[index].attisdropped == true) { scan_batch->m_arr[index].SetAllNull(); continue; } @@ -108,7 +108,7 @@ static JunkFilter* build_dummy_junk_filter( } } - junk_filter = ExecInitJunkFilter(new_targetlist, false, ExecInitExtraTupleSlot(estate)); + junk_filter = ExecInitJunkFilter(new_targetlist, false, ExecInitExtraTupleSlot(estate), TableAmHeap); junk_filter->jf_junkAttNo = ExecFindJunkAttribute(junk_filter, "ctid"); if (!AttributeNumberIsValid(junk_filter->jf_junkAttNo)) { diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp index 30b5bab4b..cd08e1a81 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp @@ -1873,7 +1873,7 @@ VecMergeJoinState* ExecInitVecMergeJoin(VecMergeJoin* node, EState* estate, int * result table tuple slot for merge join contains virtual tuple, so the * default tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&mergestate->js.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&mergestate->js.ps); PlanState* planstate = &mergestate->js.ps; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecnestloop.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecnestloop.cpp index 20e642977..13e88afa5 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecnestloop.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecnestloop.cpp @@ -519,7 +519,7 @@ VecNestLoopState* ExecInitVecNestLoop(VecNestLoop* node, EState* estate, int efl /* * initialize tuple type and projection info */ - ExecAssignResultTypeFromTL(&nlstate->js.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&nlstate->js.ps); PlanState* planstate = &nlstate->js.ps; planstate->ps_ProjInfo = ExecBuildVecProjectionInfo( planstate->targetlist, node->join.plan.qual, planstate->ps_ExprContext, planstate->ps_ResultTupleSlot, NULL); @@ -541,7 +541,7 @@ VecNestLoopRuntime::VecNestLoopRuntime(VecNestLoopState* runtime) { m_runtime = runtime; VecNestLoop* node = (VecNestLoop*)m_runtime->js.ps.plan; - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; int col_num = 0; TupleDesc outer_desc = ExecGetResultType(outerPlanState(m_runtime)); ScalarVector* column = NULL; @@ -598,7 +598,7 @@ VecNestLoopRuntime::VecNestLoopRuntime(VecNestLoopState* runtime) attrs = target_desc->attrs; col_num = target_desc->natts; for (int i = 0; i < col_num; i++) { - if (COL_IS_ENCODE(attrs[i]->atttypid)) { + if (COL_IS_ENCODE(attrs[i].atttypid)) { m_SimpletargetCol = false; break; } diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecresult.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecresult.cpp index 9c1c8044c..74a5a07b4 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecresult.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecresult.cpp @@ -194,7 +194,7 @@ VecResultState* ExecInitVecResult(VecResult* node, EState* estate, int eflags) * no relations are involved in nodeResult, set the default * tableAm type to HEAP */ - ExecAssignResultTypeFromTL(&res_state->ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&res_state->ps); res_state->ps.ps_ProjInfo = ExecBuildVecProjectionInfo( res_state->ps.targetlist, node->plan.qual, res_state->ps.ps_ExprContext, res_state->ps.ps_ResultTupleSlot, NULL); diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecrowtovector.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecrowtovector.cpp index 38e0e46a9..5a56deb4e 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecrowtovector.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecrowtovector.cpp @@ -67,7 +67,7 @@ bool VectorizeOneTuple(_in_ VectorBatch* pBatch, _in_ TupleTableSlot* slot, _in_ j = pBatch->m_rows; for (i = 0; i < slot->tts_nvalid; i++) { int type_len; - Form_pg_attribute attr = slot->tts_tupleDescriptor->attrs[i]; + Form_pg_attribute attr = &slot->tts_tupleDescriptor->attrs[i]; if (slot->tts_isnull[i] == false) { type_len = attr->attlen; @@ -241,7 +241,7 @@ void VectorizeTupleBatchMode(VectorBatch *pBatch, TupleTableSlot **slots, for (i = 0; i < scanstate->colNum; i++) { if ((lateRead && scanstate->lateRead[i]) || (!lateRead && !scanstate->lateRead[i])) { colidx = scanstate->colId[i]; - Form_pg_attribute attr = slots[0]->tts_tupleDescriptor->attrs[colidx]; + Form_pg_attribute attr = &slots[0]->tts_tupleDescriptor->attrs[colidx]; if (scanstate->nullflag[colidx]) { TransformScalarVector(attr, &pBatch->m_arr[colidx], rows); } else { @@ -546,7 +546,7 @@ RowToVecState* ExecInitRowToVec(RowToVec* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &state->ps, - ExecGetResultType(outerPlanState(state))->tdTableAmType); + ExecGetResultType(outerPlanState(state))->td_tam_ops); TupleDesc res_desc = state->ps.ps_ResultTupleSlot->tts_tupleDescriptor; state->m_pCurrentBatch = New(CurrentMemoryContext) VectorBatch(CurrentMemoryContext, res_desc); diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecsetop.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecsetop.cpp index 1407f61e2..492c02490 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecsetop.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecsetop.cpp @@ -76,7 +76,7 @@ VecSetOpState* ExecInitVecSetOp(VecSetOp* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &set_op_state->ps, - ExecGetResultType(outerPlanState(set_op_state))->tdTableAmType); + ExecGetResultType(outerPlanState(set_op_state))->td_tam_ops); set_op_state->ps.ps_ProjInfo = NULL; @@ -231,15 +231,15 @@ setOpTbl::setOpTbl(VecSetOpState* runtime) : m_runtime(runtime) } TupleDesc desc = outerPlanState(runtime)->ps_ResultTupleSlot->tts_tupleDescriptor; - Form_pg_attribute* attrs = desc->attrs; + FormData_pg_attribute* attrs = desc->attrs; m_scanBatch = New(CurrentMemoryContext) VectorBatch(CurrentMemoryContext, desc); /* Initialize m_keyDesc in vechashtable and check if m_keySimple is false */ m_keyDesc = (ScalarDesc*)palloc(m_outerColNum * sizeof(ScalarDesc)); for (i = 0; i < m_key; i++) { - m_keyDesc[i].typeId = attrs[m_keyIdx[i]]->atttypid; - m_keyDesc[i].typeMod = attrs[m_keyIdx[i]]->atttypmod; + m_keyDesc[i].typeId = attrs[m_keyIdx[i]].atttypid; + m_keyDesc[i].typeMod = attrs[m_keyIdx[i]].atttypmod; m_keyDesc[i].encoded = COL_IS_ENCODE(m_keyDesc[i].typeId); if (m_keyDesc[i].encoded) m_keySimple = false; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecsort.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecsort.cpp index 650218b13..9b65f78ec 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecsort.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecsort.cpp @@ -318,7 +318,7 @@ VecSortState* ExecInitVecSort(Sort* node, EState* estate, int eflags) ExecAssignResultTypeFromTL( &sort_stat->ss.ps, - sort_stat->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + sort_stat->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); sort_stat->ss.ps.ps_ProjInfo = NULL; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecstore.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecstore.cpp index e5a892b33..65a0d9730 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecstore.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecstore.cpp @@ -106,7 +106,7 @@ void VecStore::SetData(char* dataPtr, int dataSize, MultiColumns* multiColumn) multiColumn->size = dataSize; for (int i = 0; i < m_colNum; ++i) { - Form_pg_attribute attr = tupDesc->attrs[i]; + Form_pg_attribute attr = &tupDesc->attrs[i]; Datum v; int val_size = 0; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecstream.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecstream.cpp index 482e23d5a..488689913 100755 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecstream.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecstream.cpp @@ -168,7 +168,7 @@ static void append_msg_to_batch(VecStreamState* vs_state, VectorBatch* batch) case VALUE_TYPE: /* value stored directly */ desc = vs_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor; - data_len = desc->attrs[i]->attlen; + data_len = desc->attrs[i].attlen; column->m_vals[current_row] = fetch_att(data, true, data_len); break; case NUMERIC_TYPE: @@ -224,7 +224,7 @@ static void append_msg_to_batch(VecStreamState* vs_state, VectorBatch* batch) case FIXED_TYPE: /* fixed length value */ desc = vs_state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor; - data_len = desc->attrs[i]->attlen; + data_len = desc->attrs[i].attlen; column->AddVar(PointerGetDatum(data), current_row); break; default: @@ -370,7 +370,7 @@ void redistributeStreamInitType(TupleDesc desc, uint32* cols_type) Form_pg_attribute attr; for (int i = 0; i < desc->natts; i++) { - attr = desc->attrs[i]; + attr = &desc->attrs[i]; /* * Mark the data type of each column. @@ -448,7 +448,7 @@ VecStreamState* ExecInitVecStream(Stream* node, EState* estate, int eflags) TupleDesc desc = state->ss.ps.ps_ResultTupleSlot->tts_tupleDescriptor; for (int i = 0; i < desc->natts; i++) { - if (desc->attrs[i]->atttypid == NUMERICOID) + if (desc->attrs[i].atttypid == NUMERICOID) state->bitNumericLen++; } diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecsubplan.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecsubplan.cpp index 801870c10..4c810a9fe 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecsubplan.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecsubplan.cpp @@ -671,7 +671,7 @@ static ScalarVector* ExecVecScanSubplan( Assert(slot->tts_tupleDescriptor != NULL); Datum res = tableam_tslot_getattr(slot, 1, &is_null); if (pVector->m_desc.typeId == 0) { - pVector->m_desc.typeId = slot->tts_tupleDescriptor->attrs[0]->atttypid; + pVector->m_desc.typeId = slot->tts_tupleDescriptor->attrs[0].atttypid; pVector->m_desc.encoded = COL_IS_ENCODE(pVector->m_desc.typeId); } if (!is_null) { @@ -684,7 +684,7 @@ static ScalarVector* ExecVecScanSubplan( * Like: MACADDR/TIMETZ/TINTERVAL/INTERVAL/NAME/UNKNOWN/CSTRING */ result = - ScalarVector::DatumToScalar(res, slot->tts_tupleDescriptor->attrs[0]->atttypid, false); + ScalarVector::DatumToScalar(res, slot->tts_tupleDescriptor->attrs[0].atttypid, false); /* Need copy to encode datatype */ int key_size = VARSIZE_ANY(result); char* addr = pVector->m_buf->Allocate(key_size); @@ -695,7 +695,7 @@ static ScalarVector* ExecVecScanSubplan( pfree(DatumGetPointer(result)); } else { /* In vector engine, tid data should be copyed */ - if (slot->tts_tupleDescriptor->attrs[0]->atttypid == TIDOID) { + if (slot->tts_tupleDescriptor->attrs[0].atttypid == TIDOID) { pVector->m_vals[res_vector_idx] = 0; ItemPointer dest_tid = (ItemPointer)&pVector->m_vals[res_vector_idx]; ItemPointer src_tid = (ItemPointer)DatumGetPointer(res); @@ -741,7 +741,7 @@ static ScalarVector* ExecVecScanSubplan( Assert(slot->tts_tupleDescriptor != NULL); prmdata->value = tableam_tslot_getattr(slot, col, &(prmdata->isnull)); prmdata->isChanged = true; - prmdata->valueType = slot->tts_tupleDescriptor->attrs[col - 1]->atttypid; + prmdata->valueType = slot->tts_tupleDescriptor->attrs[col - 1].atttypid; col++; } diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecsubqueryscan.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecsubqueryscan.cpp index ad011accf..50aae598b 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecsubqueryscan.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecsubqueryscan.cpp @@ -145,7 +145,7 @@ VecSubqueryScanState* ExecInitVecSubqueryScan(VecSubqueryScan* node, EState* est */ ExecAssignResultTypeFromTL( &vecsubquerystate->ss.ps, - vecsubquerystate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->tdTableAmType); + vecsubquerystate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->td_tam_ops); ExecAssignVecScanProjectionInfo(&vecsubquerystate->ss); diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vectortorow.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vectortorow.cpp index 4e077e81e..fb34593bf 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vectortorow.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vectortorow.cpp @@ -258,7 +258,7 @@ VecToRowState* ExecInitVecToRow(VecToRow* node, EState* estate, int eflags) */ ExecAssignResultTypeFromTL( &state->ps, - ExecGetResultType(outerPlanState(state))->tdTableAmType); + ExecGetResultType(outerPlanState(state))->td_tam_ops); state->ps.ps_ProjInfo = NULL; state->m_currentRow = 0; @@ -271,7 +271,7 @@ VecToRowState* ExecInitVecToRow(VecToRow* node, EState* estate, int eflags) state->devectorizeFunRuntime = (DevectorizeFun*)palloc0(state->nattrs * sizeof(DevectorizeFun)); for (int i = 0; i < state->nattrs; i++) { state->tts->tts_isnull[i] = false; - int type_id = state->tts->tts_tupleDescriptor->attrs[i]->atttypid; + int type_id = state->tts->tts_tupleDescriptor->attrs[i].atttypid; if (COL_IS_ENCODE(type_id)) { switch (type_id) { case BPCHAROID: diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vectsstorescan.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vectsstorescan.cpp index 5e3848435..5af737720 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vectsstorescan.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vectsstorescan.cpp @@ -329,8 +329,8 @@ static void opt_orderby(TsStoreScan* node, TsStoreScanState* scanstate) att_target = (TargetEntry*)list_nth(target_list, scanstate->sort_by_time_colidx - 1); for(int i = 0; i < tuple_desc->natts; i++) { - if (IsA(att_target->expr, Var) && tuple_desc->attrs[i]->attkvtype == ATT_KV_TIMETAG && - ((Var*)(att_target->expr))->varattno == tuple_desc->attrs[i]->attnum) { + if (IsA(att_target->expr, Var) && tuple_desc->attrs[i].attkvtype == ATT_KV_TIMETAG && + ((Var*)(att_target->expr))->varattno == tuple_desc->attrs[i].attnum) { scanstate->early_stop = true; } } diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecunique.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecunique.cpp index e16c76916..87a95bdad 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecunique.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecunique.cpp @@ -118,7 +118,7 @@ VecUniqueState* ExecInitVecUnique(VecUnique* node, EState* estate, int eflags) // node appropriately ExecAssignResultTypeFromTL( &uniquestate->ps, - ExecGetResultType(outerPlanState(uniquestate))->tdTableAmType); + ExecGetResultType(outerPlanState(uniquestate))->td_tam_ops); uniquestate->ps.ps_ProjInfo = NULL; diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecwindowagg.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecwindowagg.cpp index 67b80f28f..1b303a584 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecwindowagg.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecwindowagg.cpp @@ -149,7 +149,7 @@ VecWindowAggState* ExecInitVecWindowAgg(VecWindowAgg* node, EState* estate, int * Initialize result tuple type and projection info. * result Tuple Table Slot contains virtual tuple, default tableAm type is set to HEAP. */ - ExecAssignResultTypeFromTL(&winstate->ss.ps, TAM_HEAP); + ExecAssignResultTypeFromTL(&winstate->ss.ps); { PlanState* planstate = &winstate->ss.ps; diff --git a/src/gausskernel/runtime/vecexecutor/vectorbatch.cpp b/src/gausskernel/runtime/vecexecutor/vectorbatch.cpp index 4ebf81995..7b80bb331 100644 --- a/src/gausskernel/runtime/vecexecutor/vectorbatch.cpp +++ b/src/gausskernel/runtime/vecexecutor/vectorbatch.cpp @@ -192,7 +192,7 @@ void VectorBatch::init(MemoryContext cxt, TupleDesc desc) { ScalarDesc scalar_desc; - Form_pg_attribute* attrs = desc->attrs; + FormData_pg_attribute* attrs = desc->attrs; m_cols = desc->natts; @@ -206,13 +206,13 @@ void VectorBatch::init(MemoryContext cxt, TupleDesc desc) m_arr = New(cxt) ScalarVector[m_cols]; for (int i = 0; i < m_cols; i++) { - scalar_desc.encoded = COL_IS_ENCODE(attrs[i]->atttypid); - scalar_desc.typeId = attrs[i]->atttypid; + scalar_desc.encoded = COL_IS_ENCODE(attrs[i].atttypid); + scalar_desc.typeId = attrs[i].atttypid; /* for vector result batch, treat tid as int8 */ if (scalar_desc.typeId == TIDOID) { scalar_desc.typeId = INT8OID; } - scalar_desc.typeMod = attrs[i]->atttypmod; + scalar_desc.typeMod = attrs[i].atttypmod; m_arr[i].init(cxt, scalar_desc); } } diff --git a/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp b/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp index cc1467491..312f8e556 100644 --- a/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp +++ b/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp @@ -190,11 +190,11 @@ SonicHash::SonicHash(int size) : m_hash(0), m_atomSize(size), m_rows(0), m_selec void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx, bool is_atom) { int i; - Form_pg_attribute* attrs = desc->attrs; + FormData_pg_attribute* attrs = desc->attrs; hashValFun* hashfun = (hashValFun*)hash_fun_in; for (i = 0; i < m_buildOp.keyNum; i++) { - Oid type_oid = attrs[key_indx[i]]->atttypid; + Oid type_oid = attrs[key_indx[i]].atttypid; if (i == 0) { if (!integerType(type_oid)) { switch (type_oid) { @@ -216,7 +216,7 @@ void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx break; default: if (is_atom) { - switch (attrs[key_indx[i]]->attlen) { + switch (attrs[key_indx[i]].attlen) { case 1: hashfun[i] = &SonicHash::hashGeneralFunc; break; @@ -238,7 +238,7 @@ void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx break; } } else { - switch (attrs[key_indx[i]]->attlen) { + switch (attrs[key_indx[i]].attlen) { case 1: if (is_atom) hashfun[i] = &SonicHash::hashInteger; @@ -267,12 +267,12 @@ void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("[SonicHash] Unrecognized datetype %u, attrlen %d when init hash functions.", type_oid, - attrs[key_indx[i]]->attlen))); + attrs[key_indx[i]].attlen))); break; } } } else { - if (!integerType(attrs[key_indx[i]]->atttypid)) { + if (!integerType(attrs[key_indx[i]].atttypid)) { switch (type_oid) { case BPCHAROID: hashfun[i] = &SonicHash::hashbpchar; @@ -292,7 +292,7 @@ void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx break; default: if (is_atom) { - switch (attrs[key_indx[i]]->attlen) { + switch (attrs[key_indx[i]].attlen) { case 1: hashfun[i] = &SonicHash::hashGeneralFunc; break; @@ -314,7 +314,7 @@ void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx break; } } else { - switch (attrs[key_indx[i]]->attlen) { + switch (attrs[key_indx[i]].attlen) { case 1: if (is_atom) hashfun[i] = &SonicHash::hashInteger; @@ -343,7 +343,7 @@ void SonicHash::initHashFunc(TupleDesc desc, void* hash_fun_in, uint16* key_indx errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("[SonicHash] Unrecognized datetype %u, attrlen %d when init hash functions.", type_oid, - attrs[key_indx[i]]->attlen))); + attrs[key_indx[i]].attlen))); break; } } @@ -679,9 +679,9 @@ bool SonicHash::isHashKey(Oid type_oid, int attr_idx, uint16* key_idx, int key_n */ void SonicHash::replaceEqFunc() { - Form_pg_attribute* attrs = m_buildOp.tupleDesc->attrs; + FormData_pg_attribute* attrs = m_buildOp.tupleDesc->attrs; for (int i = 0; i < m_buildOp.keyNum; i++) { - switch (attrs[m_buildOp.keyIndx[i]]->atttypid) { + switch (attrs[m_buildOp.keyIndx[i]].atttypid) { case TIMETZOID: m_eqfunctions[i].fn_addr = timetz_eq_withhead; break; diff --git a/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashagg.cpp b/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashagg.cpp index eefd4abe3..35777c299 100644 --- a/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashagg.cpp +++ b/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashagg.cpp @@ -584,8 +584,8 @@ void SonicHashAgg::initBatch() /* initialize the type information of all the outer targetlist that we needed */ for (int i = 0; i < m_hashNeed; i++) { - type_arr[i].typeId = outDesc->attrs[m_hashInBatchIdx[i]]->atttypid; - type_arr[i].typeMod = outDesc->attrs[m_hashInBatchIdx[i]]->atttypmod; + type_arr[i].typeId = outDesc->attrs[m_hashInBatchIdx[i]].atttypid; + type_arr[i].typeMod = outDesc->attrs[m_hashInBatchIdx[i]].atttypmod; type_arr[i].encoded = COL_IS_ENCODE(type_arr[i].typeId); if (type_arr[i].encoded) { m_keySimple = false; @@ -628,7 +628,7 @@ void SonicHashAgg::initDataArray() * hash type only store the address here. */ for (int i = 0; i < m_hashNeed; i++) { - Form_pg_attribute attrs = m_buildOp.tupleDesc->attrs[m_hashInBatchIdx[i]]; + Form_pg_attribute attrs = &m_buildOp.tupleDesc->attrs[m_hashInBatchIdx[i]]; getDataDesc(&desc, 0, attrs, true); if (!COL_IS_ENCODE(attrs->atttypid)) { @@ -2171,9 +2171,9 @@ void SonicHashAgg::initPartition(SonicHashPartition** partSource) TupleDesc outDesc = outerPlanState(m_runtime)->ps_ResultTupleSlot->tts_tupleDescriptor; - Form_pg_attribute* attrs = outDesc->attrs; + FormData_pg_attribute* attrs = outDesc->attrs; for (int idx = 0; idx < m_sourceBatch->m_cols; idx++) { - getDataDesc(&desc, 0, attrs[idx], isHashKey(attrs[idx]->atttypid, idx, m_buildOp.keyIndx, m_buildOp.keyNum)); + getDataDesc(&desc, 0, &attrs[idx], isHashKey(attrs[idx].atttypid, idx, m_buildOp.keyIndx, m_buildOp.keyNum)); (*partSource)->init(idx, &desc); } diff --git a/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashjoin.cpp b/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashjoin.cpp index c2c2cb5f9..1e1f239f3 100644 --- a/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashjoin.cpp +++ b/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichashjoin.cpp @@ -301,7 +301,7 @@ void SonicHashJoin::initPartition(SonicHashPartition* partition) MemoryContext old_cxt = MemoryContextSwitchTo(partition->m_context); DatumDesc desc; - Form_pg_attribute* attrs = NULL; + FormData_pg_attribute* attrs = NULL; bool doNotCompress = false; SonicHashInputOpAttr* attr_op = NULL; if (isInner) { @@ -314,13 +314,13 @@ void SonicHashJoin::initPartition(SonicHashPartition* partition) if (m_complicatekey) { for (int idx = 0; idx < attr_op->cols; idx++) { - getDataDesc(&desc, 0, attrs[idx], doNotCompress); + getDataDesc(&desc, 0, &attrs[idx], doNotCompress); partition->init(idx, &desc); } } else { for (int idx = 0; idx < attr_op->cols; idx++) { - doNotCompress = isHashKey(attrs[idx]->atttypid, idx, attr_op->keyIndx, attr_op->keyNum); - getDataDesc(&desc, 0, attrs[idx], doNotCompress); + doNotCompress = isHashKey(attrs[idx].atttypid, idx, attr_op->keyIndx, attr_op->keyNum); + getDataDesc(&desc, 0, &attrs[idx], doNotCompress); partition->init(idx, &desc); } } @@ -2513,7 +2513,7 @@ void SonicHashJoin::initMatchFunc(TupleDesc desc, uint16 keyNum) void SonicHashJoin::DispatchKeyInnerFunction(int KeyIdx) { int attrid = m_buildOp.keyIndx[KeyIdx]; - switch ((m_buildOp.tupleDesc)->attrs[attrid]->atttypid) { + switch ((m_buildOp.tupleDesc)->attrs[attrid].atttypid) { case INT1OID: DispatchKeyOuterFunction(KeyIdx); break; @@ -2532,7 +2532,7 @@ void SonicHashJoin::DispatchKeyInnerFunction(int KeyIdx) (errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE), errmodule(MOD_VEC_EXECUTOR), errmsg("Unrecognize data type %u when choosing match functions from inner hash keys.", - (m_buildOp.tupleDesc)->attrs[attrid]->atttypid))); + (m_buildOp.tupleDesc)->attrs[attrid].atttypid))); break; } } @@ -2545,7 +2545,7 @@ template void SonicHashJoin::DispatchKeyOuterFunction(int KeyIdx) { int attr_id = m_probeOp.keyIndx[KeyIdx]; - switch ((m_probeOp.tupleDesc)->attrs[attr_id]->atttypid) { + switch ((m_probeOp.tupleDesc)->attrs[attr_id].atttypid) { case INT1OID: if (m_runtime->js.nulleqqual != NIL) m_matchKey[KeyIdx] = &SonicHash::matchCheckColT; @@ -2576,7 +2576,7 @@ void SonicHashJoin::DispatchKeyOuterFunction(int KeyIdx) (errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE), errmodule(MOD_VEC_EXECUTOR), (errmsg("Unrecognize data type %u when choosing match functions from outer hash keys.", - (m_probeOp.tupleDesc)->attrs[attr_id]->atttypid)))); + (m_probeOp.tupleDesc)->attrs[attr_id].atttypid)))); break; } } diff --git a/src/gausskernel/security/gs_ledger/ledger_archive.cpp b/src/gausskernel/security/gs_ledger/ledger_archive.cpp index 82d0341c0..95037edf5 100644 --- a/src/gausskernel/security/gs_ledger/ledger_archive.cpp +++ b/src/gausskernel/security/gs_ledger/ledger_archive.cpp @@ -80,7 +80,7 @@ static uint64 ledger_copytable(CopyState cstate) { Relation cur_rel; TupleDesc tuple_desc; - Form_pg_attribute *attr = NULL; + FormData_pg_attribute *attr = NULL; ListCell *cur = NULL; int num_phys_attrs; uint64 processed = 0; @@ -106,7 +106,7 @@ static uint64 ledger_copytable(CopyState cstate) int attnum = lfirst_int(cur); Oid out_func_oid; bool isvarlena = false; - 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]); } diff --git a/src/gausskernel/security/gs_ledger/userchain.cpp b/src/gausskernel/security/gs_ledger/userchain.cpp index ce9369ad4..b08ab8f40 100644 --- a/src/gausskernel/security/gs_ledger/userchain.cpp +++ b/src/gausskernel/security/gs_ledger/userchain.cpp @@ -233,7 +233,7 @@ int user_hash_attrno(const TupleDesc rd_att) int hash_natt = -1; Form_pg_attribute rel_attr = NULL; for (int i = rd_att->natts - 1; i >= 0; i--) { - rel_attr = rd_att->attrs[i]; + rel_attr = &rd_att->attrs[i]; if (strcmp(rel_attr->attname.data, "hash") == 0) { hash_natt = i; break; @@ -263,7 +263,7 @@ static void hash_combine_tuple_data(char *buf, int buf_size, TupleDesc tabledesc continue; } - uint64 col_hash = compute_hash(tabledesc->attrs[i]->atttypid, values[i], LOCATOR_TYPE_HASH); + uint64 col_hash = compute_hash(tabledesc->attrs[i].atttypid, values[i], LOCATOR_TYPE_HASH); rc = snprintf_s(hash_str, UINT64STRSIZE + 1, UINT64STRSIZE, "%lu", col_hash); securec_check_ss(rc, "", ""); rc = snprintf_s(buf + buflen, buf_size - buflen, buf_size - buflen - 1, "%s", hash_str); diff --git a/src/gausskernel/security/gs_policy/policy_common.cpp b/src/gausskernel/security/gs_policy/policy_common.cpp index 1b573cfe6..e07da2162 100644 --- a/src/gausskernel/security/gs_policy/policy_common.cpp +++ b/src/gausskernel/security/gs_policy/policy_common.cpp @@ -276,7 +276,7 @@ static bool verify_column_name(Oid relid, const char *colname) /* verify column */ if (tbl_rel->rd_att != NULL) { for (int i = 0; i < tbl_rel->rd_att->natts && !is_found; ++i) { - Form_pg_attribute attr = tbl_rel->rd_att->attrs[i]; + Form_pg_attribute attr = &tbl_rel->rd_att->attrs[i]; is_found = (strcasecmp(attr->attname.data, colname) == 0); } } diff --git a/src/gausskernel/storage/access/cbtree/cbtree.cpp b/src/gausskernel/storage/access/cbtree/cbtree.cpp index 0dc0711b3..39335dbec 100644 --- a/src/gausskernel/storage/access/cbtree/cbtree.cpp +++ b/src/gausskernel/storage/access/cbtree/cbtree.cpp @@ -78,7 +78,7 @@ Datum cbtreebuild(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("Invalid index column, attribute column index is %d", heapScanAttrNumbers[i]))); } - transferFuncs[i] = GetTransferFuncByTypeOid(heapRel->rd_att->attrs[heapScanAttrNumbers[i] - 1]->atttypid); + transferFuncs[i] = GetTransferFuncByTypeOid(heapRel->rd_att->attrs[heapScanAttrNumbers[i] - 1].atttypid); } /* add ctid column for cstore scan */ diff --git a/src/gausskernel/storage/access/common/heaptuple.cpp b/src/gausskernel/storage/access/common/heaptuple.cpp index 27a0a5682..0ce5cf9fc 100644 --- a/src/gausskernel/storage/access/common/heaptuple.cpp +++ b/src/gausskernel/storage/access/common/heaptuple.cpp @@ -103,7 +103,7 @@ Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, const bool *isnu Size data_length = 0; int i; int numberOfAttributes = tupleDesc->natts; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; for (i = 0; i < numberOfAttributes; i++) { Datum val; @@ -114,15 +114,15 @@ Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, const bool *isnu val = values[i]; - if (ATT_IS_PACKABLE(att[i]) && VARATT_CAN_MAKE_SHORT(DatumGetPointer(val))) { + if (ATT_IS_PACKABLE(&att[i]) && VARATT_CAN_MAKE_SHORT(DatumGetPointer(val))) { /* * we're anticipating converting to a short varlena header, so * adjust length and don't count any alignment */ data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val)); } else { - data_length = att_align_datum(data_length, att[i]->attalign, att[i]->attlen, val); - data_length = att_addlength_datum(data_length, att[i]->attlen, val); + data_length = att_align_datum(data_length, att[i].attalign, att[i].attlen, val); + data_length = att_addlength_datum(data_length, att[i].attlen, val); } } @@ -145,7 +145,7 @@ void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, cha uint32 bitmask; int i; int numberOfAttributes = tupleDesc->natts; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; errno_t rc = EOK; char *begin = data; @@ -189,12 +189,12 @@ void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, cha * XXX we use the att_align macros on the pointer value itself, not on * an offset. This is a bit of a hack. */ - if (att[i]->attbyval) { + if (att[i].attbyval) { /* pass-by-value */ - data = (char *)att_align_nominal(data, att[i]->attalign); - store_att_byval(data, values[i], att[i]->attlen); - data_length = att[i]->attlen; - } else if (att[i]->attlen == -1) { + data = (char *)att_align_nominal(data, att[i].attalign); + store_att_byval(data, values[i], att[i].attlen); + data_length = att[i].attlen; + } else if (att[i].attlen == -1) { /* varlena */ Pointer val = DatumGetPointer(values[i]); @@ -210,7 +210,7 @@ void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, cha data_length = VARSIZE_SHORT(val); rc = memcpy_s(data, remain_length, val, data_length); securec_check(rc, "\0", "\0"); - } else if (VARLENA_ATT_IS_PACKABLE(att[i]) && VARATT_CAN_MAKE_SHORT(val)) { + } else if (VARLENA_ATT_IS_PACKABLE(&att[i]) && VARATT_CAN_MAKE_SHORT(val)) { /* convert to short varlena -- no alignment */ data_length = VARATT_CONVERTED_SHORT_SIZE(val); SET_VARSIZE_SHORT(data, data_length); @@ -220,23 +220,23 @@ void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, cha } } else { /* full 4-byte header varlena */ - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); data_length = VARSIZE(val); rc = memcpy_s(data, remain_length, val, data_length); securec_check(rc, "\0", "\0"); } - } else if (att[i]->attlen == -2) { + } else if (att[i].attlen == -2) { /* cstring ... never needs alignment */ *infomask |= HEAP_HASVARWIDTH; - Assert(att[i]->attalign == 'c'); + Assert(att[i].attalign == 'c'); data_length = strlen(DatumGetCString(values[i])) + 1; rc = memcpy_s(data, remain_length, DatumGetPointer(values[i]), data_length); securec_check(rc, "\0", "\0"); } else { /* fixed-length pass-by-reference */ - data = (char *)att_align_nominal(data, att[i]->attalign); - Assert(att[i]->attlen > 0); - data_length = att[i]->attlen; + data = (char *)att_align_nominal(data, att[i].attalign); + Assert(att[i].attlen > 0); + data_length = att[i].attlen; rc = memcpy_s(data, remain_length, DatumGetPointer(values[i]), data_length); securec_check(rc, "\0", "\0"); } @@ -301,7 +301,7 @@ Datum heapGetInitDefVal(int attNum, TupleDesc tupleDesc, bool *isNull) if (tupleDesc->initdefvals != NULL) { *isNull = tupleDesc->initdefvals[attNum - 1].isNull; if (!(*isNull)) { - return fetchatt(tupleDesc->attrs[attNum - 1], tupleDesc->initdefvals[attNum - 1].datum); + return fetchatt(&tupleDesc->attrs[attNum - 1], tupleDesc->initdefvals[attNum - 1].datum); } } @@ -346,12 +346,12 @@ bool relationAttIsNull(HeapTuple tup, int attNum, TupleDesc tupleDesc) Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) { HeapTupleHeader tup = tuple->t_data; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; char *tp = NULL; /* ptr to data part of tuple */ bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ bool slow = false; /* do we have to walk attrs? */ int off; /* current offset within data */ - bool heapToUHeap = tupleDesc->tdTableAmType == TAM_USTORE; + bool heapToUHeap = tupleDesc->td_tam_ops == TableAmUstore; /* * Ustore has different alignment rules so we force slow = true here. @@ -414,8 +414,8 @@ Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) * If we get here, there are no nulls up to and including the target * attribute. If we have a cached offset, we can use it. */ - if (att[attnum]->attcacheoff >= 0) { - return fetchatt(att[attnum], tp + att[attnum]->attcacheoff); + if (att[attnum].attcacheoff >= 0) { + return fetchatt(&att[attnum], tp + att[attnum].attcacheoff); } /* @@ -427,7 +427,7 @@ Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) uint32 j; for (j = 0; j <= attnum; j++) { - if (att[j]->attlen <= 0) { + if (att[j].attlen <= 0) { slow = true; break; } @@ -448,30 +448,30 @@ Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) * fixed-width columns, in hope of avoiding future visits to this * routine. */ - att[0]->attcacheoff = 0; + att[0].attcacheoff = 0; /* we might have set some offsets in the slow path previously */ - while (j < natts && att[j]->attcacheoff > 0) { + while (j < natts && att[j].attcacheoff > 0) { j++; } - off = att[j - 1]->attcacheoff + att[j - 1]->attlen; + off = att[j - 1].attcacheoff + att[j - 1].attlen; for (; j < natts; j++) { - if (att[j]->attlen <= 0) { + if (att[j].attlen <= 0) { break; } - off = att_align_nominal((uint32)off, att[j]->attalign); + off = att_align_nominal((uint32)off, att[j].attalign); - att[j]->attcacheoff = off; + att[j].attcacheoff = off; - off += att[j]->attlen; + off += att[j].attlen; } Assert(j > attnum); - off = att[attnum]->attcacheoff; + off = att[attnum].attcacheoff; } else { bool usecache = !heapToUHeap; uint32 i; @@ -495,27 +495,27 @@ Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) } /* If we know the next offset, we can skip the rest */ - if (usecache && att[i]->attcacheoff >= 0) { - off = att[i]->attcacheoff; - } else if (att[i]->attlen == -1) { + if (usecache && att[i].attcacheoff >= 0) { + off = att[i].attcacheoff; + } else if (att[i].attlen == -1) { /* * We can only cache the offset for a varlena attribute if the * offset is already suitably aligned, so that there would be * no pad bytes in any case: then the offset will be valid for * either an aligned or unaligned value. */ - if (usecache && (uintptr_t)(off) == att_align_nominal((uint32)off, att[i]->attalign)) { - att[i]->attcacheoff = off; + if (usecache && (uintptr_t)(off) == att_align_nominal((uint32)off, att[i].attalign)) { + att[i].attcacheoff = off; } else { - off = att_align_pointer((uint32)off, att[i]->attalign, -1, tp + off); + off = att_align_pointer((uint32)off, att[i].attalign, -1, tp + off); usecache = false; } } else { /* not varlena, so safe to use att_align_nominal */ - off = att_align_nominal((uint32)off, att[i]->attalign); + off = att_align_nominal((uint32)off, att[i].attalign); if (usecache) { - att[i]->attcacheoff = off; + att[i].attcacheoff = off; } } @@ -523,15 +523,15 @@ Datum nocachegetattr(HeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) break; } - off = att_addlength_pointer(off, att[i]->attlen, tp + off); + off = att_addlength_pointer(off, att[i].attlen, tp + off); - if (usecache && att[i]->attlen <= 0) { + if (usecache && att[i].attlen <= 0) { usecache = false; } } } - return fetchatt(att[attnum], tp + off); + return fetchatt(&att[attnum], tp + off); } /* ---------------- @@ -698,7 +698,7 @@ HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull Size len, data_len; int hoff; bool hasnull = false; - Form_pg_attribute *att = tupleDescriptor->attrs; + FormData_pg_attribute *att = tupleDescriptor->attrs; int numberOfAttributes = tupleDescriptor->natts; int i; @@ -706,7 +706,7 @@ HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", numberOfAttributes, - MaxTupleAttributeNumber, tupleDescriptor->tdTableAmType, tupleDescriptor->tdtypeid))); + MaxTupleAttributeNumber, GetTableAmType(tupleDescriptor->td_tam_ops), tupleDescriptor->tdtypeid))); } /* @@ -723,12 +723,12 @@ HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull for (i = 0; i < numberOfAttributes; i++) { if (isnull[i]) { hasnull = true; - } else if (att[i]->attlen == -1 && att[i]->attalign == 'd' && att[i]->attndims == 0 && + } else if (att[i].attlen == -1 && att[i].attalign == 'd' && att[i].attndims == 0 && !VARATT_IS_EXTENDED(DatumGetPointer(values[i]))) { - values[i] = toast_flatten_tuple_attribute(values[i], att[i]->atttypid, att[i]->atttypmod); - } else if (att[i]->attlen == -1 && att[i]->attalign == 'i' && + values[i] = toast_flatten_tuple_attribute(values[i], att[i].atttypid, att[i].atttypmod); + } else if (att[i].attlen == -1 && att[i].attalign == 'i' && VARATT_IS_HUGE_TOAST_POINTER(DatumGetPointer(values[i])) && - !(att[i]->atttypid == CLOBOID || att[i]->atttypid == BLOBOID)) { + !(att[i].atttypid == CLOBOID || att[i].atttypid == BLOBOID)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only suport type(clob/blob) for more than 1G toast"))); } @@ -951,14 +951,14 @@ void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool { HeapTupleHeader tup = tuple->t_data; bool hasnulls = HeapTupleHasNulls(tuple); - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; uint32 tdesc_natts = tupleDesc->natts; uint32 natts; /* number of atts to extract */ uint32 attnum; char *tp = NULL; /* ptr to tuple data */ long off; /* offset in tuple data */ bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ - bool heapToUHeap = tupleDesc->tdTableAmType == TAM_USTORE; + bool heapToUHeap = tupleDesc->td_tam_ops == TableAmUstore; /* * We need to default to slow if the TupleDesc type is UStore because @@ -994,7 +994,7 @@ void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool off = 0; for (attnum = 0; attnum < natts; attnum++) { - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (hasnulls && att_isnull(attnum, bp)) { values[attnum] = (Datum)0; @@ -1137,13 +1137,13 @@ static void slot_deform_tuple(TupleTableSlot *slot, uint32 natts) bool *isnull = slot->tts_isnull; HeapTupleHeader tup = tuple->t_data; bool hasnulls = HeapTupleHasNulls(tuple); - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; uint32 attnum; char *tp = NULL; /* ptr to tuple data */ long off; /* offset in tuple data */ bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ bool slow = false; /* can we use/set attcacheoff? */ - bool heapToUHeap = tupleDesc->tdTableAmType == TAM_USTORE; + bool heapToUHeap = tupleDesc->td_tam_ops == TableAmUstore; /* * Check whether the first call for this tuple, and initialize or restore @@ -1169,7 +1169,7 @@ static void slot_deform_tuple(TupleTableSlot *slot, uint32 natts) tp = (char *)tup + tup->t_hoff; for (; attnum < natts; attnum++) { - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (hasnulls && att_isnull(attnum, bp)) { values[attnum] = (Datum)0; @@ -1210,13 +1210,13 @@ static void slot_deform_batch(TupleTableSlot *slot, VectorBatch* batch, int cur_ TupleDesc tupleDesc = slot->tts_tupleDescriptor; HeapTupleHeader tup = tuple->t_data; bool hasnulls = HeapTupleHasNulls(tuple); - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; uint32 attnum; char *tp = NULL; /* ptr to tuple data */ long off; /* offset in tuple data */ bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ bool slow = false; /* can we use/set attcacheoff? */ - bool heapToUHeap = tupleDesc->tdTableAmType == TAM_USTORE; + bool heapToUHeap = tupleDesc->td_tam_ops == TableAmUstore; /* * Check whether the first call for this tuple, and initialize or restore @@ -1235,7 +1235,7 @@ static void slot_deform_batch(TupleTableSlot *slot, VectorBatch* batch, int cur_ tp = (char *)tup + tup->t_hoff; for (; attnum < natts; attnum++) { - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; ScalarVector* pVector = &batch->m_arr[attnum]; if (hasnulls && att_isnull(attnum, bp)) { @@ -1287,7 +1287,7 @@ static void slot_extract_anyarray_from_buff(TupleTableSlot *slot, int index, con Datum array_datum; Size data_length; errno_t rc = EOK; - Form_pg_attribute *att = slot->tts_tupleDescriptor->attrs; + FormData_pg_attribute *att = slot->tts_tupleDescriptor->attrs; int attnum = slot->tts_tupleDescriptor->natts; if (index >= attnum) { @@ -1295,7 +1295,7 @@ static void slot_extract_anyarray_from_buff(TupleTableSlot *slot, int index, con } /* If from remote cn, the datatype in buffer is string, not varattrib, so we should not use it as varattrib */ - if ((att[index]->attlen == -1) && (!need_transform_anyarray)) { + if ((att[index].attlen == -1) && (!need_transform_anyarray)) { data_length = VARSIZE_ANY(buffer->data); if (data_length <= (Size)((uint32)len + 1)) { data_length = len + 1; @@ -1345,7 +1345,7 @@ static void slot_deform_datarow(TupleTableSlot *slot, bool need_transform_anyarr return; } - Form_pg_attribute *att = slot->tts_tupleDescriptor->attrs; + FormData_pg_attribute *att = slot->tts_tupleDescriptor->attrs; attnum = slot->tts_tupleDescriptor->natts; /* fastpath: exit if values already extracted */ @@ -1395,7 +1395,7 @@ static void slot_deform_datarow(TupleTableSlot *slot, bool need_transform_anyarr } else { appendBinaryStringInfo(buffer, cur, len); cur += len; - if (att[i]->atttypid == ANYARRAYOID) { + if (att[i].atttypid == ANYARRAYOID) { /* For anyarray, it need more information to handle it, so leave it, just copy */ slot_extract_anyarray_from_buff(slot, i, buffer, len, need_transform_anyarray); } else { @@ -1497,7 +1497,7 @@ Datum heap_slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull, bool nee * This case should not happen in normal use, but it could happen if we * are executing a plan cached before the column was dropped. */ - if (tupleDesc->attrs[attnum - 1]->attisdropped) { + if (tupleDesc->attrs[attnum - 1].attisdropped) { *isnull = true; return (Datum) 0; } @@ -1816,7 +1816,7 @@ MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, Datum *values, c Size len, data_len; int hoff; bool hasnull = false; - Form_pg_attribute *att = tupleDescriptor->attrs; + FormData_pg_attribute *att = tupleDescriptor->attrs; int numberOfAttributes = tupleDescriptor->natts; int i; @@ -1835,11 +1835,11 @@ MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, Datum *values, c for (i = 0; i < numberOfAttributes; i++) { if (isnull[i]) { hasnull = true; - } else if (att[i]->attlen == -1 && att[i]->attalign == 'd' && att[i]->attndims == 0 && + } else if (att[i].attlen == -1 && att[i].attalign == 'd' && att[i].attndims == 0 && !VARATT_IS_EXTENDED(values[i])) { - values[i] = toast_flatten_tuple_attribute(values[i], att[i]->atttypid, att[i]->atttypmod); - } else if (att[i]->attlen == -1 && VARATT_IS_HUGE_TOAST_POINTER(DatumGetPointer(values[i])) && - !(att[i]->atttypid == CLOBOID || att[i]->atttypid == BLOBOID)) { + values[i] = toast_flatten_tuple_attribute(values[i], att[i].atttypid, att[i].atttypmod); + } else if (att[i].attlen == -1 && VARATT_IS_HUGE_TOAST_POINTER(DatumGetPointer(values[i])) && + !(att[i].atttypid == CLOBOID || att[i].atttypid == BLOBOID)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only suport type(clob/blob) for more than 1G toast"))); } @@ -1997,12 +1997,12 @@ static Size heap_compute_cmprs_data_size(TupleDesc tupleDesc, FormCmprTupleData Size data_length = 0; int i; int numberOfAttributes = tupleDesc->natts; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; if (numberOfAttributes > MaxTupleAttributeNumber) { ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", numberOfAttributes, - MaxTupleAttributeNumber, tupleDesc->tdTableAmType, tupleDesc->tdtypeid))); + MaxTupleAttributeNumber, GetTableAmType(tupleDesc->td_tam_ops), tupleDesc->tdtypeid))); } /* @@ -2029,15 +2029,15 @@ static Size heap_compute_cmprs_data_size(TupleDesc tupleDesc, FormCmprTupleData /* the normal field is the last */ Datum val = cmprsInfo->values[i]; - if (ATT_IS_PACKABLE(att[i]) && VARATT_CAN_MAKE_SHORT(DatumGetPointer(val))) { + if (ATT_IS_PACKABLE(&att[i]) && VARATT_CAN_MAKE_SHORT(DatumGetPointer(val))) { /* * we're anticipating converting to a short varlena header, so * adjust length and don't count any alignment */ data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val)); } else { - data_length = att_align_datum(data_length, att[i]->attalign, att[i]->attlen, val); - data_length = att_addlength_datum(data_length, att[i]->attlen, val); + data_length = att_align_datum(data_length, att[i].attalign, att[i].attlen, val); + data_length = att_addlength_datum(data_length, att[i].attlen, val); } } @@ -2093,7 +2093,7 @@ static void heap_fill_cmprs_tuple(TupleDesc tupleDesc, FormCmprTupleData *cmprsI int i; int numberOfAttributes = tupleDesc->natts; errno_t retno = EOK; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; char *start = data; /* compression-bitmap MUST be put firstly. @@ -2149,8 +2149,8 @@ static void heap_fill_cmprs_tuple(TupleDesc tupleDesc, FormCmprTupleData *cmprsI *infomask |= HEAP_COMPRESSED; /* Important: we must keep setting flag */ - if (att[i]->attlen < 0) { - Assert((-1 == att[i]->attlen) || (-2 == att[i]->attlen)); + if (att[i].attlen < 0) { + Assert((-1 == att[i].attlen) || (-2 == att[i].attlen)); *infomask |= HEAP_HASVARWIDTH; } @@ -2161,12 +2161,12 @@ static void heap_fill_cmprs_tuple(TupleDesc tupleDesc, FormCmprTupleData *cmprsI * XXX we use the att_align macros on the pointer value itself, not on * an offset. This is a bit of a hack. */ - if (att[i]->attbyval) { + if (att[i].attbyval) { /* pass-by-value */ - data = (char *)att_align_nominal(data, att[i]->attalign); - store_att_byval(data, cmprsInfo->values[i], att[i]->attlen); - data_length = att[i]->attlen; - } else if (att[i]->attlen == -1) { + data = (char *)att_align_nominal(data, att[i].attalign); + store_att_byval(data, cmprsInfo->values[i], att[i].attlen); + data_length = att[i].attlen; + } else if (att[i].attlen == -1) { /* varlena */ Pointer val = DatumGetPointer(cmprsInfo->values[i]); @@ -2182,7 +2182,7 @@ static void heap_fill_cmprs_tuple(TupleDesc tupleDesc, FormCmprTupleData *cmprsI data_length = VARSIZE_SHORT(val); retno = memcpy_s(data, remian_length, val, data_length); securec_check(retno, "\0", "\0"); - } else if (VARLENA_ATT_IS_PACKABLE(att[i]) && VARATT_CAN_MAKE_SHORT(val)) { + } else if (VARLENA_ATT_IS_PACKABLE(&att[i]) && VARATT_CAN_MAKE_SHORT(val)) { /* convert to short varlena -- no alignment */ data_length = VARATT_CONVERTED_SHORT_SIZE(val); SET_VARSIZE_SHORT(data, data_length); @@ -2190,23 +2190,23 @@ static void heap_fill_cmprs_tuple(TupleDesc tupleDesc, FormCmprTupleData *cmprsI securec_check(retno, "\0", "\0"); } else { /* full 4-byte header varlena */ - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); data_length = VARSIZE(val); retno = memcpy_s(data, remian_length, val, data_length); securec_check(retno, "\0", "\0"); } - } else if (att[i]->attlen == -2) { + } else if (att[i].attlen == -2) { /* cstring ... never needs alignment */ *infomask |= HEAP_HASVARWIDTH; - Assert(att[i]->attalign == 'c'); + Assert(att[i].attalign == 'c'); data_length = strlen(DatumGetCString(cmprsInfo->values[i])) + 1; retno = memcpy_s(data, remian_length, DatumGetPointer(cmprsInfo->values[i]), data_length); securec_check(retno, "\0", "\0"); } else { /* fixed-length pass-by-reference */ - data = (char *)att_align_nominal(data, att[i]->attalign); - Assert(att[i]->attlen > 0); - data_length = att[i]->attlen; + data = (char *)att_align_nominal(data, att[i].attalign); + Assert(att[i].attlen > 0); + data_length = att[i].attlen; retno = memcpy_s(data, remian_length, DatumGetPointer(cmprsInfo->values[i]), data_length); securec_check(retno, "\0", "\0"); } @@ -2220,7 +2220,7 @@ static void heap_fill_cmprs_tuple(TupleDesc tupleDesc, FormCmprTupleData *cmprsI Datum nocache_cmprs_get_attr(HeapTuple tuple, unsigned int attnum, TupleDesc tupleDesc, char *cmprsInfo) { HeapTupleHeader tup = tuple->t_data; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; char *tp = NULL; /* ptr to data part of tuple */ bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ bits8 *cmprsBitmap = NULL; @@ -2245,7 +2245,7 @@ Datum nocache_cmprs_get_attr(HeapTuple tuple, unsigned int attnum, TupleDesc tup /* first parse compression metaInfo data of this attr */ int metaSize = 0; - metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, att[i]->attlen, &metaSize, &mode); + metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, att[i].attlen, &metaSize, &mode); cmprsOff += metaSize; if (HeapTupleHasNulls(tuple) && att_isnull(i, bp)) { @@ -2254,34 +2254,34 @@ Datum nocache_cmprs_get_attr(HeapTuple tuple, unsigned int attnum, TupleDesc tup if (isAttrCompressed(i, cmprsBitmap)) { if (attnum != i) { - off += PageCompress::GetAttrCmprValSize(mode, att[i]->attlen, metaInfo, tp + off); + off += PageCompress::GetAttrCmprValSize(mode, att[i].attlen, metaInfo, tp + off); continue; } break; } - if (att[i]->attlen == -1) { - off = att_align_pointer((uint32)off, att[i]->attalign, -1, tp + off); + if (att[i].attlen == -1) { + off = att_align_pointer((uint32)off, att[i].attalign, -1, tp + off); } else { - off = att_align_nominal((uint32)off, att[i]->attalign); + off = att_align_nominal((uint32)off, att[i].attalign); } if (i == attnum) { break; } - off = att_addlength_pointer(off, att[i]->attlen, tp + off); + off = att_addlength_pointer(off, att[i].attlen, tp + off); } Assert(attnum == i); if (isAttrCompressed(attnum, cmprsBitmap)) { int attsize = 0; - Datum attr_val = PageCompress::UncompressOneAttr(mode, metaInfo, att[i]->atttypid, att[i]->attlen, tp + off, + Datum attr_val = PageCompress::UncompressOneAttr(mode, metaInfo, att[i].atttypid, att[i].attlen, tp + off, &attsize); return attr_val; } - return fetchatt(att[attnum], tp + off); + return fetchatt(&att[attnum], tp + off); } /* @@ -2295,7 +2295,7 @@ static HeapTuple HeapUncompressTup(HeapTuple srcTuple, TupleDesc tupleDesc, char Assert(srcTuple && tupleDesc && cmprsInfo); HeapTupleHeader srcTup = srcTuple->t_data; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; uint32 tdesc_natts = tupleDesc->natts; uint32 natts; /* number of atts to extract */ uint32 attrIdx; @@ -2352,7 +2352,7 @@ static HeapTuple HeapUncompressTup(HeapTuple srcTuple, TupleDesc tupleDesc, char } for (attrIdx = 0; attrIdx < natts; ++attrIdx) { - Form_pg_attribute thisatt = att[attrIdx]; + Form_pg_attribute thisatt = &att[attrIdx]; /* parse compression metaInfo data of this attr */ int metaSize = 0; metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, thisatt->attlen, &metaSize, &mode); @@ -2536,7 +2536,7 @@ HeapTuple heap_form_cmprs_tuple(TupleDesc tupleDescriptor, FormCmprTupleData *cm #ifdef USE_ASSERT_CHECKING bool hascmpr = false; #endif - Form_pg_attribute *att = tupleDescriptor->attrs; + FormData_pg_attribute *att = tupleDescriptor->attrs; int numberOfAttributes = tupleDescriptor->natts; int i; @@ -2544,7 +2544,7 @@ HeapTuple heap_form_cmprs_tuple(TupleDesc tupleDescriptor, FormCmprTupleData *cm ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", numberOfAttributes, - MaxTupleAttributeNumber, tupleDescriptor->tdTableAmType, tupleDescriptor->tdtypeid))); + MaxTupleAttributeNumber, GetTableAmType(tupleDescriptor->td_tam_ops), tupleDescriptor->tdtypeid))); } /* @@ -2568,10 +2568,10 @@ HeapTuple heap_form_cmprs_tuple(TupleDesc tupleDescriptor, FormCmprTupleData *cm #ifdef USE_ASSERT_CHECKING hascmpr = true; #endif - } else if (att[i]->attlen == -1 && att[i]->attalign == 'd' && att[i]->attndims == 0 && + } else if (att[i].attlen == -1 && att[i].attalign == 'd' && att[i].attndims == 0 && !VARATT_IS_EXTENDED(DatumGetPointer(cmprsInfo->values[i]))) { - cmprsInfo->values[i] = toast_flatten_tuple_attribute(cmprsInfo->values[i], att[i]->atttypid, - att[i]->atttypmod); + cmprsInfo->values[i] = toast_flatten_tuple_attribute(cmprsInfo->values[i], att[i].atttypid, + att[i].atttypmod); } } Assert(hascmpr == true); @@ -2663,7 +2663,7 @@ void heap_deform_cmprs_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values { HeapTupleHeader tup = tuple->t_data; bool hasnulls = HeapTupleHasNulls(tuple); - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; uint32 tdesc_natts = tupleDesc->natts; uint32 natts; /* number of atts to extract */ uint32 attnum; @@ -2695,7 +2695,7 @@ void heap_deform_cmprs_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values for (attnum = 0; attnum < natts; attnum++) { /* parse compression metaInfo data of this attr */ int metaSize = 0; - metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, att[attnum]->attlen, &metaSize, &mode); + metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, att[attnum].attlen, &metaSize, &mode); cmprsOff += metaSize; /* IMPORTANT: NULLs first, row-compression second, and the normal fields the last; */ @@ -2709,14 +2709,14 @@ void heap_deform_cmprs_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values if (isAttrCompressed(attnum, cmprsBitmap)) { int attsize = 0; - values[attnum] = PageCompress::UncompressOneAttr(mode, metaInfo, att[attnum]->atttypid, att[attnum]->attlen, + values[attnum] = PageCompress::UncompressOneAttr(mode, metaInfo, att[attnum].atttypid, att[attnum].attlen, tp + off, &attsize); off = off + attsize; /* attsize is the size of compressed value. */ continue; } - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (thisatt->attlen == -1) { off = att_align_pointer(off, thisatt->attalign, -1, tp + off); } else { @@ -2901,7 +2901,7 @@ static void slot_deform_cmprs_tuple(TupleTableSlot *slot, uint32 natts) bool *isnull = slot->tts_isnull; HeapTupleHeader tup = tuple->t_data; bool hasnulls = HeapTupleHasNulls(tuple); - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; uint32 attnum; char *tp = NULL; /* ptr to tuple data */ long off; /* offset in tuple data */ @@ -2949,7 +2949,7 @@ static void slot_deform_cmprs_tuple(TupleTableSlot *slot, uint32 natts) /* parse compression metaInfo data of this attr */ int metaSize = 0; for (; attnum < natts; attnum++) { - metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, att[attnum]->attlen, &metaSize, &mode); + metaInfo = PageCompress::FetchAttrCmprMeta(cmprsInfo + cmprsOff, att[attnum].attlen, &metaSize, &mode); cmprsOff += metaSize; if (hasnulls && att_isnull(attnum, bp)) { @@ -2962,14 +2962,14 @@ static void slot_deform_cmprs_tuple(TupleTableSlot *slot, uint32 natts) if (isAttrCompressed(attnum, cmprsBitmap)) { int attsize = 0; - values[attnum] = PageCompress::UncompressOneAttr(mode, metaInfo, att[attnum]->atttypid, att[attnum]->attlen, + values[attnum] = PageCompress::UncompressOneAttr(mode, metaInfo, att[attnum].atttypid, att[attnum].attlen, tp + off, &attsize); off = off + attsize; /* attsize is the size of compressed value. */ continue; } - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (thisatt->attlen == -1) { off = att_align_pointer(off, thisatt->attalign, -1, tp + off); } else { diff --git a/src/gausskernel/storage/access/common/indextuple.cpp b/src/gausskernel/storage/access/common/indextuple.cpp index e3f4cf93d..b6c6c1a69 100644 --- a/src/gausskernel/storage/access/common/indextuple.cpp +++ b/src/gausskernel/storage/access/common/indextuple.cpp @@ -109,11 +109,11 @@ IndexTuple index_form_tuple(TupleDesc tuple_descriptor, Datum* values, const boo #ifdef TOAST_INDEX_HACK uint32 toastTarget = TOAST_INDEX_TARGET; - if (tuple_descriptor->tdTableAmType == TAM_USTORE) { + if (tuple_descriptor->td_tam_ops == TableAmUstore) { toastTarget = UTOAST_INDEX_TARGET; } for (i = 0; i < attributeNum; i++) { - Form_pg_attribute att = tuple_descriptor->attrs[i]; + Form_pg_attribute att = &tuple_descriptor->attrs[i]; untoasted_values[i] = values[i]; untoasted_free[i] = false; @@ -243,7 +243,7 @@ IndexTuple index_form_tuple(TupleDesc tuple_descriptor, Datum* values, const boo */ Datum nocache_index_getattr(IndexTuple tup, uint32 attnum, TupleDesc tuple_desc) { - Form_pg_attribute* att = tuple_desc->attrs; + FormData_pg_attribute* att = tuple_desc->attrs; char* tp = NULL; /* ptr to data part of tuple */ bits8* bp = NULL; /* ptr to null bitmap in tuple */ bool slow = false; /* do we have to walk attrs? */ @@ -300,8 +300,8 @@ Datum nocache_index_getattr(IndexTuple tup, uint32 attnum, TupleDesc tuple_desc) * If we get here, there are no nulls up to and including the target * attribute. If we have a cached offset, we can use it. */ - if (att[attnum]->attcacheoff >= 0) { - return fetchatt(att[attnum], tp + att[attnum]->attcacheoff); + if (att[attnum].attcacheoff >= 0) { + return fetchatt(&att[attnum], tp + att[attnum].attcacheoff); } /* @@ -313,7 +313,7 @@ Datum nocache_index_getattr(IndexTuple tup, uint32 attnum, TupleDesc tuple_desc) uint32 j; for (j = 0; j <= attnum; j++) { - if (att[j]->attlen <= 0) { + if (att[j].attlen <= 0) { slow = true; break; } @@ -334,28 +334,28 @@ Datum nocache_index_getattr(IndexTuple tup, uint32 attnum, TupleDesc tuple_desc) * fixed-width columns, in hope of avoiding future visits to this * routine. */ - att[0]->attcacheoff = 0; + att[0].attcacheoff = 0; /* we might have set some offsets in the slow path previously */ - while (j < natts && att[j]->attcacheoff > 0) + while (j < natts && att[j].attcacheoff > 0) j++; - off = att[j - 1]->attcacheoff + att[j - 1]->attlen; + off = att[j - 1].attcacheoff + att[j - 1].attlen; for (; j < natts; j++) { - if (att[j]->attlen <= 0) + if (att[j].attlen <= 0) break; - off = att_align_nominal((uint32)off, att[j]->attalign); + off = att_align_nominal((uint32)off, att[j].attalign); - att[j]->attcacheoff = off; + att[j].attcacheoff = off; - off += att[j]->attlen; + off += att[j].attlen; } Assert(j > attnum); - off = att[attnum]->attcacheoff; + off = att[attnum].attcacheoff; } else { bool usecache = true; uint32 i; @@ -378,40 +378,40 @@ Datum nocache_index_getattr(IndexTuple tup, uint32 attnum, TupleDesc tuple_desc) } /* If we know the next offset, we can skip the rest */ - if (usecache && att[i]->attcacheoff >= 0) - off = att[i]->attcacheoff; - else if (att[i]->attlen == -1) { + if (usecache && att[i].attcacheoff >= 0) + off = att[i].attcacheoff; + else if (att[i].attlen == -1) { /* * We can only cache the offset for a varlena attribute if the * offset is already suitably aligned, so that there would be * no pad bytes in any case: then the offset will be valid for * either an aligned or unaligned value. */ - if (usecache && (uintptr_t)(off) == att_align_nominal((uint32)off, att[i]->attalign)) - att[i]->attcacheoff = off; + if (usecache && (uintptr_t)(off) == att_align_nominal((uint32)off, att[i].attalign)) + att[i].attcacheoff = off; else { - off = att_align_pointer((uint32)off, att[i]->attalign, -1, tp + off); + off = att_align_pointer((uint32)off, att[i].attalign, -1, tp + off); usecache = false; } } else { /* not varlena, so safe to use att_align_nominal */ - off = att_align_nominal((uint32)off, att[i]->attalign); + off = att_align_nominal((uint32)off, att[i].attalign); if (usecache) - att[i]->attcacheoff = off; + att[i].attcacheoff = off; } if (i == attnum) break; - off = att_addlength_pointer(off, att[i]->attlen, tp + off); + off = att_addlength_pointer(off, att[i].attlen, tp + off); - if (usecache && att[i]->attlen <= 0) + if (usecache && att[i].attlen <= 0) usecache = false; } } - return fetchatt(att[attnum], tp + off); + return fetchatt(&att[attnum], tp + off); } /* diff --git a/src/gausskernel/storage/access/common/printtup.cpp b/src/gausskernel/storage/access/common/printtup.cpp index feecc43e4..9fc7603b9 100644 --- a/src/gausskernel/storage/access/common/printtup.cpp +++ b/src/gausskernel/storage/access/common/printtup.cpp @@ -518,7 +518,7 @@ void SendRowDescriptionMessage(StringInfo buf, TupleDesc typeinfo, List *targetl */ static void SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *targetlist, int16 *formats) { - Form_pg_attribute *attrs = typeinfo->attrs; + FormData_pg_attribute *attrs = typeinfo->attrs; int natts = typeinfo->natts; int i; ListCell *tlist_item = list_head(targetlist); @@ -546,13 +546,13 @@ static void SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *t ) * natts); for (i = 0; i < natts; ++i) { - Oid atttypid = attrs[i]->atttypid; - int32 atttypmod = attrs[i]->atttypmod; + Oid atttypid = attrs[i].atttypid; + int32 atttypmod = attrs[i].atttypmod; if (IsClientLogicType(atttypid) && atttypmod == -1) { elog(DEBUG1, "client logic without original type is sent to client"); } - writeString(buf, NameStr(attrs[i]->attname), true); + writeString(buf, NameStr(attrs[i].attname), true); #ifdef PGXC /* @@ -560,7 +560,7 @@ static void SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *t * if we encounter droped columns, we should send it to CN. but atttypid of dropped column * is invalid in pg_attribute, it will generate error, so we should do special process for the reason. */ - if (IsConnFromCoord() && attrs[i]->attisdropped) + if (IsConnFromCoord() && attrs[i].attisdropped) atttypid = UNKNOWNOID; #endif @@ -587,7 +587,7 @@ static void SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *t /* If column is a domain, send the base type and typmod instead */ atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod); pq_writeint32(buf, atttypid); - pq_writeint16(buf, attrs[i]->attlen); + pq_writeint16(buf, attrs[i].attlen); /* typmod appears in protocol 2.0 and up */ pq_writeint32(buf, atttypmod); @@ -615,15 +615,15 @@ static void SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *t */ static void SendRowDescriptionCols_2(StringInfo buf, TupleDesc typeinfo, List *targetlist, int16 *formats) { - Form_pg_attribute *attrs = typeinfo->attrs; + FormData_pg_attribute *attrs = typeinfo->attrs; int natts = typeinfo->natts; int i; for (i = 0; i < natts; ++i) { - Oid atttypid = attrs[i]->atttypid; - int32 atttypmod = attrs[i]->atttypmod; + Oid atttypid = attrs[i].atttypid; + int32 atttypmod = attrs[i].atttypmod; - writeString(buf, NameStr(attrs[i]->attname), false); + writeString(buf, NameStr(attrs[i].attname), false); #ifdef PGXC /* @@ -631,14 +631,14 @@ static void SendRowDescriptionCols_2(StringInfo buf, TupleDesc typeinfo, List *t * if we encounter droped columns, we should send it to CN. but atttypid of dropped column * is invalid in pg_attribute, it will generate error, so we should do special process for the reason. */ - if (IsConnFromCoord() && attrs[i]->attisdropped) + if (IsConnFromCoord() && attrs[i].attisdropped) atttypid = UNKNOWNOID; #endif /* If column is a domain, send the base type and typmod instead */ atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod); pq_sendint32(buf, atttypid); - pq_sendint16(buf, attrs[i]->attlen); + pq_sendint16(buf, attrs[i].attlen); /* typmod appears in protocol 2.0 and up */ pq_sendint32(buf, atttypmod); @@ -757,16 +757,16 @@ static void printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int * if we encounter droped columns, we should send it to CN. but atttypid of dropped column * is invalid in pg_attribute, it will generate error, so we should do special process for the reason. */ - if (typeinfo->attrs[i]->attisdropped) { - typeinfo->attrs[i]->atttypid = UNKNOWNOID; + if (typeinfo->attrs[i].attisdropped) { + typeinfo->attrs[i].atttypid = UNKNOWNOID; } thisState->format = format; if (format == 0) { - getTypeOutputInfo(typeinfo->attrs[i]->atttypid, &thisState->typoutput, &thisState->typisvarlena); + getTypeOutputInfo(typeinfo->attrs[i].atttypid, &thisState->typoutput, &thisState->typisvarlena); fmgr_info(thisState->typoutput, &thisState->finfo); } else if (format == 1) { - getTypeBinaryOutputInfo(typeinfo->attrs[i]->atttypid, &thisState->typsend, &thisState->typisvarlena); + getTypeBinaryOutputInfo(typeinfo->attrs[i].atttypid, &thisState->typsend, &thisState->typisvarlena); fmgr_info(thisState->typsend, &thisState->finfo); } else { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); @@ -800,7 +800,7 @@ static void printtup_prepare_info_for_stream(DR_printtup *myState, TupleDesc typ for (i = 0; i < numAttrs; i++) { PrinttupAttrInfo *thisState = myState->myinfo + i; thisState->format = 0; - getTypeOutputInfo(typeinfo->attrs[i]->atttypid, &thisState->typoutput, &thisState->typisvarlena); + getTypeOutputInfo(typeinfo->attrs[i].atttypid, &thisState->typoutput, &thisState->typisvarlena); fmgr_info(thisState->typoutput, &thisState->finfo); } } @@ -1082,12 +1082,12 @@ void printtup(TupleTableSlot *slot, DestReceiver *self) * skip null value attribute, * we need to skip the droped columns for analyze global stats. */ - if (slot->tts_isnull[i] || typeinfo->attrs[i]->attisdropped) { + if (slot->tts_isnull[i] || typeinfo->attrs[i].attisdropped) { pq_sendint32(buf, (uint32)-1); continue; } - if (typeinfo->attrs[i]->atttypid == ANYARRAYOID && slot->tts_dataRow != NULL) { + if (typeinfo->attrs[i].atttypid == ANYARRAYOID && slot->tts_dataRow != NULL) { /* * For ANYARRAY type, the not null DataRow-based tuple indicates the value in * origattr had been converted to CSTRING type previously by using anyarray_out. @@ -1112,11 +1112,11 @@ void printtup(TupleTableSlot *slot, DestReceiver *self) #endif outputstr = OutputFunctionCall(&thisState->finfo, attr); if (thisState->typisvarlena && self->forAnalyzeSampleTuple && - (typeinfo->attrs[i]->atttypid == BYTEAOID || typeinfo->attrs[i]->atttypid == CHAROID || - typeinfo->attrs[i]->atttypid == TEXTOID || typeinfo->attrs[i]->atttypid == BLOBOID || - typeinfo->attrs[i]->atttypid == CLOBOID || typeinfo->attrs[i]->atttypid == RAWOID || - typeinfo->attrs[i]->atttypid == BPCHAROID || typeinfo->attrs[i]->atttypid == VARCHAROID || - typeinfo->attrs[i]->atttypid == NVARCHAR2OID) && + (typeinfo->attrs[i].atttypid == BYTEAOID || typeinfo->attrs[i].atttypid == CHAROID || + typeinfo->attrs[i].atttypid == TEXTOID || typeinfo->attrs[i].atttypid == BLOBOID || + typeinfo->attrs[i].atttypid == CLOBOID || typeinfo->attrs[i].atttypid == RAWOID || + typeinfo->attrs[i].atttypid == BPCHAROID || typeinfo->attrs[i].atttypid == VARCHAROID || + typeinfo->attrs[i].atttypid == NVARCHAR2OID) && strlen(outputstr) > WIDTH_THRESHOLD * 2) { /* * in compute_scalar_stats, we just skip detoast value if value size is @@ -1293,14 +1293,14 @@ static void printatt(unsigned attributeId, Form_pg_attribute attributeP, const c void debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo) { int natts = typeinfo->natts; - Form_pg_attribute *attinfo = typeinfo->attrs; + FormData_pg_attribute *attinfo = typeinfo->attrs; int i; /* * show the return type of the tuples */ for (i = 0; i < natts; ++i) - printatt((unsigned)i + 1, attinfo[i], NULL); + printatt((unsigned)i + 1, &attinfo[i], NULL); printf("\t----\n"); } @@ -1324,7 +1324,7 @@ void debugtup(TupleTableSlot *slot, DestReceiver *self) if (isnull) { continue; } - getTypeOutputInfo(typeinfo->attrs[i]->atttypid, &typoutput, &typisvarlena); + getTypeOutputInfo(typeinfo->attrs[i].atttypid, &typoutput, &typisvarlena); /* * If we have a toasted datum, forcibly detoast it here to avoid @@ -1338,7 +1338,7 @@ void debugtup(TupleTableSlot *slot, DestReceiver *self) value = OidOutputFunctionCall(typoutput, attr); - printatt((unsigned)i + 1, typeinfo->attrs[i], value); + printatt((unsigned)i + 1, &typeinfo->attrs[i], value); pfree(value); diff --git a/src/gausskernel/storage/access/common/tupconvert.cpp b/src/gausskernel/storage/access/common/tupconvert.cpp index f451a3fcc..27b54ba82 100644 --- a/src/gausskernel/storage/access/common/tupconvert.cpp +++ b/src/gausskernel/storage/access/common/tupconvert.cpp @@ -81,7 +81,7 @@ TupleConversionMap *convert_tuples_by_position(TupleDesc indesc, TupleDesc outde nincols = noutcols = 0; /* these count non-dropped attributes */ same = true; for (i = 0; i < n; i++) { - Form_pg_attribute att = outdesc->attrs[i]; + Form_pg_attribute att = &outdesc->attrs[i]; Oid atttypid; int32 atttypmod; @@ -91,7 +91,7 @@ TupleConversionMap *convert_tuples_by_position(TupleDesc indesc, TupleDesc outde atttypid = att->atttypid; atttypmod = att->atttypmod; for (; j < indesc->natts; j++) { - att = indesc->attrs[j]; + att = &indesc->attrs[j]; if (att->attisdropped) continue; nincols++; @@ -112,7 +112,7 @@ TupleConversionMap *convert_tuples_by_position(TupleDesc indesc, TupleDesc outde /* Check for unused input columns */ for (; j < indesc->natts; j++) { - if (indesc->attrs[j]->attisdropped) + if (indesc->attrs[j].attisdropped) continue; nincols++; same = false; /* we'll complain below */ @@ -140,9 +140,9 @@ TupleConversionMap *convert_tuples_by_position(TupleDesc indesc, TupleDesc outde * also dropped, we needn't convert. However, attlen and attalign * must agree. */ - if (attrMap[i] == 0 && indesc->attrs[i]->attisdropped && - indesc->attrs[i]->attlen == outdesc->attrs[i]->attlen && - indesc->attrs[i]->attalign == outdesc->attrs[i]->attalign) + if (attrMap[i] == 0 && indesc->attrs[i].attisdropped && + indesc->attrs[i].attlen == outdesc->attrs[i].attlen && + indesc->attrs[i].attalign == outdesc->attrs[i].attalign) continue; same = false; @@ -193,7 +193,7 @@ TupleConversionMap *convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc, n = outdesc->natts; attrMap = (AttrNumber *)palloc0(n * sizeof(AttrNumber)); for (i = 0; i < n; i++) { - Form_pg_attribute att = outdesc->attrs[i]; + Form_pg_attribute att = &outdesc->attrs[i]; char *attname = NULL; Oid atttypid; int32 atttypmod; @@ -205,7 +205,7 @@ TupleConversionMap *convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc, atttypid = att->atttypid; atttypmod = att->atttypmod; for (j = 0; j < indesc->natts; j++) { - att = indesc->attrs[j]; + att = &indesc->attrs[j]; if (att->attisdropped) continue; if (strcmp(attname, NameStr(att->attname)) == 0) { @@ -241,9 +241,9 @@ TupleConversionMap *convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc, * also dropped, we needn't convert. However, attlen and attalign * must agree. */ - if (attrMap[i] == 0 && indesc->attrs[i]->attisdropped && - indesc->attrs[i]->attlen == outdesc->attrs[i]->attlen && - indesc->attrs[i]->attalign == outdesc->attrs[i]->attalign) + if (attrMap[i] == 0 && indesc->attrs[i].attisdropped && + indesc->attrs[i].attlen == outdesc->attrs[i].attlen && + indesc->attrs[i].attalign == outdesc->attrs[i].attalign) continue; same = false; @@ -308,7 +308,7 @@ HeapTuple do_convert_tuple(HeapTuple tuple, TupleConversionMap *map) /* * Now form the new tuple. */ - return (HeapTuple)tableam_tops_form_tuple(map->outdesc, outvalues, outisnull, HEAP_TUPLE); + return (HeapTuple)tableam_tops_form_tuple(map->outdesc, outvalues, outisnull); } /* diff --git a/src/gausskernel/storage/access/common/tupdesc.cpp b/src/gausskernel/storage/access/common/tupdesc.cpp index 158dacfcc..120ca4f36 100644 --- a/src/gausskernel/storage/access/common/tupdesc.cpp +++ b/src/gausskernel/storage/access/common/tupdesc.cpp @@ -42,11 +42,9 @@ * Tuple type ID information is initially set for an anonymous record type; * caller can overwrite this if needed. */ -TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid, TableAmType tam) +TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid, const TableAmRoutine* tam_ops) { TupleDesc desc; - char *stg = NULL; - int attroffset; /* * sanity checks @@ -55,36 +53,10 @@ TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid, TableAmType tam) /* * Allocate enough memory for the tuple descriptor, including the - * attribute rows, and set up the attribute row pointers. - * - * Note: we assume that sizeof(struct tupleDesc) is a multiple of the - * struct pointer alignment requirement, and hence we don't need to insert - * alignment padding between the struct and the array of attribute row - * pointers. - * - * Note: Only the fixed part of pg_attribute rows is included in tuple - * descriptors, so we only need ATTRIBUTE_FIXED_PART_SIZE space per attr. - * That might need alignment padding, however. + * attribute rows. */ - attroffset = sizeof(struct tupleDesc) + natts * sizeof(Form_pg_attribute); - attroffset = MAXALIGN((uint32)attroffset); - stg = (char *)palloc0(attroffset + natts * MAXALIGN(ATTRIBUTE_FIXED_PART_SIZE)); - desc = (TupleDesc)stg; - - if (natts > 0) { - Form_pg_attribute *attrs = NULL; - int i; - - attrs = (Form_pg_attribute *)(stg + sizeof(struct tupleDesc)); - desc->attrs = attrs; - stg += attroffset; - for (i = 0; i < natts; i++) { - attrs[i] = (Form_pg_attribute)stg; - stg += MAXALIGN(ATTRIBUTE_FIXED_PART_SIZE); - } - } else { - desc->attrs = NULL; - } + desc = (TupleDesc) palloc0(offsetof(struct tupleDesc, attrs) + + natts * sizeof(FormData_pg_attribute)); /* * Initialize other fields of the tupdesc. @@ -98,43 +70,28 @@ TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid, TableAmType tam) desc->initdefvals = NULL; /* initialize the attrinitdefvals */ desc->tdhasuids = false; desc->tdisredistable = false; - desc->tdTableAmType = tam; + desc->td_tam_ops = tam_ops; return desc; } /* * CreateTupleDesc - * This function allocates a new TupleDesc pointing to a given + * This function allocates a new TupleDesc by copying a given * Form_pg_attribute array. * - * Note: if the TupleDesc is ever freed, the Form_pg_attribute array - * will not be freed thereby. - * * Tuple type ID information is initially set for an anonymous record type; * caller can overwrite this if needed. */ -TupleDesc CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute* attrs, TableAmType tam) +TupleDesc CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute* attrs, const TableAmRoutine* tam_ops) { TupleDesc desc; + int i; - /* - * sanity checks - */ - AssertArg(natts >= 0); + desc = CreateTemplateTupleDesc(natts, hasoid, tam_ops); - desc = (TupleDesc)palloc(sizeof(struct tupleDesc)); - desc->attrs = attrs; - desc->natts = natts; - desc->constr = NULL; - desc->tdtypeid = RECORDOID; - desc->tdtypmod = -1; - desc->tdhasoid = hasoid; - desc->tdrefcount = -1; /* assume not reference-counted */ - desc->initdefvals = NULL; /* initialize the attrinitdefvals */ - desc->tdisredistable = false; - desc->tdhasuids = false; - desc->tdTableAmType = tam; + for (i = 0; i < natts; ++i) + memcpy(TupleDescAttr(desc, i), attrs[i], ATTRIBUTE_FIXED_PART_SIZE); return desc; } @@ -172,15 +129,15 @@ TupleDesc CreateTupleDescCopy(TupleDesc tupdesc) { TupleDesc desc; int i; - errno_t rc = EOK; - desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid, tupdesc->tdTableAmType); + desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid, tupdesc->td_tam_ops); for (i = 0; i < desc->natts; i++) { - rc = memcpy_s(desc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, tupdesc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE); - securec_check(rc, "\0", "\0"); - desc->attrs[i]->attnotnull = false; - desc->attrs[i]->atthasdef = false; + Form_pg_attribute att = TupleDescAttr(desc, i); + + memcpy(att, &tupdesc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE); + att->attnotnull = false; + att->atthasdef = false; } desc->tdtypeid = tupdesc->tdtypeid; @@ -265,10 +222,10 @@ TupleConstr *TupleConstrCopy(const TupleDesc tupdesc) TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc) { errno_t rc = EOK; - TupleDesc desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid, tupdesc->tdTableAmType); + TupleDesc desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid, tupdesc->td_tam_ops); for (int i = 0; i < desc->natts; i++) { - rc = memcpy_s(desc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, tupdesc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE); + rc = memcpy_s(&desc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE, &tupdesc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE); securec_check(rc, "\0", "\0"); } @@ -534,13 +491,13 @@ bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) return false; } - if (tupdesc1->tdTableAmType != tupdesc2->tdTableAmType) { + if (tupdesc1->td_tam_ops != tupdesc2->td_tam_ops) { return false; } for (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]; /* * We do not need to check every single field here: we can disregard @@ -760,8 +717,8 @@ bool equalDeltaTupleDescs(TupleDesc mainTupdesc, TupleDesc deltaTupdesc) return false; for (i = 0; i < mainTupdesc->natts; i++) { - Form_pg_attribute attr1 = mainTupdesc->attrs[i]; - Form_pg_attribute attr2 = deltaTupdesc->attrs[i]; + Form_pg_attribute attr1 = &mainTupdesc->attrs[i]; + Form_pg_attribute attr2 = &deltaTupdesc->attrs[i]; if (GetGeneratedCol(mainTupdesc, i) != GetGeneratedCol(deltaTupdesc, i)) { return false; @@ -808,7 +765,7 @@ void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char * /* * initialize the attribute fields */ - att = desc->attrs[attributeNumber - 1]; + att = &desc->attrs[attributeNumber - 1]; att->attrelid = 0; /* dummy value */ @@ -869,7 +826,7 @@ void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid AssertArg(attributeNumber >= 1); AssertArg(attributeNumber <= desc->natts); - desc->attrs[attributeNumber - 1]->attcollation = collationid; + desc->attrs[attributeNumber - 1].attcollation = collationid; } /* @@ -1005,7 +962,7 @@ TupleDesc BuildDescForRelation(List *schema, Node *orientedFrom, char relkind) * allocate a new tuple descriptor */ natts = list_length(schema); - desc = CreateTemplateTupleDesc(natts, false, TAM_HEAP); + desc = CreateTemplateTupleDesc(natts, false); foreach (l, schema) { ColumnDef *entry = (ColumnDef *)lfirst(l); @@ -1019,7 +976,7 @@ TupleDesc BuildDescForRelation(List *schema, Node *orientedFrom, char relkind) attnum++; if (u_sess->attr.attr_sql.enable_cluster_resize && entry->dropped_attr != NULL) { - copyDroppedAttribute(desc->attrs[attnum - 1], entry->dropped_attr); + copyDroppedAttribute(&desc->attrs[attnum - 1], entry->dropped_attr); continue; } attname = entry->colname; @@ -1084,18 +1041,18 @@ TupleDesc BuildDescForRelation(List *schema, Node *orientedFrom, char relkind) /* Override TupleDescInitEntry's settings as requested */ TupleDescInitEntryCollation(desc, attnum, attcollation); if (entry->storage) - desc->attrs[attnum - 1]->attstorage = entry->storage; + desc->attrs[attnum - 1].attstorage = entry->storage; /* Fill in additional stuff not handled by TupleDescInitEntry */ - desc->attrs[attnum - 1]->attnotnull = entry->is_not_null; + desc->attrs[attnum - 1].attnotnull = entry->is_not_null; /* * PG source code: has_not_null |= entry->is_not_null; */ has_not_null = has_not_null || entry->is_not_null; - desc->attrs[attnum - 1]->attislocal = entry->is_local; - desc->attrs[attnum - 1]->attinhcount = entry->inhcount; + desc->attrs[attnum - 1].attislocal = entry->is_local; + desc->attrs[attnum - 1].attinhcount = entry->inhcount; - Form_pg_attribute thisatt = desc->attrs[attnum - 1]; + Form_pg_attribute thisatt = &desc->attrs[attnum - 1]; thisatt->attkvtype = entry->kvtype; VerifyAttrCompressMode(entry->cmprs_mode, thisatt->attlen, attname); thisatt->attcmprmode = entry->cmprs_mode; @@ -1150,7 +1107,7 @@ TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *coll /* * allocate a new tuple descriptor */ - desc = CreateTemplateTupleDesc(natts, false, TAM_HEAP); + desc = CreateTemplateTupleDesc(natts, false); attnum = 0; diff --git a/src/gausskernel/storage/access/gin/ginbulk.cpp b/src/gausskernel/storage/access/gin/ginbulk.cpp index 44287391c..5630bfc0c 100644 --- a/src/gausskernel/storage/access/gin/ginbulk.cpp +++ b/src/gausskernel/storage/access/gin/ginbulk.cpp @@ -110,7 +110,7 @@ void ginInitBA(BuildAccumulator *accum) */ static Datum getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value) { - Form_pg_attribute att = accum->ginstate->origTupdesc->attrs[attnum - 1]; + Form_pg_attribute att = &accum->ginstate->origTupdesc->attrs[attnum - 1]; Datum res; if (att->attbyval) diff --git a/src/gausskernel/storage/access/gin/ginget.cpp b/src/gausskernel/storage/access/gin/ginget.cpp index 3c1095eb0..d78776941 100644 --- a/src/gausskernel/storage/access/gin/ginget.cpp +++ b/src/gausskernel/storage/access/gin/ginget.cpp @@ -144,7 +144,7 @@ static bool collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, GinSca /* Locate tupdesc entry for key column (for attbyval/attlen data) */ attnum = scanEntry->attnum; - attr = btree->ginstate->origTupdesc->attrs[attnum - 1]; + attr = &btree->ginstate->origTupdesc->attrs[attnum - 1]; for (;;) { Page page; diff --git a/src/gausskernel/storage/access/gin/gininsert.cpp b/src/gausskernel/storage/access/gin/gininsert.cpp index abf84c30e..e7ad446bd 100644 --- a/src/gausskernel/storage/access/gin/gininsert.cpp +++ b/src/gausskernel/storage/access/gin/gininsert.cpp @@ -478,7 +478,7 @@ Datum cginbuild(PG_FUNCTION_ARGS) list_free(varsOrigin); } heapScanAttrNumbers[i] = keycol; - transferFuncs[i] = GetTransferFuncByTypeOid(heap->rd_att->attrs[heapScanAttrNumbers[i] - 1]->atttypid); + transferFuncs[i] = GetTransferFuncByTypeOid(heap->rd_att->attrs[heapScanAttrNumbers[i] - 1].atttypid); } /* add ctid column for cstore scan */ diff --git a/src/gausskernel/storage/access/gin/ginutil.cpp b/src/gausskernel/storage/access/gin/ginutil.cpp index c4735244c..45fb22595 100644 --- a/src/gausskernel/storage/access/gin/ginutil.cpp +++ b/src/gausskernel/storage/access/gin/ginutil.cpp @@ -50,12 +50,12 @@ void initGinState(GinState *state, Relation index) if (state->oneCol) state->tupdesc[i] = state->origTupdesc; else { - state->tupdesc[i] = CreateTemplateTupleDesc(GIN_UTIL_ATTR_NUM, false, TAM_HEAP); + state->tupdesc[i] = CreateTemplateTupleDesc(GIN_UTIL_ATTR_NUM, false); TupleDescInitEntry(state->tupdesc[i], (AttrNumber)1, NULL, INT2OID, -1, 0); - TupleDescInitEntry(state->tupdesc[i], (AttrNumber)GIN_UTIL_ATTR_NUM, NULL, origTupdesc->attrs[i]->atttypid, - origTupdesc->attrs[i]->atttypmod, origTupdesc->attrs[i]->attndims); - TupleDescInitEntryCollation(state->tupdesc[i], (AttrNumber)2, origTupdesc->attrs[i]->attcollation); + TupleDescInitEntry(state->tupdesc[i], (AttrNumber)GIN_UTIL_ATTR_NUM, NULL, origTupdesc->attrs[i].atttypid, + origTupdesc->attrs[i].atttypmod, origTupdesc->attrs[i].attndims); + TupleDescInitEntryCollation(state->tupdesc[i], (AttrNumber)2, origTupdesc->attrs[i].attcollation); } fmgr_info_copy(&(state->compareFn[i]), index_getprocinfo(index, i + 1, GIN_COMPARE_PROC), CurrentMemoryContext); diff --git a/src/gausskernel/storage/access/gist/gistbuild.cpp b/src/gausskernel/storage/access/gist/gistbuild.cpp index 64febf202..9d5e118c7 100644 --- a/src/gausskernel/storage/access/gist/gistbuild.cpp +++ b/src/gausskernel/storage/access/gist/gistbuild.cpp @@ -275,10 +275,10 @@ static void gistInitBuffering(GISTBuildState *buildstate) */ itupMinSize = (Size)MAXALIGN(sizeof(IndexTupleData)); for (i = 0; i < index->rd_att->natts; i++) { - if (index->rd_att->attrs[i]->attlen < 0) + if (index->rd_att->attrs[i].attlen < 0) itupMinSize += VARHDRSZ; else - itupMinSize += index->rd_att->attrs[i]->attlen; + itupMinSize += index->rd_att->attrs[i].attlen; } /* Calculate average and maximal number of index tuples which fit to page */ diff --git a/src/gausskernel/storage/access/hash/hashfunc.cpp b/src/gausskernel/storage/access/hash/hashfunc.cpp index e04d36111..7d6221d93 100644 --- a/src/gausskernel/storage/access/hash/hashfunc.cpp +++ b/src/gausskernel/storage/access/hash/hashfunc.cpp @@ -1568,7 +1568,7 @@ static Datum getBucketInternal(Datum array, char flag, int bucketcnt, bool *allI for (i = 0; i < tupdesc->natts; i++) { Datum val = heap_getattr(tuple, i + 1, tupdesc, &isnull); - Oid colType = tupdesc->attrs[i]->atttypid; + Oid colType = tupdesc->attrs[i].atttypid; if (!isnull) { hashValue = hashValueCombination(hashValue, colType, val, *allIsNull, flag); *allIsNull = false; diff --git a/src/gausskernel/storage/access/heap/heapam.cpp b/src/gausskernel/storage/access/heap/heapam.cpp index 73a897488..317e27250 100755 --- a/src/gausskernel/storage/access/heap/heapam.cpp +++ b/src/gausskernel/storage/access/heap/heapam.cpp @@ -1374,9 +1374,9 @@ Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool* isnull) *isnull = false; if (HeapTupleNoNulls(tup)) { - if (tupleDesc->attrs[attnum - 1]->attcacheoff >= 0) { - return fetchatt(tupleDesc->attrs[attnum - 1], - (char *)tup->t_data + tup->t_data->t_hoff + tupleDesc->attrs[attnum - 1]->attcacheoff); + if (tupleDesc->attrs[attnum - 1].attcacheoff >= 0) { + return fetchatt(&tupleDesc->attrs[attnum - 1], + (char *)tup->t_data + tup->t_data->t_hoff + tupleDesc->attrs[attnum - 1].attcacheoff); } return nocachegetattr(tup, attnum, tupleDesc); } else { @@ -5947,7 +5947,7 @@ static bool heap_tuple_attr_equals(TupleDesc tupdesc, int attrnum, HeapTuple tup return (DatumGetObjectId(value1) == DatumGetObjectId(value2)); } else { Assert(attrnum <= tupdesc->natts); - att = tupdesc->attrs[attrnum - 1]; + att = &tupdesc->attrs[attrnum - 1]; return datumIsEqual(value1, value2, att->attbyval, att->attlen); } } diff --git a/src/gausskernel/storage/access/heap/tuptoaster.cpp b/src/gausskernel/storage/access/heap/tuptoaster.cpp index 5ad169a0c..770f1411e 100644 --- a/src/gausskernel/storage/access/heap/tuptoaster.cpp +++ b/src/gausskernel/storage/access/heap/tuptoaster.cpp @@ -416,7 +416,7 @@ int64 calculate_huge_length(text *t) void toast_delete(Relation rel, HeapTuple oldtup, int options) { TupleDesc tuple_desc; - Form_pg_attribute *att = NULL; + FormData_pg_attribute *att = NULL; int num_attrs; int i; Datum toast_values[MaxHeapAttributeNumber]; @@ -447,7 +447,7 @@ void toast_delete(Relation rel, HeapTuple oldtup, int options) if (num_attrs > MaxHeapAttributeNumber) ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", num_attrs, - MaxHeapAttributeNumber, tuple_desc->tdTableAmType, tuple_desc->tdtypeid))); + MaxHeapAttributeNumber, GetTableAmType(tuple_desc->td_tam_ops), tuple_desc->tdtypeid))); heap_deform_tuple(oldtup, tuple_desc, toast_values, toast_isnull); @@ -456,7 +456,7 @@ void toast_delete(Relation rel, HeapTuple oldtup, int options) * relation. */ for (i = 0; i < num_attrs; i++) { - if (att[i]->attlen == -1) { + if (att[i].attlen == -1) { Datum value = toast_values[i]; if (toast_isnull[i]) @@ -558,7 +558,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu { HeapTuple result_tuple; TupleDesc tuple_desc; - Form_pg_attribute *att = NULL; + FormData_pg_attribute *att = NULL; int num_attrs; int i; @@ -598,7 +598,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu if (num_attrs > MaxHeapAttributeNumber) { ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", num_attrs, - MaxHeapAttributeNumber, tuple_desc->tdTableAmType, tuple_desc->tdtypeid))); + MaxHeapAttributeNumber, GetTableAmType(tuple_desc->td_tam_ops), tuple_desc->tdtypeid))); } heap_deform_tuple(newtup, tuple_desc, toast_values, toast_isnull); if (oldtup != NULL) { @@ -642,7 +642,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu * If the old value is stored on disk, check if it has changed so * we have to delete it later. */ - if (att[i]->attlen == -1 && !toast_oldisnull[i] && + if (att[i].attlen == -1 && !toast_oldisnull[i] && (VARATT_IS_EXTERNAL_ONDISK_B(old_value) || VARATT_IS_HUGE_TOAST_POINTER(old_value))) { if (toast_isnull[i] || (RelationIsLogicallyLogged(rel) && !VARATT_IS_HUGE_TOAST_POINTER(new_value)) || !(VARATT_IS_EXTERNAL_ONDISK_B(new_value) || VARATT_IS_HUGE_TOAST_POINTER(new_value)) || @@ -683,11 +683,11 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu /* * Now look at varlena attributes */ - if (att[i]->attlen == -1) { + if (att[i].attlen == -1) { /* * If the table's attribute says PLAIN always, force it so. */ - if (att[i]->attstorage == 'p') { + if (att[i].attstorage == 'p') { toast_action[i] = 'p'; } @@ -700,7 +700,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu */ if (VARATT_IS_EXTERNAL(new_value) && !VARATT_IS_HUGE_TOAST_POINTER(new_value)) { toast_oldexternal[i] = new_value; - if (att[i]->attstorage == 'p') { + if (att[i].attstorage == 'p') { new_value = heap_tuple_untoast_attr(new_value); } else { new_value = heap_tuple_fetch_attr(new_value); @@ -776,7 +776,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu if (VARATT_IS_COMPRESSED(DatumGetPointer(toast_values[i]))) { continue; } - if (att[i]->attstorage != 'x' && att[i]->attstorage != 'e') { + if (att[i].attstorage != 'x' && att[i].attstorage != 'e') { continue; } if (toast_sizes[i] > biggest_size) { @@ -793,7 +793,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu * Attempt to compress it inline, if it has attstorage 'x' */ i = biggest_attno; - if (att[i]->attstorage == 'x') { + if (att[i].attstorage == 'x') { old_value = toast_values[i]; new_value = toast_compress_datum(old_value); if (DatumGetPointer(new_value) != NULL) { @@ -859,7 +859,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu continue; /* can't happen, toast_action would be 'p' */ } - if (att[i]->attstorage != 'x' && att[i]->attstorage != 'e') { + if (att[i].attstorage != 'x' && att[i].attstorage != 'e') { continue; } if (toast_sizes[i] > biggest_size) { @@ -911,7 +911,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu if (VARATT_IS_COMPRESSED(DatumGetPointer(toast_values[i]))) { continue; } - if (att[i]->attstorage != 'm') { + if (att[i].attstorage != 'm') { continue; } if (toast_sizes[i] > biggest_size) { @@ -971,7 +971,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu if (VARATT_IS_EXTERNAL(DatumGetPointer(toast_values[i]))) { continue; /* can't happen, toast_action would be 'p' */ } - if (att[i]->attstorage != 'm') { + if (att[i].attstorage != 'm') { continue; } if (toast_sizes[i] > biggest_size) { @@ -1101,7 +1101,7 @@ HeapTuple toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtu HeapTuple toast_flatten_tuple(HeapTuple tup, TupleDesc tuple_desc) { HeapTuple new_tuple; - Form_pg_attribute *att = tuple_desc->attrs; + FormData_pg_attribute *att = tuple_desc->attrs; int num_attrs = tuple_desc->natts; int i; Datum toast_values[MaxTupleAttributeNumber]; @@ -1121,7 +1121,7 @@ HeapTuple toast_flatten_tuple(HeapTuple tup, TupleDesc tuple_desc) /* * Look at non-null varlena attributes */ - if (!toast_isnull[i] && att[i]->attlen == -1) { + if (!toast_isnull[i] && att[i].attlen == -1) { struct varlena *new_value; new_value = (struct varlena *)DatumGetPointer(toast_values[i]); @@ -1190,7 +1190,7 @@ Datum toast_flatten_tuple_attribute(Datum value, Oid typeId, int32 typeMod) int32 new_data_len; int32 new_tuple_len; HeapTupleData tmptup; - Form_pg_attribute *att = NULL; + FormData_pg_attribute *att = NULL; int num_attrs; int i; bool need_change = false; @@ -1231,7 +1231,7 @@ Datum toast_flatten_tuple_attribute(Datum value, Oid typeId, int32 typeMod) ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", tuple_desc->natts, - MaxTupleAttributeNumber, tuple_desc->tdTableAmType, tuple_desc->tdtypeid))); + MaxTupleAttributeNumber, GetTableAmType(tuple_desc->td_tam_ops), tuple_desc->tdtypeid))); heap_deform_tuple(&tmptup, tuple_desc, toast_values, toast_isnull); @@ -1243,7 +1243,7 @@ Datum toast_flatten_tuple_attribute(Datum value, Oid typeId, int32 typeMod) */ if (toast_isnull[i]) has_nulls = true; - else if (att[i]->attlen == -1) { + else if (att[i].attlen == -1) { struct varlena *new_value; new_value = (struct varlena *)DatumGetPointer(toast_values[i]); diff --git a/src/gausskernel/storage/access/spgist/spgutils.cpp b/src/gausskernel/storage/access/spgist/spgutils.cpp index 8dc79807a..5ff8fc646 100644 --- a/src/gausskernel/storage/access/spgist/spgutils.cpp +++ b/src/gausskernel/storage/access/spgist/spgutils.cpp @@ -59,7 +59,7 @@ SpGistCache *spgGetCache(Relation index) * tupdesc. We pass this to the opclass config function so that * polymorphic opclasses are possible. */ - atttype = index->rd_att->attrs[0]->atttypid; + atttype = index->rd_att->attrs[0].atttypid; /* Call the config function to get config info for the opclass */ in.attType = atttype; diff --git a/src/gausskernel/storage/access/table/tableam.cpp b/src/gausskernel/storage/access/table/tableam.cpp index 952d46c56..78c917bf5 100644 --- a/src/gausskernel/storage/access/table/tableam.cpp +++ b/src/gausskernel/storage/access/table/tableam.cpp @@ -51,121 +51,6 @@ #include "access/ustore/knl_utuple.h" #include "access/ustore/knl_uvisibility.h" -/* ------------------------------------------------------------------------ - * HEAP TABLE SLOT AM APIs - * ------------------------------------------------------------------------ - */ - -Tuple tableam_tslot_get_tuple_from_slot(Relation relation, TupleTableSlot *slot) -{ - slot->tts_tupleDescriptor->tdhasuids = RELATION_HAS_UIDS(relation); - return g_tableam_routines[relation->rd_tam_type]->tslot_get_tuple_from_slot(slot); -} - -/* ------------------------------------------------------------------------ - * TABLE TUPLE AM APIs - * ------------------------------------------------------------------------ - */ - -Datum tableam_tops_getsysattr(Tuple tup, int attnum, TupleDesc tuple_desc, bool *isnull, - Buffer buf) -{ - AssertValidTuple(tup); - return g_tableam_routines[GetTabelAmIndexTuple(tup)]->tops_getsysattr(tup, attnum, tuple_desc, isnull, buf); -} - -MinimalTuple tableam_tops_form_minimal_tuple(TupleDesc tuple_descriptor, Datum *values, - const bool *isnull, MinimalTuple in_tuple, uint32 tupTableType) -{ - AssertValidTupleType(tupTableType); - return g_tableam_routines[GetTableAMIndex(tupTableType)]->tops_form_minimal_tuple(tuple_descriptor, values, isnull, - in_tuple); -} - -Tuple tableam_tops_form_tuple(TupleDesc tuple_descriptor, Datum *values, bool *isnull, - uint32 tupTableType) -{ - AssertValidTupleType(tupTableType); - return g_tableam_routines[GetTableAMIndex(tupTableType)]->tops_form_tuple(tuple_descriptor, values, isnull); -} - -Tuple tableam_tops_form_cmprs_tuple(TupleDesc tuple_descriptor, FormCmprTupleData *cmprs_info, - uint32 tupTableType) -{ - AssertValidTupleType(tupTableType); - return g_tableam_routines[GetTableAMIndex(tupTableType)]->tops_form_cmprs_tuple(tuple_descriptor, cmprs_info); -} - - -void tableam_tops_deform_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_tuple(tuple, tuple_desc, values, isnull); -} - -void tableam_tops_deform_tuple2(Tuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_tuple2(tuple, tupleDesc, values, isnull, buffer); -} - -void tableam_tops_deform_cmprs_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull, - char *cmprs_info) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_cmprs_tuple(tuple, tuple_desc, values, isnull, - cmprs_info); -} - -void tableam_tops_fill_tuple(TupleDesc tuple_desc, Datum *values, const bool *isnull, char *data, - Size data_size, uint16 *infomask, bits8 *bit) -{ - return g_tableam_routines[tuple_desc->tdTableAmType]->tops_fill_tuple(tuple_desc, values, isnull, data, data_size, - infomask, bit); -} - -/* - * there is no uheapam_tops_modify_tuple - * but this is done for completeness - */ -Tuple tableam_tops_modify_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *repl_values, - const bool *repl_isnull, const bool *do_replace) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_modify_tuple(tuple, tuple_desc, repl_values, - repl_isnull, do_replace); -} - -Tuple tableam_tops_opfusion_modify_tuple(Tuple tuple, TupleDesc tuple_desc, - Datum* repl_values, bool* repl_isnull, UpdateFusion* opf) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_opfusion_modify_tuple(tuple, tuple_desc, - repl_values, repl_isnull, opf); -} - - - -Datum tableam_tops_tuple_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_getattr(tuple, att_num, - tuple_desc, is_null); -} - -Datum tableam_tops_tuple_fast_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_fast_getattr(tuple, att_num, - tuple_desc, is_null); -} - -bool tableam_tops_tuple_attisnull(Tuple tuple, int attnum, TupleDesc tuple_desc) -{ - AssertValidTuple(tuple); - return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_attisnull(tuple, attnum, tuple_desc); -} - bool tableam_tops_page_get_item(Relation rel, Tuple tuple, Page page, OffsetNumber tupleNo, BlockNumber destBlocks) { @@ -726,7 +611,7 @@ Tuple HeapamTopsOpFusionModifyTuple(Tuple tuple, TupleDesc tuple_desc, Datum* re /* * create a new tuple from the values and isnull arrays */ - newTuple = tableam_tops_form_tuple(tuple_desc, repl_values, repl_isnull, HEAP_TUPLE); + newTuple = tableam_tops_form_tuple(tuple_desc, repl_values, repl_isnull, TableAmHeap); /* * copy the identification info of the old tuple: t_ctid, t_self, and OID * (if any) @@ -1161,7 +1046,7 @@ Tuple uheapam_tslot_get_tuple_from_slot(TupleTableSlot* slot) if (!TTS_TABLEAM_IS_USTORE(slot)) { tableam_tslot_getallattrs(slot); // here has some main difference. utuple = (UHeapTuple)tableam_tops_form_tuple(slot->tts_tupleDescriptor, slot->tts_values, slot->tts_isnull, - UHEAP_TUPLE); + TableAmUstore); slot->tts_tam_ops = TableAmUstore; utuple->tupInfo = 1; ExecStoreTuple((Tuple)utuple, slot, InvalidBuffer, true); @@ -1245,7 +1130,7 @@ Tuple UHeapamTopsOpFusionModifyTuple(Tuple tuple, TupleDesc tuple_desc, Datum* r /* * create a new tuple from the values and isnull arrays */ - newTuple = tableam_tops_form_tuple(tuple_desc, repl_values, repl_isnull, UHEAP_TUPLE); + newTuple = tableam_tops_form_tuple(tuple_desc, repl_values, repl_isnull, TableAmUstore); /* * copy the identification info of the old tuple: t_ctid, t_self, and OID * (if any) diff --git a/src/gausskernel/storage/access/transam/cbmfuncs.cpp b/src/gausskernel/storage/access/transam/cbmfuncs.cpp index d5316afa6..5481096ed 100644 --- a/src/gausskernel/storage/access/transam/cbmfuncs.cpp +++ b/src/gausskernel/storage/access/transam/cbmfuncs.cpp @@ -142,7 +142,7 @@ Datum pg_cbm_get_changed_block(PG_FUNCTION_ARGS) oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - tupdesc = CreateTemplateTupleDesc(13, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(13, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "merged_start_lsn", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "merged_end_lsn", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "tablespace_oid", OIDOID, -1, 0); diff --git a/src/gausskernel/storage/access/transam/twophase.cpp b/src/gausskernel/storage/access/transam/twophase.cpp index 104002d76..de1e6abfd 100644 --- a/src/gausskernel/storage/access/transam/twophase.cpp +++ b/src/gausskernel/storage/access/transam/twophase.cpp @@ -1284,9 +1284,9 @@ static void build_prepared_xact_tuple_desc(FuncCallContext *funcctx, bool with_n TupleDesc tupdesc; if (!with_node_name) { - tupdesc = CreateTemplateTupleDesc(5, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(5, false); } else { - tupdesc = CreateTemplateTupleDesc(6, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(6, false); } TupleDescInitEntry(tupdesc, (AttrNumber)1, "transaction", XIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "gid", TEXTOID, -1, 0); @@ -1589,7 +1589,7 @@ Datum pg_parse_clog(PG_FUNCTION_ARGS) /* build tupdesc for result tuples */ /* this had better match pg_prepared_xacts view in system_views.sql */ - tupdesc = CreateTemplateTupleDesc(2, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "xid", XIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "status", TEXTOID, -1, 0); diff --git a/src/gausskernel/storage/access/transam/varsup.cpp b/src/gausskernel/storage/access/transam/varsup.cpp index 059f25f56..43b6ec037 100644 --- a/src/gausskernel/storage/access/transam/varsup.cpp +++ b/src/gausskernel/storage/access/transam/varsup.cpp @@ -461,7 +461,7 @@ Datum pg_get_xidlimit(PG_FUNCTION_ARGS) oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* build tupdesc for result tuples */ - tupdesc = CreateTemplateTupleDesc(7, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(7, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "nextXid", XIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "oldestXid", XIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "xidVacLimit", XIDOID, -1, 0); @@ -530,7 +530,7 @@ Datum pg_get_variable_info(PG_FUNCTION_ARGS) oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* Build tupdesc for result tuples */ - tupdesc = CreateTemplateTupleDesc(VARIABLE_INFO_ATTRS, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(VARIABLE_INFO_ATTRS, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "nodeName", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "nextOid", OIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "nextXid", XIDOID, -1, 0); @@ -593,7 +593,7 @@ const unsigned NODE_XID_CSN_VIEW_COL_NUM = 3; TupleDesc get_xid_csn_view_frist_row() { TupleDesc tupdesc = NULL; - tupdesc = CreateTemplateTupleDesc(NODE_XID_CSN_VIEW_COL_NUM, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(NODE_XID_CSN_VIEW_COL_NUM, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "node_name", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "next_xid", XIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "next_csn", XIDOID, -1, 0); diff --git a/src/gausskernel/storage/access/transam/xlogfuncs.cpp b/src/gausskernel/storage/access/transam/xlogfuncs.cpp index aaebeba8f..9d21337ef 100755 --- a/src/gausskernel/storage/access/transam/xlogfuncs.cpp +++ b/src/gausskernel/storage/access/transam/xlogfuncs.cpp @@ -684,7 +684,7 @@ Datum pg_xlogfile_name_offset(PG_FUNCTION_ARGS) * Construct a tuple descriptor for the result row. This must match this * function's pg_proc entry! */ - resultTupleDesc = CreateTemplateTupleDesc(2, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "file_name", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "file_offset", INT4OID, -1, 0); @@ -971,7 +971,7 @@ Datum pg_disable_delay_ddl_recycle(PG_FUNCTION_ARGS) /* * Construct a tuple descriptor for the result row. */ - resultTupleDesc = CreateTemplateTupleDesc(2, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "ddl_delay_start_lsn", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "ddl_delay_end_lsn", TEXTOID, -1, 0); @@ -1037,7 +1037,7 @@ Datum gs_roach_disable_delay_ddl_recycle(PG_FUNCTION_ARGS) securec_check_ss(rc, "\0", "\0"); /* Construct a tuple descriptor for the result row. */ - resultTupleDesc = CreateTemplateTupleDesc(2, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "ddl_delay_start_lsn", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "ddl_delay_end_lsn", TEXTOID, -1, 0); @@ -1106,7 +1106,7 @@ Datum pg_resume_bkp_flag(PG_FUNCTION_ARGS) /* * Construct a tuple descriptor for the result row. */ - resultTupleDesc = CreateTemplateTupleDesc(4, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(4, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "start_backup_flag", BOOLOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "to_delay", BOOLOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)3, "ddl_delay_recycle_ptr", TEXTOID, -1, 0); @@ -1360,7 +1360,7 @@ Datum gs_get_global_barrier_status(PG_FUNCTION_ARGS) /* * Construct a tuple descriptor for the result row. */ - resultTupleDesc = CreateTemplateTupleDesc(PG_GET_GLOBAL_BARRIER_STATUS_COLS, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(PG_GET_GLOBAL_BARRIER_STATUS_COLS, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "global_barrier_id", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "global_achive_barrier_id", TEXTOID, -1, 0); resultTupleDesc = BlessTupleDesc(resultTupleDesc); @@ -1558,7 +1558,7 @@ Datum gs_get_local_barrier_status(PG_FUNCTION_ARGS) /* * Construct a tuple descriptor for the result row. */ - resultTupleDesc = CreateTemplateTupleDesc(PG_GET_LOCAL_BARRIER_STATUS_COLS, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(PG_GET_LOCAL_BARRIER_STATUS_COLS, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "barrier_id", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "barrier_lsn", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)3, "archive_lsn", TEXTOID, -1, 0); @@ -2470,7 +2470,7 @@ Datum gs_get_standby_cluster_barrier_status(PG_FUNCTION_ARGS) /* * Construct a tuple descriptor for the result row. */ - resultTupleDesc = CreateTemplateTupleDesc(PG_GET_STANDBY_BARRIER_STATUS_COLS, false, TAM_HEAP); + resultTupleDesc = CreateTemplateTupleDesc(PG_GET_STANDBY_BARRIER_STATUS_COLS, false); TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "latest_id", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "barrier_lsn", TEXTOID, -1, 0); TupleDescInitEntry(resultTupleDesc, (AttrNumber)3, "recovery_id", TEXTOID, -1, 0); diff --git a/src/gausskernel/storage/access/ustore/knl_pruneuheap.cpp b/src/gausskernel/storage/access/ustore/knl_pruneuheap.cpp index 7bf1a7060..a8f3c5686 100644 --- a/src/gausskernel/storage/access/ustore/knl_pruneuheap.cpp +++ b/src/gausskernel/storage/access/ustore/knl_pruneuheap.cpp @@ -61,7 +61,7 @@ int CalTupSize(Relation relation, UHeapDiskTuple diskTuple, TupleDesc scanTupDes { TupleDesc rowDesc = (scanTupDesc == NULL) ? RelationGetDescr(relation) : scanTupDesc; bool hasnulls = UHeapDiskTupHasNulls(diskTuple); - Form_pg_attribute *att = rowDesc->attrs; + FormData_pg_attribute *att = rowDesc->attrs; int natts; /* number of atts to extract */ int attnum; bits8 *bp = diskTuple->data; @@ -75,7 +75,7 @@ int CalTupSize(Relation relation, UHeapDiskTuple diskTuple, TupleDesc scanTupDes natts = Min(tupleAttrs, rowDesc->natts); for (attnum = 0; attnum < natts; attnum++) { - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (hasnulls && att_isnull(attnum, bp)) { /* Skip attribute length in case the tuple was stored with diff --git a/src/gausskernel/storage/access/ustore/knl_uheap.cpp b/src/gausskernel/storage/access/ustore/knl_uheap.cpp index 2b9c31999..f2db7db31 100644 --- a/src/gausskernel/storage/access/ustore/knl_uheap.cpp +++ b/src/gausskernel/storage/access/ustore/knl_uheap.cpp @@ -402,13 +402,13 @@ Datum UHeapFastGetAttr(UHeapTuple tup, int attnum, TupleDesc tupleDesc, bool *is * See comments in att_align_pointer() */ char *tp = (char *)(tup)->disk_tuple + (tup)->disk_tuple->t_hoff; - char *dp = ((tupleDesc)->attrs[0]->attlen >= 0) ? + char *dp = ((tupleDesc)->attrs[0].attlen >= 0) ? tp : - (char *)att_align_pointer(tp, (tupleDesc)->attrs[(attnum)-1]->attalign, -1, tp); + (char *)att_align_pointer(tp, (tupleDesc)->attrs[(attnum)-1].attalign, -1, tp); return ((attnum) > 0 ? ((*(isnull) = false), UHeapDiskTupNoNulls(tup->disk_tuple) ? - ((tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? - (fetchatt((tupleDesc)->attrs[(attnum)-1], (dp + (tupleDesc)->attrs[(attnum)-1]->attcacheoff)) + ( TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? + (fetchatt( TupleDescAttr((tupleDesc), (attnum)-1), (dp + TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff)) ) : (UHeapNoCacheGetAttr((tup), (attnum), (tupleDesc)))) : (att_isnull((attnum)-1, (tup)->disk_tuple->data) ? ((*(isnull) = true), (Datum)NULL) : @@ -1826,7 +1826,7 @@ bool TableFetchAndStore(Relation scanRelation, Snapshot snapshot, Tuple tuple, B */ static UHeapTuple UHeapToastFlattenTuple(UHeapTuple tup, TupleDesc tupDesc) { - Form_pg_attribute *att = tupDesc->attrs; + FormData_pg_attribute *att = tupDesc->attrs; int numAttrs = tupDesc->natts; Datum toastValues[MaxTupleAttributeNumber]; bool toastIsnull[MaxTupleAttributeNumber]; @@ -1845,7 +1845,7 @@ static UHeapTuple UHeapToastFlattenTuple(UHeapTuple tup, TupleDesc tupDesc) /* * Look at non-null varlena attributes */ - if (!toastIsnull[i] && att[i]->attlen == -1) { + if (!toastIsnull[i] && att[i].attlen == -1) { struct varlena *newValue = (struct varlena *)DatumGetPointer(toastValues[i]); checkHugeToastPointer(newValue); if (VARATT_IS_EXTERNAL(newValue)) { diff --git a/src/gausskernel/storage/access/ustore/knl_utuple.cpp b/src/gausskernel/storage/access/ustore/knl_utuple.cpp index 73395ea2c..cb1db90eb 100644 --- a/src/gausskernel/storage/access/ustore/knl_utuple.cpp +++ b/src/gausskernel/storage/access/ustore/knl_utuple.cpp @@ -60,7 +60,7 @@ void CheckTupleValidity(Relation rel, UHeapTuple utuple) uint32 UHeapCalcTupleDataSize(TupleDesc tuple_desc, Datum *values, const bool *is_nulls, uint32 hoff, bool enableReverseBitmap, bool enableReserve) { - Form_pg_attribute *attrs = tuple_desc->attrs; + FormData_pg_attribute *attrs = tuple_desc->attrs; int attrNum = tuple_desc->natts; int size = hoff; @@ -69,7 +69,7 @@ uint32 UHeapCalcTupleDataSize(TupleDesc tuple_desc, Datum *values, const bool *i Assert(enableReverseBitmap || (enableReverseBitmap == false && enableReserve == false)); for (int i = 0; i < attrNum; ++i) { - Form_pg_attribute attr = attrs[i]; + Form_pg_attribute attr = &attrs[i]; Datum val = values[i]; if (is_nulls[i] && (!enableReserve || !attr->attbyval || ATT_IS_DROPPED(attr))) { @@ -125,7 +125,7 @@ void UHeapFillDiskTuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, Assert(!enableReserve || enableReverseBitmap); Assert(enableReverseBitmap || (enableReverseBitmap == false && enableReserve == false)); - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; char *data = (char *)diskTuple->data; if (hasnull) { @@ -170,11 +170,11 @@ void UHeapFillDiskTuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, } if (isnull[i]) { - if (!enableReserve || !att[i]->attbyval || ATT_IS_DROPPED(att[i])) { + if (!enableReserve || !att[i].attbyval || ATT_IS_DROPPED(&att[i])) { ; } else { - Assert(att[i]->attlen > 0); - data += att[i]->attlen; + Assert(att[i].attlen > 0); + data += att[i].attlen; *bitPReserve |= bitmaskReserve; } @@ -191,13 +191,13 @@ void UHeapFillDiskTuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, *bitP |= bitmask; } - if (att[i]->attbyval) { + if (att[i].attbyval) { /* pass-by-value * Not aligned */ - store_att_byval(data, values[i], att[i]->attlen); - attrLength = att[i]->attlen; - } else if (att[i]->attlen == LEN_VARLENA) { + store_att_byval(data, values[i], att[i].attlen); + attrLength = att[i].attlen; + } else if (att[i].attlen == LEN_VARLENA) { /* varlena */ Pointer val = DatumGetPointer(values[i]); @@ -213,29 +213,29 @@ void UHeapFillDiskTuple(TupleDesc tupleDesc, Datum *values, const bool *isnull, Assert(attrLength <= MaxPossibleUHeapTupleSize); rc = memcpy_s(data, remainingLen, val, attrLength); securec_check(rc, "\0", "\0"); - } else if (att[i]->attstorage != 'p' && VARATT_CAN_MAKE_SHORT(val)) { + } else if (att[i].attstorage != 'p' && VARATT_CAN_MAKE_SHORT(val)) { attrLength = VARATT_CONVERTED_SHORT_SIZE(val); SET_VARSIZE_SHORT(data, attrLength); Assert(attrLength <= MaxPossibleUHeapTupleSize); rc = memcpy_s(data + 1, remainingLen, VARDATA(val), attrLength - 1); securec_check(rc, "\0", "\0"); } else { - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); attrLength = VARSIZE(val); rc = memcpy_s(data, remainingLen, val, attrLength); securec_check(rc, "\0", "\0"); } - } else if (att[i]->attlen == LEN_CSTRING) { + } else if (att[i].attlen == LEN_CSTRING) { diskTuple->flag |= HEAP_HASVARWIDTH; - Assert(att[i]->attalign == 'c'); + Assert(att[i].attalign == 'c'); attrLength = strlen(DatumGetCString(values[i])) + 1; Assert(attrLength <= MaxPossibleUHeapTupleSize); rc = memcpy_s(data, remainingLen, DatumGetPointer(values[i]), attrLength); securec_check(rc, "\0", "\0"); } else { - data = (char *)att_align_nominal(data, att[i]->attalign); - Assert(att[i]->attlen > 0); - attrLength = att[i]->attlen; + data = (char *)att_align_nominal(data, att[i].attalign); + Assert(att[i].attlen > 0); + attrLength = att[i].attlen; rc = memcpy_s(data, remainingLen, DatumGetPointer(values[i]), attrLength); securec_check(rc, "\0", "\0"); } @@ -307,7 +307,7 @@ void UHeapCopyDiskTupleNoNull(TupleDesc tupleDesc, const bool *destNull, UHeapTu uint32 bitmask = HIGHBIT; bits8 *bitPReserve = NULL; uint32 bitmaskReserve = 0; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; int tupleAttrs = UHeapTupleHeaderGetNatts(srcDtup); bitPReserve = (bits8*)((char *)destDtup->data + (tupleAttrs / ISNULL_ATTRS_PER_BYTE)); @@ -329,13 +329,13 @@ void UHeapCopyDiskTupleNoNull(TupleDesc tupleDesc, const bool *destNull, UHeapTu *bitP |= bitmask; } - if (att[i]->attbyval) { + if (att[i].attbyval) { /* attribute passed by value */ if (destNull[i]) { - srcOff += att[i]->attlen; + srcOff += att[i].attlen; if (enableReserve) { - Assert(att[i]->attlen > 0); - data += att[i]->attlen; + Assert(att[i].attlen > 0); + data += att[i].attlen; *bitPReserve |= bitmaskReserve; } @@ -348,16 +348,16 @@ void UHeapCopyDiskTupleNoNull(TupleDesc tupleDesc, const bool *destNull, UHeapTu continue; } - attrLength = att[i]->attlen; - store_att_byval(data, *((Datum *)((char *)srcTupPtr + srcOff)), att[i]->attlen); - } else if (att[i]->attlen == LEN_VARLENA) { + attrLength = att[i].attlen; + store_att_byval(data, *((Datum *)((char *)srcTupPtr + srcOff)), att[i].attlen); + } else if (att[i].attlen == LEN_VARLENA) { /* varlena */ - srcOff = att_align_pointer(srcOff, att[i]->attalign, -1, srcTupPtr + srcOff); + srcOff = att_align_pointer(srcOff, att[i].attalign, -1, srcTupPtr + srcOff); attrLength = VARSIZE_ANY(srcTupPtr + srcOff); if (!destNull[i]) { Pointer val = (Pointer) (srcTupPtr + srcOff); - data = UHeapCopyDtupleVarlena(val, data, attrLength, remainingLen, att[i]); + data = UHeapCopyDtupleVarlena(val, data, attrLength, remainingLen, &att[i]); } else { if (bitmaskReserve != HIGHBIT) { bitmaskReserve <<= 1; @@ -366,14 +366,14 @@ void UHeapCopyDiskTupleNoNull(TupleDesc tupleDesc, const bool *destNull, UHeapTu bitmaskReserve = 1; } } - } else if (att[i]->attlen == LEN_CSTRING) { + } else if (att[i].attlen == LEN_CSTRING) { /* null terminated cstring */ - srcOff = att_align_nominal(srcOff, att[i]->attalign); - Assert(att[i]->attalign == 'c'); + srcOff = att_align_nominal(srcOff, att[i].attalign); + Assert(att[i].attalign == 'c'); attrLength = (uint32)strlen(srcTupPtr + srcOff) + 1; Assert(attrLength <= MaxPossibleUHeapTupleSize); if (!destNull[i]) { - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); rc = memcpy_s(data, remainingLen, (srcTupPtr + srcOff), attrLength); securec_check(rc, "\0", "\0"); } else { @@ -386,12 +386,12 @@ void UHeapCopyDiskTupleNoNull(TupleDesc tupleDesc, const bool *destNull, UHeapTu } } else { /* fixed length */ - srcOff = att_align_nominal(srcOff, att[i]->attalign); - Assert(att[i]->attlen > 0); - attrLength = att[i]->attlen; + srcOff = att_align_nominal(srcOff, att[i].attalign); + Assert(att[i].attlen > 0); + attrLength = att[i].attlen; if (!destNull[i]) { - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); rc = memcpy_s(data, remainingLen, (srcTupPtr + srcOff), attrLength); securec_check(rc, "\0", "\0"); } else { @@ -437,7 +437,7 @@ void UHeapCopyDiskTupleWithNulls(TupleDesc tupleDesc, const bool *destNull, UHea uint32 bitmask = HIGHBIT; bits8 *bitPReserve = NULL; uint32 bitmaskReserve = 0; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; int srcnullcount = 0; @@ -460,9 +460,9 @@ void UHeapCopyDiskTupleWithNulls(TupleDesc tupleDesc, const bool *destNull, UHea if (att_isnull(i, srcBp)) { if (enableReverseBitmap) { if (!att_isnull(tupleAttrs + srcnullcount, srcBp)) { - Assert(att[i]->attlen > 0); - data += att[i]->attlen; - srcOff += att[i]->attlen; + Assert(att[i].attlen > 0); + data += att[i].attlen; + srcOff += att[i].attlen; *bitPReserve |= bitmaskReserve; } } @@ -481,13 +481,13 @@ void UHeapCopyDiskTupleWithNulls(TupleDesc tupleDesc, const bool *destNull, UHea if (!destNull[i]) *bitP |= bitmask; - if (att[i]->attbyval) { + if (att[i].attbyval) { /* attribute is passed by value */ if (destNull[i]) { - srcOff += att[i]->attlen; + srcOff += att[i].attlen; if (enableReserve) { - Assert(att[i]->attlen > 0); - data += att[i]->attlen; + Assert(att[i].attlen > 0); + data += att[i].attlen; *bitPReserve |= bitmaskReserve; } @@ -500,16 +500,16 @@ void UHeapCopyDiskTupleWithNulls(TupleDesc tupleDesc, const bool *destNull, UHea continue; } - attrLength = att[i]->attlen; - store_att_byval(data, *((Datum *)((char *)srcTupPtr + srcOff)), att[i]->attlen); - } else if (att[i]->attlen == LEN_VARLENA) { + attrLength = att[i].attlen; + store_att_byval(data, *((Datum *)((char *)srcTupPtr + srcOff)), att[i].attlen); + } else if (att[i].attlen == LEN_VARLENA) { /* varlena */ - srcOff = att_align_pointer(srcOff, att[i]->attalign, -1, srcTupPtr + srcOff); + srcOff = att_align_pointer(srcOff, att[i].attalign, -1, srcTupPtr + srcOff); attrLength = VARSIZE_ANY(srcTupPtr + srcOff); if (!destNull[i]) { Pointer val = (Pointer) (srcTupPtr + srcOff); - data = UHeapCopyDtupleVarlena(val, data, attrLength, remainingLen, att[i]); + data = UHeapCopyDtupleVarlena(val, data, attrLength, remainingLen, &att[i]); } else { if (bitmaskReserve != HIGHBIT) { bitmaskReserve <<= 1; @@ -518,14 +518,14 @@ void UHeapCopyDiskTupleWithNulls(TupleDesc tupleDesc, const bool *destNull, UHea bitmaskReserve = 1; } } - } else if (att[i]->attlen == LEN_CSTRING) { + } else if (att[i].attlen == LEN_CSTRING) { /* null terminated cstring */ - srcOff = att_align_nominal(srcOff, att[i]->attalign); - Assert(att[i]->attalign == 'c'); + srcOff = att_align_nominal(srcOff, att[i].attalign); + Assert(att[i].attalign == 'c'); attrLength = (uint32)strlen(srcTupPtr + srcOff) + 1; Assert(attrLength <= MaxPossibleUHeapTupleSize); if (!destNull[i]) { - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); rc = memcpy_s(data, remainingLen, (srcTupPtr + srcOff), attrLength); securec_check(rc, "\0", "\0"); } else { @@ -538,11 +538,11 @@ void UHeapCopyDiskTupleWithNulls(TupleDesc tupleDesc, const bool *destNull, UHea } } else { /* fixed length */ - srcOff = att_align_nominal(srcOff, att[i]->attalign); - Assert(att[i]->attlen > 0); - attrLength = att[i]->attlen; + srcOff = att_align_nominal(srcOff, att[i].attalign); + Assert(att[i].attlen > 0); + attrLength = att[i].attlen; if (!destNull[i]) { - data = (char *)att_align_nominal(data, att[i]->attalign); + data = (char *)att_align_nominal(data, att[i].attalign); rc = memcpy_s(data, remainingLen, (srcTupPtr + srcOff), attrLength); securec_check(rc, "\0", "\0"); } else { @@ -571,7 +571,7 @@ UHeapTuple UHeapFormTuple(TupleDesc tuple_desc, Datum *values, bool *is_nulls) bool enableReverseBitmap = NAttrsReserveSpace(attrNum); bool enableReserve = u_sess->attr.attr_storage.reserve_space_for_nullable_atts; UHeapDiskTupleData *diskTuple = NULL; - Form_pg_attribute *att = tuple_desc->attrs; + FormData_pg_attribute *att = tuple_desc->attrs; int nullcount = 0; enableReserve = enableReserve && enableReverseBitmap; @@ -579,7 +579,7 @@ UHeapTuple UHeapFormTuple(TupleDesc tuple_desc, Datum *values, bool *is_nulls) if (attrNum > MaxTupleAttributeNumber) { ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("number of columns (%d) exceeds limit (%d), AM type (%d), type id (%u)", attrNum, - MaxTupleAttributeNumber, tuple_desc->tdTableAmType, tuple_desc->tdtypeid))); + MaxTupleAttributeNumber, GetTableAmType(tuple_desc->td_tam_ops), tuple_desc->tdtypeid))); } WHITEBOX_TEST_STUB(UHEAP_FORM_TUPLE_FAILED, WhiteboxDefaultErrorEmit); @@ -588,12 +588,12 @@ UHeapTuple UHeapFormTuple(TupleDesc tuple_desc, Datum *values, bool *is_nulls) for (i = 0; i < attrNum; i++) { if (is_nulls[i]) { nullcount++; - } else if (att[i]->attlen == -1 && att[i]->attalign == 'd' && att[i]->attndims == 0 && + } else if (att[i].attlen == -1 && att[i].attalign == 'd' && att[i].attndims == 0 && !VARATT_IS_EXTENDED(DatumGetPointer(values[i]))) { - values[i] = toast_flatten_tuple_attribute(values[i], att[i]->atttypid, att[i]->atttypmod); - } else if (att[i]->attlen == -1 && att[i]->attalign == 'i' && + values[i] = toast_flatten_tuple_attribute(values[i], att[i].atttypid, att[i].atttypmod); + } else if (att[i].attlen == -1 && att[i].attalign == 'i' && VARATT_IS_HUGE_TOAST_POINTER(DatumGetPointer(values[i])) && - !(att[i]->atttypid == CLOBOID || att[i]->atttypid == BLOBOID)) { + !(att[i].atttypid == CLOBOID || att[i].atttypid == BLOBOID)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only suport type(clob/blob) for more than 1G toast"))); } @@ -673,7 +673,7 @@ UHeapTuple UHeapModifyTuple(UHeapTuple tuple, TupleDesc tupleDesc, Datum *replVa /* * create a new tuple from the values and isnull arrays */ - newTuple = (UHeapTuple)tableam_tops_form_tuple(tupleDesc, values, isnull, UHEAP_TUPLE); + newTuple = (UHeapTuple)tableam_tops_form_tuple(tupleDesc, values, isnull, TableAmUstore); pfree(values); pfree(isnull); @@ -703,7 +703,7 @@ void SlotDeformUTuple(TupleTableSlot *slot, UHeapTuple tuple, long *offp, int na Datum *values = slot->tts_values; bool *isNulls = slot->tts_isnull; UHeapDiskTuple tup = tuple->disk_tuple; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; bool hasnulls = UHeapDiskTupHasNulls(tup); char *tp = (char *) tup; bits8 *bp = tup->data; /* ptr to null bitmap in tuple */ @@ -727,7 +727,7 @@ void SlotDeformUTuple(TupleTableSlot *slot, UHeapTuple tuple, long *offp, int na } for (; attnum < nattsAvailable; attnum++) { - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (hasnulls && att_isnull(attnum, bp)) { /* Skip attribute length in case the tuple was stored with @@ -785,7 +785,7 @@ void UHeapDeformTupleGuts(UHeapTuple utuple, TupleDesc rowDesc, Datum *values, b UHeapDiskTuple diskTuple = utuple->disk_tuple; bool hasnulls = UHeapDiskTupHasNulls(diskTuple); - Form_pg_attribute *att = rowDesc->attrs; + FormData_pg_attribute *att = rowDesc->attrs; int natts; /* number of atts to extract */ int attnum; bits8 *bp = diskTuple->data; @@ -799,7 +799,7 @@ void UHeapDeformTupleGuts(UHeapTuple utuple, TupleDesc rowDesc, Datum *values, b natts = Min(tupleAttrs, unatts); for (attnum = 0; attnum < natts; attnum++) { - Form_pg_attribute thisatt = att[attnum]; + Form_pg_attribute thisatt = &att[attnum]; if (hasnulls && att_isnull(attnum, bp)) { /* Skip attribute length in case the tuple was stored with @@ -1183,7 +1183,7 @@ bool UHeapAttIsNull(UHeapTuple tup, int attnum, TupleDesc tupleDesc) Datum UHeapNoCacheGetAttr(UHeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) { UHeapDiskTuple tup = tuple->disk_tuple; - Form_pg_attribute *att = tupleDesc->attrs; + FormData_pg_attribute *att = tupleDesc->attrs; char *tp = (char *)tup; /* ptr to data part of tuple */ bits8 *bp = tup->data; /* ptr to null bitmap in tuple */ bool slow = false; /* do we have to walk attrs? */ @@ -1245,7 +1245,7 @@ Datum UHeapNoCacheGetAttr(UHeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) */ if (UHeapDiskTupHasVarWidth(tup)) { for (uint32 j = 0; j <= attnum; j++) { - if (att[j]->attlen <= 0) { + if (att[j].attlen <= 0) { slow = true; break; } @@ -1266,26 +1266,26 @@ Datum UHeapNoCacheGetAttr(UHeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) * fixed-width columns, in hope of avoiding future visits to this * routine. */ - att[0]->attcacheoff = 0; + att[0].attcacheoff = 0; /* we might have set some offsets in the slow path previously */ - while (j < natts && att[j]->attcacheoff > 0) + while (j < natts && att[j].attcacheoff > 0) j++; - off = att[j - 1]->attcacheoff + att[j - 1]->attlen; + off = att[j - 1].attcacheoff + att[j - 1].attlen; for (; j < natts; j++) { - if (att[j]->attlen <= 0) + if (att[j].attlen <= 0) break; - att[j]->attcacheoff = off; + att[j].attcacheoff = off; - off += att[j]->attlen; + off += att[j].attlen; } Assert(j > attnum); - off = att[attnum]->attcacheoff + hoff; + off = att[attnum].attcacheoff + hoff; } else { bool usecache = true; @@ -1305,11 +1305,11 @@ Datum UHeapNoCacheGetAttr(UHeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) bool enableReverseBitmap = NAttrsReserveSpace(tupleAttrs); for (uint32 i = 0; i <= attnum; i++) { /* loop exit is at "break" */ Assert(i < (uint32)tupleDesc->natts); - int attrLen = att[i]->attlen; + int attrLen = att[i].attlen; if (hasnulls && att_isnull(i, bp)) { if (enableReverseBitmap && !att_isnull(tupleAttrs + nullcount, bp)) - off += att[i]->attlen; + off += att[i].attlen; nullcount++; @@ -1317,26 +1317,26 @@ Datum UHeapNoCacheGetAttr(UHeapTuple tuple, uint32 attnum, TupleDesc tupleDesc) continue; /* this cannot be the target att */ } - if (att[i]->attlen == LEN_VARLENA) { - off = att_align_pointer(off, att[i]->attalign, -1, tp + off); + if (att[i].attlen == LEN_VARLENA) { + off = att_align_pointer(off, att[i].attalign, -1, tp + off); attrLen = VARSIZE_ANY(tp + off); - } else if (!att[i]->attbyval) { - off = att_align_nominal(off, att[i]->attalign); + } else if (!att[i].attbyval) { + off = att_align_nominal(off, att[i].attalign); } else if (usecache) { - att[i]->attcacheoff = off - hoff; + att[i].attcacheoff = off - hoff; } if (i == (uint32)attnum) break; - off = att_addlength_pointer(off, att[i]->attlen, tp + off); + off = att_addlength_pointer(off, att[i].attlen, tp + off); - if (usecache && att[i]->attlen <= 0) + if (usecache && att[i].attlen <= 0) usecache = false; } } - return fetchatt(att[attnum], tp + off); + return fetchatt(&att[attnum], tp + off); } @@ -1430,7 +1430,7 @@ void UHeapSlotFormBatch(TupleTableSlot* slot, VectorBatch* batch, int cur_rows, bool isNull = slot->tts_isnull; UHeapDiskTuple diskTuple = utuple->disk_tuple; bool hasNull = UHeapDiskTupHasNulls(diskTuple); - Form_pg_attribute* att = rowDesc->attrs; + FormData_pg_attribute* att = rowDesc->attrs; int attno; bits8* bp = diskTuple->data; long off = diskTuple->t_hoff; @@ -1443,7 +1443,7 @@ void UHeapSlotFormBatch(TupleTableSlot* slot, VectorBatch* batch, int cur_rows, int natts = Min(tupleAttrs, attnum); for (attno = 0; attno < natts; attno++) { - Form_pg_attribute thisatt = att[attno]; + Form_pg_attribute thisatt = &att[attno]; ScalarVector* pVector = &batch->m_arr[attno]; if (hasNull && att_isnull(attno, bp)) { @@ -1639,7 +1639,7 @@ Datum UHeapSlotGetAttr(TupleTableSlot *slot, int attnum, bool *isnull) * This case should not happen in normal use, but it could happen if we * are executing a plan cached before the column was dropped. */ - if (tupleDesc->attrs[attnum - 1]->attisdropped) { + if (tupleDesc->attrs[attnum - 1].attisdropped) { *isnull = true; return (Datum)0; } diff --git a/src/gausskernel/storage/bulkload/dist_fdw.cpp b/src/gausskernel/storage/bulkload/dist_fdw.cpp index 1538ab4c5..73fd0b740 100644 --- a/src/gausskernel/storage/bulkload/dist_fdw.cpp +++ b/src/gausskernel/storage/bulkload/dist_fdw.cpp @@ -526,7 +526,7 @@ ForeignScanState *buildRelatedStateInfo(Relation relation, DistFdwFileSegment *s ; /* setup tuple slot */ - scanTupleSlot = MakeTupleTableSlot(true, GetTableAmRoutine(tupleDescriptor->tdTableAmType)); + scanTupleSlot = MakeTupleTableSlot(true, tupleDescriptor->td_tam_ops); scanTupleSlot->tts_tupleDescriptor = tupleDescriptor; scanTupleSlot->tts_values = columnValues; scanTupleSlot->tts_isnull = columnNulls; @@ -653,7 +653,7 @@ static int distAcquireSampleRows(Relation relation, int logLevel, HeapTuple *sam * reach the end of the relation. */ if (sampleRowCount < targetRowCount) { - sampleRows[sampleRowCount++] = (HeapTuple)tableam_tops_form_tuple(tupleDescriptor, columnValues, columnNulls, HEAP_TUPLE); + sampleRows[sampleRowCount++] = (HeapTuple)tableam_tops_form_tuple(tupleDescriptor, columnValues, columnNulls); } else { /* * If we need to compute a new S value, we must use the "not yet @@ -673,7 +673,7 @@ static int distAcquireSampleRows(Relation relation, int logLevel, HeapTuple *sam Assert(rowIndex < targetRowCount); heap_freetuple(sampleRows[rowIndex]); - sampleRows[rowIndex] = (HeapTuple)tableam_tops_form_tuple(tupleDescriptor, columnValues, columnNulls, HEAP_TUPLE); + sampleRows[rowIndex] = (HeapTuple)tableam_tops_form_tuple(tupleDescriptor, columnValues, columnNulls); } rowCountToSkip -= 1; } @@ -777,7 +777,7 @@ bool check_selective_binary_conversion(RelOptInfo *baserel, Oid foreigntableid, /* Get user attributes. */ if (attnum > 0) { - Form_pg_attribute attr = tupleDesc->attrs[attnum - 1]; + Form_pg_attribute attr = &tupleDesc->attrs[attnum - 1]; char *attname = NameStr(attr->attname); /* Skip dropped attributes (probably shouldn't see any here). */ @@ -790,7 +790,7 @@ bool check_selective_binary_conversion(RelOptInfo *baserel, Oid foreigntableid, /* Count non-dropped user attributes while we have the tupdesc. */ numattrs = 0; for (i = 0; i < tupleDesc->natts; i++) { - Form_pg_attribute attr = tupleDesc->attrs[i]; + Form_pg_attribute attr = &tupleDesc->attrs[i]; if (attr->attisdropped) continue; @@ -1412,7 +1412,7 @@ static void DistBegin(CopyState cstate, bool isImport, Relation rel, Node *raw_q if (!list_member_int(cstate->attnumlist, attnum)) 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; } } @@ -1427,7 +1427,7 @@ static void DistBegin(CopyState cstate, bool isImport, Relation rel, Node *raw_q if (!list_member_int(cstate->attnumlist, attnum)) 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; } } @@ -1439,14 +1439,14 @@ static void DistBegin(CopyState cstate, bool isImport, Relation rel, Node *raw_q /* 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; } if (cstate->force_notnull_flags[i]) 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. */ @@ -1473,7 +1473,7 @@ void InitDistImport(DistImportExecutionState *importstate, Relation rel, const c List *options, List *totalTask) { 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; @@ -1540,15 +1540,15 @@ void InitDistImport(DistImportExecutionState *importstate, Relation rel, const c 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(importstate)) - 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 */ @@ -1579,9 +1579,9 @@ void InitDistImport(DistImportExecutionState *importstate, Relation rel, const c * values into output form before appending to data row. */ if (IS_BINARY(importstate)) - 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, &importstate->out_functions[attnum - 1]); } } else { diff --git a/src/gausskernel/storage/bulkload/importerror.cpp b/src/gausskernel/storage/bulkload/importerror.cpp index 85f26684b..89faf15f7 100644 --- a/src/gausskernel/storage/bulkload/importerror.cpp +++ b/src/gausskernel/storage/bulkload/importerror.cpp @@ -92,7 +92,7 @@ void unlink_local_cache_file(const char *prefix, const uint32 smpId) void BaseError::Serialize(StringInfo buf) { - Form_pg_attribute *attrs = m_desc->attrs; + FormData_pg_attribute *attrs = m_desc->attrs; int natts = m_desc->natts; Assert(m_desc->natts == MaxNumOfValue); @@ -104,12 +104,12 @@ void BaseError::Serialize(StringInfo buf) pq_sendint32(buf, UNSIGNED_MINUS_ONE); continue; } - if (attrs[i]->attlen > 0 && attrs[i]->attlen <= 8) { - pq_sendint32(buf, attrs[i]->attlen); - pq_sendbytes(buf, (char *)&attr, attrs[i]->attlen); - } else if (attrs[i]->attlen > 8) { - pq_sendint32(buf, attrs[i]->attlen); - pq_sendbytes(buf, DatumGetPointer(attr), attrs[i]->attlen); + if (attrs[i].attlen > 0 && attrs[i].attlen <= 8) { + pq_sendint32(buf, attrs[i].attlen); + pq_sendbytes(buf, (char *)&attr, attrs[i].attlen); + } else if (attrs[i].attlen > 8) { + pq_sendint32(buf, attrs[i].attlen); + pq_sendbytes(buf, DatumGetPointer(attr), attrs[i].attlen); } else { pq_sendint32(buf, VARSIZE(attr) - VARHDRSZ); pq_sendbytes(buf, VARDATA(attr), VARSIZE(attr) - VARHDRSZ); @@ -120,7 +120,7 @@ void BaseError::Serialize(StringInfo buf) void BaseError::Deserialize(StringInfo buf) { int natts; - Form_pg_attribute *attrs = m_desc->attrs; + FormData_pg_attribute *attrs = m_desc->attrs; natts = pq_getmsgint(buf, 2); if (natts != MaxNumOfValue || natts != m_desc->natts) { ereport(ERROR, (errcode(ERRCODE_OPERATE_RESULT_NOT_EXPECTED), errmsg("Found invalid error recored"))); @@ -139,15 +139,15 @@ void BaseError::Deserialize(StringInfo buf) errmsg("Found invalid error recored: negative length that is not -1."))); } m_isNull[i] = false; - if (attrs[i]->attlen > 0 && attrs[i]->attlen <= 8) { - if (unlikely(len != m_desc->attrs[i]->attlen)) { + if (attrs[i].attlen > 0 && attrs[i].attlen <= 8) { + if (unlikely(len != m_desc->attrs[i].attlen)) { ereport(ERROR, (errcode(ERRCODE_OPERATE_RESULT_NOT_EXPECTED), errmsg("Found invalid error recored: length is not the same as the attribute length."))); } pq_copymsgbytes(buf, (char*)&m_values[i], len); - } else if (attrs[i]->attlen > 8) { - if (unlikely(len != m_desc->attrs[i]->attlen)) { + } else if (attrs[i].attlen > 8) { + if (unlikely(len != m_desc->attrs[i].attlen)) { ereport(ERROR, (errcode(ERRCODE_OPERATE_RESULT_NOT_EXPECTED), errmsg("Found invalid error recored: length is not the same as the attribute length."))); diff --git a/src/gausskernel/storage/cstore/cstore_allocspace.cpp b/src/gausskernel/storage/cstore/cstore_allocspace.cpp index 32ade1cb0..7f0fdcd1d 100644 --- a/src/gausskernel/storage/cstore/cstore_allocspace.cpp +++ b/src/gausskernel/storage/cstore/cstore_allocspace.cpp @@ -288,7 +288,7 @@ void CStoreAllocator::BuildColSpaceCacheForRel(_in_ Relation heapRel, maxCUID = maxIdxCUID; } for (int i = 0; i < attrNum; ++i) { - if (!heapRel->rd_att->attrs[i]->attisdropped) { + if (!heapRel->rd_att->attrs[i].attisdropped) { offset[i] = CStore::GetMaxCUPointer(attrIds[i], heapRel); } else { offset[i] = 0; diff --git a/src/gausskernel/storage/cstore/cstore_am.cpp b/src/gausskernel/storage/cstore/cstore_am.cpp index 4dee7879a..27f819f41 100644 --- a/src/gausskernel/storage/cstore/cstore_am.cpp +++ b/src/gausskernel/storage/cstore/cstore_am.cpp @@ -163,7 +163,7 @@ void CStore::BindingFp(CStoreScanState* state) m_fillMinMaxFunc = (fillMinMaxFuncPtr*)palloc0(sizeof(fillMinMaxFuncPtr) * m_colNum); for (i = 0; i < m_colNum; ++i) { - switch (rel->rd_att->attrs[m_colId[i]]->atttypid) { + switch (rel->rd_att->attrs[m_colId[i]].atttypid) { case CHAROID: case INT2OID: case INT4OID: @@ -188,7 +188,7 @@ void CStore::BindingFp(CStoreScanState* state) if (m_colId[i] > rel->rd_att->natts - 1 || m_colId[i] < 0) { continue; } - switch (rel->rd_att->attrs[m_colId[i]]->attlen) { + switch (rel->rd_att->attrs[m_colId[i]].attlen) { case sizeof(char): InitFillColFunction(i, (int)sizeof(char)); break; @@ -217,8 +217,8 @@ void CStore::BindingFp(CStoreScanState* state) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), (errmsg("unsupported data type length %d of column \"%s\" of relation \"%s\" ", - (int)rel->rd_att->attrs[m_colId[i]]->attlen, - NameStr(rel->rd_att->attrs[m_colId[i]]->attname), + (int)rel->rd_att->attrs[m_colId[i]].attlen, + NameStr(rel->rd_att->attrs[m_colId[i]].attname), RelationGetRelationName(rel))))); break; } @@ -252,10 +252,10 @@ void CStore::InitFillVecEnv(CStoreScanState* state) errmsg("column %d does not exist", colId))); } - if (m_relation->rd_att->attrs[colId]->attisdropped) { + if (m_relation->rd_att->attrs[colId].attisdropped) { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column %s does not exist", - NameStr(m_relation->rd_att->attrs[colId]->attname)))); + NameStr(m_relation->rd_att->attrs[colId].attname)))); } m_colId[i] = colId; m_lateRead[i] = false; @@ -319,12 +319,12 @@ void CStore::InitRoughCheckEnv(CStoreScanState* state) if (nkeys > 0) { CStoreScanKey scanKey = state->csss_ScanKeys; Relation rel = state->ss_currentRelation; - Form_pg_attribute* attrs = rel->rd_att->attrs; + FormData_pg_attribute* attrs = rel->rd_att->attrs; m_RCFuncs = (RoughCheckFunc*)palloc(sizeof(RoughCheckFunc) * nkeys); for (int i = 0; i < nkeys; i++) { int colIdx = m_colId[scanKey[i].cs_attno]; - m_RCFuncs[i] = GetRoughCheckFunc(attrs[colIdx]->atttypid, scanKey[i].cs_strategy, scanKey[i].cs_collation); + m_RCFuncs[i] = GetRoughCheckFunc(attrs[colIdx].atttypid, scanKey[i].cs_strategy, scanKey[i].cs_collation); } } } @@ -356,13 +356,13 @@ void CStore::InitScan(CStoreScanState* state, Snapshot snapshot) m_cuStorage = (CUStorage**)palloc(sizeof(CUStorage*) * attNo); for (int i = 0; i < attNo; ++i) { - if (m_relation->rd_att->attrs[i]->attisdropped) { + if (m_relation->rd_att->attrs[i].attisdropped) { m_cuStorage[i] = NULL; continue; } m_firstColIdx = i; // Here we must use physical column id - CFileNode cFileNode(m_relation->rd_node, m_relation->rd_att->attrs[i]->attnum, MAIN_FORKNUM); + CFileNode cFileNode(m_relation->rd_node, m_relation->rd_att->attrs[i].attnum, MAIN_FORKNUM); m_cuStorage[i] = New(CurrentMemoryContext) CUStorage(cFileNode); } @@ -422,8 +422,8 @@ void CStore::Destroy() if (m_cuStorage[i]) DELETE_EX(m_cuStorage[i]); else { - Assert(m_relation->rd_att->attrs[i]->attisdropped); - if (!m_relation->rd_att->attrs[i]->attisdropped) { + Assert(m_relation->rd_att->attrs[i].attisdropped); + if (!m_relation->rd_att->attrs[i].attisdropped) { ereport(WARNING, (errmsg("m_cuStorage[%d] is NULL for a valid column", i))); } } @@ -766,21 +766,21 @@ void CStore::CStoreScanWithCU(_in_ CStoreScanState* state, __inout BatchCUData* * 2. Number of deadrows. Should be 0 because we do not deal with deadrows in copying CUs */ int cuDescIdx = m_CUDescIdx[m_cursor]; - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; for (int i = 0; i < m_colNum; ++i) { /* colIdx is pysical column id */ int colIdx = m_colId[i]; - if (attrs[colIdx]->attisdropped) { + if (attrs[colIdx].attisdropped) { ereport(ERROR, (errcode(ERRCODE_INVALID_OPERATION), (errmsg("Cannot load CUDesc and CU for a dropped column \"%s\" of table \"%s\"", - NameStr(attrs[colIdx]->attname), + NameStr(attrs[colIdx].attname), RelationGetRelationName(m_relation))))); } CUDesc* cuDescPtr = &(m_CUDescInfo[i]->cuDescArray[cuDescIdx]); CU* cuDataPtr = - New(CurrentMemoryContext) CU(attrs[colIdx]->attlen, attrs[colIdx]->atttypmod, attrs[colIdx]->atttypid); + New(CurrentMemoryContext) CU(attrs[colIdx].attlen, attrs[colIdx].atttypmod, attrs[colIdx].atttypid); /* CStoreMemAlloc::Palloc is used in LoadCU. Need toCStoreMemAlloc::Pfree later */ if (cuDescPtr->cu_size > 0) { @@ -1382,14 +1382,14 @@ void CStore::InitPartReScan(Relation rel) // destroy the old *m_cuStorage*, which will close the open fd, // and then create an new object for next partition. for (int i = 0; i < attNo; ++i) { - if (m_relation->rd_att->attrs[i]->attisdropped) + if (m_relation->rd_att->attrs[i].attisdropped) continue; if (m_cuStorage[i]) { DELETE_EX(m_cuStorage[i]); } // Here we must use physical column id - CFileNode cFileNode(m_relation->rd_node, m_relation->rd_att->attrs[i]->attnum, MAIN_FORKNUM); + CFileNode cFileNode(m_relation->rd_node, m_relation->rd_att->attrs[i].attnum, MAIN_FORKNUM); m_cuStorage[i] = New(CurrentMemoryContext) CUStorage(cFileNode); } } @@ -1586,7 +1586,7 @@ HeapTuple CStore::FormVCCUDescTup( nulls[CUDescSizeAttr - 1] = true; nulls[CUDescCUExtraAttr - 1] = true; - HeapTuple newTup = (HeapTuple)tableam_tops_form_tuple(cudesc, values, nulls, HEAP_TUPLE); + HeapTuple newTup = (HeapTuple)tableam_tops_form_tuple(cudesc, values, nulls); // ok, the temp data has been copied to newTup. // now we must free it before returning. @@ -1650,7 +1650,7 @@ HeapTuple CStore::FormCudescTuple(_in_ CUDesc* pCudesc, _in_ TupleDesc pCudescTu // add attribute extra and set null flag. pTupNulls[CUDescCUExtraAttr - 1] = true; - return (HeapTuple)tableam_tops_form_tuple(pCudescTupDesc, pTupVals, pTupNulls, HEAP_TUPLE); + return (HeapTuple)tableam_tops_form_tuple(pCudescTupDesc, pTupVals, pTupNulls); } /* description: future plan-refact CStore::LoadCUDesc() with DeformCudescTuple(). */ @@ -1965,7 +1965,7 @@ void CStore::SaveVCCUDesc(Oid cudescOid, uint32 cuId, int rowCount, uint32 magic Assert(VARSIZE_ANY_EXHDR(PointerGetDatum(tmpCuPointData)) == (uint32)delMaskBytes); } - HeapTuple tup = (HeapTuple)tableam_tops_form_tuple(tupdesc, values, nulls, HEAP_TUPLE); + HeapTuple tup = (HeapTuple)tableam_tops_form_tuple(tupdesc, values, nulls); // We always generate xlog for cudesc tuple options &= (~TABLE_INSERT_SKIP_WAL); @@ -2001,8 +2001,8 @@ uint32 CStore::GetMaxCUID(Oid cudescHeap, TupleDesc cstoreRelTupDesc, Snapshot s // find a column which is not dropped. int attrId = 0; for (int i = 0; i < cstoreRelTupDesc->natts; ++i) { - if (!cstoreRelTupDesc->attrs[i]->attisdropped) { - attrId = cstoreRelTupDesc->attrs[i]->attnum; + if (!cstoreRelTupDesc->attrs[i].attisdropped) { + attrId = cstoreRelTupDesc->attrs[i].attnum; break; } } @@ -2178,10 +2178,10 @@ void CStore::SaveCUDesc(_in_ Relation rel, _in_ CUDesc* cuDescPtr, _in_ int col, Assert(rel != NULL); Assert(col >= 0); - if (rel->rd_att->attrs[col]->attisdropped) { + if (rel->rd_att->attrs[col].attisdropped) { ereport(PANIC, (errmsg("Cannot save CUDesc for a dropped column \"%s\" of table \"%s\"", - NameStr(rel->rd_att->attrs[col]->attname), + NameStr(rel->rd_att->attrs[col].attname), RelationGetRelationName(rel)))); } @@ -2190,7 +2190,7 @@ void CStore::SaveCUDesc(_in_ Relation rel, _in_ CUDesc* cuDescPtr, _in_ int col, Datum values[CUDescMaxAttrNum]; bool nulls[CUDescMaxAttrNum]; - HeapTuple tup = CStore::FormCudescTuple(cuDescPtr, cudesc_rel->rd_att, values, nulls, rel->rd_att->attrs[col]); + HeapTuple tup = CStore::FormCudescTuple(cuDescPtr, cudesc_rel->rd_att, values, nulls, &rel->rd_att->attrs[col]); // We always generate xlog for cudesc tuple options &= (~TABLE_INSERT_SKIP_WAL); @@ -2258,9 +2258,9 @@ bool CStore::LoadCUDesc( Relation cudesc_rel = heap_open(m_relation->rd_rel->relcudescrelid, AccessShareLock); TupleDesc cudesc_tupdesc = cudesc_rel->rd_att; Relation idx_rel = index_open(cudesc_rel->rd_rel->relcudescidx, AccessShareLock); - bool needLengthInfo = m_relation->rd_att->attrs[col]->attlen < 0; + bool needLengthInfo = m_relation->rd_att->attrs[col].attlen < 0; /* Convert logical id is to physical id of attribute */ - int attid = m_relation->rd_att->attrs[col]->attnum; + int attid = m_relation->rd_att->attrs[col].attnum; /* * Setup scan key to fetch from the index by attid and CU ID range. @@ -2428,10 +2428,10 @@ int CStore::FillVecBatch(_out_ VectorBatch* vecBatchOut) for (i = 0; i < m_colNum; ++i) { int colIdx = m_colId[i]; - if (m_relation->rd_att->attrs[colIdx]->attisdropped) { + if (m_relation->rd_att->attrs[colIdx].attisdropped) { ereport(PANIC, (errmsg("Cannot fill VecBatch for a dropped column \"%s\" of table \"%s\"", - NameStr(m_relation->rd_att->attrs[colIdx]->attname), + NameStr(m_relation->rd_att->attrs[colIdx].attname), RelationGetRelationName(m_relation)))); } if (likely(colIdx >= 0)) { @@ -2493,7 +2493,7 @@ int CStore::FillVecBatch(_out_ VectorBatch* vecBatchOut) } /* Step 4: fill other columns if need, most likely for the dropped column */ for (i = 0; i < vecBatchOut->m_cols; i++) { - if (m_relation->rd_att->attrs[i]->attisdropped) { + if (m_relation->rd_att->attrs[i].attisdropped) { ScalarVector* vec = vecBatchOut->m_arr + i; vec->m_rows = vecBatchOut->m_rows; vec->SetAllNull(); @@ -2840,7 +2840,7 @@ void CStore::FillVectorByTids(_in_ int colIdx, _in_ ScalarVector* tids, _out_ Sc (errmsg("compression unit descriptor not found, table(%s), column(%s), relfilenode(%u/%u/%u), " "cuid(%u)).", RelationGetRelationName(this->m_relation), - NameStr(this->m_relation->rd_att->attrs[colIdx]->attname), + NameStr(this->m_relation->rd_att->attrs[colIdx].attname), this->m_relation->rd_node.spcNode, this->m_relation->rd_node.dbNode, this->m_relation->rd_node.relNode, @@ -3216,9 +3216,9 @@ bool CStore::GetCUDesc(_in_ int col, _in_ uint32 cuid, _out_ CUDesc* cuDescPtr, Relation cudesc_rel = heap_open(m_relation->rd_rel->relcudescrelid, AccessShareLock); TupleDesc cudesc_tupdesc = cudesc_rel->rd_att; Relation idx_rel = index_open(cudesc_rel->rd_rel->relcudescidx, AccessShareLock); - bool isFixedLen = m_relation->rd_att->attrs[col]->attlen > 0 ? true : false; + bool isFixedLen = m_relation->rd_att->attrs[col].attlen > 0 ? true : false; // Convert logical id is to physical id of attribute - int attid = m_relation->rd_att->attrs[col]->attnum; + int attid = m_relation->rd_att->attrs[col].attnum; /* * Setup scan key to fetch from the index by attid. @@ -3519,18 +3519,18 @@ CU* CStore::GetCUData(CUDesc* cuDescPtr, int colIdx, int valSize, int& slotId) * so the spaces only used for this batch should be managed by m_PerScanMemCnxt, * including the peices of space used in the decompression. */ - if (m_relation->rd_att->attrs[colIdx]->attisdropped) { + if (m_relation->rd_att->attrs[colIdx].attisdropped) { ereport(ERROR, (errcode(ERRCODE_INVALID_OPERATION), (errmsg("Cannot get CUData for a dropped column \"%s\" of table \"%s\"", - NameStr(m_relation->rd_att->attrs[colIdx]->attname), + NameStr(m_relation->rd_att->attrs[colIdx].attname), RelationGetRelationName(m_relation))))); } AutoContextSwitch newMemCnxt(this->m_perScanMemCnxt); CU* cuPtr = NULL; - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; CUUncompressedRetCode retCode = CU_OK; bool hasFound = false; DataSlotTag dataSlotTag = @@ -3561,7 +3561,7 @@ RETRY_LOAD_CU: // Use the cached CU cuPtr = CUCache->GetCUBuf(slotId); cuPtr->m_inCUCache = true; - cuPtr->SetAttInfo(valSize, attrs[colIdx]->atttypmod, attrs[colIdx]->atttypid); + cuPtr->SetAttInfo(valSize, attrs[colIdx].atttypmod, attrs[colIdx].atttypid); // If the CU was already in the cache, return it. if (hasFound) { @@ -3573,7 +3573,7 @@ RETRY_LOAD_CU: errmsg("CU wait IO find an error, need to reload! table(%s), column(%s), relfilenode(%u/%u/%u), " "cuid(%u)", RelationGetRelationName(m_relation), - NameStr(m_relation->rd_att->attrs[colIdx]->attname), + NameStr(m_relation->rd_att->attrs[colIdx].attname), m_relation->rd_node.spcNode, m_relation->rd_node.dbNode, m_relation->rd_node.relNode, @@ -3601,7 +3601,7 @@ RETRY_LOAD_CU: ereport(LOG, (errmodule(MOD_CACHE), errmsg("The CU is being reloaded by remote read thread. Retry to load CU! table(%s), " "column(%s), relfilenode(%u/%u/%u), cuid(%u)", - RelationGetRelationName(m_relation), NameStr(m_relation->rd_att->attrs[colIdx]->attname), + RelationGetRelationName(m_relation), NameStr(m_relation->rd_att->attrs[colIdx].attname), m_relation->rd_node.spcNode, m_relation->rd_node.dbNode, m_relation->rd_node.relNode, cuDescPtr->cu_id))); goto RETRY_LOAD_CU; @@ -3611,7 +3611,7 @@ RETRY_LOAD_CU: errmodule(MOD_ADIO), errmsg("Load CU failed in adio! table(%s), column(%s), relfilenode(%u/%u/%u), cuid(%u)", RelationGetRelationName(m_relation), - NameStr(m_relation->rd_att->attrs[colIdx]->attname), + NameStr(m_relation->rd_att->attrs[colIdx].attname), m_relation->rd_node.spcNode, m_relation->rd_node.dbNode, m_relation->rd_node.relNode, @@ -3644,7 +3644,7 @@ RETRY_LOAD_CU: errmsg("The CU is being reloaded by remote read thread. Retry to load CU! table(%s), " "column(%s), relfilenode(%u/%u/%u), cuid(%u)", RelationGetRelationName(m_relation), - NameStr(m_relation->rd_att->attrs[colIdx]->attname), m_relation->rd_node.spcNode, + NameStr(m_relation->rd_att->attrs[colIdx].attname), m_relation->rd_node.spcNode, m_relation->rd_node.dbNode, m_relation->rd_node.relNode, cuDescPtr->cu_id))); goto RETRY_LOAD_CU; } @@ -3702,7 +3702,7 @@ RETRY_LOAD_CU: errmsg("The CU is being reloaded by remote read thread. Retry to load CU! table(%s), column(%s), " "relfilenode(%u/%u/%u), cuid(%u)", RelationGetRelationName(m_relation), - NameStr(m_relation->rd_att->attrs[colIdx]->attname), + NameStr(m_relation->rd_att->attrs[colIdx].attname), m_relation->rd_node.spcNode, m_relation->rd_node.dbNode, m_relation->rd_node.relNode, @@ -3736,7 +3736,7 @@ RETRY_LOAD_CU: (errmodule(MOD_CACHE), errmsg("The CU is being reloaded by remote read thread. Retry to load CU! table(%s), " "column(%s), relfilenode(%u/%u/%u), cuid(%u)", - RelationGetRelationName(m_relation), NameStr(m_relation->rd_att->attrs[colIdx]->attname), + RelationGetRelationName(m_relation), NameStr(m_relation->rd_att->attrs[colIdx].attname), m_relation->rd_node.spcNode, m_relation->rd_node.dbNode, m_relation->rd_node.relNode, cuDescPtr->cu_id))); goto RETRY_LOAD_CU; @@ -3777,14 +3777,14 @@ RETRY_LOAD_CU: CUUncompressedRetCode CStore::GetCUDataFromRemote( CUDesc* cuDescPtr, CU* cuPtr, int colIdx, int valSize, const int& slotId) { - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; CUUncompressedRetCode retCode = CU_OK; /* reuse memory and check if have some other session is updating it concurrently. */ if (CUCache->ReserveCstoreDataBlockWithSlotId(slotId)) { cuPtr = CUCache->GetCUBuf(slotId); cuPtr->m_inCUCache = true; - cuPtr->SetAttInfo(valSize, attrs[colIdx]->atttypmod, attrs[colIdx]->atttypid); + cuPtr->SetAttInfo(valSize, attrs[colIdx].atttypmod, attrs[colIdx].atttypid); /* * remote load need CU compressed. (cuPtr->m_compressedLoadBuf != NULL) @@ -3819,7 +3819,7 @@ CUUncompressedRetCode CStore::GetCUDataFromRemote( relcolpath(m_cuStorage[colIdx]), cuDescPtr->cu_pointer, slotId, - NameStr(m_relation->rd_att->attrs[colIdx]->attname)))); + NameStr(m_relation->rd_att->attrs[colIdx].attname)))); } } @@ -3866,7 +3866,7 @@ bool CStore::GetCURowCount(_in_ int col, __inout LoadCUDescCtl* loadCUDescInfoPt loadCUDescInfoPtr->curLoadNum = 0; CUDesc* cuDescArray = loadCUDescInfoPtr->cuDescArray; - int attid = m_relation->rd_att->attrs[col]->attnum; + int attid = m_relation->rd_att->attrs[col].attnum; Relation cudesc_rel = heap_open(m_relation->rd_rel->relcudescrelid, AccessShareLock); TupleDesc cudesc_tupdesc = cudesc_rel->rd_att; Relation idx_rel = index_open(cudesc_rel->rd_rel->relcudescidx, AccessShareLock); @@ -4037,7 +4037,7 @@ void CStore::CreateStorage(Relation rel, Oid newRelFileNode) { TupleDesc desc = RelationGetDescr(rel); int nattrs = desc->natts; - Form_pg_attribute* attrs = desc->attrs; + FormData_pg_attribute* attrs = desc->attrs; char relpersistence = rel->rd_rel->relpersistence; RelFileNode rd_node = rel->rd_node; @@ -4047,9 +4047,9 @@ void CStore::CreateStorage(Relation rel, Oid newRelFileNode) } for (int i = 0; i < nattrs; i++) { - if (attrs[i]->attisdropped) + if (attrs[i].attisdropped) continue; - int attrid = attrs[i]->attnum; + int attrid = attrs[i].attnum; CFileNode cnode(rd_node, attrid, MAIN_FORKNUM); @@ -4072,7 +4072,7 @@ void CStore::TruncateStorageInSameXact(Relation rel) { TupleDesc desc = RelationGetDescr(rel); int nattrs = desc->natts; - Form_pg_attribute* attrs = desc->attrs; + FormData_pg_attribute* attrs = desc->attrs; RelFileNode rd_node = rel->rd_node; uint64 totalSize = 0; @@ -4086,7 +4086,7 @@ void CStore::TruncateStorageInSameXact(Relation rel) CUCache->DropRelationCUCache(rd_node); for (int i = 0; i < nattrs; i++) { - int attrid = attrs[i]->attnum; + int attrid = attrs[i].attnum; CFileNode cnode(rd_node, attrid, MAIN_FORKNUM); // calculate each column size @@ -4260,7 +4260,7 @@ TransactionId CStore::GetCUXmin(uint32 cuid) ereport(FATAL, (errmsg("compression unit descriptor(talbe \"%s\", column \"%s\", cuid %u) not found", RelationGetRelationName(m_relation), - NameStr(m_relation->rd_att->attrs[colid]->attname), + NameStr(m_relation->rd_att->attrs[colid].attname), cuid))); } @@ -4534,7 +4534,7 @@ CStoreScanDesc CStoreBeginScan(Relation relation, int colNum, int16* colIdx, Sna List *sysAttrList = NULL; for (int i = 0; i < colNum; ++i) { /* dropped column and not system column */ - if (colIdx[i] >= 0 && relation->rd_att->attrs[colIdx[i] - 1]->attisdropped) + if (colIdx[i] >= 0 && relation->rd_att->attrs[colIdx[i] - 1].attisdropped) continue; if (colIdx[i] >= 0) accessAttrList = lappend_int(accessAttrList, colIdx[i]); @@ -4684,11 +4684,11 @@ uint32 CStoreRelGetCUNumByNow(CStoreScanDesc cstoreScanState) TupleDesc cudesc_tupdesc = cudesc_rel->rd_att; Relation idx_rel = index_open(cudesc_rel->rd_rel->relcudescidx, AccessShareLock); - int attid = relation->rd_att->attrs[0]->attnum; + int attid = relation->rd_att->attrs[0].attnum; - if (relation->rd_att->attrs[0]->attisdropped) { + if (relation->rd_att->attrs[0].attisdropped) { int fstColIdx = CStoreGetfstColIdx(relation); - attid = relation->rd_att->attrs[fstColIdx]->attnum; + attid = relation->rd_att->attrs[fstColIdx].attnum; } /* Setup scan key to fetch from the index by col_id. */ @@ -4751,7 +4751,7 @@ void CStoreDropColumnInCuDesc(Relation rel, AttrNumber attrnum) int CStoreGetfstColIdx(Relation rel) { for (int i = 0; i < rel->rd_att->natts; i++) { - if (!rel->rd_att->attrs[i]->attisdropped) + if (!rel->rd_att->attrs[i].attisdropped) return i; } return 0; diff --git a/src/gausskernel/storage/cstore/cstore_delete.cpp b/src/gausskernel/storage/cstore/cstore_delete.cpp index 7575c6360..1a5d045bd 100644 --- a/src/gausskernel/storage/cstore/cstore_delete.cpp +++ b/src/gausskernel/storage/cstore/cstore_delete.cpp @@ -305,7 +305,7 @@ void CStoreDelete::InitDeleteSortStateForTable(TupleDesc sortTupDesc, int /* par TypeCacheEntry* typeEntry = lookup_type_cache(TIDOID, TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); attNums[0] = ctidAttNo; - sortCollations[0] = sortTupDesc->attrs[ctidAttNo - 1]->attcollation; + sortCollations[0] = sortTupDesc->attrs[ctidAttNo - 1].attcollation; nullsFirstFlags[0] = false; SortMem = m_DelMemInfo->MemSort > 0 ? m_DelMemInfo->MemSort : u_sess->attr.attr_storage.psort_work_mem; @@ -337,8 +337,8 @@ void CStoreDelete::InitDeleteSortStateForPartition(TupleDesc sortTupDesc, int pa typeEntry = lookup_type_cache(TIDOID, TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); sortOperators[1] = typeEntry->lt_opr; - sortCollations[0] = sortTupDesc->attrs[partidAttNo - 1]->attcollation; - sortCollations[1] = sortTupDesc->attrs[ctidAttNo - 1]->attcollation; + sortCollations[0] = sortTupDesc->attrs[partidAttNo - 1].attcollation; + sortCollations[1] = sortTupDesc->attrs[ctidAttNo - 1].attcollation; nullsFirstFlags[0] = false; nullsFirstFlags[1] = false; diff --git a/src/gausskernel/storage/cstore/cstore_insert.cpp b/src/gausskernel/storage/cstore/cstore_insert.cpp index 3a88deca9..3fa95fca8 100644 --- a/src/gausskernel/storage/cstore/cstore_insert.cpp +++ b/src/gausskernel/storage/cstore/cstore_insert.cpp @@ -185,11 +185,11 @@ CStoreInsert::CStoreInsert(_in_ Relation relation, _in_ const InsertArg& args, _ m_cuCmprsOptions = (compression_options*)palloc(sizeof(compression_options) * attNo); for (int i = 0; i < attNo; ++i) { - if (m_relation->rd_att->attrs[i]->attisdropped) { + if (m_relation->rd_att->attrs[i].attisdropped) { m_cuStorage[i] = NULL; } else { // Here we must use physical column id - CFileNode cFileNode(m_relation->rd_node, m_relation->rd_att->attrs[i]->attnum, MAIN_FORKNUM); + CFileNode cFileNode(m_relation->rd_node, m_relation->rd_att->attrs[i].attnum, MAIN_FORKNUM); m_cuStorage[i] = New(CurrentMemoryContext) CUStorage(cFileNode); } /* init compression filter */ @@ -463,7 +463,7 @@ void CStoreInsert::InitInsertMemArg(Plan* plan, MemInfoArg* ArgmemInfo) void CStoreInsert::InitFuncPtr() { int attNo = m_relation->rd_att->natts; - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; m_setMinMaxFuncs = (FuncSetMinMax*)palloc(attNo * sizeof(FuncSetMinMax)); m_formCUFuncArray = (FormCUFuncArray*)palloc(sizeof(FormCUFuncArray) * attNo); @@ -474,9 +474,9 @@ void CStoreInsert::InitFuncPtr() * Initilize FormCU function */ for (int col = 0; col < attNo; ++col) { - if (!attrs[col]->attisdropped) { - m_setMinMaxFuncs[col] = GetMinMaxFunc(attrs[col]->atttypid); - SetFormCUFuncArray(attrs[col], col); + if (!attrs[col].attisdropped) { + m_setMinMaxFuncs[col] = GetMinMaxFunc(attrs[col].atttypid); + SetFormCUFuncArray(&attrs[col], col); m_cuDescPPtr[col] = New(CurrentMemoryContext) CUDesc; } else { m_setMinMaxFuncs[col] = NULL; @@ -490,14 +490,14 @@ void CStoreInsert::InitFuncPtr() void CStoreInsert::InitColSpaceAlloc() { int attNo = m_relation->rd_att->natts; - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; AttrNumber* attrIds = (AttrNumber*)palloc(sizeof(AttrNumber) * attNo); for (int i = 0; i < attNo; ++i) { - attrIds[i] = attrs[i]->attnum; + attrIds[i] = attrs[i].attnum; /* Set all column use APPEND_ONLY */ - if (!attrs[i]->attisdropped) + if (!attrs[i].attisdropped) m_cuStorage[i]->SetAllocateStrategy(APPEND_ONLY); } @@ -601,7 +601,7 @@ void CStoreInsert::InitDeltaInfo() void CStoreInsert::InitIndexColId(int which_index) { int attrs_num = m_relation->rd_att->natts; - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; AttrNumber* keyPtr = NULL; List* exprList = NULL; @@ -613,7 +613,7 @@ void CStoreInsert::InitIndexColId(int which_index) if (exprList == NIL) { for (int which_idxkey = 0; which_idxkey < m_idxKeyNum[which_index]; ++which_idxkey) { for (int attr_cnt = 0; attr_cnt < attrs_num; ++attr_cnt) { - if (attrs[attr_cnt]->attnum == keyPtr[which_idxkey]) { + if (attrs[attr_cnt].attnum == keyPtr[which_idxkey]) { m_idxKeyAttr[which_index][which_idxkey] = attr_cnt; break; } @@ -631,7 +631,7 @@ void CStoreInsert::InitIndexColId(int which_index) } for (int attr_cnt = 0; attr_cnt < attrs_num; ++attr_cnt) { - if (attrs[attr_cnt]->attnum == keycol) { + if (attrs[attr_cnt].attnum == keycol) { m_idxKeyAttr[which_index][which_idxkey] = attr_cnt; break; } @@ -810,7 +810,7 @@ void CStoreInsert::BatchInsertCommon(bulkload_rows* batchRowPtr, int options) CHECK_FOR_INTERRUPTS(); /* step 1: form CU and CUDesc; */ for (col = 0; col < attno; ++col) { - if (!m_relation->rd_att->attrs[col]->attisdropped) { + if (!m_relation->rd_att->attrs[col].attisdropped) { m_cuPPtr[col] = FormCU(col, batchRowPtr, m_cuDescPPtr[col]); m_cuCmprsOptions[col].m_sampling_fihished = true; } @@ -827,7 +827,7 @@ void CStoreInsert::BatchInsertCommon(bulkload_rows* batchRowPtr, int options) SaveAll(options); /* step 3: batch insert index table */ - if (m_relation->rd_att->attrs[0]->attisdropped) { + if (m_relation->rd_att->attrs[0].attisdropped) { int fstColIdx = CStoreGetfstColIdx(m_relation); InsertIdxTableIfNeed(batchRowPtr, m_cuDescPPtr[fstColIdx]->cu_id); } else @@ -870,7 +870,7 @@ void CStoreInsert::InsertDeltaTable(bulkload_rows* batchRowPtr, int options) iter.begin(batchRowPtr); while (iter.not_end()) { iter.next(values, nulls); - tuple = (HeapTuple)tableam_tops_form_tuple(m_delta_desc, values, nulls, HEAP_TUPLE); + tuple = (HeapTuple)tableam_tops_form_tuple(m_delta_desc, values, nulls); /* We always generate xlog for delta tuple */ uint32 tmpVal = (uint32)options; @@ -963,7 +963,7 @@ void CStoreInsert::InsertNotPsortIdx(int indice) } MemoryContext oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(m_estate)); - HeapTuple fakeTuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, m_fake_values, m_fake_isnull, HEAP_TUPLE); + HeapTuple fakeTuple = (HeapTuple)tableam_tops_form_tuple(tupDesc, m_fake_values, m_fake_isnull); TupleTableSlot* fakeSlot = MakeSingleTupleTableSlot(tupDesc); (void)ExecStoreTuple(fakeTuple, fakeSlot, InvalidBuffer, false); @@ -1206,7 +1206,7 @@ void CStoreInsert::CUListWrite() PG_ENSURE_ERROR_CLEANUP(CUListWriteAbort, (Datum)this); { for (col = 0; col < attno; ++col) { - if (!m_relation->rd_att->attrs[col]->attisdropped) { + if (!m_relation->rd_att->attrs[col].attisdropped) { if (m_cuDescPPtr[col]->cu_size > 0) { CUWrite(attno, col); } else { @@ -1342,7 +1342,7 @@ void CStoreInsert::SaveAll(int options, _in_ const char* delBitmap) LockRelationForExtension(m_relation, ExclusiveLock); uint32 curCUID = CStoreAllocator::GetNextCUID(m_relation); for (col = 0; col < attno; ++col) { - if (m_relation->rd_att->attrs[col]->attisdropped) + if (m_relation->rd_att->attrs[col].attisdropped) continue; /* step 2: Allocate space, update m_cuDescPPtr[col]->cu_pointer */ CUDesc* cuDesc = m_cuDescPPtr[col]; @@ -1375,7 +1375,7 @@ void CStoreInsert::SaveAll(int options, _in_ const char* delBitmap) ADIO_ELSE() { for (col = 0; col < attno; ++col) { - if (m_relation->rd_att->attrs[col]->attisdropped) { + if (m_relation->rd_att->attrs[col].attisdropped) { if (m_cuPPtr[col]) DELETE_EX(m_cuPPtr[col]); continue; @@ -1429,18 +1429,18 @@ void CStoreInsert::SaveAll(int options, _in_ const char* delBitmap) */ CU* CStoreInsert::FormCU(int col, bulkload_rows* batchRowPtr, CUDesc* cuDescPtr) { - Form_pg_attribute* attrs = m_relation->rd_att->attrs; - int attlen = attrs[col]->attlen; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; + int attlen = attrs[col].attlen; CU* cuPtr = NULL; ADIO_RUN() { /* cuPtr need keep untill async write finish */ - cuPtr = New(m_aio_memcnxt) CU(attlen, attrs[col]->atttypmod, attrs[col]->atttypid); + cuPtr = New(m_aio_memcnxt) CU(attlen, attrs[col].atttypmod, attrs[col].atttypid); } ADIO_ELSE() { - cuPtr = New(CurrentMemoryContext) CU(attlen, attrs[col]->atttypmod, attrs[col]->atttypid); + cuPtr = New(CurrentMemoryContext) CU(attlen, attrs[col].atttypmod, attrs[col].atttypid); } ADIO_END(); @@ -1458,7 +1458,7 @@ CU* CStoreInsert::FormCU(int col, bulkload_rows* batchRowPtr, CUDesc* cuDescPtr) // a little tricky to reduce the recomputation of min/max value. // some data type is equal to int8/int16/int32/int32. for them it // is not necessary to recompute the min/max value. - m_cuTempInfo.m_valid_minmax = !NeedToRecomputeMinMax(attrs[col]->atttypid); + m_cuTempInfo.m_valid_minmax = !NeedToRecomputeMinMax(attrs[col].atttypid); if (m_cuTempInfo.m_valid_minmax) { m_cuTempInfo.m_min_value = ConvertToInt64Data(cuDescPtr->cu_min, attlen); m_cuTempInfo.m_max_value = ConvertToInt64Data(cuDescPtr->cu_max, attlen); @@ -1572,7 +1572,7 @@ bool CStoreInsert::TryEncodeNumeric(int col, bulkload_rows* batchRowPtr, CUDesc* template bool CStoreInsert::FormNumberStringCU(int col, bulkload_rows* batchRowPtr, CUDesc* cuDescPtr, CU* cuPtr) { - int attlen = this->m_relation->rd_att->attrs[col]->attlen; + int attlen = this->m_relation->rd_att->attrs[col].attlen; int rows = batchRowPtr->m_rows_curnum; bulkload_datums* batch_values = &(batchRowPtr->m_vectors[col].m_values_nulls); uint64 data = 0; @@ -1736,7 +1736,7 @@ bool CStoreInsert::TryFormNumberStringCU( if (atttypid == BPCHAROID) { /* for type define bpchar, we do not know the length, so we don't do the change */ - if (this->m_relation->rd_att->attrs[col]->atttypmod == -1) { + if (this->m_relation->rd_att->attrs[col].atttypmod == -1) { return ret; } if (func == NULL) { @@ -1791,7 +1791,7 @@ void CStoreInsert::FormCUTCopyMem( CU* cuPtr, bulkload_rows* batchRowPtr, CUDesc* cuDescPtr, Size dtSize, int col, bool hasNull) { bulkload_vector* vector = batchRowPtr->m_vectors + col; - Form_pg_attribute attr = this->m_relation->rd_att->attrs[col]; + Form_pg_attribute attr = &this->m_relation->rd_att->attrs[col]; /* copy null-bitmap */ if (hasNull) { @@ -1880,7 +1880,7 @@ void CStoreInsert::FormCUTNumeric(int col, bulkload_rows* batchRowPtr, CUDesc* c template void CStoreInsert::FormCUTNumString(int col, bulkload_rows* batchRowPtr, CUDesc* cuDescPtr, CU* cuPtr) { - Form_pg_attribute attr = this->m_relation->rd_att->attrs[col]; + Form_pg_attribute attr = &this->m_relation->rd_att->attrs[col]; Size dataSize = this->FormCUTInitMem(cuPtr, batchRowPtr, col, hasNull); @@ -1918,7 +1918,7 @@ void CStoreInsert::CUInsert(_in_ BatchCUData* CUData, _in_ int options) // step 1: pass CUDesc and CU to CStoreInsert for (col = 0; col < attno; ++col) { - if (m_relation->rd_att->attrs[col]->attisdropped) + if (m_relation->rd_att->attrs[col].attisdropped) continue; *m_cuDescPPtr[col] = *CUData->CUDescData[col]; m_cuPPtr[col] = CUData->CUptrData[col]; @@ -2033,26 +2033,26 @@ void CStoreInsert::InitIndexInsertArg(Relation heap_rel, const int* key_map, int /* plus TID system attribute */ int nkeys_plus_tid = nkeys + 1; - struct tupleDesc index_tupdesc; - index_tupdesc.natts = nkeys_plus_tid; - index_tupdesc.attrs = (Form_pg_attribute*)palloc(sizeof(Form_pg_attribute) * nkeys_plus_tid); + struct tupleDesc *index_tupdesc = CreateTemplateTupleDesc(nkeys_plus_tid, false); + + index_tupdesc->natts = nkeys_plus_tid; /* the following are not important to us, just init them */ - index_tupdesc.constr = NULL; - index_tupdesc.initdefvals = NULL; - index_tupdesc.tdhasoid = false; - index_tupdesc.tdrefcount = 1; - index_tupdesc.tdtypeid = InvalidOid; - index_tupdesc.tdtypmod = -1; + index_tupdesc->constr = NULL; + index_tupdesc->initdefvals = NULL; + index_tupdesc->tdhasoid = false; + index_tupdesc->tdrefcount = 1; + index_tupdesc->tdtypeid = InvalidOid; + index_tupdesc->tdtypmod = -1; /* set attribute point exlcuding TID field */ for (int i = 0; i < nkeys; ++i) { - index_tupdesc.attrs[i] = heap_rel->rd_att->attrs[key_map[i]]; + memcpy(&index_tupdesc->attrs[i], &heap_rel->rd_att->attrs[key_map[i]], ATTRIBUTE_FIXED_PART_SIZE); } /* set TID attribute */ FormData_pg_attribute tid_attr; init_tid_attinfo(&tid_attr); - index_tupdesc.attrs[nkeys] = &tid_attr; + memcpy(&index_tupdesc->attrs[nkeys], &tid_attr, ATTRIBUTE_FIXED_PART_SIZE); args.es_result_relations = NULL; /* psort index will use tuple sort */ @@ -2061,11 +2061,11 @@ void CStoreInsert::InitIndexInsertArg(Relation heap_rel, const int* key_map, int args.idxBatchRow = NULL; /* init temp batch buffer for psort index */ args.tmpBatchRows = - New(CurrentMemoryContext) bulkload_rows(&index_tupdesc, RelationGetMaxBatchRows(heap_rel), true); + New(CurrentMemoryContext) bulkload_rows(index_tupdesc, RelationGetMaxBatchRows(heap_rel), true); args.using_vectorbatch = false; /* release temp memory */ - pfree(index_tupdesc.attrs); + pfree(index_tupdesc); } /* @@ -2581,7 +2581,7 @@ void CStorePartitionInsert::BatchInsert(VectorBatch* batch, int hi_options) int ncols = batch->m_cols; int rows = batch->m_rows; - Form_pg_attribute* attrs = m_relation->rd_att->attrs; + FormData_pg_attribute* attrs = m_relation->rd_att->attrs; ScalarVector* pVec = NULL; ScalarValue* pVals = NULL; @@ -2602,10 +2602,10 @@ void CStorePartitionInsert::BatchInsert(VectorBatch* batch, int hi_options) if (pVec->m_desc.encoded == false) m_val[col] = pVals[rowCnt]; else { - Assert(attrs[col]->attlen < 0 || attrs[col]->attlen > 8); + Assert(attrs[col].attlen < 0 || attrs[col].attlen > 8); Datum v = ScalarVector::Decode(pVals[rowCnt]); /* m_val[] just point to existing memory, not allocing new space. */ - m_val[col] = (attrs[col]->attlen < 0) ? v : PointerGetDatum((char*)v + VARHDRSZ_SHORT); + m_val[col] = (attrs[col].attlen < 0) ? v : PointerGetDatum((char*)v + VARHDRSZ_SHORT); } } @@ -2800,12 +2800,12 @@ Size PartitionValueCache::WriteRow(Datum* values, const bool* nulls) { TupleDesc tupleDesc = RelationGetDescr(m_rel); int natts = tupleDesc->natts; - Form_pg_attribute* attrs = tupleDesc->attrs; + FormData_pg_attribute* attrs = tupleDesc->attrs; Size row_size = 0; for (int i = 0; i < natts; i++) { Datum val = values[i]; - int att_len = attrs[i]->attlen; + int att_len = attrs[i].attlen; if (nulls[i]) { InternalWriteInt(-1); @@ -2837,7 +2837,7 @@ Size PartitionValueCache::WriteRow(Datum* values, const bool* nulls) int PartitionValueCache::ReadRow(_out_ Datum* values, _out_ bool* nulls) { TupleDesc tupleDesc = RelationGetDescr(m_rel); - Form_pg_attribute* attrs = tupleDesc->attrs; + FormData_pg_attribute* attrs = tupleDesc->attrs; int natts = tupleDesc->natts; int i; int nread = 0; @@ -2861,13 +2861,13 @@ int PartitionValueCache::ReadRow(_out_ Datum* values, _out_ bool* nulls) continue; } - if (attrs[i]->attlen > 0 && attrs[i]->attlen <= 8) { - Assert(len == tupleDesc->attrs[i]->attlen); + if (attrs[i].attlen > 0 && attrs[i].attlen <= 8) { + Assert(len == tupleDesc->attrs[i].attlen); retval = InternalRead((char*)&(val), len); - } else if (attrs[i]->attlen > 8 || attrs[i]->attlen == -2) { + } else if (attrs[i].attlen > 8 || attrs[i].attlen == -2) { val = (Datum)palloc(len); retval = InternalRead(DatumGetPointer(val), len); - } else if (attrs[i]->attlen == -1) { + } else if (attrs[i].attlen == -1) { val = (Datum)palloc(VARHDRSZ + len); SET_VARSIZE(val, VARHDRSZ + len); retval = InternalRead(VARDATA(DatumGetPointer(val)), len); diff --git a/src/gausskernel/storage/cstore/cstore_psort.cpp b/src/gausskernel/storage/cstore/cstore_psort.cpp index def061569..f70242984 100644 --- a/src/gausskernel/storage/cstore/cstore_psort.cpp +++ b/src/gausskernel/storage/cstore/cstore_psort.cpp @@ -43,7 +43,7 @@ CStorePSort::CStorePSort(Relation rel, AttrNumber* sortKeys, int keyNum, int typ m_vecBatchCursor(InvalidBathCursor) { m_tupDesc = m_rel->rd_att; - Form_pg_attribute* attr = m_tupDesc->attrs; + FormData_pg_attribute* attr = m_tupDesc->attrs; m_psortMemInfo = NULL; m_fullCUSize = RelationGetMaxBatchRows(m_rel); @@ -59,9 +59,9 @@ CStorePSort::CStorePSort(Relation rel, AttrNumber* sortKeys, int keyNum, int typ m_sortCollations = (Oid*)palloc(sizeof(Oid) * keyNum); for (int i = 0; i < keyNum; ++i) { int colIdx = m_sortKeys[i] - 1; - m_sortCollations[i] = attr[colIdx]->attcollation; + m_sortCollations[i] = attr[colIdx].attcollation; - TypeCacheEntry* typeEntry = lookup_type_cache(attr[colIdx]->atttypid, TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); + TypeCacheEntry* typeEntry = lookup_type_cache(attr[colIdx].atttypid, TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); m_sortOperators[i] = typeEntry->lt_opr; } @@ -227,7 +227,7 @@ void CStorePSort::PutTuple(Datum* values, bool* nulls) AutoContextSwitch memContextGuard(m_psortMemContext); - HeapTuple tuple = (HeapTuple)tableam_tops_form_tuple(m_tupDesc, values, nulls, HEAP_TUPLE); + HeapTuple tuple = (HeapTuple)tableam_tops_form_tuple(m_tupDesc, values, nulls); TupleTableSlot* slot = MakeSingleTupleTableSlot(m_tupDesc); diff --git a/src/gausskernel/storage/cstore/cstore_rewrite.cpp b/src/gausskernel/storage/cstore/cstore_rewrite.cpp index 2642f08b5..2ca26339f 100644 --- a/src/gausskernel/storage/cstore/cstore_rewrite.cpp +++ b/src/gausskernel/storage/cstore/cstore_rewrite.cpp @@ -440,7 +440,7 @@ void CStoreRewriter::RewriteColsData() // each col_id of cudesc for (int i = 0; i < nOldAttrs; i++) { // skip the droped column - if (unlikely(m_OldTupDesc->attrs[i]->attisdropped)) + if (unlikely(m_OldTupDesc->attrs[i].attisdropped)) continue; // explaination: key[0] --> col_id = 1 to natts @@ -537,7 +537,7 @@ void CStoreRewriter::RewriteColsData() // and the virtual-delete tuple into cudesc table. // for (int i = 0; i < nOldAttrs; ++i) { - if (m_OldTupDesc->attrs[i]->attisdropped || m_NewTupDesc->attrs[i]->attisdropped) + if (m_OldTupDesc->attrs[i].attisdropped || m_NewTupDesc->attrs[i].attisdropped) continue; if (!m_ColsRewriteFlag[i]) { @@ -638,7 +638,7 @@ void CStoreRewriter::AddColumnInitPhrase2(_in_ CStoreRewriteColumn* addColInfo, m_AddColsInfo[idx] = addColInfo; /* Min/Max functions for rough checking. */ - m_AddColsMinMaxFunc[idx] = GetMinMaxFunc(m_NewTupDesc->attrs[addColInfo->attrno - 1]->atttypid); + m_AddColsMinMaxFunc[idx] = GetMinMaxFunc(m_NewTupDesc->attrs[addColInfo->attrno - 1].atttypid); /* maybe different tablespace and relfilenode will be used, * so we create a new temp RelFileNode object. @@ -728,7 +728,7 @@ void CStoreRewriter::AddColumns(_in_ uint32 cuId, _in_ int rowsCntInCu, _in_ boo CStoreRewriteColumn* newColInfo = m_AddColsInfo[i]; Assert(newColInfo && newColInfo->isAdded && !newColInfo->isDropped); int attrIndex = newColInfo->attrno - 1; - Form_pg_attribute newColAttr = m_NewTupDesc->attrs[attrIndex]; + Form_pg_attribute newColAttr = &m_NewTupDesc->attrs[attrIndex]; CUDesc newColCudesc; newColCudesc.cu_id = cuId; @@ -949,7 +949,7 @@ void CStoreRewriter::SetDataTypeInitPhase2(_in_ CStoreRewriteColumn* sdtColInfo, m_SDTColsInfo[idx] = sdtColInfo; /* Min/Max functions for columns of changing data type. */ - m_SDTColsMinMaxFunc[idx] = GetMinMaxFunc(m_NewTupDesc->attrs[sdtColInfo->attrno - 1]->atttypid); + m_SDTColsMinMaxFunc[idx] = GetMinMaxFunc(m_NewTupDesc->attrs[sdtColInfo->attrno - 1].atttypid); CFileNode cFileNode(m_OldHeapRel->rd_node, (int)sdtColInfo->attrno, MAIN_FORKNUM); m_SDTColsReader[idx] = New(CurrentMemoryContext) CUStorage(cFileNode); @@ -1040,7 +1040,7 @@ void CStoreRewriter::HandleWholeDeletedCu( for (int i = 0; i < nRewriteCols; ++i) { InsertNewCudescTup( - &fullNullCudesc, RelationGetDescr(m_NewCudescRel), m_NewTupDesc->attrs[(rewriteColsInfo[i]->attrno - 1)]); + &fullNullCudesc, RelationGetDescr(m_NewCudescRel), &m_NewTupDesc->attrs[(rewriteColsInfo[i]->attrno - 1)]); } } @@ -1069,7 +1069,7 @@ void CStoreRewriter::SetDataType(_in_ uint32 cuId, _in_ HeapTuple* cudescTup, _i // deform the cudesc tuple and set old CUDesc object. CUDesc oldColCudesc; - CStore::DeformCudescTuple(cudescTup[attrIndex], cudescTupDesc, m_OldTupDesc->attrs[attrIndex], &oldColCudesc); + CStore::DeformCudescTuple(cudescTup[attrIndex], cudescTupDesc, &m_OldTupDesc->attrs[attrIndex], &oldColCudesc); Assert(oldColCudesc.cu_id == cuId); Assert(oldColCudesc.row_count == rowsCntInCu); @@ -1082,7 +1082,7 @@ void CStoreRewriter::SetDataType(_in_ uint32 cuId, _in_ HeapTuple* cudescTup, _i SetDataTypeHandleNormalCu(sdtIndex, delMaskDataPtr, &oldColCudesc, &newColCudesc); } - InsertNewCudescTup(&newColCudesc, RelationGetDescr(m_NewCudescRel), m_NewTupDesc->attrs[attrIndex]); + InsertNewCudescTup(&newColCudesc, RelationGetDescr(m_NewCudescRel), &m_NewTupDesc->attrs[attrIndex]); ResetExprContext(m_econtext); @@ -1122,8 +1122,8 @@ void CStoreRewriter::SetDataTypeHandleSameValCu( TupleTableSlot* fakeSlot = MakeSingleTupleTableSlot(m_OldTupDesc); int attrIndex = setDataTypeColInfo->attrno - 1; - Form_pg_attribute pColOldAttr = m_OldTupDesc->attrs[attrIndex]; - Form_pg_attribute pColNewAttr = m_NewTupDesc->attrs[attrIndex]; + Form_pg_attribute pColOldAttr = &m_OldTupDesc->attrs[attrIndex]; + Form_pg_attribute pColNewAttr = &m_NewTupDesc->attrs[attrIndex]; // limit the memory size used in running time. MemoryContext oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(m_estate)); @@ -1197,8 +1197,8 @@ void CStoreRewriter::SetDataTypeHandleNormalCu( TupleTableSlot* fakeSlot = MakeSingleTupleTableSlot(m_OldTupDesc); int attrIndex = setDataTypeColInfo->attrno - 1; - Form_pg_attribute pColOldAttr = m_OldTupDesc->attrs[attrIndex]; - Form_pg_attribute pColNewAttr = m_NewTupDesc->attrs[attrIndex]; + Form_pg_attribute pColOldAttr = &m_OldTupDesc->attrs[attrIndex]; + Form_pg_attribute pColNewAttr = &m_NewTupDesc->attrs[attrIndex]; /* the other fields will be set later. */ int rowsCntInCu = oldColCudesc->row_count; @@ -1730,7 +1730,7 @@ Oid CStoreSetTableSpaceForColumnData(Relation colRel, Oid targetTableSpace) int nattrs = RelationGetDescr(colRel)->natts; for (int i = 0; i < nattrs; ++i) { - Form_pg_attribute thisattr = RelationGetDescr(colRel)->attrs[i]; + Form_pg_attribute thisattr = &RelationGetDescr(colRel)->attrs[i]; if (!thisattr->attisdropped) { /* change tablespace for each column' data */ CStoreCopyColumnData(CUReplicationRel, colRel, thisattr->attnum); @@ -2013,7 +2013,7 @@ void ATExecCStoreMergePartition(Relation partTableRel, AlterTableCmd* cmd) CStoreInsert* cstoreOpt = NULL; CStoreScanDesc scan = NULL; int16* colIdx = NULL; - Form_pg_attribute* oldAttrs = NULL; + FormData_pg_attribute* oldAttrs = NULL; // Init CStore insertion. InsertArg args; @@ -2046,7 +2046,7 @@ void ATExecCStoreMergePartition(Relation partTableRel, AlterTableCmd* cmd) colIdx = (int16*)palloc0(sizeof(int16) * partedTableHeapDesc->natts); oldAttrs = partedTableHeapDesc->attrs; for (int i = 0; i < partedTableHeapDesc->natts; i++) - colIdx[i] = oldAttrs[i]->attnum; + colIdx[i] = oldAttrs[i].attnum; scan = CStoreBeginScan(srcPartRel, partedTableHeapDesc->natts, colIdx, SnapshotNow, true); /* scan and insert CU data */ diff --git a/src/gausskernel/storage/cstore/cstore_vector.cpp b/src/gausskernel/storage/cstore/cstore_vector.cpp index 8edc0f71c..c3f5e5a72 100644 --- a/src/gausskernel/storage/cstore/cstore_vector.cpp +++ b/src/gausskernel/storage/cstore/cstore_vector.cpp @@ -1312,13 +1312,13 @@ void bulkload_rows::init(TupleDesc tup_desc, int rows_maxnum) bulkload_memsize_increase(m_context, cur_size); bulkload_vector* vector = m_vectors; - Form_pg_attribute* attrs = tup_desc->attrs; + FormData_pg_attribute* attrs = tup_desc->attrs; m_has_dropped_column = false; for (int i = 0; i < attr_num; ++i) { - if ((*attrs)->attisdropped) + if ((*attrs).attisdropped) m_has_dropped_column = true; /* initialize each vector */ - vector->init(*attrs, rows_maxnum); + vector->init(attrs, rows_maxnum); /* compute the total memory size of all head blocks */ m_using_blocks_init_rawsize += vector->m_blocks.m_block_size; ++vector; @@ -1406,7 +1406,7 @@ bool bulkload_rows::append_one_tuple(Datum* values, const bool* isnull, TupleDes Assert(m_rows_curnum < m_rows_maxnum); bulkload_vector* vector = m_vectors; - Form_pg_attribute* attrs = tup_desc->attrs; + FormData_pg_attribute* attrs = tup_desc->attrs; /* append one tuple */ for (int attrIdx = 0; attrIdx < m_attr_num; ++attrIdx) { @@ -1415,7 +1415,7 @@ bool bulkload_rows::append_one_tuple(Datum* values, const bool* isnull, TupleDes vector->m_values_nulls.set_null(m_rows_curnum); } else { /* append this value into vector */ - Datum v = (vector->*(vector->m_append))(this, values[attrIdx], (*attrs)->attlen); + Datum v = (vector->*(vector->m_append))(this, values[attrIdx], (*attrs).attlen); /* compare for min/max values */ vector->m_minmax.m_compare(vector->m_minmax.m_min_buf, @@ -1509,7 +1509,7 @@ void bulkload_rows::append_one_column(Datum* values, const bool* isnull, int row if (dest_idx >= 0) { Assert(tup_desc); bulkload_vector* vector = m_vectors + dest_idx; - int attlen = tup_desc->attrs[dest_idx]->attlen; + int attlen = tup_desc->attrs[dest_idx].attlen; /* handle a batch of values for one attribute */ for (int rowCnt = 0; rowCnt < rows; ++rowCnt) { @@ -1555,12 +1555,12 @@ Size bulkload_rows::sample_tuple_size(TupleDesc tup_desc, VectorBatch* p_batch, { ScalarVector* scalar_vector = p_batch->m_arr; bulkload_vector* vector = m_vectors; - Form_pg_attribute* attrs = tup_desc->attrs; + FormData_pg_attribute* attrs = tup_desc->attrs; Size tup_size = 0; /* compute the sampling tuple' size */ for (int i = 0; i < tup_desc->natts; ++i) { - if (hasDroppedColumn && (*attrs)->attisdropped) { + if (hasDroppedColumn && (*attrs).attisdropped) { /* advance to the next attribute */ ++scalar_vector; ++vector; @@ -1568,16 +1568,16 @@ Size bulkload_rows::sample_tuple_size(TupleDesc tup_desc, VectorBatch* p_batch, continue; } - if ((*attrs)->attlen > 0) { + if ((*attrs).attlen > 0) { /* datum struct: len-B value */ - tup_size += (*attrs)->attlen; - } else if (!scalar_vector->IsNull(idx_sample) && (*attrs)->attlen == -1) { + tup_size += (*attrs).attlen; + } else if (!scalar_vector->IsNull(idx_sample) && (*attrs).attlen == -1) { /* datum struct: 4B var-header + varlen-B value */ - Assert((*attrs)->attlen == -1); + Assert((*attrs).attlen == -1); Datum v = (vector->*(vector->m_decode))(scalar_vector, idx_sample); tup_size += VARSIZE_ANY(DatumGetPointer(v)); - } else if (!scalar_vector->IsNull(idx_sample) && (*attrs)->attlen == -2) { - Assert((*attrs)->attlen == -2); + } else if (!scalar_vector->IsNull(idx_sample) && (*attrs).attlen == -2) { + Assert((*attrs).attlen == -2); Datum v = (vector->*(vector->m_decode))(scalar_vector, idx_sample); tup_size += strlen(DatumGetPointer(v)) + 1; } @@ -1599,26 +1599,26 @@ Size bulkload_rows::sample_tuple_size(TupleDesc tup_desc, VectorBatch* p_batch, */ Size bulkload_rows::calculate_tuple_size(TupleDesc tup_desc, Datum* tup_values, const bool* tup_nulls) const { - Form_pg_attribute* attrs = tup_desc->attrs; + FormData_pg_attribute* attrs = tup_desc->attrs; Size tup_size = 0; /* compute the sampling tuple' size */ for (int attrIdx = 0; attrIdx < tup_desc->natts; attrIdx++) { - if ((*attrs)->attisdropped) { + if ((*attrs).attisdropped) { /* advance to the next attribute */ ++attrs; continue; } - if ((*attrs)->attlen > 0) { + if ((*attrs).attlen > 0) { /* datum struct: len-B value */ - tup_size += (*attrs)->attlen; - } else if (!tup_nulls[attrIdx] && (*attrs)->attlen == -1) { + tup_size += (*attrs).attlen; + } else if (!tup_nulls[attrIdx] && (*attrs).attlen == -1) { /* datum struct: 4B var-header + varlen-B value */ - Assert((*attrs)->attlen == -1); + Assert((*attrs).attlen == -1); tup_size += VARSIZE_ANY(DatumGetPointer(tup_values[attrIdx])); - } else if (!tup_nulls[attrIdx] && (*attrs)->attlen == -2) { - Assert((*attrs)->attlen == -2); + } else if (!tup_nulls[attrIdx] && (*attrs).attlen == -2) { + Assert((*attrs).attlen == -2); tup_size += strlen(DatumGetPointer(tup_values[attrIdx])) + 1; } /* advance to the next attribute */ @@ -1654,7 +1654,7 @@ bool bulkload_rows::append_in_row_orientation(TupleDesc tup_desc, VectorBatch* p while (row_count < maxRows) { ScalarVector* scalar_vector = p_batch->m_arr; bulkload_vector* vector = m_vectors; - Form_pg_attribute* attrs = tup_desc->attrs; + FormData_pg_attribute* attrs = tup_desc->attrs; Size tuple_size = (this->*m_form_sample_tuple_size_func)(tup_desc, p_batch, srcRowIdx); if ((BULKLOAD_MAX_MEMSIZE - m_using_blocks_total_rawsize) < tuple_size) { @@ -1669,7 +1669,7 @@ bool bulkload_rows::append_in_row_orientation(TupleDesc tup_desc, VectorBatch* p Datum vector_value = (vector->*(vector->m_decode))(scalar_vector, srcRowIdx); /* append this value into vector */ - vector_value = (vector->*(vector->m_append))(this, vector_value, (*attrs)->attlen); + vector_value = (vector->*(vector->m_append))(this, vector_value, (*attrs).attlen); /* compare for min/max values */ vector->m_minmax.m_compare(vector->m_minmax.m_min_buf, @@ -1725,10 +1725,10 @@ bool bulkload_rows::append_in_column_orientation(TupleDesc tup_desc, VectorBatch ScalarVector* scalar_vector = p_batch->m_arr; bulkload_vector* vector = m_vectors; - Form_pg_attribute* attrs = tup_desc->attrs; + FormData_pg_attribute* attrs = tup_desc->attrs; for (int attrIdx = 0; attrIdx < nattrs; ++attrIdx) { - if (hasDroppedColumn && (*attrs)->attisdropped) { + if (hasDroppedColumn && (*attrs).attisdropped) { /* advance to the next attribute */ /* for droped columns, set all null */ int destRowIdx = m_rows_curnum; @@ -1753,7 +1753,7 @@ bool bulkload_rows::append_in_column_orientation(TupleDesc tup_desc, VectorBatch Datum value = (vector->*(vector->m_decode))(scalar_vector, srcRowIdx); /* append this value into vector */ - value = (vector->*(vector->m_append))(this, value, (*attrs)->attlen); + value = (vector->*(vector->m_append))(this, value, (*attrs).attlen); /* compare for min/max values */ vector->m_minmax.m_compare(vector->m_minmax.m_min_buf, diff --git a/src/gausskernel/storage/ipc/procarray.cpp b/src/gausskernel/storage/ipc/procarray.cpp index df7bc62f5..1cf7591ec 100755 --- a/src/gausskernel/storage/ipc/procarray.cpp +++ b/src/gausskernel/storage/ipc/procarray.cpp @@ -2314,7 +2314,7 @@ Datum pg_get_running_xacts(PG_FUNCTION_ARGS) /* build tupdesc for result tuples */ /* this had better match pg_prepared_xacts view in system_views.sql */ - tupdesc = CreateTemplateTupleDesc(10, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(10, false); TupleDescInitEntry(tupdesc, (AttrNumber)1, "handle", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)2, "gxid", XIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)3, "state", INT1OID, -1, 0); diff --git a/src/gausskernel/storage/mot/fdw_adapter/mot_fdw.cpp b/src/gausskernel/storage/mot/fdw_adapter/mot_fdw.cpp index 949676ce7..0eb0dadb3 100644 --- a/src/gausskernel/storage/mot/fdw_adapter/mot_fdw.cpp +++ b/src/gausskernel/storage/mot/fdw_adapter/mot_fdw.cpp @@ -440,8 +440,8 @@ static void MOTGetForeignRelSize(PlannerInfo* root, RelOptInfo* baserel, Oid for if (needWholeRow) { for (int i = 0; i < desc->natts; i++) { - if (!desc->attrs[i]->attisdropped) { - BITMAP_SET(planstate->m_attrsUsed, (desc->attrs[i]->attnum - 1)); + if (!desc->attrs[i].attisdropped) { + BITMAP_SET(planstate->m_attrsUsed, (desc->attrs[i].attnum - 1)); } } } else { @@ -450,8 +450,8 @@ static void MOTGetForeignRelSize(PlannerInfo* root, RelOptInfo* baserel, Oid for if (attrs != NULL) { bool all = bms_is_member(-FirstLowInvalidHeapAttributeNumber, attrs); for (int i = 0; i < planstate->m_numAttrs; i++) { - if (all || bms_is_member(desc->attrs[i]->attnum - FirstLowInvalidHeapAttributeNumber, attrs)) { - BITMAP_SET(planstate->m_attrsUsed, (desc->attrs[i]->attnum - 1)); + if (all || bms_is_member(desc->attrs[i].attnum - FirstLowInvalidHeapAttributeNumber, attrs)) { + BITMAP_SET(planstate->m_attrsUsed, (desc->attrs[i].attnum - 1)); } } } @@ -1278,8 +1278,8 @@ static int MOTAcquireSampleRowsFunc(Relation relation, int elevel, HeapTuple* ro MOT::Row* row = nullptr; for (int i = 0; i < desc->natts; i++) { - if (!desc->attrs[i]->attisdropped) { - BITMAP_SET(attrsUsed, (desc->attrs[i]->attnum - 1)); + if (!desc->attrs[i].attisdropped) { + BITMAP_SET(attrsUsed, (desc->attrs[i].attnum - 1)); } } @@ -1386,17 +1386,17 @@ static void PrepareAttributeList(ModifyTable* plan, RangeTblEntry* rte, Relation switch (plan->operation) { case CMD_INSERT: { for (int i = 0; i < desc->natts; i++) { - if (!desc->attrs[i]->attisdropped) { - BITMAP_SET(ptrAttrsModify, (desc->attrs[i]->attnum - 1)); + if (!desc->attrs[i].attisdropped) { + BITMAP_SET(ptrAttrsModify, (desc->attrs[i].attnum - 1)); } } break; } case CMD_UPDATE: { for (int i = 0; i < desc->natts; i++) { - if (bms_is_member(desc->attrs[i]->attnum - FirstLowInvalidHeapAttributeNumber, rte->updatedCols)) { - if (MOTAdaptor::IsColumnIndexed(desc->attrs[i]->attnum, table)) { - if (table->GetPrimaryIndex()->IsFieldPresent(desc->attrs[i]->attnum)) { + if (bms_is_member(desc->attrs[i].attnum - FirstLowInvalidHeapAttributeNumber, rte->updatedCols)) { + if (MOTAdaptor::IsColumnIndexed(desc->attrs[i].attnum, table)) { + if (table->GetPrimaryIndex()->IsFieldPresent(desc->attrs[i].attnum)) { ixUpd = MOT::UpdateIndexColumnType::UPDATE_COLUMN_PRIMARY; ereport(ERROR, (errcode(ERRCODE_FDW_UPDATE_INDEXED_FIELD_NOT_SUPPORTED), @@ -1406,7 +1406,7 @@ static void PrepareAttributeList(ModifyTable* plan, RangeTblEntry* rte, Relation ixUpd = MOT::UpdateIndexColumnType::UPDATE_COLUMN_SECONDARY; } } - BITMAP_SET(ptrAttrsModify, (desc->attrs[i]->attnum - 1)); + BITMAP_SET(ptrAttrsModify, (desc->attrs[i].attnum - 1)); } } if (fdwState != nullptr) { @@ -1417,8 +1417,8 @@ static void PrepareAttributeList(ModifyTable* plan, RangeTblEntry* rte, Relation case CMD_DELETE: { if (list_length(plan->returningLists) > 0) { for (int i = 0; i < desc->natts; i++) { - if (!desc->attrs[i]->attisdropped) { - BITMAP_SET(ptrAttrsModify, (desc->attrs[i]->attnum - 1)); + if (!desc->attrs[i].attisdropped) { + BITMAP_SET(ptrAttrsModify, (desc->attrs[i].attnum - 1)); } } } diff --git a/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp b/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp index 2ffad8b0a..dbcd5a529 100644 --- a/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp +++ b/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp @@ -1861,7 +1861,7 @@ void MOTAdaptor::CreateKeyBuffer(Relation rel, MOTFdwStateSt* festate, int start DatumToMOTKey(col, expr->resultType, val, - desc->attrs[orgCols[i] - 1]->atttypid, + desc->attrs[orgCols[i] - 1].atttypid, buf + offset, fieldLengths[i], opers[i], @@ -1943,7 +1943,7 @@ void MOTAdaptor::PackRow(TupleTableSlot* slot, MOT::Table* table, uint8_t* attrs Datum value = heap_slot_getattr(slot, j, &isnull); if (!isnull) { - DatumToMOT(table->GetField(j), value, tupdesc->attrs[i]->atttypid, destRow); + DatumToMOT(table->GetField(j), value, tupdesc->attrs[i].atttypid, destRow); } } } @@ -1966,7 +1966,7 @@ void MOTAdaptor::PackUpdateRow(TupleTableSlot* slot, MOT::Table* table, const ui Datum value = heap_slot_getattr(slot, j, &isnull); if (!isnull) { - DatumToMOT(table->GetField(j), value, tupdesc->attrs[i]->atttypid, destRow); + DatumToMOT(table->GetField(j), value, tupdesc->attrs[i].atttypid, destRow); BITMAP_SET(bits, i); } else { BITMAP_CLEAR(bits, i); @@ -1986,7 +1986,7 @@ void MOTAdaptor::UnpackRow(TupleTableSlot* slot, MOT::Table* table, const uint8_ for (; i < cols; i++) { if (BITMAP_GET(attrs_used, i)) { - MOTToDatum(table, tupdesc->attrs[i], srcRow, &(slot->tts_values[i]), &(slot->tts_isnull[i])); + MOTToDatum(table, &tupdesc->attrs[i], srcRow, &(slot->tts_values[i]), &(slot->tts_isnull[i])); } else { slot->tts_isnull[i] = true; slot->tts_values[i] = PointerGetDatum(nullptr); diff --git a/src/gausskernel/storage/mot/jit_exec/jit_context.cpp b/src/gausskernel/storage/mot/jit_exec/jit_context.cpp index 8e5b54592..dbdcbb402 100644 --- a/src/gausskernel/storage/mot/jit_exec/jit_context.cpp +++ b/src/gausskernel/storage/mot/jit_exec/jit_context.cpp @@ -1462,7 +1462,7 @@ static bool PrepareCallSite( } for (uint32_t i = 0; i < attrCount; ++i) { PLpgSQL_type* typeDesc = &execState->m_resultTypes[i]; - Form_pg_attribute attr = execState->m_resultSlot->tts_tupleDescriptor->attrs[i]; + Form_pg_attribute attr = &execState->m_resultSlot->tts_tupleDescriptor->attrs[i]; GetTypeDescriptor(typeDesc, attr); } } diff --git a/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp b/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp index 33e7f60a5..570ce6018 100644 --- a/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp +++ b/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp @@ -1581,13 +1581,13 @@ static void CopyTupleTableSlot(TupleTableSlot* tuple) TupleDesc tupDesc = tuple->tts_tupleDescriptor; for (int i = 0; i < tupDesc->natts; ++i) { // skip dropped columns in destination - if (tupDesc->attrs[i]->attisdropped) { + if (tupDesc->attrs[i].attisdropped) { continue; } bool isNull = tuple->tts_isnull[i]; Datum value = tuple->tts_values[i]; - Oid type = tuple->tts_tupleDescriptor->attrs[i]->atttypid; + Oid type = tuple->tts_tupleDescriptor->attrs[i].atttypid; // perform proper type conversion as in exec_assign_value() at pl_exec.cpp MOT_LOG_DEBUG("CopyTupleTableSlot(): Copying datum %d of type %u", i, type); diff --git a/src/gausskernel/storage/mot/jit_exec/jit_helpers.cpp b/src/gausskernel/storage/mot/jit_exec/jit_helpers.cpp index f882adb73..8d25999d5 100644 --- a/src/gausskernel/storage/mot/jit_exec/jit_helpers.cpp +++ b/src/gausskernel/storage/mot/jit_exec/jit_helpers.cpp @@ -1190,9 +1190,9 @@ struct SelectRowFunctor { inline void operator()() { uint8_t* rowData = const_cast(m_row->GetData()); - m_slot->tts_tupleDescriptor->attrs[m_tupleColumnId]->attnum = m_tableColumnId; + m_slot->tts_tupleDescriptor->attrs[m_tupleColumnId].attnum = m_tableColumnId; MOTAdaptor::MOTToDatum(m_table, - m_slot->tts_tupleDescriptor->attrs[m_tupleColumnId], + &m_slot->tts_tupleDescriptor->attrs[m_tupleColumnId], rowData, &(m_slot->tts_values[m_tupleColumnId]), &(m_slot->tts_isnull[m_tupleColumnId])); @@ -1208,14 +1208,14 @@ void selectColumn(MOT::Table* table, MOT::Row* row, TupleTableSlot* slot, int ta table_colid, table->GetFieldName(table_colid)); uint8_t* rowData = const_cast(row->GetData()); - slot->tts_tupleDescriptor->attrs[tuple_colid]->attnum = table_colid; + slot->tts_tupleDescriptor->attrs[tuple_colid].attnum = table_colid; MOTAdaptor::MOTToDatum(table, - slot->tts_tupleDescriptor->attrs[tuple_colid], + &slot->tts_tupleDescriptor->attrs[tuple_colid], rowData, &(slot->tts_values[tuple_colid]), &(slot->tts_isnull[tuple_colid])); DEBUG_PRINT_DATUM("Column Datum", - slot->tts_tupleDescriptor->attrs[tuple_colid]->atttypid, + slot->tts_tupleDescriptor->attrs[tuple_colid].atttypid, slot->tts_values[tuple_colid], slot->tts_isnull[tuple_colid]); } @@ -2138,7 +2138,7 @@ Datum readTupleDatum(TupleTableSlot* slot, int tuple_colid) MOT_LOG_DEBUG("Reading datum from tuple column %d ", tuple_colid); Datum result = slot->tts_values[tuple_colid]; DEBUG_PRINT_DATUM("Pre-sum Tuple Datum", - slot->tts_tupleDescriptor->attrs[tuple_colid]->atttypid, + slot->tts_tupleDescriptor->attrs[tuple_colid].atttypid, slot->tts_values[tuple_colid], slot->tts_isnull[tuple_colid]); bool isnull = (result == PointerGetDatum(NULL)); @@ -2152,7 +2152,7 @@ void writeTupleDatum(TupleTableSlot* slot, int tuple_colid, Datum datum, int isn slot->tts_values[tuple_colid] = datum; slot->tts_isnull[tuple_colid] = isnull; DEBUG_PRINT_DATUM("Post-sum Tuple Datum", - slot->tts_tupleDescriptor->attrs[tuple_colid]->atttypid, + slot->tts_tupleDescriptor->attrs[tuple_colid].atttypid, slot->tts_values[tuple_colid], slot->tts_isnull[tuple_colid]); } @@ -2599,13 +2599,13 @@ static bool CopyHeapTupleHeader(HeapTupleHeader tupleHeader, TupleTableSlot* slo int resultIndex = 0; for (int i = 0; i < tupDescAttrCount; ++i) { // skip dropped columns in destination - if (tupDesc->attrs[i]->attisdropped) { + if (tupDesc->attrs[i].attisdropped) { continue; } bool isNull = true; Datum value = (Datum)0; - if ((i < tupleAttrCount) && !tupDesc->attrs[i]->attisdropped) { + if ((i < tupleAttrCount) && !tupDesc->attrs[i].attisdropped) { value = SPI_getbinval(tuple, tupDesc, i + 1, &isNull); if (SPI_result != 0) { MOT_LOG_TRACE( @@ -2736,7 +2736,7 @@ int InvokeStoredProcedure() int IsCompositeResult(TupleTableSlot* slot) { int res = 0; - if ((slot->tts_tupleDescriptor->natts == 1) && slot->tts_tupleDescriptor->attrs[0]->atttypid == RECORDOID) { + if ((slot->tts_tupleDescriptor->natts == 1) && slot->tts_tupleDescriptor->attrs[0].atttypid == RECORDOID) { res = 1; } MOT_LOG_DEBUG("Result is composite: %d", res); @@ -3309,13 +3309,13 @@ static bool CopyHeapTuple( int resultIndex = 0; for (int i = 0; i < tupleDescAttrCount; ++i) { // skip dropped columns in destination - if (tupleDesc->attrs[i]->attisdropped) { + if (tupleDesc->attrs[i].attisdropped) { continue; } bool isNull = true; Datum value = (Datum)0; - if ((i < tupleAttrCount) && !tupleDesc->attrs[i]->attisdropped) { + if ((i < tupleAttrCount) && !tupleDesc->attrs[i].attisdropped) { value = SPI_getbinval(tuple, tupleDesc, i + 1, &isNull); if (SPI_result != 0) { MOT_LOG_TRACE( @@ -3364,13 +3364,13 @@ static void CopyTupleTableSlot(JitExec::JitInvokedQueryExecState* invokeExecStat int resultIndex = 0; for (int i = 0; i < tupDesc->natts; ++i) { // skip dropped columns in destination - if (tupDesc->attrs[i]->attisdropped) { + if (tupDesc->attrs[i].attisdropped) { continue; } bool isNull = tuple->tts_isnull[i]; Datum value = tuple->tts_values[i]; - Oid type = tuple->tts_tupleDescriptor->attrs[i]->atttypid; + Oid type = tuple->tts_tupleDescriptor->attrs[i].atttypid; // perform proper type conversion as in exec_assign_value() at pl_exec.cpp PLpgSQL_type* resultType = &invokeExecState->m_resultTypes[resultIndex]; @@ -3438,7 +3438,7 @@ static void PrintResultSlot(TupleTableSlot* resultSlot) MOT_LOG_BEGIN(MOT::LogLevel::LL_DEBUG, "Query result slot:"); for (int i = 0; i < resultSlot->tts_tupleDescriptor->natts; ++i) { MOT_LOG_APPEND(MOT::LogLevel::LL_DEBUG, "Datum[%d]: ", i); - Oid type = resultSlot->tts_tupleDescriptor->attrs[i]->atttypid; + Oid type = resultSlot->tts_tupleDescriptor->attrs[i].atttypid; JitExec::PrintDatum(MOT::LogLevel::LL_DEBUG, type, resultSlot->tts_values[i], resultSlot->tts_isnull[i]); MOT_LOG_APPEND(MOT::LogLevel::LL_DEBUG, "\n"); } diff --git a/src/gausskernel/storage/mot/jit_exec/jit_llvm_sp.cpp b/src/gausskernel/storage/mot/jit_exec/jit_llvm_sp.cpp index d3fa6b024..00d403ebd 100644 --- a/src/gausskernel/storage/mot/jit_exec/jit_llvm_sp.cpp +++ b/src/gausskernel/storage/mot/jit_exec/jit_llvm_sp.cpp @@ -5105,7 +5105,7 @@ static bool IsSubQueryResultComposite(JitLlvmFunctionCodeGenContext* ctx, int su bool result = false; if (subQueryId < ctx->m_plan->_query_count) { JitCallSitePlan* callSitePlan = &ctx->m_plan->m_callSitePlanList[subQueryId]; - if ((callSitePlan->m_tupDesc->natts == 1) && (callSitePlan->m_tupDesc->attrs[0]->atttypid == RECORDOID)) { + if ((callSitePlan->m_tupDesc->natts == 1) && (callSitePlan->m_tupDesc->attrs[0].atttypid == RECORDOID)) { result = true; } } @@ -5217,7 +5217,7 @@ static bool ProcessStatementExecSql(JitLlvmFunctionCodeGenContext* ctx, PLpgSQL_ break; } JitCallSitePlan* callSitePlan = &ctx->m_plan->m_callSitePlanList[subQueryId]; - Oid slotType = callSitePlan->m_tupDesc->attrs[i]->atttypid; + Oid slotType = callSitePlan->m_tupDesc->attrs[i].atttypid; if (!AssignScalarValue( ctx, (PLpgSQL_var*)target, resultVar, resultIsNullVar, slotValue, isNullValue, slotType)) { MOT_LOG_TRACE("Failed to assign scalar value form sub-query"); diff --git a/src/gausskernel/storage/page/pagecompress.cpp b/src/gausskernel/storage/page/pagecompress.cpp index 8433caea9..b22f3e06b 100644 --- a/src/gausskernel/storage/page/pagecompress.cpp +++ b/src/gausskernel/storage/page/pagecompress.cpp @@ -109,7 +109,7 @@ static uint32 getBitsOfDelta(uint64 delta) #define isToastTuple(_tup) (HeapTupleHasExternal(_tup) || (_tup)->t_len > TOAST_TUPLE_THRESHOLD) /* judge whether this attribute is dropped */ -#define isAttrDropped(_attr) (InvalidOid == ((_attr)->atttypid)) +#define isAttrDropped(_attr) (InvalidOid == ((_attr).atttypid)) /* one data repeats at least such times so that it will be added into dict. */ #define DICTITEM_MIN_REPEATS 3 @@ -421,9 +421,9 @@ PageCompress::PageCompress(Relation rel, MemoryContext memCtx) (void)MemoryContextSwitchTo(oldMemCnxt); - Form_pg_attribute* attrs = m_rel->rd_att->attrs; + FormData_pg_attribute* attrs = m_rel->rd_att->attrs; for (int col = 0; col < nattrs; ++col) { - m_numTypeOpt[col] = binarySearch(attrs[col]->atttypid); + m_numTypeOpt[col] = binarySearch(attrs[col].atttypid); } #ifdef TRACE_COMPRESS @@ -847,7 +847,7 @@ Datum PageCompress::PrefixUncompress(int attlen, PrefixCmprMeta* prefix, char* s */ void PageCompress::ChooseMethodForFixedLenType(ColArray* colArray, int col) { - int hintMode = m_rel->rd_att->attrs[col]->attcmprmode; + int hintMode = m_rel->rd_att->attrs[col].attcmprmode; /* first, try to use the user's hint */ if (SetCmprMethod(colArray, col, hintMode)) @@ -1010,7 +1010,7 @@ bool PageCompress::NumstrEvaluate(ColArray* colArray) */ void PageCompress::ChooseMethodForVaryLenType(ColArray* colArray, int col) { - int hintMode = m_rel->rd_att->attrs[col]->attcmprmode; + int hintMode = m_rel->rd_att->attrs[col].attcmprmode; /* first, try to use the user's hint */ if (SetCmprMethod(colArray, col, hintMode)) @@ -1041,8 +1041,8 @@ void PageCompress::ChooseMethodForVaryLenType(ColArray* colArray, int col) */ bool PageCompress::SetCmprMethod(ColArray* colArray, int col, int mode) { - Form_pg_attribute* attrs = m_rel->rd_att->attrs; - int attlen = attrs[col]->attlen; + FormData_pg_attribute* attrs = m_rel->rd_att->attrs; + int attlen = attrs[col].attlen; switch (mode) { case CMPR_DELTA: { @@ -1135,11 +1135,11 @@ bool PageCompress::SetCmprMethod(ColArray* colArray, int col, int mode) void PageCompress::ChooseCmprMethod(ColArray* colArrays) { int attrNum = RelationGetNumberOfAttributes(m_rel); - Form_pg_attribute* attrs = m_rel->rd_att->attrs; + FormData_pg_attribute* attrs = m_rel->rd_att->attrs; for (int col = 0; col < attrNum; ++col) { /* continue if this attribute shouldn't be compressed specified by user; */ - if (CMPR_NONE == attrs[col]->attcmprmode) + if (CMPR_NONE == attrs[col].attcmprmode) continue; /* continue if this attribute is dropped by user */ @@ -1148,13 +1148,13 @@ void PageCompress::ChooseCmprMethod(ColArray* colArrays) continue; } if (m_numTypeOpt[col] != NULL) { - Assert(attrs[col]->attlen > 1); + Assert(attrs[col].attlen > 1); ChooseMethodForFixedLenType(colArrays + col, col); - } else if (attrs[col]->attlen > 0) { + } else if (attrs[col].attlen > 0) { /* These types are not compressed. */ (void)SetCmprMethod(colArrays + col, col, CMPR_NONE); } else { - Assert(attrs[col]->attlen == -1 || attrs[col]->attlen == -2); + Assert(attrs[col].attlen == -1 || attrs[col].attlen == -2); ChooseMethodForVaryLenType(colArrays + col, col); } } @@ -1162,7 +1162,7 @@ void PageCompress::ChooseCmprMethod(ColArray* colArrays) void PageCompress::SetCmprHeaderData(void) { - Form_pg_attribute* atts = RelationGetDescr(m_rel)->attrs; + FormData_pg_attribute* atts = RelationGetDescr(m_rel)->attrs; int nattrs = RelationGetNumberOfAttributes(m_rel); int offset = 0; int rawCols = 0; @@ -1174,7 +1174,7 @@ void PageCompress::SetCmprHeaderData(void) switch (m_cmprMode[col]) { case CMPR_DELTA: { DeltaCmprMeta* deltaInfo = (DeltaCmprMeta*)m_cmprMeta[col]; - int attrLen = atts[col]->attlen; + int attrLen = atts[col].attlen; Assert(deltaInfo->bytes < g_number_max_value_in_bytes); Assert(attrLen > 0); @@ -1198,7 +1198,7 @@ void PageCompress::SetCmprHeaderData(void) } case CMPR_PREFIX: { - Assert(-2 == atts[col]->attlen || -1 == atts[col]->attlen); + Assert(-2 == atts[col].attlen || -1 == atts[col].attlen); PrefixCmprMeta* prefixInfo = (PrefixCmprMeta*)m_cmprMeta[col]; Assert(prefixInfo->len > 0 && prefixInfo->len < MAX_PREFIX_LEN); /* how many bytes is used for prefix string */ @@ -1461,7 +1461,7 @@ Datum PageCompress::UncompressOneAttr( bool PageCompress::DictCompress(int col, Datum val, unsigned char& dicItemId) { bool found = false; - int attlen = m_rel->rd_att->attrs[col]->attlen; + int attlen = m_rel->rd_att->attrs[col].attlen; DictCmprMeta* dicInfo = (DictCmprMeta*)m_cmprMeta[col]; DictItemData key; @@ -1491,7 +1491,7 @@ void PageCompress::CompressOneAttr(Datum val, bool null, FormCmprTupleData* form return; } - Form_pg_attribute* attrs = m_rel->rd_att->attrs; + FormData_pg_attribute* attrs = m_rel->rd_att->attrs; formTuple->values[col] = val; formTuple->isnulls[col] = false; @@ -1537,7 +1537,7 @@ void PageCompress::CompressOneAttr(Datum val, bool null, FormCmprTupleData* form } case CMPR_PREFIX: { - int attrLen = attrs[col]->attlen; + int attrLen = attrs[col].attlen; Assert(attrLen == -1 || attrLen == -2); PrefixCmprMeta* prefixInfo = (PrefixCmprMeta*)m_cmprMeta[col]; Datum cmprsVal; @@ -1566,7 +1566,7 @@ void PageCompress::CompressOneAttr(Datum val, bool null, FormCmprTupleData* form } case CMPR_NUMSTR: { - int attrLen = attrs[col]->attlen; + int attrLen = attrs[col].attlen; Assert(-1 == attrLen || -2 == attrLen); int outSize = 0; @@ -1699,7 +1699,7 @@ bool PageCompress::CompressOnePage(void) * or all compressed tuples fill part of one page. */ if (hascmpr) { - fillOnePage = Dispatch(m_mappedTups[row], (HeapTuple)tableam_tops_form_cmprs_tuple(desc, &formTupleData, HEAP_TUPLE), size, blksize); + fillOnePage = Dispatch(m_mappedTups[row], (HeapTuple)tableam_tops_form_cmprs_tuple(desc, &formTupleData, TableAmHeap), size, blksize); } else { fillOnePage = Dispatch(m_mappedTups[row], size, blksize); } @@ -1746,7 +1746,7 @@ bool PageCompress::CompressOnePage(void) } if (hascmpr) { - fillOnePage = Dispatch(raw, (HeapTuple)tableam_tops_form_cmprs_tuple(desc, &formTupleData, HEAP_TUPLE), size, blksize); + fillOnePage = Dispatch(raw, (HeapTuple)tableam_tops_form_cmprs_tuple(desc, &formTupleData, TableAmHeap), size, blksize); } else { fillOnePage = Dispatch(raw, size, blksize); } @@ -2218,24 +2218,24 @@ void PageCompress::CheckCmprAttr(Datum rawVal, bool rawNull, int col, FormCmprTu } Assert(m_cmprMode[col] != CMPR_UNDEF); - Form_pg_attribute* atts = RelationGetDescr(m_rel)->attrs; - Assert(1 != atts[col]->attlen); + FormData_pg_attribute* atts = RelationGetDescr(m_rel)->attrs; + Assert(1 != atts[col].attlen); int cmprSize; Datum value = UncompressOneAttr(m_cmprMode[col], m_cmprMeta[col], - atts[col]->atttypid, - atts[col]->attlen, + atts[col].atttypid, + atts[col].attlen, DatumGetPointer(formTuple->values[col]), &cmprSize); Assert(cmprSize == formTuple->valsize[col]); - CheckCmprDatum(rawVal, value, atts[col]); + CheckCmprDatum(rawVal, value, &atts[col]); } void PageCompress::CheckCmprTuple(HeapTuple rawTup, HeapTuple cmprTup) { TupleDesc desc = RelationGetDescr(m_rel); - Form_pg_attribute* atts = desc->attrs; + FormData_pg_attribute* atts = desc->attrs; int nattrs = desc->natts; Datum* values = (Datum*)palloc(sizeof(Datum) * nattrs); @@ -2254,7 +2254,7 @@ void PageCompress::CheckCmprTuple(HeapTuple rawTup, HeapTuple cmprTup) continue; } - CheckCmprDatum(values[col], values2[col], atts[col]); + CheckCmprDatum(values[col], values2[col], &atts[col]); } pfree(values); @@ -2269,7 +2269,7 @@ void PageCompress::CheckCmprHeaderData(void) return; } - Form_pg_attribute* atts = RelationGetDescr(m_rel)->attrs; + FormData_pg_attribute* atts = RelationGetDescr(m_rel)->attrs; int nattrs = RelationGetNumberOfAttributes(m_rel); int cmprsOff = 0; /* pointer to the start of compression meta */ void* metaInfo = NULL; @@ -2277,7 +2277,7 @@ void PageCompress::CheckCmprHeaderData(void) for (int col = 0; col < nattrs; ++col) { int metaSize = 0; - metaInfo = PageCompress::FetchAttrCmprMeta(m_cmprHeaderData + cmprsOff, atts[col]->attlen, &metaSize, &mode); + metaInfo = PageCompress::FetchAttrCmprMeta(m_cmprHeaderData + cmprsOff, atts[col].attlen, &metaSize, &mode); cmprsOff += metaSize; Assert(mode != CMPR_UNDEF && m_cmprMode[col] == mode); diff --git a/src/gausskernel/storage/remote/remote_adapter.cpp b/src/gausskernel/storage/remote/remote_adapter.cpp index 54a0b80c6..0370a0321 100755 --- a/src/gausskernel/storage/remote/remote_adapter.cpp +++ b/src/gausskernel/storage/remote/remote_adapter.cpp @@ -428,7 +428,7 @@ Datum gs_read_file_from_remote(PG_FUNCTION_ARGS) current_lsn = GetXLogInsertRecPtr(); } - tupdesc = CreateTemplateTupleDesc(RES_COL_NUM, false, TAM_HEAP); + tupdesc = CreateTemplateTupleDesc(RES_COL_NUM, false); parano = 1; TupleDescInitEntry(tupdesc, (AttrNumber)parano++, "file", BYTEAOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber)parano++, "lsn", XIDOID, -1, 0); diff --git a/src/gausskernel/storage/replication/logical/parallel_decode.cpp b/src/gausskernel/storage/replication/logical/parallel_decode.cpp index 9715c5b07..a3707fd3e 100644 --- a/src/gausskernel/storage/replication/logical/parallel_decode.cpp +++ b/src/gausskernel/storage/replication/logical/parallel_decode.cpp @@ -88,7 +88,7 @@ void tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool Datum origval; /* possibly toasted Datum */ bool isnull = true; /* column is null? */ - attr = tupdesc->attrs[natt]; + attr = &tupdesc->attrs[natt]; if (attr->attisdropped || attr->attnum < 0) continue; @@ -293,7 +293,7 @@ static void TupleToJsoninfo( /* print all columns individually */ for (int natt = 0; natt < tupdesc->natts; natt++) { - 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; } @@ -489,7 +489,7 @@ static void AppendTuple(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool s uint16 attrNum = 0; pq_sendint16(s, (uint16)(tupdesc->natts)); for (int natt = 0; natt < tupdesc->natts; natt++) { - Form_pg_attribute attr = tupdesc->attrs[natt]; + Form_pg_attribute attr = &tupdesc->attrs[natt]; if (attr->attisdropped || attr->attnum < 0) { continue; } diff --git a/src/gausskernel/storage/replication/logical/parallel_reorderbuffer.cpp b/src/gausskernel/storage/replication/logical/parallel_reorderbuffer.cpp index 35f4f5b0a..c8a1cc6ac 100644 --- a/src/gausskernel/storage/replication/logical/parallel_reorderbuffer.cpp +++ b/src/gausskernel/storage/replication/logical/parallel_reorderbuffer.cpp @@ -503,7 +503,7 @@ void ToastTupleSplicing(Datum *attrs, TupleDesc desc, bool *isnull, TupleDesc to const int toast_index = 3; /* toast index in tuple is 3 */ for (natt = 0; natt < desc->natts; natt++) { - Form_pg_attribute attr = desc->attrs[natt]; + Form_pg_attribute attr = &desc->attrs[natt]; ReorderBufferToastEnt *ent = NULL; struct varlena *varlena = NULL; diff --git a/src/gausskernel/storage/replication/logical/proto.cpp b/src/gausskernel/storage/replication/logical/proto.cpp index 45c4df86a..a75b3b16b 100644 --- a/src/gausskernel/storage/replication/logical/proto.cpp +++ b/src/gausskernel/storage/replication/logical/proto.cpp @@ -360,7 +360,7 @@ static void logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple desc = RelationGetDescr(rel); for (i = 0; i < desc->natts; i++) { - if (desc->attrs[i]->attisdropped || GetGeneratedCol(desc, i)) + if (desc->attrs[i].attisdropped || GetGeneratedCol(desc, i)) continue; nliveatts++; } @@ -375,7 +375,7 @@ static void logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple for (i = 0; i < desc->natts; i++) { HeapTuple typtup; Form_pg_type typclass; - Form_pg_attribute att = desc->attrs[i]; + Form_pg_attribute att = &desc->attrs[i]; /* skip dropped columns */ if (att->attisdropped || GetGeneratedCol(desc, i)) { @@ -499,7 +499,7 @@ static void logicalrep_write_attrs(StringInfo out, Relation rel) /* send number of live attributes */ for (i = 0; i < desc->natts; i++) { - if (desc->attrs[i]->attisdropped || GetGeneratedCol(desc, i)) + if (desc->attrs[i].attisdropped || GetGeneratedCol(desc, i)) continue; nliveatts++; } @@ -512,7 +512,7 @@ static void logicalrep_write_attrs(StringInfo out, Relation rel) /* send the attributes */ for (i = 0; i < desc->natts; i++) { - Form_pg_attribute att = desc->attrs[i]; + Form_pg_attribute att = &desc->attrs[i]; uint8 flags = 0; if (att->attisdropped || GetGeneratedCol(desc, i)) diff --git a/src/gausskernel/storage/replication/logical/relation.cpp b/src/gausskernel/storage/replication/logical/relation.cpp index e3581c0d6..fd3a439c4 100644 --- a/src/gausskernel/storage/replication/logical/relation.cpp +++ b/src/gausskernel/storage/replication/logical/relation.cpp @@ -271,11 +271,11 @@ LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lo found = 0; for (i = 0; i < desc->natts; i++) { - if (desc->attrs[i]->attisdropped || GetGeneratedCol(desc, i)) { + if (desc->attrs[i].attisdropped || GetGeneratedCol(desc, i)) { entry->attrmap[i] = -1; continue; } - int attnum = logicalrep_rel_att_by_name(remoterel, NameStr(desc->attrs[i]->attname)); + int attnum = logicalrep_rel_att_by_name(remoterel, NameStr(desc->attrs[i].attname)); entry->attrmap[i] = attnum; if (attnum >= 0) found++; diff --git a/src/gausskernel/storage/replication/logical/reorderbuffer.cpp b/src/gausskernel/storage/replication/logical/reorderbuffer.cpp index 46fabc86a..1ef02d1ec 100644 --- a/src/gausskernel/storage/replication/logical/reorderbuffer.cpp +++ b/src/gausskernel/storage/replication/logical/reorderbuffer.cpp @@ -2693,7 +2693,7 @@ static void ReorderBufferFillAttributes(ReorderBufferTXN *txn, TupleDesc desc, T errno_t rc = 0; const int toast_index = 3; /* toast index in tuple is 3 */ for (int natt = 0; natt < desc->natts; natt++) { - Form_pg_attribute attr = desc->attrs[natt]; + Form_pg_attribute attr = &desc->attrs[natt]; ReorderBufferToastEnt *ent = NULL; struct varlena *varlena = NULL; diff --git a/src/gausskernel/storage/replication/logical/worker.cpp b/src/gausskernel/storage/replication/logical/worker.cpp index 2925c730c..105d3cba5 100644 --- a/src/gausskernel/storage/replication/logical/worker.cpp +++ b/src/gausskernel/storage/replication/logical/worker.cpp @@ -238,7 +238,7 @@ static void slot_fill_defaults(LogicalRepRelMapEntry *rel, EState *estate, Tuple for (attnum = 0; attnum < num_phys_attrs; attnum++) { Expr *defexpr; - if (desc->attrs[attnum]->attisdropped || GetGeneratedCol(desc, attnum)) + if (desc->attrs[attnum].attisdropped || GetGeneratedCol(desc, attnum)) continue; if (rel->attrmap[attnum] >= 0) @@ -304,7 +304,7 @@ static void slot_store_data(TupleTableSlot *slot, LogicalRepRelMapEntry *rel, Lo /* Call the "in" function for each non-dropped, non-null attribute */ for (i = 0; i < natts; i++) { - Form_pg_attribute att = slot->tts_tupleDescriptor->attrs[i]; + Form_pg_attribute att = &slot->tts_tupleDescriptor->attrs[i]; int remoteattnum = rel->attrmap[i]; if (!att->attisdropped && remoteattnum >= 0) { @@ -411,7 +411,7 @@ static void slot_modify_data(TupleTableSlot *slot, TupleTableSlot *srcslot, Logi /* Call the "in" function for each replaced attribute */ for (i = 0; i < natts; i++) { - Form_pg_attribute att = slot->tts_tupleDescriptor->attrs[i]; + Form_pg_attribute att = &slot->tts_tupleDescriptor->attrs[i]; int remoteattnum = rel->attrmap[i]; if (remoteattnum < 0) { diff --git a/src/gausskernel/storage/replication/pgoutput/pgoutput.cpp b/src/gausskernel/storage/replication/pgoutput/pgoutput.cpp index 1f2478924..1c11618ea 100644 --- a/src/gausskernel/storage/replication/pgoutput/pgoutput.cpp +++ b/src/gausskernel/storage/replication/pgoutput/pgoutput.cpp @@ -289,7 +289,7 @@ static void MaybeSendSchema(LogicalDecodingContext *ctx, Relation relation, Rela * types. */ for (i = 0; i < desc->natts; i++) { - Form_pg_attribute att = desc->attrs[i]; + Form_pg_attribute att = &desc->attrs[i]; if (att->attisdropped || GetGeneratedCol(desc, i)) continue; diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 4f175ec8a..46e5d1a39 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -1090,10 +1090,10 @@ extern TransactionId HeapTupleHeaderMultiXactGetUpdateXid(Page page, HeapTupleHe AssertMacro((attnum) > 0), \ (*(isnull) = false), \ HeapTupleNoNulls(tup) \ - ? ((tuple_desc)->attrs[(attnum)-1]->attcacheoff >= 0 \ - ? (fetchatt((tuple_desc)->attrs[(attnum)-1], \ + ? (TupleDescAttr((tuple_desc), (attnum)-1)->attcacheoff >= 0 \ + ? (fetchatt(TupleDescAttr((tuple_desc), (attnum)-1), \ (char*)(tup)->t_data + (tup)->t_data->t_hoff + \ - (tuple_desc)->attrs[(attnum)-1]->attcacheoff)) \ + TupleDescAttr((tuple_desc), (attnum)-1)->attcacheoff)) \ : nocachegetattr((tup), (attnum), (tuple_desc))) \ : (att_isnull((attnum)-1, (tup)->t_data->t_bits) ? ((*(isnull) = true), (Datum)NULL) \ : (nocachegetattr((tup), (attnum), (tuple_desc))))) diff --git a/src/include/access/itup.h b/src/include/access/itup.h index e33a2660c..899d89081 100644 --- a/src/include/access/itup.h +++ b/src/include/access/itup.h @@ -107,10 +107,10 @@ typedef IndexAttributeBitMapData* IndexAttributeBitMap; #define index_getattr(tup, attnum, tupleDesc, isnull) \ (AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \ *(isnull) = false, \ - !IndexTupleHasNulls(tup) ? ((tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 \ - ? (fetchatt((tupleDesc)->attrs[(attnum)-1], \ + !IndexTupleHasNulls(tup) ? (TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 \ + ? (fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \ (char*)(tup) + IndexInfoFindDataOffset((tup)->t_info) + \ - (tupleDesc)->attrs[(attnum)-1]->attcacheoff)) \ + TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff)) \ : nocache_index_getattr((tup), (attnum), (tupleDesc))) \ : ((att_isnull((attnum)-1, (char*)(tup) + sizeof(IndexTupleData))) \ ? (*(isnull) = true, (Datum)NULL) \ diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 1de4e5ccc..3272dc1d7 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -516,6 +516,17 @@ static inline TableAmType GetTableAmType(const TableAmRoutine* ops) return ops == TableAmHeap ? TAM_HEAP : TAM_USTORE; } +/* ------------------------------------------------------------------------ + * HEAP TABLE SLOT AM APIs + * ------------------------------------------------------------------------ + */ + +static inline Tuple tableam_tslot_get_tuple_from_slot(Relation relation, TupleTableSlot *slot) +{ + slot->tts_tupleDescriptor->tdhasuids = RELATION_HAS_UIDS(relation); + return g_tableam_routines[relation->rd_tam_type]->tslot_get_tuple_from_slot(slot); +} + /* * Clears the contents of the table slot that contains heap table tuple data. */ @@ -556,8 +567,7 @@ static inline HeapTuple tableam_tslot_copy_heap_tuple(TupleTableSlot *slot) static inline void tableam_tslot_store_tuple(Tuple tuple, TupleTableSlot *slot, Buffer buffer, bool shouldFree, bool batchMode) { - Assert(slot->tts_tam_ops == GetTableAmRoutine(TableAmType(GetTabelAmIndexTuple(tuple)))); - slot->tts_tam_ops->tslot_store_tuple(tuple, slot, buffer, shouldFree, batchMode); + g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tslot_store_tuple(tuple, slot, buffer, shouldFree, batchMode); } static inline void tableam_tslot_getsomeattrs(TupleTableSlot *slot, int natts) @@ -585,25 +595,86 @@ static inline bool tableam_tslot_attisnull(TupleTableSlot *slot, int attnum) return slot->tts_tam_ops->tslot_attisnull(slot, attnum); } -extern Tuple tableam_tslot_get_tuple_from_slot(Relation relation, TupleTableSlot *slot); -extern Datum tableam_tops_getsysattr(Tuple tup, int attnum, TupleDesc tuple_desc, bool *isnull, - Buffer buf = InvalidBuffer); -extern MinimalTuple tableam_tops_form_minimal_tuple(TupleDesc tuple_descriptor, Datum *values, - const bool *isnull, MinimalTuple in_tuple, uint32 tupTableType); -extern Tuple tableam_tops_form_tuple(TupleDesc tuple_descriptor, Datum *values, bool *isnull, - uint32 tupTableType); -extern Tuple tableam_tops_form_cmprs_tuple(TupleDesc tuple_descriptor, FormCmprTupleData *cmprs_info, - uint32 tupTableType); -extern void tableam_tops_deform_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull); -extern void tableam_tops_deform_tuple2(Tuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull, Buffer buffer); -extern void tableam_tops_deform_cmprs_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull, - char *cmprs_info); -extern void tableam_tops_fill_tuple(TupleDesc tuple_desc, Datum *values, const bool *isnull, char *data, - Size data_size, uint16 *infomask, bits8 *bit); -extern Tuple tableam_tops_modify_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *repl_values, - const bool *repl_isnull, const bool *do_replace); -extern Tuple tableam_tops_opfusion_modify_tuple(Tuple tuple, TupleDesc tuple_desc, - Datum* repl_values, bool* repl_isnull, UpdateFusion* opf); +/* ------------------------------------------------------------------------ + * TABLE TUPLE AM APIs + * ------------------------------------------------------------------------ + */ + +static inline Datum tableam_tops_getsysattr(Tuple tuple, int attnum, TupleDesc tuple_desc, bool *isnull, + Buffer buf = InvalidBuffer) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_getsysattr(tuple, attnum, tuple_desc, isnull, buf); +} + +static inline MinimalTuple tableam_tops_form_minimal_tuple(TupleDesc tuple_descriptor, Datum *values, + const bool *isnull, MinimalTuple in_tuple, const TableAmRoutine* tam_ops = TableAmHeap) +{ + Assert(tuple_descriptor->td_tam_ops == tam_ops); + return tuple_descriptor->td_tam_ops->tops_form_minimal_tuple(tuple_descriptor, values, isnull, + in_tuple); +} + +static inline Tuple tableam_tops_form_tuple(TupleDesc tuple_descriptor, Datum *values, bool *isnull, + const TableAmRoutine* tam_ops = TableAmHeap) +{ + Assert(tuple_descriptor->td_tam_ops == tam_ops); + return tuple_descriptor->td_tam_ops->tops_form_tuple(tuple_descriptor, values, isnull); +} + +static inline Tuple tableam_tops_form_cmprs_tuple(TupleDesc tuple_descriptor, FormCmprTupleData *cmprs_info, + const TableAmRoutine* tam_ops = TableAmHeap) +{ + Assert(tuple_descriptor->td_tam_ops == tam_ops); + return tuple_descriptor->td_tam_ops->tops_form_cmprs_tuple(tuple_descriptor, cmprs_info); +} + +static inline void tableam_tops_deform_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_tuple(tuple, tuple_desc, values, isnull); +} + +static inline void tableam_tops_deform_tuple2(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull, Buffer buffer) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_tuple2(tuple, tuple_desc, values, isnull, buffer); +} + +static inline void tableam_tops_deform_cmprs_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *values, bool *isnull, + char *cmprs_info) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_deform_cmprs_tuple(tuple, tuple_desc, values, isnull, + cmprs_info); +} + +static inline void tableam_tops_fill_tuple(TupleDesc tuple_desc, Datum *values, const bool *isnull, char *data, + Size data_size, uint16 *infomask, bits8 *bit) +{ + return tuple_desc->td_tam_ops->tops_fill_tuple(tuple_desc, values, isnull, data, data_size, + infomask, bit); +} + +/* + * there is no uheapam_tops_modify_tuple + * but this is done for completeness + */ +static inline Tuple tableam_tops_modify_tuple(Tuple tuple, TupleDesc tuple_desc, Datum *repl_values, + const bool *repl_isnull, const bool *do_replace) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_modify_tuple(tuple, tuple_desc, repl_values, + repl_isnull, do_replace); +} + +static inline Tuple tableam_tops_opfusion_modify_tuple(Tuple tuple, TupleDesc tuple_desc, + Datum* repl_values, bool* repl_isnull, UpdateFusion* opf) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_opfusion_modify_tuple(tuple, tuple_desc, + repl_values, repl_isnull, opf); +} #define tableam_tops_free_tuple(tup) \ do { \ @@ -616,9 +687,29 @@ extern Tuple tableam_tops_opfusion_modify_tuple(Tuple tuple, TupleDesc tuple_des } \ } while (0) -extern Datum tableam_tops_tuple_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null); -extern Datum tableam_tops_tuple_fast_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null); -extern bool tableam_tops_tuple_attisnull(Tuple tuple, int attnum, TupleDesc tuple_desc); +static inline Datum tableam_tops_tuple_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_getattr(tuple, att_num, + tuple_desc, is_null); +} + +static inline Datum tableam_tops_tuple_fast_getattr(Tuple tuple, int att_num, TupleDesc tuple_desc, bool *is_null) +{ + AssertValidTuple(tuple); + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_fast_getattr(tuple, att_num, + tuple_desc, is_null); +} + +static inline bool tableam_tops_tuple_attisnull(Tuple tuple, int attnum, TupleDesc tuple_desc) +{ + /* + * We allow a NULL tupledesc for relations not expected to have missing + * values, such as catalog relations and indexes. + */ + return g_tableam_routines[GetTabelAmIndexTuple(tuple)]->tops_tuple_attisnull(tuple, attnum, tuple_desc); +} + extern Tuple tableam_tops_copy_tuple(Tuple tuple); extern MinimalTuple tableam_tops_copy_minimal_tuple(MinimalTuple mtup); extern void tableam_tops_free_minimal_tuple(MinimalTuple mtup); diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h index 96ba3bcf2..5a029877b 100644 --- a/src/include/access/tupdesc.h +++ b/src/include/access/tupdesc.h @@ -148,28 +148,28 @@ typedef struct InformationalConstraint { * always have tdrefcount >= 0. */ typedef struct tupleDesc { - TableAmType tdTableAmType; /*index for accessing the Table Accessor methods on singleton TableAccessorMethods */ + const TableAmRoutine* td_tam_ops; /* implementation of table AM */ int natts; /* number of attributes in the tuple */ - bool tdisredistable; /* temp table created for data redistribution by the redis tool */ - Form_pg_attribute* attrs; - /* attrs[N] is a pointer to the description of Attribute Number N+1 */ - TupleConstr* constr; /* constraints, or NULL if none */ - TupInitDefVal* initdefvals; /* init default value due to ADD COLUMN */ Oid tdtypeid; /* composite type ID for tuple type */ int32 tdtypmod; /* typmod for tuple type */ - bool tdhasoid; /* tuple has oid attribute in its header */ int tdrefcount; /* reference count, or -1 if not counting */ + bool tdisredistable; /* temp table created for data redistribution by the redis tool */ + bool tdhasoid; /* tuple has oid attribute in its header */ bool tdhasuids; /* tuple has uid attribute in its header */ + TupleConstr* constr; /* constraints, or NULL if none */ + TupInitDefVal* initdefvals; /* init default value due to ADD COLUMN */ + /* attrs[N] is the description of Attribute Number N+1 */ + FormData_pg_attribute attrs[FLEXIBLE_ARRAY_MEMBER]; } * TupleDesc; /* Accessor for the i'th attribute of tupdesc. */ -#define TupleDescAttr(tupdesc, i) (tupdesc->attrs[(i)]) +#define TupleDescAttr(tupdesc, i) (&(tupdesc)->attrs[(i)]) #define ISGENERATEDCOL(tupdesc, i) \ ((tupdesc)->constr != NULL && (tupdesc)->constr->num_defval > 0 && (tupdesc)->constr->generatedCols[(i)]) -extern TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid, TableAmType tam = TAM_HEAP); +extern TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid, const TableAmRoutine* tam_ops = TableAmHeap); -extern TupleDesc CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute* attrs, TableAmType tam = TAM_HEAP); +extern TupleDesc CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute* attrs, const TableAmRoutine* tam_ops = TableAmHeap); extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc); diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index 0ffc54bff..83136b7f7 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -115,8 +115,8 @@ extern void RangeVarCallbackOwnsTable( extern void RangeVarCallbackOwnsRelation( const RangeVar* relation, Oid relId, Oid oldRelId, bool target_is_partition, void* noCatalogs); extern void checkPartNotInUse(Partition part, const char* stmt); -extern List* transformConstIntoTargetType(Form_pg_attribute* attrs, int2vector* partitionKey, List* boundary); -extern List* transformIntoTargetType(Form_pg_attribute* attrs, int2 pos, List* boundary); +extern List* transformConstIntoTargetType(FormData_pg_attribute* attrs, int2vector* partitionKey, List* boundary); +extern List* transformIntoTargetType(FormData_pg_attribute* attrs, int2 pos, List* boundary); extern void RenameDistributedTable(Oid distributedTableOid, const char* distributedTableNewName); extern void renamePartitionedTable(Oid partitionedTableOid, const char* partitionedTableNewName); @@ -131,8 +131,8 @@ extern bool checkPartitionLocalIndexesUsable(Oid partitionOid); extern bool checkRelationLocalIndexesUsable(Relation relation); extern List* GetPartitionkeyPos(List* partitionkeys, List* schema, bool* partkeyIsFunc = NULL); -extern void ComparePartitionValue(List* pos, Form_pg_attribute* attrs, List *partitionList, bool isPartition = true, bool partkeyIsFunc = false); -extern void CompareListValue(const List* pos, Form_pg_attribute* attrs, List *partitionList, bool partkeyIsFunc = false); +extern void ComparePartitionValue(List* pos, FormData_pg_attribute* attrs, List *partitionList, bool isPartition = true, bool partkeyIsFunc = false); +extern void CompareListValue(const List* pos, FormData_pg_attribute* attrs, List *partitionList, bool partkeyIsFunc = false); extern void clearAttrInitDefVal(Oid relid); extern void ATMatviewGroup(List* stmts, Oid mvid, LOCKMODE lockmode); @@ -145,7 +145,7 @@ extern void AlterCreateChainTables(Oid relOid, Datum reloptions, CreateStmt *mai * @return If the the column is partition column, return true, otherwise return false. */ extern bool is_partition_column(Relation rel, AttrNumber att_no); -extern Const* GetPartitionValue(List* pos, Form_pg_attribute* attrs, List* value, bool isinterval, bool isPartition, bool partkeyIsFunc = false); +extern Const* GetPartitionValue(List* pos, FormData_pg_attribute* attrs, List* value, bool isinterval, bool isPartition, bool partkeyIsFunc = false); extern Node* GetTargetValue(Form_pg_attribute attrs, Const* src, bool isinterval, bool partkeyIsFunc = false); extern void ATExecEnableDisableRls(Relation rel, RelationRlsStatus changeType, LOCKMODE lockmode); extern bool isQueryUsingTempRelation(Query *query); diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index e4240ee4a..919ad9d98 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -192,7 +192,7 @@ extern TupleHashEntry FindTupleHashEntry( /* * prototypes from functions in execJunk.c */ -extern JunkFilter* ExecInitJunkFilter(List* targetList, bool hasoid, TupleTableSlot* slot, TableAmType tam = TAM_HEAP); +extern JunkFilter* ExecInitJunkFilter(List* targetList, bool hasoid, TupleTableSlot* slot, const TableAmRoutine* tam_ops); extern void ExecInitJunkAttr(EState* estate, CmdType operation, List* targetlist, ResultRelInfo* result_rel_info); extern JunkFilter* ExecInitJunkFilterConversion(List* targetList, TupleDesc cleanTupType, TupleTableSlot* slot); extern AttrNumber ExecFindJunkAttribute(JunkFilter* junkfilter, const char* attrName); @@ -334,9 +334,9 @@ extern void ExecInitResultTupleSlot(EState* estate, PlanState* planstate, const extern void ExecInitScanTupleSlot(EState* estate, ScanState* scanstate, const TableAmRoutine* tam_ops = TableAmHeap); extern TupleTableSlot* ExecInitExtraTupleSlot(EState* estate, const TableAmRoutine* tam_ops = TableAmHeap); extern TupleTableSlot* ExecInitNullTupleSlot(EState* estate, TupleDesc tupType); -extern TupleDesc ExecTypeFromTL(List* targetList, bool hasoid, bool markdropped = false, TableAmType tam = TAM_HEAP); -extern TupleDesc ExecCleanTypeFromTL(List* targetList, bool hasoid, TableAmType tam = TAM_HEAP); -extern TupleDesc ExecTypeFromExprList(List* exprList, List* namesList, TableAmType tam = TAM_HEAP); +extern TupleDesc ExecTypeFromTL(List* targetList, bool hasoid, bool markdropped = false, const TableAmRoutine* tam_ops = TableAmHeap); +extern TupleDesc ExecCleanTypeFromTL(List* targetList, bool hasoid, const TableAmRoutine* tam_ops = TableAmHeap); +extern TupleDesc ExecTypeFromExprList(List* exprList, List* namesList, const TableAmRoutine* tam_ops = TableAmHeap); extern void UpdateChangedParamSet(PlanState* node, Bitmapset* newchg); extern void InitOutputValues(RightRefState* refState, GenericExprState* targetArr[], Datum* values, bool* isnull, int targetCount, bool* hasExecs); @@ -421,7 +421,7 @@ extern ExprContext* MakePerTupleExprContext(EState* estate); extern void ExecAssignExprContext(EState* estate, PlanState* planstate); extern void ExecAssignResultType(PlanState* planstate, TupleDesc tupDesc); -extern void ExecAssignResultTypeFromTL(PlanState* planstate, TableAmType tam = TAM_HEAP); +extern void ExecAssignResultTypeFromTL(PlanState* planstate, const TableAmRoutine* tam_ops = TableAmHeap); extern TupleDesc ExecGetResultType(PlanState* planstate); extern void ExecAssignVectorForExprEval(ExprContext* econtext); extern ProjectionInfo* ExecBuildProjectionInfo( diff --git a/src/include/optimizer/aioptimizer.h b/src/include/optimizer/aioptimizer.h index 61f62ee74..37af7ba0e 100644 --- a/src/include/optimizer/aioptimizer.h +++ b/src/include/optimizer/aioptimizer.h @@ -112,9 +112,9 @@ public: datumTuple.typlen = (int16 *)palloc0(sizeof(int16) * sample->num_attrs); datumTuple.nattrs = sample->num_attrs; for (int i = 0; i < datumTuple.nattrs; i++) { - datumTuple.typid[i] = attDesc->attrs[i]->atttypid; - datumTuple.typbyval[i] = attDesc->attrs[i]->attbyval; - datumTuple.typlen[i] = attDesc->attrs[i]->attlen; + datumTuple.typid[i] = attDesc->attrs[i].atttypid; + datumTuple.typbyval[i] = attDesc->attrs[i].attbyval; + datumTuple.typlen[i] = attDesc->attrs[i].attlen; } values = sample->values; freqs = sample->freqs; diff --git a/src/include/parser/parse_utilcmd.h b/src/include/parser/parse_utilcmd.h index 5036c050d..0673f4832 100644 --- a/src/include/parser/parse_utilcmd.h +++ b/src/include/parser/parse_utilcmd.h @@ -84,7 +84,7 @@ extern Oid searchSeqidFromExpr(Node* cooked_default); extern bool is_start_end_def_list(List* def_list); extern void get_range_partition_name_prefix(char* namePrefix, char* srcName, bool printNotice, bool isPartition); extern List* transformRangePartStartEndStmt(ParseState* pstate, List* partitionList, List* pos, - Form_pg_attribute* attrs, int32 existPartNum, Const* lowBound, Const* upBound, bool needFree, + FormData_pg_attribute* attrs, int32 existPartNum, Const* lowBound, Const* upBound, bool needFree, bool isPartition = true); extern bool check_contains_tbllike_in_multi_nodegroup(CreateStmt* stmt); extern bool is_multi_nodegroup_createtbllike(PGXCSubCluster* subcluster, Oid oid); diff --git a/src/include/utils/partitionkey.h b/src/include/utils/partitionkey.h index 0fe617646..0fcad414a 100644 --- a/src/include/utils/partitionkey.h +++ b/src/include/utils/partitionkey.h @@ -58,7 +58,7 @@ extern List* untransformPartitionBoundary(Datum options); * return value : None- * Note : */ -extern void CheckValuePartitionKeyType(Form_pg_attribute* attrs, List* pos); +extern void CheckValuePartitionKeyType(FormData_pg_attribute* attrs, List* pos); extern bool GetPartitionOidForRTE(RangeTblEntry *rte, RangeVar *relation, ParseState *pstate, Relation rel); extern bool GetSubPartitionOidForRTE(RangeTblEntry *rte, RangeVar *relation, ParseState *pstate, Relation rel); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 4ff327c72..bcd3b6322 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -415,9 +415,6 @@ typedef struct StdRdOptions { #define UHEAP_MAX_TD 128 #define UHEAP_DEFAULT_TD 4 -#define RelationGetTupleType(relation) \ - ((relation)->rd_tam_type + 1) - /* * RelationIsUsedAsCatalogTable * Returns whether the relation should be treated as a catalog table diff --git a/src/include/utils/rel_gs.h b/src/include/utils/rel_gs.h index a86501a6a..13ca06d2c 100644 --- a/src/include/utils/rel_gs.h +++ b/src/include/utils/rel_gs.h @@ -391,8 +391,8 @@ static inline RedisHtlAction RelationGetAppendMode(Relation rel) pg_strcasecmp(RelationGetOrientation(relation), ORIENTATION_TIMESERIES) == 0) #define TsRelWithImplDistColumn(attribute, pos) \ - (((attribute)[pos]->attkvtype == ATT_KV_HIDE) && \ - namestrcmp(&((attribute)[pos]->attname), TS_PSEUDO_DIST_COLUMN) == 0) + (((attribute)[pos].attkvtype == ATT_KV_HIDE) && \ + namestrcmp(&((attribute)[pos].attname), TS_PSEUDO_DIST_COLUMN) == 0) // Helper Macro Defination // diff --git a/src/include/vecexecutor/vecgrpuniq.h b/src/include/vecexecutor/vecgrpuniq.h index 07a98d47f..727b7782e 100644 --- a/src/include/vecexecutor/vecgrpuniq.h +++ b/src/include/vecexecutor/vecgrpuniq.h @@ -186,13 +186,13 @@ static void BindingFp(T* node) } template -static void ReplaceGrpUniqEqfunc(Encap* cap, Form_pg_attribute* attrs) +static void ReplaceGrpUniqEqfunc(Encap* cap, FormData_pg_attribute* attrs) { AttrNumber* colIdx = cap->colIdx; FmgrInfo* eqfunctions = cap->eqfunctions; for (int i = 0; i < cap->cols; i++) { - switch (attrs[colIdx[i] - 1]->atttypid) { + switch (attrs[colIdx[i] - 1].atttypid) { case TIMETZOID: eqfunctions[i].fn_addr = timetz_eq_withhead; break; @@ -228,10 +228,10 @@ void InitGrpUniq(T* state, int cols, AttrNumber* colIdx) cap->outerCols = outDesc->natts; cap->colIdx = colIdx; cap->eqfunctions = state->eqfunctions; - Form_pg_attribute* attrs = outDesc->attrs; + FormData_pg_attribute* attrs = outDesc->attrs; for (i = 0; i < cap->outerCols; i++) { - if (COL_IS_ENCODE(attrs[i]->atttypid)) { + if (COL_IS_ENCODE(attrs[i].atttypid)) { state->keySimple = false; break; } diff --git a/src/include/vecexecutor/vecstore.h b/src/include/vecexecutor/vecstore.h index 42042b5ca..e05725717 100644 --- a/src/include/vecexecutor/vecstore.h +++ b/src/include/vecexecutor/vecstore.h @@ -133,7 +133,7 @@ public: * When faced with NULL, we just skip, in the following produce, we do the same thing. */ for (int col = 0; col < batch->m_cols; ++col) { - Form_pg_attribute attr = tupDesc->attrs[col]; + Form_pg_attribute attr = &tupDesc->attrs[col]; flag = batch->m_arr[col].m_flag[row]; multiColValue.m_nulls[col] = flag; diff --git a/src/test/regress/regress.cpp b/src/test/regress/regress.cpp index f03a2289f..bed92db52 100644 --- a/src/test/regress/regress.cpp +++ b/src/test/regress/regress.cpp @@ -1034,7 +1034,7 @@ Datum make_tuple_indirect(PG_FUNCTION_ARGS) struct varatt_indirect redirect_pointer; /* only work on existing, not-null varlenas */ - if (tupdesc->attrs[i]->attisdropped || nulls[i] || tupdesc->attrs[i]->attlen != -1) + if (tupdesc->attrs[i].attisdropped || nulls[i] || tupdesc->attrs[i].attlen != -1) continue; attr = (struct varlena*)DatumGetPointer(values[i]);