From f9dffb28b8bff8abf29a2a3d322a6678d54c0796 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Sat, 9 Jul 2022 12:19:18 +0700 Subject: [PATCH v2 1/4] Transform GETSTRUCT macro to pass the catalog name as a parameter Preparatory refactoring per suggestion from Andres Freund --- contrib/bloom/blvalidate.c | 8 +- contrib/dblink/dblink.c | 2 +- contrib/intarray/_int_selfuncs.c | 2 +- contrib/postgres_fdw/deparse.c | 8 +- contrib/sepgsql/database.c | 2 +- contrib/sepgsql/dml.c | 4 +- contrib/sepgsql/label.c | 10 +- contrib/sepgsql/proc.c | 6 +- contrib/sepgsql/relation.c | 12 +- contrib/sepgsql/schema.c | 2 +- contrib/tcn/tcn.c | 2 +- src/backend/access/brin/brin_validate.c | 8 +- src/backend/access/common/reloptions.c | 2 +- src/backend/access/common/tupdesc.c | 2 +- src/backend/access/gin/ginvalidate.c | 8 +- src/backend/access/gist/gistvalidate.c | 8 +- src/backend/access/hash/hashvalidate.c | 10 +- src/backend/access/index/amapi.c | 4 +- src/backend/access/index/amvalidate.c | 14 +- src/backend/access/nbtree/nbtvalidate.c | 8 +- src/backend/access/spgist/spgutils.c | 4 +- src/backend/access/spgist/spgvalidate.c | 8 +- src/backend/bootstrap/bootstrap.c | 2 +- src/backend/catalog/aclchk.c | 118 ++++----- src/backend/catalog/catalog.c | 2 +- src/backend/catalog/dependency.c | 4 +- src/backend/catalog/heap.c | 24 +- src/backend/catalog/index.c | 40 +-- src/backend/catalog/namespace.c | 40 +-- src/backend/catalog/objectaddress.c | 124 ++++----- src/backend/catalog/partition.c | 8 +- src/backend/catalog/pg_aggregate.c | 8 +- src/backend/catalog/pg_attrdef.c | 14 +- src/backend/catalog/pg_constraint.c | 28 +- src/backend/catalog/pg_conversion.c | 2 +- src/backend/catalog/pg_depend.c | 26 +- src/backend/catalog/pg_enum.c | 20 +- src/backend/catalog/pg_inherits.c | 14 +- src/backend/catalog/pg_operator.c | 8 +- src/backend/catalog/pg_proc.c | 6 +- src/backend/catalog/pg_publication.c | 22 +- src/backend/catalog/pg_shdepend.c | 14 +- src/backend/catalog/pg_subscription.c | 12 +- src/backend/catalog/pg_type.c | 6 +- src/backend/catalog/toasting.c | 2 +- src/backend/commands/alter.c | 16 +- src/backend/commands/amcmds.c | 4 +- src/backend/commands/analyze.c | 2 +- src/backend/commands/cluster.c | 12 +- src/backend/commands/collationcmds.c | 10 +- src/backend/commands/dbcommands.c | 28 +- src/backend/commands/event_trigger.c | 6 +- src/backend/commands/extension.c | 14 +- src/backend/commands/foreigncmds.c | 12 +- src/backend/commands/functioncmds.c | 22 +- src/backend/commands/indexcmds.c | 24 +- src/backend/commands/matview.c | 4 +- src/backend/commands/opclasscmds.c | 20 +- src/backend/commands/operatorcmds.c | 4 +- src/backend/commands/policy.c | 16 +- src/backend/commands/proclang.c | 2 +- src/backend/commands/publicationcmds.c | 22 +- src/backend/commands/schemacmds.c | 8 +- src/backend/commands/sequence.c | 18 +- src/backend/commands/statscmds.c | 6 +- src/backend/commands/subscriptioncmds.c | 8 +- src/backend/commands/tablecmds.c | 240 +++++++++--------- src/backend/commands/tablespace.c | 10 +- src/backend/commands/trigger.c | 34 +-- src/backend/commands/tsearchcmds.c | 26 +- src/backend/commands/typecmds.c | 42 +-- src/backend/commands/user.c | 14 +- src/backend/commands/vacuum.c | 12 +- src/backend/commands/variable.c | 4 +- src/backend/executor/execAmi.c | 2 +- src/backend/executor/functions.c | 4 +- src/backend/executor/nodeAgg.c | 4 +- src/backend/executor/nodeWindowAgg.c | 4 +- src/backend/executor/spi.c | 2 +- src/backend/foreign/foreign.c | 14 +- src/backend/optimizer/plan/planagg.c | 2 +- src/backend/optimizer/plan/subselect.c | 2 +- src/backend/optimizer/prep/prepagg.c | 2 +- src/backend/optimizer/util/appendinfo.c | 2 +- src/backend/optimizer/util/clauses.c | 14 +- src/backend/optimizer/util/plancat.c | 8 +- src/backend/parser/parse_clause.c | 2 +- src/backend/parser/parse_coerce.c | 12 +- src/backend/parser/parse_func.c | 6 +- src/backend/parser/parse_oper.c | 10 +- src/backend/parser/parse_relation.c | 2 +- src/backend/parser/parse_type.c | 32 +-- src/backend/parser/parse_utilcmd.c | 22 +- src/backend/postmaster/autovacuum.c | 20 +- src/backend/replication/logical/launcher.c | 2 +- src/backend/replication/logical/origin.c | 4 +- src/backend/replication/logical/proto.c | 4 +- src/backend/replication/logical/worker.c | 2 +- src/backend/rewrite/rewriteDefine.c | 10 +- src/backend/rewrite/rewriteRemove.c | 2 +- src/backend/rewrite/rewriteSupport.c | 4 +- src/backend/statistics/extended_stats.c | 6 +- src/backend/storage/large_object/inv_api.c | 8 +- src/backend/tcop/fastpath.c | 2 +- src/backend/tsearch/ts_selfuncs.c | 2 +- src/backend/utils/adt/acl.c | 16 +- src/backend/utils/adt/amutils.c | 4 +- src/backend/utils/adt/array_selfuncs.c | 4 +- src/backend/utils/adt/dbsize.c | 4 +- src/backend/utils/adt/domains.c | 2 +- src/backend/utils/adt/enum.c | 16 +- src/backend/utils/adt/format_type.c | 4 +- src/backend/utils/adt/jsonfuncs.c | 2 +- src/backend/utils/adt/like_support.c | 2 +- .../utils/adt/multirangetypes_selfuncs.c | 2 +- src/backend/utils/adt/network_selfuncs.c | 10 +- src/backend/utils/adt/pg_locale.c | 4 +- src/backend/utils/adt/rangetypes_selfuncs.c | 2 +- src/backend/utils/adt/regproc.c | 22 +- src/backend/utils/adt/ri_triggers.c | 6 +- src/backend/utils/adt/ruleutils.c | 54 ++-- src/backend/utils/adt/selfuncs.c | 28 +- src/backend/utils/adt/xml.c | 4 +- src/backend/utils/cache/evtcache.c | 2 +- src/backend/utils/cache/inval.c | 10 +- src/backend/utils/cache/lsyscache.c | 196 +++++++------- src/backend/utils/cache/partcache.c | 4 +- src/backend/utils/cache/relcache.c | 44 ++-- src/backend/utils/cache/relfilenumbermap.c | 2 +- src/backend/utils/cache/syscache.c | 4 +- src/backend/utils/cache/ts_cache.c | 12 +- src/backend/utils/cache/typcache.c | 12 +- src/backend/utils/fmgr/fmgr.c | 18 +- src/backend/utils/fmgr/funcapi.c | 6 +- src/backend/utils/init/miscinit.c | 6 +- src/backend/utils/init/postinit.c | 10 +- src/backend/utils/misc/rls.c | 2 +- src/backend/utils/misc/superuser.c | 2 +- src/include/access/htup_details.h | 2 +- src/pl/plperl/plperl.c | 10 +- src/pl/plpgsql/src/pl_comp.c | 14 +- src/pl/plpgsql/src/pl_handler.c | 2 +- src/pl/plpython/plpy_main.c | 2 +- src/pl/plpython/plpy_procedure.c | 6 +- src/pl/tcl/pltcl.c | 8 +- src/test/modules/plsample/plsample.c | 8 +- 146 files changed, 1049 insertions(+), 1049 deletions(-) diff --git a/contrib/bloom/blvalidate.c b/contrib/bloom/blvalidate.c index 333a35d377..fc9911d6bf 100644 --- a/contrib/bloom/blvalidate.c +++ b/contrib/bloom/blvalidate.c @@ -52,7 +52,7 @@ blvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -65,7 +65,7 @@ blvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -77,7 +77,7 @@ blvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); bool ok; /* @@ -138,7 +138,7 @@ blvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); /* Check it's allowed strategy for bloom */ if (oprform->amopstrategy < 1 || diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index e323fdd0e6..faa2a07da2 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -2075,7 +2075,7 @@ get_pkey_attnames(Relation rel, int16 *indnkeyatts) while (HeapTupleIsValid(indexTuple = systable_getnext(scan))) { - Form_pg_index index = (Form_pg_index) GETSTRUCT(indexTuple); + Form_pg_index index = GETSTRUCT(pg_index, indexTuple); /* we're only interested if it is the primary key */ if (index->indisprimary) diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c index 3d8ff6781b..a66d5fee92 100644 --- a/contrib/intarray/_int_selfuncs.c +++ b/contrib/intarray/_int_selfuncs.c @@ -191,7 +191,7 @@ _int_matchsel(PG_FUNCTION_ARGS) { Form_pg_statistic stats; - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); nullfrac = stats->stanullfrac; /* diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c index 8f4d8a5022..63dc4e8c55 100644 --- a/contrib/postgres_fdw/deparse.c +++ b/contrib/postgres_fdw/deparse.c @@ -3005,7 +3005,7 @@ deparseOpExpr(OpExpr *node, deparse_expr_cxt *context) tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for operator %u", node->opno); - form = (Form_pg_operator) GETSTRUCT(tuple); + form = GETSTRUCT(pg_operator, tuple); oprkind = form->oprkind; /* Sanity check. */ @@ -3180,7 +3180,7 @@ deparseScalarArrayOpExpr(ScalarArrayOpExpr *node, deparse_expr_cxt *context) tuple = SearchSysCache1(OPEROID, ObjectIdGetDatum(node->opno)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for operator %u", node->opno); - form = (Form_pg_operator) GETSTRUCT(tuple); + form = GETSTRUCT(pg_operator, tuple); /* Sanity check. */ Assert(list_length(node->args) == 2); @@ -3519,7 +3519,7 @@ appendOrderBySuffix(Oid sortop, Oid sortcoltype, bool nulls_first, opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(sortop)); if (!HeapTupleIsValid(opertup)) elog(ERROR, "cache lookup failed for operator %u", sortop); - operform = (Form_pg_operator) GETSTRUCT(opertup); + operform = GETSTRUCT(pg_operator, opertup); deparseOperatorName(buf, operform); ReleaseSysCache(opertup); } @@ -3734,7 +3734,7 @@ appendFunctionName(Oid funcid, deparse_expr_cxt *context) proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); /* Print schema name only if it's not pg_catalog */ if (procform->pronamespace != PG_CATALOG_NAMESPACE) diff --git a/contrib/sepgsql/database.c b/contrib/sepgsql/database.c index dce97859f4..a73d600cb8 100644 --- a/contrib/sepgsql/database.c +++ b/contrib/sepgsql/database.c @@ -89,7 +89,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for database %u", databaseId); - datForm = (Form_pg_database) GETSTRUCT(tuple); + datForm = GETSTRUCT(pg_database, tuple); ncontext = sepgsql_compute_create(sepgsql_get_client_label(), tcontext, diff --git a/contrib/sepgsql/dml.c b/contrib/sepgsql/dml.c index 3bb98dfb06..114a46c2db 100644 --- a/contrib/sepgsql/dml.c +++ b/contrib/sepgsql/dml.c @@ -52,7 +52,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relOid); - natts = ((Form_pg_class) GETSTRUCT(tuple))->relnatts; + natts = (GETSTRUCT(pg_class, tuple))->relnatts; ReleaseSysCache(tuple); /* remove bit 0 from column set, add in all the non-dropped columns */ @@ -67,7 +67,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns) if (!HeapTupleIsValid(tuple)) continue; /* unexpected case, should we error? */ - if (!((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped) + if (!(GETSTRUCT(pg_attribute, tuple))->attisdropped) { index = attno - FirstLowInvalidHeapAttributeNumber; result = bms_add_member(result, index); diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c index e4c98b7eae..a7dd60fb90 100644 --- a/contrib/sepgsql/label.c +++ b/contrib/sepgsql/label.c @@ -733,7 +733,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) switch (catalogId) { case DatabaseRelationId: - datForm = (Form_pg_database) GETSTRUCT(tuple); + datForm = GETSTRUCT(pg_database, tuple); objtype = SELABEL_DB_DATABASE; @@ -746,7 +746,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) break; case NamespaceRelationId: - nspForm = (Form_pg_namespace) GETSTRUCT(tuple); + nspForm = GETSTRUCT(pg_namespace, tuple); objtype = SELABEL_DB_SCHEMA; @@ -760,7 +760,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) break; case RelationRelationId: - relForm = (Form_pg_class) GETSTRUCT(tuple); + relForm = GETSTRUCT(pg_class, tuple); if (relForm->relkind == RELKIND_RELATION || relForm->relkind == RELKIND_PARTITIONED_TABLE) @@ -785,7 +785,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) break; case AttributeRelationId: - attForm = (Form_pg_attribute) GETSTRUCT(tuple); + attForm = GETSTRUCT(pg_attribute, tuple); if (get_rel_relkind(attForm->attrelid) != RELKIND_RELATION && get_rel_relkind(attForm->attrelid) != RELKIND_PARTITIONED_TABLE) @@ -809,7 +809,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) break; case ProcedureRelationId: - proForm = (Form_pg_proc) GETSTRUCT(tuple); + proForm = GETSTRUCT(pg_proc, tuple); objtype = SELABEL_DB_PROCEDURE; diff --git a/contrib/sepgsql/proc.c b/contrib/sepgsql/proc.c index 45f006ed2a..54446cb02d 100644 --- a/contrib/sepgsql/proc.c +++ b/contrib/sepgsql/proc.c @@ -68,7 +68,7 @@ sepgsql_proc_post_create(Oid functionId) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for function %u", functionId); - proForm = (Form_pg_proc) GETSTRUCT(tuple); + proForm = GETSTRUCT(pg_proc, tuple); /* * check db_schema:{add_name} permission of the namespace @@ -260,7 +260,7 @@ sepgsql_proc_setattr(Oid functionId) newtup = systable_getnext(sscan); if (!HeapTupleIsValid(newtup)) elog(ERROR, "could not find tuple for function %u", functionId); - newform = (Form_pg_proc) GETSTRUCT(newtup); + newform = GETSTRUCT(pg_proc, newtup); /* * Fetch older catalog @@ -268,7 +268,7 @@ sepgsql_proc_setattr(Oid functionId) oldtup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId)); if (!HeapTupleIsValid(oldtup)) elog(ERROR, "cache lookup failed for function %u", functionId); - oldform = (Form_pg_proc) GETSTRUCT(oldtup); + oldform = GETSTRUCT(pg_proc, oldtup); /* * Does this ALTER command takes operation to namespace? diff --git a/contrib/sepgsql/relation.c b/contrib/sepgsql/relation.c index 8767988c4d..1d79397448 100644 --- a/contrib/sepgsql/relation.c +++ b/contrib/sepgsql/relation.c @@ -84,7 +84,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum) elog(ERROR, "could not find tuple for column %d of relation %u", attnum, relOid); - attForm = (Form_pg_attribute) GETSTRUCT(tuple); + attForm = GETSTRUCT(pg_attribute, tuple); scontext = sepgsql_get_client_label(); tcontext = sepgsql_get_label(RelationRelationId, relOid, 0); @@ -271,7 +271,7 @@ sepgsql_relation_post_create(Oid relOid) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for relation %u", relOid); - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); /* ignore indexes on toast tables */ if (classForm->relkind == RELKIND_INDEX && @@ -368,7 +368,7 @@ sepgsql_relation_post_create(Oid relOid) while (HeapTupleIsValid(atup = systable_getnext(ascan))) { - attForm = (Form_pg_attribute) GETSTRUCT(atup); + attForm = GETSTRUCT(pg_attribute, atup); resetStringInfo(&audit_name); appendStringInfo(&audit_name, "%s.%s.%s", @@ -494,7 +494,7 @@ sepgsql_relation_drop(Oid relOid) for (i = 0; i < attrList->n_members; i++) { atttup = &attrList->members[i]->tuple; - attForm = (Form_pg_attribute) GETSTRUCT(atttup); + attForm = GETSTRUCT(pg_attribute, atttup); if (attForm->attisdropped) continue; @@ -662,7 +662,7 @@ sepgsql_relation_setattr(Oid relOid) newtup = systable_getnext(sscan); if (!HeapTupleIsValid(newtup)) elog(ERROR, "could not find tuple for relation %u", relOid); - newform = (Form_pg_class) GETSTRUCT(newtup); + newform = GETSTRUCT(pg_class, newtup); /* * Fetch older catalog @@ -670,7 +670,7 @@ sepgsql_relation_setattr(Oid relOid) oldtup = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(oldtup)) elog(ERROR, "cache lookup failed for relation %u", relOid); - oldform = (Form_pg_class) GETSTRUCT(oldtup); + oldform = GETSTRUCT(pg_class, oldtup); /* * Does this ALTER command takes operation to namespace? diff --git a/contrib/sepgsql/schema.c b/contrib/sepgsql/schema.c index fecd02f07a..28c6cb3d03 100644 --- a/contrib/sepgsql/schema.c +++ b/contrib/sepgsql/schema.c @@ -67,7 +67,7 @@ sepgsql_schema_post_create(Oid namespaceId) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for namespace %u", namespaceId); - nspForm = (Form_pg_namespace) GETSTRUCT(tuple); + nspForm = GETSTRUCT(pg_namespace, tuple); nsp_name = NameStr(nspForm->nspname); if (strncmp(nsp_name, "pg_temp_", 8) == 0) nsp_name = "pg_temp"; diff --git a/contrib/tcn/tcn.c b/contrib/tcn/tcn.c index a2de6c385c..ff9990e044 100644 --- a/contrib/tcn/tcn.c +++ b/contrib/tcn/tcn.c @@ -134,7 +134,7 @@ triggered_change_notification(PG_FUNCTION_ARGS) indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid)); if (!HeapTupleIsValid(indexTuple)) /* should not happen */ elog(ERROR, "cache lookup failed for index %u", indexoid); - index = (Form_pg_index) GETSTRUCT(indexTuple); + index = GETSTRUCT(pg_index, indexTuple); /* we're only interested if it is the primary key and valid */ if (index->indisprimary && index->indisvalid) { diff --git a/src/backend/access/brin/brin_validate.c b/src/backend/access/brin/brin_validate.c index c54c874bc0..06c60b6780 100644 --- a/src/backend/access/brin/brin_validate.c +++ b/src/backend/access/brin/brin_validate.c @@ -58,7 +58,7 @@ brinvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -68,7 +68,7 @@ brinvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -80,7 +80,7 @@ brinvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); bool ok; /* Check procedure numbers and function signatures */ @@ -146,7 +146,7 @@ brinvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); /* Check that only allowed strategy numbers exist */ if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63) diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 609329bb21..e58c1ff436 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -1393,7 +1393,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, if (isnull) return NULL; - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); /* Parse into appropriate format; don't error out here */ switch (classForm->relkind) diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index d6fb261e20..dfad4a8dfa 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -635,7 +635,7 @@ TupleDescInitEntry(TupleDesc desc, tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(oidtypeid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", oidtypeid); - typeForm = (Form_pg_type) GETSTRUCT(tuple); + typeForm = GETSTRUCT(pg_type, tuple); att->atttypid = oidtypeid; att->attlen = typeForm->typlen; diff --git a/src/backend/access/gin/ginvalidate.c b/src/backend/access/gin/ginvalidate.c index 44f2ff205d..a873ab8b70 100644 --- a/src/backend/access/gin/ginvalidate.c +++ b/src/backend/access/gin/ginvalidate.c @@ -53,7 +53,7 @@ ginvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -66,7 +66,7 @@ ginvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -78,7 +78,7 @@ ginvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); bool ok; /* @@ -172,7 +172,7 @@ ginvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); /* TODO: Check that only allowed strategy numbers exist */ if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63) diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c index 95beca05fe..ce87ea3f9e 100644 --- a/src/backend/access/gist/gistvalidate.c +++ b/src/backend/access/gist/gistvalidate.c @@ -54,7 +54,7 @@ gistvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -67,7 +67,7 @@ gistvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -79,7 +79,7 @@ gistvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); bool ok; /* @@ -174,7 +174,7 @@ gistvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); Oid op_rettype; /* TODO: Check that only allowed strategy numbers exist */ diff --git a/src/backend/access/hash/hashvalidate.c b/src/backend/access/hash/hashvalidate.c index 10bf26ce7c..8f8712a552 100644 --- a/src/backend/access/hash/hashvalidate.c +++ b/src/backend/access/hash/hashvalidate.c @@ -67,7 +67,7 @@ hashvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -77,7 +77,7 @@ hashvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -89,7 +89,7 @@ hashvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); /* * All hash functions should be registered with matching left/right @@ -149,7 +149,7 @@ hashvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); /* Check that only allowed strategy numbers exist */ if (oprform->amopstrategy < 1 || @@ -299,7 +299,7 @@ check_hash_func_signature(Oid funcid, int16 amprocnum, Oid argtype) tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(tp); + procform = GETSTRUCT(pg_proc, tp); if (procform->prorettype != restype || procform->proretset || procform->pronargs != nargs) diff --git a/src/backend/access/index/amapi.c b/src/backend/access/index/amapi.c index 2b028e1950..243d80c2e5 100644 --- a/src/backend/access/index/amapi.c +++ b/src/backend/access/index/amapi.c @@ -68,7 +68,7 @@ GetIndexAmRoutineByAmId(Oid amoid, bool noerror) elog(ERROR, "cache lookup failed for access method %u", amoid); } - amform = (Form_pg_am) GETSTRUCT(tuple); + amform = GETSTRUCT(pg_am, tuple); /* Check if it's an index access method as opposed to some other AM */ if (amform->amtype != AMTYPE_INDEX) @@ -123,7 +123,7 @@ amvalidate(PG_FUNCTION_ARGS) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); amoid = classform->opcmethod; diff --git a/src/backend/access/index/amvalidate.c b/src/backend/access/index/amvalidate.c index d13054e33f..89b5ade49a 100644 --- a/src/backend/access/index/amvalidate.c +++ b/src/backend/access/index/amvalidate.c @@ -62,14 +62,14 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist) io = ip = 0; if (io < oprlist->n_members) { - oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple); + oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple); io++; } else oprform = NULL; if (ip < proclist->n_members) { - procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple); + procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple); ip++; } else @@ -89,7 +89,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist) if (io < oprlist->n_members) { - oprform = (Form_pg_amop) GETSTRUCT(&oprlist->members[io]->tuple); + oprform = GETSTRUCT(pg_amop, &oprlist->members[io]->tuple); io++; } else @@ -109,7 +109,7 @@ identify_opfamily_groups(CatCList *oprlist, CatCList *proclist) if (ip < proclist->n_members) { - procform = (Form_pg_amproc) GETSTRUCT(&proclist->members[ip]->tuple); + procform = GETSTRUCT(pg_amproc, &proclist->members[ip]->tuple); ip++; } else @@ -161,7 +161,7 @@ check_amproc_signature(Oid funcid, Oid restype, bool exact, tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(tp); + procform = GETSTRUCT(pg_proc, tp); if (procform->prorettype != restype || procform->proretset || procform->pronargs < minargs || procform->pronargs > maxargs) @@ -212,7 +212,7 @@ check_amop_signature(Oid opno, Oid restype, Oid lefttype, Oid righttype) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (!HeapTupleIsValid(tp)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for operator %u", opno); - opform = (Form_pg_operator) GETSTRUCT(tp); + opform = GETSTRUCT(pg_operator, tp); if (opform->oprresult != restype || opform->oprkind != 'b' || opform->oprleft != lefttype || opform->oprright != righttype) @@ -249,7 +249,7 @@ opclass_for_family_datatype(Oid amoid, Oid opfamilyoid, Oid datatypeoid) for (i = 0; i < opclist->n_members; i++) { HeapTuple classtup = &opclist->members[i]->tuple; - Form_pg_opclass classform = (Form_pg_opclass) GETSTRUCT(classtup); + Form_pg_opclass classform = GETSTRUCT(pg_opclass, classtup); if (classform->opcfamily == opfamilyoid && classform->opcintype == datatypeoid) diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c index 55ed3251d3..05d3c6707e 100644 --- a/src/backend/access/nbtree/nbtvalidate.c +++ b/src/backend/access/nbtree/nbtvalidate.c @@ -62,7 +62,7 @@ btvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -72,7 +72,7 @@ btvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -84,7 +84,7 @@ btvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); bool ok; /* Check procedure numbers and function signatures */ @@ -141,7 +141,7 @@ btvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); /* Check that only allowed strategy numbers exist */ if (oprform->amopstrategy < 1 || diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c index 2c661fcf96..93ed425c29 100644 --- a/src/backend/access/spgist/spgutils.c +++ b/src/backend/access/spgist/spgutils.c @@ -163,7 +163,7 @@ fillTypeDesc(SpGistTypeDesc *desc, Oid type) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for type %u", type); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); desc->attlen = typtup->typlen; desc->attbyval = typtup->typbyval; desc->attalign = typtup->typalign; @@ -1328,7 +1328,7 @@ spgproperty(Oid index_oid, int attno, for (i = 0; i < catlist->n_members; i++) { HeapTuple amoptup = &catlist->members[i]->tuple; - Form_pg_amop amopform = (Form_pg_amop) GETSTRUCT(amoptup); + Form_pg_amop amopform = GETSTRUCT(pg_amop, amoptup); if (amopform->amoppurpose == AMOP_ORDER && (amopform->amoplefttype == opcintype || diff --git a/src/backend/access/spgist/spgvalidate.c b/src/backend/access/spgist/spgvalidate.c index 82281f7b83..ab055f9371 100644 --- a/src/backend/access/spgist/spgvalidate.c +++ b/src/backend/access/spgist/spgvalidate.c @@ -64,7 +64,7 @@ spgvalidate(Oid opclassoid) classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup)) elog(ERROR, "cache lookup failed for operator class %u", opclassoid); - classform = (Form_pg_opclass) GETSTRUCT(classtup); + classform = GETSTRUCT(pg_opclass, classtup); opfamilyoid = classform->opcfamily; opcintype = classform->opcintype; @@ -75,7 +75,7 @@ spgvalidate(Oid opclassoid) familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid)); if (!HeapTupleIsValid(familytup)) elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid); - familyform = (Form_pg_opfamily) GETSTRUCT(familytup); + familyform = GETSTRUCT(pg_opfamily, familytup); opfamilyname = NameStr(familyform->opfname); @@ -88,7 +88,7 @@ spgvalidate(Oid opclassoid) for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); bool ok; /* @@ -210,7 +210,7 @@ spgvalidate(Oid opclassoid) for (i = 0; i < oprlist->n_members; i++) { HeapTuple oprtup = &oprlist->members[i]->tuple; - Form_pg_amop oprform = (Form_pg_amop) GETSTRUCT(oprtup); + Form_pg_amop oprform = GETSTRUCT(pg_amop, oprtup); Oid op_rettype; /* TODO: Check that only allowed strategy numbers exist */ diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 088556ab54..3a718201f3 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -720,7 +720,7 @@ populate_typ_list(void) old = MemoryContextSwitchTo(TopMemoryContext); while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup); + Form_pg_type typForm = GETSTRUCT(pg_type, tup); struct typmap *newtyp; newtyp = (struct typmap *) palloc(sizeof(struct typmap)); diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 5f1726c095..913fdbbea0 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -884,7 +884,7 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames) while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Oid oid = ((Form_pg_proc) GETSTRUCT(tuple))->oid; + Oid oid = (GETSTRUCT(pg_proc, tuple))->oid; objects = lappend_oid(objects, oid); } @@ -931,7 +931,7 @@ getRelationsInNamespace(Oid namespaceId, char relkind) while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Oid oid = ((Form_pg_class) GETSTRUCT(tuple))->oid; + Oid oid = (GETSTRUCT(pg_class, tuple))->oid; relations = lappend_oid(relations, oid); } @@ -1333,7 +1333,7 @@ SetDefaultACL(InternalDefaultACL *iacls) * there shouldn't be anything depending on this entry. */ myself.classId = DefaultAclRelationId; - myself.objectId = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid; + myself.objectId = (GETSTRUCT(pg_default_acl, tuple))->oid; myself.objectSubId = 0; performDeletion(&myself, DROP_RESTRICT, 0); @@ -1364,7 +1364,7 @@ SetDefaultACL(InternalDefaultACL *iacls) } else { - defAclOid = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid; + defAclOid = (GETSTRUCT(pg_default_acl, tuple))->oid; /* update existing entry */ values[Anum_pg_default_acl_defaclacl - 1] = PointerGetDatum(new_acl); @@ -1460,7 +1460,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for default ACL %u", objid); - pg_default_acl_tuple = (Form_pg_default_acl) GETSTRUCT(tuple); + pg_default_acl_tuple = GETSTRUCT(pg_default_acl, tuple); iacls.roleid = pg_default_acl_tuple->defaclrole; iacls.nspid = pg_default_acl_tuple->defaclnamespace; @@ -1630,7 +1630,7 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm, elog(ERROR, "cache lookup failed for attribute %d of relation %u", curr_att, table_oid); - isdropped = ((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped; + isdropped = (GETSTRUCT(pg_attribute, attTuple))->attisdropped; ReleaseSysCache(attTuple); @@ -1676,7 +1676,7 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname, if (!HeapTupleIsValid(attr_tuple)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relOid); - pg_attribute_tuple = (Form_pg_attribute) GETSTRUCT(attr_tuple); + pg_attribute_tuple = GETSTRUCT(pg_attribute, attr_tuple); /* * Get working copy of existing ACL. If there's no ACL, substitute the @@ -1825,7 +1825,7 @@ ExecGrant_Relation(InternalGrant *istmt) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relOid); - pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); + pg_class_tuple = GETSTRUCT(pg_class, tuple); /* Not sensible to grant on an index */ if (pg_class_tuple->relkind == RELKIND_INDEX || @@ -2163,7 +2163,7 @@ ExecGrant_Database(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for database %u", datId); - pg_database_tuple = (Form_pg_database) GETSTRUCT(tuple); + pg_database_tuple = GETSTRUCT(pg_database, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -2284,7 +2284,7 @@ ExecGrant_Fdw(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid); - pg_fdw_tuple = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple); + pg_fdw_tuple = GETSTRUCT(pg_foreign_data_wrapper, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -2410,7 +2410,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for foreign server %u", srvid); - pg_server_tuple = (Form_pg_foreign_server) GETSTRUCT(tuple); + pg_server_tuple = GETSTRUCT(pg_foreign_server, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -2535,7 +2535,7 @@ ExecGrant_Function(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", funcId); - pg_proc_tuple = (Form_pg_proc) GETSTRUCT(tuple); + pg_proc_tuple = GETSTRUCT(pg_proc, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -2658,7 +2658,7 @@ ExecGrant_Language(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for language %u", langId); - pg_language_tuple = (Form_pg_language) GETSTRUCT(tuple); + pg_language_tuple = GETSTRUCT(pg_language, tuple); if (!pg_language_tuple->lanpltrusted) ereport(ERROR, @@ -2803,7 +2803,7 @@ ExecGrant_Largeobject(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for large object %u", loid); - form_lo_meta = (Form_pg_largeobject_metadata) GETSTRUCT(tuple); + form_lo_meta = GETSTRUCT(pg_largeobject_metadata, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -2929,7 +2929,7 @@ ExecGrant_Namespace(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for namespace %u", nspid); - pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple); + pg_namespace_tuple = GETSTRUCT(pg_namespace, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -3054,7 +3054,7 @@ ExecGrant_Tablespace(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for tablespace %u", tblId); - pg_tablespace_tuple = (Form_pg_tablespace) GETSTRUCT(tuple); + pg_tablespace_tuple = GETSTRUCT(pg_tablespace, tuple); /* * Get owner ID and working copy of existing ACL. If there's no ACL, @@ -3174,7 +3174,7 @@ ExecGrant_Type(InternalGrant *istmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", typId); - pg_type_tuple = (Form_pg_type) GETSTRUCT(tuple); + pg_type_tuple = GETSTRUCT(pg_type, tuple); if (IsTrueArrayType(pg_type_tuple)) ereport(ERROR, @@ -3958,7 +3958,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid, attnum, table_oid))); } - attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple); + attributeForm = GETSTRUCT(pg_attribute, attTuple); /* Check dropped columns, too */ if (attributeForm->attisdropped) @@ -4005,7 +4005,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid, ReleaseSysCache(attTuple); return 0; } - classForm = (Form_pg_class) GETSTRUCT(classTuple); + classForm = GETSTRUCT(pg_class, classTuple); ownerId = classForm->relowner; @@ -4072,7 +4072,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask, table_oid))); } - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); /* * Deny anyone permission to update a system catalog unless @@ -4183,7 +4183,7 @@ pg_database_aclmask(Oid db_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database with OID %u does not exist", db_oid))); - ownerId = ((Form_pg_database) GETSTRUCT(tuple))->datdba; + ownerId = (GETSTRUCT(pg_database, tuple))->datdba; aclDatum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datacl, &isNull); @@ -4352,7 +4352,7 @@ pg_proc_aclmask(Oid proc_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function with OID %u does not exist", proc_oid))); - ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner; + ownerId = (GETSTRUCT(pg_proc, tuple))->proowner; aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl, &isNull); @@ -4406,7 +4406,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("language with OID %u does not exist", lang_oid))); - ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner; + ownerId = (GETSTRUCT(pg_language, tuple))->lanowner; aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl, &isNull); @@ -4485,7 +4485,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("large object %u does not exist", lobj_oid))); - ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner; + ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner; aclDatum = heap_getattr(tuple, Anum_pg_largeobject_metadata_lomacl, RelationGetDescr(pg_lo_meta), &isNull); @@ -4570,7 +4570,7 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_SCHEMA), errmsg("schema with OID %u does not exist", nsp_oid))); - ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner; + ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner; aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, Anum_pg_namespace_nspacl, &isNull); @@ -4634,7 +4634,7 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("tablespace with OID %u does not exist", spc_oid))); - ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner; + ownerId = (GETSTRUCT(pg_tablespace, tuple))->spcowner; aclDatum = SysCacheGetAttr(TABLESPACEOID, tuple, Anum_pg_tablespace_spcacl, @@ -4693,7 +4693,7 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign-data wrapper with OID %u does not exist", fdw_oid))); - fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple); + fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tuple); /* * Normal case: get the FDW's ACL from pg_foreign_data_wrapper @@ -4755,7 +4755,7 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign server with OID %u does not exist", srv_oid))); - srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple); + srvForm = GETSTRUCT(pg_foreign_server, tuple); /* * Normal case: get the foreign server's ACL from pg_foreign_server @@ -4815,7 +4815,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type with OID %u does not exist", type_oid))); - typeForm = (Form_pg_type) GETSTRUCT(tuple); + typeForm = GETSTRUCT(pg_type, tuple); /* * "True" array types don't manage permissions of their own; consult the @@ -4831,7 +4831,7 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how) /* this case is not a user-facing error, so elog not ereport */ if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", elttype_oid); - typeForm = (Form_pg_type) GETSTRUCT(tuple); + typeForm = GETSTRUCT(pg_type, tuple); } /* @@ -4936,7 +4936,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode, classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(table_oid)); if (!HeapTupleIsValid(classTuple)) return ACLCHECK_NO_PRIV; - classForm = (Form_pg_class) GETSTRUCT(classTuple); + classForm = GETSTRUCT(pg_class, classTuple); nattrs = classForm->relnatts; @@ -4960,7 +4960,7 @@ pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode, continue; /* ignore dropped columns */ - if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped) + if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped) { ReleaseSysCache(attTuple); continue; @@ -5183,7 +5183,7 @@ pg_class_ownercheck(Oid class_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_TABLE), errmsg("relation with OID %u does not exist", class_oid))); - ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner; + ownerId = (GETSTRUCT(pg_class, tuple))->relowner; ReleaseSysCache(tuple); @@ -5209,7 +5209,7 @@ pg_type_ownercheck(Oid type_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type with OID %u does not exist", type_oid))); - ownerId = ((Form_pg_type) GETSTRUCT(tuple))->typowner; + ownerId = (GETSTRUCT(pg_type, tuple))->typowner; ReleaseSysCache(tuple); @@ -5235,7 +5235,7 @@ pg_oper_ownercheck(Oid oper_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("operator with OID %u does not exist", oper_oid))); - ownerId = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner; + ownerId = (GETSTRUCT(pg_operator, tuple))->oprowner; ReleaseSysCache(tuple); @@ -5261,7 +5261,7 @@ pg_proc_ownercheck(Oid proc_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function with OID %u does not exist", proc_oid))); - ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner; + ownerId = (GETSTRUCT(pg_proc, tuple))->proowner; ReleaseSysCache(tuple); @@ -5287,7 +5287,7 @@ pg_language_ownercheck(Oid lan_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("language with OID %u does not exist", lan_oid))); - ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner; + ownerId = (GETSTRUCT(pg_language, tuple))->lanowner; ReleaseSysCache(tuple); @@ -5332,7 +5332,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("large object %u does not exist", lobj_oid))); - ownerId = ((Form_pg_largeobject_metadata) GETSTRUCT(tuple))->lomowner; + ownerId = (GETSTRUCT(pg_largeobject_metadata, tuple))->lomowner; systable_endscan(scan); table_close(pg_lo_meta, AccessShareLock); @@ -5359,7 +5359,7 @@ pg_namespace_ownercheck(Oid nsp_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_SCHEMA), errmsg("schema with OID %u does not exist", nsp_oid))); - ownerId = ((Form_pg_namespace) GETSTRUCT(tuple))->nspowner; + ownerId = (GETSTRUCT(pg_namespace, tuple))->nspowner; ReleaseSysCache(tuple); @@ -5386,7 +5386,7 @@ pg_tablespace_ownercheck(Oid spc_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("tablespace with OID %u does not exist", spc_oid))); - spcowner = ((Form_pg_tablespace) GETSTRUCT(spctuple))->spcowner; + spcowner = (GETSTRUCT(pg_tablespace, spctuple))->spcowner; ReleaseSysCache(spctuple); @@ -5413,7 +5413,7 @@ pg_opclass_ownercheck(Oid opc_oid, Oid roleid) errmsg("operator class with OID %u does not exist", opc_oid))); - ownerId = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner; + ownerId = (GETSTRUCT(pg_opclass, tuple))->opcowner; ReleaseSysCache(tuple); @@ -5440,7 +5440,7 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid) errmsg("operator family with OID %u does not exist", opf_oid))); - ownerId = ((Form_pg_opfamily) GETSTRUCT(tuple))->opfowner; + ownerId = (GETSTRUCT(pg_opfamily, tuple))->opfowner; ReleaseSysCache(tuple); @@ -5467,7 +5467,7 @@ pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid) errmsg("text search dictionary with OID %u does not exist", dict_oid))); - ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner; + ownerId = (GETSTRUCT(pg_ts_dict, tuple))->dictowner; ReleaseSysCache(tuple); @@ -5494,7 +5494,7 @@ pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid) errmsg("text search configuration with OID %u does not exist", cfg_oid))); - ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner; + ownerId = (GETSTRUCT(pg_ts_config, tuple))->cfgowner; ReleaseSysCache(tuple); @@ -5521,7 +5521,7 @@ pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid) errmsg("foreign-data wrapper with OID %u does not exist", srv_oid))); - ownerId = ((Form_pg_foreign_data_wrapper) GETSTRUCT(tuple))->fdwowner; + ownerId = (GETSTRUCT(pg_foreign_data_wrapper, tuple))->fdwowner; ReleaseSysCache(tuple); @@ -5548,7 +5548,7 @@ pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid) errmsg("foreign server with OID %u does not exist", srv_oid))); - ownerId = ((Form_pg_foreign_server) GETSTRUCT(tuple))->srvowner; + ownerId = (GETSTRUCT(pg_foreign_server, tuple))->srvowner; ReleaseSysCache(tuple); @@ -5575,7 +5575,7 @@ pg_event_trigger_ownercheck(Oid et_oid, Oid roleid) errmsg("event trigger with OID %u does not exist", et_oid))); - ownerId = ((Form_pg_event_trigger) GETSTRUCT(tuple))->evtowner; + ownerId = (GETSTRUCT(pg_event_trigger, tuple))->evtowner; ReleaseSysCache(tuple); @@ -5601,7 +5601,7 @@ pg_database_ownercheck(Oid db_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database with OID %u does not exist", db_oid))); - dba = ((Form_pg_database) GETSTRUCT(tuple))->datdba; + dba = (GETSTRUCT(pg_database, tuple))->datdba; ReleaseSysCache(tuple); @@ -5627,7 +5627,7 @@ pg_collation_ownercheck(Oid coll_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("collation with OID %u does not exist", coll_oid))); - ownerId = ((Form_pg_collation) GETSTRUCT(tuple))->collowner; + ownerId = (GETSTRUCT(pg_collation, tuple))->collowner; ReleaseSysCache(tuple); @@ -5653,7 +5653,7 @@ pg_conversion_ownercheck(Oid conv_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("conversion with OID %u does not exist", conv_oid))); - ownerId = ((Form_pg_conversion) GETSTRUCT(tuple))->conowner; + ownerId = (GETSTRUCT(pg_conversion, tuple))->conowner; ReleaseSysCache(tuple); @@ -5694,7 +5694,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("extension with OID %u does not exist", ext_oid))); - ownerId = ((Form_pg_extension) GETSTRUCT(tuple))->extowner; + ownerId = (GETSTRUCT(pg_extension, tuple))->extowner; systable_endscan(scan); table_close(pg_extension, AccessShareLock); @@ -5721,7 +5721,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("publication with OID %u does not exist", pub_oid))); - ownerId = ((Form_pg_publication) GETSTRUCT(tuple))->pubowner; + ownerId = (GETSTRUCT(pg_publication, tuple))->pubowner; ReleaseSysCache(tuple); @@ -5747,7 +5747,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("subscription with OID %u does not exist", sub_oid))); - ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner; + ownerId = (GETSTRUCT(pg_subscription, tuple))->subowner; ReleaseSysCache(tuple); @@ -5774,7 +5774,7 @@ pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid) errmsg("statistics object with OID %u does not exist", stat_oid))); - ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->stxowner; + ownerId = (GETSTRUCT(pg_statistic_ext, tuple))->stxowner; ReleaseSysCache(tuple); @@ -5805,7 +5805,7 @@ has_createrole_privilege(Oid roleid) utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(utup)) { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreaterole; + result = (GETSTRUCT(pg_authid, utup))->rolcreaterole; ReleaseSysCache(utup); } return result; @@ -5824,7 +5824,7 @@ has_bypassrls_privilege(Oid roleid) utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(utup)) { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolbypassrls; + result = (GETSTRUCT(pg_authid, utup))->rolbypassrls; ReleaseSysCache(utup); } return result; @@ -5996,7 +5996,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", objoid); - pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); + pg_class_tuple = GETSTRUCT(pg_class, tuple); /* * Indexes don't have permissions, neither do the pg_class rows for @@ -6033,7 +6033,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid) continue; /* ignore dropped columns */ - if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped) + if ((GETSTRUCT(pg_attribute, attTuple))->attisdropped) { ReleaseSysCache(attTuple); continue; @@ -6290,7 +6290,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", objoid); - pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); + pg_class_tuple = GETSTRUCT(pg_class, tuple); /* * Indexes don't have permissions, neither do the pg_class rows for diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 6f43870779..31e06aab3e 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -629,7 +629,7 @@ pg_nextoid(PG_FUNCTION_ARGS) errmsg("column \"%s\" of relation \"%s\" does not exist", NameStr(*attname), RelationGetRelationName(rel)))); - attform = ((Form_pg_attribute) GETSTRUCT(atttuple)); + attform = (GETSTRUCT(pg_attribute, atttuple)); attno = attform->attnum; if (attform->atttypid != OIDOID) diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index de10923391..4c96444617 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -577,7 +577,7 @@ findDependentObjects(const ObjectAddress *object, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup); otherObject.classId = foundDep->refclassid; otherObject.objectId = foundDep->refobjid; @@ -866,7 +866,7 @@ findDependentObjects(const ObjectAddress *object, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend foundDep = GETSTRUCT(pg_depend, tup); int subflags; otherObject.classId = foundDep->classid; diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index e770ea6eb8..3c4778a5d4 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -1664,7 +1664,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relid); - attStruct = (Form_pg_attribute) GETSTRUCT(tuple); + attStruct = GETSTRUCT(pg_attribute, tuple); if (attnum < 0) { @@ -1776,7 +1776,7 @@ heap_drop_with_catalog(Oid relid) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - if (((Form_pg_class) GETSTRUCT(tuple))->relispartition) + if ((GETSTRUCT(pg_class, tuple))->relispartition) { /* * We have to lock the parent if the partition is being detached, @@ -1973,7 +1973,7 @@ RelationClearMissing(Relation rel) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relid); - attrtuple = (Form_pg_attribute) GETSTRUCT(tuple); + attrtuple = GETSTRUCT(pg_attribute, tuple); /* ignore any where atthasmissing is not true */ if (attrtuple->atthasmissing) @@ -2032,7 +2032,7 @@ SetAttrMissing(Oid relid, char *attname, char *value) if (!HeapTupleIsValid(atttup)) elog(ERROR, "cache lookup failed for attribute %s of relation %u", attname, relid); - attStruct = (Form_pg_attribute) GETSTRUCT(atttup); + attStruct = GETSTRUCT(pg_attribute, atttup); /* get an array value from the value string */ missingval = OidFunctionCall3(F_ARRAY_IN, @@ -2536,7 +2536,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, /* There can be at most one matching row */ if (HeapTupleIsValid(tup = systable_getnext(conscan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tup); /* Found it. Conflicts if not identical check constraint */ if (con->contype == CONSTRAINT_CHECK) @@ -2605,7 +2605,7 @@ MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, ccname))); tup = heap_copytuple(tup); - con = (Form_pg_constraint) GETSTRUCT(tup); + con = GETSTRUCT(pg_constraint, tup); /* * In case of partitions, an inherited constraint must be inherited @@ -2663,7 +2663,7 @@ SetRelationNumChecks(Relation rel, int numchecks) if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup failed for relation %u", RelationGetRelid(rel)); - relStruct = (Form_pg_class) GETSTRUCT(reltup); + relStruct = GETSTRUCT(pg_class, reltup); if (relStruct->relchecks != numchecks) { @@ -2882,7 +2882,7 @@ CopyStatistics(Oid fromrelid, Oid torelid) /* make a modifiable copy */ tup = heap_copytuple(tup); - statform = (Form_pg_statistic) GETSTRUCT(tup); + statform = GETSTRUCT(pg_statistic, tup); /* update the copy of the tuple and insert it */ statform->starelid = torelid; @@ -3207,7 +3207,7 @@ restart: while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple); /* Not a foreign key */ if (con->contype != CONSTRAINT_FOREIGN) @@ -3259,7 +3259,7 @@ restart: tuple = systable_getnext(fkeyScan); if (HeapTupleIsValid(tuple)) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple); /* * pg_constraint rows always appear for partitioned hierarchies @@ -3486,7 +3486,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound) Form_pg_class classForm; bool isnull; - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); Assert(!classForm->relispartition); (void) SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relpartbound, &isnull); @@ -3504,7 +3504,7 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound) newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel), new_val, new_null, new_repl); /* Also set the flag */ - ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = true; + (GETSTRUCT(pg_class, newtuple))->relispartition = true; CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple); heap_freetuple(newtuple); table_close(classRel, RowExclusiveLock); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index c5d463ac55..bd909be6d1 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -170,7 +170,7 @@ relationHasPrimaryKey(Relation rel) indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid)); if (!HeapTupleIsValid(indexTuple)) /* should not happen */ elog(ERROR, "cache lookup failed for index %u", indexoid); - result = ((Form_pg_index) GETSTRUCT(indexTuple))->indisprimary; + result = (GETSTRUCT(pg_index, indexTuple))->indisprimary; ReleaseSysCache(indexTuple); if (result) break; @@ -251,7 +251,7 @@ index_check_primary_key(Relation heapRel, if (!HeapTupleIsValid(atttuple)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, RelationGetRelid(heapRel)); - attform = (Form_pg_attribute) GETSTRUCT(atttuple); + attform = GETSTRUCT(pg_attribute, atttuple); if (!attform->attnotnull) ereport(ERROR, @@ -369,7 +369,7 @@ ConstructTupleDescriptor(Relation heapRelation, tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", keyType); - typeTup = (Form_pg_type) GETSTRUCT(tuple); + typeTup = GETSTRUCT(pg_type, tuple); /* * Assign some of the attributes values. Leave the rest. @@ -426,7 +426,7 @@ ConstructTupleDescriptor(Relation heapRelation, if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for opclass %u", classObjectId[i]); - opclassTup = (Form_pg_opclass) GETSTRUCT(tuple); + opclassTup = GETSTRUCT(pg_opclass, tuple); if (OidIsValid(opclassTup->opckeytype)) keyType = opclassTup->opckeytype; @@ -459,7 +459,7 @@ ConstructTupleDescriptor(Relation heapRelation, tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", keyType); - typeTup = (Form_pg_type) GETSTRUCT(tuple); + typeTup = GETSTRUCT(pg_type, tuple); to->atttypid = keyType; to->atttypmod = -1; @@ -812,7 +812,7 @@ index_create(Relation heapRelation, ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("nondeterministic collations are not supported for operator class \"%s\"", - NameStr(((Form_pg_opclass) GETSTRUCT(classtup))->opcname)))); + NameStr((GETSTRUCT(pg_opclass, classtup))->opcname)))); ReleaseSysCache(classtup); } } @@ -1547,8 +1547,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName) if (!HeapTupleIsValid(newClassTuple)) elog(ERROR, "could not find tuple for relation %u", newIndexId); - oldClassForm = (Form_pg_class) GETSTRUCT(oldClassTuple); - newClassForm = (Form_pg_class) GETSTRUCT(newClassTuple); + oldClassForm = GETSTRUCT(pg_class, oldClassTuple); + newClassForm = GETSTRUCT(pg_class, newClassTuple); /* Swap the names */ namestrcpy(&newClassForm->relname, NameStr(oldClassForm->relname)); @@ -1577,8 +1577,8 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName) if (!HeapTupleIsValid(newIndexTuple)) elog(ERROR, "could not find tuple for relation %u", newIndexId); - oldIndexForm = (Form_pg_index) GETSTRUCT(oldIndexTuple); - newIndexForm = (Form_pg_index) GETSTRUCT(newIndexTuple); + oldIndexForm = GETSTRUCT(pg_index, oldIndexTuple); + newIndexForm = GETSTRUCT(pg_index, newIndexTuple); /* * Copy constraint flags from the old index. This is safe because the old @@ -1641,7 +1641,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName) if (!HeapTupleIsValid(constraintTuple)) elog(ERROR, "could not find tuple for constraint %u", constraintOid); - conForm = ((Form_pg_constraint) GETSTRUCT(constraintTuple)); + conForm = (GETSTRUCT(pg_constraint, constraintTuple)); if (conForm->conindid == oldIndexId) { @@ -1663,14 +1663,14 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName) while (HeapTupleIsValid((triggerTuple = systable_getnext(scan)))) { - Form_pg_trigger tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple); + Form_pg_trigger tgForm = GETSTRUCT(pg_trigger, triggerTuple); if (tgForm->tgconstrindid != oldIndexId) continue; /* Make a modifiable copy */ triggerTuple = heap_copytuple(triggerTuple); - tgForm = (Form_pg_trigger) GETSTRUCT(triggerTuple); + tgForm = GETSTRUCT(pg_trigger, triggerTuple); tgForm->tgconstrindid = newIndexId; @@ -1776,7 +1776,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName) while (HeapTupleIsValid((attrTuple = systable_getnext(scan)))) { - Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attrTuple); + Form_pg_attribute att = GETSTRUCT(pg_attribute, attrTuple); Datum repl_val[Natts_pg_attribute]; bool repl_null[Natts_pg_attribute]; bool repl_repl[Natts_pg_attribute]; @@ -2078,7 +2078,7 @@ index_constraint_create(Relation heapRelation, ObjectIdGetDatum(indexRelationId)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexRelationId); - indexForm = (Form_pg_index) GETSTRUCT(indexTuple); + indexForm = GETSTRUCT(pg_index, indexTuple); if (mark_as_primary && !indexForm->indisprimary) { @@ -2854,7 +2854,7 @@ index_update_stats(Relation rel, if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for relation %u", relid); - rd_rel = (Form_pg_class) GETSTRUCT(tuple); + rd_rel = GETSTRUCT(pg_class, tuple); /* Should this be a more comprehensive test? */ Assert(rd_rel->relkind != RELKIND_PARTITIONED_INDEX); @@ -3078,7 +3078,7 @@ index_build(Relation heapRelation, ObjectIdGetDatum(indexId)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexId); - indexForm = (Form_pg_index) GETSTRUCT(indexTuple); + indexForm = GETSTRUCT(pg_index, indexTuple); /* If it's a new index, indcheckxmin shouldn't be set ... */ Assert(!indexForm->indcheckxmin); @@ -3450,7 +3450,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action) ObjectIdGetDatum(indexId)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexId); - indexForm = (Form_pg_index) GETSTRUCT(indexTuple); + indexForm = GETSTRUCT(pg_index, indexTuple); /* Perform the requested state change on the copy */ switch (action) @@ -3531,7 +3531,7 @@ IndexGetRelation(Oid indexId, bool missing_ok) return InvalidOid; elog(ERROR, "cache lookup failed for index %u", indexId); } - index = (Form_pg_index) GETSTRUCT(tuple); + index = GETSTRUCT(pg_index, tuple); Assert(index->indexrelid == indexId); result = index->indrelid; @@ -3768,7 +3768,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, ObjectIdGetDatum(indexId)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexId); - indexForm = (Form_pg_index) GETSTRUCT(indexTuple); + indexForm = GETSTRUCT(pg_index, indexTuple); index_bad = (!indexForm->indisvalid || !indexForm->indisready || diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index fafb9349cc..737cc9d64b 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -717,7 +717,7 @@ RelationIsVisible(Oid relid) reltup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup failed for relation %u", relid); - relform = (Form_pg_class) GETSTRUCT(reltup); + relform = GETSTRUCT(pg_class, reltup); recomputeNamespacePath(); @@ -825,7 +825,7 @@ TypeIsVisible(Oid typid) typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(typtup)) elog(ERROR, "cache lookup failed for type %u", typid); - typform = (Form_pg_type) GETSTRUCT(typtup); + typform = GETSTRUCT(pg_type, typtup); recomputeNamespacePath(); @@ -986,7 +986,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames, for (i = 0; i < catlist->n_members; i++) { HeapTuple proctup = &catlist->members[i]->tuple; - Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup); + Form_pg_proc procform = GETSTRUCT(pg_proc, proctup); Oid *proargtypes = procform->proargtypes.values; int pronargs = procform->pronargs; int effective_nargs; @@ -1349,7 +1349,7 @@ MatchNamedCall(HeapTuple proctup, int nargs, List *argnames, bool include_out_arguments, int pronargs, int **argnumbers) { - Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup); + Form_pg_proc procform = GETSTRUCT(pg_proc, proctup); int numposargs = nargs - list_length(argnames); int pronallargs; Oid *p_argtypes; @@ -1466,7 +1466,7 @@ FunctionIsVisible(Oid funcid) proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); recomputeNamespacePath(); @@ -1553,7 +1553,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright) ObjectIdGetDatum(namespaceId)); if (HeapTupleIsValid(opertup)) { - Form_pg_operator operclass = (Form_pg_operator) GETSTRUCT(opertup); + Form_pg_operator operclass = GETSTRUCT(pg_operator, opertup); Oid result = operclass->oid; ReleaseSysCache(opertup); @@ -1595,7 +1595,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright) for (i = 0; i < catlist->n_members; i++) { HeapTuple opertup = &catlist->members[i]->tuple; - Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup); + Form_pg_operator operform = GETSTRUCT(pg_operator, opertup); if (operform->oprnamespace == namespaceId) { @@ -1678,7 +1678,7 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok) for (i = 0; i < catlist->n_members; i++) { HeapTuple opertup = &catlist->members[i]->tuple; - Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup); + Form_pg_operator operform = GETSTRUCT(pg_operator, opertup); int pathpos = 0; FuncCandidateList newResult; @@ -1800,7 +1800,7 @@ OperatorIsVisible(Oid oprid) oprtup = SearchSysCache1(OPEROID, ObjectIdGetDatum(oprid)); if (!HeapTupleIsValid(oprtup)) elog(ERROR, "cache lookup failed for operator %u", oprid); - oprform = (Form_pg_operator) GETSTRUCT(oprtup); + oprform = GETSTRUCT(pg_operator, oprtup); recomputeNamespacePath(); @@ -1886,7 +1886,7 @@ OpclassIsVisible(Oid opcid) opctup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opcid)); if (!HeapTupleIsValid(opctup)) elog(ERROR, "cache lookup failed for opclass %u", opcid); - opcform = (Form_pg_opclass) GETSTRUCT(opctup); + opcform = GETSTRUCT(pg_opclass, opctup); recomputeNamespacePath(); @@ -1969,7 +1969,7 @@ OpfamilyIsVisible(Oid opfid) opftup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid)); if (!HeapTupleIsValid(opftup)) elog(ERROR, "cache lookup failed for opfamily %u", opfid); - opfform = (Form_pg_opfamily) GETSTRUCT(opftup); + opfform = GETSTRUCT(pg_opfamily, opftup); recomputeNamespacePath(); @@ -2032,7 +2032,7 @@ lookup_collation(const char *collname, Oid collnamespace, int32 encoding) ObjectIdGetDatum(collnamespace)); if (!HeapTupleIsValid(colltup)) return InvalidOid; - collform = (Form_pg_collation) GETSTRUCT(colltup); + collform = GETSTRUCT(pg_collation, colltup); if (collform->collprovider == COLLPROVIDER_ICU) { if (is_encoding_supported_by_icu(encoding)) @@ -2101,7 +2101,7 @@ CollationIsVisible(Oid collid) colltup = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid)); if (!HeapTupleIsValid(colltup)) elog(ERROR, "cache lookup failed for collation %u", collid); - collform = (Form_pg_collation) GETSTRUCT(colltup); + collform = GETSTRUCT(pg_collation, colltup); recomputeNamespacePath(); @@ -2184,7 +2184,7 @@ ConversionIsVisible(Oid conid) contup = SearchSysCache1(CONVOID, ObjectIdGetDatum(conid)); if (!HeapTupleIsValid(contup)) elog(ERROR, "cache lookup failed for conversion %u", conid); - conform = (Form_pg_conversion) GETSTRUCT(contup); + conform = GETSTRUCT(pg_conversion, contup); recomputeNamespacePath(); @@ -2288,7 +2288,7 @@ StatisticsObjIsVisible(Oid relid) stxtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(stxtup)) elog(ERROR, "cache lookup failed for statistics object %u", relid); - stxform = (Form_pg_statistic_ext) GETSTRUCT(stxtup); + stxform = GETSTRUCT(pg_statistic_ext, stxtup); recomputeNamespacePath(); @@ -2411,7 +2411,7 @@ TSParserIsVisible(Oid prsId) tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for text search parser %u", prsId); - form = (Form_pg_ts_parser) GETSTRUCT(tup); + form = GETSTRUCT(pg_ts_parser, tup); recomputeNamespacePath(); @@ -2538,7 +2538,7 @@ TSDictionaryIsVisible(Oid dictId) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for text search dictionary %u", dictId); - form = (Form_pg_ts_dict) GETSTRUCT(tup); + form = GETSTRUCT(pg_ts_dict, tup); recomputeNamespacePath(); @@ -2664,7 +2664,7 @@ TSTemplateIsVisible(Oid tmplId) tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for text search template %u", tmplId); - form = (Form_pg_ts_template) GETSTRUCT(tup); + form = GETSTRUCT(pg_ts_template, tup); recomputeNamespacePath(); @@ -2791,7 +2791,7 @@ TSConfigIsVisible(Oid cfgid) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for text search configuration %u", cfgid); - form = (Form_pg_ts_config) GETSTRUCT(tup); + form = GETSTRUCT(pg_ts_config, tup); recomputeNamespacePath(); @@ -3835,7 +3835,7 @@ recomputeNamespacePath(void) { char *rname; - rname = NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname); + rname = NameStr((GETSTRUCT(pg_authid, tuple))->rolname); namespaceId = get_namespace_oid(rname, true); ReleaseSysCache(tuple); if (OidIsValid(namespaceId) && diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 6080ff8f5f..4991a76c41 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -1643,7 +1643,7 @@ get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok) if (objtype == OBJECT_DOMAIN) { - if (((Form_pg_type) GETSTRUCT(tup))->typtype != TYPTYPE_DOMAIN) + if ((GETSTRUCT(pg_type, tup))->typtype != TYPTYPE_DOMAIN) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a domain", @@ -1762,7 +1762,7 @@ get_object_address_opf_member(ObjectType objtype, } else { - address.objectId = ((Form_pg_amop) GETSTRUCT(tp))->oid; + address.objectId = (GETSTRUCT(pg_amop, tp))->oid; ReleaseSysCache(tp); } } @@ -1793,7 +1793,7 @@ get_object_address_opf_member(ObjectType objtype, } else { - address.objectId = ((Form_pg_amproc) GETSTRUCT(tp))->oid; + address.objectId = (GETSTRUCT(pg_amproc, tp))->oid; ReleaseSysCache(tp); } } @@ -1840,7 +1840,7 @@ get_object_address_usermapping(List *object, bool missing_ok) username, servername))); return address; } - userid = ((Form_pg_authid) GETSTRUCT(tp))->oid; + userid = (GETSTRUCT(pg_authid, tp))->oid; ReleaseSysCache(tp); } @@ -1867,7 +1867,7 @@ get_object_address_usermapping(List *object, bool missing_ok) return address; } - address.objectId = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid; + address.objectId = (GETSTRUCT(pg_user_mapping, tp))->oid; ReleaseSysCache(tp); @@ -2040,7 +2040,7 @@ get_object_address_defacl(List *object, bool missing_ok) CStringGetDatum(username)); if (!HeapTupleIsValid(tp)) goto not_found; - userid = ((Form_pg_authid) GETSTRUCT(tp))->oid; + userid = (GETSTRUCT(pg_authid, tp))->oid; ReleaseSysCache(tp); /* @@ -2064,7 +2064,7 @@ get_object_address_defacl(List *object, bool missing_ok) if (!HeapTupleIsValid(tp)) goto not_found; - address.objectId = ((Form_pg_default_acl) GETSTRUCT(tp))->oid; + address.objectId = (GETSTRUCT(pg_default_acl, tp))->oid; ReleaseSysCache(tp); return address; @@ -2440,7 +2440,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, elog(ERROR, "constraint with OID %u does not exist", address.objectId); - contypid = ((Form_pg_constraint) GETSTRUCT(tuple))->contypid; + contypid = (GETSTRUCT(pg_constraint, tuple))->contypid; ReleaseSysCache(tuple); @@ -2908,7 +2908,7 @@ getPublicationSchemaInfo(const ObjectAddress *object, bool missing_ok, return false; } - pnform = (Form_pg_publication_namespace) GETSTRUCT(tup); + pnform = GETSTRUCT(pg_publication_namespace, tup); *pubname = get_publication_name(pnform->pnpubid, missing_ok); if (!(*pubname)) { @@ -3028,7 +3028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - castForm = (Form_pg_cast) GETSTRUCT(tup); + castForm = GETSTRUCT(pg_cast, tup); appendStringInfo(&buffer, _("cast from %s to %s"), format_type_be(castForm->castsource), @@ -3055,7 +3055,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - coll = (Form_pg_collation) GETSTRUCT(collTup); + coll = GETSTRUCT(pg_collation, collTup); /* Qualify the name if not visible in search path */ if (CollationIsVisible(object->objectId)) @@ -3085,7 +3085,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - con = (Form_pg_constraint) GETSTRUCT(conTup); + con = GETSTRUCT(pg_constraint, conTup); if (OidIsValid(con->conrelid)) { @@ -3124,7 +3124,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - conv = (Form_pg_conversion) GETSTRUCT(conTup); + conv = GETSTRUCT(pg_conversion, conTup); /* Qualify the name if not visible in search path */ if (ConversionIsVisible(object->objectId)) @@ -3208,14 +3208,14 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - opcForm = (Form_pg_opclass) GETSTRUCT(opcTup); + opcForm = GETSTRUCT(pg_opclass, opcTup); amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opcForm->opcmethod)); if (!HeapTupleIsValid(amTup)) elog(ERROR, "cache lookup failed for access method %u", opcForm->opcmethod); - amForm = (Form_pg_am) GETSTRUCT(amTup); + amForm = GETSTRUCT(pg_am, amTup); /* Qualify the name if not visible in search path */ if (OpclassIsVisible(object->objectId)) @@ -3252,7 +3252,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) } appendStringInfo(&buffer, _("access method %s"), - NameStr(((Form_pg_am) GETSTRUCT(tup))->amname)); + NameStr((GETSTRUCT(pg_am, tup))->amname)); ReleaseSysCache(tup); break; } @@ -3290,7 +3290,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - amopForm = (Form_pg_amop) GETSTRUCT(tup); + amopForm = GETSTRUCT(pg_amop, tup); initStringInfo(&opfam); getOpFamilyDescription(&opfam, amopForm->amopfamily, false); @@ -3347,7 +3347,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - amprocForm = (Form_pg_amproc) GETSTRUCT(tup); + amprocForm = GETSTRUCT(pg_amproc, tup); initStringInfo(&opfam); getOpFamilyDescription(&opfam, amprocForm->amprocfamily, false); @@ -3403,7 +3403,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - rule = (Form_pg_rewrite) GETSTRUCT(tup); + rule = GETSTRUCT(pg_rewrite, tup); initStringInfo(&rel); getRelationDescription(&rel, rule->ev_class, false); @@ -3449,7 +3449,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - trig = (Form_pg_trigger) GETSTRUCT(tup); + trig = GETSTRUCT(pg_trigger, tup); initStringInfo(&rel); getRelationDescription(&rel, trig->tgrelid, false); @@ -3495,7 +3495,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup); + stxForm = GETSTRUCT(pg_statistic_ext, stxTup); /* Qualify the name if not visible in search path */ if (StatisticsObjIsVisible(object->objectId)) @@ -3526,7 +3526,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) object->objectId); break; } - prsForm = (Form_pg_ts_parser) GETSTRUCT(tup); + prsForm = GETSTRUCT(pg_ts_parser, tup); /* Qualify the name if not visible in search path */ if (TSParserIsVisible(object->objectId)) @@ -3557,7 +3557,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - dictForm = (Form_pg_ts_dict) GETSTRUCT(tup); + dictForm = GETSTRUCT(pg_ts_dict, tup); /* Qualify the name if not visible in search path */ if (TSDictionaryIsVisible(object->objectId)) @@ -3588,7 +3588,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - tmplForm = (Form_pg_ts_template) GETSTRUCT(tup); + tmplForm = GETSTRUCT(pg_ts_template, tup); /* Qualify the name if not visible in search path */ if (TSTemplateIsVisible(object->objectId)) @@ -3619,7 +3619,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - cfgForm = (Form_pg_ts_config) GETSTRUCT(tup); + cfgForm = GETSTRUCT(pg_ts_config, tup); /* Qualify the name if not visible in search path */ if (TSConfigIsVisible(object->objectId)) @@ -3715,7 +3715,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - umform = (Form_pg_user_mapping) GETSTRUCT(tup); + umform = GETSTRUCT(pg_user_mapping, tup); useid = umform->umuser; srv = GetForeignServer(umform->umserver); @@ -3764,7 +3764,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - defacl = (Form_pg_default_acl) GETSTRUCT(tup); + defacl = GETSTRUCT(pg_default_acl, tup); rolename = GetUserNameFromId(defacl->defaclrole, false); @@ -3869,7 +3869,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } appendStringInfo(&buffer, _("event trigger %s"), - NameStr(((Form_pg_event_trigger) GETSTRUCT(tup))->evtname)); + NameStr((GETSTRUCT(pg_event_trigger, tup))->evtname)); ReleaseSysCache(tup); break; } @@ -3932,7 +3932,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - form_policy = (Form_pg_policy) GETSTRUCT(tuple); + form_policy = GETSTRUCT(pg_policy, tuple); initStringInfo(&rel); getRelationDescription(&rel, form_policy->polrelid, false); @@ -3989,7 +3989,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - prform = (Form_pg_publication_rel) GETSTRUCT(tup); + prform = GETSTRUCT(pg_publication_rel, tup); pubname = get_publication_name(prform->prpubid, false); initStringInfo(&rel); @@ -4028,7 +4028,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok) break; } - trfForm = (Form_pg_transform) GETSTRUCT(trfTup); + trfForm = GETSTRUCT(pg_transform, trfTup); appendStringInfo(&buffer, _("transform for %s language %s"), format_type_be(trfForm->trftype), @@ -4087,7 +4087,7 @@ getRelationDescription(StringInfo buffer, Oid relid, bool missing_ok) elog(ERROR, "cache lookup failed for relation %u", relid); return; } - relForm = (Form_pg_class) GETSTRUCT(relTup); + relForm = GETSTRUCT(pg_class, relTup); /* Qualify the name if not visible in search path */ if (RelationIsVisible(relid)) @@ -4162,13 +4162,13 @@ getOpFamilyDescription(StringInfo buffer, Oid opfid, bool missing_ok) elog(ERROR, "cache lookup failed for opfamily %u", opfid); return; } - opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup); + opfForm = GETSTRUCT(pg_opfamily, opfTup); amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod)); if (!HeapTupleIsValid(amTup)) elog(ERROR, "cache lookup failed for access method %u", opfForm->opfmethod); - amForm = (Form_pg_am) GETSTRUCT(amTup); + amForm = GETSTRUCT(pg_am, amTup); /* Qualify the name if not visible in search path */ if (OpfamilyIsVisible(opfid)) @@ -4626,7 +4626,7 @@ getRelationTypeDescription(StringInfo buffer, Oid relid, int32 objectSubId, appendStringInfoString(buffer, "relation"); return; } - relForm = (Form_pg_class) GETSTRUCT(relTup); + relForm = GETSTRUCT(pg_class, relTup); switch (relForm->relkind) { @@ -4693,7 +4693,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid, bool missing_ok) return; } - constrForm = (Form_pg_constraint) GETSTRUCT(constrTup); + constrForm = GETSTRUCT(pg_constraint, constrTup); if (OidIsValid(constrForm->conrelid)) appendStringInfoString(buffer, "table constraint"); @@ -4726,7 +4726,7 @@ getProcedureTypeDescription(StringInfo buffer, Oid procid, appendStringInfoString(buffer, "routine"); return; } - procForm = (Form_pg_proc) GETSTRUCT(procTup); + procForm = GETSTRUCT(pg_proc, procTup); if (procForm->prokind == PROKIND_AGGREGATE) appendStringInfoString(buffer, "aggregate"); @@ -4870,7 +4870,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - castForm = (Form_pg_cast) GETSTRUCT(tup); + castForm = GETSTRUCT(pg_cast, tup); appendStringInfo(&buffer, "(%s AS %s)", format_type_be_qualified(castForm->castsource), @@ -4901,7 +4901,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - coll = (Form_pg_collation) GETSTRUCT(collTup); + coll = GETSTRUCT(pg_collation, collTup); schema = get_namespace_name_or_temp(coll->collnamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -4927,7 +4927,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - con = (Form_pg_constraint) GETSTRUCT(conTup); + con = GETSTRUCT(pg_constraint, conTup); if (OidIsValid(con->conrelid)) { @@ -4975,7 +4975,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - conForm = (Form_pg_conversion) GETSTRUCT(conTup); + conForm = GETSTRUCT(pg_conversion, conTup); schema = get_namespace_name_or_temp(conForm->connamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -5022,7 +5022,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - langForm = (Form_pg_language) GETSTRUCT(langTup); + langForm = GETSTRUCT(pg_language, langTup); appendStringInfoString(&buffer, quote_identifier(NameStr(langForm->lanname))); if (objname) @@ -5071,7 +5071,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - opcForm = (Form_pg_opclass) GETSTRUCT(opcTup); + opcForm = GETSTRUCT(pg_opclass, opcTup); schema = get_namespace_name_or_temp(opcForm->opcnamespace); amTup = SearchSysCache1(AMOID, @@ -5079,7 +5079,7 @@ getObjectIdentityParts(const ObjectAddress *object, if (!HeapTupleIsValid(amTup)) elog(ERROR, "cache lookup failed for access method %u", opcForm->opcmethod); - amForm = (Form_pg_am) GETSTRUCT(amTup); + amForm = GETSTRUCT(pg_am, amTup); appendStringInfo(&buffer, "%s USING %s", quote_qualified_identifier(schema, @@ -5153,7 +5153,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - amopForm = (Form_pg_amop) GETSTRUCT(tup); + amopForm = GETSTRUCT(pg_amop, tup); initStringInfo(&opfam); getOpFamilyIdentity(&opfam, amopForm->amopfamily, objname, @@ -5215,7 +5215,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - amprocForm = (Form_pg_amproc) GETSTRUCT(tup); + amprocForm = GETSTRUCT(pg_amproc, tup); initStringInfo(&opfam); getOpFamilyIdentity(&opfam, amprocForm->amprocfamily, objname, @@ -5263,7 +5263,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - rule = (Form_pg_rewrite) GETSTRUCT(tup); + rule = GETSTRUCT(pg_rewrite, tup); appendStringInfo(&buffer, "%s on ", quote_identifier(NameStr(rule->rulename))); @@ -5296,7 +5296,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - trig = (Form_pg_trigger) GETSTRUCT(tup); + trig = GETSTRUCT(pg_trigger, tup); appendStringInfo(&buffer, "%s on ", quote_identifier(NameStr(trig->tgname))); @@ -5342,7 +5342,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup); + formStatistic = GETSTRUCT(pg_statistic_ext, tup); schema = get_namespace_name_or_temp(formStatistic->stxnamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -5369,7 +5369,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - formParser = (Form_pg_ts_parser) GETSTRUCT(tup); + formParser = GETSTRUCT(pg_ts_parser, tup); schema = get_namespace_name_or_temp(formParser->prsnamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -5396,7 +5396,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - formDict = (Form_pg_ts_dict) GETSTRUCT(tup); + formDict = GETSTRUCT(pg_ts_dict, tup); schema = get_namespace_name_or_temp(formDict->dictnamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -5423,7 +5423,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - formTmpl = (Form_pg_ts_template) GETSTRUCT(tup); + formTmpl = GETSTRUCT(pg_ts_template, tup); schema = get_namespace_name_or_temp(formTmpl->tmplnamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -5450,7 +5450,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - formCfg = (Form_pg_ts_config) GETSTRUCT(tup); + formCfg = GETSTRUCT(pg_ts_config, tup); schema = get_namespace_name_or_temp(formCfg->cfgnamespace); appendStringInfoString(&buffer, quote_qualified_identifier(schema, @@ -5562,7 +5562,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - umform = (Form_pg_user_mapping) GETSTRUCT(tup); + umform = GETSTRUCT(pg_user_mapping, tup); useid = umform->umuser; srv = GetForeignServer(umform->umserver); @@ -5618,7 +5618,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - defacl = (Form_pg_default_acl) GETSTRUCT(tup); + defacl = GETSTRUCT(pg_default_acl, tup); username = GetUserNameFromId(defacl->defaclrole, false); appendStringInfo(&buffer, @@ -5705,7 +5705,7 @@ getObjectIdentityParts(const ObjectAddress *object, object->objectId); break; } - trigForm = (Form_pg_event_trigger) GETSTRUCT(tup); + trigForm = GETSTRUCT(pg_event_trigger, tup); evtname = pstrdup(NameStr(trigForm->evtname)); appendStringInfoString(&buffer, quote_identifier(evtname)); if (objname) @@ -5763,7 +5763,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - policy = (Form_pg_policy) GETSTRUCT(tup); + policy = GETSTRUCT(pg_policy, tup); appendStringInfo(&buffer, "%s on ", quote_identifier(NameStr(policy->polname))); @@ -5830,7 +5830,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - prform = (Form_pg_publication_rel) GETSTRUCT(tup); + prform = GETSTRUCT(pg_publication_rel, tup); pubname = get_publication_name(prform->prpubid, false); getRelationIdentity(&buffer, prform->prrelid, objname, false); @@ -5882,7 +5882,7 @@ getObjectIdentityParts(const ObjectAddress *object, break; } - transform = (Form_pg_transform) GETSTRUCT(tup); + transform = GETSTRUCT(pg_transform, tup); transformType = format_type_be_qualified(transform->trftype); transformLang = get_language_name(transform->trflang, false); @@ -5948,13 +5948,13 @@ getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object, elog(ERROR, "cache lookup failed for opfamily %u", opfid); return; } - opfForm = (Form_pg_opfamily) GETSTRUCT(opfTup); + opfForm = GETSTRUCT(pg_opfamily, opfTup); amTup = SearchSysCache1(AMOID, ObjectIdGetDatum(opfForm->opfmethod)); if (!HeapTupleIsValid(amTup)) elog(ERROR, "cache lookup failed for access method %u", opfForm->opfmethod); - amForm = (Form_pg_am) GETSTRUCT(amTup); + amForm = GETSTRUCT(pg_am, amTup); schema = get_namespace_name_or_temp(opfForm->opfnamespace); appendStringInfo(buffer, "%s USING %s", @@ -5994,7 +5994,7 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **object, *object = NIL; return; } - relForm = (Form_pg_class) GETSTRUCT(relTup); + relForm = GETSTRUCT(pg_class, relTup); schema = get_namespace_name_or_temp(relForm->relnamespace); appendStringInfoString(buffer, diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index c6ec479004..a3d4ebe38d 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -106,7 +106,7 @@ get_partition_parent_worker(Relation inhRel, Oid relid, bool *detach_pending) tuple = systable_getnext(scan); if (HeapTupleIsValid(tuple)) { - Form_pg_inherits form = (Form_pg_inherits) GETSTRUCT(tuple); + Form_pg_inherits form = GETSTRUCT(pg_inherits, tuple); /* Let caller know of partition being detached */ if (form->inhdetachpending) @@ -187,7 +187,7 @@ index_get_partition(Relation partition, Oid indexId) tup = SearchSysCache1(RELOID, ObjectIdGetDatum(partIdx)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for relation %u", partIdx); - classForm = (Form_pg_class) GETSTRUCT(tup); + classForm = GETSTRUCT(pg_class, tup); ispartition = classForm->relispartition; ReleaseSysCache(tup); if (!ispartition) @@ -321,7 +321,7 @@ get_default_partition_oid(Oid parentId) { Form_pg_partitioned_table part_table_form; - part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple); + part_table_form = GETSTRUCT(pg_partitioned_table, tuple); defaultPartId = part_table_form->partdefid; ReleaseSysCache(tuple); } @@ -349,7 +349,7 @@ update_default_partition_oid(Oid parentId, Oid defaultPartId) elog(ERROR, "cache lookup failed for partition key of relation %u", parentId); - part_table_form = (Form_pg_partitioned_table) GETSTRUCT(tuple); + part_table_form = GETSTRUCT(pg_partitioned_table, tuple); part_table_form->partdefid = defaultPartId; CatalogTupleUpdate(pg_partitioned_table, &tuple->t_self, tuple); diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 0d0daa69b3..392296edbe 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -250,7 +250,7 @@ AggregateCreate(const char *aggName, tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(transfn)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for function %u", transfn); - proc = (Form_pg_proc) GETSTRUCT(tup); + proc = GETSTRUCT(pg_proc, tup); /* * If the transfn is strict and the initval is NULL, make sure first input @@ -294,7 +294,7 @@ AggregateCreate(const char *aggName, tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(mtransfn)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for function %u", mtransfn); - proc = (Form_pg_proc) GETSTRUCT(tup); + proc = GETSTRUCT(pg_proc, tup); /* * If the mtransfn is strict and the minitval is NULL, check first @@ -339,7 +339,7 @@ AggregateCreate(const char *aggName, tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(minvtransfn)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for function %u", minvtransfn); - proc = (Form_pg_proc) GETSTRUCT(tup); + proc = GETSTRUCT(pg_proc, tup); /* * We require the strictness settings of the forward and inverse @@ -692,7 +692,7 @@ AggregateCreate(const char *aggName, if (HeapTupleIsValid(oldtup)) { - Form_pg_aggregate oldagg = (Form_pg_aggregate) GETSTRUCT(oldtup); + Form_pg_aggregate oldagg = GETSTRUCT(pg_aggregate, oldtup); /* * If we're replacing an existing entry, we need to validate that diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c index c5d4a9912e..d52e1050ed 100644 --- a/src/backend/catalog/pg_attrdef.c +++ b/src/backend/catalog/pg_attrdef.c @@ -101,7 +101,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, if (!HeapTupleIsValid(atttup)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, RelationGetRelid(rel)); - attStruct = (Form_pg_attribute) GETSTRUCT(atttup); + attStruct = GETSTRUCT(pg_attribute, atttup); attgenerated = attStruct->attgenerated; if (!attStruct->atthasdef) { @@ -240,7 +240,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum, while (HeapTupleIsValid(tuple = systable_getnext(scan))) { ObjectAddress object; - Form_pg_attrdef attrtuple = (Form_pg_attrdef) GETSTRUCT(tuple); + Form_pg_attrdef attrtuple = GETSTRUCT(pg_attrdef, tuple); object.classId = AttrDefaultRelationId; object.objectId = attrtuple->oid; @@ -295,8 +295,8 @@ RemoveAttrDefaultById(Oid attrdefId) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for attrdef %u", attrdefId); - myrelid = ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid; - myattnum = ((Form_pg_attrdef) GETSTRUCT(tuple))->adnum; + myrelid = (GETSTRUCT(pg_attrdef, tuple))->adrelid; + myattnum = (GETSTRUCT(pg_attrdef, tuple))->adnum; /* Get an exclusive lock on the relation owning the attribute */ myrel = relation_open(myrelid, AccessExclusiveLock); @@ -317,7 +317,7 @@ RemoveAttrDefaultById(Oid attrdefId) elog(ERROR, "cache lookup failed for attribute %d of relation %u", myattnum, myrelid); - ((Form_pg_attribute) GETSTRUCT(tuple))->atthasdef = false; + (GETSTRUCT(pg_attribute, tuple))->atthasdef = false; CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); @@ -363,7 +363,7 @@ GetAttrDefaultOid(Oid relid, AttrNumber attnum) if (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup); + Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup); result = atdform->oid; } @@ -399,7 +399,7 @@ GetAttrDefaultColumnAddress(Oid attrdefoid) if (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup); + Form_pg_attrdef atdform = GETSTRUCT(pg_attrdef, tup); result.classId = RelationRelationId; result.objectId = atdform->adrelid; diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c index bb65fb1e0a..48f1653242 100644 --- a/src/backend/catalog/pg_constraint.c +++ b/src/backend/catalog/pg_constraint.c @@ -577,7 +577,7 @@ RemoveConstraintById(Oid conId) tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conId)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for constraint %u", conId); - con = (Form_pg_constraint) GETSTRUCT(tup); + con = GETSTRUCT(pg_constraint, tup); /* * Special processing depending on what the constraint is for. @@ -609,7 +609,7 @@ RemoveConstraintById(Oid conId) if (!HeapTupleIsValid(relTup)) elog(ERROR, "cache lookup failed for relation %u", con->conrelid); - classForm = (Form_pg_class) GETSTRUCT(relTup); + classForm = GETSTRUCT(pg_class, relTup); if (classForm->relchecks == 0) /* should not happen */ elog(ERROR, "relation \"%s\" has relchecks = 0", @@ -668,7 +668,7 @@ RenameConstraintById(Oid conId, const char *newname) tuple = SearchSysCacheCopy1(CONSTROID, ObjectIdGetDatum(conId)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", conId); - con = (Form_pg_constraint) GETSTRUCT(tuple); + con = GETSTRUCT(pg_constraint, tuple); /* * For user-friendliness, check whether the name is already in use. @@ -733,7 +733,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, while (HeapTupleIsValid((tup = systable_getnext(scan)))) { - Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(tup); + Form_pg_constraint conform = GETSTRUCT(pg_constraint, tup); ObjectAddress thisobj; ObjectAddressSet(thisobj, ConstraintRelationId, conform->oid); @@ -745,7 +745,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, if (conform->connamespace == oldNspId && oldNspId != newNspId) { tup = heap_copytuple(tup); - conform = (Form_pg_constraint) GETSTRUCT(tup); + conform = GETSTRUCT(pg_constraint, tup); conform->connamespace = newNspId; @@ -794,7 +794,7 @@ ConstraintSetParentConstraint(Oid childConstrId, if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", childConstrId); newtup = heap_copytuple(tuple); - constrForm = (Form_pg_constraint) GETSTRUCT(newtup); + constrForm = GETSTRUCT(pg_constraint, newtup); if (OidIsValid(parentConstrId)) { /* don't allow setting parent for a constraint that already has one */ @@ -875,7 +875,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok) /* There can be at most one matching row */ if (HeapTupleIsValid(tuple = systable_getnext(scan))) - conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid; + conOid = (GETSTRUCT(pg_constraint, tuple))->oid; systable_endscan(scan); @@ -940,7 +940,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname, Datum adatum; bool isNull; - *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid; + *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid; /* Extract the conkey array, ie, attnums of constrained columns */ adatum = heap_getattr(tuple, Anum_pg_constraint_conkey, @@ -1010,7 +1010,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId) { Form_pg_constraint constrForm; - constrForm = (Form_pg_constraint) GETSTRUCT(tuple); + constrForm = GETSTRUCT(pg_constraint, tuple); if (constrForm->conindid == indexId) { constraintId = constrForm->oid; @@ -1057,7 +1057,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok) /* There can be at most one matching row */ if (HeapTupleIsValid(tuple = systable_getnext(scan))) - conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid; + conOid = (GETSTRUCT(pg_constraint, tuple))->oid; systable_endscan(scan); @@ -1112,7 +1112,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid) while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple); Datum adatum; bool isNull; ArrayType *arr; @@ -1137,7 +1137,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid) RelationGetDescr(pg_constraint), &isNull); if (isNull) elog(ERROR, "null conkey for constraint %u", - ((Form_pg_constraint) GETSTRUCT(tuple))->oid); + (GETSTRUCT(pg_constraint, tuple))->oid); arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */ numkeys = ARR_DIMS(arr)[0]; if (ARR_NDIM(arr) != 1 || @@ -1153,7 +1153,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid) pkattnos = bms_add_member(pkattnos, attnums[i] - FirstLowInvalidHeapAttributeNumber); } - *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid; + *constraintOid = (GETSTRUCT(pg_constraint, tuple))->oid; /* No need to search further */ break; @@ -1185,7 +1185,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks, ArrayType *arr; int numkeys; - constrId = ((Form_pg_constraint) GETSTRUCT(tuple))->oid; + constrId = (GETSTRUCT(pg_constraint, tuple))->oid; /* * We expect the arrays to be 1-D arrays of the right types; verify that. diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c index 3d8b86ace7..4a39593d4a 100644 --- a/src/backend/catalog/pg_conversion.c +++ b/src/backend/catalog/pg_conversion.c @@ -168,7 +168,7 @@ FindDefaultConversion(Oid name_space, int32 for_encoding, int32 to_encoding) for (i = 0; i < catlist->n_members; i++) { tuple = &catlist->members[i]->tuple; - body = (Form_pg_conversion) GETSTRUCT(tuple); + body = GETSTRUCT(pg_conversion, tuple); if (body->condefault) { proc = body->conproc; diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c index e86e5e6898..20ebdcc6e6 100644 --- a/src/backend/catalog/pg_depend.c +++ b/src/backend/catalog/pg_depend.c @@ -266,7 +266,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId, while (HeapTupleIsValid(tup = systable_getnext(scan))) { if (skipExtensionDeps && - ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION) + (GETSTRUCT(pg_depend, tup))->deptype == DEPENDENCY_EXTENSION) continue; CatalogTupleDelete(depRel, &tup->t_self); @@ -315,7 +315,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depform = GETSTRUCT(pg_depend, tup); if (depform->refclassid == refclassId && depform->deptype == deptype) { @@ -362,7 +362,7 @@ deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depform = GETSTRUCT(pg_depend, tup); if (depform->refclassid == refclassId && depform->refobjid == refobjectId && @@ -464,7 +464,7 @@ changeDependencyFor(Oid classId, Oid objectId, while (HeapTupleIsValid((tup = systable_getnext(scan)))) { - Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depform = GETSTRUCT(pg_depend, tup); if (depform->refclassid == refClassId && depform->refobjid == oldRefObjectId) @@ -475,7 +475,7 @@ changeDependencyFor(Oid classId, Oid objectId, { /* make a modifiable copy */ tup = heap_copytuple(tup); - depform = (Form_pg_depend) GETSTRUCT(tup); + depform = GETSTRUCT(pg_depend, tup); depform->refobjid = newRefObjectId; @@ -533,7 +533,7 @@ changeDependenciesOf(Oid classId, Oid oldObjectId, /* make a modifiable copy */ tup = heap_copytuple(tup); - depform = (Form_pg_depend) GETSTRUCT(tup); + depform = GETSTRUCT(pg_depend, tup); depform->objid = newObjectId; @@ -620,7 +620,7 @@ changeDependenciesOn(Oid refClassId, Oid oldRefObjectId, /* make a modifiable copy */ tup = heap_copytuple(tup); - depform = (Form_pg_depend) GETSTRUCT(tup); + depform = GETSTRUCT(pg_depend, tup); depform->refobjid = newRefObjectId; @@ -695,7 +695,7 @@ getExtensionOfObject(Oid classId, Oid objectId) while (HeapTupleIsValid((tup = systable_getnext(scan)))) { - Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depform = GETSTRUCT(pg_depend, tup); if (depform->refclassid == ExtensionRelationId && depform->deptype == DEPENDENCY_EXTENSION) @@ -741,7 +741,7 @@ getAutoExtensionsOfObject(Oid classId, Oid objectId) while (HeapTupleIsValid((tup = systable_getnext(scan)))) { - Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depform = GETSTRUCT(pg_depend, tup); if (depform->refclassid == ExtensionRelationId && depform->deptype == DEPENDENCY_AUTO_EXTENSION) @@ -791,7 +791,7 @@ sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId) while (HeapTupleIsValid((tup = systable_getnext(scan)))) { - Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depform = GETSTRUCT(pg_depend, tup); if (depform->refclassid == RelationRelationId && depform->deptype == deptype) @@ -845,7 +845,7 @@ getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype) while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend deprec = GETSTRUCT(pg_depend, tup); /* * We assume any auto or internal dependency of a sequence on a column @@ -937,7 +937,7 @@ get_index_constraint(Oid indexId) while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend deprec = GETSTRUCT(pg_depend, tup); /* * We assume any internal dependency on a constraint must be what we @@ -993,7 +993,7 @@ get_index_ref_constraints(Oid indexId) while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend deprec = GETSTRUCT(pg_depend, tup); /* * We assume any normal dependency from a constraint must be what we diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c index 114715498d..3a518b9122 100644 --- a/src/backend/catalog/pg_enum.c +++ b/src/backend/catalog/pg_enum.c @@ -292,7 +292,7 @@ restart: */ if (nelems > 0) { - Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nelems - 1]); + Form_pg_enum en = GETSTRUCT(pg_enum, existing[nelems - 1]); newelemorder = en->enumsortorder + 1; } @@ -310,7 +310,7 @@ restart: /* Locate the neighbor element */ for (nbr_index = 0; nbr_index < nelems; nbr_index++) { - Form_pg_enum en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]); + Form_pg_enum en = GETSTRUCT(pg_enum, existing[nbr_index]); if (strcmp(NameStr(en->enumlabel), neighbor) == 0) break; @@ -320,7 +320,7 @@ restart: (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("\"%s\" is not an existing enum label", neighbor))); - nbr_en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]); + nbr_en = GETSTRUCT(pg_enum, existing[nbr_index]); /* * Attempt to assign an appropriate enumsortorder value: one less than @@ -352,7 +352,7 @@ restart: */ volatile float4 midpoint; - other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]); + other_nbr_en = GETSTRUCT(pg_enum, existing[other_nbr_index]); midpoint = (nbr_en->enumsortorder + other_nbr_en->enumsortorder) / 2; @@ -418,7 +418,7 @@ restart: for (i = 0; i < nelems; i++) { HeapTuple exists_tup = existing[i]; - Form_pg_enum exists_en = (Form_pg_enum) GETSTRUCT(exists_tup); + Form_pg_enum exists_en = GETSTRUCT(pg_enum, exists_tup); Oid exists_oid = exists_en->oid; if (exists_oid & 1) @@ -552,7 +552,7 @@ RenameEnumLabel(Oid enumTypeOid, for (i = 0; i < nelems; i++) { enum_tup = &(list->members[i]->tuple); - en = (Form_pg_enum) GETSTRUCT(enum_tup); + en = GETSTRUCT(pg_enum, enum_tup); if (strcmp(NameStr(en->enumlabel), oldVal) == 0) old_tup = enum_tup; if (strcmp(NameStr(en->enumlabel), newVal) == 0) @@ -571,7 +571,7 @@ RenameEnumLabel(Oid enumTypeOid, /* OK, make a writable copy of old tuple */ enum_tup = heap_copytuple(old_tup); - en = (Form_pg_enum) GETSTRUCT(enum_tup); + en = GETSTRUCT(pg_enum, enum_tup); ReleaseCatCacheList(list); @@ -656,7 +656,7 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems) float4 newsortorder; newtup = heap_copytuple(existing[i]); - en = (Form_pg_enum) GETSTRUCT(newtup); + en = GETSTRUCT(pg_enum, newtup); newsortorder = i + 1; if (en->enumsortorder != newsortorder) @@ -680,8 +680,8 @@ sort_order_cmp(const void *p1, const void *p2) { HeapTuple v1 = *((const HeapTuple *) p1); HeapTuple v2 = *((const HeapTuple *) p2); - Form_pg_enum en1 = (Form_pg_enum) GETSTRUCT(v1); - Form_pg_enum en2 = (Form_pg_enum) GETSTRUCT(v2); + Form_pg_enum en1 = GETSTRUCT(pg_enum, v1); + Form_pg_enum en2 = GETSTRUCT(pg_enum, v2); if (en1->enumsortorder < en2->enumsortorder) return -1; diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c index 92afbc2f25..2764c1c35c 100644 --- a/src/backend/catalog/pg_inherits.c +++ b/src/backend/catalog/pg_inherits.c @@ -136,7 +136,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached, * SERIALIZABLE transactions: such queries use a different snapshot * than the one used by regular (user) queries. */ - if (((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending) + if ((GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending) { if (detached_exist) *detached_exist = true; @@ -179,7 +179,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached, } } - inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid; + inhrelid = (GETSTRUCT(pg_inherits, inheritsTuple))->inhrelid; if (numoids >= maxoids) { maxoids *= 2; @@ -362,7 +362,7 @@ has_subclass(Oid relationId) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relationId); - result = ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass; + result = (GETSTRUCT(pg_class, tuple))->relhassubclass; ReleaseSysCache(tuple); return result; } @@ -473,7 +473,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) while ((inhtup = systable_getnext(inhscan)) != NULL) { - Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup); + Form_pg_inherits inh = GETSTRUCT(pg_inherits, inhtup); Oid inhparent = inh->inhparent; /* If this is the target superclass, we're done */ @@ -575,13 +575,13 @@ DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending, Oid parent; /* Compare inhparent if it was given, and do the actual deletion. */ - parent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent; + parent = (GETSTRUCT(pg_inherits, inheritsTuple))->inhparent; if (!OidIsValid(inhparent) || parent == inhparent) { bool detach_pending; detach_pending = - ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending; + (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending; /* * Raise error depending on state. This should only happen for @@ -643,7 +643,7 @@ PartitionHasPendingDetach(Oid partoid) bool detached; detached = - ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending; + (GETSTRUCT(pg_inherits, inheritsTuple))->inhdetachpending; /* Done */ systable_endscan(scan); diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 630bf3e56c..6b4db2306f 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -143,7 +143,7 @@ OperatorGet(const char *operatorName, ObjectIdGetDatum(operatorNamespace)); if (HeapTupleIsValid(tup)) { - Form_pg_operator oprform = (Form_pg_operator) GETSTRUCT(tup); + Form_pg_operator oprform = GETSTRUCT(pg_operator, tup); operatorObjectId = oprform->oid; *defined = RegProcedureIsValid(oprform->oprcode); @@ -677,7 +677,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete) /* Update the commutator's tuple if need be. */ if (HeapTupleIsValid(tup)) { - Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup); + Form_pg_operator t = GETSTRUCT(pg_operator, tup); bool update_commutator = false; /* @@ -722,7 +722,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete) if (HeapTupleIsValid(tup)) { - Form_pg_operator t = (Form_pg_operator) GETSTRUCT(tup); + Form_pg_operator t = GETSTRUCT(pg_operator, tup); bool update_negator = false; /* @@ -778,7 +778,7 @@ makeOperatorDependencies(HeapTuple tuple, bool makeExtensionDep, bool isUpdate) { - Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple); + Form_pg_operator oper = GETSTRUCT(pg_operator, tuple); ObjectAddress myself, referenced; ObjectAddresses *addrs; diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index a9fe45e347..8eed22b3fb 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -365,7 +365,7 @@ ProcedureCreate(const char *procedureName, if (HeapTupleIsValid(oldtup)) { /* There is one; okay to replace it? */ - Form_pg_proc oldproc = (Form_pg_proc) GETSTRUCT(oldtup); + Form_pg_proc oldproc = GETSTRUCT(pg_proc, oldtup); Datum proargnames; bool isnull; const char *dropcmd; @@ -586,7 +586,7 @@ ProcedureCreate(const char *procedureName, } - retval = ((Form_pg_proc) GETSTRUCT(tup))->oid; + retval = (GETSTRUCT(pg_proc, tup))->oid; /* * Create dependencies for the new function. If we are updating an @@ -842,7 +842,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", funcoid); - proc = (Form_pg_proc) GETSTRUCT(tuple); + proc = GETSTRUCT(pg_proc, tuple); /* Disallow pseudotype result */ /* except for RECORD, VOID, or polymorphic */ diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index c365de3a72..2819aafe75 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -236,7 +236,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); - result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple)); + result = is_publishable_class(relid, GETSTRUCT(pg_class, tuple)); ReleaseSysCache(tuple); PG_RETURN_BOOL(result); } @@ -678,7 +678,7 @@ GetRelationPublications(Oid relid) for (i = 0; i < pubrellist->n_members; i++) { HeapTuple tup = &pubrellist->members[i]->tuple; - Oid pubid = ((Form_pg_publication_rel) GETSTRUCT(tup))->prpubid; + Oid pubid = (GETSTRUCT(pg_publication_rel, tup))->prpubid; result = lappend_oid(result, pubid); } @@ -719,7 +719,7 @@ GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt) { Form_pg_publication_rel pubrel; - pubrel = (Form_pg_publication_rel) GETSTRUCT(tup); + pubrel = GETSTRUCT(pg_publication_rel, tup); result = GetPubPartitionOptionRelations(result, pub_partopt, pubrel->prrelid); } @@ -760,7 +760,7 @@ GetAllTablesPublications(void) result = NIL; while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Oid oid = ((Form_pg_publication) GETSTRUCT(tup))->oid; + Oid oid = (GETSTRUCT(pg_publication, tup))->oid; result = lappend_oid(result, oid); } @@ -798,7 +798,7 @@ GetAllTablesPublicationRelations(bool pubviaroot) while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class relForm = GETSTRUCT(pg_class, tuple); Oid relid = relForm->oid; if (is_publishable_class(relid, relForm) && @@ -819,7 +819,7 @@ GetAllTablesPublicationRelations(bool pubviaroot) while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class relForm = GETSTRUCT(pg_class, tuple); Oid relid = relForm->oid; if (is_publishable_class(relid, relForm) && @@ -863,7 +863,7 @@ GetPublicationSchemas(Oid pubid) { Form_pg_publication_namespace pubsch; - pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup); + pubsch = GETSTRUCT(pg_publication_namespace, tup); result = lappend_oid(result, pubsch->pnnspid); } @@ -890,7 +890,7 @@ GetSchemaPublications(Oid schemaid) for (i = 0; i < pubschlist->n_members; i++) { HeapTuple tup = &pubschlist->members[i]->tuple; - Oid pubid = ((Form_pg_publication_namespace) GETSTRUCT(tup))->pnpubid; + Oid pubid = (GETSTRUCT(pg_publication_namespace, tup))->pnpubid; result = lappend_oid(result, pubid); } @@ -925,7 +925,7 @@ GetSchemaPublicationRelations(Oid schemaid, PublicationPartOpt pub_partopt) scan = table_beginscan_catalog(classRel, 1, key); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class relForm = GETSTRUCT(pg_class, tuple); Oid relid = relForm->oid; char relkind; @@ -995,7 +995,7 @@ GetPublication(Oid pubid) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for publication %u", pubid); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); pub = (Publication *) palloc(sizeof(Publication)); pub->oid = pubid; @@ -1068,7 +1068,7 @@ get_publication_name(Oid pubid, bool missing_ok) return NULL; } - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); pubname = pstrdup(NameStr(pubform->pubname)); ReleaseSysCache(tup); diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 3e8fa008b9..b0f6ca6f8a 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -242,7 +242,7 @@ shdepChangeDep(Relation sdepRel, while ((scantup = systable_getnext(scan)) != NULL) { /* Ignore if not of the target dependency type */ - if (((Form_pg_shdepend) GETSTRUCT(scantup))->deptype != deptype) + if ((GETSTRUCT(pg_shdepend, scantup))->deptype != deptype) continue; /* Caller screwed up if multiple matches */ if (oldtup) @@ -263,7 +263,7 @@ shdepChangeDep(Relation sdepRel, else if (oldtup) { /* Need to update existing entry */ - Form_pg_shdepend shForm = (Form_pg_shdepend) GETSTRUCT(oldtup); + Form_pg_shdepend shForm = GETSTRUCT(pg_shdepend, oldtup); /* Since oldtup is a copy, we can just modify it in-memory */ shForm->refclassid = refclassid; @@ -692,7 +692,7 @@ checkSharedDependencies(Oid classId, Oid objectId, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tup); + Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tup); object.classId = sdepForm->classid; object.objectId = sdepForm->objid; @@ -907,7 +907,7 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId) memset(slot[slot_stored_count]->tts_isnull, false, slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool)); - shdep = (Form_pg_shdepend) GETSTRUCT(tup); + shdep = GETSTRUCT(pg_shdepend, tup); slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId); slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid; @@ -1115,7 +1115,7 @@ shdepDropDependency(Relation sdepRel, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_shdepend shdepForm = (Form_pg_shdepend) GETSTRUCT(tup); + Form_pg_shdepend shdepForm = GETSTRUCT(pg_shdepend, tup); /* Filter entries according to additional parameters */ if (OidIsValid(refclassId) && shdepForm->refclassid != refclassId) @@ -1347,7 +1347,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior) while ((tuple = systable_getnext(scan)) != NULL) { - Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple); + Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple); ObjectAddress obj; /* @@ -1497,7 +1497,7 @@ shdepReassignOwned(List *roleids, Oid newrole) while ((tuple = systable_getnext(scan)) != NULL) { - Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple); + Form_pg_shdepend sdepForm = GETSTRUCT(pg_shdepend, tuple); MemoryContext cxt, oldcxt; diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index 8856ce3b50..cb6e1675d9 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -58,7 +58,7 @@ GetSubscription(Oid subid, bool missing_ok) elog(ERROR, "cache lookup failed for subscription %u", subid); } - subform = (Form_pg_subscription) GETSTRUCT(tup); + subform = GETSTRUCT(pg_subscription, tup); sub = (Subscription *) palloc(sizeof(Subscription)); sub->oid = subid; @@ -239,7 +239,7 @@ get_subscription_name(Oid subid, bool missing_ok) return NULL; } - subform = (Form_pg_subscription) GETSTRUCT(tup); + subform = GETSTRUCT(pg_subscription, tup); subname = pstrdup(NameStr(subform->subname)); ReleaseSysCache(tup); @@ -399,7 +399,7 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn) } /* Get the state. */ - substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate; + substate = (GETSTRUCT(pg_subscription_rel, tup))->srsubstate; /* Get the LSN */ d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup, @@ -456,7 +456,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid) { Form_pg_subscription_rel subrel; - subrel = (Form_pg_subscription_rel) GETSTRUCT(tup); + subrel = GETSTRUCT(pg_subscription_rel, tup); /* * We don't allow to drop the relation mapping when the table @@ -555,7 +555,7 @@ GetSubscriptionRelations(Oid subid) Datum d; bool isnull; - subrel = (Form_pg_subscription_rel) GETSTRUCT(tup); + subrel = GETSTRUCT(pg_subscription_rel, tup); relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState)); relstate->relid = subrel->srrelid; @@ -614,7 +614,7 @@ GetSubscriptionNotReadyRelations(Oid subid) Datum d; bool isnull; - subrel = (Form_pg_subscription_rel) GETSTRUCT(tup); + subrel = GETSTRUCT(pg_subscription_rel, tup); relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState)); relstate->relid = subrel->srrelid; diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index 03788cb975..9fb756d728 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -424,7 +424,7 @@ TypeCreate(Oid newTypeOid, ObjectIdGetDatum(typeNamespace)); if (HeapTupleIsValid(tup)) { - Form_pg_type typform = (Form_pg_type) GETSTRUCT(tup); + Form_pg_type typform = GETSTRUCT(pg_type, tup); /* * check that the type is not already defined. It may exist as a @@ -562,7 +562,7 @@ GenerateTypeDependencies(HeapTuple typeTuple, bool makeExtensionDep, bool rebuild) { - Form_pg_type typeForm = (Form_pg_type) GETSTRUCT(typeTuple); + Form_pg_type typeForm = GETSTRUCT(pg_type, typeTuple); Oid typeObjectId = typeForm->oid; Datum datum; bool isNull; @@ -751,7 +751,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace) tuple = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", typeOid); - typ = (Form_pg_type) GETSTRUCT(tuple); + typ = GETSTRUCT(pg_type, tuple); /* We are not supposed to be changing schemas here */ Assert(typeNamespace == typ->typnamespace); diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c index 9bc10729b0..5b10baff8a 100644 --- a/src/backend/catalog/toasting.c +++ b/src/backend/catalog/toasting.c @@ -341,7 +341,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup failed for relation %u", relOid); - ((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid = toast_relid; + (GETSTRUCT(pg_class, reltup))->reltoastrelid = toast_relid; if (!IsBootstrapProcessingMode()) { diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 5456b8222b..018582b304 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -243,27 +243,27 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name) */ if (classId == ProcedureRelationId) { - Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(oldtup); + Form_pg_proc proc = GETSTRUCT(pg_proc, oldtup); IsThereFunctionInNamespace(new_name, proc->pronargs, &proc->proargtypes, proc->pronamespace); } else if (classId == CollationRelationId) { - Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(oldtup); + Form_pg_collation coll = GETSTRUCT(pg_collation, oldtup); IsThereCollationInNamespace(new_name, coll->collnamespace); } else if (classId == OperatorClassRelationId) { - Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(oldtup); + Form_pg_opclass opc = GETSTRUCT(pg_opclass, oldtup); IsThereOpClassInNamespace(new_name, opc->opcmethod, opc->opcnamespace); } else if (classId == OperatorFamilyRelationId) { - Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(oldtup); + Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, oldtup); IsThereOpFamilyInNamespace(new_name, opf->opfmethod, opf->opfnamespace); @@ -769,27 +769,27 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid) */ if (classId == ProcedureRelationId) { - Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(tup); + Form_pg_proc proc = GETSTRUCT(pg_proc, tup); IsThereFunctionInNamespace(NameStr(proc->proname), proc->pronargs, &proc->proargtypes, nspOid); } else if (classId == CollationRelationId) { - Form_pg_collation coll = (Form_pg_collation) GETSTRUCT(tup); + Form_pg_collation coll = GETSTRUCT(pg_collation, tup); IsThereCollationInNamespace(NameStr(coll->collname), nspOid); } else if (classId == OperatorClassRelationId) { - Form_pg_opclass opc = (Form_pg_opclass) GETSTRUCT(tup); + Form_pg_opclass opc = GETSTRUCT(pg_opclass, tup); IsThereOpClassInNamespace(NameStr(opc->opcname), opc->opcmethod, nspOid); } else if (classId == OperatorFamilyRelationId) { - Form_pg_opfamily opf = (Form_pg_opfamily) GETSTRUCT(tup); + Form_pg_opfamily opf = GETSTRUCT(pg_opfamily, tup); IsThereOpFamilyInNamespace(NameStr(opf->opfname), opf->opfmethod, nspOid); diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c index 914cfa4cc7..ea057efe80 100644 --- a/src/backend/commands/amcmds.c +++ b/src/backend/commands/amcmds.c @@ -134,7 +134,7 @@ get_am_type_oid(const char *amname, char amtype, bool missing_ok) tup = SearchSysCache1(AMNAME, CStringGetDatum(amname)); if (HeapTupleIsValid(tup)) { - Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup); + Form_pg_am amform = GETSTRUCT(pg_am, tup); if (amtype != '\0' && amform->amtype != amtype) @@ -197,7 +197,7 @@ get_am_name(Oid amOid) tup = SearchSysCache1(AMOID, ObjectIdGetDatum(amOid)); if (HeapTupleIsValid(tup)) { - Form_pg_am amform = (Form_pg_am) GETSTRUCT(tup); + Form_pg_am amform = GETSTRUCT(pg_am, tup); result = pstrdup(NameStr(amform->amname)); ReleaseSysCache(tup); diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index a7966fff83..fb4f748ee1 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -1057,7 +1057,7 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr) ObjectIdGetDatum(stats->attrtypid)); if (!HeapTupleIsValid(typtuple)) elog(ERROR, "cache lookup failed for type %u", stats->attrtypid); - stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple); + stats->attrtype = GETSTRUCT(pg_type, typtuple); stats->anl_context = anl_context; stats->tupattnum = attnum; diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index dc35b02910..d5163e038e 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -590,7 +590,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal) ObjectIdGetDatum(thisIndexOid)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", thisIndexOid); - indexForm = (Form_pg_index) GETSTRUCT(indexTuple); + indexForm = GETSTRUCT(pg_index, indexTuple); /* * Unset the bit if set. We know it's wrong because we checked this @@ -1003,7 +1003,7 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose, reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDNewHeap)); if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup failed for relation %u", OIDNewHeap); - relform = (Form_pg_class) GETSTRUCT(reltup); + relform = GETSTRUCT(pg_class, reltup); relform->relpages = num_pages; relform->reltuples = num_tuples; @@ -1072,12 +1072,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1)); if (!HeapTupleIsValid(reltup1)) elog(ERROR, "cache lookup failed for relation %u", r1); - relform1 = (Form_pg_class) GETSTRUCT(reltup1); + relform1 = GETSTRUCT(pg_class, reltup1); reltup2 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r2)); if (!HeapTupleIsValid(reltup2)) elog(ERROR, "cache lookup failed for relation %u", r2); - relform2 = (Form_pg_class) GETSTRUCT(reltup2); + relform2 = GETSTRUCT(pg_class, reltup2); relfilenumber1 = relform1->relfilenode; relfilenumber2 = relform2->relfilenode; @@ -1515,7 +1515,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(OIDOldHeap)); if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup failed for relation %u", OIDOldHeap); - relform = (Form_pg_class) GETSTRUCT(reltup); + relform = GETSTRUCT(pg_class, reltup); relform->relfrozenxid = frozenXid; relform->relminmxid = cutoffMulti; @@ -1638,7 +1638,7 @@ get_tables_to_cluster(MemoryContext cluster_context) { RelToCluster *rtc; - index = (Form_pg_index) GETSTRUCT(indexTuple); + index = GETSTRUCT(pg_index, indexTuple); if (!pg_class_ownercheck(index->indrelid, GetUserId())) continue; diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index fcfc02d2ae..956249259f 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -137,9 +137,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for collation %u", collid); - collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider; - collisdeterministic = ((Form_pg_collation) GETSTRUCT(tp))->collisdeterministic; - collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding; + collprovider = (GETSTRUCT(pg_collation, tp))->collprovider; + collisdeterministic = (GETSTRUCT(pg_collation, tp))->collisdeterministic; + collencoding = (GETSTRUCT(pg_collation, tp))->collencoding; datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull); if (!isnull) @@ -373,7 +373,7 @@ AlterCollation(AlterCollationStmt *stmt) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for collation %u", collOid); - collForm = (Form_pg_collation) GETSTRUCT(tup); + collForm = GETSTRUCT(pg_collation, tup); datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull); oldversion = isnull ? NULL : TextDatumGetCString(datum); @@ -438,7 +438,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("collation with OID %u does not exist", collid))); - collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider; + collprovider = (GETSTRUCT(pg_collation, tp))->collprovider; if (collprovider != COLLPROVIDER_DEFAULT) { diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 1901b434c5..7af9401e34 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -399,7 +399,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid, Form_pg_class classForm; Oid relfilenumber = InvalidRelFileNumber; - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); /* * Return NULL if this object does not need to be copied. @@ -579,7 +579,7 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid, scan = table_beginscan_catalog(rel, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_tablespace spaceform = (Form_pg_tablespace) GETSTRUCT(tuple); + Form_pg_tablespace spaceform = GETSTRUCT(pg_tablespace, tuple); Oid srctablespace = spaceform->oid; Oid dsttablespace; char *srcpath; @@ -1792,7 +1792,7 @@ RenameDatabase(const char *oldname, const char *newname) newtup = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(db_id)); if (!HeapTupleIsValid(newtup)) elog(ERROR, "cache lookup failed for database %u", db_id); - namestrcpy(&(((Form_pg_database) GETSTRUCT(newtup))->datname), newname); + namestrcpy(&((GETSTRUCT(pg_database, newtup))->datname), newname); CatalogTupleUpdate(rel, &newtup->t_self, newtup); InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0); @@ -2284,7 +2284,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel) (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", stmt->dbname))); - datform = (Form_pg_database) GETSTRUCT(tuple); + datform = GETSTRUCT(pg_database, tuple); dboid = datform->oid; if (!pg_database_ownercheck(dboid, GetUserId())) @@ -2371,7 +2371,7 @@ AlterDatabaseRefreshColl(AlterDatabaseRefreshCollStmt *stmt) (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", stmt->dbname))); - datForm = (Form_pg_database) GETSTRUCT(tuple); + datForm = GETSTRUCT(pg_database, tuple); db_id = datForm->oid; if (!pg_database_ownercheck(db_id, GetUserId())) @@ -2481,7 +2481,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", dbname))); - datForm = (Form_pg_database) GETSTRUCT(tuple); + datForm = GETSTRUCT(pg_database, tuple); db_id = datForm->oid; /* @@ -2581,7 +2581,7 @@ pg_database_collation_actual_version(PG_FUNCTION_ARGS) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("database with OID %u does not exist", dbid))); - datlocprovider = ((Form_pg_database) GETSTRUCT(tp))->datlocprovider; + datlocprovider = (GETSTRUCT(pg_database, tp))->datlocprovider; datum = SysCacheGetAttr(DATABASEOID, tp, datlocprovider == COLLPROVIDER_ICU ? Anum_pg_database_daticulocale : Anum_pg_database_datcollate, &isnull); if (isnull) @@ -2657,7 +2657,7 @@ get_db_info(const char *name, LOCKMODE lockmode, break; } - dbOid = ((Form_pg_database) GETSTRUCT(tuple))->oid; + dbOid = (GETSTRUCT(pg_database, tuple))->oid; systable_endscan(scan); @@ -2675,7 +2675,7 @@ get_db_info(const char *name, LOCKMODE lockmode, tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbOid)); if (HeapTupleIsValid(tuple)) { - Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple); + Form_pg_database dbform = GETSTRUCT(pg_database, tuple); if (strcmp(name, NameStr(dbform->datname)) == 0) { @@ -2768,7 +2768,7 @@ have_createdb_privilege(void) utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId())); if (HeapTupleIsValid(utup)) { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreatedb; + result = (GETSTRUCT(pg_authid, utup))->rolcreatedb; ReleaseSysCache(utup); } return result; @@ -2796,7 +2796,7 @@ remove_dbtablespaces(Oid db_id) scan = table_beginscan_catalog(rel, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple); + Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple); Oid dsttablespace = spcform->oid; char *dstpath; struct stat st; @@ -2882,7 +2882,7 @@ check_db_file_conflict(Oid db_id) scan = table_beginscan_catalog(rel, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple); + Form_pg_tablespace spcform = GETSTRUCT(pg_tablespace, tuple); Oid dsttablespace = spcform->oid; char *dstpath; struct stat st; @@ -2968,7 +2968,7 @@ get_database_oid(const char *dbname, bool missing_ok) /* We assume that there can be at most one matching tuple */ if (HeapTupleIsValid(dbtuple)) - oid = ((Form_pg_database) GETSTRUCT(dbtuple))->oid; + oid = (GETSTRUCT(pg_database, dbtuple))->oid; else oid = InvalidOid; @@ -2999,7 +2999,7 @@ get_database_name(Oid dbid) dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid)); if (HeapTupleIsValid(dbtuple)) { - result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname)); + result = pstrdup(NameStr((GETSTRUCT(pg_database, dbtuple))->datname)); ReleaseSysCache(dbtuple); } else diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index f46f86474a..04d5f2ed68 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -376,7 +376,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt) errmsg("event trigger \"%s\" does not exist", stmt->trigname))); - evtForm = (Form_pg_event_trigger) GETSTRUCT(tup); + evtForm = GETSTRUCT(pg_event_trigger, tup); trigoid = evtForm->oid; if (!pg_event_trigger_ownercheck(trigoid, GetUserId())) @@ -419,7 +419,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("event trigger \"%s\" does not exist", name))); - evtForm = (Form_pg_event_trigger) GETSTRUCT(tup); + evtForm = GETSTRUCT(pg_event_trigger, tup); evtOid = evtForm->oid; AlterEventTriggerOwner_internal(rel, tup, newOwnerId); @@ -466,7 +466,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) { Form_pg_event_trigger form; - form = (Form_pg_event_trigger) GETSTRUCT(tup); + form = GETSTRUCT(pg_event_trigger, tup); if (form->evtowner == newOwnerId) return; diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index 3db859c3ea..fd31544069 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -159,7 +159,7 @@ get_extension_oid(const char *extname, bool missing_ok) /* We assume that there can be at most one matching tuple */ if (HeapTupleIsValid(tuple)) - result = ((Form_pg_extension) GETSTRUCT(tuple))->oid; + result = (GETSTRUCT(pg_extension, tuple))->oid; else result = InvalidOid; @@ -204,7 +204,7 @@ get_extension_name(Oid ext_oid) /* We assume that there can be at most one matching tuple */ if (HeapTupleIsValid(tuple)) - result = pstrdup(NameStr(((Form_pg_extension) GETSTRUCT(tuple))->extname)); + result = pstrdup(NameStr((GETSTRUCT(pg_extension, tuple))->extname)); else result = NULL; @@ -243,7 +243,7 @@ get_extension_schema(Oid ext_oid) /* We assume that there can be at most one matching tuple */ if (HeapTupleIsValid(tuple)) - result = ((Form_pg_extension) GETSTRUCT(tuple))->extnamespace; + result = (GETSTRUCT(pg_extension, tuple))->extnamespace; else result = InvalidOid; @@ -2762,7 +2762,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o /* Copy tuple so we can modify it below */ extTup = heap_copytuple(extTup); - extForm = (Form_pg_extension) GETSTRUCT(extTup); + extForm = GETSTRUCT(pg_extension, extTup); systable_endscan(extScan); @@ -2805,7 +2805,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o while (HeapTupleIsValid(depTup = systable_getnext(depScan))) { - Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup); + Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup); ObjectAddress dep; Oid dep_oldNspOid; @@ -2927,7 +2927,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt) errmsg("extension \"%s\" does not exist", stmt->extname))); - extensionOid = ((Form_pg_extension) GETSTRUCT(extTup))->oid; + extensionOid = (GETSTRUCT(pg_extension, extTup))->oid; /* * Determine the existing version we are updating from @@ -3079,7 +3079,7 @@ ApplyExtensionUpdates(Oid extensionOid, elog(ERROR, "could not find tuple for extension %u", extensionOid); - extForm = (Form_pg_extension) GETSTRUCT(extTup); + extForm = GETSTRUCT(pg_extension, extTup); /* * Determine the target schema (set by original install) diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c index ea27857bb8..899e1cceef 100644 --- a/src/backend/commands/foreigncmds.c +++ b/src/backend/commands/foreigncmds.c @@ -212,7 +212,7 @@ AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerI Datum aclDatum; bool isNull; - form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup); + form = GETSTRUCT(pg_foreign_data_wrapper, tup); /* Must be a superuser to change a FDW owner */ if (!superuser()) @@ -290,7 +290,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign-data wrapper \"%s\" does not exist", name))); - form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup); + form = GETSTRUCT(pg_foreign_data_wrapper, tup); fdwId = form->oid; AlterForeignDataWrapperOwner_internal(rel, tup, newOwnerId); @@ -345,7 +345,7 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) Datum aclDatum; bool isNull; - form = (Form_pg_foreign_server) GETSTRUCT(tup); + form = GETSTRUCT(pg_foreign_server, tup); if (form->srvowner != newOwnerId) { @@ -429,7 +429,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("server \"%s\" does not exist", name))); - form = (Form_pg_foreign_server) GETSTRUCT(tup); + form = GETSTRUCT(pg_foreign_server, tup); servOid = form->oid; AlterForeignServerOwner_internal(rel, tup, newOwnerId); @@ -706,7 +706,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign-data wrapper \"%s\" does not exist", stmt->fdwname))); - fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp); + fdwForm = GETSTRUCT(pg_foreign_data_wrapper, tp); fdwId = fdwForm->oid; memset(repl_val, 0, sizeof(repl_val)); @@ -983,7 +983,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("server \"%s\" does not exist", stmt->servername))); - srvForm = (Form_pg_foreign_server) GETSTRUCT(tp); + srvForm = GETSTRUCT(pg_foreign_server, tp); srvId = srvForm->oid; /* diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index b016eecb2c..cdac19d505 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -101,7 +101,7 @@ compute_return_type(TypeName *returnType, Oid languageOid, if (typtup) { - if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined) + if (!(GETSTRUCT(pg_type, typtup))->typisdefined) { if (languageOid == SQLlanguageId) ereport(ERROR, @@ -241,7 +241,7 @@ interpret_function_parameter_list(ParseState *pstate, typtup = LookupTypeName(NULL, t, NULL, false); if (typtup) { - if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined) + if (!(GETSTRUCT(pg_type, typtup))->typisdefined) { /* As above, hard error if language is SQL */ if (languageOid == SQLlanguageId) @@ -1106,7 +1106,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt) (extension_file_exists(language) ? errhint("Use CREATE EXTENSION to load the language into the database.") : 0))); - languageStruct = (Form_pg_language) GETSTRUCT(languageTuple); + languageStruct = GETSTRUCT(pg_language, languageTuple); languageOid = languageStruct->oid; if (languageStruct->lanpltrusted) @@ -1313,7 +1313,7 @@ RemoveFunctionById(Oid funcOid) if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for function %u", funcOid); - prokind = ((Form_pg_proc) GETSTRUCT(tup))->prokind; + prokind = (GETSTRUCT(pg_proc, tup))->prokind; CatalogTupleDelete(relation, &tup->t_self); @@ -1377,7 +1377,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt) if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for function %u", funcOid); - procForm = (Form_pg_proc) GETSTRUCT(tup); + procForm = GETSTRUCT(pg_proc, tup); /* Permission check: must own function */ if (!pg_proc_ownercheck(funcOid, GetUserId())) @@ -1600,7 +1600,7 @@ CreateCast(CreateCastStmt *stmt) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", funcid); - procstruct = (Form_pg_proc) GETSTRUCT(tuple); + procstruct = GETSTRUCT(pg_proc, tuple); nargs = procstruct->pronargs; if (nargs < 1 || nargs > 3) ereport(ERROR, @@ -1868,7 +1868,7 @@ CreateTransform(CreateTransformStmt *stmt) tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fromsqlfuncid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", fromsqlfuncid); - procstruct = (Form_pg_proc) GETSTRUCT(tuple); + procstruct = GETSTRUCT(pg_proc, tuple); if (procstruct->prorettype != INTERNALOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), @@ -1894,7 +1894,7 @@ CreateTransform(CreateTransformStmt *stmt) tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(tosqlfuncid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", tosqlfuncid); - procstruct = (Form_pg_proc) GETSTRUCT(tuple); + procstruct = GETSTRUCT(pg_proc, tuple); if (procstruct->prorettype != typeid) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), @@ -1922,7 +1922,7 @@ CreateTransform(CreateTransformStmt *stmt) ObjectIdGetDatum(langid)); if (HeapTupleIsValid(tuple)) { - Form_pg_transform form = (Form_pg_transform) GETSTRUCT(tuple); + Form_pg_transform form = GETSTRUCT(pg_transform, tuple); if (!stmt->replace) ereport(ERROR, @@ -2106,7 +2106,7 @@ ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic) (extension_file_exists(language) ? errhint("Use CREATE EXTENSION to load the language into the database.") : 0))); - languageStruct = (Form_pg_language) GETSTRUCT(languageTuple); + languageStruct = GETSTRUCT(pg_language, languageTuple); codeblock->langOid = languageStruct->oid; codeblock->langIsTrusted = languageStruct->lanpltrusted; codeblock->atomic = atomic; @@ -2220,7 +2220,7 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver * and AbortTransaction() resets the security context. This could be * reorganized, but right now it doesn't work. */ - if (((Form_pg_proc) GETSTRUCT(tp))->prosecdef) + if ((GETSTRUCT(pg_proc, tp))->prosecdef) callcontext->atomic = true; ReleaseSysCache(tp); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ff847579f3..233d265f71 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -212,7 +212,7 @@ CheckIndexCompatible(Oid oldId, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("access method \"%s\" does not exist", accessMethodName))); - accessMethodForm = (Form_pg_am) GETSTRUCT(tuple); + accessMethodForm = GETSTRUCT(pg_am, tuple); accessMethodId = accessMethodForm->oid; amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler); ReleaseSysCache(tuple); @@ -245,7 +245,7 @@ CheckIndexCompatible(Oid oldId, tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(oldId)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for index %u", oldId); - indexForm = (Form_pg_index) GETSTRUCT(tuple); + indexForm = GETSTRUCT(pg_index, tuple); /* * We don't assess expressions or predicates; assume incompatibility. @@ -833,7 +833,7 @@ DefineIndex(Oid relationId, errmsg("access method \"%s\" does not exist", accessMethodName))); } - accessMethodForm = (Form_pg_am) GETSTRUCT(tuple); + accessMethodForm = GETSTRUCT(pg_am, tuple); accessMethodId = accessMethodForm->oid; amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler); @@ -1441,7 +1441,7 @@ DefineIndex(Oid relationId, elog(ERROR, "cache lookup failed for index %u", indexRelationId); newtup = heap_copytuple(tup); - ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = false; + (GETSTRUCT(pg_index, newtup))->indisvalid = false; CatalogTupleUpdate(pg_index, &tup->t_self, newtup); ReleaseSysCache(tup); table_close(pg_index, RowExclusiveLock); @@ -1822,7 +1822,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo, errmsg("column \"%s\" does not exist", attribute->name))); } - attform = (Form_pg_attribute) GETSTRUCT(atttuple); + attform = GETSTRUCT(pg_attribute, atttuple); indexInfo->ii_IndexAttrNumbers[attn] = attform->attnum; atttype = attform->atttypid; attcollation = attform->attcollation; @@ -2044,7 +2044,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo, if (!HeapTupleIsValid(opftuple)) elog(ERROR, "cache lookup failed for opfamily %u", opfamily); - opfform = (Form_pg_opfamily) GETSTRUCT(opftuple); + opfform = GETSTRUCT(pg_opfamily, opftuple); ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -2183,7 +2183,7 @@ ResolveOpClass(List *opclass, Oid attrType, * Verify that the index operator class accepts this datatype. Note we * will accept binary compatibility. */ - opform = (Form_pg_opclass) GETSTRUCT(tuple); + opform = GETSTRUCT(pg_opclass, tuple); opClassId = opform->oid; opInputType = opform->opcintype; @@ -2246,7 +2246,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id) while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup); + Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup); /* ignore altogether if not a default opclass */ if (!opclass->opcdefault) @@ -2951,7 +2951,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, scan = table_beginscan_catalog(relationRelation, num_keys, scan_keys); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class classtuple = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class classtuple = GETSTRUCT(pg_class, tuple); Oid relid = classtuple->oid; /* @@ -4194,7 +4194,7 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid) } else { - Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(tuple); + Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, tuple); if (parentOid == InvalidOid) { @@ -4285,8 +4285,8 @@ update_relispartition(Oid relationId, bool newval) tup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for relation %u", relationId); - Assert(((Form_pg_class) GETSTRUCT(tup))->relispartition != newval); - ((Form_pg_class) GETSTRUCT(tup))->relispartition = newval; + Assert((GETSTRUCT(pg_class, tup))->relispartition != newval); + (GETSTRUCT(pg_class, tup))->relispartition = newval; CatalogTupleUpdate(classRel, &tup->t_self, tup); heap_freetuple(tup); table_close(classRel, RowExclusiveLock); diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index 9ac0383459..0e5e86ccb3 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -100,7 +100,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate) elog(ERROR, "cache lookup failed for relation %u", RelationGetRelid(relation)); - ((Form_pg_class) GETSTRUCT(tuple))->relispopulated = newstate; + (GETSTRUCT(pg_class, tuple))->relispopulated = newstate; CatalogTupleUpdate(pgrel, &tuple->t_self, tuple); @@ -724,7 +724,7 @@ refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner, cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(cla_ht)) elog(ERROR, "cache lookup failed for opclass %u", opclass); - cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht); + cla_tup = GETSTRUCT(pg_opclass, cla_ht); Assert(cla_tup->opcmethod == BTREE_AM_OID); opfamily = cla_tup->opcfamily; opcintype = cla_tup->opcintype; diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index 7a931ab758..91b782ed0f 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -123,7 +123,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("operator family \"%s\" does not exist for access method \"%s\"", NameListToString(opfamilyname), - NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname)))); + NameStr((GETSTRUCT(pg_am, amtup))->amname)))); } return htup; @@ -145,7 +145,7 @@ get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok) htup = OpFamilyCacheLookup(amID, opfamilyname, missing_ok); if (!HeapTupleIsValid(htup)) return InvalidOid; - opfamform = (Form_pg_opfamily) GETSTRUCT(htup); + opfamform = GETSTRUCT(pg_opfamily, htup); opfID = opfamform->oid; ReleaseSysCache(htup); @@ -204,7 +204,7 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("operator class \"%s\" does not exist for access method \"%s\"", NameListToString(opclassname), - NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname)))); + NameStr((GETSTRUCT(pg_am, amtup))->amname)))); } return htup; @@ -226,7 +226,7 @@ get_opclass_oid(Oid amID, List *opclassname, bool missing_ok) htup = OpClassCacheLookup(amID, opclassname, missing_ok); if (!HeapTupleIsValid(htup)) return InvalidOid; - opcform = (Form_pg_opclass) GETSTRUCT(htup); + opcform = GETSTRUCT(pg_opclass, htup); opcID = opcform->oid; ReleaseSysCache(htup); @@ -375,7 +375,7 @@ DefineOpClass(CreateOpClassStmt *stmt) errmsg("access method \"%s\" does not exist", stmt->amname))); - amform = (Form_pg_am) GETSTRUCT(tup); + amform = GETSTRUCT(pg_am, tup); amoid = amform->oid; amroutine = GetIndexAmRoutineByAmId(amoid, false); ReleaseSysCache(tup); @@ -442,7 +442,7 @@ DefineOpClass(CreateOpClassStmt *stmt) ObjectIdGetDatum(namespaceoid)); if (HeapTupleIsValid(tup)) { - opfamilyoid = ((Form_pg_opfamily) GETSTRUCT(tup))->oid; + opfamilyoid = (GETSTRUCT(pg_opfamily, tup))->oid; /* * XXX given the superuser check above, there's no need for an @@ -630,7 +630,7 @@ DefineOpClass(CreateOpClassStmt *stmt) while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_opclass opclass = (Form_pg_opclass) GETSTRUCT(tup); + Form_pg_opclass opclass = GETSTRUCT(pg_opclass, tup); if (opclass->opcintype == typeoid && opclass->opcdefault) ereport(ERROR, @@ -833,7 +833,7 @@ AlterOpFamily(AlterOpFamilyStmt *stmt) errmsg("access method \"%s\" does not exist", stmt->amname))); - amform = (Form_pg_am) GETSTRUCT(tup); + amform = GETSTRUCT(pg_am, tup); amoid = amform->oid; amroutine = GetIndexAmRoutineByAmId(amoid, false); ReleaseSysCache(tup); @@ -1143,7 +1143,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid) optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object)); if (!HeapTupleIsValid(optup)) elog(ERROR, "cache lookup failed for operator %u", member->object); - opform = (Form_pg_operator) GETSTRUCT(optup); + opform = GETSTRUCT(pg_operator, optup); /* * Opfamily operators must be binary. @@ -1210,7 +1210,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid, proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", member->object); - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); /* Check the signature of the opclass options parsing function */ if (member->number == opclassOptsProcNum) diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index a5924d7d56..312588f296 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -372,7 +372,7 @@ RemoveOperatorById(Oid operOid) tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for operator %u", operOid); - op = (Form_pg_operator) GETSTRUCT(tup); + op = GETSTRUCT(pg_operator, tup); /* * Reset links from commutator and negator, if any. In case of a @@ -431,7 +431,7 @@ AlterOperator(AlterOperatorStmt *stmt) tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for operator %u", oprId); - oprForm = (Form_pg_operator) GETSTRUCT(tup); + oprForm = GETSTRUCT(pg_operator, tup); /* Process options */ foreach(pl, stmt->options) diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index d9dff9ecaa..99e210fb7c 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -75,7 +75,7 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid, if (!HeapTupleIsValid(tuple)) return; - classform = (Form_pg_class) GETSTRUCT(tuple); + classform = GETSTRUCT(pg_class, tuple); relkind = classform->relkind; /* Must own relation. */ @@ -236,7 +236,7 @@ RelationBuildRowSecurity(Relation relation) while (HeapTupleIsValid(tuple = systable_getnext(sscan))) { - Form_pg_policy policy_form = (Form_pg_policy) GETSTRUCT(tuple); + Form_pg_policy policy_form = GETSTRUCT(pg_policy, tuple); RowSecurityPolicy *policy; Datum datum; bool isnull; @@ -366,7 +366,7 @@ RemovePolicyById(Oid policy_id) * set of policies the rel has; furthermore we've got to hold the lock * till commit.) */ - relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid; + relid = (GETSTRUCT(pg_policy, tuple))->polrelid; rel = table_open(relid, AccessExclusiveLock); if (rel->rd_rel->relkind != RELKIND_RELATION && @@ -455,7 +455,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id) elog(ERROR, "could not find tuple for policy %u", policy_id); /* Identify rel the policy belongs to */ - relid = ((Form_pg_policy) GETSTRUCT(tuple))->polrelid; + relid = (GETSTRUCT(pg_policy, tuple))->polrelid; /* Get the current set of roles */ roles_datum = heap_getattr(tuple, @@ -917,7 +917,7 @@ AlterPolicy(AlterPolicyStmt *stmt) (errcode(ERRCODE_SYNTAX_ERROR), errmsg("only WITH CHECK expression allowed for INSERT"))); - policy_id = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid; + policy_id = (GETSTRUCT(pg_policy, policy_tuple))->oid; if (role_ids != NULL) { @@ -1169,11 +1169,11 @@ rename_policy(RenameStmt *stmt) errmsg("policy \"%s\" for table \"%s\" does not exist", stmt->subname, RelationGetRelationName(target_table)))); - opoloid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid; + opoloid = (GETSTRUCT(pg_policy, policy_tuple))->oid; policy_tuple = heap_copytuple(policy_tuple); - namestrcpy(&((Form_pg_policy) GETSTRUCT(policy_tuple))->polname, + namestrcpy(&(GETSTRUCT(pg_policy, policy_tuple))->polname, stmt->newname); CatalogTupleUpdate(pg_policy_rel, &policy_tuple->t_self, policy_tuple); @@ -1243,7 +1243,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok) policy_oid = InvalidOid; } else - policy_oid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid; + policy_oid = (GETSTRUCT(pg_policy, policy_tuple))->oid; /* Clean up. */ systable_endscan(sscan); diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 4a093f45d8..d28274e3c4 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -124,7 +124,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) if (HeapTupleIsValid(oldtup)) { - Form_pg_language oldform = (Form_pg_language) GETSTRUCT(oldtup); + Form_pg_language oldform = GETSTRUCT(pg_language, oldtup); /* There is one; okay to replace it? */ if (!stmt->replace) diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c index 8e645741e4..c939ae689a 100644 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@ -922,7 +922,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt, &publish_via_partition_root_given, &publish_via_partition_root); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); /* * If the publication doesn't publish changes via the root partitioned @@ -1038,7 +1038,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt, CommandCounterIncrement(); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); /* Invalidate the relcache. */ if (pubform->puballtables) @@ -1114,7 +1114,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup, const char *queryString) { List *rels = NIL; - Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup); + Form_pg_publication pubform = GETSTRUCT(pg_publication, tup); Oid pubid = pubform->oid; /* @@ -1291,7 +1291,7 @@ static void AlterPublicationSchemas(AlterPublicationStmt *stmt, HeapTuple tup, List *schemaidlist) { - Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup); + Form_pg_publication pubform = GETSTRUCT(pg_publication, tup); /* * Nothing to do if no objects, except in SET: for that it is quite @@ -1355,7 +1355,7 @@ static void CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup, List *tables, List *schemaidlist) { - Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup); + Form_pg_publication pubform = GETSTRUCT(pg_publication, tup); if ((stmt->action == AP_AddObjects || stmt->action == AP_SetObjects) && schemaidlist && !superuser()) @@ -1407,7 +1407,7 @@ AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt) errmsg("publication \"%s\" does not exist", stmt->pubname))); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); /* must be owner */ if (!pg_publication_ownercheck(pubform->oid, GetUserId())) @@ -1482,7 +1482,7 @@ RemovePublicationRelById(Oid proid) elog(ERROR, "cache lookup failed for publication table %u", proid); - pubrel = (Form_pg_publication_rel) GETSTRUCT(tup); + pubrel = GETSTRUCT(pg_publication_rel, tup); /* * Invalidate relcache so that publication info is rebuilt. @@ -1520,7 +1520,7 @@ RemovePublicationById(Oid pubid) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for publication %u", pubid); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); /* Invalidate relcache so that publication info is rebuilt. */ if (pubform->puballtables) @@ -1551,7 +1551,7 @@ RemovePublicationSchemaById(Oid psoid) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for publication schema %u", psoid); - pubsch = (Form_pg_publication_namespace) GETSTRUCT(tup); + pubsch = GETSTRUCT(pg_publication_namespace, tup); /* * Invalidate relcache so that publication info is rebuilt. See @@ -1944,7 +1944,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) { Form_pg_publication form; - form = (Form_pg_publication) GETSTRUCT(tup); + form = GETSTRUCT(pg_publication, tup); if (form->pubowner == newOwnerId) return; @@ -2015,7 +2015,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("publication \"%s\" does not exist", name))); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); subid = pubform->oid; AlterPublicationOwner_internal(rel, tup, newOwnerId); diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index be3925b3b4..204bd066fa 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -80,7 +80,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString, if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for role %u", owner_uid); schemaName = - pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname)); + pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname)); ReleaseSysCache(tuple); } @@ -233,7 +233,7 @@ RenameSchema(const char *oldname, const char *newname) (errcode(ERRCODE_UNDEFINED_SCHEMA), errmsg("schema \"%s\" does not exist", oldname))); - nspform = (Form_pg_namespace) GETSTRUCT(tup); + nspform = GETSTRUCT(pg_namespace, tup); nspOid = nspform->oid; /* make sure the new name doesn't exist */ @@ -313,7 +313,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_SCHEMA), errmsg("schema \"%s\" does not exist", name))); - nspform = (Form_pg_namespace) GETSTRUCT(tup); + nspform = GETSTRUCT(pg_namespace, tup); nspOid = nspform->oid; AlterSchemaOwner_internal(tup, rel, newOwnerId); @@ -335,7 +335,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId) Assert(tup->t_tableOid == NamespaceRelationId); Assert(RelationGetRelid(rel) == NamespaceRelationId); - nspForm = (Form_pg_namespace) GETSTRUCT(tup); + nspForm = GETSTRUCT(pg_namespace, tup); /* * If the new owner is the same as the existing owner, consider the diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index b0b211891c..d070904fb1 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -286,7 +286,7 @@ ResetSequence(Oid seq_relid) pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(seq_relid)); if (!HeapTupleIsValid(pgstuple)) elog(ERROR, "cache lookup failed for sequence %u", seq_relid); - pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple); + pgsform = GETSTRUCT(pg_sequence, pgstuple); startv = pgsform->seqstart; ReleaseSysCache(pgstuple); @@ -302,7 +302,7 @@ ResetSequence(Oid seq_relid) * Modify the copied tuple to execute the restart (compare the RESTART * action in AlterSequence) */ - seq = (Form_pg_sequence_data) GETSTRUCT(tuple); + seq = GETSTRUCT(pg_sequence_data, tuple); seq->last_value = startv; seq->is_called = false; seq->log_cnt = 0; @@ -478,14 +478,14 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt) elog(ERROR, "cache lookup failed for sequence %u", relid); - seqform = (Form_pg_sequence) GETSTRUCT(seqtuple); + seqform = GETSTRUCT(pg_sequence, seqtuple); /* lock page's buffer and read tuple into new sequence structure */ (void) read_seq_tuple(seqrel, &buf, &datatuple); /* copy the existing sequence data tuple, so it can be modified locally */ newdatatuple = heap_copytuple(&datatuple); - newdataform = (Form_pg_sequence_data) GETSTRUCT(newdatatuple); + newdataform = GETSTRUCT(pg_sequence_data, newdatatuple); UnlockReleaseBuffer(buf); @@ -676,7 +676,7 @@ nextval_internal(Oid relid, bool check_permissions) pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(pgstuple)) elog(ERROR, "cache lookup failed for sequence %u", relid); - pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple); + pgsform = GETSTRUCT(pg_sequence, pgstuple); incby = pgsform->seqincrement; maxv = pgsform->seqmax; minv = pgsform->seqmin; @@ -964,7 +964,7 @@ do_setval(Oid relid, int64 next, bool iscalled) pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(pgstuple)) elog(ERROR, "cache lookup failed for sequence %u", relid); - pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple); + pgsform = GETSTRUCT(pg_sequence, pgstuple); maxv = pgsform->seqmax; minv = pgsform->seqmin; ReleaseSysCache(pgstuple); @@ -1232,7 +1232,7 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple) MarkBufferDirtyHint(*buf, true); } - seq = (Form_pg_sequence_data) GETSTRUCT(seqdatatuple); + seq = GETSTRUCT(pg_sequence_data, seqdatatuple); return seq; } @@ -1714,7 +1714,7 @@ sequence_options(Oid relid) pgstuple = SearchSysCache1(SEQRELID, relid); if (!HeapTupleIsValid(pgstuple)) elog(ERROR, "cache lookup failed for sequence %u", relid); - pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple); + pgsform = GETSTRUCT(pg_sequence, pgstuple); /* Use makeFloat() for 64-bit integers, like gram.y does. */ options = lappend(options, @@ -1777,7 +1777,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS) pgstuple = SearchSysCache1(SEQRELID, relid); if (!HeapTupleIsValid(pgstuple)) elog(ERROR, "cache lookup failed for sequence %u", relid); - pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple); + pgsform = GETSTRUCT(pg_sequence, pgstuple); values[0] = Int64GetDatum(pgsform->seqstart); values[1] = Int64GetDatum(pgsform->seqmin); diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index cd5e2f2b6b..68e599a104 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -238,7 +238,7 @@ CreateStatistics(CreateStatsStmt *stmt) (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" does not exist", attname))); - attForm = (Form_pg_attribute) GETSTRUCT(atttuple); + attForm = GETSTRUCT(pg_attribute, atttuple); /* Disallow use of system attributes in extended stats */ if (attForm->attnum <= 0) @@ -754,7 +754,7 @@ RemoveStatisticsById(Oid statsOid) if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for statistics object %u", statsOid); - statext = (Form_pg_statistic_ext) GETSTRUCT(tup); + statext = GETSTRUCT(pg_statistic_ext, tup); relid = statext->stxrelid; CacheInvalidateRelcacheByRelid(relid); @@ -885,7 +885,7 @@ StatisticsGetRelation(Oid statId, bool missing_ok) return InvalidOid; elog(ERROR, "cache lookup failed for statistics object %u", statId); } - stx = (Form_pg_statistic_ext) GETSTRUCT(tuple); + stx = GETSTRUCT(pg_statistic_ext, tuple); Assert(stx->oid == statId); result = stx->stxrelid; diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index bdc1208724..722d5337fc 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -990,7 +990,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, errmsg("subscription \"%s\" does not exist", stmt->subname))); - form = (Form_pg_subscription) GETSTRUCT(tup); + form = GETSTRUCT(pg_subscription, tup); subid = form->oid; /* must be owner */ @@ -1362,7 +1362,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel) return; } - form = (Form_pg_subscription) GETSTRUCT(tup); + form = GETSTRUCT(pg_subscription, tup); subid = form->oid; /* must be owner */ @@ -1652,7 +1652,7 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) { Form_pg_subscription form; - form = (Form_pg_subscription) GETSTRUCT(tup); + form = GETSTRUCT(pg_subscription, tup); if (form->subowner == newOwnerId) return; @@ -1705,7 +1705,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("subscription \"%s\" does not exist", name))); - form = (Form_pg_subscription) GETSTRUCT(tup); + form = GETSTRUCT(pg_subscription, tup); subid = form->oid; AlterSubscriptionOwner_internal(rel, tup, newOwnerId); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index f2947ea9b4..5fe2701ed1 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1543,7 +1543,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(tuple)) return; /* concurrently dropped, so nothing to do */ - classform = (Form_pg_class) GETSTRUCT(tuple); + classform = GETSTRUCT(pg_class, tuple); is_partition = classform->relispartition; /* Pass back some data to save lookups in RemoveRelations */ @@ -1595,7 +1595,7 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid, return; } - indexform = (Form_pg_index) GETSTRUCT(locTuple); + indexform = GETSTRUCT(pg_index, locTuple); indisvalid = indexform->indisvalid; ReleaseSysCache(locTuple); @@ -3248,7 +3248,7 @@ SetRelationHasSubclass(Oid relationId, bool relhassubclass) tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relationId); - classtuple = (Form_pg_class) GETSTRUCT(tuple); + classtuple = GETSTRUCT(pg_class, tuple); if (classtuple->relhassubclass != relhassubclass) { @@ -3350,7 +3350,7 @@ SetRelationTableSpace(Relation rel, tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", reloid); - rd_rel = (Form_pg_class) GETSTRUCT(tuple); + rd_rel = GETSTRUCT(pg_class, tuple); /* Update the pg_class row. */ rd_rel->reltablespace = (newTableSpaceId == MyDatabaseTableSpace) ? @@ -3522,7 +3522,7 @@ renameatt_internal(Oid myrelid, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" does not exist", oldattname))); - attform = (Form_pg_attribute) GETSTRUCT(atttup); + attform = GETSTRUCT(pg_attribute, atttup); attnum = attform->attnum; if (attnum <= 0) @@ -3578,7 +3578,7 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) return; /* concurrently dropped */ - form = (Form_pg_class) GETSTRUCT(tuple); + form = GETSTRUCT(pg_class, tuple); renameatt_check(relid, form, false); ReleaseSysCache(tuple); } @@ -3664,7 +3664,7 @@ rename_constraint_internal(Oid myrelid, if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", constraintOid); - con = (Form_pg_constraint) GETSTRUCT(tuple); + con = GETSTRUCT(pg_constraint, tuple); if (myrelid && con->contype == CONSTRAINT_CHECK && !con->connoinherit) { @@ -3876,7 +3876,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid)); if (!HeapTupleIsValid(reltup)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for relation %u", myrelid); - relform = (Form_pg_class) GETSTRUCT(reltup); + relform = GETSTRUCT(pg_class, reltup); if (get_relname_relid(newrelname, namespaceId) != InvalidOid) ereport(ERROR, @@ -3951,7 +3951,7 @@ ResetRelRewrite(Oid myrelid) reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid)); if (!HeapTupleIsValid(reltup)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for relation %u", myrelid); - relform = (Form_pg_class) GETSTRUCT(reltup); + relform = GETSTRUCT(pg_class, reltup); /* * Update pg_class tuple. @@ -6447,7 +6447,7 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation, while (HeapTupleIsValid(depTup = systable_getnext(depScan))) { - Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup); + Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup); Relation rel; Form_pg_attribute att; @@ -6553,7 +6553,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class classform = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class classform = GETSTRUCT(pg_class, tuple); if (behavior == DROP_RESTRICT) ereport(ERROR, @@ -6585,7 +6585,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be void check_of_type(HeapTuple typetuple) { - Form_pg_type typ = (Form_pg_type) GETSTRUCT(typetuple); + Form_pg_type typ = GETSTRUCT(pg_type, typetuple); bool typeOk = false; if (typ->typtype == TYPTYPE_COMPOSITE) @@ -6704,7 +6704,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, tuple = SearchSysCacheCopyAttName(myrelid, colDef->colname); if (HeapTupleIsValid(tuple)) { - Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple); + Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple); Oid ctypeId; int32 ctypmod; Oid ccollid; @@ -6785,10 +6785,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid)); if (!HeapTupleIsValid(reltup)) elog(ERROR, "cache lookup failed for relation %u", myrelid); - relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind; + relkind = (GETSTRUCT(pg_class, reltup))->relkind; /* Determine the new attribute's number */ - newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1; + newattnum = (GETSTRUCT(pg_class, reltup))->relnatts + 1; if (newattnum > MaxHeapAttributeNumber) ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), @@ -6796,7 +6796,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, MaxHeapAttributeNumber))); typeTuple = typenameType(NULL, colDef->typeName, &typmod); - tform = (Form_pg_type) GETSTRUCT(typeTuple); + tform = GETSTRUCT(pg_type, typeTuple); typeOid = tform->oid; aclresult = pg_type_aclcheck(typeOid, GetUserId(), ACL_USAGE); @@ -6851,7 +6851,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, /* * Update pg_class tuple as appropriate */ - ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum; + (GETSTRUCT(pg_class, reltup))->relnatts = newattnum; CatalogTupleUpdate(pgclass, &reltup->t_self, reltup); @@ -7084,7 +7084,7 @@ check_for_column_name_collision(Relation rel, const char *colname, if (!HeapTupleIsValid(attTuple)) return true; - attnum = ((Form_pg_attribute) GETSTRUCT(attTuple))->attnum; + attnum = (GETSTRUCT(pg_attribute, attTuple))->attnum; ReleaseSysCache(attTuple); /* @@ -7207,7 +7207,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode) (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); attnum = attTup->attnum; /* Prevent them from altering a system attribute */ @@ -7243,7 +7243,7 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode) indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexoid); - indexStruct = (Form_pg_index) GETSTRUCT(indexTuple); + indexStruct = GETSTRUCT(pg_index, indexTuple); /* * If the index is not a primary key or an index used as replica @@ -7364,7 +7364,7 @@ ATPrepSetNotNull(List **wqueue, Relation rel, errmsg("column \"%s\" of relation \"%s\" does not exist", cmd->name, RelationGetRelationName(rel)))); - attnotnull = ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull; + attnotnull = (GETSTRUCT(pg_attribute, tuple))->attnotnull; ReleaseSysCache(tuple); if (attnotnull) return; @@ -7414,7 +7414,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel, errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum; + attnum = (GETSTRUCT(pg_attribute, tuple))->attnum; /* Prevent them from altering a system attribute */ if (attnum <= 0) @@ -7426,9 +7426,9 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel, /* * Okay, actually perform the catalog change ... if needed */ - if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull) + if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull) { - ((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull = true; + (GETSTRUCT(pg_attribute, tuple))->attnotnull = true; CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); @@ -7439,7 +7439,7 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel, * already found that we must verify some other NOT NULL constraint. */ if (!tab->verify_new_notnull && - !NotNullImpliedByRelConstraints(rel, (Form_pg_attribute) GETSTRUCT(tuple))) + !NotNullImpliedByRelConstraints(rel, GETSTRUCT(pg_attribute, tuple))) { /* Tell Phase 3 it needs to test the constraint */ tab->verify_new_notnull = true; @@ -7488,7 +7488,7 @@ ATExecCheckNotNull(AlteredTableInfo *tab, Relation rel, errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull) + if (!(GETSTRUCT(pg_attribute, tuple))->attnotnull) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("constraint must be added to child tables too"), @@ -7669,7 +7669,7 @@ ATExecAddIdentity(Relation rel, const char *colName, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); attnum = attTup->attnum; /* Can't alter a system attribute */ @@ -7764,7 +7764,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); attnum = attTup->attnum; if (attnum <= 0) @@ -7823,7 +7823,7 @@ ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); attnum = attTup->attnum; if (attnum <= 0) @@ -7912,7 +7912,7 @@ ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recurs errmsg("column \"%s\" of relation \"%s\" does not exist", cmd->name, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); if (attTup->attinhcount > 0) ereport(ERROR, @@ -7942,7 +7942,7 @@ ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMOD errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); attnum = attTup->attnum; if (attnum <= 0) @@ -8081,7 +8081,7 @@ ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newVa colNum, RelationGetRelationName(rel)))); } - attrtuple = (Form_pg_attribute) GETSTRUCT(tuple); + attrtuple = GETSTRUCT(pg_attribute, tuple); attnum = attrtuple->attnum; if (attnum <= 0) @@ -8151,7 +8151,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attrtuple = (Form_pg_attribute) GETSTRUCT(tuple); + attrtuple = GETSTRUCT(pg_attribute, tuple); attnum = attrtuple->attnum; if (attnum <= 0) @@ -8241,7 +8241,7 @@ SetIndexStorageProperties(Relation rel, Relation attrelation, if (HeapTupleIsValid(tuple)) { - Form_pg_attribute attrtuple = (Form_pg_attribute) GETSTRUCT(tuple); + Form_pg_attribute attrtuple = GETSTRUCT(pg_attribute, tuple); if (setstorage) attrtuple->attstorage = newstorage; @@ -8285,7 +8285,7 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attrtuple = (Form_pg_attribute) GETSTRUCT(tuple); + attrtuple = GETSTRUCT(pg_attribute, tuple); attnum = attrtuple->attnum; if (attnum <= 0) @@ -8402,7 +8402,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName, return InvalidObjectAddress; } } - targetatt = (Form_pg_attribute) GETSTRUCT(tuple); + targetatt = GETSTRUCT(pg_attribute, tuple); attnum = targetatt->attnum; @@ -8476,7 +8476,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName, if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for attribute \"%s\" of relation %u", colName, childrelid); - childatt = (Form_pg_attribute) GETSTRUCT(tuple); + childatt = GETSTRUCT(pg_attribute, tuple); if (childatt->attinhcount <= 0) /* shouldn't happen */ elog(ERROR, "relation %u has non-inherited attribute \"%s\"", @@ -9205,7 +9205,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclasses[i])); if (!HeapTupleIsValid(cla_ht)) elog(ERROR, "cache lookup failed for opclass %u", opclasses[i]); - cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht); + cla_tup = GETSTRUCT(pg_opclass, cla_ht); amid = cla_tup->opcmethod; opfamily = cla_tup->opcfamily; opcintype = cla_tup->opcintype; @@ -9983,7 +9983,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel) NULL, 2, key); while ((tuple = systable_getnext(scan)) != NULL) { - Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple); clone = lappend_oid(clone, constrForm->oid); } @@ -10023,7 +10023,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel) tuple = SearchSysCache1(CONSTROID, constrOid); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", constrOid); - constrForm = (Form_pg_constraint) GETSTRUCT(tuple); + constrForm = GETSTRUCT(pg_constraint, tuple); /* * As explained above: don't try to clone a constraint for which we're @@ -10210,7 +10210,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", parentConstrOid); - constrForm = (Form_pg_constraint) GETSTRUCT(tuple); + constrForm = GETSTRUCT(pg_constraint, tuple); /* Don't clone constraints whose parents are being cloned */ if (list_member_oid(clone, constrForm->conparentid)) @@ -10417,7 +10417,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk, ObjectIdGetDatum(parentConstrOid)); if (!HeapTupleIsValid(parentConstrTup)) elog(ERROR, "cache lookup failed for constraint %u", parentConstrOid); - parentConstr = (Form_pg_constraint) GETSTRUCT(parentConstrTup); + parentConstr = GETSTRUCT(pg_constraint, parentConstrTup); /* * Do some quick & easy initial checks. If any of these fail, we cannot @@ -10448,7 +10448,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk, ObjectIdGetDatum(fk->conoid)); if (!HeapTupleIsValid(partcontup)) elog(ERROR, "cache lookup failed for constraint %u", fk->conoid); - partConstr = (Form_pg_constraint) GETSTRUCT(partcontup); + partConstr = GETSTRUCT(pg_constraint, partcontup); if (OidIsValid(partConstr->conparentid) || !partConstr->convalidated || partConstr->condeferrable != parentConstr->condeferrable || @@ -10480,7 +10480,7 @@ tryAttachPartitionForeignKey(ForeignKeyCacheInfo *fk, NULL, 1, &key); while ((trigtup = systable_getnext(scan)) != NULL) { - Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup); + Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup); ObjectAddress trigger; if (trgform->tgconstrrelid != fk->conrelid) @@ -10554,7 +10554,7 @@ GetForeignKeyActionTriggers(Relation trigrel, NULL, 1, &key); while ((trigtup = systable_getnext(scan)) != NULL) { - Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup); + Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup); if (trgform->tgconstrrelid != conrelid) continue; @@ -10609,7 +10609,7 @@ GetForeignKeyCheckTriggers(Relation trigrel, NULL, 1, &key); while ((trigtup = systable_getnext(scan)) != NULL) { - Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup); + Form_pg_trigger trgform = GETSTRUCT(pg_trigger, trigtup); if (trgform->tgconstrrelid != confrelid) continue; @@ -10694,7 +10694,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse, errmsg("constraint \"%s\" of relation \"%s\" does not exist", cmdcon->conname, RelationGetRelationName(rel)))); - currcon = (Form_pg_constraint) GETSTRUCT(contuple); + currcon = GETSTRUCT(pg_constraint, contuple); if (currcon->contype != CONSTRAINT_FOREIGN) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -10720,7 +10720,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd, bool recurse, /* Loop to find the topmost constraint */ while (HeapTupleIsValid(tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(parent)))) { - Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp); + Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp); /* If no parent, this is the constraint we want */ if (!OidIsValid(contup->conparentid)) @@ -10796,7 +10796,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, Oid refrelid; bool changed = false; - currcon = (Form_pg_constraint) GETSTRUCT(contuple); + currcon = GETSTRUCT(pg_constraint, contuple); conoid = currcon->oid; refrelid = currcon->confrelid; @@ -10816,7 +10816,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, SysScanDesc tgscan; copyTuple = heap_copytuple(contuple); - copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); + copy_con = GETSTRUCT(pg_constraint, copyTuple); copy_con->condeferrable = cmdcon->deferrable; copy_con->condeferred = cmdcon->initdeferred; CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple); @@ -10842,7 +10842,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, NULL, 1, &tgkey); while (HeapTupleIsValid(tgtuple = systable_getnext(tgscan))) { - Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tgtuple); + Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tgtuple); Form_pg_trigger copy_tg; HeapTuple copyTuple; @@ -10869,7 +10869,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, continue; copyTuple = heap_copytuple(tgtuple); - copy_tg = (Form_pg_trigger) GETSTRUCT(copyTuple); + copy_tg = GETSTRUCT(pg_trigger, copyTuple); copy_tg->tgdeferrable = cmdcon->deferrable; copy_tg->tginitdeferred = cmdcon->initdeferred; @@ -10908,7 +10908,7 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, while (HeapTupleIsValid(childtup = systable_getnext(pscan))) { - Form_pg_constraint childcon = (Form_pg_constraint) GETSTRUCT(childtup); + Form_pg_constraint childcon = GETSTRUCT(pg_constraint, childtup); Relation childrel; childrel = table_open(childcon->conrelid, lockmode); @@ -10972,7 +10972,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName, errmsg("constraint \"%s\" of relation \"%s\" does not exist", constrName, RelationGetRelationName(rel)))); - con = (Form_pg_constraint) GETSTRUCT(tuple); + con = GETSTRUCT(pg_constraint, tuple); if (con->contype != CONSTRAINT_FOREIGN && con->contype != CONSTRAINT_CHECK) ereport(ERROR, @@ -11096,7 +11096,7 @@ ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName, * Now update the catalog, while we have the door open. */ copyTuple = heap_copytuple(tuple); - copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); + copy_con = GETSTRUCT(pg_constraint, copyTuple); copy_con->convalidated = true; CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple); @@ -11146,9 +11146,9 @@ transformColumnNameList(Oid relId, List *colList, (errcode(ERRCODE_TOO_MANY_COLUMNS), errmsg("cannot have more than %d keys in a foreign key", INDEX_MAX_KEYS))); - attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum; + attnums[attnum] = (GETSTRUCT(pg_attribute, atttuple))->attnum; if (atttypids != NULL) - atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid; + atttypids[attnum] = (GETSTRUCT(pg_attribute, atttuple))->atttypid; ReleaseSysCache(atttuple); attnum++; } @@ -11199,7 +11199,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexoid); - indexStruct = (Form_pg_index) GETSTRUCT(indexTuple); + indexStruct = GETSTRUCT(pg_index, indexTuple); if (indexStruct->indisprimary && indexStruct->indisvalid) { /* @@ -11312,7 +11312,7 @@ transformFkeyCheckAttrs(Relation pkrel, indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid)); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "cache lookup failed for index %u", indexoid); - indexStruct = (Form_pg_index) GETSTRUCT(indexTuple); + indexStruct = GETSTRUCT(pg_index, indexTuple); /* * Must have the right number of columns; must be unique and not a @@ -11826,7 +11826,7 @@ ATExecDropConstraint(Relation rel, const char *constrName, { ObjectAddress conobj; - con = (Form_pg_constraint) GETSTRUCT(tuple); + con = GETSTRUCT(pg_constraint, tuple); /* Don't drop inherited constraints */ if (con->coninhcount > 0 && !recursing) @@ -11959,7 +11959,7 @@ ATExecDropConstraint(Relation rel, const char *constrName, systable_endscan(scan); - con = (Form_pg_constraint) GETSTRUCT(copy_tuple); + con = GETSTRUCT(pg_constraint, copy_tuple); /* Right now only CHECK constraints can be inherited */ if (con->contype != CONSTRAINT_CHECK) @@ -12067,7 +12067,7 @@ ATPrepAlterColumnType(List **wqueue, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attTup = GETSTRUCT(pg_attribute, tuple); attnum = attTup->attnum; /* Can't alter a system attribute */ @@ -12248,7 +12248,7 @@ ATPrepAlterColumnType(List **wqueue, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(childrel)))); - childattTup = (Form_pg_attribute) GETSTRUCT(childtuple); + childattTup = GETSTRUCT(pg_attribute, childtuple); if (childattTup->attinhcount > numparents) ereport(ERROR, @@ -12408,7 +12408,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", colName, RelationGetRelationName(rel)))); - attTup = (Form_pg_attribute) GETSTRUCT(heapTup); + attTup = GETSTRUCT(pg_attribute, heapTup); attnum = attTup->attnum; attOldTup = TupleDescAttr(tab->oldDesc, attnum - 1); @@ -12422,7 +12422,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, /* Look up the target type (should not fail, since prep found it) */ typeTuple = typenameType(NULL, typeName, &targettypmod); - tform = (Form_pg_type) GETSTRUCT(typeTuple); + tform = GETSTRUCT(pg_type, typeTuple); targettype = tform->oid; /* And the collation */ targetcollid = GetColumnDefCollation(NULL, def, targettype); @@ -12496,7 +12496,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, while (HeapTupleIsValid(depTup = systable_getnext(scan))) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup); + Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup); ObjectAddress foundObject; foundObject.classId = foundDep->classid; @@ -12702,7 +12702,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, while (HeapTupleIsValid(depTup = systable_getnext(scan))) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(depTup); + Form_pg_depend foundDep = GETSTRUCT(pg_depend, depTup); ObjectAddress foundObject; foundObject.classId = foundDep->refclassid; @@ -12790,7 +12790,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, valuesAtt, nullsAtt, replacesAtt); heap_freetuple(heapTup); heapTup = newTup; - attTup = (Form_pg_attribute) GETSTRUCT(heapTup); + attTup = GETSTRUCT(pg_attribute, heapTup); } } @@ -13068,7 +13068,7 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode) tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(oldId)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for constraint %u", oldId); - con = (Form_pg_constraint) GETSTRUCT(tup); + con = GETSTRUCT(pg_constraint, tup); if (OidIsValid(con->conrelid)) relid = con->conrelid; else @@ -13558,7 +13558,7 @@ ATExecAlterColumnGenericOptions(Relation rel, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign table \"%s\" does not exist", RelationGetRelationName(rel)))); - fttableform = (Form_pg_foreign_table) GETSTRUCT(tuple); + fttableform = GETSTRUCT(pg_foreign_table, tuple); server = GetForeignServer(fttableform->ftserver); fdw = GetForeignDataWrapper(server->fdwid); @@ -13574,7 +13574,7 @@ ATExecAlterColumnGenericOptions(Relation rel, colName, RelationGetRelationName(rel)))); /* Prevent them from altering a system attribute */ - atttableform = (Form_pg_attribute) GETSTRUCT(tuple); + atttableform = GETSTRUCT(pg_attribute, tuple); attnum = atttableform->attnum; if (attnum <= 0) ereport(ERROR, @@ -13662,7 +13662,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relationOid); - tuple_class = (Form_pg_class) GETSTRUCT(tuple); + tuple_class = GETSTRUCT(pg_class, tuple); /* Can we change the ownership of this tuple? */ switch (tuple_class->relkind) @@ -13898,7 +13898,7 @@ change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId) true, NULL, 1, key); while (HeapTupleIsValid(attributeTuple = systable_getnext(scan))) { - Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple); + Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple); Datum repl_val[Natts_pg_attribute]; bool repl_null[Natts_pg_attribute]; bool repl_repl[Natts_pg_attribute]; @@ -13975,7 +13975,7 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lock while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depForm = GETSTRUCT(pg_depend, tup); Relation seqRel; /* skip dependencies other than auto dependencies on columns */ @@ -14518,7 +14518,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt) scan = table_beginscan_catalog(rel, 1, key); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class relForm = GETSTRUCT(pg_class, tuple); Oid relOid = relForm->oid; /* @@ -14856,7 +14856,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel) inhseqno = 0; while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan))) { - Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inheritsTuple); + Form_pg_inherits inh = GETSTRUCT(pg_inherits, inheritsTuple); if (inh->inhparent == RelationGetRelid(parent_rel)) ereport(ERROR, @@ -14901,7 +14901,7 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc) Datum attr; Datum expr; - con = (Form_pg_constraint) GETSTRUCT(contup); + con = GETSTRUCT(pg_constraint, contup); attr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull); if (isnull) elog(ERROR, "null conbin for constraint %u", con->oid); @@ -14921,8 +14921,8 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc) static bool constraints_equivalent(HeapTuple a, HeapTuple b, TupleDesc tupleDesc) { - Form_pg_constraint acon = (Form_pg_constraint) GETSTRUCT(a); - Form_pg_constraint bcon = (Form_pg_constraint) GETSTRUCT(b); + Form_pg_constraint acon = GETSTRUCT(pg_constraint, a); + Form_pg_constraint bcon = GETSTRUCT(pg_constraint, b); if (acon->condeferrable != bcon->condeferrable || acon->condeferred != bcon->condeferred || @@ -14982,7 +14982,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel) if (HeapTupleIsValid(tuple)) { /* Check they are same type, typmod, and collation */ - Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple); + Form_pg_attribute childatt = GETSTRUCT(pg_attribute, tuple); if (attribute->atttypid != childatt->atttypid || attribute->atttypmod != childatt->atttypmod) @@ -15145,7 +15145,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel) while (HeapTupleIsValid(parent_tuple = systable_getnext(parent_scan))) { - Form_pg_constraint parent_con = (Form_pg_constraint) GETSTRUCT(parent_tuple); + Form_pg_constraint parent_con = GETSTRUCT(pg_constraint, parent_tuple); SysScanDesc child_scan; ScanKeyData child_key; HeapTuple child_tuple; @@ -15168,7 +15168,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel) while (HeapTupleIsValid(child_tuple = systable_getnext(child_scan))) { - Form_pg_constraint child_con = (Form_pg_constraint) GETSTRUCT(child_tuple); + Form_pg_constraint child_con = GETSTRUCT(pg_constraint, child_tuple); HeapTuple child_copy; if (child_con->contype != CONSTRAINT_CHECK) @@ -15209,7 +15209,7 @@ MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel) * later on, this change will just roll back.) */ child_copy = heap_copytuple(child_tuple); - child_con = (Form_pg_constraint) GETSTRUCT(child_copy); + child_con = GETSTRUCT(pg_constraint, child_copy); child_con->coninhcount++; /* @@ -15317,7 +15317,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel) { Form_pg_inherits inhForm; - inhForm = (Form_pg_inherits) GETSTRUCT(inheritsTuple); + inhForm = GETSTRUCT(pg_inherits, inheritsTuple); if (inhForm->inhdetachpending) ereport(ERROR, errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), @@ -15332,7 +15332,7 @@ MarkInheritDetached(Relation child_rel, Relation parent_rel) HeapTuple newtup; newtup = heap_copytuple(inheritsTuple); - ((Form_pg_inherits) GETSTRUCT(newtup))->inhdetachpending = true; + (GETSTRUCT(pg_inherits, newtup))->inhdetachpending = true; CatalogTupleUpdate(catalogRelation, &inheritsTuple->t_self, @@ -15421,7 +15421,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached) true, NULL, 1, key); while (HeapTupleIsValid(attributeTuple = systable_getnext(scan))) { - Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(attributeTuple); + Form_pg_attribute att = GETSTRUCT(pg_attribute, attributeTuple); /* Ignore if dropped or not inherited */ if (att->attisdropped) @@ -15434,7 +15434,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached) { /* Decrement inhcount and possibly set islocal to true */ HeapTuple copyTuple = heap_copytuple(attributeTuple); - Form_pg_attribute copy_att = (Form_pg_attribute) GETSTRUCT(copyTuple); + Form_pg_attribute copy_att = GETSTRUCT(pg_attribute, copyTuple); copy_att->attinhcount--; if (copy_att->attinhcount == 0) @@ -15465,7 +15465,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached) while (HeapTupleIsValid(constraintTuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple); if (con->contype == CONSTRAINT_CHECK) connames = lappend(connames, pstrdup(NameStr(con->conname))); @@ -15483,7 +15483,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached) while (HeapTupleIsValid(constraintTuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(constraintTuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, constraintTuple); bool match; ListCell *lc; @@ -15504,7 +15504,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached) { /* Decrement inhcount and possibly set islocal to true */ HeapTuple copyTuple = heap_copytuple(constraintTuple); - Form_pg_constraint copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); + Form_pg_constraint copy_con = GETSTRUCT(pg_constraint, copyTuple); if (copy_con->coninhcount <= 0) /* shouldn't happen */ elog(ERROR, "relation %u has non-inherited constraint \"%s\"", @@ -15573,7 +15573,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid, while (HeapTupleIsValid(depTuple = systable_getnext(scan))) { - Form_pg_depend dep = (Form_pg_depend) GETSTRUCT(depTuple); + Form_pg_depend dep = GETSTRUCT(pg_depend, depTuple); if (dep->refclassid == refclassid && dep->refobjid == refobjid && @@ -15618,7 +15618,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode) /* Validate the type. */ typetuple = typenameType(NULL, ofTypename, NULL); check_of_type(typetuple); - typeform = (Form_pg_type) GETSTRUCT(typetuple); + typeform = GETSTRUCT(pg_type, typetuple); typeid = typeform->oid; /* Fail if the table has any inheritance parents. */ @@ -15719,7 +15719,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode) classtuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(classtuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - ((Form_pg_class) GETSTRUCT(classtuple))->reloftype = typeid; + (GETSTRUCT(pg_class, classtuple))->reloftype = typeid; CatalogTupleUpdate(relationRelation, &classtuple->t_self, classtuple); InvokeObjectPostAlterHook(RelationRelationId, relid, 0); @@ -15764,7 +15764,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode) tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - ((Form_pg_class) GETSTRUCT(tuple))->reloftype = InvalidOid; + (GETSTRUCT(pg_class, tuple))->reloftype = InvalidOid; CatalogTupleUpdate(relationRelation, &tuple->t_self, tuple); InvokeObjectPostAlterHook(RelationRelationId, relid, 0); @@ -15801,7 +15801,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid, if (!HeapTupleIsValid(pg_class_tuple)) elog(ERROR, "cache lookup failed for relation \"%s\"", RelationGetRelationName(rel)); - pg_class_form = (Form_pg_class) GETSTRUCT(pg_class_tuple); + pg_class_form = GETSTRUCT(pg_class, pg_class_tuple); if (pg_class_form->relreplident != ri_type) { pg_class_form->relreplident = ri_type; @@ -15821,7 +15821,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid, pg_index_tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid)); if (!HeapTupleIsValid(pg_index_tuple)) elog(ERROR, "cache lookup failed for index %u", indexOid); - pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple); + pg_index_form = GETSTRUCT(pg_index, pg_index_tuple); if (pg_index_form->indisreplident) { @@ -15845,7 +15845,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid, ObjectIdGetDatum(thisIndexOid)); if (!HeapTupleIsValid(pg_index_tuple)) elog(ERROR, "cache lookup failed for index %u", thisIndexOid); - pg_index_form = (Form_pg_index) GETSTRUCT(pg_index_tuple); + pg_index_form = GETSTRUCT(pg_index, pg_index_tuple); /* * Unset the bit if set. We know it's wrong because we checked this @@ -16015,7 +16015,7 @@ ATExecSetRowSecurity(Relation rel, bool rls) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls; + (GETSTRUCT(pg_class, tuple))->relrowsecurity = rls; CatalogTupleUpdate(pg_class, &tuple->t_self, tuple); table_close(pg_class, RowExclusiveLock); @@ -16041,7 +16041,7 @@ ATExecForceNoForceRowSecurity(Relation rel, bool force_rls) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - ((Form_pg_class) GETSTRUCT(tuple))->relforcerowsecurity = force_rls; + (GETSTRUCT(pg_class, tuple))->relforcerowsecurity = force_rls; CatalogTupleUpdate(pg_class, &tuple->t_self, tuple); table_close(pg_class, RowExclusiveLock); @@ -16076,7 +16076,7 @@ ATExecGenericOptions(Relation rel, List *options) (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("foreign table \"%s\" does not exist", RelationGetRelationName(rel)))); - tableform = (Form_pg_foreign_table) GETSTRUCT(tuple); + tableform = GETSTRUCT(pg_foreign_table, tuple); server = GetForeignServer(tableform->ftserver); fdw = GetForeignDataWrapper(server->fdwid); @@ -16158,7 +16158,7 @@ ATExecSetCompression(Relation rel, column, RelationGetRelationName(rel)))); /* prevent them from altering a system attribute */ - atttableform = (Form_pg_attribute) GETSTRUCT(tuple); + atttableform = GETSTRUCT(pg_attribute, tuple); attnum = atttableform->attnum; if (attnum <= 0) ereport(ERROR, @@ -16279,7 +16279,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged) while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple); if (con->contype == CONSTRAINT_FOREIGN) { @@ -16481,7 +16481,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid, classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(classTup)) elog(ERROR, "cache lookup failed for relation %u", relOid); - classForm = (Form_pg_class) GETSTRUCT(classTup); + classForm = GETSTRUCT(pg_class, classTup); Assert(classForm->relnamespace == oldNspOid); @@ -16613,7 +16613,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend depForm = GETSTRUCT(pg_depend, tup); Relation seqRel; /* skip dependencies other than auto dependencies on columns */ @@ -16939,8 +16939,8 @@ RangeVarCallbackForTruncate(const RangeVar *relation, if (!HeapTupleIsValid(tuple)) /* should not happen */ elog(ERROR, "cache lookup failed for relation %u", relId); - truncate_check_rel(relId, (Form_pg_class) GETSTRUCT(tuple)); - truncate_check_perms(relId, (Form_pg_class) GETSTRUCT(tuple)); + truncate_check_rel(relId, GETSTRUCT(pg_class, tuple)); + truncate_check_perms(relId, GETSTRUCT(pg_class, tuple)); ReleaseSysCache(tuple); } @@ -16968,7 +16968,7 @@ RangeVarCallbackOwnsRelation(const RangeVar *relation, relation->relname); if (!allowSystemTableMods && - IsSystemClass(relId, (Form_pg_class) GETSTRUCT(tuple))) + IsSystemClass(relId, GETSTRUCT(pg_class, tuple))) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied: \"%s\" is a system catalog", @@ -16995,7 +16995,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) return; /* concurrently dropped */ - classform = (Form_pg_class) GETSTRUCT(tuple); + classform = GETSTRUCT(pg_class, tuple); relkind = classform->relkind; /* Must own relation. */ @@ -17219,7 +17219,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu errmsg("column \"%s\" named in partition key does not exist", pelem->name), parser_errposition(pstate, pelem->location))); - attform = (Form_pg_attribute) GETSTRUCT(atttuple); + attform = GETSTRUCT(pg_attribute, atttuple); if (attform->attnum <= 0) ereport(ERROR, @@ -18127,7 +18127,7 @@ CloneRowTriggersToPartition(Relation parent, Relation partition) while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - Form_pg_trigger trigForm = (Form_pg_trigger) GETSTRUCT(tuple); + Form_pg_trigger trigForm = GETSTRUCT(pg_trigger, tuple); CreateTrigStmt *trigStmt; Node *qual = NULL; Datum value; @@ -18481,7 +18481,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent, contup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(fk->conoid)); if (!HeapTupleIsValid(contup)) elog(ERROR, "cache lookup failed for constraint %u", fk->conoid); - conform = (Form_pg_constraint) GETSTRUCT(contup); + conform = GETSTRUCT(pg_constraint, contup); /* consider only the inherited foreign keys */ if (conform->contype != CONSTRAINT_FOREIGN || @@ -18586,7 +18586,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent, if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", RelationGetRelid(partRel)); - Assert(((Form_pg_class) GETSTRUCT(tuple))->relispartition); + Assert((GETSTRUCT(pg_class, tuple))->relispartition); /* Clear relpartbound and reset relispartition */ memset(new_val, 0, sizeof(new_val)); @@ -18598,7 +18598,7 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent, newtuple = heap_modify_tuple(tuple, RelationGetDescr(classRel), new_val, new_null, new_repl); - ((Form_pg_class) GETSTRUCT(newtuple))->relispartition = false; + (GETSTRUCT(pg_class, newtuple))->relispartition = false; CatalogTupleUpdate(classRel, &newtuple->t_self, newtuple); heap_freetuple(newtuple); table_close(classRel, RowExclusiveLock); @@ -18748,7 +18748,7 @@ DropClonedTriggersFromPartition(Oid partitionId) true, NULL, 1, &skey); while (HeapTupleIsValid(trigtup = systable_getnext(scan))) { - Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(trigtup); + Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, trigtup); ObjectAddress trig; /* Ignore triggers that weren't cloned */ @@ -18835,7 +18835,7 @@ RangeVarCallbackForAttachIndex(const RangeVar *rv, Oid relOid, Oid oldRelOid, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid)); if (!HeapTupleIsValid(tuple)) return; /* concurrently dropped, so nothing to do */ - classform = (Form_pg_class) GETSTRUCT(tuple); + classform = GETSTRUCT(pg_class, tuple); if (classform->relkind != RELKIND_PARTITIONED_INDEX && classform->relkind != RELKIND_INDEX) ereport(ERROR, @@ -19056,7 +19056,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) NULL, 1, &key); while ((inhTup = systable_getnext(scan)) != NULL) { - Form_pg_inherits inhForm = (Form_pg_inherits) GETSTRUCT(inhTup); + Form_pg_inherits inhForm = GETSTRUCT(pg_inherits, inhTup); HeapTuple indTup; Form_pg_index indexForm; @@ -19064,7 +19064,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) ObjectIdGetDatum(inhForm->inhrelid)); if (!HeapTupleIsValid(indTup)) elog(ERROR, "cache lookup failed for index %u", inhForm->inhrelid); - indexForm = (Form_pg_index) GETSTRUCT(indTup); + indexForm = GETSTRUCT(pg_index, indTup); if (indexForm->indisvalid) tuples += 1; ReleaseSysCache(indTup); @@ -19086,7 +19086,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) idxRel = table_open(IndexRelationId, RowExclusiveLock); newtup = heap_copytuple(partedIdx->rd_indextuple); - ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true; + (GETSTRUCT(pg_index, newtup))->indisvalid = true; updated = true; CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup); @@ -19156,7 +19156,7 @@ GetParentedForeignKeyRefs(Relation partition) scan = systable_beginscan(pg_constraint, InvalidOid, true, NULL, 2, key); while ((tuple = systable_getnext(scan)) != NULL) { - Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint constrForm = GETSTRUCT(pg_constraint, tuple); /* * We only need to process constraints that are part of larger ones. @@ -19197,7 +19197,7 @@ ATDetachCheckNoForeignKeyRefs(Relation partition) tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", constrOid); - constrForm = (Form_pg_constraint) GETSTRUCT(tuple); + constrForm = GETSTRUCT(pg_constraint, tuple); Assert(OidIsValid(constrForm->conparentid)); Assert(constrForm->confrelid == RelationGetRelid(partition)); diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index c8bdd9992a..36ff46fda3 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -474,7 +474,7 @@ DropTableSpace(DropTableSpaceStmt *stmt) return; } - spcform = (Form_pg_tablespace) GETSTRUCT(tuple); + spcform = GETSTRUCT(pg_tablespace, tuple); tablespaceoid = spcform->oid; /* Must be tablespace owner */ @@ -1002,7 +1002,7 @@ RenameTableSpace(const char *oldname, const char *newname) oldname))); newtuple = heap_copytuple(tup); - newform = (Form_pg_tablespace) GETSTRUCT(newtuple); + newform = GETSTRUCT(pg_tablespace, newtuple); tspId = newform->oid; table_endscan(scan); @@ -1090,7 +1090,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt) errmsg("tablespace \"%s\" does not exist", stmt->tablespacename))); - tablespaceoid = ((Form_pg_tablespace) GETSTRUCT(tup))->oid; + tablespaceoid = (GETSTRUCT(pg_tablespace, tup))->oid; /* Must be owner of the existing object */ if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId())) @@ -1495,7 +1495,7 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok) /* We assume that there can be at most one matching tuple */ if (HeapTupleIsValid(tuple)) - result = ((Form_pg_tablespace) GETSTRUCT(tuple))->oid; + result = (GETSTRUCT(pg_tablespace, tuple))->oid; else result = InvalidOid; @@ -1541,7 +1541,7 @@ get_tablespace_name(Oid spc_oid) /* We assume that there can be at most one matching tuple */ if (HeapTupleIsValid(tuple)) - result = pstrdup(NameStr(((Form_pg_tablespace) GETSTRUCT(tuple))->spcname)); + result = pstrdup(NameStr((GETSTRUCT(pg_tablespace, tuple))->spcname)); else result = NULL; diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index b8db53b66d..47ef4004fa 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -736,7 +736,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, /* There should be at most one matching tuple */ if (HeapTupleIsValid(tuple = systable_getnext(tgscan))) { - Form_pg_trigger oldtrigger = (Form_pg_trigger) GETSTRUCT(tuple); + Form_pg_trigger oldtrigger = GETSTRUCT(pg_trigger, tuple); trigoid = oldtrigger->oid; existing_constraint_oid = oldtrigger->tgconstraint; @@ -1022,9 +1022,9 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", RelationGetRelid(rel)); - if (!((Form_pg_class) GETSTRUCT(tuple))->relhastriggers) + if (!(GETSTRUCT(pg_class, tuple))->relhastriggers) { - ((Form_pg_class) GETSTRUCT(tuple))->relhastriggers = true; + (GETSTRUCT(pg_class, tuple))->relhastriggers = true; CatalogTupleUpdate(pgrel, &tuple->t_self, tuple); @@ -1283,7 +1283,7 @@ TriggerSetParentTrigger(Relation trigRel, if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for trigger %u", childTrigId); newtup = heap_copytuple(tuple); - trigForm = (Form_pg_trigger) GETSTRUCT(newtup); + trigForm = GETSTRUCT(pg_trigger, newtup); if (OidIsValid(parentTrigId)) { /* don't allow setting parent for a constraint that already has one */ @@ -1355,7 +1355,7 @@ RemoveTriggerById(Oid trigOid) /* * Open and exclusive-lock the relation the trigger belongs to. */ - relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid; + relid = (GETSTRUCT(pg_trigger, tup))->tgrelid; rel = table_open(relid, AccessExclusiveLock); @@ -1443,7 +1443,7 @@ get_trigger_oid(Oid relid, const char *trigname, bool missing_ok) } else { - oid = ((Form_pg_trigger) GETSTRUCT(tup))->oid; + oid = (GETSTRUCT(pg_trigger, tup))->oid; } systable_endscan(tgscan); @@ -1464,7 +1464,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) return; /* concurrently dropped */ - form = (Form_pg_class) GETSTRUCT(tuple); + form = GETSTRUCT(pg_class, tuple); /* only tables and views can have triggers */ if (form->relkind != RELKIND_RELATION && form->relkind != RELKIND_VIEW && @@ -1551,7 +1551,7 @@ renametrig(RenameStmt *stmt) { Form_pg_trigger trigform; - trigform = (Form_pg_trigger) GETSTRUCT(tuple); + trigform = GETSTRUCT(pg_trigger, tuple); tgoid = trigform->oid; /* @@ -1625,7 +1625,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup, SysScanDesc tgscan; /* If the trigger already has the new name, nothing to do. */ - tgform = (Form_pg_trigger) GETSTRUCT(trigtup); + tgform = GETSTRUCT(pg_trigger, trigtup); if (strcmp(NameStr(tgform->tgname), newname) == 0) return; @@ -1655,7 +1655,7 @@ renametrig_internal(Relation tgrel, Relation targetrel, HeapTuple trigtup, * The target name is free; update the existing pg_trigger tuple with it. */ tuple = heap_copytuple(trigtup); /* need a modifiable copy */ - tgform = (Form_pg_trigger) GETSTRUCT(tuple); + tgform = GETSTRUCT(pg_trigger, tuple); /* * If the trigger has a name different from what we expected, let the user @@ -1707,7 +1707,7 @@ renametrig_partition(Relation tgrel, Oid partitionId, Oid parentTriggerOid, NULL, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(tgscan))) { - Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tuple); + Form_pg_trigger tgform = GETSTRUCT(pg_trigger, tuple); Relation partitionRel; if (tgform->tgparentid != parentTriggerOid) @@ -1794,7 +1794,7 @@ EnableDisableTrigger(Relation rel, const char *tgname, while (HeapTupleIsValid(tuple = systable_getnext(tgscan))) { - Form_pg_trigger oldtrig = (Form_pg_trigger) GETSTRUCT(tuple); + Form_pg_trigger oldtrig = GETSTRUCT(pg_trigger, tuple); if (oldtrig->tgisinternal) { @@ -1814,7 +1814,7 @@ EnableDisableTrigger(Relation rel, const char *tgname, { /* need to change this one ... make a copy to scribble on */ HeapTuple newtup = heap_copytuple(tuple); - Form_pg_trigger newtrig = (Form_pg_trigger) GETSTRUCT(newtup); + Form_pg_trigger newtrig = GETSTRUCT(pg_trigger, newtup); newtrig->tgenabled = fires_when; @@ -1898,7 +1898,7 @@ RelationBuildTriggers(Relation relation) while (HeapTupleIsValid(htup = systable_getnext(tgscan))) { - Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup); + Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup); Trigger *build; Datum datum; bool isnull; @@ -5702,7 +5702,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) while (HeapTupleIsValid(tup = systable_getnext(conscan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tup); if (con->condeferrable) conoidlist = lappend_oid(conoidlist, con->oid); @@ -5758,7 +5758,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint con = GETSTRUCT(pg_constraint, tuple); conoidlist = lappend_oid(conoidlist, con->oid); } @@ -5791,7 +5791,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) while (HeapTupleIsValid(htup = systable_getnext(tgscan))) { - Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup); + Form_pg_trigger pg_trigger = GETSTRUCT(pg_trigger, htup); /* * Silently skip triggers that are marked as non-deferrable in diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c index 4cc4e3c00f..164379934a 100644 --- a/src/backend/commands/tsearchcmds.c +++ b/src/backend/commands/tsearchcmds.c @@ -130,7 +130,7 @@ get_ts_parser_func(DefElem *defel, int attnum) static ObjectAddress makeParserDependencies(HeapTuple tuple) { - Form_pg_ts_parser prs = (Form_pg_ts_parser) GETSTRUCT(tuple); + Form_pg_ts_parser prs = GETSTRUCT(pg_ts_parser, tuple); ObjectAddress myself, referenced; ObjectAddresses *addrs; @@ -300,7 +300,7 @@ DefineTSParser(List *names, List *parameters) static ObjectAddress makeDictionaryDependencies(HeapTuple tuple) { - Form_pg_ts_dict dict = (Form_pg_ts_dict) GETSTRUCT(tuple); + Form_pg_ts_dict dict = GETSTRUCT(pg_ts_dict, tuple); ObjectAddress myself, referenced; ObjectAddresses *addrs; @@ -353,7 +353,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions) if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for text search template %u", tmplId); - tform = (Form_pg_ts_template) GETSTRUCT(tup); + tform = GETSTRUCT(pg_ts_template, tup); initmethod = tform->tmplinit; @@ -552,7 +552,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt) /* * Validate */ - verify_dictoptions(((Form_pg_ts_dict) GETSTRUCT(tup))->dicttemplate, + verify_dictoptions((GETSTRUCT(pg_ts_dict, tup))->dicttemplate, dictoptions); /* @@ -645,7 +645,7 @@ get_ts_template_func(DefElem *defel, int attnum) static ObjectAddress makeTSTemplateDependencies(HeapTuple tuple) { - Form_pg_ts_template tmpl = (Form_pg_ts_template) GETSTRUCT(tuple); + Form_pg_ts_template tmpl = GETSTRUCT(pg_ts_template, tuple); ObjectAddress myself, referenced; ObjectAddresses *addrs; @@ -806,7 +806,7 @@ static ObjectAddress makeConfigurationDependencies(HeapTuple tuple, bool removeOld, Relation mapRel) { - Form_pg_ts_config cfg = (Form_pg_ts_config) GETSTRUCT(tuple); + Form_pg_ts_config cfg = GETSTRUCT(pg_ts_config, tuple); ObjectAddresses *addrs; ObjectAddress myself, referenced; @@ -867,7 +867,7 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld, while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { - Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup); + Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup); referenced.classId = TSDictionaryRelationId; referenced.objectId = cfgmap->mapdict; @@ -959,7 +959,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied) elog(ERROR, "cache lookup failed for text search configuration %u", sourceOid); - cfg = (Form_pg_ts_config) GETSTRUCT(tup); + cfg = GETSTRUCT(pg_ts_config, tup); /* use source's parser */ prsOid = cfg->cfgparser; @@ -1017,7 +1017,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied) while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { - Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup); + Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup); HeapTuple newmaptup; Datum mapvalues[Natts_pg_ts_config_map]; bool mapnulls[Natts_pg_ts_config_map]; @@ -1121,7 +1121,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt) errmsg("text search configuration \"%s\" does not exist", NameListToString(stmt->cfgname)))); - cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid; + cfgId = (GETSTRUCT(pg_ts_config, tup))->oid; /* must be owner */ if (!pg_ts_config_ownercheck(cfgId, GetUserId())) @@ -1226,7 +1226,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt, int ndict; ListCell *c; - tsform = (Form_pg_ts_config) GETSTRUCT(tup); + tsform = GETSTRUCT(pg_ts_config, tup); cfgId = tsform->oid; prsId = tsform->cfgparser; @@ -1293,7 +1293,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt, while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { - Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup); + Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup); /* * check if it's one of target token types @@ -1386,7 +1386,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt, int *tokens; ListCell *c; - tsform = (Form_pg_ts_config) GETSTRUCT(tup); + tsform = GETSTRUCT(pg_ts_config, tup); cfgId = tsform->oid; prsId = tsform->cfgparser; diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index a8757a90bf..fc1e512c75 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -345,7 +345,7 @@ DefineType(ParseState *pstate, List *names, List *parameters) Form_pg_type likeForm; likeType = typenameType(NULL, defGetTypeName(likeTypeEl), NULL); - likeForm = (Form_pg_type) GETSTRUCT(likeType); + likeForm = GETSTRUCT(pg_type, likeType); internalLength = likeForm->typlen; byValue = likeForm->typbyval; alignment = likeForm->typalign; @@ -668,7 +668,7 @@ RemoveTypeById(Oid typeOid) * making dependency entries for those, so it has to be done "by hand" * here. */ - if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_ENUM) + if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_ENUM) EnumValuesDelete(typeOid); /* @@ -676,7 +676,7 @@ RemoveTypeById(Oid typeOid) * with making a dependency entry for that, so it has to be done "by hand" * here. */ - if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_RANGE) + if ((GETSTRUCT(pg_type, tup))->typtype == TYPTYPE_RANGE) RangeDelete(typeOid); ReleaseSysCache(tup); @@ -758,7 +758,7 @@ DefineDomain(CreateDomainStmt *stmt) * Look up the base type. */ typeTup = typenameType(NULL, stmt->typeName, &basetypeMod); - baseType = (Form_pg_type) GETSTRUCT(typeTup); + baseType = GETSTRUCT(pg_type, typeTup); basetypeoid = baseType->oid; /* @@ -1308,7 +1308,7 @@ AlterEnum(AlterEnumStmt *stmt) static void checkEnumOwner(HeapTuple tup) { - Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup); + Form_pg_type typTup = GETSTRUCT(pg_type, tup); /* Check that this is actually an enum */ if (typTup->typtype != TYPTYPE_ENUM) @@ -2587,7 +2587,7 @@ AlterDomainDefault(List *names, Node *defaultRaw) tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", domainoid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); /* Check it's a domain and check user has permission for ALTER DOMAIN */ checkDomainOwner(tup); @@ -2712,7 +2712,7 @@ AlterDomainNotNull(List *names, bool notNull) tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", domainoid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); /* Check it's a domain and check user has permission for ALTER DOMAIN */ checkDomainOwner(tup); @@ -2867,7 +2867,7 @@ AlterDomainDropConstraint(List *names, const char *constrName, ObjectAddress conobj; conobj.classId = ConstraintRelationId; - conobj.objectId = ((Form_pg_constraint) GETSTRUCT(contup))->oid; + conobj.objectId = (GETSTRUCT(pg_constraint, contup))->oid; conobj.objectSubId = 0; performDeletion(&conobj, behavior, 0); @@ -2934,7 +2934,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint, tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", domainoid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); /* Check it's a domain and check user has permission for ALTER DOMAIN */ checkDomainOwner(tup); @@ -3088,7 +3088,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName) errmsg("constraint \"%s\" of domain \"%s\" does not exist", constrName, TypeNameToString(typename)))); - con = (Form_pg_constraint) GETSTRUCT(tuple); + con = GETSTRUCT(pg_constraint, tuple); if (con->contype != CONSTRAINT_CHECK) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -3109,7 +3109,7 @@ AlterDomainValidateConstraint(List *names, const char *constrName) * Now update the catalog, while we have the door open. */ copyTuple = heap_copytuple(tuple); - copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); + copy_con = GETSTRUCT(pg_constraint, copyTuple); copy_con->convalidated = true; CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple); @@ -3284,7 +3284,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) while (HeapTupleIsValid(depTup = systable_getnext(depScan))) { - Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup); + Form_pg_depend pg_depend = GETSTRUCT(pg_depend, depTup); RelToCheck *rtc = NULL; ListCell *rellist; Form_pg_attribute pg_att; @@ -3421,7 +3421,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) void checkDomainOwner(HeapTuple tup) { - Form_pg_type typTup = (Form_pg_type) GETSTRUCT(tup); + Form_pg_type typTup = GETSTRUCT(pg_type, tup); /* Check that this is actually a domain */ if (typTup->typtype != TYPTYPE_DOMAIN) @@ -3616,7 +3616,7 @@ RenameType(RenameStmt *stmt) tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typeOid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); /* check permissions on type */ if (!pg_type_ownercheck(typeOid, GetUserId())) @@ -3701,7 +3701,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype) newtup = heap_copytuple(tup); ReleaseSysCache(tup); tup = newtup; - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); /* Don't allow ALTER DOMAIN on a type */ if (objecttype == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN) @@ -3791,7 +3791,7 @@ AlterTypeOwner_oid(Oid typeOid, Oid newOwnerId, bool hasDependEntry) tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typeOid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); /* * If it's a composite type, invoke ATExecChangeOwner so that we fix up @@ -3837,7 +3837,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId) tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typeOid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); memset(repl_null, false, sizeof(repl_null)); memset(repl_repl, false, sizeof(repl_repl)); @@ -3978,7 +3978,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typeOid); - typform = (Form_pg_type) GETSTRUCT(tup); + typform = GETSTRUCT(pg_type, tup); oldNspOid = typform->typnamespace; arrayOid = typform->typarray; @@ -4112,7 +4112,7 @@ AlterType(AlterTypeStmt *stmt) tup = typenameType(NULL, typename, NULL); typeOid = typeTypeId(tup); - typForm = (Form_pg_type) GETSTRUCT(tup); + typForm = GETSTRUCT(pg_type, tup); /* Process options */ memset(&atparams, 0, sizeof(atparams)); @@ -4426,7 +4426,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray, if (!isImplicitArray && (atparams->updateTypmodin || atparams->updateTypmodout)) { - Oid arrtypoid = ((Form_pg_type) GETSTRUCT(newtup))->typarray; + Oid arrtypoid = (GETSTRUCT(pg_type, newtup))->typarray; if (OidIsValid(arrtypoid)) { @@ -4475,7 +4475,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray, while ((domainTup = systable_getnext(scan)) != NULL) { - Form_pg_type domainForm = (Form_pg_type) GETSTRUCT(domainTup); + Form_pg_type domainForm = GETSTRUCT(pg_type, domainTup); /* * Shouldn't have a nonzero typbasetype in a non-domain, but let's diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 984305ba31..767c75ce2f 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -446,7 +446,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt) { RoleSpec *oldrole = lfirst(item); HeapTuple oldroletup = get_rolespec_tuple(oldrole); - Form_pg_authid oldroleform = (Form_pg_authid) GETSTRUCT(oldroletup); + Form_pg_authid oldroleform = GETSTRUCT(pg_authid, oldroletup); Oid oldroleid = oldroleform->oid; char *oldrolename = NameStr(oldroleform->rolname); @@ -620,7 +620,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt) pg_authid_dsc = RelationGetDescr(pg_authid_rel); tuple = get_rolespec_tuple(stmt->role); - authform = (Form_pg_authid) GETSTRUCT(tuple); + authform = GETSTRUCT(pg_authid, tuple); rolename = pstrdup(NameStr(authform->rolname)); roleid = authform->oid; @@ -838,7 +838,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt) "Cannot alter reserved roles."); roletuple = get_rolespec_tuple(stmt->role); - roleform = (Form_pg_authid) GETSTRUCT(roletuple); + roleform = GETSTRUCT(pg_authid, roletuple); roleid = roleform->oid; /* @@ -962,7 +962,7 @@ DropRole(DropRoleStmt *stmt) continue; } - roleform = (Form_pg_authid) GETSTRUCT(tuple); + roleform = GETSTRUCT(pg_authid, tuple); roleid = roleform->oid; if (roleid == GetUserId()) @@ -1117,7 +1117,7 @@ RenameRole(const char *oldname, const char *newname) * effective userid, though. */ - authform = (Form_pg_authid) GETSTRUCT(oldtuple); + authform = GETSTRUCT(pg_authid, oldtuple); roleid = authform->oid; if (roleid == GetSessionUserId()) @@ -1165,7 +1165,7 @@ RenameRole(const char *oldname, const char *newname) /* * createrole is enough privilege unless you want to mess with a superuser */ - if (((Form_pg_authid) GETSTRUCT(oldtuple))->rolsuper) + if ((GETSTRUCT(pg_authid, oldtuple))->rolsuper) { if (!superuser()) ereport(ERROR, @@ -1490,7 +1490,7 @@ AddRoleMems(const char *rolename, Oid roleid, ObjectIdGetDatum(memberid)); if (HeapTupleIsValid(authmem_tuple) && (!admin_opt || - ((Form_pg_auth_members) GETSTRUCT(authmem_tuple))->admin_option)) + (GETSTRUCT(pg_auth_members, authmem_tuple))->admin_option)) { ereport(NOTICE, (errmsg("role \"%s\" is already a member of role \"%s\"", diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 8df25f59d8..72a028f21f 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -806,7 +806,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); /* * Make a returnable VacuumRelation for this rel if user is a proper @@ -894,7 +894,7 @@ get_all_vacuum_rels(int options) while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class classForm = GETSTRUCT(pg_class, tuple); MemoryContext oldcontext; Oid relid = classForm->oid; @@ -1346,7 +1346,7 @@ vac_update_relstats(Relation relation, if (!HeapTupleIsValid(ctup)) elog(ERROR, "pg_class entry for relid %u vanished during vacuuming", relid); - pgcform = (Form_pg_class) GETSTRUCT(ctup); + pgcform = GETSTRUCT(pg_class, ctup); /* Apply statistical updates, if any, to copied tuple */ @@ -1545,7 +1545,7 @@ vac_update_datfrozenxid(void) while ((classTup = systable_getnext(scan)) != NULL) { - Form_pg_class classForm = (Form_pg_class) GETSTRUCT(classTup); + Form_pg_class classForm = GETSTRUCT(pg_class, classTup); /* * Only consider relations able to hold unfrozen XIDs (anything else @@ -1639,7 +1639,7 @@ vac_update_datfrozenxid(void) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for database %u", MyDatabaseId); - dbform = (Form_pg_database) GETSTRUCT(tuple); + dbform = GETSTRUCT(pg_database, tuple); /* * As in vac_update_relstats(), we ordinarily don't want to let @@ -1747,7 +1747,7 @@ vac_truncate_clog(TransactionId frozenXID, while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - volatile FormData_pg_database *dbform = (Form_pg_database) GETSTRUCT(tuple); + volatile FormData_pg_database *dbform = GETSTRUCT(pg_database, tuple); TransactionId datfrozenxid = dbform->datfrozenxid; TransactionId datminmxid = dbform->datminmxid; diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index e5ddcda0b4..49f548d144 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -782,7 +782,7 @@ check_session_authorization(char **newval, void **extra, GucSource source) return false; } - roleform = (Form_pg_authid) GETSTRUCT(roleTup); + roleform = GETSTRUCT(pg_authid, roleTup); roleid = roleform->oid; is_superuser = roleform->rolsuper; @@ -869,7 +869,7 @@ check_role(char **newval, void **extra, GucSource source) return false; } - roleform = (Form_pg_authid) GETSTRUCT(roleTup); + roleform = GETSTRUCT(pg_authid, roleTup); roleid = roleform->oid; is_superuser = roleform->rolsuper; diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index 44b2e0b82d..09c40fa1e1 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -612,7 +612,7 @@ IndexSupportsBackwardScan(Oid indexid) ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexid)); if (!HeapTupleIsValid(ht_idxrel)) elog(ERROR, "cache lookup failed for relation %u", indexid); - idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel); + idxrelrec = GETSTRUCT(pg_class, ht_idxrel); /* Fetch the index AM's API struct */ amroutine = GetIndexAmRoutineByAmId(idxrelrec->relam, false); diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 076226868f..76f18bbbdc 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -178,7 +178,7 @@ prepare_sql_fn_parse_info(HeapTuple procedureTuple, Oid inputCollation) { SQLFunctionParseInfoPtr pinfo; - Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); + Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple); int nargs; pinfo = (SQLFunctionParseInfoPtr) palloc0(sizeof(SQLFunctionParseInfo)); @@ -621,7 +621,7 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK) procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(foid)); if (!HeapTupleIsValid(procedureTuple)) elog(ERROR, "cache lookup failed for function %u", foid); - procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); + procedureStruct = GETSTRUCT(pg_proc, procedureTuple); /* * copy function name immediately for use by error reporting callback, and diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 2fc606cf29..668e3181ac 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -3666,7 +3666,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) if (!HeapTupleIsValid(aggTuple)) elog(ERROR, "cache lookup failed for aggregate %u", aggref->aggfnoid); - aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); + aggform = GETSTRUCT(pg_aggregate, aggTuple); /* Check permission to call aggregate function */ aclresult = pg_proc_aclcheck(aggref->aggfnoid, GetUserId(), @@ -3731,7 +3731,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) if (!HeapTupleIsValid(procTuple)) elog(ERROR, "cache lookup failed for function %u", aggref->aggfnoid); - aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner; + aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner; ReleaseSysCache(procTuple); if (OidIsValid(finalfn_oid)) diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c index 4b104c4d98..14b3547309 100644 --- a/src/backend/executor/nodeWindowAgg.c +++ b/src/backend/executor/nodeWindowAgg.c @@ -2775,7 +2775,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc, if (!HeapTupleIsValid(aggTuple)) elog(ERROR, "cache lookup failed for aggregate %u", wfunc->winfnoid); - aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); + aggform = GETSTRUCT(pg_aggregate, aggTuple); /* * Figure out whether we want to use the moving-aggregate implementation, @@ -2836,7 +2836,7 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc, if (!HeapTupleIsValid(procTuple)) elog(ERROR, "cache lookup failed for function %u", wfunc->winfnoid); - aggOwner = ((Form_pg_proc) GETSTRUCT(procTuple))->proowner; + aggOwner = (GETSTRUCT(pg_proc, procTuple))->proowner; ReleaseSysCache(procTuple); aclresult = pg_proc_aclcheck(transfn_oid, aggOwner, diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 29bc26669b..72998c71fb 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -1291,7 +1291,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) return NULL; } - result = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname)); + result = pstrdup(NameStr((GETSTRUCT(pg_type, typeTuple))->typname)); ReleaseSysCache(typeTuple); return result; } diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c index cf222fc3e9..4f52075f03 100644 --- a/src/backend/foreign/foreign.c +++ b/src/backend/foreign/foreign.c @@ -62,7 +62,7 @@ GetForeignDataWrapperExtended(Oid fdwid, bits16 flags) return NULL; } - fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp); + fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp); fdw = (ForeignDataWrapper *) palloc(sizeof(ForeignDataWrapper)); fdw->fdwid = fdwid; @@ -136,7 +136,7 @@ GetForeignServerExtended(Oid serverid, bits16 flags) return NULL; } - serverform = (Form_pg_foreign_server) GETSTRUCT(tp); + serverform = GETSTRUCT(pg_foreign_server, tp); server = (ForeignServer *) palloc(sizeof(ForeignServer)); server->serverid = serverid; @@ -222,7 +222,7 @@ GetUserMapping(Oid userid, Oid serverid) MappingUserName(userid)))); um = (UserMapping *) palloc(sizeof(UserMapping)); - um->umid = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid; + um->umid = (GETSTRUCT(pg_user_mapping, tp))->oid; um->userid = userid; um->serverid = serverid; @@ -257,7 +257,7 @@ GetForeignTable(Oid relid) tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign table %u", relid); - tableform = (Form_pg_foreign_table) GETSTRUCT(tp); + tableform = GETSTRUCT(pg_foreign_table, tp); ft = (ForeignTable *) palloc(sizeof(ForeignTable)); ft->relid = relid; @@ -347,7 +347,7 @@ GetForeignServerIdByRelId(Oid relid) tp = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign table %u", relid); - tableform = (Form_pg_foreign_table) GETSTRUCT(tp); + tableform = GETSTRUCT(pg_foreign_table, tp); serverid = tableform->ftserver; ReleaseSysCache(tp); @@ -372,7 +372,7 @@ GetFdwRoutineByServerId(Oid serverid) tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(serverid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign server %u", serverid); - serverform = (Form_pg_foreign_server) GETSTRUCT(tp); + serverform = GETSTRUCT(pg_foreign_server, tp); fdwid = serverform->srvfdw; ReleaseSysCache(tp); @@ -380,7 +380,7 @@ GetFdwRoutineByServerId(Oid serverid) tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid); - fdwform = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp); + fdwform = GETSTRUCT(pg_foreign_data_wrapper, tp); fdwhandler = fdwform->fdwhandler; /* Complain if FDW has been set to NO HANDLER. */ diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c index 9330908cbf..c924c0e61c 100644 --- a/src/backend/optimizer/plan/planagg.c +++ b/src/backend/optimizer/plan/planagg.c @@ -505,7 +505,7 @@ fetch_agg_sort_op(Oid aggfnoid) aggTuple = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(aggfnoid)); if (!HeapTupleIsValid(aggTuple)) return InvalidOid; - aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); + aggform = GETSTRUCT(pg_aggregate, aggTuple); aggsortop = aggform->aggsortop; ReleaseSysCache(aggTuple); diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index df4ca12919..c80434b08c 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -866,7 +866,7 @@ hash_ok_operator(OpExpr *expr) tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for operator %u", opid); - optup = (Form_pg_operator) GETSTRUCT(tup); + optup = GETSTRUCT(pg_operator, tup); if (!optup->oprcanhash || !func_strict(optup->oprcode)) { ReleaseSysCache(tup); diff --git a/src/backend/optimizer/prep/prepagg.c b/src/backend/optimizer/prep/prepagg.c index 404a5f1dac..45f28de829 100644 --- a/src/backend/optimizer/prep/prepagg.c +++ b/src/backend/optimizer/prep/prepagg.c @@ -152,7 +152,7 @@ preprocess_aggref(Aggref *aggref, PlannerInfo *root) if (!HeapTupleIsValid(aggTuple)) elog(ERROR, "cache lookup failed for aggregate %u", aggref->aggfnoid); - aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); + aggform = GETSTRUCT(pg_aggregate, aggTuple); aggtransfn = aggform->aggtransfn; aggfinalfn = aggform->aggfinalfn; aggcombinefn = aggform->aggcombinefn; diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c index 9d4bb47027..a450c1e69f 100644 --- a/src/backend/optimizer/util/appendinfo.c +++ b/src/backend/optimizer/util/appendinfo.c @@ -150,7 +150,7 @@ make_inh_translation_list(Relation oldrelation, Relation newrelation, if (!HeapTupleIsValid(newtup)) elog(ERROR, "could not find inherited attribute \"%s\" of relation \"%s\"", attname, RelationGetRelationName(newrelation)); - new_attno = ((Form_pg_attribute) GETSTRUCT(newtup))->attnum - 1; + new_attno = (GETSTRUCT(pg_attribute, newtup))->attnum - 1; Assert(new_attno >= 0 && new_attno < newnatts); ReleaseSysCache(newtup); diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 533df86ff7..277218abdc 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -3962,7 +3962,7 @@ simplify_function(Oid funcid, Oid result_type, int32 result_typmod, func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(func_tuple)) elog(ERROR, "cache lookup failed for function %u", funcid); - func_form = (Form_pg_proc) GETSTRUCT(func_tuple); + func_form = GETSTRUCT(pg_proc, func_tuple); /* * Process the function arguments, unless the caller did it already. @@ -4056,7 +4056,7 @@ List * expand_function_arguments(List *args, bool include_out_arguments, Oid result_type, HeapTuple func_tuple) { - Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple); + Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple); Oid *proargtypes = funcform->proargtypes.values; int pronargs = funcform->pronargs; bool has_named_args = false; @@ -4136,7 +4136,7 @@ expand_function_arguments(List *args, bool include_out_arguments, static List * reorder_function_arguments(List *args, int pronargs, HeapTuple func_tuple) { - Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple); + Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple); int nargsprovided = list_length(args); Node *argarray[FUNC_MAX_ARGS]; ListCell *lc; @@ -4267,7 +4267,7 @@ recheck_cast_function_args(List *args, Oid result_type, Oid *proargtypes, int pronargs, HeapTuple func_tuple) { - Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple); + Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple); int nargs; Oid actual_arg_types[FUNC_MAX_ARGS]; Oid declared_arg_types[FUNC_MAX_ARGS]; @@ -4314,7 +4314,7 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod, HeapTuple func_tuple, eval_const_expressions_context *context) { - Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple); + Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple); bool has_nonconst_input = false; bool has_null_input = false; ListCell *arg; @@ -4441,7 +4441,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid, HeapTuple func_tuple, eval_const_expressions_context *context) { - Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple); + Form_pg_proc funcform = GETSTRUCT(pg_proc, func_tuple); char *src; Datum tmp; bool isNull; @@ -5034,7 +5034,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte) func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_oid)); if (!HeapTupleIsValid(func_tuple)) elog(ERROR, "cache lookup failed for function %u", func_oid); - funcform = (Form_pg_proc) GETSTRUCT(func_tuple); + funcform = GETSTRUCT(pg_proc, func_tuple); /* * Forget it if the function is not SQL-language or has other showstopper diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 5012bfe142..c163f1096e 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -1296,7 +1296,7 @@ get_relation_statistics_worker(List **stainfos, RelOptInfo *rel, if (!HeapTupleIsValid(dtup)) return; - dataForm = (Form_pg_statistic_ext_data) GETSTRUCT(dtup); + dataForm = GETSTRUCT(pg_statistic_ext_data, dtup); /* add one StatisticExtInfo for each kind built */ if (statext_is_kind_built(dtup, STATS_EXT_NDISTINCT)) @@ -1388,7 +1388,7 @@ get_relation_statistics(RelOptInfo *rel, Relation relation) htup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid)); if (!HeapTupleIsValid(htup)) elog(ERROR, "cache lookup failed for statistics object %u", statOid); - staForm = (Form_pg_statistic_ext) GETSTRUCT(htup); + staForm = GETSTRUCT(pg_statistic_ext, htup); /* * First, build the array of columns covered. This is ultimately @@ -1994,7 +1994,7 @@ add_function_cost(PlannerInfo *root, Oid funcid, Node *node, proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); if (OidIsValid(procform->prosupport)) { @@ -2055,7 +2055,7 @@ get_function_rows(PlannerInfo *root, Oid funcid, Node *node) proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); Assert(procform->proretset); /* else caller error */ diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index c655d188c7..36451e7d63 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -3617,7 +3617,7 @@ transformFrameOffset(ParseState *pstate, int frameOptions, for (i = 0; i < proclist->n_members; i++) { HeapTuple proctup = &proclist->members[i]->tuple; - Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup); + Form_pg_amproc procform = GETSTRUCT(pg_amproc, proctup); /* The search will find all support proc types; ignore others */ if (procform->amprocnum != BTINRANGE_PROC) diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index c4e958e4aa..172d4b2034 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -853,7 +853,7 @@ build_coercion_expression(Node *node, tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcId)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcId); - procstruct = (Form_pg_proc) GETSTRUCT(tp); + procstruct = GETSTRUCT(pg_proc, tp); /* * These Asserts essentially check that function is a legal coercion @@ -3056,7 +3056,7 @@ IsBinaryCoercible(Oid srctype, Oid targettype) ObjectIdGetDatum(targettype)); if (!HeapTupleIsValid(tuple)) return false; /* no cast */ - castForm = (Form_pg_cast) GETSTRUCT(tuple); + castForm = GETSTRUCT(pg_cast, tuple); result = (castForm->castmethod == COERCION_METHOD_BINARY && castForm->castcontext == COERCION_CODE_IMPLICIT); @@ -3120,7 +3120,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, if (HeapTupleIsValid(tuple)) { - Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple); + Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple); CoercionContext castcontext; /* convert char value for castcontext to CoercionContext enum */ @@ -3269,7 +3269,7 @@ find_typmod_coercion_function(Oid typeId, result = COERCION_PATH_FUNC; targetType = typeidType(typeId); - typeForm = (Form_pg_type) GETSTRUCT(targetType); + typeForm = GETSTRUCT(pg_type, targetType); /* Check for a "true" array type */ if (IsTrueArrayType(typeForm)) @@ -3287,7 +3287,7 @@ find_typmod_coercion_function(Oid typeId, if (HeapTupleIsValid(tuple)) { - Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple); + Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple); *funcid = castForm->castfunc; ReleaseSysCache(tuple); @@ -3335,7 +3335,7 @@ typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for relation %u", relid); - reltup = (Form_pg_class) GETSTRUCT(tp); + reltup = GETSTRUCT(pg_class, tp); if (reltup->reloftype == reloftypeId) result = true; diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index f71a682cd6..c9be37c173 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -367,7 +367,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for aggregate %u", funcid); - classForm = (Form_pg_aggregate) GETSTRUCT(tup); + classForm = GETSTRUCT(pg_aggregate, tup); aggkind = classForm->aggkind; catDirectArgs = classForm->aggnumdirectargs; ReleaseSysCache(tup); @@ -1623,7 +1623,7 @@ func_get_detail(List *funcname, if (!HeapTupleIsValid(ftup)) /* should not happen */ elog(ERROR, "cache lookup failed for function %u", best_candidate->oid); - pform = (Form_pg_proc) GETSTRUCT(ftup); + pform = GETSTRUCT(pg_proc, ftup); *rettype = pform->prorettype; *retset = pform->proretset; *vatype = pform->provariadic; @@ -1893,7 +1893,7 @@ FuncNameAsType(List *funcname) if (typtup == NULL) return InvalidOid; - if (((Form_pg_type) GETSTRUCT(typtup))->typisdefined && + if ((GETSTRUCT(pg_type, typtup))->typisdefined && !OidIsValid(typeTypeRelid(typtup))) result = typeTypeId(typtup); else diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index cf64afbd85..2c165bb1be 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -249,14 +249,14 @@ get_sort_group_operators(Oid argtype, Oid oprid(Operator op) { - return ((Form_pg_operator) GETSTRUCT(op))->oid; + return (GETSTRUCT(pg_operator, op))->oid; } /* given operator tuple, return the underlying function's OID */ Oid oprfuncid(Operator op) { - Form_pg_operator pgopform = (Form_pg_operator) GETSTRUCT(op); + Form_pg_operator pgopform = GETSTRUCT(pg_operator, op); return pgopform->oprcode; } @@ -471,7 +471,7 @@ compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2, return (Operator) NULL; /* must be noError case */ /* but is it good enough? */ - opform = (Form_pg_operator) GETSTRUCT(optup); + opform = GETSTRUCT(pg_operator, optup); if (IsBinaryCoercible(arg1, opform->oprleft) && IsBinaryCoercible(arg2, opform->oprright)) return optup; @@ -705,7 +705,7 @@ make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree, tup = oper(pstate, opname, ltypeId, rtypeId, false, location); } - opform = (Form_pg_operator) GETSTRUCT(tup); + opform = GETSTRUCT(pg_operator, tup); /* Check it's not a shell */ if (!RegProcedureIsValid(opform->oprcode)) @@ -819,7 +819,7 @@ make_scalar_array_op(ParseState *pstate, List *opname, /* Now resolve the operator */ tup = oper(pstate, opname, ltypeId, rtypeId, false, location); - opform = (Form_pg_operator) GETSTRUCT(tup); + opform = GETSTRUCT(pg_operator, tup); /* Check it's not a shell */ if (!RegProcedureIsValid(opform->oprcode)) diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 926dcbf30e..84d7e05fa5 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -3243,7 +3243,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) if (!HeapTupleIsValid(tp)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, rte->relid); - att_tup = (Form_pg_attribute) GETSTRUCT(tp); + att_tup = GETSTRUCT(pg_attribute, tp); result = att_tup->attisdropped; ReleaseSysCache(tp); } diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index f7ad689459..65f0ab1489 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -247,7 +247,7 @@ LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok) return InvalidOid; } - typoid = ((Form_pg_type) GETSTRUCT(tup))->oid; + typoid = (GETSTRUCT(pg_type, tup))->oid; ReleaseSysCache(tup); return typoid; @@ -272,7 +272,7 @@ typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p) errmsg("type \"%s\" does not exist", TypeNameToString(typeName)), parser_errposition(pstate, typeName->location))); - if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined) + if (!(GETSTRUCT(pg_type, tup))->typisdefined) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type \"%s\" is only a shell", @@ -294,7 +294,7 @@ typenameTypeId(ParseState *pstate, const TypeName *typeName) Type tup; tup = typenameType(pstate, typeName, NULL); - typoid = ((Form_pg_type) GETSTRUCT(tup))->oid; + typoid = (GETSTRUCT(pg_type, tup))->oid; ReleaseSysCache(tup); return typoid; @@ -313,7 +313,7 @@ typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Type tup; tup = typenameType(pstate, typeName, typmod_p); - *typeid_p = ((Form_pg_type) GETSTRUCT(tup))->oid; + *typeid_p = (GETSTRUCT(pg_type, tup))->oid; ReleaseSysCache(tup); } @@ -348,14 +348,14 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ) * for the shell-type case, since a shell couldn't possibly have a * typmodin function. */ - if (!((Form_pg_type) GETSTRUCT(typ))->typisdefined) + if (!(GETSTRUCT(pg_type, typ))->typisdefined) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("type modifier cannot be specified for shell type \"%s\"", TypeNameToString(typeName)), parser_errposition(pstate, typeName->location))); - typmodin = ((Form_pg_type) GETSTRUCT(typ))->typmodin; + typmodin = (GETSTRUCT(pg_type, typ))->typmodin; if (typmodin == InvalidOid) ereport(ERROR, @@ -591,7 +591,7 @@ typeTypeId(Type tp) { if (tp == NULL) /* probably useless */ elog(ERROR, "typeTypeId() called with NULL type struct"); - return ((Form_pg_type) GETSTRUCT(tp))->oid; + return (GETSTRUCT(pg_type, tp))->oid; } /* given type (as type struct), return the length of type */ @@ -600,7 +600,7 @@ typeLen(Type t) { Form_pg_type typ; - typ = (Form_pg_type) GETSTRUCT(t); + typ = GETSTRUCT(pg_type, t); return typ->typlen; } @@ -610,7 +610,7 @@ typeByVal(Type t) { Form_pg_type typ; - typ = (Form_pg_type) GETSTRUCT(t); + typ = GETSTRUCT(pg_type, t); return typ->typbyval; } @@ -620,7 +620,7 @@ typeTypeName(Type t) { Form_pg_type typ; - typ = (Form_pg_type) GETSTRUCT(t); + typ = GETSTRUCT(pg_type, t); /* pstrdup here because result may need to outlive the syscache entry */ return pstrdup(NameStr(typ->typname)); } @@ -631,7 +631,7 @@ typeTypeRelid(Type typ) { Form_pg_type typtup; - typtup = (Form_pg_type) GETSTRUCT(typ); + typtup = GETSTRUCT(pg_type, typ); return typtup->typrelid; } @@ -641,7 +641,7 @@ typeTypeCollation(Type typ) { Form_pg_type typtup; - typtup = (Form_pg_type) GETSTRUCT(typ); + typtup = GETSTRUCT(pg_type, typ); return typtup->typcollation; } @@ -653,7 +653,7 @@ typeTypeCollation(Type typ) Datum stringTypeDatum(Type tp, char *string, int32 atttypmod) { - Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typform = GETSTRUCT(pg_type, tp); Oid typinput = typform->typinput; Oid typioparam = getTypeIOParam(tp); @@ -674,7 +674,7 @@ typeidTypeRelid(Oid type_id) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", type_id); - type = (Form_pg_type) GETSTRUCT(typeTuple); + type = GETSTRUCT(pg_type, typeTuple); result = type->typrelid; ReleaseSysCache(typeTuple); return result; @@ -697,7 +697,7 @@ typeOrDomainTypeRelid(Oid type_id) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_id)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", type_id); - type = (Form_pg_type) GETSTRUCT(typeTuple); + type = GETSTRUCT(pg_type, typeTuple); if (type->typtype != TYPTYPE_DOMAIN) { /* Not a domain, so done looking through domains */ @@ -797,7 +797,7 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok } else { - Form_pg_type typ = (Form_pg_type) GETSTRUCT(tup); + Form_pg_type typ = GETSTRUCT(pg_type, tup); if (!typ->typisdefined) ereport(ERROR, diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index b57253463b..417a571529 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -693,7 +693,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) errmsg("identity columns are not supported on partitions"))); ctype = typenameType(cxt->pstate, column->typeName, NULL); - typeOid = ((Form_pg_type) GETSTRUCT(ctype))->oid; + typeOid = (GETSTRUCT(pg_type, ctype))->oid; ReleaseSysCache(ctype); if (saw_identity) @@ -1457,7 +1457,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename) tuple = typenameType(NULL, ofTypename, NULL); check_of_type(tuple); - ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid; + ofTypeId = (GETSTRUCT(pg_type, tuple))->oid; ofTypename->typeOid = ofTypeId; /* cached for later */ tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1); @@ -1541,11 +1541,11 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(source_relid)); if (!HeapTupleIsValid(ht_idxrel)) elog(ERROR, "cache lookup failed for relation %u", source_relid); - idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel); + idxrelrec = GETSTRUCT(pg_class, ht_idxrel); /* Fetch pg_index tuple for source index from relcache entry */ ht_idx = source_idx->rd_indextuple; - idxrec = (Form_pg_index) GETSTRUCT(ht_idx); + idxrec = GETSTRUCT(pg_index, ht_idx); indrelid = idxrec->indrelid; /* Fetch the pg_am tuple of the index' access method */ @@ -1553,7 +1553,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, if (!HeapTupleIsValid(ht_am)) elog(ERROR, "cache lookup failed for access method %u", idxrelrec->relam); - amrec = (Form_pg_am) GETSTRUCT(ht_am); + amrec = GETSTRUCT(pg_am, ht_am); /* Extract indcollation from the pg_index tuple */ datum = SysCacheGetAttr(INDEXRELID, ht_idx, @@ -1620,7 +1620,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, if (!HeapTupleIsValid(ht_constr)) elog(ERROR, "cache lookup failed for constraint %u", constraintId); - conrec = (Form_pg_constraint) GETSTRUCT(ht_constr); + conrec = GETSTRUCT(pg_constraint, ht_constr); index->isconstraint = true; index->deferrable = conrec->condeferrable; @@ -1658,7 +1658,7 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, if (!HeapTupleIsValid(opertup)) elog(ERROR, "cache lookup failed for operator %u", operid); - operform = (Form_pg_operator) GETSTRUCT(opertup); + operform = GETSTRUCT(pg_operator, opertup); oprname = pstrdup(NameStr(operform->oprname)); /* For simplicity we always schema-qualify the op name */ nspname = get_namespace_name(operform->oprnamespace); @@ -1889,7 +1889,7 @@ generateClonedExtStatsStmt(RangeVar *heapRel, Oid heapRelid, ht_stats = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(source_statsid)); if (!HeapTupleIsValid(ht_stats)) elog(ERROR, "cache lookup failed for statistics object %u", source_statsid); - statsrec = (Form_pg_statistic_ext) GETSTRUCT(ht_stats); + statsrec = GETSTRUCT(pg_statistic_ext, ht_stats); /* Determine which statistics types exist */ datum = SysCacheGetAttr(STATEXTOID, ht_stats, @@ -2001,7 +2001,7 @@ get_collation(Oid collation, Oid actual_datatype) ht_coll = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation)); if (!HeapTupleIsValid(ht_coll)) elog(ERROR, "cache lookup failed for collation %u", collation); - coll_rec = (Form_pg_collation) GETSTRUCT(ht_coll); + coll_rec = GETSTRUCT(pg_collation, ht_coll); /* For simplicity, we always schema-qualify the name */ nsp_name = get_namespace_name(coll_rec->collnamespace); @@ -2028,7 +2028,7 @@ get_opclass(Oid opclass, Oid actual_datatype) ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(ht_opc)) elog(ERROR, "cache lookup failed for opclass %u", opclass); - opc_rec = (Form_pg_opclass) GETSTRUCT(ht_opc); + opc_rec = GETSTRUCT(pg_opclass, ht_opc); if (GetDefaultOpClass(actual_datatype, opc_rec->opcmethod) != opclass) { @@ -3771,7 +3771,7 @@ transformColumnType(CreateStmtContext *cxt, ColumnDef *column) if (column->collClause) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(ctype); + Form_pg_type typtup = GETSTRUCT(pg_type, ctype); LookupCollation(cxt->pstate, column->collClause->collname, diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 2e146aac93..a3ffd2947b 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -1910,7 +1910,7 @@ get_database_list(void) while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection))) { - Form_pg_database pgdatabase = (Form_pg_database) GETSTRUCT(tup); + Form_pg_database pgdatabase = GETSTRUCT(pg_database, tup); avw_dbase *avdb; MemoryContext oldcxt; @@ -1997,7 +1997,7 @@ do_autovacuum(void) tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for database %u", MyDatabaseId); - dbForm = (Form_pg_database) GETSTRUCT(tuple); + dbForm = GETSTRUCT(pg_database, tuple); if (dbForm->datistemplate || !dbForm->datallowconn) { @@ -2055,7 +2055,7 @@ do_autovacuum(void) */ while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL) { - Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class classForm = GETSTRUCT(pg_class, tuple); PgStat_StatTabEntry *tabentry; AutoVacOpts *relopts; Oid relid; @@ -2148,7 +2148,7 @@ do_autovacuum(void) relScan = table_beginscan_catalog(classRel, 1, &key); while ((tuple = heap_getnext(relScan, ForwardScanDirection)) != NULL) { - Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class classForm = GETSTRUCT(pg_class, tuple); PgStat_StatTabEntry *tabentry; Oid relid; AutoVacOpts *relopts = NULL; @@ -2235,7 +2235,7 @@ do_autovacuum(void) UnlockRelationOid(relid, AccessExclusiveLock); continue; } - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); /* * Make all the same tests made in the loop above. In event of OID @@ -2340,7 +2340,7 @@ do_autovacuum(void) classTup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(classTup)) continue; /* somebody deleted the rel, forget it */ - isshared = ((Form_pg_class) GETSTRUCT(classTup))->relisshared; + isshared = (GETSTRUCT(pg_class, classTup))->relisshared; ReleaseSysCache(classTup); /* @@ -2726,9 +2726,9 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc) bytea *relopts; AutoVacOpts *av; - Assert(((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_RELATION || - ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_MATVIEW || - ((Form_pg_class) GETSTRUCT(tup))->relkind == RELKIND_TOASTVALUE); + Assert((GETSTRUCT(pg_class, tup))->relkind == RELKIND_RELATION || + (GETSTRUCT(pg_class, tup))->relkind == RELKIND_MATVIEW || + (GETSTRUCT(pg_class, tup))->relkind == RELKIND_TOASTVALUE); relopts = extractRelOptions(tup, pg_class_desc, NULL); if (relopts == NULL) @@ -2767,7 +2767,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map, classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(classTup)) return NULL; - classForm = (Form_pg_class) GETSTRUCT(classTup); + classForm = GETSTRUCT(pg_class, classTup); /* * Get the applicable reloptions. If it is a TOAST table, try to get the diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 2bdab53e19..8f8d61d682 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -114,7 +114,7 @@ get_subscription_list(void) while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection))) { - Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup); + Form_pg_subscription subform = GETSTRUCT(pg_subscription, tup); Subscription *sub; MemoryContext oldcxt; diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index 21937ab2d3..bcc8ce4451 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -218,7 +218,7 @@ replorigin_by_name(const char *roname, bool missing_ok) tuple = SearchSysCache1(REPLORIGNAME, roname_d); if (HeapTupleIsValid(tuple)) { - ident = (Form_pg_replication_origin) GETSTRUCT(tuple); + ident = GETSTRUCT(pg_replication_origin, tuple); roident = ident->roident; ReleaseSysCache(tuple); } @@ -460,7 +460,7 @@ replorigin_by_oid(RepOriginId roident, bool missing_ok, char **roname) if (HeapTupleIsValid(tuple)) { - ric = (Form_pg_replication_origin) GETSTRUCT(tuple); + ric = GETSTRUCT(pg_replication_origin, tuple); *roname = text_to_cstring(&ric->roname); ReleaseSysCache(tuple); diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index ff8513e2d2..01f38d1b28 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -736,7 +736,7 @@ logicalrep_write_typ(StringInfo out, TransactionId xid, Oid typoid) tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(basetypoid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", basetypoid); - typtup = (Form_pg_type) GETSTRUCT(tup); + typtup = GETSTRUCT(pg_type, tup); /* use Oid as relation identifier */ pq_sendint32(out, typoid); @@ -827,7 +827,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, TupleTableSlot *slot, typtup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(att->atttypid)); if (!HeapTupleIsValid(typtup)) elog(ERROR, "cache lookup failed for type %u", att->atttypid); - typclass = (Form_pg_type) GETSTRUCT(typtup); + typclass = GETSTRUCT(pg_type, typtup); /* * Send in binary if requested and type has suitable send function. diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 38e3b1c1b3..591d625c24 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -3939,7 +3939,7 @@ clear_subscription_skip_lsn(XLogRecPtr finish_lsn) if (!HeapTupleIsValid(tup)) elog(ERROR, "subscription \"%s\" does not exist", MySubscription->name); - subform = (Form_pg_subscription) GETSTRUCT(tup); + subform = GETSTRUCT(pg_subscription, tup); /* * Clear the subskiplsn. If the user has already changed subskiplsn before diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index 185bf5fbff..75c7785044 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -128,7 +128,7 @@ InsertRule(const char *rulname, ReleaseSysCache(oldtup); - rewriteObjectId = ((Form_pg_rewrite) GETSTRUCT(tup))->oid; + rewriteObjectId = (GETSTRUCT(pg_rewrite, tup))->oid; is_update = true; } else @@ -627,7 +627,7 @@ DefineQueryRewrite(const char *rulename, classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(event_relid)); if (!HeapTupleIsValid(classTup)) elog(ERROR, "cache lookup failed for relation %u", event_relid); - classForm = (Form_pg_class) GETSTRUCT(classTup); + classForm = GETSTRUCT(pg_class, classTup); classForm->relam = InvalidOid; classForm->reltablespace = InvalidOid; @@ -877,7 +877,7 @@ EnableDisableRule(Relation rel, const char *rulename, errmsg("rule \"%s\" for relation \"%s\" does not exist", rulename, get_rel_name(owningRel)))); - ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup); + ruleform = GETSTRUCT(pg_rewrite, ruletup); /* * Verify that the user has appropriate permissions. @@ -928,7 +928,7 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) return; /* concurrently dropped */ - form = (Form_pg_class) GETSTRUCT(tuple); + form = GETSTRUCT(pg_class, tuple); /* only tables and views can have rules */ if (form->relkind != RELKIND_RELATION && @@ -991,7 +991,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("rule \"%s\" for relation \"%s\" does not exist", oldName, RelationGetRelationName(targetrel)))); - ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup); + ruleform = GETSTRUCT(pg_rewrite, ruletup); ruleOid = ruleform->oid; /* rule with the new name should not already exist */ diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index 2b51683f6d..ad845f4124 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -71,7 +71,7 @@ RemoveRewriteRuleById(Oid ruleOid) * going on that might depend on this rule. (Note: a weaker lock would * suffice if it's not an ON SELECT rule.) */ - eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class; + eventRelationOid = (GETSTRUCT(pg_rewrite, tuple))->ev_class; event_relation = table_open(eventRelationOid, AccessExclusiveLock); if (!allowSystemTableMods && IsSystemRelation(event_relation)) diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index 80e2509450..bb8c6c1fbd 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -64,7 +64,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules) tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relationId); - classForm = (Form_pg_class) GETSTRUCT(tuple); + classForm = GETSTRUCT(pg_class, tuple); if (classForm->relhasrules != relHasRules) { @@ -109,7 +109,7 @@ get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok) errmsg("rule \"%s\" for relation \"%s\" does not exist", rulename, get_rel_name(relid)))); } - ruleform = (Form_pg_rewrite) GETSTRUCT(tuple); + ruleform = GETSTRUCT(pg_rewrite, tuple); Assert(relid == ruleform->ev_class); ruleoid = ruleform->oid; ReleaseSysCache(tuple); diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index d2aa8d0ca3..9d9bfa1912 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -453,7 +453,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid) List *exprs = NIL; entry = palloc0(sizeof(StatExtEntry)); - staForm = (Form_pg_statistic_ext) GETSTRUCT(htup); + staForm = GETSTRUCT(pg_statistic_ext, htup); entry->statOid = staForm->oid; entry->schema = get_namespace_name(staForm->stxnamespace); entry->name = pstrdup(NameStr(staForm->stxname)); @@ -561,7 +561,7 @@ examine_attribute(Node *expr) ObjectIdGetDatum(stats->attrtypid)); if (!HeapTupleIsValid(typtuple)) elog(ERROR, "cache lookup failed for type %u", stats->attrtypid); - stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple); + stats->attrtype = GETSTRUCT(pg_type, typtuple); /* * We don't actually analyze individual attributes, so no need to set the @@ -663,7 +663,7 @@ examine_expression(Node *expr, int stattarget) if (!HeapTupleIsValid(typtuple)) elog(ERROR, "cache lookup failed for type %u", stats->attrtypid); - stats->attrtype = (Form_pg_type) GETSTRUCT(typtuple); + stats->attrtype = GETSTRUCT(pg_type, typtuple); stats->anl_context = CurrentMemoryContext; /* XXX should be using * something else? */ stats->tupattnum = InvalidAttrNumber; diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index d204482a61..e63c78c20c 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -412,7 +412,7 @@ inv_getsize(LargeObjectDesc *obj_desc) if (HeapTupleHasNulls(tuple)) /* paranoia */ elog(ERROR, "null field found in pg_largeobject"); - data = (Form_pg_largeobject) GETSTRUCT(tuple); + data = GETSTRUCT(pg_largeobject, tuple); getdatafield(data, &datafield, &len, &pfreeit); lastbyte = (uint64) data->pageno * LOBLKSIZE + len; if (pfreeit) @@ -534,7 +534,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes) if (HeapTupleHasNulls(tuple)) /* paranoia */ elog(ERROR, "null field found in pg_largeobject"); - data = (Form_pg_largeobject) GETSTRUCT(tuple); + data = GETSTRUCT(pg_largeobject, tuple); /* * We expect the indexscan will deliver pages in order. However, @@ -662,7 +662,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes) { if (HeapTupleHasNulls(oldtuple)) /* paranoia */ elog(ERROR, "null field found in pg_largeobject"); - olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple); + olddata = GETSTRUCT(pg_largeobject, oldtuple); Assert(olddata->pageno >= pageno); } neednextpage = false; @@ -848,7 +848,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len) { if (HeapTupleHasNulls(oldtuple)) /* paranoia */ elog(ERROR, "null field found in pg_largeobject"); - olddata = (Form_pg_largeobject) GETSTRUCT(oldtuple); + olddata = GETSTRUCT(pg_largeobject, oldtuple); Assert(olddata->pageno >= pageno); } diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index d429aa4663..2311f1ad05 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -139,7 +139,7 @@ fetch_fp_info(Oid func_id, struct fp_info *fip) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function with OID %u does not exist", func_id))); - pp = (Form_pg_proc) GETSTRUCT(func_htp); + pp = GETSTRUCT(pg_proc, func_htp); /* reject pg_proc entries that are unsafe to call via fastpath */ if (pp->prokind != PROKIND_FUNCTION || pp->proretset) diff --git a/src/backend/tsearch/ts_selfuncs.c b/src/backend/tsearch/ts_selfuncs.c index 8f2679f57e..69dcf0f327 100644 --- a/src/backend/tsearch/ts_selfuncs.c +++ b/src/backend/tsearch/ts_selfuncs.c @@ -165,7 +165,7 @@ tsquerysel(VariableStatData *vardata, Datum constval) Form_pg_statistic stats; AttStatsSlot sslot; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); /* MCELEM will be an array of TEXT elements for a tsvector column */ if (get_attstatsslot(&sslot, vardata->statsTuple, diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index b7fd3bcf05..6ee7101357 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -603,7 +603,7 @@ aclitemout(PG_FUNCTION_ARGS) htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantee)); if (HeapTupleIsValid(htup)) { - putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname)); + putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname)); ReleaseSysCache(htup); } else @@ -631,7 +631,7 @@ aclitemout(PG_FUNCTION_ARGS) htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantor)); if (HeapTupleIsValid(htup)) { - putid(p, NameStr(((Form_pg_authid) GETSTRUCT(htup))->rolname)); + putid(p, NameStr((GETSTRUCT(pg_authid, htup))->rolname)); ReleaseSysCache(htup); } else @@ -2818,7 +2818,7 @@ convert_column_name(Oid tableoid, text *column) { Form_pg_attribute attributeForm; - attributeForm = (Form_pg_attribute) GETSTRUCT(attTuple); + attributeForm = GETSTRUCT(pg_attribute, attTuple); /* We want to return NULL for dropped columns */ if (attributeForm->attisdropped) attnum = InvalidAttrNumber; @@ -4782,7 +4782,7 @@ has_rolinherit(Oid roleid) utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(utup)) { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolinherit; + result = (GETSTRUCT(pg_authid, utup))->rolinherit; ReleaseSysCache(utup); } return result; @@ -4835,7 +4835,7 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type, dbtup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId)); if (!HeapTupleIsValid(dbtup)) elog(ERROR, "cache lookup failed for database %u", MyDatabaseId); - dba = ((Form_pg_database) GETSTRUCT(dbtup))->datdba; + dba = (GETSTRUCT(pg_database, dbtup))->datdba; ReleaseSysCache(dbtup); } @@ -4867,14 +4867,14 @@ roles_is_member_of(Oid roleid, enum RoleRecurseType type, for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; - Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; + Oid otherid = (GETSTRUCT(pg_auth_members, tup))->roleid; /* * While otherid==InvalidOid shouldn't appear in the catalog, the * OidIsValid() avoids crashing if that arises. */ if (otherid == admin_of && - ((Form_pg_auth_members) GETSTRUCT(tup))->admin_option && + (GETSTRUCT(pg_auth_members, tup))->admin_option && OidIsValid(admin_of)) *is_admin = true; @@ -5274,7 +5274,7 @@ get_rolespec_name(const RoleSpec *role) char *rolename; tp = get_rolespec_tuple(role); - authForm = (Form_pg_authid) GETSTRUCT(tp); + authForm = GETSTRUCT(pg_authid, tp); rolename = pstrdup(NameStr(authForm->rolname)); ReleaseSysCache(tp); diff --git a/src/backend/utils/adt/amutils.c b/src/backend/utils/adt/amutils.c index 9d78a90d69..f04ed870fe 100644 --- a/src/backend/utils/adt/amutils.c +++ b/src/backend/utils/adt/amutils.c @@ -174,7 +174,7 @@ indexam_property(FunctionCallInfo fcinfo, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(index_oid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); - rd_rel = (Form_pg_class) GETSTRUCT(tuple); + rd_rel = GETSTRUCT(pg_class, tuple); if (rd_rel->relkind != RELKIND_INDEX && rd_rel->relkind != RELKIND_PARTITIONED_INDEX) { @@ -229,7 +229,7 @@ indexam_property(FunctionCallInfo fcinfo, tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); - rd_index = (Form_pg_index) GETSTRUCT(tuple); + rd_index = GETSTRUCT(pg_index, tuple); Assert(index_oid == rd_index->indexrelid); Assert(attno > 0 && attno <= rd_index->indnatts); diff --git a/src/backend/utils/adt/array_selfuncs.c b/src/backend/utils/adt/array_selfuncs.c index 8cbee1406b..9bac8771c1 100644 --- a/src/backend/utils/adt/array_selfuncs.c +++ b/src/backend/utils/adt/array_selfuncs.c @@ -139,7 +139,7 @@ scalararraysel_containment(PlannerInfo *root, AttStatsSlot sslot; AttStatsSlot hslot; - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); /* MCELEM will be an array of same type as element */ if (get_attstatsslot(&sslot, vardata.statsTuple, @@ -362,7 +362,7 @@ calc_arraycontsel(VariableStatData *vardata, Datum constval, AttStatsSlot sslot; AttStatsSlot hslot; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); /* MCELEM will be an array of same type as column */ if (get_attstatsslot(&sslot, vardata->statsTuple, diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 34efa121b4..403cbd0b13 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -857,7 +857,7 @@ pg_relation_filenode(PG_FUNCTION_ARGS) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); - relform = (Form_pg_class) GETSTRUCT(tuple); + relform = GETSTRUCT(pg_class, tuple); if (RELKIND_HAS_STORAGE(relform->relkind)) { @@ -931,7 +931,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); - relform = (Form_pg_class) GETSTRUCT(tuple); + relform = GETSTRUCT(pg_class, tuple); if (RELKIND_HAS_STORAGE(relform->relkind)) { diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c index 3de0cb01a2..3d17b1de79 100644 --- a/src/backend/utils/adt/domains.c +++ b/src/backend/utils/adt/domains.c @@ -365,7 +365,7 @@ errdatatype(Oid datatypeOid) tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(datatypeOid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", datatypeOid); - typtup = (Form_pg_type) GETSTRUCT(tup); + typtup = GETSTRUCT(pg_type, tup); err_generic_string(PG_DIAG_SCHEMA_NAME, get_namespace_name(typtup->typnamespace)); diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c index 0cc7a6d8ad..bb24bd13fa 100644 --- a/src/backend/utils/adt/enum.c +++ b/src/backend/utils/adt/enum.c @@ -63,7 +63,7 @@ static void check_safe_enum_use(HeapTuple enumval_tup) { TransactionId xmin; - Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enumval_tup); + Form_pg_enum en = GETSTRUCT(pg_enum, enumval_tup); /* * If the row is hinted as committed, it's surely safe. This provides a @@ -138,7 +138,7 @@ enum_in(PG_FUNCTION_ARGS) * This comes from pg_enum.oid and stores system oids in user tables. This * oid must be preserved by binary upgrades. */ - enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid; + enumoid = (GETSTRUCT(pg_enum, tup))->oid; ReleaseSysCache(tup); @@ -159,7 +159,7 @@ enum_out(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid internal value for enum: %u", enumval))); - en = (Form_pg_enum) GETSTRUCT(tup); + en = GETSTRUCT(pg_enum, tup); result = pstrdup(NameStr(en->enumlabel)); @@ -202,7 +202,7 @@ enum_recv(PG_FUNCTION_ARGS) /* check it's safe to use in SQL */ check_safe_enum_use(tup); - enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid; + enumoid = (GETSTRUCT(pg_enum, tup))->oid; ReleaseSysCache(tup); @@ -225,7 +225,7 @@ enum_send(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid internal value for enum: %u", enumval))); - en = (Form_pg_enum) GETSTRUCT(tup); + en = GETSTRUCT(pg_enum, tup); pq_begintypsend(&buf); pq_sendtext(&buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel))); @@ -284,7 +284,7 @@ enum_cmp_internal(Oid arg1, Oid arg2, FunctionCallInfo fcinfo) (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid internal value for enum: %u", arg1))); - en = (Form_pg_enum) GETSTRUCT(enum_tup); + en = GETSTRUCT(pg_enum, enum_tup); typeoid = en->enumtypid; ReleaseSysCache(enum_tup); /* Now locate and remember the typcache entry */ @@ -412,7 +412,7 @@ enum_endpoint(Oid enumtypoid, ScanDirection direction) { /* check it's safe to use in SQL */ check_safe_enum_use(enum_tuple); - minmax = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid; + minmax = (GETSTRUCT(pg_enum, enum_tuple))->oid; } else { @@ -572,7 +572,7 @@ enum_range_internal(Oid enumtypoid, Oid lower, Oid upper) while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection))) { - Oid enum_oid = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid; + Oid enum_oid = (GETSTRUCT(pg_enum, enum_tuple))->oid; if (!left_found && lower == enum_oid) left_found = true; diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c index 060fd7e183..e2e127ac2c 100644 --- a/src/backend/utils/adt/format_type.c +++ b/src/backend/utils/adt/format_type.c @@ -136,7 +136,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags) else elog(ERROR, "cache lookup failed for type %u", type_oid); } - typeform = (Form_pg_type) GETSTRUCT(tuple); + typeform = GETSTRUCT(pg_type, tuple); /* * Check if it's a "true" array type. Pseudo-array types such as "name" @@ -161,7 +161,7 @@ format_type_extended(Oid type_oid, int32 typemod, bits16 flags) else elog(ERROR, "cache lookup failed for type %u", type_oid); } - typeform = (Form_pg_type) GETSTRUCT(tuple); + typeform = GETSTRUCT(pg_type, tuple); type_oid = array_base_type; is_array = true; } diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 9819e1a45c..8e70d97c9b 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -2997,7 +2997,7 @@ prepare_column_cache(ColumnIOData *column, if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typid); - type = (Form_pg_type) GETSTRUCT(tup); + type = GETSTRUCT(pg_type, tup); if (type->typtype == TYPTYPE_DOMAIN) { diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c index 65a57fc3c4..3884c19aef 100644 --- a/src/backend/utils/adt/like_support.c +++ b/src/backend/utils/adt/like_support.c @@ -608,7 +608,7 @@ patternsel_common(PlannerInfo *root, { Form_pg_statistic stats; - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); nullfrac = stats->stanullfrac; } diff --git a/src/backend/utils/adt/multirangetypes_selfuncs.c b/src/backend/utils/adt/multirangetypes_selfuncs.c index 919c8889d4..8d2a0977e5 100644 --- a/src/backend/utils/adt/multirangetypes_selfuncs.c +++ b/src/backend/utils/adt/multirangetypes_selfuncs.c @@ -306,7 +306,7 @@ calc_multirangesel(TypeCacheEntry *typcache, VariableStatData *vardata, Form_pg_statistic stats; AttStatsSlot sslot; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); null_frac = stats->stanullfrac; /* Try to get fraction of empty multiranges */ diff --git a/src/backend/utils/adt/network_selfuncs.c b/src/backend/utils/adt/network_selfuncs.c index 49196376a8..33b45e4d99 100644 --- a/src/backend/utils/adt/network_selfuncs.c +++ b/src/backend/utils/adt/network_selfuncs.c @@ -127,7 +127,7 @@ networksel(PG_FUNCTION_ARGS) PG_RETURN_FLOAT8(DEFAULT_SEL(operator)); } - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); nullfrac = stats->stanullfrac; /* @@ -283,7 +283,7 @@ networkjoinsel_inner(Oid operator, if (HeapTupleIsValid(vardata1->statsTuple)) { - stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata1->statsTuple); nullfrac1 = stats->stanullfrac; mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple, @@ -305,7 +305,7 @@ networkjoinsel_inner(Oid operator, if (HeapTupleIsValid(vardata2->statsTuple)) { - stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata2->statsTuple); nullfrac2 = stats->stanullfrac; mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple, @@ -413,7 +413,7 @@ networkjoinsel_semi(Oid operator, if (HeapTupleIsValid(vardata1->statsTuple)) { - stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata1->statsTuple); nullfrac1 = stats->stanullfrac; mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple, @@ -435,7 +435,7 @@ networkjoinsel_semi(Oid operator, if (HeapTupleIsValid(vardata2->statsTuple)) { - stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata2->statsTuple); nullfrac2 = stats->stanullfrac; mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple, diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 607a4b7340..ec15a5a81a 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1243,7 +1243,7 @@ lookup_collation_cache(Oid collation, bool set_flags) tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for collation %u", collation); - collform = (Form_pg_collation) GETSTRUCT(tp); + collform = GETSTRUCT(pg_collation, tp); if (collform->collprovider == COLLPROVIDER_LIBC) { @@ -1495,7 +1495,7 @@ pg_newlocale_from_collation(Oid collid) tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for collation %u", collid); - collform = (Form_pg_collation) GETSTRUCT(tp); + collform = GETSTRUCT(pg_collation, tp); /* We'll fill in the result struct locally before allocating memory */ memset(&result, 0, sizeof(result)); diff --git a/src/backend/utils/adt/rangetypes_selfuncs.c b/src/backend/utils/adt/rangetypes_selfuncs.c index c2795f4593..70bdbbdf6c 100644 --- a/src/backend/utils/adt/rangetypes_selfuncs.c +++ b/src/backend/utils/adt/rangetypes_selfuncs.c @@ -244,7 +244,7 @@ calc_rangesel(TypeCacheEntry *typcache, VariableStatData *vardata, Form_pg_statistic stats; AttStatsSlot sslot; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); null_frac = stats->stanullfrac; /* Try to get fraction of empty ranges */ diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 6d4c1c27a5..052374dd23 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -155,7 +155,7 @@ regprocout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(proctup)) { - Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup); + Form_pg_proc procform = GETSTRUCT(pg_proc, proctup); char *proname = NameStr(procform->proname); /* @@ -356,7 +356,7 @@ format_procedure_extended(Oid procedure_oid, bits16 flags) if (HeapTupleIsValid(proctup)) { - Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup); + Form_pg_proc procform = GETSTRUCT(pg_proc, proctup); char *proname = NameStr(procform->proname); int nargs = procform->pronargs; int i; @@ -436,7 +436,7 @@ format_procedure_parts(Oid procedure_oid, List **objnames, List **objargs, return; } - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); nargs = procform->pronargs; *objnames = list_make2(get_namespace_name_or_temp(procform->pronamespace), @@ -593,7 +593,7 @@ regoperout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(opertup)) { - Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup); + Form_pg_operator operform = GETSTRUCT(pg_operator, opertup); char *oprname = NameStr(operform->oprname); /* @@ -787,7 +787,7 @@ format_operator_extended(Oid operator_oid, bits16 flags) if (HeapTupleIsValid(opertup)) { - Form_pg_operator operform = (Form_pg_operator) GETSTRUCT(opertup); + Form_pg_operator operform = GETSTRUCT(pg_operator, opertup); char *oprname = NameStr(operform->oprname); char *nspname; StringInfoData buf; @@ -877,7 +877,7 @@ format_operator_parts(Oid operator_oid, List **objnames, List **objargs, return; } - oprForm = (Form_pg_operator) GETSTRUCT(opertup); + oprForm = GETSTRUCT(pg_operator, opertup); *objnames = list_make2(get_namespace_name_or_temp(oprForm->oprnamespace), pstrdup(NameStr(oprForm->oprname))); *objargs = NIL; @@ -1023,7 +1023,7 @@ regclassout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(classtup)) { - Form_pg_class classform = (Form_pg_class) GETSTRUCT(classtup); + Form_pg_class classform = GETSTRUCT(pg_class, classtup); char *classname = NameStr(classform->relname); /* @@ -1174,7 +1174,7 @@ regcollationout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(collationtup)) { - Form_pg_collation collationform = (Form_pg_collation) GETSTRUCT(collationtup); + Form_pg_collation collationform = GETSTRUCT(pg_collation, collationtup); char *collationname = NameStr(collationform->collname); /* @@ -1326,7 +1326,7 @@ regtypeout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(typetup)) { - Form_pg_type typeform = (Form_pg_type) GETSTRUCT(typetup); + Form_pg_type typeform = GETSTRUCT(pg_type, typetup); /* * In bootstrap mode, skip the fancy namespace stuff and just return @@ -1439,7 +1439,7 @@ regconfigout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(cfgtup)) { - Form_pg_ts_config cfgform = (Form_pg_ts_config) GETSTRUCT(cfgtup); + Form_pg_ts_config cfgform = GETSTRUCT(pg_ts_config, cfgtup); char *cfgname = NameStr(cfgform->cfgname); char *nspname; @@ -1550,7 +1550,7 @@ regdictionaryout(PG_FUNCTION_ARGS) if (HeapTupleIsValid(dicttup)) { - Form_pg_ts_dict dictform = (Form_pg_ts_dict) GETSTRUCT(dicttup); + Form_pg_ts_dict dictform = GETSTRUCT(pg_ts_dict, dicttup); char *dictname = NameStr(dictform->dictname); char *nspname; diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 51b3fdc9a0..33e9cfa567 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -1945,7 +1945,7 @@ ri_GenerateQualCollation(StringInfo buf, Oid collation) tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for collation %u", collation); - colltup = (Form_pg_collation) GETSTRUCT(tp); + colltup = GETSTRUCT(pg_collation, tp); collname = NameStr(colltup->collname); /* @@ -2134,7 +2134,7 @@ ri_LoadConstraintInfo(Oid constraintOid) tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintOid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for constraint %u", constraintOid); - conForm = (Form_pg_constraint) GETSTRUCT(tup); + conForm = GETSTRUCT(pg_constraint, tup); if (conForm->contype != CONSTRAINT_FOREIGN) /* should not happen */ elog(ERROR, "constraint %u is not a foreign key constraint", @@ -2197,7 +2197,7 @@ get_ri_constraint_root(Oid constrOid) tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for constraint %u", constrOid); - constrParentOid = ((Form_pg_constraint) GETSTRUCT(tuple))->conparentid; + constrParentOid = (GETSTRUCT(pg_constraint, tuple))->conparentid; ReleaseSysCache(tuple); if (!OidIsValid(constrParentOid)) break; /* we reached the root constraint */ diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 26cf4fa9a0..f1b31fc4e7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -898,7 +898,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) return NULL; } - trigrec = (Form_pg_trigger) GETSTRUCT(ht_trig); + trigrec = GETSTRUCT(pg_trigger, ht_trig); /* * Start the trigger definition. Note that the trigger's name should never @@ -1253,7 +1253,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, return NULL; elog(ERROR, "cache lookup failed for index %u", indexrelid); } - idxrec = (Form_pg_index) GETSTRUCT(ht_idx); + idxrec = GETSTRUCT(pg_index, ht_idx); indrelid = idxrec->indrelid; Assert(indexrelid == idxrec->indexrelid); @@ -1280,7 +1280,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexrelid)); if (!HeapTupleIsValid(ht_idxrel)) elog(ERROR, "cache lookup failed for relation %u", indexrelid); - idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel); + idxrelrec = GETSTRUCT(pg_class, ht_idxrel); /* * Fetch the pg_am tuple of the index' access method @@ -1289,7 +1289,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, if (!HeapTupleIsValid(ht_am)) elog(ERROR, "cache lookup failed for access method %u", idxrelrec->relam); - amrec = (Form_pg_am) GETSTRUCT(ht_am); + amrec = GETSTRUCT(pg_am, ht_am); /* Fetch the index AM's API struct */ amroutine = GetIndexAmRoutine(amrec->amhandler); @@ -1637,7 +1637,7 @@ pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok) /* has the statistics expressions? */ has_exprs = !heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL); - statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup); + statextrec = GETSTRUCT(pg_statistic_ext, statexttup); /* * Get the statistics expressions, if any. (NOTE: we do not use the @@ -1821,7 +1821,7 @@ pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - statextrec = (Form_pg_statistic_ext) GETSTRUCT(statexttup); + statextrec = GETSTRUCT(pg_statistic_ext, statexttup); /* * Get the statistics expressions, and deparse them into text values. @@ -1919,7 +1919,7 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags, elog(ERROR, "cache lookup failed for partition key of %u", relid); } - form = (Form_pg_partitioned_table) GETSTRUCT(tuple); + form = GETSTRUCT(pg_partitioned_table, tuple); Assert(form->partrelid == relid); @@ -2197,7 +2197,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, elog(ERROR, "could not find tuple for constraint %u", constraintId); } - conForm = (Form_pg_constraint) GETSTRUCT(tup); + conForm = GETSTRUCT(pg_constraint, tup); initStringInfo(&buf); @@ -2371,7 +2371,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, if (!HeapTupleIsValid(indtup)) elog(ERROR, "cache lookup failed for index %u", indexId); if (conForm->contype == CONSTRAINT_UNIQUE && - ((Form_pg_index) GETSTRUCT(indtup))->indnullsnotdistinct) + (GETSTRUCT(pg_index, indtup))->indnullsnotdistinct) appendStringInfoString(&buf, "NULLS NOT DISTINCT "); appendStringInfoString(&buf, "("); @@ -2769,7 +2769,7 @@ pg_get_userbyid(PG_FUNCTION_ARGS) roletup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(roletup)) { - role_rec = (Form_pg_authid) GETSTRUCT(roletup); + role_rec = GETSTRUCT(pg_authid, roletup); *result = role_rec->rolname; ReleaseSysCache(roletup); } @@ -2837,7 +2837,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS) while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend deprec = GETSTRUCT(pg_depend, tup); /* * Look for an auto dependency (serial column) or internal dependency @@ -2905,7 +2905,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS) if (!HeapTupleIsValid(proctup)) PG_RETURN_NULL(); - proc = (Form_pg_proc) GETSTRUCT(proctup); + proc = GETSTRUCT(pg_proc, proctup); name = NameStr(proc->proname); if (proc->prokind == PROKIND_AGGREGATE) @@ -3197,7 +3197,7 @@ pg_get_function_result(PG_FUNCTION_ARGS) if (!HeapTupleIsValid(proctup)) PG_RETURN_NULL(); - if (((Form_pg_proc) GETSTRUCT(proctup))->prokind == PROKIND_PROCEDURE) + if ((GETSTRUCT(pg_proc, proctup))->prokind == PROKIND_PROCEDURE) { ReleaseSysCache(proctup); PG_RETURN_NULL(); @@ -3219,7 +3219,7 @@ pg_get_function_result(PG_FUNCTION_ARGS) static void print_function_rettype(StringInfo buf, HeapTuple proctup) { - Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup); + Form_pg_proc proc = GETSTRUCT(pg_proc, proctup); int ntabargs = 0; StringInfoData rbuf; @@ -3258,7 +3258,7 @@ static int print_function_arguments(StringInfo buf, HeapTuple proctup, bool print_table_args, bool print_defaults) { - Form_pg_proc proc = (Form_pg_proc) GETSTRUCT(proctup); + Form_pg_proc proc = GETSTRUCT(pg_proc, proctup); int numargs; Oid *argtypes; char **argnames; @@ -3306,7 +3306,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup, if (!HeapTupleIsValid(aggtup)) elog(ERROR, "cache lookup failed for aggregate %u", proc->oid); - agg = (Form_pg_aggregate) GETSTRUCT(aggtup); + agg = GETSTRUCT(pg_aggregate, aggtup); if (AGGKIND_IS_ORDERED_SET(agg->aggkind)) insertorderbyat = agg->aggnumdirectargs; ReleaseSysCache(aggtup); @@ -3491,7 +3491,7 @@ pg_get_function_arg_default(PG_FUNCTION_ARGS) argdefaults = castNode(List, stringToNode(str)); pfree(str); - proc = (Form_pg_proc) GETSTRUCT(proctup); + proc = GETSTRUCT(pg_proc, proctup); /* * Calculate index into proargdefaults: proargdefaults corresponds to the @@ -3524,7 +3524,7 @@ print_function_sqlbody(StringInfo buf, HeapTuple proctup) bool isnull; Node *n; - dpns.funcname = pstrdup(NameStr(((Form_pg_proc) GETSTRUCT(proctup))->proname)); + dpns.funcname = pstrdup(NameStr((GETSTRUCT(pg_proc, proctup))->proname)); numargs = get_func_arg_info(proctup, &argtypes, &argnames, &argmodes); dpns.numargs = numargs; @@ -12029,7 +12029,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype, ht_opc = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(ht_opc)) elog(ERROR, "cache lookup failed for opclass %u", opclass); - opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc); + opcrec = GETSTRUCT(pg_opclass, ht_opc); if (!OidIsValid(actual_datatype) || GetDefaultOpClass(actual_datatype, opcrec->opcmethod) != opclass) @@ -12323,7 +12323,7 @@ generate_relation_name(Oid relid, List *namespaces) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for relation %u", relid); - reltup = (Form_pg_class) GETSTRUCT(tp); + reltup = GETSTRUCT(pg_class, tp); relname = NameStr(reltup->relname); /* Check for conflicting CTE name */ @@ -12381,7 +12381,7 @@ generate_qualified_relation_name(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for relation %u", relid); - reltup = (Form_pg_class) GETSTRUCT(tp); + reltup = GETSTRUCT(pg_class, tp); relname = NameStr(reltup->relname); nspname = get_namespace_name_or_temp(reltup->relnamespace); @@ -12434,7 +12434,7 @@ generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(proctup); + procform = GETSTRUCT(pg_proc, proctup); proname = NameStr(procform->proname); /* @@ -12531,7 +12531,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2) opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operid)); if (!HeapTupleIsValid(opertup)) elog(ERROR, "cache lookup failed for operator %u", operid); - operform = (Form_pg_operator) GETSTRUCT(opertup); + operform = GETSTRUCT(pg_operator, opertup); oprname = NameStr(operform->oprname); /* @@ -12607,7 +12607,7 @@ generate_operator_clause(StringInfo buf, opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opoid)); if (!HeapTupleIsValid(opertup)) elog(ERROR, "cache lookup failed for operator %u", opoid); - operform = (Form_pg_operator) GETSTRUCT(opertup); + operform = GETSTRUCT(pg_operator, opertup); Assert(operform->oprkind == 'b'); oprname = NameStr(operform->oprname); @@ -12644,7 +12644,7 @@ add_cast_to(StringInfo buf, Oid typid) typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup failed for type %u", typid); - typform = (Form_pg_type) GETSTRUCT(typetup); + typform = GETSTRUCT(pg_type, typetup); typname = NameStr(typform->typname); nspname = get_namespace_name_or_temp(typform->typnamespace); @@ -12676,7 +12676,7 @@ generate_qualified_type_name(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for type %u", typid); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); typname = NameStr(typtup->typname); nspname = get_namespace_name_or_temp(typtup->typnamespace); @@ -12709,7 +12709,7 @@ generate_collation_name(Oid collid) tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for collation %u", collid); - colltup = (Form_pg_collation) GETSTRUCT(tp); + colltup = GETSTRUCT(pg_collation, tp); collname = NameStr(colltup->collname); if (!CollationIsVisible(collid)) diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index fa1f589fad..81eb913317 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -313,7 +313,7 @@ var_eq_const(VariableStatData *vardata, Oid operator, Oid collation, { Form_pg_statistic stats; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); nullfrac = stats->stanullfrac; } @@ -475,7 +475,7 @@ var_eq_non_const(VariableStatData *vardata, Oid operator, Oid collation, { Form_pg_statistic stats; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); nullfrac = stats->stanullfrac; } @@ -665,7 +665,7 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq, /* no stats available, so default result */ return DEFAULT_INEQ_SEL; } - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); fmgr_info(get_opcode(operator), &opproc); @@ -990,7 +990,7 @@ generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation, /* Don't forget to account for nulls. */ if (HeapTupleIsValid(vardata.statsTuple)) - nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata.statsTuple))->stanullfrac; + nullfrac = (GETSTRUCT(pg_statistic, vardata.statsTuple))->stanullfrac; else nullfrac = 0.0; @@ -1548,7 +1548,7 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, double freq_null; AttStatsSlot sslot; - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); freq_null = stats->stanullfrac; if (get_attstatsslot(&sslot, vardata.statsTuple, @@ -1705,7 +1705,7 @@ nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg, Form_pg_statistic stats; double freq_null; - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); freq_null = stats->stanullfrac; switch (nulltesttype) @@ -2277,7 +2277,7 @@ eqjoinsel(PG_FUNCTION_ARGS) if (HeapTupleIsValid(vardata1.statsTuple)) { /* note we allow use of nullfrac regardless of security check */ - stats1 = (Form_pg_statistic) GETSTRUCT(vardata1.statsTuple); + stats1 = GETSTRUCT(pg_statistic, vardata1.statsTuple); if (statistic_proc_security_check(&vardata1, opfuncoid)) have_mcvs1 = get_attstatsslot(&sslot1, vardata1.statsTuple, STATISTIC_KIND_MCV, InvalidOid, @@ -2287,7 +2287,7 @@ eqjoinsel(PG_FUNCTION_ARGS) if (HeapTupleIsValid(vardata2.statsTuple)) { /* note we allow use of nullfrac regardless of security check */ - stats2 = (Form_pg_statistic) GETSTRUCT(vardata2.statsTuple); + stats2 = GETSTRUCT(pg_statistic, vardata2.statsTuple); if (statistic_proc_security_check(&vardata2, opfuncoid)) have_mcvs2 = get_attstatsslot(&sslot2, vardata2.statsTuple, STATISTIC_KIND_MCV, InvalidOid, @@ -2804,7 +2804,7 @@ neqjoinsel(PG_FUNCTION_ARGS) get_join_variables(root, args, sjinfo, &leftvar, &rightvar, &reversed); statsTuple = reversed ? rightvar.statsTuple : leftvar.statsTuple; if (HeapTupleIsValid(statsTuple)) - nullfrac = ((Form_pg_statistic) GETSTRUCT(statsTuple))->stanullfrac; + nullfrac = (GETSTRUCT(pg_statistic, statsTuple))->stanullfrac; else nullfrac = 0.0; ReleaseVariableStats(leftvar); @@ -3162,7 +3162,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause, if (HeapTupleIsValid(leftvar.statsTuple)) { - stats = (Form_pg_statistic) GETSTRUCT(leftvar.statsTuple); + stats = GETSTRUCT(pg_statistic, leftvar.statsTuple); *leftstart += stats->stanullfrac; CLAMP_PROBABILITY(*leftstart); *leftend += stats->stanullfrac; @@ -3170,7 +3170,7 @@ mergejoinscansel(PlannerInfo *root, Node *clause, } if (HeapTupleIsValid(rightvar.statsTuple)) { - stats = (Form_pg_statistic) GETSTRUCT(rightvar.statsTuple); + stats = GETSTRUCT(pg_statistic, rightvar.statsTuple); *rightstart += stats->stanullfrac; CLAMP_PROBABILITY(*rightstart); *rightend += stats->stanullfrac; @@ -3830,7 +3830,7 @@ estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets, { Form_pg_statistic stats; - stats = (Form_pg_statistic) GETSTRUCT(vardata.statsTuple); + stats = GETSTRUCT(pg_statistic, vardata.statsTuple); stanullfrac = stats->stanullfrac; } else @@ -5672,7 +5672,7 @@ get_variable_numdistinct(VariableStatData *vardata, bool *isdefault) /* Use the pg_statistic entry */ Form_pg_statistic stats; - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); + stats = GETSTRUCT(pg_statistic, vardata->statsTuple); stadistinct = stats->stadistinct; stanullfrac = stats->stanullfrac; } @@ -5889,7 +5889,7 @@ get_variable_range(PlannerInfo *root, VariableStatData *vardata, for (i = 0; i < sslot.nnumbers; i++) sumcommon += sslot.numbers[i]; - nullfrac = ((Form_pg_statistic) GETSTRUCT(vardata->statsTuple))->stanullfrac; + nullfrac = (GETSTRUCT(pg_statistic, vardata->statsTuple))->stanullfrac; if (sumcommon + nullfrac > 0.99999) use_mcvs = true; } diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 60a85c4697..0ce9012784 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -3183,7 +3183,7 @@ map_sql_table_to_xmlschema(TupleDesc tupdesc, Oid relid, bool nulls, tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", relid); - reltuple = (Form_pg_class) GETSTRUCT(tuple); + reltuple = GETSTRUCT(pg_class, tuple); xmltn = map_sql_identifier_to_xml_name(NameStr(reltuple->relname), true, false); @@ -3483,7 +3483,7 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod) tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for type %u", typeoid); - typtuple = (Form_pg_type) GETSTRUCT(tuple); + typtuple = GETSTRUCT(pg_type, tuple); appendStringInfoString(&result, map_multipart_sql_identifier_to_xml_name((typtuple->typtype == TYPTYPE_DOMAIN) ? "Domain" : "UDT", diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c index f7f7165f7f..a6893f9947 100644 --- a/src/backend/utils/cache/evtcache.c +++ b/src/backend/utils/cache/evtcache.c @@ -153,7 +153,7 @@ BuildEventTriggerCache(void) break; /* Skip trigger if disabled. */ - form = (Form_pg_event_trigger) GETSTRUCT(tup); + form = GETSTRUCT(pg_event_trigger, tup); if (form->evtenabled == TRIGGER_DISABLED) continue; diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index eb5782f82a..8e100862bf 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -1259,7 +1259,7 @@ CacheInvalidateHeapTuple(Relation relation, */ if (tupleRelId == RelationRelationId) { - Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple); + Form_pg_class classtup = GETSTRUCT(pg_class, tuple); relationId = classtup->oid; if (classtup->relisshared) @@ -1269,7 +1269,7 @@ CacheInvalidateHeapTuple(Relation relation, } else if (tupleRelId == AttributeRelationId) { - Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple); + Form_pg_attribute atttup = GETSTRUCT(pg_attribute, tuple); relationId = atttup->attrelid; @@ -1287,7 +1287,7 @@ CacheInvalidateHeapTuple(Relation relation, } else if (tupleRelId == IndexRelationId) { - Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple); + Form_pg_index indextup = GETSTRUCT(pg_index, tuple); /* * When a pg_index row is updated, we should send out a relcache inval @@ -1300,7 +1300,7 @@ CacheInvalidateHeapTuple(Relation relation, } else if (tupleRelId == ConstraintRelationId) { - Form_pg_constraint constrtup = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint constrtup = GETSTRUCT(pg_constraint, tuple); /* * Foreign keys are part of relcache entries, too, so send out an @@ -1398,7 +1398,7 @@ CacheInvalidateRelcacheAll(void) void CacheInvalidateRelcacheByTuple(HeapTuple classTuple) { - Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple); + Form_pg_class classtup = GETSTRUCT(pg_class, classTuple); Oid databaseId; Oid relationId; diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 1b7e11b93e..e189e5e564 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -90,7 +90,7 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily) ObjectIdGetDatum(opfamily)); if (!HeapTupleIsValid(tp)) return 0; - amop_tup = (Form_pg_amop) GETSTRUCT(tp); + amop_tup = GETSTRUCT(pg_amop, tp); result = amop_tup->amopstrategy; ReleaseSysCache(tp); return result; @@ -115,7 +115,7 @@ get_op_opfamily_sortfamily(Oid opno, Oid opfamily) ObjectIdGetDatum(opfamily)); if (!HeapTupleIsValid(tp)) return InvalidOid; - amop_tup = (Form_pg_amop) GETSTRUCT(tp); + amop_tup = GETSTRUCT(pg_amop, tp); result = amop_tup->amopsortfamily; ReleaseSysCache(tp); return result; @@ -146,7 +146,7 @@ get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, if (!HeapTupleIsValid(tp)) elog(ERROR, "operator %u is not a member of opfamily %u", opno, opfamily); - amop_tup = (Form_pg_amop) GETSTRUCT(tp); + amop_tup = GETSTRUCT(pg_amop, tp); *strategy = amop_tup->amopstrategy; *lefttype = amop_tup->amoplefttype; *righttype = amop_tup->amoprighttype; @@ -175,7 +175,7 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, Int16GetDatum(strategy)); if (!HeapTupleIsValid(tp)) return InvalidOid; - amop_tup = (Form_pg_amop) GETSTRUCT(tp); + amop_tup = GETSTRUCT(pg_amop, tp); result = amop_tup->amopopr; ReleaseSysCache(tp); return result; @@ -223,7 +223,7 @@ get_ordering_op_properties(Oid opno, for (i = 0; i < catlist->n_members; i++) { HeapTuple tuple = &catlist->members[i]->tuple; - Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple); + Form_pg_amop aform = GETSTRUCT(pg_amop, tuple); /* must be btree */ if (aform->amopmethod != BTREE_AM_OID) @@ -315,7 +315,7 @@ get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type) for (i = 0; i < catlist->n_members; i++) { HeapTuple tuple = &catlist->members[i]->tuple; - Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple); + Form_pg_amop aform = GETSTRUCT(pg_amop, tuple); /* must be btree */ if (aform->amopmethod != BTREE_AM_OID) @@ -376,7 +376,7 @@ get_mergejoin_opfamilies(Oid opno) for (i = 0; i < catlist->n_members; i++) { HeapTuple tuple = &catlist->members[i]->tuple; - Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple); + Form_pg_amop aform = GETSTRUCT(pg_amop, tuple); /* must be btree equality */ if (aform->amopmethod == BTREE_AM_OID && @@ -428,7 +428,7 @@ get_compatible_hash_operators(Oid opno, for (i = 0; i < catlist->n_members; i++) { HeapTuple tuple = &catlist->members[i]->tuple; - Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple); + Form_pg_amop aform = GETSTRUCT(pg_amop, tuple); if (aform->amopmethod == HASH_AM_OID && aform->amopstrategy == HTEqualStrategyNumber) @@ -528,7 +528,7 @@ get_op_hash_functions(Oid opno, for (i = 0; i < catlist->n_members; i++) { HeapTuple tuple = &catlist->members[i]->tuple; - Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple); + Form_pg_amop aform = GETSTRUCT(pg_amop, tuple); if (aform->amopmethod == HASH_AM_OID && aform->amopstrategy == HTEqualStrategyNumber) @@ -611,7 +611,7 @@ get_op_btree_interpretation(Oid opno) for (i = 0; i < catlist->n_members; i++) { HeapTuple op_tuple = &catlist->members[i]->tuple; - Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple); + Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple); StrategyNumber op_strategy; /* must be btree */ @@ -649,7 +649,7 @@ get_op_btree_interpretation(Oid opno) for (i = 0; i < catlist->n_members; i++) { HeapTuple op_tuple = &catlist->members[i]->tuple; - Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple); + Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple); StrategyNumber op_strategy; /* must be btree */ @@ -712,7 +712,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2) for (i = 0; i < catlist->n_members; i++) { HeapTuple op_tuple = &catlist->members[i]->tuple; - Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple); + Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple); /* must be btree or hash */ if (op_form->amopmethod == BTREE_AM_OID || @@ -763,7 +763,7 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2) for (i = 0; i < catlist->n_members; i++) { HeapTuple op_tuple = &catlist->members[i]->tuple; - Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple); + Form_pg_amop op_form = GETSTRUCT(pg_amop, op_tuple); if (op_form->amopmethod == BTREE_AM_OID) { @@ -804,7 +804,7 @@ get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum) Int16GetDatum(procnum)); if (!HeapTupleIsValid(tp)) return InvalidOid; - amproc_tup = (Form_pg_amproc) GETSTRUCT(tp); + amproc_tup = GETSTRUCT(pg_amproc, tp); result = amproc_tup->amproc; ReleaseSysCache(tp); return result; @@ -830,7 +830,7 @@ get_attname(Oid relid, AttrNumber attnum, bool missing_ok) ObjectIdGetDatum(relid), Int16GetDatum(attnum)); if (HeapTupleIsValid(tp)) { - Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp); + Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp); char *result; result = pstrdup(NameStr(att_tup->attname)); @@ -860,7 +860,7 @@ get_attnum(Oid relid, const char *attname) tp = SearchSysCacheAttName(relid, attname); if (HeapTupleIsValid(tp)) { - Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp); + Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp); AttrNumber result; result = att_tup->attnum; @@ -892,7 +892,7 @@ get_attstattarget(Oid relid, AttrNumber attnum) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relid); - att_tup = (Form_pg_attribute) GETSTRUCT(tp); + att_tup = GETSTRUCT(pg_attribute, tp); result = att_tup->attstattarget; ReleaseSysCache(tp); return result; @@ -922,7 +922,7 @@ get_attgenerated(Oid relid, AttrNumber attnum) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relid); - att_tup = (Form_pg_attribute) GETSTRUCT(tp); + att_tup = GETSTRUCT(pg_attribute, tp); result = att_tup->attgenerated; ReleaseSysCache(tp); return result; @@ -944,7 +944,7 @@ get_atttype(Oid relid, AttrNumber attnum) Int16GetDatum(attnum)); if (HeapTupleIsValid(tp)) { - Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp); + Form_pg_attribute att_tup = GETSTRUCT(pg_attribute, tp); Oid result; result = att_tup->atttypid; @@ -977,7 +977,7 @@ get_atttypetypmodcoll(Oid relid, AttrNumber attnum, if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for attribute %d of relation %u", attnum, relid); - att_tup = (Form_pg_attribute) GETSTRUCT(tp); + att_tup = GETSTRUCT(pg_attribute, tp); *typid = att_tup->atttypid; *typmod = att_tup->atttypmod; @@ -1064,7 +1064,7 @@ get_collation_name(Oid colloid) tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid)); if (HeapTupleIsValid(tp)) { - Form_pg_collation colltup = (Form_pg_collation) GETSTRUCT(tp); + Form_pg_collation colltup = GETSTRUCT(pg_collation, tp); char *result; result = pstrdup(NameStr(colltup->collname)); @@ -1085,7 +1085,7 @@ get_collation_isdeterministic(Oid colloid) tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for collation %u", colloid); - colltup = (Form_pg_collation) GETSTRUCT(tp); + colltup = GETSTRUCT(pg_collation, tp); result = colltup->collisdeterministic; ReleaseSysCache(tp); return result; @@ -1110,7 +1110,7 @@ get_constraint_name(Oid conoid) tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid)); if (HeapTupleIsValid(tp)) { - Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp); + Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp); char *result; result = pstrdup(NameStr(contup->conname)); @@ -1142,7 +1142,7 @@ get_constraint_index(Oid conoid) tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid)); if (HeapTupleIsValid(tp)) { - Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp); + Form_pg_constraint contup = GETSTRUCT(pg_constraint, tp); Oid result; if (contup->contype == CONSTRAINT_UNIQUE || @@ -1168,7 +1168,7 @@ get_language_name(Oid langoid, bool missing_ok) tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid)); if (HeapTupleIsValid(tp)) { - Form_pg_language lantup = (Form_pg_language) GETSTRUCT(tp); + Form_pg_language lantup = GETSTRUCT(pg_language, tp); char *result; result = pstrdup(NameStr(lantup->lanname)); @@ -1199,7 +1199,7 @@ get_opclass_family(Oid opclass) tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for opclass %u", opclass); - cla_tup = (Form_pg_opclass) GETSTRUCT(tp); + cla_tup = GETSTRUCT(pg_opclass, tp); result = cla_tup->opcfamily; ReleaseSysCache(tp); @@ -1221,7 +1221,7 @@ get_opclass_input_type(Oid opclass) tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for opclass %u", opclass); - cla_tup = (Form_pg_opclass) GETSTRUCT(tp); + cla_tup = GETSTRUCT(pg_opclass, tp); result = cla_tup->opcintype; ReleaseSysCache(tp); @@ -1244,7 +1244,7 @@ get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype) if (!HeapTupleIsValid(tp)) return false; - cla_tup = (Form_pg_opclass) GETSTRUCT(tp); + cla_tup = GETSTRUCT(pg_opclass, tp); *opfamily = cla_tup->opcfamily; *opcintype = cla_tup->opcintype; @@ -1270,7 +1270,7 @@ get_opcode(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); RegProcedure result; result = optup->oprcode; @@ -1295,7 +1295,7 @@ get_opname(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); char *result; result = pstrdup(NameStr(optup->oprname)); @@ -1318,7 +1318,7 @@ get_op_rettype(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); Oid result; result = optup->oprresult; @@ -1344,7 +1344,7 @@ op_input_types(Oid opno, Oid *lefttype, Oid *righttype) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (!HeapTupleIsValid(tp)) /* shouldn't happen */ elog(ERROR, "cache lookup failed for operator %u", opno); - optup = (Form_pg_operator) GETSTRUCT(tp); + optup = GETSTRUCT(pg_operator, tp); *lefttype = optup->oprleft; *righttype = optup->oprright; ReleaseSysCache(tp); @@ -1394,7 +1394,7 @@ op_mergejoinable(Oid opno, Oid inputtype) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); result = optup->oprcanmerge; ReleaseSysCache(tp); @@ -1440,7 +1440,7 @@ op_hashjoinable(Oid opno, Oid inputtype) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); result = optup->oprcanhash; ReleaseSysCache(tp); @@ -1494,7 +1494,7 @@ get_commutator(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); Oid result; result = optup->oprcom; @@ -1518,7 +1518,7 @@ get_negator(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); Oid result; result = optup->oprnegate; @@ -1542,7 +1542,7 @@ get_oprrest(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); RegProcedure result; result = optup->oprrest; @@ -1566,7 +1566,7 @@ get_oprjoin(Oid opno) tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { - Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); + Form_pg_operator optup = GETSTRUCT(pg_operator, tp); RegProcedure result; result = optup->oprjoin; @@ -1593,7 +1593,7 @@ get_func_name(Oid funcid) tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (HeapTupleIsValid(tp)) { - Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp); + Form_pg_proc functup = GETSTRUCT(pg_proc, tp); char *result; result = pstrdup(NameStr(functup->proname)); @@ -1617,7 +1617,7 @@ get_func_namespace(Oid funcid) tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (HeapTupleIsValid(tp)) { - Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp); + Form_pg_proc functup = GETSTRUCT(pg_proc, tp); Oid result; result = functup->pronamespace; @@ -1642,7 +1642,7 @@ get_func_rettype(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype; + result = (GETSTRUCT(pg_proc, tp))->prorettype; ReleaseSysCache(tp); return result; } @@ -1661,7 +1661,7 @@ get_func_nargs(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs; + result = (GETSTRUCT(pg_proc, tp))->pronargs; ReleaseSysCache(tp); return result; } @@ -1684,7 +1684,7 @@ get_func_signature(Oid funcid, Oid **argtypes, int *nargs) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - procstruct = (Form_pg_proc) GETSTRUCT(tp); + procstruct = GETSTRUCT(pg_proc, tp); result = procstruct->prorettype; *nargs = (int) procstruct->pronargs; @@ -1710,7 +1710,7 @@ get_func_variadictype(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic; + result = (GETSTRUCT(pg_proc, tp))->provariadic; ReleaseSysCache(tp); return result; } @@ -1729,7 +1729,7 @@ get_func_retset(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->proretset; + result = (GETSTRUCT(pg_proc, tp))->proretset; ReleaseSysCache(tp); return result; } @@ -1748,7 +1748,7 @@ func_strict(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict; + result = (GETSTRUCT(pg_proc, tp))->proisstrict; ReleaseSysCache(tp); return result; } @@ -1767,7 +1767,7 @@ func_volatile(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile; + result = (GETSTRUCT(pg_proc, tp))->provolatile; ReleaseSysCache(tp); return result; } @@ -1786,7 +1786,7 @@ func_parallel(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel; + result = (GETSTRUCT(pg_proc, tp))->proparallel; ReleaseSysCache(tp); return result; } @@ -1805,7 +1805,7 @@ get_func_prokind(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->prokind; + result = (GETSTRUCT(pg_proc, tp))->prokind; ReleaseSysCache(tp); return result; } @@ -1824,7 +1824,7 @@ get_func_leakproof(Oid funcid) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof; + result = (GETSTRUCT(pg_proc, tp))->proleakproof; ReleaseSysCache(tp); return result; } @@ -1843,7 +1843,7 @@ get_func_support(Oid funcid) tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (HeapTupleIsValid(tp)) { - Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp); + Form_pg_proc functup = GETSTRUCT(pg_proc, tp); RegProcedure result; result = functup->prosupport; @@ -1884,7 +1884,7 @@ get_relnatts(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); int result; result = reltup->relnatts; @@ -1913,7 +1913,7 @@ get_rel_name(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); char *result; result = pstrdup(NameStr(reltup->relname)); @@ -1937,7 +1937,7 @@ get_rel_namespace(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); Oid result; result = reltup->relnamespace; @@ -1964,7 +1964,7 @@ get_rel_type_id(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); Oid result; result = reltup->reltype; @@ -1988,7 +1988,7 @@ get_rel_relkind(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); char result; result = reltup->relkind; @@ -2012,7 +2012,7 @@ get_rel_relispartition(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); bool result; result = reltup->relispartition; @@ -2039,7 +2039,7 @@ get_rel_tablespace(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { - Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); + Form_pg_class reltup = GETSTRUCT(pg_class, tp); Oid result; result = reltup->reltablespace; @@ -2065,7 +2065,7 @@ get_rel_persistence(Oid relid) tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for relation %u", relid); - reltup = (Form_pg_class) GETSTRUCT(tp); + reltup = GETSTRUCT(pg_class, tp); result = reltup->relpersistence; ReleaseSysCache(tp); @@ -2088,7 +2088,7 @@ get_transform_fromsql(Oid typid, Oid langid, List *trftypes) { Oid funcid; - funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql; + funcid = (GETSTRUCT(pg_transform, tup))->trffromsql; ReleaseSysCache(tup); return funcid; } @@ -2109,7 +2109,7 @@ get_transform_tosql(Oid typid, Oid langid, List *trftypes) { Oid funcid; - funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql; + funcid = (GETSTRUCT(pg_transform, tup))->trftosql; ReleaseSysCache(tup); return funcid; } @@ -2134,7 +2134,7 @@ get_typisdefined(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); bool result; result = typtup->typisdefined; @@ -2158,7 +2158,7 @@ get_typlen(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); int16 result; result = typtup->typlen; @@ -2183,7 +2183,7 @@ get_typbyval(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); bool result; result = typtup->typbyval; @@ -2213,7 +2213,7 @@ get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for type %u", typid); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); *typlen = typtup->typlen; *typbyval = typtup->typbyval; ReleaseSysCache(tp); @@ -2234,7 +2234,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for type %u", typid); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); *typlen = typtup->typlen; *typbyval = typtup->typbyval; *typalign = typtup->typalign; @@ -2259,7 +2259,7 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, Oid getTypeIOParam(HeapTuple typeTuple) { - Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple); + Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTuple); /* * Array types get their typelem as parameter; everybody else gets their @@ -2326,7 +2326,7 @@ get_type_io_data(Oid typid, typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", typid); - typeStruct = (Form_pg_type) GETSTRUCT(typeTuple); + typeStruct = GETSTRUCT(pg_type, typeTuple); *typlen = typeStruct->typlen; *typbyval = typeStruct->typbyval; @@ -2360,7 +2360,7 @@ get_typalign(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); char result; result = typtup->typalign; @@ -2380,7 +2380,7 @@ get_typstorage(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); char result; result = typtup->typstorage; @@ -2413,7 +2413,7 @@ get_typdefault(Oid typid) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", typid); - type = (Form_pg_type) GETSTRUCT(typeTuple); + type = GETSTRUCT(pg_type, typeTuple); /* * typdefault and typdefaultbin are potentially null, so don't try to @@ -2505,7 +2505,7 @@ getBaseTypeAndTypmod(Oid typid, int32 *typmod) tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); if (typTup->typtype != TYPTYPE_DOMAIN) { /* Not a domain, so done */ @@ -2590,7 +2590,7 @@ get_typtype(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); char result; result = typtup->typtype; @@ -2672,7 +2672,7 @@ get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for type %u", typid); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); *typcategory = typtup->typcategory; *typispreferred = typtup->typispreferred; ReleaseSysCache(tp); @@ -2692,7 +2692,7 @@ get_typ_typrelid(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); Oid result; result = typtup->typrelid; @@ -2720,7 +2720,7 @@ get_element_type(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); Oid result; if (IsTrueArrayType(typtup)) @@ -2749,7 +2749,7 @@ get_array_type(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - result = ((Form_pg_type) GETSTRUCT(tp))->typarray; + result = (GETSTRUCT(pg_type, tp))->typarray; ReleaseSysCache(tp); } return result; @@ -2799,7 +2799,7 @@ get_base_element_type(Oid typid) tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (!HeapTupleIsValid(tup)) break; - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); if (typTup->typtype != TYPTYPE_DOMAIN) { /* Not a domain, so stop descending */ @@ -2836,7 +2836,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", type); - pt = (Form_pg_type) GETSTRUCT(typeTuple); + pt = GETSTRUCT(pg_type, typeTuple); if (!pt->typisdefined) ereport(ERROR, @@ -2869,7 +2869,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", type); - pt = (Form_pg_type) GETSTRUCT(typeTuple); + pt = GETSTRUCT(pg_type, typeTuple); if (!pt->typisdefined) ereport(ERROR, @@ -2902,7 +2902,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", type); - pt = (Form_pg_type) GETSTRUCT(typeTuple); + pt = GETSTRUCT(pg_type, typeTuple); if (!pt->typisdefined) ereport(ERROR, @@ -2935,7 +2935,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena) typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", type); - pt = (Form_pg_type) GETSTRUCT(typeTuple); + pt = GETSTRUCT(pg_type, typeTuple); if (!pt->typisdefined) ereport(ERROR, @@ -2967,7 +2967,7 @@ get_typmodin(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); Oid result; result = typtup->typmodin; @@ -2992,7 +2992,7 @@ get_typmodout(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); Oid result; result = typtup->typmodout; @@ -3017,7 +3017,7 @@ get_typcollation(Oid typid) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typtup = GETSTRUCT(pg_type, tp); Oid result; result = typtup->typcollation; @@ -3058,7 +3058,7 @@ get_typsubscript(Oid typid, Oid *typelemp) tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { - Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp); + Form_pg_type typform = GETSTRUCT(pg_type, tp); RegProcedure handler = typform->typsubscript; if (typelemp) @@ -3129,7 +3129,7 @@ get_attavgwidth(Oid relid, AttrNumber attnum) BoolGetDatum(false)); if (HeapTupleIsValid(tp)) { - stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth; + stawidth = (GETSTRUCT(pg_statistic, tp))->stawidth; ReleaseSysCache(tp); if (stawidth > 0) return stawidth; @@ -3187,7 +3187,7 @@ bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags) { - Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple); + Form_pg_statistic stats = GETSTRUCT(pg_statistic, statstuple); int i; Datum val; bool isnull; @@ -3236,7 +3236,7 @@ get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype)); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "cache lookup failed for type %u", arrayelemtype); - typeForm = (Form_pg_type) GETSTRUCT(typeTuple); + typeForm = GETSTRUCT(pg_type, typeTuple); /* Deconstruct array into Datum elements; NULLs not expected */ deconstruct_array(statarray, @@ -3330,7 +3330,7 @@ get_namespace_name(Oid nspid) tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid)); if (HeapTupleIsValid(tp)) { - Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp); + Form_pg_namespace nsptup = GETSTRUCT(pg_namespace, tp); char *result; result = pstrdup(NameStr(nsptup->nspname)); @@ -3371,7 +3371,7 @@ get_range_subtype(Oid rangeOid) tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid)); if (HeapTupleIsValid(tp)) { - Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp); + Form_pg_range rngtup = GETSTRUCT(pg_range, tp); Oid result; result = rngtup->rngsubtype; @@ -3397,7 +3397,7 @@ get_range_collation(Oid rangeOid) tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid)); if (HeapTupleIsValid(tp)) { - Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp); + Form_pg_range rngtup = GETSTRUCT(pg_range, tp); Oid result; result = rngtup->rngcollation; @@ -3422,7 +3422,7 @@ get_range_multirange(Oid rangeOid) tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid)); if (HeapTupleIsValid(tp)) { - Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp); + Form_pg_range rngtup = GETSTRUCT(pg_range, tp); Oid result; result = rngtup->rngmultitypid; @@ -3447,7 +3447,7 @@ get_multirange_range(Oid multirangeOid) tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid)); if (HeapTupleIsValid(tp)) { - Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp); + Form_pg_range rngtup = GETSTRUCT(pg_range, tp); Oid result; result = rngtup->rngtypid; @@ -3484,7 +3484,7 @@ get_index_column_opclass(Oid index_oid, int attno) if (!HeapTupleIsValid(tuple)) return InvalidOid; - rd_index = (Form_pg_index) GETSTRUCT(tuple); + rd_index = GETSTRUCT(pg_index, tuple); /* caller is supposed to guarantee this */ Assert(attno > 0 && attno <= rd_index->indnatts); @@ -3526,7 +3526,7 @@ get_index_isreplident(Oid index_oid) if (!HeapTupleIsValid(tuple)) return false; - rd_index = (Form_pg_index) GETSTRUCT(tuple); + rd_index = GETSTRUCT(pg_index, tuple); result = rd_index->indisreplident; ReleaseSysCache(tuple); @@ -3549,7 +3549,7 @@ get_index_isvalid(Oid index_oid) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for index %u", index_oid); - rd_index = (Form_pg_index) GETSTRUCT(tuple); + rd_index = GETSTRUCT(pg_index, tuple); isvalid = rd_index->indisvalid; ReleaseSysCache(tuple); @@ -3572,7 +3572,7 @@ get_index_isclustered(Oid index_oid) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for index %u", index_oid); - rd_index = (Form_pg_index) GETSTRUCT(tuple); + rd_index = GETSTRUCT(pg_index, tuple); isclustered = rd_index->indisclustered; ReleaseSysCache(tuple); diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c index afa99c5d03..4f8c7c5bde 100644 --- a/src/backend/utils/cache/partcache.c +++ b/src/backend/utils/cache/partcache.c @@ -111,7 +111,7 @@ RelationBuildPartitionKey(Relation relation) sizeof(PartitionKeyData)); /* Fixed-length attributes */ - form = (Form_pg_partitioned_table) GETSTRUCT(tuple); + form = GETSTRUCT(pg_partitioned_table, tuple); key->strategy = form->partstrat; key->partnatts = form->partnatts; @@ -200,7 +200,7 @@ RelationBuildPartitionKey(Relation relation) if (!HeapTupleIsValid(opclasstup)) elog(ERROR, "cache lookup failed for opclass %u", opclass->values[i]); - opclassform = (Form_pg_opclass) GETSTRUCT(opclasstup); + opclassform = GETSTRUCT(pg_opclass, opclasstup); key->partopfamily[i] = opclassform->opcfamily; key->partopcintype[i] = opclassform->opcintype; diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index bdb771d278..7187de3a4c 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -572,7 +572,7 @@ RelationBuildTupleDesc(Relation relation) Form_pg_attribute attp; int attnum; - attp = (Form_pg_attribute) GETSTRUCT(pg_attribute_tuple); + attp = GETSTRUCT(pg_attribute, pg_attribute_tuple); attnum = attp->attnum; if (attnum <= 0 || attnum > RelationGetNumberOfAttributes(relation)) @@ -785,7 +785,7 @@ RelationBuildRuleLock(Relation relation) while (HeapTupleIsValid(rewrite_tuple = systable_getnext(rewrite_scan))) { - Form_pg_rewrite rewrite_form = (Form_pg_rewrite) GETSTRUCT(rewrite_tuple); + Form_pg_rewrite rewrite_form = GETSTRUCT(pg_rewrite, rewrite_tuple); bool isnull; Datum rule_datum; char *rule_str; @@ -1111,7 +1111,7 @@ retry: /* * get information from the pg_class_tuple */ - relp = (Form_pg_class) GETSTRUCT(pg_class_tuple); + relp = GETSTRUCT(pg_class, pg_class_tuple); relid = relp->oid; Assert(relid == targetRelId); @@ -1349,7 +1349,7 @@ RelationInitPhysicalAddr(Relation relation) if (!HeapTupleIsValid(phys_tuple)) elog(ERROR, "could not find pg_class entry for %u", RelationGetRelid(relation)); - physrel = (Form_pg_class) GETSTRUCT(phys_tuple); + physrel = GETSTRUCT(pg_class, phys_tuple); relation->rd_rel->reltablespace = physrel->reltablespace; relation->rd_rel->relfilenode = physrel->relfilenode; @@ -1442,7 +1442,7 @@ RelationInitIndexAccessInfo(Relation relation) RelationGetRelid(relation)); oldcontext = MemoryContextSwitchTo(CacheMemoryContext); relation->rd_indextuple = heap_copytuple(tuple); - relation->rd_index = (Form_pg_index) GETSTRUCT(relation->rd_indextuple); + relation->rd_index = GETSTRUCT(pg_index, relation->rd_indextuple); MemoryContextSwitchTo(oldcontext); ReleaseSysCache(tuple); @@ -1454,7 +1454,7 @@ RelationInitIndexAccessInfo(Relation relation) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for access method %u", relation->rd_rel->relam); - aform = (Form_pg_am) GETSTRUCT(tuple); + aform = GETSTRUCT(pg_am, tuple); relation->rd_amhandler = aform->amhandler; ReleaseSysCache(tuple); @@ -1728,7 +1728,7 @@ LookupOpclassInfo(Oid operatorClassOid, if (HeapTupleIsValid(htup = systable_getnext(scan))) { - Form_pg_opclass opclassform = (Form_pg_opclass) GETSTRUCT(htup); + Form_pg_opclass opclassform = GETSTRUCT(pg_opclass, htup); opcentry->opcfamily = opclassform->opcfamily; opcentry->opcintype = opclassform->opcintype; @@ -1763,7 +1763,7 @@ LookupOpclassInfo(Oid operatorClassOid, while (HeapTupleIsValid(htup = systable_getnext(scan))) { - Form_pg_amproc amprocform = (Form_pg_amproc) GETSTRUCT(htup); + Form_pg_amproc amprocform = GETSTRUCT(pg_amproc, htup); if (amprocform->amprocnum <= 0 || (StrategyNumber) amprocform->amprocnum > numSupport) @@ -1832,7 +1832,7 @@ RelationInitTableAccessMethod(Relation relation) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for access method %u", relation->rd_rel->relam); - aform = (Form_pg_am) GETSTRUCT(tuple); + aform = GETSTRUCT(pg_am, tuple); relation->rd_amhandler = aform->amhandler; ReleaseSysCache(tuple); } @@ -2257,7 +2257,7 @@ RelationReloadIndexInfo(Relation relation) if (!HeapTupleIsValid(pg_class_tuple)) elog(ERROR, "could not find pg_class tuple for index %u", RelationGetRelid(relation)); - relp = (Form_pg_class) GETSTRUCT(pg_class_tuple); + relp = GETSTRUCT(pg_class, pg_class_tuple); memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE); /* Reload reloptions in case they changed */ if (relation->rd_options) @@ -2286,7 +2286,7 @@ RelationReloadIndexInfo(Relation relation) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for index %u", RelationGetRelid(relation)); - index = (Form_pg_index) GETSTRUCT(tuple); + index = GETSTRUCT(pg_index, tuple); /* * Basically, let's just copy all the bool fields. There are one or @@ -2378,7 +2378,7 @@ RelationReloadNailed(Relation relation) pg_class_tuple = ScanPgRelation(RelationGetRelid(relation), true, false); - relp = (Form_pg_class) GETSTRUCT(pg_class_tuple); + relp = GETSTRUCT(pg_class, pg_class_tuple); memcpy(relation->rd_rel, relp, CLASS_TUPLE_SIZE); heap_freetuple(pg_class_tuple); @@ -3721,7 +3721,7 @@ RelationSetNewRelfilenumber(Relation relation, char persistence) if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for relation %u", RelationGetRelid(relation)); - classform = (Form_pg_class) GETSTRUCT(tuple); + classform = GETSTRUCT(pg_class, tuple); /* * Schedule unlinking of the old storage at transaction commit. @@ -4137,7 +4137,7 @@ RelationCacheInitializePhase3(void) if (!HeapTupleIsValid(htup)) elog(FATAL, "cache lookup failed for relation %u", RelationGetRelid(relation)); - relp = (Form_pg_class) GETSTRUCT(htup); + relp = GETSTRUCT(pg_class, htup); /* * Copy tuple to relation->rd_rel. (See notes in @@ -4382,7 +4382,7 @@ AttrDefaultFetch(Relation relation, int ndef) while (HeapTupleIsValid(htup = systable_getnext(adscan))) { - Form_pg_attrdef adform = (Form_pg_attrdef) GETSTRUCT(htup); + Form_pg_attrdef adform = GETSTRUCT(pg_attrdef, htup); Datum val; bool isnull; @@ -4478,7 +4478,7 @@ CheckConstraintFetch(Relation relation) while (HeapTupleIsValid(htup = systable_getnext(conscan))) { - Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup); + Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup); Datum val; bool isnull; @@ -4602,7 +4602,7 @@ RelationGetFKeyList(Relation relation) while (HeapTupleIsValid(htup = systable_getnext(conscan))) { - Form_pg_constraint constraint = (Form_pg_constraint) GETSTRUCT(htup); + Form_pg_constraint constraint = GETSTRUCT(pg_constraint, htup); ForeignKeyCacheInfo *info; /* consider only foreign keys */ @@ -4709,7 +4709,7 @@ RelationGetIndexList(Relation relation) while (HeapTupleIsValid(htup = systable_getnext(indscan))) { - Form_pg_index index = (Form_pg_index) GETSTRUCT(htup); + Form_pg_index index = GETSTRUCT(pg_index, htup); /* * Ignore any indexes that are currently being dropped. This will @@ -4828,7 +4828,7 @@ RelationGetStatExtList(Relation relation) while (HeapTupleIsValid(htup = systable_getnext(indscan))) { - Oid oid = ((Form_pg_statistic_ext) GETSTRUCT(htup))->oid; + Oid oid = (GETSTRUCT(pg_statistic_ext, htup))->oid; result = lappend_oid(result, oid); } @@ -5474,7 +5474,7 @@ RelationGetExclusionInfo(Relation indexRelation, while (HeapTupleIsValid(htup = systable_getnext(conscan))) { - Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup); + Form_pg_constraint conform = GETSTRUCT(pg_constraint, htup); Datum val; bool isnull; ArrayType *arr; @@ -5621,7 +5621,7 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for publication %u", pubid); - pubform = (Form_pg_publication) GETSTRUCT(tup); + pubform = GETSTRUCT(pg_publication, tup); pubdesc->pubactions.pubinsert |= pubform->pubinsert; pubdesc->pubactions.pubupdate |= pubform->pubupdate; @@ -6088,7 +6088,7 @@ load_relcache_init_file(bool shared) /* Fix up internal pointers in the tuple -- see heap_copytuple */ rel->rd_indextuple->t_data = (HeapTupleHeader) ((char *) rel->rd_indextuple + HEAPTUPLESIZE); - rel->rd_index = (Form_pg_index) GETSTRUCT(rel->rd_indextuple); + rel->rd_index = GETSTRUCT(pg_index, rel->rd_indextuple); /* * prepare index info context --- parameters should match diff --git a/src/backend/utils/cache/relfilenumbermap.c b/src/backend/utils/cache/relfilenumbermap.c index c4245d5ccd..7570f5e095 100644 --- a/src/backend/utils/cache/relfilenumbermap.c +++ b/src/backend/utils/cache/relfilenumbermap.c @@ -209,7 +209,7 @@ RelidByRelfilenumber(Oid reltablespace, RelFileNumber relfilenumber) while (HeapTupleIsValid(ntp = systable_getnext(scandesc))) { - Form_pg_class classform = (Form_pg_class) GETSTRUCT(ntp); + Form_pg_class classform = GETSTRUCT(pg_class, ntp); if (found) elog(ERROR, diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 1912b12146..a8c320ef91 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -1320,7 +1320,7 @@ SearchSysCacheAttName(Oid relid, const char *attname) CStringGetDatum(attname)); if (!HeapTupleIsValid(tuple)) return NULL; - if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped) + if ((GETSTRUCT(pg_attribute, tuple))->attisdropped) { ReleaseSysCache(tuple); return NULL; @@ -1383,7 +1383,7 @@ SearchSysCacheAttNum(Oid relid, int16 attnum) Int16GetDatum(attnum)); if (!HeapTupleIsValid(tuple)) return NULL; - if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped) + if ((GETSTRUCT(pg_attribute, tuple))->attisdropped) { ReleaseSysCache(tuple); return NULL; diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c index 24808dfbb1..e1d0dad795 100644 --- a/src/backend/utils/cache/ts_cache.c +++ b/src/backend/utils/cache/ts_cache.c @@ -152,7 +152,7 @@ lookup_ts_parser_cache(Oid prsId) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for text search parser %u", prsId); - prs = (Form_pg_ts_parser) GETSTRUCT(tp); + prs = GETSTRUCT(pg_ts_parser, tp); /* * Sanity checks @@ -254,7 +254,7 @@ lookup_ts_dictionary_cache(Oid dictId) if (!HeapTupleIsValid(tpdict)) elog(ERROR, "cache lookup failed for text search dictionary %u", dictId); - dict = (Form_pg_ts_dict) GETSTRUCT(tpdict); + dict = GETSTRUCT(pg_ts_dict, tpdict); /* * Sanity checks @@ -270,7 +270,7 @@ lookup_ts_dictionary_cache(Oid dictId) if (!HeapTupleIsValid(tptmpl)) elog(ERROR, "cache lookup failed for text search template %u", dict->dicttemplate); - template = (Form_pg_ts_template) GETSTRUCT(tptmpl); + template = GETSTRUCT(pg_ts_template, tptmpl); /* * Sanity checks @@ -424,7 +424,7 @@ lookup_ts_config_cache(Oid cfgId) if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for text search configuration %u", cfgId); - cfg = (Form_pg_ts_config) GETSTRUCT(tp); + cfg = GETSTRUCT(pg_ts_config, tp); /* * Sanity checks @@ -484,7 +484,7 @@ lookup_ts_config_cache(Oid cfgId) while ((maptup = systable_getnext_ordered(mapscan, ForwardScanDirection)) != NULL) { - Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup); + Form_pg_ts_config_map cfgmap = GETSTRUCT(pg_ts_config_map, maptup); int toktype = cfgmap->maptokentype; if (toktype <= 0 || toktype > MAXTOKENTYPE) @@ -625,7 +625,7 @@ check_TSCurrentConfig(char **newval, void **extra, GucSource source) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for text search configuration %u", cfgId); - cfg = (Form_pg_ts_config) GETSTRUCT(tuple); + cfg = GETSTRUCT(pg_ts_config, tuple); buf = quote_qualified_identifier(get_namespace_name(cfg->cfgnamespace), NameStr(cfg->cfgname)); diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index 808f9ebd0d..6b55c4a4e1 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -383,7 +383,7 @@ lookup_type_cache(Oid type_id, int flags) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type with OID %u does not exist", type_id))); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); if (!typtup->typisdefined) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), @@ -438,7 +438,7 @@ lookup_type_cache(Oid type_id, int flags) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("type with OID %u does not exist", type_id))); - typtup = (Form_pg_type) GETSTRUCT(tp); + typtup = GETSTRUCT(pg_type, tp); if (!typtup->typisdefined) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), @@ -922,7 +922,7 @@ load_rangetype_info(TypeCacheEntry *typentry) if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for range type %u", typentry->type_id); - pg_range = (Form_pg_range) GETSTRUCT(tup); + pg_range = GETSTRUCT(pg_range, tup); subtypeOid = pg_range->rngsubtype; typentry->rng_collation = pg_range->rngcollation; @@ -1032,7 +1032,7 @@ load_domaintype_info(TypeCacheEntry *typentry) tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for type %u", typeOid); - typTup = (Form_pg_type) GETSTRUCT(tup); + typTup = GETSTRUCT(pg_type, tup); if (typTup->typtype != TYPTYPE_DOMAIN) { @@ -1056,7 +1056,7 @@ load_domaintype_info(TypeCacheEntry *typentry) while (HeapTupleIsValid(conTup = systable_getnext(scan))) { - Form_pg_constraint c = (Form_pg_constraint) GETSTRUCT(conTup); + Form_pg_constraint c = GETSTRUCT(pg_constraint, conTup); Datum val; bool isNull; char *constring; @@ -2592,7 +2592,7 @@ load_enum_cache_data(TypeCacheEntry *tcache) while (HeapTupleIsValid(enum_tuple = systable_getnext(enum_scan))) { - Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enum_tuple); + Form_pg_enum en = GETSTRUCT(pg_enum, enum_tuple); if (numitems >= maxitems) { diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index a9dd068095..125a175a11 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -181,7 +181,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId)); if (!HeapTupleIsValid(procedureTuple)) elog(ERROR, "cache lookup failed for function %u", functionId); - procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); + procedureStruct = GETSTRUCT(pg_proc, procedureTuple); finfo->fn_nargs = procedureStruct->pronargs; finfo->fn_strict = procedureStruct->proisstrict; @@ -291,7 +291,7 @@ fmgr_symbol(Oid functionId, char **mod, char **fn) procedureTuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId)); if (!HeapTupleIsValid(procedureTuple)) elog(ERROR, "cache lookup failed for function %u", functionId); - procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); + procedureStruct = GETSTRUCT(pg_proc, procedureTuple); if (procedureStruct->prosecdef || !heap_attisnull(procedureTuple, Anum_pg_proc_proconfig, NULL) || @@ -431,7 +431,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple) static void fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple) { - Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); + Form_pg_proc procedureStruct = GETSTRUCT(pg_proc, procedureTuple); Oid language = procedureStruct->prolang; HeapTuple languageTuple; Form_pg_language languageStruct; @@ -440,7 +440,7 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple) languageTuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(language)); if (!HeapTupleIsValid(languageTuple)) elog(ERROR, "cache lookup failed for language %u", language); - languageStruct = (Form_pg_language) GETSTRUCT(languageTuple); + languageStruct = GETSTRUCT(pg_language, languageTuple); /* * Look up the language's call handler function, ignoring any attributes @@ -528,7 +528,7 @@ fetch_finfo_record(void *filehandle, const char *funcname) static CFuncHashTabEntry * lookup_C_func(HeapTuple procedureTuple) { - Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid; + Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid; CFuncHashTabEntry *entry; if (CFuncHash == NULL) @@ -553,7 +553,7 @@ static void record_C_func(HeapTuple procedureTuple, PGFunction user_fn, const Pg_finfo_record *inforec) { - Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid; + Oid fn_oid = (GETSTRUCT(pg_proc, procedureTuple))->oid; CFuncHashTabEntry *entry; bool found; @@ -671,7 +671,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS) if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", fcinfo->flinfo->fn_oid); - procedureStruct = (Form_pg_proc) GETSTRUCT(tuple); + procedureStruct = GETSTRUCT(pg_proc, tuple); if (procedureStruct->prosecdef) fcache->userid = procedureStruct->proowner; @@ -2035,7 +2035,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function with OID %u does not exist", functionOid))); - procStruct = (Form_pg_proc) GETSTRUCT(procTup); + procStruct = GETSTRUCT(pg_proc, procTup); /* * Fetch pg_language entry to know if this is the correct validation @@ -2044,7 +2044,7 @@ CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid) langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(procStruct->prolang)); if (!HeapTupleIsValid(langTup)) elog(ERROR, "cache lookup failed for language %u", procStruct->prolang); - langStruct = (Form_pg_language) GETSTRUCT(langTup); + langStruct = GETSTRUCT(pg_language, langTup); if (langStruct->lanvalidator != validatorOid) ereport(ERROR, diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index a1fe50ffca..213121461d 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -403,7 +403,7 @@ internal_get_result_type(Oid funcid, tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); - procform = (Form_pg_proc) GETSTRUCT(tp); + procform = GETSTRUCT(pg_proc, tp); rettype = procform->prorettype; @@ -1337,7 +1337,7 @@ int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes) { - Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup); + Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup); Datum proallargtypes; Datum proargmodes; Datum proargnames; @@ -1667,7 +1667,7 @@ get_func_result_name(Oid functionId) TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple) { - Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(procTuple); + Form_pg_proc procform = GETSTRUCT(pg_proc, procTuple); Datum proallargtypes; Datum proargmodes; Datum proargnames; diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index eb43b2c5e5..df10da08b9 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -683,7 +683,7 @@ has_rolreplication(Oid roleid) utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(utup)) { - result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication; + result = (GETSTRUCT(pg_authid, utup))->rolreplication; ReleaseSysCache(utup); } return result; @@ -732,7 +732,7 @@ InitializeSessionUserId(const char *rolename, Oid roleid) errmsg("role with OID %u does not exist", roleid))); } - rform = (Form_pg_authid) GETSTRUCT(roleTup); + rform = GETSTRUCT(pg_authid, roleTup); roleid = rform->oid; rname = NameStr(rform->rolname); @@ -925,7 +925,7 @@ GetUserNameFromId(Oid roleid, bool noerr) } else { - result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname)); + result = pstrdup(NameStr((GETSTRUCT(pg_authid, tuple))->rolname)); ReleaseSysCache(tuple); } return result; diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index a5c208a20a..3ddd0d3c66 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -321,7 +321,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId)); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for database %u", MyDatabaseId); - dbform = (Form_pg_database) GETSTRUCT(tup); + dbform = GETSTRUCT(pg_database, tup); /* This recheck is strictly paranoia */ if (strcmp(name, NameStr(dbform->datname)) != 0) @@ -921,7 +921,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, ereport(FATAL, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", in_dbname))); - dbform = (Form_pg_database) GETSTRUCT(tuple); + dbform = GETSTRUCT(pg_database, tuple); MyDatabaseId = dbform->oid; MyDatabaseTableSpace = dbform->dattablespace; /* take database name from the caller, just for paranoia */ @@ -938,7 +938,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, ereport(FATAL, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database %u does not exist", dboid))); - dbform = (Form_pg_database) GETSTRUCT(tuple); + dbform = GETSTRUCT(pg_database, tuple); MyDatabaseId = dbform->oid; MyDatabaseTableSpace = dbform->dattablespace; Assert(MyDatabaseId == dboid); @@ -1021,8 +1021,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, tuple = GetDatabaseTuple(dbname); if (!HeapTupleIsValid(tuple) || - MyDatabaseId != ((Form_pg_database) GETSTRUCT(tuple))->oid || - MyDatabaseTableSpace != ((Form_pg_database) GETSTRUCT(tuple))->dattablespace) + MyDatabaseId != (GETSTRUCT(pg_database, tuple))->oid || + MyDatabaseTableSpace != (GETSTRUCT(pg_database, tuple))->dattablespace) ereport(FATAL, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", dbname), diff --git a/src/backend/utils/misc/rls.c b/src/backend/utils/misc/rls.c index d15880670f..73fd21d843 100644 --- a/src/backend/utils/misc/rls.c +++ b/src/backend/utils/misc/rls.c @@ -66,7 +66,7 @@ check_enable_rls(Oid relid, Oid checkAsUser, bool noError) tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) return RLS_NONE; - classform = (Form_pg_class) GETSTRUCT(tuple); + classform = GETSTRUCT(pg_class, tuple); relrowsecurity = classform->relrowsecurity; relforcerowsecurity = classform->relforcerowsecurity; diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index d20e7af797..1902f49d0a 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -70,7 +70,7 @@ superuser_arg(Oid roleid) rtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid)); if (HeapTupleIsValid(rtup)) { - result = ((Form_pg_authid) GETSTRUCT(rtup))->rolsuper; + result = (GETSTRUCT(pg_authid, rtup))->rolsuper; ReleaseSysCache(rtup); } else diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h index 51a60eda08..7310e3b2b8 100644 --- a/src/include/access/htup_details.h +++ b/src/include/access/htup_details.h @@ -651,7 +651,7 @@ struct MinimalTupleData /* * GETSTRUCT - given a HeapTuple pointer, return address of the user data */ -#define GETSTRUCT(TUP) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff) +#define GETSTRUCT(CAT, TUP) ((Form_##CAT) ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)) /* * Accessor macros to be used with HeapTuple pointers. diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index edb93ec1c4..1aa8227afb 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -1994,7 +1994,7 @@ plperl_validator(PG_FUNCTION_ARGS) tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", funcoid); - proc = (Form_pg_proc) GETSTRUCT(tuple); + proc = GETSTRUCT(pg_proc, tuple); functyptype = get_typtype(proc->prorettype); @@ -2717,7 +2717,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger) procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid)); if (!HeapTupleIsValid(procTup)) elog(ERROR, "cache lookup failed for function %u", fn_oid); - procStruct = (Form_pg_proc) GETSTRUCT(procTup); + procStruct = GETSTRUCT(pg_proc, procTup); /* * Try to find function in plperl_proc_hash. The reason for this @@ -2818,7 +2818,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger) if (!HeapTupleIsValid(langTup)) elog(ERROR, "cache lookup failed for language %u", procStruct->prolang); - langStruct = (Form_pg_language) GETSTRUCT(langTup); + langStruct = GETSTRUCT(pg_language, langTup); prodesc->lang_oid = langStruct->oid; prodesc->lanpltrusted = langStruct->lanpltrusted; ReleaseSysCache(langTup); @@ -2834,7 +2834,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger) typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype)); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", rettype); - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = GETSTRUCT(pg_type, typeTup); /* Disallow pseudotype result, except VOID or RECORD */ if (typeStruct->typtype == TYPTYPE_PSEUDO) @@ -2883,7 +2883,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger) typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype)); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", argtype); - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = GETSTRUCT(pg_type, typeTup); /* Disallow pseudotype argument, except RECORD */ if (typeStruct->typtype == TYPTYPE_PSEUDO && diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 61fbdf0686..41eca1990a 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -149,7 +149,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator) procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid)); if (!HeapTupleIsValid(procTup)) elog(ERROR, "cache lookup failed for function %u", funcOid); - procStruct = (Form_pg_proc) GETSTRUCT(procTup); + procStruct = GETSTRUCT(pg_proc, procTup); /* * See if there's already a cache entry for the current FmgrInfo. If not, @@ -267,7 +267,7 @@ do_compile(FunctionCallInfo fcinfo, PLpgSQL_func_hashkey *hashkey, bool forValidator) { - Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup); + Form_pg_proc procStruct = GETSTRUCT(pg_proc, procTup); bool is_dml_trigger = CALLED_AS_TRIGGER(fcinfo); bool is_event_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo); Datum prosrcdatum; @@ -545,7 +545,7 @@ do_compile(FunctionCallInfo fcinfo, typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettypeid)); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", rettypeid); - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = GETSTRUCT(pg_type, typeTup); /* Disallow pseudotype result, except VOID or RECORD */ /* (note we already replaced polymorphic types) */ @@ -1643,7 +1643,7 @@ plpgsql_parse_wordtype(char *ident) typeTup = LookupTypeName(NULL, typeName, NULL, false); if (typeTup) { - Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup); if (!typeStruct->typisdefined || typeStruct->typrelid != InvalidOid) @@ -1735,7 +1735,7 @@ plpgsql_parse_cwordtype(List *idents) classtup = SearchSysCache1(RELOID, ObjectIdGetDatum(classOid)); if (!HeapTupleIsValid(classtup)) goto done; - classStruct = (Form_pg_class) GETSTRUCT(classtup); + classStruct = GETSTRUCT(pg_class, classtup); /* * It must be a relation, sequence, view, materialized view, composite @@ -1756,7 +1756,7 @@ plpgsql_parse_cwordtype(List *idents) attrtup = SearchSysCacheAttName(classOid, fldname); if (!HeapTupleIsValid(attrtup)) goto done; - attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); + attrStruct = GETSTRUCT(pg_attribute, attrtup); typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(attrStruct->atttypid)); @@ -2107,7 +2107,7 @@ static PLpgSQL_type * build_datatype(HeapTuple typeTup, int32 typmod, Oid collation, TypeName *origtypname) { - Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + Form_pg_type typeStruct = GETSTRUCT(pg_type, typeTup); PLpgSQL_type *typ; if (!typeStruct->typisdefined) diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index 190d286f1c..632e4c351d 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -460,7 +460,7 @@ plpgsql_validator(PG_FUNCTION_ARGS) tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", funcoid); - proc = (Form_pg_proc) GETSTRUCT(tuple); + proc = GETSTRUCT(pg_proc, tuple); functyptype = get_typtype(proc->prorettype); diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c index 0bce106495..ab5fc74c1b 100644 --- a/src/pl/plpython/plpy_main.c +++ b/src/pl/plpython/plpy_main.c @@ -177,7 +177,7 @@ plpython3_validator(PG_FUNCTION_ARGS) tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for function %u", funcoid); - procStruct = (Form_pg_proc) GETSTRUCT(tuple); + procStruct = GETSTRUCT(pg_proc, tuple); is_trigger = PLy_procedure_is_trigger(procStruct); diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c index 494f109b32..2c91e6df81 100644 --- a/src/pl/plpython/plpy_procedure.c +++ b/src/pl/plpython/plpy_procedure.c @@ -140,7 +140,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger) int rv; char *ptr; - procStruct = (Form_pg_proc) GETSTRUCT(procTup); + procStruct = GETSTRUCT(pg_proc, procTup); rv = snprintf(procName, sizeof(procName), "__plpython_procedure_%s_%u", NameStr(procStruct->proname), @@ -211,7 +211,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger) rvTypeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype)); if (!HeapTupleIsValid(rvTypeTup)) elog(ERROR, "cache lookup failed for type %u", rettype); - rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup); + rvTypeStruct = GETSTRUCT(pg_type, rvTypeTup); /* Disallow pseudotype result, except for void or record */ if (rvTypeStruct->typtype == TYPTYPE_PSEUDO) @@ -298,7 +298,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger) ObjectIdGetDatum(types[i])); if (!HeapTupleIsValid(argTypeTup)) elog(ERROR, "cache lookup failed for type %u", types[i]); - argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup); + argTypeStruct = GETSTRUCT(pg_type, argTypeTup); /* disallow pseudotype arguments */ if (argTypeStruct->typtype == TYPTYPE_PSEUDO) diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 0dd6d8ab2c..0161a9bb9c 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -628,7 +628,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted) procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid)); if (!HeapTupleIsValid(procTup)) elog(ERROR, "cache lookup failed for function %u", procOid); - procStruct = (Form_pg_proc) GETSTRUCT(procTup); + procStruct = GETSTRUCT(pg_proc, procTup); /* It must be same language as the function we're currently calling */ if (procStruct->prolang != prolang) @@ -1405,7 +1405,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid)); if (!HeapTupleIsValid(procTup)) elog(ERROR, "cache lookup failed for function %u", fn_oid); - procStruct = (Form_pg_proc) GETSTRUCT(procTup); + procStruct = GETSTRUCT(pg_proc, procTup); /* * Look up function in pltcl_proc_htab; if it's not there, create an entry @@ -1527,7 +1527,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(rettype)); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", rettype); - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = GETSTRUCT(pg_type, typeTup); /* Disallow pseudotype result, except VOID and RECORD */ if (typeStruct->typtype == TYPTYPE_PSEUDO) @@ -1575,7 +1575,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid, typeTup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype)); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", argtype); - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); + typeStruct = GETSTRUCT(pg_type, typeTup); /* Disallow pseudotype argument, except RECORD */ if (typeStruct->typtype == TYPTYPE_PSEUDO && diff --git a/src/test/modules/plsample/plsample.c b/src/test/modules/plsample/plsample.c index 780db7292a..8cc3118985 100644 --- a/src/test/modules/plsample/plsample.c +++ b/src/test/modules/plsample/plsample.c @@ -122,7 +122,7 @@ plsample_func_handler(PG_FUNCTION_ARGS) * Extract and print the source text of the function. This can be used as * a base for the function validation and execution. */ - pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple); + pl_struct = GETSTRUCT(pg_proc, pl_tuple); proname = pstrdup(NameStr(pl_struct->proname)); ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull); if (isnull) @@ -157,7 +157,7 @@ plsample_func_handler(PG_FUNCTION_ARGS) if (!HeapTupleIsValid(type_tuple)) elog(ERROR, "cache lookup failed for type %u", argtype); - type_struct = (Form_pg_type) GETSTRUCT(type_tuple); + type_struct = GETSTRUCT(pg_type, type_tuple); fmgr_info_cxt(type_struct->typoutput, &(arg_out_func[i]), proc_cxt); ReleaseSysCache(type_tuple); @@ -186,7 +186,7 @@ plsample_func_handler(PG_FUNCTION_ARGS) ObjectIdGetDatum(prorettype)); if (!HeapTupleIsValid(type_tuple)) elog(ERROR, "cache lookup failed for type %u", prorettype); - pg_type_entry = (Form_pg_type) GETSTRUCT(type_tuple); + pg_type_entry = GETSTRUCT(pg_type, type_tuple); result_typioparam = getTypeIOParam(type_tuple); fmgr_info_cxt(pg_type_entry->typinput, &result_in_func, proc_cxt); @@ -239,7 +239,7 @@ plsample_trigger_handler(PG_FUNCTION_ARGS) * Extract and print the source text of the function. This can be used as * a base for the function validation and execution. */ - pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple); + pl_struct = GETSTRUCT(pg_proc, pl_tuple); proname = pstrdup(NameStr(pl_struct->proname)); ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull); if (isnull) -- 2.36.1