PostgreSQL Source Code  git master
htup_details.h File Reference
#include "access/htup.h"
#include "access/tupdesc.h"
#include "access/tupmacs.h"
#include "access/transam.h"
#include "storage/bufpage.h"
Include dependency graph for htup_details.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  HeapTupleFields
 
struct  DatumTupleFields
 
struct  HeapTupleHeaderData
 
struct  MinimalTupleData
 

Macros

#define MaxTupleAttributeNumber   1664 /* 8 * 208 */
 
#define MaxHeapAttributeNumber   1600 /* 8 * 200 */
 
#define FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK2   2
 
#define FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK   3
 
#define FIELDNO_HEAPTUPLEHEADERDATA_HOFF   4
 
#define FIELDNO_HEAPTUPLEHEADERDATA_BITS   5
 
#define SizeofHeapTupleHeader   offsetof(HeapTupleHeaderData, t_bits)
 
#define HEAP_HASNULL   0x0001 /* has null attribute(s) */
 
#define HEAP_HASVARWIDTH   0x0002 /* has variable-width attribute(s) */
 
#define HEAP_HASEXTERNAL   0x0004 /* has external stored attribute(s) */
 
#define HEAP_HASOID_OLD   0x0008 /* has an object-id field */
 
#define HEAP_XMAX_KEYSHR_LOCK   0x0010 /* xmax is a key-shared locker */
 
#define HEAP_COMBOCID   0x0020 /* t_cid is a combo cid */
 
#define HEAP_XMAX_EXCL_LOCK   0x0040 /* xmax is exclusive locker */
 
#define HEAP_XMAX_LOCK_ONLY   0x0080 /* xmax, if valid, is only a locker */
 
#define HEAP_XMAX_SHR_LOCK   (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)
 
#define HEAP_LOCK_MASK
 
#define HEAP_XMIN_COMMITTED   0x0100 /* t_xmin committed */
 
#define HEAP_XMIN_INVALID   0x0200 /* t_xmin invalid/aborted */
 
#define HEAP_XMIN_FROZEN   (HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID)
 
#define HEAP_XMAX_COMMITTED   0x0400 /* t_xmax committed */
 
#define HEAP_XMAX_INVALID   0x0800 /* t_xmax invalid/aborted */
 
#define HEAP_XMAX_IS_MULTI   0x1000 /* t_xmax is a MultiXactId */
 
#define HEAP_UPDATED   0x2000 /* this is UPDATEd version of row */
 
#define HEAP_MOVED_OFF
 
#define HEAP_MOVED_IN
 
#define HEAP_MOVED   (HEAP_MOVED_OFF | HEAP_MOVED_IN)
 
#define HEAP_XACT_MASK   0xFFF0 /* visibility-related bits */
 
#define HEAP_XMAX_IS_LOCKED_ONLY(infomask)
 
#define HEAP_LOCKED_UPGRADED(infomask)
 
#define HEAP_XMAX_IS_SHR_LOCKED(infomask)   (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_SHR_LOCK)
 
#define HEAP_XMAX_IS_EXCL_LOCKED(infomask)   (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_EXCL_LOCK)
 
#define HEAP_XMAX_IS_KEYSHR_LOCKED(infomask)   (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_KEYSHR_LOCK)
 
#define HEAP_XMAX_BITS
 
#define HEAP_NATTS_MASK   0x07FF /* 11 bits for number of attributes */
 
#define HEAP_KEYS_UPDATED
 
#define HEAP_HOT_UPDATED   0x4000 /* tuple was HOT-updated */
 
#define HEAP_ONLY_TUPLE   0x8000 /* this is heap-only tuple */
 
#define HEAP2_XACT_MASK   0xE000 /* visibility-related bits */
 
#define HEAP_TUPLE_HAS_MATCH   HEAP_ONLY_TUPLE /* tuple has a join match */
 
#define HeapTupleHeaderGetRawXmin(tup)
 
#define HeapTupleHeaderGetXmin(tup)
 
#define HeapTupleHeaderSetXmin(tup, xid)
 
#define HeapTupleHeaderXminCommitted(tup)
 
#define HeapTupleHeaderXminInvalid(tup)
 
#define HeapTupleHeaderXminFrozen(tup)
 
#define HeapTupleHeaderSetXminCommitted(tup)
 
#define HeapTupleHeaderSetXminInvalid(tup)
 
#define HeapTupleHeaderSetXminFrozen(tup)
 
#define HeapTupleHeaderGetUpdateXid(tup)
 
#define HeapTupleHeaderGetRawXmax(tup)
 
#define HeapTupleHeaderSetXmax(tup, xid)
 
#define HeapTupleHeaderGetRawCommandId(tup)
 
#define HeapTupleHeaderSetCmin(tup, cid)
 
#define HeapTupleHeaderSetCmax(tup, cid, iscombo)
 
#define HeapTupleHeaderGetXvac(tup)
 
#define HeapTupleHeaderSetXvac(tup, xid)
 
#define HeapTupleHeaderIsSpeculative(tup)
 
#define HeapTupleHeaderGetSpeculativeToken(tup)
 
#define HeapTupleHeaderSetSpeculativeToken(tup, token)
 
#define HeapTupleHeaderIndicatesMovedPartitions(tup)
 
#define HeapTupleHeaderSetMovedPartitions(tup)   ItemPointerSet(&(tup)->t_ctid, MovedPartitionsBlockNumber, MovedPartitionsOffsetNumber)
 
#define HeapTupleHeaderGetDatumLength(tup)   VARSIZE(tup)
 
#define HeapTupleHeaderSetDatumLength(tup, len)   SET_VARSIZE(tup, len)
 
#define HeapTupleHeaderGetTypeId(tup)
 
#define HeapTupleHeaderSetTypeId(tup, typeid)
 
#define HeapTupleHeaderGetTypMod(tup)
 
#define HeapTupleHeaderSetTypMod(tup, typmod)
 
#define HeapTupleHeaderIsHotUpdated(tup)
 
#define HeapTupleHeaderSetHotUpdated(tup)
 
#define HeapTupleHeaderClearHotUpdated(tup)
 
#define HeapTupleHeaderIsHeapOnly(tup)
 
#define HeapTupleHeaderSetHeapOnly(tup)
 
#define HeapTupleHeaderClearHeapOnly(tup)
 
#define HeapTupleHeaderHasMatch(tup)
 
#define HeapTupleHeaderSetMatch(tup)
 
#define HeapTupleHeaderClearMatch(tup)
 
#define HeapTupleHeaderGetNatts(tup)   ((tup)->t_infomask2 & HEAP_NATTS_MASK)
 
#define HeapTupleHeaderSetNatts(tup, natts)
 
#define HeapTupleHeaderHasExternal(tup)   (((tup)->t_infomask & HEAP_HASEXTERNAL) != 0)
 
#define BITMAPLEN(NATTS)   (((int)(NATTS) + 7) / 8)
 
#define MaxHeapTupleSize   (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)))
 
#define MinHeapTupleSize   MAXALIGN(SizeofHeapTupleHeader)
 
#define MaxHeapTuplesPerPage
 
#define MaxAttrSize   (10 * 1024 * 1024)
 
#define MINIMAL_TUPLE_OFFSET   ((offsetof(HeapTupleHeaderData, t_infomask2) - sizeof(uint32)) / MAXIMUM_ALIGNOF * MAXIMUM_ALIGNOF)
 
#define MINIMAL_TUPLE_PADDING   ((offsetof(HeapTupleHeaderData, t_infomask2) - sizeof(uint32)) % MAXIMUM_ALIGNOF)
 
#define MINIMAL_TUPLE_DATA_OFFSET   offsetof(MinimalTupleData, t_infomask2)
 
#define SizeofMinimalTupleHeader   offsetof(MinimalTupleData, t_bits)
 
#define GETSTRUCT(TUP)   ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)
 
#define HeapTupleHasNulls(tuple)   (((tuple)->t_data->t_infomask & HEAP_HASNULL) != 0)
 
#define HeapTupleNoNulls(tuple)   (!((tuple)->t_data->t_infomask & HEAP_HASNULL))
 
#define HeapTupleHasVarWidth(tuple)   (((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH) != 0)
 
#define HeapTupleAllFixed(tuple)   (!((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH))
 
#define HeapTupleHasExternal(tuple)   (((tuple)->t_data->t_infomask & HEAP_HASEXTERNAL) != 0)
 
#define HeapTupleIsHotUpdated(tuple)   HeapTupleHeaderIsHotUpdated((tuple)->t_data)
 
#define HeapTupleSetHotUpdated(tuple)   HeapTupleHeaderSetHotUpdated((tuple)->t_data)
 
#define HeapTupleClearHotUpdated(tuple)   HeapTupleHeaderClearHotUpdated((tuple)->t_data)
 
#define HeapTupleIsHeapOnly(tuple)   HeapTupleHeaderIsHeapOnly((tuple)->t_data)
 
#define HeapTupleSetHeapOnly(tuple)   HeapTupleHeaderSetHeapOnly((tuple)->t_data)
 
#define HeapTupleClearHeapOnly(tuple)   HeapTupleHeaderClearHeapOnly((tuple)->t_data)
 
#define fastgetattr(tup, attnum, tupleDesc, isnull)
 
#define heap_getattr(tup, attnum, tupleDesc, isnull)
 

Typedefs

typedef struct HeapTupleFields HeapTupleFields
 
typedef struct DatumTupleFields DatumTupleFields
 

Functions

Size heap_compute_data_size (TupleDesc tupleDesc, Datum *values, bool *isnull)
 
void heap_fill_tuple (TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
 
bool heap_attisnull (HeapTuple tup, int attnum, TupleDesc tupleDesc)
 
Datum nocachegetattr (HeapTuple tup, int attnum, TupleDesc att)
 
Datum heap_getsysattr (HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
 
Datum getmissingattr (TupleDesc tupleDesc, int attnum, bool *isnull)
 
HeapTuple heap_copytuple (HeapTuple tuple)
 
void heap_copytuple_with_tuple (HeapTuple src, HeapTuple dest)
 
Datum heap_copy_tuple_as_datum (HeapTuple tuple, TupleDesc tupleDesc)
 
HeapTuple heap_form_tuple (TupleDesc tupleDescriptor, Datum *values, bool *isnull)
 
HeapTuple heap_modify_tuple (HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
 
HeapTuple heap_modify_tuple_by_cols (HeapTuple tuple, TupleDesc tupleDesc, int nCols, int *replCols, Datum *replValues, bool *replIsnull)
 
void heap_deform_tuple (HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
 
void heap_freetuple (HeapTuple htup)
 
MinimalTuple heap_form_minimal_tuple (TupleDesc tupleDescriptor, Datum *values, bool *isnull)
 
void heap_free_minimal_tuple (MinimalTuple mtup)
 
MinimalTuple heap_copy_minimal_tuple (MinimalTuple mtup)
 
HeapTuple heap_tuple_from_minimal_tuple (MinimalTuple mtup)
 
MinimalTuple minimal_tuple_from_heap_tuple (HeapTuple htup)
 
size_t varsize_any (void *p)
 
HeapTuple heap_expand_tuple (HeapTuple sourceTuple, TupleDesc tupleDesc)
 
MinimalTuple minimal_expand_tuple (HeapTuple sourceTuple, TupleDesc tupleDesc)
 

Macro Definition Documentation

◆ BITMAPLEN

◆ fastgetattr

#define fastgetattr (   tup,
  attnum,
  tupleDesc,
  isnull 
)
Value:
( \
AssertMacro((attnum) > 0), \
(*(isnull) = false), \
HeapTupleNoNulls(tup) ? \
( \
TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ? \
( \
fetchatt(TupleDescAttr((tupleDesc), (attnum)-1), \
(char *) (tup)->t_data + (tup)->t_data->t_hoff + \
TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff)\
) \
: \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
: \
( \
att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
( \
(*(isnull) = true), \
(Datum)NULL \
) \
: \
( \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
) \
)
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
uintptr_t Datum
Definition: postgres.h:367
int16 attnum
Definition: pg_attribute.h:79
Datum nocachegetattr(HeapTuple tup, int attnum, TupleDesc att)
Definition: heaptuple.c:423

Definition at line 712 of file htup_details.h.

Referenced by AttrDefaultFetch(), CatalogCacheComputeTupleHashValue(), CheckConstraintFetch(), extractRelOptions(), heapgettup_pagemode(), load_domaintype_info(), MergeWithExistingConstraint(), pg_get_triggerdef_worker(), RelationBuildTriggers(), RelationGetExclusionInfo(), RelationInitIndexAccessInfo(), ReorderBufferToastAppendChunk(), ReorderBufferToastReplace(), toast_fetch_datum(), and toast_fetch_datum_slice().

◆ FIELDNO_HEAPTUPLEHEADERDATA_BITS

#define FIELDNO_HEAPTUPLEHEADERDATA_BITS   5

Definition at line 176 of file htup_details.h.

Referenced by slot_compile_deform().

◆ FIELDNO_HEAPTUPLEHEADERDATA_HOFF

#define FIELDNO_HEAPTUPLEHEADERDATA_HOFF   4

Definition at line 171 of file htup_details.h.

Referenced by slot_compile_deform().

◆ FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK

#define FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK   3

Definition at line 168 of file htup_details.h.

Referenced by slot_compile_deform().

◆ FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK2

#define FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK2   2

Definition at line 165 of file htup_details.h.

Referenced by slot_compile_deform().

◆ GETSTRUCT

#define GETSTRUCT (   TUP)    ((char *) ((TUP)->t_data) + (TUP)->t_data->t_hoff)

Definition at line 655 of file htup_details.h.

Referenced by _int_matchsel(), aclitemout(), add_cast_to(), add_function_cost(), add_function_defaults(), AddEnumLabel(), AddRoleMems(), AfterTriggerSetState(), AggregateCreate(), AlterCollation(), AlterConstraintNamespaces(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainAddConstraint(), AlterDomainDefault(), AlterDomainDropConstraint(), AlterDomainNotNull(), AlterDomainValidateConstraint(), AlterEventTrigger(), AlterEventTriggerOwner(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectRename_internal(), AlterOperator(), AlterOpFamily(), AlterPolicy(), AlterPublication(), AlterPublicationOptions(), AlterPublicationOwner(), AlterPublicationOwner_internal(), AlterPublicationTables(), AlterRelationNamespaceInternal(), AlterRole(), AlterRoleSet(), AlterSchemaOwner(), AlterSchemaOwner_internal(), AlterSeqNamespaces(), AlterSequence(), AlterSubscription(), AlterSubscriptionOwner(), AlterSubscriptionOwner_internal(), AlterTableMoveAll(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterTSDictionary(), AlterTypeNamespaceInternal(), AlterTypeOwner(), AlterTypeOwner_oid(), AlterTypeOwnerInternal(), amvalidate(), appendAggOrderBy(), appendFunctionName(), ApplyExtensionUpdates(), assignOperTypes(), assignProcTypes(), ATAddForeignKeyConstraint(), ATDetachCheckNoForeignKeyRefs(), ATExecAddColumn(), ATExecAddIdentity(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecChangeOwner(), ATExecCheckNotNull(), ATExecDetachPartition(), ATExecDisableRowSecurity(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropIdentity(), ATExecDropNotNull(), ATExecDropOf(), ATExecEnableRowSecurity(), ATExecForceNoForceRowSecurity(), ATExecGenericOptions(), ATExecSetIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecSetTableSpace(), ATExecSetTableSpaceNoStorage(), ATExecValidateConstraint(), ATPostAlterTypeCleanup(), ATPrepAlterColumnType(), ATPrepChangePersistence(), AttrDefaultFetch(), blvalidate(), booltestsel(), boot_openrel(), brinvalidate(), btvalidate(), build_coercion_expression(), build_datatype(), build_function_result_tupdesc_t(), BuildEventTriggerCache(), CacheInvalidateHeapTuple(), CacheInvalidateRelcacheByTuple(), calc_arraycontsel(), calc_rangesel(), call_pltcl_start_proc(), change_owner_fix_column_acls(), change_owner_recurse_to_sequences(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), check_amop_signature(), check_amproc_signature(), check_db_file_conflict(), check_enable_rls(), check_for_column_name_collision(), check_hash_func_signature(), check_object_ownership(), check_of_type(), check_role(), check_safe_enum_use(), check_session_authorization(), check_TSCurrentConfig(), CheckConstraintFetch(), checkDomainOwner(), checkEnumOwner(), CheckFunctionValidatorAccess(), CheckIndexCompatible(), CheckMyDatabase(), checkSharedDependencies(), CloneFkReferenced(), CloneFkReferencing(), CloneRowTriggersToPartition(), cluster(), cluster_rel(), CollationIsVisible(), column_privilege_check(), compatible_oper(), compile_plperl_function(), compile_pltcl_function(), compute_return_type(), ComputeIndexAttrs(), ComputePartitionAttrs(), constraints_equivalent(), ConstraintSetParentConstraint(), ConstructTupleDescriptor(), ConversionIsVisible(), convert_column_name(), copy_table_data(), create_proc_lang(), create_toast_table(), CreateCast(), createdb(), CreateFunction(), CreateInheritance(), CreateRole(), CreateSchemaCommand(), CreateStatistics(), CreateTransform(), CreateTrigger(), decompile_conbin(), DeconstructFkConstraintRow(), DefineCollation(), DefineDomain(), DefineIndex(), DefineOpClass(), DefineQueryRewrite(), DefineTSConfiguration(), DefineType(), deleteDependencyRecordsFor(), deleteDependencyRecordsForClass(), DeleteInheritsTuple(), deparseOpExpr(), deparseScalarArrayOpExpr(), do_autovacuum(), do_compile(), do_setval(), drop_parent_dependency(), DropConfigurationMapping(), DropRole(), DropSubscription(), DropTableSpace(), EnableDisableRule(), EnableDisableTrigger(), enum_cmp_internal(), enum_endpoint(), enum_in(), enum_out(), enum_range_internal(), enum_recv(), enum_send(), eqjoinsel(), equality_ops_are_compatible(), errdatatype(), estimate_hash_bucket_stats(), evaluate_function(), examine_attribute(), exec_object_restorecon(), ExecAlterExtensionStmt(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitAgg(), ExecuteCallStmt(), ExecuteDoStmt(), expand_all_col_privileges(), expand_function_arguments(), expand_vacuum_rel(), extract_autovac_opts(), extractRelOptions(), fetch_agg_sort_op(), fetch_fp_info(), fetch_statentries_for_relation(), find_coercion_pathway(), find_composite_type_dependencies(), find_inheritance_children(), find_language_template(), find_typed_table_dependencies(), find_typmod_coercion_function(), FindDefaultConversion(), findDependentObjects(), finish_heap_swap(), fixup_whole_row_references(), fmgr_info_cxt_security(), fmgr_info_other_lang(), fmgr_security_definer(), fmgr_sql_validator(), fmgr_symbol(), format_operator_internal(), format_operator_parts(), format_procedure_internal(), format_procedure_parts(), format_type_extended(), func_get_detail(), func_parallel(), func_strict(), func_volatile(), FuncNameAsType(), FuncnameGetCandidates(), FunctionIsVisible(), generate_collation_name(), generate_function_name(), generate_operator_clause(), generate_operator_name(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_agg_clause_costs_walker(), get_all_vacuum_rels(), get_am_name(), get_am_type_oid(), get_array_type(), get_attavgwidth(), get_attgenerated(), get_attname(), get_attnum(), get_attstatsslot(), get_atttype(), get_atttypetypmodcoll(), get_base_element_type(), get_collation(), get_collation_isdeterministic(), get_collation_name(), get_commutator(), get_compatible_hash_operators(), get_constraint_index(), get_constraint_name(), get_database_list(), get_database_name(), get_database_oid(), get_db_info(), get_default_partition_oid(), get_domain_constraint_oid(), get_element_type(), get_extension_name(), get_extension_oid(), get_extension_schema(), get_func_arg_info(), get_func_leakproof(), get_func_name(), get_func_namespace(), get_func_nargs(), get_func_prokind(), get_func_retset(), get_func_rettype(), get_func_signature(), get_func_support(), get_func_trftypes(), get_func_variadictype(), get_function_rows(), get_index_column_opclass(), get_index_constraint(), get_index_ref_constraints(), get_language_name(), get_mergejoin_opfamilies(), get_namespace_name(), get_negator(), get_object_address_attrdef(), get_object_address_defacl(), get_object_address_opf_member(), get_object_address_type(), get_object_address_usermapping(), get_op_btree_interpretation(), get_op_hash_functions(), get_op_opfamily_properties(), get_op_opfamily_sortfamily(), get_op_opfamily_strategy(), get_op_rettype(), get_opclass(), get_opclass_family(), get_opclass_input_type(), get_opclass_name(), get_opclass_oid(), get_opclass_opfamily_and_input_type(), get_opcode(), get_oper_expr(), get_opfamily_member(), get_opfamily_oid(), get_opfamily_proc(), get_opname(), get_oprjoin(), get_oprrest(), get_ordering_op_for_equality_op(), get_ordering_op_properties(), get_partition_parent_worker(), get_pkey_attnames(), get_primary_key_attnos(), get_publication_name(), get_range_subtype(), get_rel_name(), get_rel_namespace(), get_rel_persistence(), get_rel_relispartition(), get_rel_relkind(), get_rel_tablespace(), get_rel_type_id(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_idx_constraint_oid(), get_relation_policy_oid(), get_relation_statistics(), get_relname_relid(), get_rels_with_domain(), get_rewrite_oid(), get_rolespec_name(), get_rte_attribute_is_dropped(), get_rte_attribute_type(), get_subscription_list(), get_subscription_name(), get_tables_to_cluster(), get_tablespace_name(), get_tablespace_oid(), get_transform_fromsql(), get_transform_tosql(), get_trigger_oid(), get_typ_typrelid(), get_typbyval(), get_typcollation(), get_typdefault(), get_type_category_preferred(), get_type_io_data(), get_typisdefined(), get_typlen(), get_typlenbyval(), get_typlenbyvalalign(), get_typmodin(), get_typstorage(), get_typtype(), get_variable_numdistinct(), GetAllTablesPublicationRelations(), GetAllTablesPublications(), getBaseTypeAndTypmod(), getConstraintTypeDescription(), GetDefaultOpClass(), getExtensionOfObject(), GetFdwRoutineByServerId(), GetForeignDataWrapperExtended(), GetForeignServerExtended(), GetForeignServerIdByRelId(), GetForeignTable(), GetIndexAmRoutineByAmId(), getObjectDescription(), getObjectIdentityParts(), getOpFamilyDescription(), getOpFamilyIdentity(), getOwnedSequences_internal(), GetParentedForeignKeyRefs(), getProcedureTypeDescription(), GetPublication(), GetPublicationRelations(), getRelationDescription(), getRelationIdentity(), GetRelationPublicationActions(), GetRelationPublications(), getRelationsInNamespace(), getRelationTypeDescription(), GetSubscription(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), gettype(), getTypeBinaryInputInfo(), getTypeBinaryOutputInfo(), getTypeInputInfo(), getTypeIOParam(), getTypeOutputInfo(), GetUserMapping(), GetUserNameFromId(), ginvalidate(), gistvalidate(), has_bypassrls_privilege(), has_createrole_privilege(), has_rolinherit(), has_rolreplication(), has_subclass(), hash_ok_operator(), hashvalidate(), have_createdb_privilege(), heap_drop_with_catalog(), heap_truncate_find_FKs(), identify_opfamily_groups(), index_build(), index_check_primary_key(), index_concurrently_swap(), index_constraint_create(), index_get_partition(), index_set_state_flags(), index_update_stats(), indexam_property(), IndexGetRelation(), IndexSetParentIndex(), IndexSupportsBackwardScan(), init_sql_fcache(), initialize_peragg(), InitializeSessionUserId(), InitPostgres(), inline_function(), inline_set_returning_function(), InsertRule(), internal_get_result_type(), interpret_function_parameter_list(), inv_getsize(), inv_read(), inv_truncate(), inv_write(), is_admin_of_role(), IsBinaryCoercible(), isObjectPinned(), isSharedObjectPinned(), load_domaintype_info(), load_enum_cache_data(), load_rangetype_info(), load_relcache_init_file(), logicalrep_write_tuple(), logicalrep_write_typ(), lookup_C_func(), lookup_collation(), lookup_collation_cache(), lookup_ts_config_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupOpclassInfo(), LookupTypeNameOid(), ltreeparentsel(), make_inh_translation_list(), make_op(), make_scalar_array_op(), makeConfigurationDependencies(), MakeConfigurationMapping(), makeDictionaryDependencies(), makeOperatorDependencies(), makeParserDependencies(), makeTSTemplateDependencies(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), mark_index_clustered(), MatchNamedCall(), MergeAttributesIntoExisting(), MergeConstraintsIntoExisting(), mergejoinscansel(), MergeWithExistingConstraint(), neqjoinsel(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), nextval_internal(), nulltestsel(), objectsInSchemaToOids(), op_hashjoinable(), op_input_types(), op_mergejoinable(), OpClassCacheLookup(), OpclassIsVisible(), OperatorGet(), OperatorIsVisible(), OperatorUpd(), OpernameGetCandidates(), OpernameGetOprid(), opfamily_can_sort_type(), OpFamilyCacheLookup(), OpfamilyIsVisible(), oprfuncid(), oprid(), ParseFuncOrColumn(), parseTypeString(), patternsel_common(), pg_attribute_aclcheck_all(), pg_attribute_aclmask(), pg_class_aclmask(), pg_class_ownercheck(), pg_collation_actual_version(), pg_collation_ownercheck(), pg_conversion_ownercheck(), pg_database_aclmask(), pg_database_ownercheck(), pg_event_trigger_ownercheck(), pg_extension_ownercheck(), pg_foreign_data_wrapper_aclmask(), pg_foreign_data_wrapper_ownercheck(), pg_foreign_server_aclmask(), pg_foreign_server_ownercheck(), pg_get_constraintdef_worker(), pg_get_function_arg_default(), pg_get_function_result(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_serial_sequence(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), pg_get_userbyid(), pg_language_aclmask(), pg_language_ownercheck(), pg_largeobject_aclmask_snapshot(), pg_largeobject_ownercheck(), pg_namespace_aclmask(), pg_namespace_ownercheck(), pg_newlocale_from_collation(), pg_nextoid(), pg_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_proc_aclmask(), pg_proc_ownercheck(), pg_publication_ownercheck(), pg_relation_filenode(), pg_relation_filepath(), pg_relation_is_publishable(), pg_sequence_parameters(), pg_statistics_object_ownercheck(), pg_subscription_ownercheck(), pg_tablespace_aclmask(), pg_tablespace_ownercheck(), pg_ts_config_ownercheck(), pg_ts_dict_ownercheck(), pg_type_aclmask(), pg_type_ownercheck(), pgfdw_reject_incomplete_xact_state_change(), plperl_validator(), plpgsql_compile(), plpgsql_parse_cwordtype(), plpgsql_parse_wordtype(), plpgsql_validator(), plpython_validator(), PLy_procedure_create(), prepare_column_cache(), prepare_sql_fn_parse_info(), print_function_arguments(), print_function_rettype(), ProcedureCreate(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForRenameAttribute(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackForTruncate(), RangeVarCallbackOwnsRelation(), read_seq_tuple(), recheck_cast_function_args(), recomputeNamespacePath(), record_C_func(), recordExtObjInitPriv(), refresh_by_match_merge(), regclassout(), regconfigout(), regdictionaryout(), regoperout(), regprocout(), regtypeout(), reindex_index(), ReindexMultipleTables(), relation_mark_replica_identity(), RelationBuildDesc(), RelationBuildPartitionKey(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationCacheInitializePhase3(), RelationClearMissing(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationGetIndexList(), RelationGetStatExtList(), relationHasPrimaryKey(), RelationInitIndexAccessInfo(), RelationInitPhysicalAddr(), RelationInitTableAccessMethod(), RelationIsVisible(), RelationReloadIndexInfo(), RelationReloadNailed(), RelationSetNewRelfilenode(), RelidByRelfilenode(), remove_dbtablespaces(), RemoveAttrDefault(), RemoveAttrDefaultById(), RemoveAttributeById(), RemoveConstraintById(), removeExtObjInitPriv(), RemoveFunctionById(), RemoveInheritance(), RemoveOperatorById(), RemovePolicyById(), RemovePublicationRelById(), RemoveRewriteRuleById(), RemoveRoleFromObjectACL(), RemoveRoleFromObjectPolicy(), RemoveStatisticsById(), RemoveTriggerById(), RemoveTypeById(), rename_constraint_internal(), rename_policy(), renameatt_internal(), RenameConstraintById(), RenameDatabase(), RenameEnumLabel(), RenameRelationInternal(), RenameRewriteRule(), RenameRole(), RenameSchema(), RenameTableSpace(), renametrig(), RenameType(), RenameTypeInternal(), RenumberEnumType(), reorder_function_arguments(), replorigin_by_name(), replorigin_by_oid(), ResetSequence(), ResolveOpClass(), ri_GenerateQualCollation(), ri_LoadConstraintInfo(), roles_has_privs_of(), roles_is_member_of(), scalararraysel_containment(), scalarineqsel(), SearchSysCacheAttName(), SearchSysCacheAttNum(), sepgsql_attribute_post_create(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_proc_setattr(), sepgsql_relation_drop(), sepgsql_relation_post_create(), sepgsql_relation_setattr(), sepgsql_schema_post_create(), sequence_options(), sequenceIsOwned(), SetAttrMissing(), SetDefaultACL(), SetFunctionArgType(), SetFunctionReturnType(), SetMatViewPopulatedState(), SetRelationHasSubclass(), SetRelationNumChecks(), SetRelationRuleStatus(), shdepChangeDep(), shdepDropDependency(), shdepDropOwned(), shdepReassignOwned(), simplify_function(), sort_order_cmp(), spgproperty(), spgvalidate(), SPI_gettype(), StatisticsObjIsVisible(), StoreAttrDefault(), StorePartitionBound(), stringTypeDatum(), superuser_arg(), swap_relation_files(), table_recheck_autovac(), transformColumnDefinition(), transformColumnNameList(), transformColumnType(), transformContainerType(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), transformFrameOffset(), transformOfType(), triggered_change_notification(), tryAttachPartitionForeignKey(), TSConfigIsVisible(), TSDictionaryIsVisible(), TSParserIsVisible(), tsquerysel(), TSTemplateIsVisible(), TupleDescInitEntry(), typeByVal(), TypeCreate(), typeidTypeRelid(), typeInheritsFrom(), typeIsOfTypedTable(), TypeIsVisible(), typeLen(), typenameType(), typenameTypeId(), typenameTypeIdAndMod(), typenameTypeMod(), typeOrDomainTypeRelid(), TypeShellMake(), typeTypeCollation(), typeTypeId(), typeTypeName(), typeTypeRelid(), update_default_partition_oid(), update_relispartition(), vac_truncate_clog(), vac_update_datfrozenxid(), vac_update_relstats(), validateCheckConstraint(), validatePartitionedIndex(), var_eq_const(), var_eq_non_const(), and verify_dictoptions().

◆ HEAP2_XACT_MASK

#define HEAP2_XACT_MASK   0xE000 /* visibility-related bits */

◆ HEAP_COMBOCID

#define HEAP_COMBOCID   0x0020 /* t_cid is a combo cid */

◆ heap_getattr

#define heap_getattr (   tup,
  attnum,
  tupleDesc,
  isnull 
)
Value:
( \
((attnum) > 0) ? \
( \
((attnum) > (int) HeapTupleHeaderGetNatts((tup)->t_data)) ? \
getmissingattr((tupleDesc), (attnum), (isnull)) \
: \
fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
) \
: \
heap_getsysattr((tup), (attnum), (tupleDesc), (isnull)) \
)
#define fastgetattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:712
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: heaptuple.c:627
Datum getmissingattr(TupleDesc tupleDesc, int attnum, bool *isnull)
Definition: heaptuple.c:84
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:531
int16 attnum
Definition: pg_attribute.h:79

Definition at line 762 of file htup_details.h.

Referenced by AlterDatabaseOwner(), AlterDomainDefault(), AlterForeignDataWrapperOwner_internal(), AlterForeignServerOwner_internal(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterPolicy(), AlterSetting(), AlterTableSpaceOptions(), AlterTypeOwnerInternal(), ApplySetting(), ATExecAlterColumnType(), build_sorted_items(), BuildEventTriggerCache(), CatalogCacheCreateEntry(), change_owner_fix_column_acls(), CloneRowTriggersToPartition(), comparetup_cluster(), comparetup_heap(), composite_to_json(), composite_to_jsonb(), copytup_cluster(), copytup_heap(), decompile_conbin(), EventTriggerSQLDropAddObject(), ExecAlterExtensionStmt(), ExecEvalFieldSelect(), ExecGrant_Database(), ExecGrant_Largeobject(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecScanSubPlan(), ExecSetParamPlan(), extension_config_remove(), find_language_template(), get_primary_key_attnos(), get_relation_constraint_attnos(), GetAttributeByName(), GetAttributeByNum(), GetComment(), GetSecurityLabel(), GetSharedSecurityLabel(), GetSysCacheOid(), heap_tuple_attr_equals(), ndistinct_for_combination(), pg_event_trigger_ddl_commands(), pg_extension_config_dump(), pg_identify_object(), pg_largeobject_aclmask_snapshot(), pgstat_collect_oids(), plperl_hash_from_tuple(), pltcl_build_tuple_argument(), pltcl_set_tuple_values(), PLyDict_FromTuple(), readtup_cluster(), readtup_heap(), recordExtObjInitPriv(), RelationBuildPartitionDesc(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationBuildTupleDesc(), RelationGetIndexAttrBitmap(), RelationGetIndexExpressions(), RelationGetIndexPredicate(), RemoveRoleFromObjectPolicy(), RenameRole(), sepgsql_relation_setattr_extra(), SPI_getbinval(), SPI_getvalue(), std_fetch_func(), SysCacheGetAttr(), and tuple_to_stringinfo().

◆ HEAP_HASEXTERNAL

#define HEAP_HASEXTERNAL   0x0004 /* has external stored attribute(s) */

◆ HEAP_HASNULL

#define HEAP_HASNULL   0x0001 /* has null attribute(s) */

◆ HEAP_HASOID_OLD

#define HEAP_HASOID_OLD   0x0008 /* has an object-id field */

Definition at line 192 of file htup_details.h.

Referenced by heap_page_items(), and heap_tuple_infomask_flags().

◆ HEAP_HASVARWIDTH

#define HEAP_HASVARWIDTH   0x0002 /* has variable-width attribute(s) */

◆ HEAP_HOT_UPDATED

#define HEAP_HOT_UPDATED   0x4000 /* tuple was HOT-updated */

Definition at line 280 of file htup_details.h.

Referenced by heap_prepare_freeze_tuple(), and heap_tuple_infomask_flags().

◆ HEAP_KEYS_UPDATED

◆ HEAP_LOCK_MASK

#define HEAP_LOCK_MASK
Value:
HEAP_XMAX_KEYSHR_LOCK)
#define HEAP_XMAX_SHR_LOCK
Definition: htup_details.h:199
#define HEAP_XMAX_EXCL_LOCK
Definition: htup_details.h:195

Definition at line 201 of file htup_details.h.

Referenced by xmax_infomask_changed().

◆ HEAP_LOCKED_UPGRADED

#define HEAP_LOCKED_UPGRADED (   infomask)

◆ HEAP_MOVED

◆ HEAP_MOVED_IN

#define HEAP_MOVED_IN
Value:
0x8000 /* moved from another place by pre-9.0
* VACUUM FULL; kept for binary
* upgrade support */

Definition at line 213 of file htup_details.h.

Referenced by heap_tuple_infomask_flags(), HeapTupleSatisfiesDirty(), HeapTupleSatisfiesMVCC(), HeapTupleSatisfiesSelf(), HeapTupleSatisfiesToast(), HeapTupleSatisfiesUpdate(), and HeapTupleSatisfiesVacuum().

◆ HEAP_MOVED_OFF

#define HEAP_MOVED_OFF
Value:
0x4000 /* moved to another place by pre-9.0
* VACUUM FULL; kept for binary
* upgrade support */

Definition at line 210 of file htup_details.h.

Referenced by heap_prepare_freeze_tuple(), heap_tuple_infomask_flags(), HeapTupleSatisfiesDirty(), HeapTupleSatisfiesMVCC(), HeapTupleSatisfiesSelf(), HeapTupleSatisfiesToast(), HeapTupleSatisfiesUpdate(), and HeapTupleSatisfiesVacuum().

◆ HEAP_NATTS_MASK

#define HEAP_NATTS_MASK   0x07FF /* 11 bits for number of attributes */

◆ HEAP_ONLY_TUPLE

#define HEAP_ONLY_TUPLE   0x8000 /* this is heap-only tuple */

Definition at line 281 of file htup_details.h.

Referenced by heap_tuple_infomask_flags().

◆ HEAP_TUPLE_HAS_MATCH

#define HEAP_TUPLE_HAS_MATCH   HEAP_ONLY_TUPLE /* tuple has a join match */

Definition at line 291 of file htup_details.h.

◆ HEAP_UPDATED

#define HEAP_UPDATED   0x2000 /* this is UPDATEd version of row */

Definition at line 209 of file htup_details.h.

Referenced by heap_tuple_infomask_flags(), heap_update(), and rewrite_heap_tuple().

◆ HEAP_XACT_MASK

#define HEAP_XACT_MASK   0xFFF0 /* visibility-related bits */

◆ HEAP_XMAX_BITS

#define HEAP_XMAX_BITS

◆ HEAP_XMAX_COMMITTED

◆ HEAP_XMAX_EXCL_LOCK

#define HEAP_XMAX_EXCL_LOCK   0x0040 /* xmax is exclusive locker */

◆ HEAP_XMAX_INVALID

◆ HEAP_XMAX_IS_EXCL_LOCKED

#define HEAP_XMAX_IS_EXCL_LOCKED (   infomask)    (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_EXCL_LOCK)

◆ HEAP_XMAX_IS_KEYSHR_LOCKED

#define HEAP_XMAX_IS_KEYSHR_LOCKED (   infomask)    (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_KEYSHR_LOCK)

◆ HEAP_XMAX_IS_LOCKED_ONLY

◆ HEAP_XMAX_IS_MULTI

◆ HEAP_XMAX_IS_SHR_LOCKED

#define HEAP_XMAX_IS_SHR_LOCKED (   infomask)    (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_SHR_LOCK)

◆ HEAP_XMAX_KEYSHR_LOCK

#define HEAP_XMAX_KEYSHR_LOCK   0x0010 /* xmax is a key-shared locker */

◆ HEAP_XMAX_LOCK_ONLY

#define HEAP_XMAX_LOCK_ONLY   0x0080 /* xmax, if valid, is only a locker */

◆ HEAP_XMAX_SHR_LOCK

#define HEAP_XMAX_SHR_LOCK   (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)

◆ HEAP_XMIN_COMMITTED

◆ HEAP_XMIN_FROZEN

#define HEAP_XMIN_FROZEN   (HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID)

Definition at line 205 of file htup_details.h.

Referenced by heap_prepare_freeze_tuple(), and heap_tuple_infomask_flags().

◆ HEAP_XMIN_INVALID

◆ HeapTupleAllFixed

#define HeapTupleAllFixed (   tuple)    (!((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH))

Definition at line 670 of file htup_details.h.

◆ HeapTupleClearHeapOnly

#define HeapTupleClearHeapOnly (   tuple)    HeapTupleHeaderClearHeapOnly((tuple)->t_data)

Definition at line 691 of file htup_details.h.

Referenced by heap_update().

◆ HeapTupleClearHotUpdated

#define HeapTupleClearHotUpdated (   tuple)    HeapTupleHeaderClearHotUpdated((tuple)->t_data)

Definition at line 682 of file htup_details.h.

Referenced by heap_update().

◆ HeapTupleHasExternal

◆ HeapTupleHasNulls

#define HeapTupleHasNulls (   tuple)    (((tuple)->t_data->t_infomask & HEAP_HASNULL) != 0)

◆ HeapTupleHasVarWidth

#define HeapTupleHasVarWidth (   tuple)    (((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH) != 0)

Definition at line 667 of file htup_details.h.

Referenced by nocachegetattr().

◆ HeapTupleHeaderClearHeapOnly

#define HeapTupleHeaderClearHeapOnly (   tup)
Value:
( \
(tup)->t_infomask2 &= ~HEAP_ONLY_TUPLE \
)
#define HEAP_ONLY_TUPLE
Definition: htup_details.h:281

Definition at line 511 of file htup_details.h.

◆ HeapTupleHeaderClearHotUpdated

#define HeapTupleHeaderClearHotUpdated (   tup)
Value:
( \
(tup)->t_infomask2 &= ~HEAP_HOT_UPDATED \
)
#define HEAP_HOT_UPDATED
Definition: htup_details.h:280

Definition at line 496 of file htup_details.h.

Referenced by heap_delete(), heap_lock_tuple(), heap_xlog_delete(), heap_xlog_lock(), and heap_xlog_update().

◆ HeapTupleHeaderClearMatch

#define HeapTupleHeaderClearMatch (   tup)
Value:
( \
(tup)->t_infomask2 &= ~HEAP_TUPLE_HAS_MATCH \
)
#define HEAP_TUPLE_HAS_MATCH
Definition: htup_details.h:291

Definition at line 526 of file htup_details.h.

Referenced by ExecHashSkewTableInsert(), ExecHashTableInsert(), ExecHashTableResetMatchFlags(), and ExecParallelHashTableInsertCurrentBatch().

◆ HeapTupleHeaderGetDatumLength

◆ HeapTupleHeaderGetNatts

#define HeapTupleHeaderGetNatts (   tup)    ((tup)->t_infomask2 & HEAP_NATTS_MASK)

◆ HeapTupleHeaderGetRawCommandId

#define HeapTupleHeaderGetRawCommandId (   tup)
Value:
( \
(tup)->t_choice.t_heap.t_field3.t_cid \
)

Definition at line 391 of file htup_details.h.

Referenced by heap_getsysattr(), heap_page_items(), HeapTupleHeaderGetCmax(), HeapTupleHeaderGetCmin(), HeapTupleSatisfiesHistoricMVCC(), and log_heap_new_cid().

◆ HeapTupleHeaderGetRawXmax

◆ HeapTupleHeaderGetRawXmin

◆ HeapTupleHeaderGetSpeculativeToken

#define HeapTupleHeaderGetSpeculativeToken (   tup)
Value:
( \
AssertMacro(HeapTupleHeaderIsSpeculative(tup)), \
ItemPointerGetBlockNumber(&(tup)->t_ctid) \
)
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:429

Definition at line 434 of file htup_details.h.

Referenced by HeapTupleSatisfiesDirty().

◆ HeapTupleHeaderGetTypeId

◆ HeapTupleHeaderGetTypMod

◆ HeapTupleHeaderGetUpdateXid

#define HeapTupleHeaderGetUpdateXid (   tup)

◆ HeapTupleHeaderGetXmin

◆ HeapTupleHeaderGetXvac

#define HeapTupleHeaderGetXvac (   tup)

◆ HeapTupleHeaderHasExternal

#define HeapTupleHeaderHasExternal (   tup)    (((tup)->t_infomask & HEAP_HASEXTERNAL) != 0)

Definition at line 539 of file htup_details.h.

Referenced by HeapTupleHeaderGetDatum(), and make_expanded_record_from_datum().

◆ HeapTupleHeaderHasMatch

#define HeapTupleHeaderHasMatch (   tup)
Value:
( \
((tup)->t_infomask2 & HEAP_TUPLE_HAS_MATCH) != 0 \
)
#define HEAP_TUPLE_HAS_MATCH
Definition: htup_details.h:291

Definition at line 516 of file htup_details.h.

Referenced by ExecScanHashTableForUnmatched().

◆ HeapTupleHeaderIndicatesMovedPartitions

#define HeapTupleHeaderIndicatesMovedPartitions (   tup)
Value:
ItemPointerGetBlockNumberNoCheck(&(tup)->t_ctid) == MovedPartitionsBlockNumber)
#define MovedPartitionsOffsetNumber
Definition: itemptr.h:69
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:117
#define MovedPartitionsBlockNumber
Definition: itemptr.h:70

Definition at line 445 of file htup_details.h.

Referenced by heap_delete(), heap_get_latest_tid(), heap_get_root_tuples(), heap_lock_tuple(), heap_lock_updated_tuple(), heap_lock_updated_tuple_rec(), heap_prune_chain(), heap_update(), HeapTupleSatisfiesUpdate(), rewrite_heap_tuple(), and test_lockmode_for_conflict().

◆ HeapTupleHeaderIsHeapOnly

#define HeapTupleHeaderIsHeapOnly (   tup)
Value:
( \
((tup)->t_infomask2 & HEAP_ONLY_TUPLE) != 0 \
)
#define HEAP_ONLY_TUPLE
Definition: htup_details.h:281

Definition at line 501 of file htup_details.h.

Referenced by heap_abort_speculative(), heap_get_root_tuples(), and heap_prune_chain().

◆ HeapTupleHeaderIsHotUpdated

#define HeapTupleHeaderIsHotUpdated (   tup)
Value:
( \
((tup)->t_infomask2 & HEAP_HOT_UPDATED) != 0 && \
((tup)->t_infomask & HEAP_XMAX_INVALID) == 0 && \
)
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:329
#define HEAP_XMAX_INVALID
Definition: htup_details.h:207
#define HEAP_HOT_UPDATED
Definition: htup_details.h:280

Definition at line 484 of file htup_details.h.

Referenced by heap_get_root_tuples(), and heap_prune_chain().

◆ HeapTupleHeaderIsSpeculative

#define HeapTupleHeaderIsSpeculative (   tup)
Value:
( \
)
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
#define SpecTokenOffsetNumber
Definition: itemptr.h:63

Definition at line 429 of file htup_details.h.

Referenced by heap_abort_speculative(), heap_finish_speculative(), heap_mask(), heapam_tuple_lock(), HeapTupleSatisfiesDirty(), and RelationPutHeapTuple().

◆ HeapTupleHeaderSetCmax

#define HeapTupleHeaderSetCmax (   tup,
  cid,
  iscombo 
)
Value:
do { \
Assert(!((tup)->t_infomask & HEAP_MOVED)); \
(tup)->t_choice.t_heap.t_field3.t_cid = (cid); \
if (iscombo) \
(tup)->t_infomask |= HEAP_COMBOCID; \
else \
(tup)->t_infomask &= ~HEAP_COMBOCID; \
} while (0)
#define HEAP_MOVED
Definition: htup_details.h:216
#define HEAP_COMBOCID
Definition: htup_details.h:194

Definition at line 405 of file htup_details.h.

Referenced by heap_delete(), heap_update(), heap_xlog_delete(), heap_xlog_lock(), and heap_xlog_update().

◆ HeapTupleHeaderSetCmin

#define HeapTupleHeaderSetCmin (   tup,
  cid 
)
Value:
do { \
Assert(!((tup)->t_infomask & HEAP_MOVED)); \
(tup)->t_choice.t_heap.t_field3.t_cid = (cid); \
(tup)->t_infomask &= ~HEAP_COMBOCID; \
} while (0)
#define HEAP_MOVED
Definition: htup_details.h:216
#define HEAP_COMBOCID
Definition: htup_details.h:194

Definition at line 397 of file htup_details.h.

Referenced by apply_returning_filter(), fill_seq_with_data(), heap_prepare_insert(), heap_update(), heap_xlog_insert(), heap_xlog_multi_insert(), heap_xlog_update(), and make_tuple_from_result_row().

◆ HeapTupleHeaderSetDatumLength

#define HeapTupleHeaderSetDatumLength (   tup,
  len 
)    SET_VARSIZE(tup, len)

◆ HeapTupleHeaderSetHeapOnly

#define HeapTupleHeaderSetHeapOnly (   tup)
Value:
( \
(tup)->t_infomask2 |= HEAP_ONLY_TUPLE \
)
#define HEAP_ONLY_TUPLE
Definition: htup_details.h:281

Definition at line 506 of file htup_details.h.

◆ HeapTupleHeaderSetHotUpdated

#define HeapTupleHeaderSetHotUpdated (   tup)
Value:
( \
(tup)->t_infomask2 |= HEAP_HOT_UPDATED \
)
#define HEAP_HOT_UPDATED
Definition: htup_details.h:280

Definition at line 491 of file htup_details.h.

Referenced by heap_xlog_update().

◆ HeapTupleHeaderSetMatch

#define HeapTupleHeaderSetMatch (   tup)
Value:
( \
(tup)->t_infomask2 |= HEAP_TUPLE_HAS_MATCH \
)
#define HEAP_TUPLE_HAS_MATCH
Definition: htup_details.h:291

Definition at line 521 of file htup_details.h.

Referenced by ExecHashJoinImpl().

◆ HeapTupleHeaderSetMovedPartitions

#define HeapTupleHeaderSetMovedPartitions (   tup)    ItemPointerSet(&(tup)->t_ctid, MovedPartitionsBlockNumber, MovedPartitionsOffsetNumber)

Definition at line 449 of file htup_details.h.

Referenced by heap_delete(), and heap_xlog_delete().

◆ HeapTupleHeaderSetNatts

#define HeapTupleHeaderSetNatts (   tup,
  natts 
)
Value:
( \
(tup)->t_infomask2 = ((tup)->t_infomask2 & ~HEAP_NATTS_MASK) | (natts) \
)
#define HEAP_NATTS_MASK
Definition: htup_details.h:276

Definition at line 534 of file htup_details.h.

Referenced by ER_flatten_into(), expand_tuple(), heap_form_minimal_tuple(), heap_form_tuple(), toast_flatten_tuple_to_datum(), and toast_insert_or_update().

◆ HeapTupleHeaderSetSpeculativeToken

#define HeapTupleHeaderSetSpeculativeToken (   tup,
  token 
)
Value:
( \
ItemPointerSet(&(tup)->t_ctid, token, SpecTokenOffsetNumber) \
)
#define SpecTokenOffsetNumber
Definition: itemptr.h:63

Definition at line 440 of file htup_details.h.

Referenced by heapam_tuple_insert_speculative().

◆ HeapTupleHeaderSetTypeId

#define HeapTupleHeaderSetTypeId (   tup,
  typeid 
)
Value:
( \
(tup)->t_choice.t_datum.datum_typeid = (typeid) \
)

Definition at line 463 of file htup_details.h.

Referenced by coerce_function_result_tuple(), ER_flatten_into(), ExecEvalWholeRowVar(), expand_tuple(), heap_copy_tuple_as_datum(), heap_form_tuple(), and toast_flatten_tuple_to_datum().

◆ HeapTupleHeaderSetTypMod

#define HeapTupleHeaderSetTypMod (   tup,
  typmod 
)
Value:
( \
(tup)->t_choice.t_datum.datum_typmod = (typmod) \
)

Definition at line 473 of file htup_details.h.

Referenced by coerce_function_result_tuple(), ER_flatten_into(), ExecEvalWholeRowVar(), expand_tuple(), heap_copy_tuple_as_datum(), heap_form_tuple(), and toast_flatten_tuple_to_datum().

◆ HeapTupleHeaderSetXmax

◆ HeapTupleHeaderSetXmin

#define HeapTupleHeaderSetXmin (   tup,
  xid 
)

◆ HeapTupleHeaderSetXminCommitted

#define HeapTupleHeaderSetXminCommitted (   tup)
Value:
( \
AssertMacro(!HeapTupleHeaderXminInvalid(tup)), \
((tup)->t_infomask |= HEAP_XMIN_COMMITTED) \
)
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:329
#define HEAP_XMIN_COMMITTED
Definition: htup_details.h:203

Definition at line 340 of file htup_details.h.

◆ HeapTupleHeaderSetXminFrozen

#define HeapTupleHeaderSetXminFrozen (   tup)
Value:
( \
AssertMacro(!HeapTupleHeaderXminInvalid(tup)), \
((tup)->t_infomask |= HEAP_XMIN_FROZEN) \
)
#define HEAP_XMIN_FROZEN
Definition: htup_details.h:205
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:329

Definition at line 352 of file htup_details.h.

Referenced by fill_seq_with_data(), and heap_prepare_insert().

◆ HeapTupleHeaderSetXminInvalid

#define HeapTupleHeaderSetXminInvalid (   tup)
Value:
( \
AssertMacro(!HeapTupleHeaderXminCommitted(tup)), \
((tup)->t_infomask |= HEAP_XMIN_INVALID) \
)
#define HEAP_XMIN_INVALID
Definition: htup_details.h:204
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:324

Definition at line 346 of file htup_details.h.

◆ HeapTupleHeaderSetXvac

#define HeapTupleHeaderSetXvac (   tup,
  xid 
)
Value:
do { \
Assert((tup)->t_infomask & HEAP_MOVED); \
(tup)->t_choice.t_heap.t_field3.t_xvac = (xid); \
} while (0)
#define HEAP_MOVED
Definition: htup_details.h:216

Definition at line 423 of file htup_details.h.

Referenced by heap_execute_freeze_tuple().

◆ HeapTupleHeaderXminCommitted

◆ HeapTupleHeaderXminFrozen

#define HeapTupleHeaderXminFrozen (   tup)
Value:
( \
((tup)->t_infomask & (HEAP_XMIN_FROZEN)) == HEAP_XMIN_FROZEN \
)
#define HEAP_XMIN_FROZEN
Definition: htup_details.h:205

Definition at line 335 of file htup_details.h.

Referenced by heap_mask(), and HeapTupleSatisfiesMVCC().

◆ HeapTupleHeaderXminInvalid

◆ HeapTupleIsHeapOnly

◆ HeapTupleIsHotUpdated

#define HeapTupleIsHotUpdated (   tuple)    HeapTupleHeaderIsHotUpdated((tuple)->t_data)

◆ HeapTupleNoNulls

#define HeapTupleNoNulls (   tuple)    (!((tuple)->t_data->t_infomask & HEAP_HASNULL))

Definition at line 664 of file htup_details.h.

Referenced by heap_attisnull(), heapgettup_pagemode(), and nocachegetattr().

◆ HeapTupleSetHeapOnly

#define HeapTupleSetHeapOnly (   tuple)    HeapTupleHeaderSetHeapOnly((tuple)->t_data)

Definition at line 688 of file htup_details.h.

Referenced by heap_update().

◆ HeapTupleSetHotUpdated

#define HeapTupleSetHotUpdated (   tuple)    HeapTupleHeaderSetHotUpdated((tuple)->t_data)

Definition at line 679 of file htup_details.h.

Referenced by heap_update().

◆ MaxAttrSize

#define MaxAttrSize   (10 * 1024 * 1024)

Definition at line 585 of file htup_details.h.

Referenced by anybit_typmodin(), and anychar_typmodin().

◆ MaxHeapAttributeNumber

#define MaxHeapAttributeNumber   1600 /* 8 * 200 */

◆ MaxHeapTupleSize

◆ MaxHeapTuplesPerPage

◆ MaxTupleAttributeNumber

◆ MinHeapTupleSize

#define MinHeapTupleSize   MAXALIGN(SizeofHeapTupleHeader)

Definition at line 561 of file htup_details.h.

Referenced by heap_page_items().

◆ MINIMAL_TUPLE_DATA_OFFSET

#define MINIMAL_TUPLE_DATA_OFFSET   offsetof(MinimalTupleData, t_infomask2)

Definition at line 623 of file htup_details.h.

Referenced by readtup_heap(), and writetup_heap().

◆ MINIMAL_TUPLE_OFFSET

◆ MINIMAL_TUPLE_PADDING

#define MINIMAL_TUPLE_PADDING   ((offsetof(HeapTupleHeaderData, t_infomask2) - sizeof(uint32)) % MAXIMUM_ALIGNOF)

Definition at line 621 of file htup_details.h.

◆ SizeofHeapTupleHeader

◆ SizeofMinimalTupleHeader

Typedef Documentation

◆ DatumTupleFields

◆ HeapTupleFields

Function Documentation

◆ getmissingattr()

Datum getmissingattr ( TupleDesc  tupleDesc,
int  attnum,
bool isnull 
)

Definition at line 84 of file heaptuple.c.

References AttrMissing::am_present, AttrMissing::am_value, Assert, TupleDescData::constr, TupleConstr::missing, PointerGetDatum, and TupleDescAttr.

Referenced by heap_deform_tuple().

86 {
88 
89  Assert(attnum <= tupleDesc->natts);
90  Assert(attnum > 0);
91 
92  att = TupleDescAttr(tupleDesc, attnum - 1);
93 
94  if (att->atthasmissing)
95  {
96  AttrMissing *attrmiss;
97 
98  Assert(tupleDesc->constr);
99  Assert(tupleDesc->constr->missing);
100 
101  attrmiss = tupleDesc->constr->missing + (attnum - 1);
102 
103  if (attrmiss->am_present)
104  {
105  *isnull = false;
106  return attrmiss->am_value;
107  }
108  }
109 
110  *isnull = true;
111  return PointerGetDatum(NULL);
112 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
TupleConstr * constr
Definition: tupdesc.h:85
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
int16 attnum
Definition: pg_attribute.h:79
#define Assert(condition)
Definition: c.h:732
struct AttrMissing * missing
Definition: tupdesc.h:41

◆ heap_attisnull()

bool heap_attisnull ( HeapTuple  tup,
int  attnum,
TupleDesc  tupleDesc 
)

Definition at line 359 of file heaptuple.c.

References Assert, att_isnull, elog, ERROR, HeapTupleHeaderGetNatts, HeapTupleNoNulls, MaxCommandIdAttributeNumber, MaxTransactionIdAttributeNumber, MinCommandIdAttributeNumber, MinTransactionIdAttributeNumber, SelfItemPointerAttributeNumber, HeapTupleHeaderData::t_bits, HeapTupleData::t_data, TableOidAttributeNumber, and TupleDescAttr.

Referenced by build_function_result_tupdesc_t(), check_index_is_clusterable(), CheckIndexCompatible(), ExecEvalRowNullInt(), ExecuteCallStmt(), fmgr_info_cxt_security(), fmgr_symbol(), get_func_result_name(), index_drop(), inline_function(), inline_set_returning_function(), pg_attribute_aclcheck_all(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), RelationGetIndexExpressions(), RelationGetIndexList(), RelationGetIndexPredicate(), statext_is_kind_built(), and transformFkeyCheckAttrs().

360 {
361  /*
362  * We allow a NULL tupledesc for relations not expected to have missing
363  * values, such as catalog relations and indexes.
364  */
365  Assert(!tupleDesc || attnum <= tupleDesc->natts);
366  if (attnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
367  {
368  if (tupleDesc && TupleDescAttr(tupleDesc, attnum - 1)->atthasmissing)
369  return false;
370  else
371  return true;
372  }
373 
374  if (attnum > 0)
375  {
376  if (HeapTupleNoNulls(tup))
377  return false;
378  return att_isnull(attnum - 1, tup->t_data->t_bits);
379  }
380 
381  switch (attnum)
382  {
389  /* these are never null */
390  break;
391 
392  default:
393  elog(ERROR, "invalid attnum: %d", attnum);
394  }
395 
396  return false;
397 }
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:177
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:23
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define MinCommandIdAttributeNumber
Definition: sysattr.h:23
HeapTupleHeader t_data
Definition: htup.h:68
#define ERROR
Definition: elog.h:43
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:531
#define TableOidAttributeNumber
Definition: sysattr.h:26
#define HeapTupleNoNulls(tuple)
Definition: htup_details.h:664
#define MaxCommandIdAttributeNumber
Definition: sysattr.h:25
#define MaxTransactionIdAttributeNumber
Definition: sysattr.h:24
int16 attnum
Definition: pg_attribute.h:79
#define Assert(condition)
Definition: c.h:732
#define elog(elevel,...)
Definition: elog.h:226
#define SelfItemPointerAttributeNumber
Definition: sysattr.h:21
#define MinTransactionIdAttributeNumber
Definition: sysattr.h:22

◆ heap_compute_data_size()

Size heap_compute_data_size ( TupleDesc  tupleDesc,
Datum values,
bool isnull 
)

Definition at line 119 of file heaptuple.c.

References att_addlength_datum, att_align_datum, att_align_nominal, ATT_IS_PACKABLE, DatumGetEOHP(), DatumGetPointer, EOH_get_flat_size(), i, TupleDescData::natts, TupleDescAttr, val, VARATT_CAN_MAKE_SHORT, VARATT_CONVERTED_SHORT_SIZE, and VARATT_IS_EXTERNAL_EXPANDED.

Referenced by brin_form_tuple(), ER_get_flat_size(), heap_form_minimal_tuple(), heap_form_tuple(), index_form_tuple(), toast_flatten_tuple_to_datum(), and toast_insert_or_update().

122 {
123  Size data_length = 0;
124  int i;
125  int numberOfAttributes = tupleDesc->natts;
126 
127  for (i = 0; i < numberOfAttributes; i++)
128  {
129  Datum val;
130  Form_pg_attribute atti;
131 
132  if (isnull[i])
133  continue;
134 
135  val = values[i];
136  atti = TupleDescAttr(tupleDesc, i);
137 
138  if (ATT_IS_PACKABLE(atti) &&
140  {
141  /*
142  * we're anticipating converting to a short varlena header, so
143  * adjust length and don't count any alignment
144  */
145  data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
146  }
147  else if (atti->attlen == -1 &&
149  {
150  /*
151  * we want to flatten the expanded value so that the constructed
152  * tuple doesn't depend on it
153  */
154  data_length = att_align_nominal(data_length, atti->attalign);
155  data_length += EOH_get_flat_size(DatumGetEOHP(val));
156  }
157  else
158  {
159  data_length = att_align_datum(data_length, atti->attalign,
160  atti->attlen, val);
161  data_length = att_addlength_datum(data_length, atti->attlen,
162  val);
163  }
164  }
165 
166  return data_length;
167 }
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:146
#define VARATT_IS_EXTERNAL_EXPANDED(PTR)
Definition: postgres.h:322
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define att_align_datum(cur_offset, attalign, attlen, attdatum)
Definition: tupmacs.h:103
#define VARATT_CAN_MAKE_SHORT(PTR)
Definition: postgres.h:270
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
Size EOH_get_flat_size(ExpandedObjectHeader *eohptr)
Definition: expandeddatum.c:75
ExpandedObjectHeader * DatumGetEOHP(Datum d)
Definition: expandeddatum.c:29
#define VARATT_CONVERTED_SHORT_SIZE(PTR)
Definition: postgres.h:273
uintptr_t Datum
Definition: postgres.h:367
size_t Size
Definition: c.h:466
#define DatumGetPointer(X)
Definition: postgres.h:549
static Datum values[MAXATTR]
Definition: bootstrap.c:167
#define att_addlength_datum(cur_offset, attlen, attdatum)
Definition: tupmacs.h:162
#define ATT_IS_PACKABLE(att)
Definition: heaptuple.c:68
int i
long val
Definition: informix.c:684

◆ heap_copy_minimal_tuple()

MinimalTuple heap_copy_minimal_tuple ( MinimalTuple  mtup)

Definition at line 1439 of file heaptuple.c.

References palloc(), and MinimalTupleData::t_len.

Referenced by tts_minimal_copy_minimal_tuple(), tts_minimal_materialize(), tuplesort_gettupleslot(), and tuplestore_gettupleslot().

1440 {
1441  MinimalTuple result;
1442 
1443  result = (MinimalTuple) palloc(mtup->t_len);
1444  memcpy(result, mtup, mtup->t_len);
1445  return result;
1446 }
MinimalTupleData * MinimalTuple
Definition: htup.h:27
void * palloc(Size size)
Definition: mcxt.c:924

◆ heap_copy_tuple_as_datum()

Datum heap_copy_tuple_as_datum ( HeapTuple  tuple,
TupleDesc  tupleDesc 
)

Definition at line 984 of file heaptuple.c.

References HeapTupleHasExternal, HeapTupleHeaderSetDatumLength, HeapTupleHeaderSetTypeId, HeapTupleHeaderSetTypMod, palloc(), PointerGetDatum, HeapTupleData::t_data, HeapTupleData::t_len, TupleDescData::tdtypeid, TupleDescData::tdtypmod, and toast_flatten_tuple_to_datum().

Referenced by ExecEvalConvertRowtype(), ExecFetchSlotHeapTupleDatum(), PLyGenericObject_ToComposite(), PLyMapping_ToComposite(), PLySequence_ToComposite(), and SPI_returntuple().

985 {
986  HeapTupleHeader td;
987 
988  /*
989  * If the tuple contains any external TOAST pointers, we have to inline
990  * those fields to meet the conventions for composite-type Datums.
991  */
992  if (HeapTupleHasExternal(tuple))
993  return toast_flatten_tuple_to_datum(tuple->t_data,
994  tuple->t_len,
995  tupleDesc);
996 
997  /*
998  * Fast path for easy case: just make a palloc'd copy and insert the
999  * correct composite-Datum header fields (since those may not be set if
1000  * the given tuple came from disk, rather than from heap_form_tuple).
1001  */
1002  td = (HeapTupleHeader) palloc(tuple->t_len);
1003  memcpy((char *) td, (char *) tuple->t_data, tuple->t_len);
1004 
1006  HeapTupleHeaderSetTypeId(td, tupleDesc->tdtypeid);
1007  HeapTupleHeaderSetTypMod(td, tupleDesc->tdtypmod);
1008 
1009  return PointerGetDatum(td);
1010 }
#define HeapTupleHeaderSetTypeId(tup, typeid)
Definition: htup_details.h:463
#define PointerGetDatum(X)
Definition: postgres.h:556
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HeapTupleHeaderSetDatumLength(tup, len)
Definition: htup_details.h:455
HeapTupleHeader t_data
Definition: htup.h:68
int32 tdtypmod
Definition: tupdesc.h:83
uint32 t_len
Definition: htup.h:64
#define HeapTupleHeaderSetTypMod(tup, typmod)
Definition: htup_details.h:473
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
Definition: heaptoast.c:442
Oid tdtypeid
Definition: tupdesc.h:82
#define HeapTupleHasExternal(tuple)
Definition: htup_details.h:673
void * palloc(Size size)
Definition: mcxt.c:924

◆ heap_copytuple()

HeapTuple heap_copytuple ( HeapTuple  tuple)

Definition at line 680 of file heaptuple.c.

References HeapTupleIsValid, HEAPTUPLESIZE, palloc(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.

Referenced by AlterConstraintNamespaces(), AlterDomainValidateConstraint(), AlterExtensionNamespace(), AlterSequence(), AlterTypeOwner(), ATExecAlterConstraint(), ATExecDropConstraint(), ATExecValidateConstraint(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), ConstraintSetParentConstraint(), copytup_cluster(), DefineIndex(), EnableDisableTrigger(), ExecForceStoreHeapTuple(), expanded_record_set_tuple(), get_catalog_object_by_oid(), GetDatabaseTuple(), GetDatabaseTupleByOid(), index_concurrently_swap(), index_update_stats(), make_expanded_record_from_datum(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), RelationInitIndexAccessInfo(), RemoveInheritance(), rename_policy(), RenameEnumLabel(), RenameTableSpace(), renametrig(), RenumberEnumType(), ResetSequence(), rewrite_heap_tuple(), ScanPgRelation(), SearchSysCacheCopy(), SearchSysCacheCopyAttName(), SearchSysCacheCopyAttNum(), shdepChangeDep(), SPI_copytuple(), tts_buffer_heap_copy_heap_tuple(), tts_buffer_heap_materialize(), tts_heap_copy_heap_tuple(), tts_heap_materialize(), TupleQueueReaderNext(), and validatePartitionedIndex().

681 {
682  HeapTuple newTuple;
683 
684  if (!HeapTupleIsValid(tuple) || tuple->t_data == NULL)
685  return NULL;
686 
687  newTuple = (HeapTuple) palloc(HEAPTUPLESIZE + tuple->t_len);
688  newTuple->t_len = tuple->t_len;
689  newTuple->t_self = tuple->t_self;
690  newTuple->t_tableOid = tuple->t_tableOid;
691  newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
692  memcpy((char *) newTuple->t_data, (char *) tuple->t_data, tuple->t_len);
693  return newTuple;
694 }
HeapTupleData * HeapTuple
Definition: htup.h:71
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
HeapTupleHeader t_data
Definition: htup.h:68
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
Oid t_tableOid
Definition: htup.h:66
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
void * palloc(Size size)
Definition: mcxt.c:924
#define HEAPTUPLESIZE
Definition: htup.h:73

◆ heap_copytuple_with_tuple()

void heap_copytuple_with_tuple ( HeapTuple  src,
HeapTuple  dest 
)

Definition at line 706 of file heaptuple.c.

References HeapTupleIsValid, palloc(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.

707 {
708  if (!HeapTupleIsValid(src) || src->t_data == NULL)
709  {
710  dest->t_data = NULL;
711  return;
712  }
713 
714  dest->t_len = src->t_len;
715  dest->t_self = src->t_self;
716  dest->t_tableOid = src->t_tableOid;
717  dest->t_data = (HeapTupleHeader) palloc(src->t_len);
718  memcpy((char *) dest->t_data, (char *) src->t_data, src->t_len);
719 }
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
HeapTupleHeader t_data
Definition: htup.h:68
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
Oid t_tableOid
Definition: htup.h:66
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
void * palloc(Size size)
Definition: mcxt.c:924

◆ heap_deform_tuple()

void heap_deform_tuple ( HeapTuple  tuple,
TupleDesc  tupleDesc,
Datum values,
bool isnull 
)

Definition at line 1249 of file heaptuple.c.

References att_addlength_pointer, att_align_nominal, att_align_pointer, att_isnull, attnum, fetchatt, getmissingattr(), HeapTupleHasNulls, HeapTupleHeaderGetNatts, Min, TupleDescData::natts, HeapTupleHeaderData::t_bits, HeapTupleData::t_data, HeapTupleHeaderData::t_hoff, TupleDescAttr, and values.

Referenced by deconstruct_expanded_record(), exec_move_row(), ExecEvalFieldStoreDeForm(), ExecForceStoreHeapTuple(), ExecForceStoreMinimalTuple(), ExecStoreHeapTupleDatum(), execute_attr_map_tuple(), ExtractReplicaIdentity(), heap_modify_tuple(), heap_modify_tuple_by_cols(), hstore_from_record(), hstore_populate_record(), logicalrep_write_tuple(), make_tuple_indirect(), populate_record(), record_cmp(), record_eq(), record_image_cmp(), record_image_eq(), record_out(), record_send(), reform_and_rewrite_tuple(), ReorderBufferToastReplace(), RI_Initial_Check(), RI_PartitionRemove_Check(), SPI_modifytuple(), toast_delete(), toast_flatten_tuple(), toast_flatten_tuple_to_datum(), and toast_insert_or_update().

1251 {
1252  HeapTupleHeader tup = tuple->t_data;
1253  bool hasnulls = HeapTupleHasNulls(tuple);
1254  int tdesc_natts = tupleDesc->natts;
1255  int natts; /* number of atts to extract */
1256  int attnum;
1257  char *tp; /* ptr to tuple data */
1258  uint32 off; /* offset in tuple data */
1259  bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
1260  bool slow = false; /* can we use/set attcacheoff? */
1261 
1262  natts = HeapTupleHeaderGetNatts(tup);
1263 
1264  /*
1265  * In inheritance situations, it is possible that the given tuple actually
1266  * has more fields than the caller is expecting. Don't run off the end of
1267  * the caller's arrays.
1268  */
1269  natts = Min(natts, tdesc_natts);
1270 
1271  tp = (char *) tup + tup->t_hoff;
1272 
1273  off = 0;
1274 
1275  for (attnum = 0; attnum < natts; attnum++)
1276  {
1277  Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
1278 
1279  if (hasnulls && att_isnull(attnum, bp))
1280  {
1281  values[attnum] = (Datum) 0;
1282  isnull[attnum] = true;
1283  slow = true; /* can't use attcacheoff anymore */
1284  continue;
1285  }
1286 
1287  isnull[attnum] = false;
1288 
1289  if (!slow && thisatt->attcacheoff >= 0)
1290  off = thisatt->attcacheoff;
1291  else if (thisatt->attlen == -1)
1292  {
1293  /*
1294  * We can only cache the offset for a varlena attribute if the
1295  * offset is already suitably aligned, so that there would be no
1296  * pad bytes in any case: then the offset will be valid for either
1297  * an aligned or unaligned value.
1298  */
1299  if (!slow &&
1300  off == att_align_nominal(off, thisatt->attalign))
1301  thisatt->attcacheoff = off;
1302  else
1303  {
1304  off = att_align_pointer(off, thisatt->attalign, -1,
1305  tp + off);
1306  slow = true;
1307  }
1308  }
1309  else
1310  {
1311  /* not varlena, so safe to use att_align_nominal */
1312  off = att_align_nominal(off, thisatt->attalign);
1313 
1314  if (!slow)
1315  thisatt->attcacheoff = off;
1316  }
1317 
1318  values[attnum] = fetchatt(thisatt, tp + off);
1319 
1320  off = att_addlength_pointer(off, thisatt->attlen, tp + off);
1321 
1322  if (thisatt->attlen <= 0)
1323  slow = true; /* can't use attcacheoff anymore */
1324  }
1325 
1326  /*
1327  * If tuple doesn't have all the atts indicated by tupleDesc, read the
1328  * rest as nulls or missing values as appropriate.
1329  */
1330  for (; attnum < tdesc_natts; attnum++)
1331  values[attnum] = getmissingattr(tupleDesc, attnum + 1, &isnull[attnum]);
1332 }
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:146
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:177
Datum getmissingattr(TupleDesc tupleDesc, int attnum, bool *isnull)
Definition: heaptuple.c:84
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:23
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define Min(x, y)
Definition: c.h:904
#define fetchatt(A, T)
Definition: tupmacs.h:39
HeapTupleHeader t_data
Definition: htup.h:68
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:531
#define HeapTupleHasNulls(tuple)
Definition: htup_details.h:661
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
unsigned int uint32
Definition: c.h:358
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:174
uint8 bits8
Definition: c.h:365
uintptr_t Datum
Definition: postgres.h:367
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
Definition: tupmacs.h:124
int16 attnum
Definition: pg_attribute.h:79
static Datum values[MAXATTR]
Definition: bootstrap.c:167

◆ heap_expand_tuple()

HeapTuple heap_expand_tuple ( HeapTuple  sourceTuple,
TupleDesc  tupleDesc 
)

Definition at line 969 of file heaptuple.c.

References expand_tuple().

970 {
971  HeapTuple heapTuple;
972 
973  expand_tuple(&heapTuple, NULL, sourceTuple, tupleDesc);
974  return heapTuple;
975 }
static void expand_tuple(HeapTuple *targetHeapTuple, MinimalTuple *targetMinimalTuple, HeapTuple sourceTuple, TupleDesc tupleDesc)
Definition: heaptuple.c:732

◆ heap_fill_tuple()

void heap_fill_tuple ( TupleDesc  tupleDesc,
Datum values,
bool isnull,
char *  data,
Size  data_size,
uint16 infomask,
bits8 bit 
)

Definition at line 304 of file heaptuple.c.

References Assert, fill_val(), HEAP_HASEXTERNAL, HEAP_HASNULL, HEAP_HASVARWIDTH, HIGHBIT, i, TupleDescData::natts, PointerGetDatum, and TupleDescAttr.

Referenced by brin_form_tuple(), ER_flatten_into(), heap_form_minimal_tuple(), heap_form_tuple(), index_form_tuple(), toast_flatten_tuple_to_datum(), and toast_insert_or_update().

308 {
309  bits8 *bitP;
310  int bitmask;
311  int i;
312  int numberOfAttributes = tupleDesc->natts;
313 
314 #ifdef USE_ASSERT_CHECKING
315  char *start = data;
316 #endif
317 
318  if (bit != NULL)
319  {
320  bitP = &bit[-1];
321  bitmask = HIGHBIT;
322  }
323  else
324  {
325  /* just to keep compiler quiet */
326  bitP = NULL;
327  bitmask = 0;
328  }
329 
330  *infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTERNAL);
331 
332  for (i = 0; i < numberOfAttributes; i++)
333  {
334  Form_pg_attribute attr = TupleDescAttr(tupleDesc, i);
335 
336  fill_val(attr,
337  bitP ? &bitP : NULL,
338  &bitmask,
339  &data,
340  infomask,
341  values ? values[i] : PointerGetDatum(NULL),
342  isnull ? isnull[i] : true);
343  }
344 
345  Assert((data - start) == data_size);
346 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
static void fill_val(Form_pg_attribute att, bits8 **bit, int *bitmask, char **dataP, uint16 *infomask, Datum datum, bool isnull)
Definition: heaptuple.c:175
#define HEAP_HASNULL
Definition: htup_details.h:189
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
#define HEAP_HASVARWIDTH
Definition: htup_details.h:190
#define HIGHBIT
Definition: c.h:1074
uint8 bits8
Definition: c.h:365
Datum bit(PG_FUNCTION_ARGS)
Definition: varbit.c:363
#define Assert(condition)
Definition: c.h:732
static Datum values[MAXATTR]
Definition: bootstrap.c:167
int i
#define HEAP_HASEXTERNAL
Definition: htup_details.h:191

◆ heap_form_minimal_tuple()

MinimalTuple heap_form_minimal_tuple ( TupleDesc  tupleDescriptor,
Datum values,
bool isnull 
)

Definition at line 1356 of file heaptuple.c.

References BITMAPLEN, ereport, errcode(), errmsg(), ERROR, heap_compute_data_size(), heap_fill_tuple(), HeapTupleHeaderSetNatts, i, MAXALIGN, MaxTupleAttributeNumber, MINIMAL_TUPLE_OFFSET, TupleDescData::natts, palloc0(), SizeofMinimalTupleHeader, MinimalTupleData::t_bits, MinimalTupleData::t_hoff, MinimalTupleData::t_infomask, and MinimalTupleData::t_len.

Referenced by tts_minimal_materialize(), tts_virtual_copy_minimal_tuple(), and tuplestore_putvalues().

1359 {
1360  MinimalTuple tuple; /* return tuple */
1361  Size len,
1362  data_len;
1363  int hoff;
1364  bool hasnull = false;
1365  int numberOfAttributes = tupleDescriptor->natts;
1366  int i;
1367 
1368  if (numberOfAttributes > MaxTupleAttributeNumber)
1369  ereport(ERROR,
1370  (errcode(ERRCODE_TOO_MANY_COLUMNS),
1371  errmsg("number of columns (%d) exceeds limit (%d)",
1372  numberOfAttributes, MaxTupleAttributeNumber)));
1373 
1374  /*
1375  * Check for nulls
1376  */
1377  for (i = 0; i < numberOfAttributes; i++)
1378  {
1379  if (isnull[i])
1380  {
1381  hasnull = true;
1382  break;
1383  }
1384  }
1385 
1386  /*
1387  * Determine total space needed
1388  */
1390 
1391  if (hasnull)
1392  len += BITMAPLEN(numberOfAttributes);
1393 
1394  hoff = len = MAXALIGN(len); /* align user data safely */
1395 
1396  data_len = heap_compute_data_size(tupleDescriptor, values, isnull);
1397 
1398  len += data_len;
1399 
1400  /*
1401  * Allocate and zero the space needed.
1402  */
1403  tuple = (MinimalTuple) palloc0(len);
1404 
1405  /*
1406  * And fill in the information.
1407  */
1408  tuple->t_len = len;
1409  HeapTupleHeaderSetNatts(tuple, numberOfAttributes);
1410  tuple->t_hoff = hoff + MINIMAL_TUPLE_OFFSET;
1411 
1412  heap_fill_tuple(tupleDescriptor,
1413  values,
1414  isnull,
1415  (char *) tuple + hoff,
1416  data_len,
1417  &tuple->t_infomask,
1418  (hasnull ? tuple->t_bits : NULL));
1419 
1420  return tuple;
1421 }
void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
Definition: heaptuple.c:304
#define MaxTupleAttributeNumber
Definition: htup_details.h:33
int errcode(int sqlerrcode)
Definition: elog.c:570
#define BITMAPLEN(NATTS)
Definition: htup_details.h:547
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:642
#define ERROR
Definition: elog.h:43
MinimalTupleData * MinimalTuple
Definition: htup.h:27
#define ereport(elevel, rest)
Definition: elog.h:141
#define SizeofMinimalTupleHeader
Definition: htup_details.h:649
void * palloc0(Size size)
Definition: mcxt.c:955
#define HeapTupleHeaderSetNatts(tup, natts)
Definition: htup_details.h:534
size_t Size
Definition: c.h:466
#define MAXALIGN(LEN)
Definition: c.h:685
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:619
Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:119
static Datum values[MAXATTR]
Definition: bootstrap.c:167
int errmsg(const char *fmt,...)
Definition: elog.c:784
int i

◆ heap_form_tuple()

HeapTuple heap_form_tuple ( TupleDesc  tupleDescriptor,
Datum values,
bool isnull 
)

Definition at line 1020 of file heaptuple.c.

References BITMAPLEN, ereport, errcode(), errmsg(), ERROR, heap_compute_data_size(), heap_fill_tuple(), HeapTupleHeaderSetDatumLength, HeapTupleHeaderSetNatts, HeapTupleHeaderSetTypeId, HeapTupleHeaderSetTypMod, HEAPTUPLESIZE, i, InvalidOid, ItemPointerSetInvalid, MAXALIGN, MaxTupleAttributeNumber, TupleDescData::natts, offsetof, palloc0(), HeapTupleHeaderData::t_bits, HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleHeaderData::t_hoff, HeapTupleHeaderData::t_infomask, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, TupleDescData::tdtypeid, and TupleDescData::tdtypmod.

Referenced by aclexplode(), AddEnumLabel(), AddRoleMems(), AddSubscriptionRelState(), AggregateCreate(), AlterSetting(), brin_metapage_info(), BuildTupleFromCStrings(), CollationCreate(), ConversionCreate(), copy_replication_slot(), create_proc_lang(), CreateAccessMethod(), CreateCast(), CreateComments(), CreateConstraintEntry(), createdb(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateOpFamily(), CreatePolicy(), CreatePublication(), CreateRole(), CreateSharedComments(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), DefineOpClass(), DefineSequence(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), elements_worker_jsonb(), EnumValuesCreate(), ExecEvalFieldStoreForm(), ExecEvalRow(), execute_attr_map_tuple(), expanded_record_get_tuple(), ExtractReplicaIdentity(), file_acquire_sample_rows(), fill_hba_line(), gin_leafpage_items(), gin_metapage_info(), gin_page_opaque_info(), gistFetchTuple(), hash_bitmap_info(), hash_metapage_info(), hash_page_items(), hash_page_stats(), heap_modify_tuple(), heap_modify_tuple_by_cols(), heap_page_items(), hstore_each(), hstore_populate_record(), IndexSetParentIndex(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertOneTuple(), InsertPgAttributeTuple(), InsertPgClassTuple(), InsertRule(), inv_truncate(), inv_write(), LargeObjectCreate(), make_tuple_from_result_row(), make_tuple_from_row(), make_tuple_indirect(), MakeConfigurationMapping(), NamespaceCreate(), OperatorCreate(), OperatorShellMake(), page_header(), pg_buffercache_pages(), pg_control_checkpoint(), pg_control_init(), pg_control_recovery(), pg_control_system(), pg_create_logical_replication_slot(), pg_create_physical_replication_slot(), pg_get_object_address(), pg_identify_object(), pg_identify_object_as_address(), pg_last_committed_xact(), pg_lock_status(), pg_ls_dir_files(), pg_partition_tree(), pg_prepared_xact(), pg_replication_slot_advance(), pg_sequence_parameters(), pg_stat_file(), pg_stat_get_archiver(), pg_stat_get_wal_receiver(), pg_stats_ext_mcvlist_items(), pg_timezone_abbrevs(), pg_timezone_names(), pg_visibility(), pg_visibility_map(), pg_visibility_map_rel(), pg_visibility_map_summary(), pg_visibility_rel(), pg_walfile_name_offset(), pgstatginindex_internal(), pgstathashindex(), pgstattuple_approx_internal(), plperl_build_tuple_result(), PLyGenericObject_ToComposite(), PLyMapping_ToComposite(), PLySequence_ToComposite(), populate_record(), ProcedureCreate(), publication_add_relation(), RangeCreate(), record_in(), record_recv(), recordExtensionInitPrivWorker(), recordMultipleDependencies(), reform_and_rewrite_tuple(), ReorderBufferToastReplace(), replorigin_create(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepAddDependency(), shdepChangeDep(), SPI_modifytuple(), ssl_extension_info(), StoreAttrDefault(), storeGettuple(), storeOperators(), StorePartitionKey(), storeProcedures(), StoreSingleInheritance(), test_predtest(), toast_build_flattened_tuple(), toast_flatten_tuple(), toast_save_datum(), tsvector_unnest(), tts_buffer_heap_materialize(), tts_heap_materialize(), tts_virtual_copy_heap_tuple(), TypeCreate(), TypeShellMake(), update_attstats(), and UpdateIndexRelation().

1023 {
1024  HeapTuple tuple; /* return tuple */
1025  HeapTupleHeader td; /* tuple data */
1026  Size len,
1027  data_len;
1028  int hoff;
1029  bool hasnull = false;
1030  int numberOfAttributes = tupleDescriptor->natts;
1031  int i;
1032 
1033  if (numberOfAttributes > MaxTupleAttributeNumber)
1034  ereport(ERROR,
1035  (errcode(ERRCODE_TOO_MANY_COLUMNS),
1036  errmsg("number of columns (%d) exceeds limit (%d)",
1037  numberOfAttributes, MaxTupleAttributeNumber)));
1038 
1039  /*
1040  * Check for nulls
1041  */
1042  for (i = 0; i < numberOfAttributes; i++)
1043  {
1044  if (isnull[i])
1045  {
1046  hasnull = true;
1047  break;
1048  }
1049  }
1050 
1051  /*
1052  * Determine total space needed
1053  */
1054  len = offsetof(HeapTupleHeaderData, t_bits);
1055 
1056  if (hasnull)
1057  len += BITMAPLEN(numberOfAttributes);
1058 
1059  hoff = len = MAXALIGN(len); /* align user data safely */
1060 
1061  data_len = heap_compute_data_size(tupleDescriptor, values, isnull);
1062 
1063  len += data_len;
1064 
1065  /*
1066  * Allocate and zero the space needed. Note that the tuple body and
1067  * HeapTupleData management structure are allocated in one chunk.
1068  */
1069  tuple = (HeapTuple) palloc0(HEAPTUPLESIZE + len);
1070  tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
1071 
1072  /*
1073  * And fill in the information. Note we fill the Datum fields even though
1074  * this tuple may never become a Datum. This lets HeapTupleHeaderGetDatum
1075  * identify the tuple type if needed.
1076  */
1077  tuple->t_len = len;
1078  ItemPointerSetInvalid(&(tuple->t_self));
1079  tuple->t_tableOid = InvalidOid;
1080 
1082  HeapTupleHeaderSetTypeId(td, tupleDescriptor->tdtypeid);
1083  HeapTupleHeaderSetTypMod(td, tupleDescriptor->tdtypmod);
1084  /* We also make sure that t_ctid is invalid unless explicitly set */
1085  ItemPointerSetInvalid(&(td->t_ctid));
1086 
1087  HeapTupleHeaderSetNatts(td, numberOfAttributes);
1088  td->t_hoff = hoff;
1089 
1090  heap_fill_tuple(tupleDescriptor,
1091  values,
1092  isnull,
1093  (char *) td + hoff,
1094  data_len,
1095  &td->t_infomask,
1096  (hasnull ? td->t_bits : NULL));
1097 
1098  return tuple;
1099 }
void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
Definition: heaptuple.c:304
HeapTupleData * HeapTuple
Definition: htup.h:71
#define HeapTupleHeaderSetTypeId(tup, typeid)
Definition: htup_details.h:463
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:177
#define MaxTupleAttributeNumber
Definition: htup_details.h:33
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
int errcode(int sqlerrcode)
Definition: elog.c:570
#define BITMAPLEN(NATTS)
Definition: htup_details.h:547
#define HeapTupleHeaderSetDatumLength(tup, len)
Definition: htup_details.h:455
HeapTupleHeader t_data
Definition: htup.h:68
#define ERROR
Definition: elog.h:43
int32 tdtypmod
Definition: tupdesc.h:83
ItemPointerData t_ctid
Definition: htup_details.h:160
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
Oid t_tableOid
Definition: htup.h:66
#define ereport(elevel, rest)
Definition: elog.h:141
void * palloc0(Size size)
Definition: mcxt.c:955
#define HeapTupleHeaderSetTypMod(tup, typmod)
Definition: htup_details.h:473
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleHeaderSetNatts(tup, natts)
Definition: htup_details.h:534
size_t Size
Definition: c.h:466
#define MAXALIGN(LEN)
Definition: c.h:685
Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:119
static Datum values[MAXATTR]
Definition: bootstrap.c:167
Oid tdtypeid
Definition: tupdesc.h:82
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
int errmsg(const char *fmt,...)
Definition: elog.c:784
#define HEAPTUPLESIZE
Definition: htup.h:73
int i
#define offsetof(type, field)
Definition: c.h:655

◆ heap_free_minimal_tuple()

void heap_free_minimal_tuple ( MinimalTuple  mtup)

◆ heap_freetuple()

void heap_freetuple ( HeapTuple  htup)

Definition at line 1338 of file heaptuple.c.

References pfree().

Referenced by acquire_inherited_sample_rows(), acquire_sample_rows(), AddEnumLabel(), AddSubscriptionRelState(), AfterTriggerExecute(), AlterCollation(), AlterDatabaseOwner(), AlterDomainDefault(), AlterDomainNotNull(), AlterDomainValidateConstraint(), AlterEventTrigger(), AlterEventTriggerOwner(), AlterEventTriggerOwner_oid(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner(), AlterForeignDataWrapperOwner_oid(), AlterForeignServer(), AlterForeignServerOwner(), AlterForeignServerOwner_oid(), AlterFunction(), AlterObjectRename_internal(), AlterPolicy(), AlterPublication(), AlterPublicationOwner(), AlterPublicationOwner_oid(), AlterRelationNamespaceInternal(), AlterRole(), AlterSchemaOwner_internal(), AlterStatistics(), AlterSubscription(), AlterSubscriptionOwner(), AlterSubscriptionOwner_oid(), AlterTableSpaceOptions(), AlterTSDictionary(), AlterTypeNamespaceInternal(), AlterUserMapping(), analyze_row_processor(), ATExecAddColumn(), ATExecAddIdentity(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecChangeOwner(), ATExecDetachPartition(), ATExecDisableRowSecurity(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropIdentity(), ATExecDropOf(), ATExecEnableRowSecurity(), ATExecForceNoForceRowSecurity(), ATExecGenericOptions(), ATExecSetIdentity(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecSetTableSpace(), ATExecSetTableSpaceNoStorage(), ATExecValidateConstraint(), build_tuplestore_recursively(), CatalogCacheCreateEntry(), change_owner_fix_column_acls(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), CollationCreate(), ConversionCreate(), copy_table_data(), copyTemplateDependencies(), create_toast_table(), CreateAccessMethod(), CreateCast(), CreateComments(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateOpFamily(), CreatePolicy(), CreatePublication(), CreateSharedComments(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), crosstab(), DefineIndex(), DefineOpClass(), DefineQueryRewrite(), DefineSequence(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), EnableDisableRule(), EnableDisableTrigger(), EnumValuesCreate(), examine_attribute(), exec_stmt_return_query(), ExecBRDeleteTriggers(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecIRDeleteTriggers(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecReScanAgg(), ExecReScanSetOp(), ExecScanSubPlan(), ExecSetParamPlan(), expanded_record_set_tuple(), ExtractReplicaIdentity(), file_acquire_sample_rows(), gather_merge_clear_tuples(), heap_delete(), heap_insert(), heap_update(), index_build(), index_concurrently_swap(), index_constraint_create(), index_update_stats(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertOneTuple(), InsertPgAttributeTuple(), InsertPgClassTuple(), InsertRule(), inv_truncate(), inv_write(), LargeObjectCreate(), MakeConfigurationMapping(), mark_index_clustered(), MergeAttributesIntoExisting(), MergeConstraintsIntoExisting(), OperatorShellMake(), PLyGenericObject_ToComposite(), PLyMapping_ToComposite(), PLySequence_ToComposite(), ProcedureCreate(), publication_add_relation(), RangeCreate(), raw_heap_insert(), record_in(), record_recv(), recordMultipleDependencies(), reform_and_rewrite_tuple(), relation_mark_replica_identity(), RelationBuildDesc(), RelationClearMissing(), RelationInitPhysicalAddr(), RelationReloadIndexInfo(), RelationReloadNailed(), RelationSetNewRelfilenode(), RemoveConstraintById(), RemoveInheritance(), RemoveRoleFromObjectPolicy(), renameatt_internal(), RenameConstraintById(), RenameEnumLabel(), RenameRelationInternal(), RenameRewriteRule(), RenameSchema(), RenameTypeInternal(), RenumberEnumType(), replorigin_create(), rewrite_heap_dead_tuple(), rewrite_heap_tuple(), SetMatViewPopulatedState(), SetRelationHasSubclass(), SetRelationNumChecks(), SetRelationRuleStatus(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepAddDependency(), shdepChangeDep(), SPI_freetuple(), statext_store(), StoreAttrDefault(), storeOperators(), StorePartitionBound(), storeProcedures(), StoreSingleInheritance(), swap_relation_files(), table_recheck_autovac(), toast_save_datum(), tqueueReceiveSlot(), tts_buffer_heap_clear(), tts_buffer_heap_store_tuple(), tts_heap_clear(), TypeShellMake(), update_attstats(), update_default_partition_oid(), update_relispartition(), UpdateIndexRelation(), UpdateStatisticsForTypeChange(), vac_update_datfrozenxid(), writetup_cluster(), and xpath_table().

1339 {
1340  pfree(htup);
1341 }
void pfree(void *pointer)
Definition: mcxt.c:1031

◆ heap_getsysattr()

Datum heap_getsysattr ( HeapTuple  tup,
int  attnum,
TupleDesc  tupleDesc,
bool isnull 
)

Definition at line 627 of file heaptuple.c.

References Assert, CommandIdGetDatum, elog, ERROR, HeapTupleHeaderGetRawCommandId, HeapTupleHeaderGetRawXmax, HeapTupleHeaderGetRawXmin, MaxCommandIdAttributeNumber, MaxTransactionIdAttributeNumber, MinCommandIdAttributeNumber, MinTransactionIdAttributeNumber, ObjectIdGetDatum, PointerGetDatum, SelfItemPointerAttributeNumber, HeapTupleData::t_data, HeapTupleData::t_self, HeapTupleData::t_tableOid, TableOidAttributeNumber, and TransactionIdGetDatum.

Referenced by expanded_record_fetch_field(), tts_buffer_heap_getsysattr(), and tts_heap_getsysattr().

628 {
629  Datum result;
630 
631  Assert(tup);
632 
633  /* Currently, no sys attribute ever reads as NULL. */
634  *isnull = false;
635 
636  switch (attnum)
637  {
639  /* pass-by-reference datatype */
640  result = PointerGetDatum(&(tup->t_self));
641  break;
644  break;
647  break;
650 
651  /*
652  * cmin and cmax are now both aliases for the same field, which
653  * can in fact also be a combo command id. XXX perhaps we should
654  * return the "real" cmin or cmax if possible, that is if we are
655  * inside the originating transaction?
656  */
658  break;
660  result = ObjectIdGetDatum(tup->t_tableOid);
661  break;
662  default:
663  elog(ERROR, "invalid attnum: %d", attnum);
664  result = 0; /* keep compiler quiet */
665  break;
666  }
667  return result;
668 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define MinCommandIdAttributeNumber
Definition: sysattr.h:23
HeapTupleHeader t_data
Definition: htup.h:68
#define HeapTupleHeaderGetRawXmax(tup)
Definition: htup_details.h:375
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
ItemPointerData t_self
Definition: htup.h:65
#define TableOidAttributeNumber
Definition: sysattr.h:26
Oid t_tableOid
Definition: htup.h:66
#define MaxCommandIdAttributeNumber
Definition: sysattr.h:25
#define MaxTransactionIdAttributeNumber
Definition: sysattr.h:24
#define TransactionIdGetDatum(X)
Definition: postgres.h:521
uintptr_t Datum
Definition: postgres.h:367
int16 attnum
Definition: pg_attribute.h:79
#define Assert(condition)
Definition: c.h:732
#define HeapTupleHeaderGetRawXmin(tup)
Definition: htup_details.h:308
#define HeapTupleHeaderGetRawCommandId(tup)
Definition: htup_details.h:391
#define elog(elevel,...)
Definition: elog.h:226
#define CommandIdGetDatum(X)
Definition: postgres.h:542
#define SelfItemPointerAttributeNumber
Definition: sysattr.h:21
#define MinTransactionIdAttributeNumber
Definition: sysattr.h:22

◆ heap_modify_tuple()

HeapTuple heap_modify_tuple ( HeapTuple  tuple,
TupleDesc  tupleDesc,
Datum replValues,
bool replIsnull,
bool doReplace 
)

Definition at line 1113 of file heaptuple.c.

References heap_deform_tuple(), heap_form_tuple(), TupleDescData::natts, palloc(), pfree(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleData::t_self, HeapTupleData::t_tableOid, and values.

Referenced by AddRoleMems(), AggregateCreate(), AlterCollation(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDefault(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPolicy(), AlterPublicationOptions(), AlterRole(), AlterSchemaOwner_internal(), AlterSetting(), AlterStatistics(), AlterSubscription(), AlterTableSpaceOptions(), AlterTSDictionary(), AlterTypeOwnerInternal(), AlterUserMapping(), ApplyExtensionUpdates(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecChangeOwner(), ATExecDetachPartition(), ATExecGenericOptions(), ATExecSetOptions(), ATExecSetRelOptions(), change_owner_fix_column_acls(), copyTemplateDependencies(), create_proc_lang(), CreateComments(), CreateSharedComments(), CreateTransform(), DelRoleMems(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), extension_config_remove(), index_concurrently_swap(), InsertRule(), inv_truncate(), inv_write(), MakeConfigurationMapping(), movedb(), OperatorCreate(), pg_extension_config_dump(), plperl_modify_tuple(), PLy_modify_tuple(), ProcedureCreate(), recordExtensionInitPrivWorker(), RelationClearMissing(), RemoveAttributeById(), RemoveRoleFromObjectPolicy(), RenameRole(), SetAttrMissing(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), statext_store(), StoreAttrDefault(), StorePartitionBound(), TypeCreate(), update_attstats(), UpdateStatisticsForTypeChange(), and UpdateSubscriptionRelState().

1118 {
1119  int numberOfAttributes = tupleDesc->natts;
1120  int attoff;
1121  Datum *values;
1122  bool *isnull;
1123  HeapTuple newTuple;
1124 
1125  /*
1126  * allocate and fill values and isnull arrays from either the tuple or the
1127  * repl information, as appropriate.
1128  *
1129  * NOTE: it's debatable whether to use heap_deform_tuple() here or just
1130  * heap_getattr() only the non-replaced columns. The latter could win if
1131  * there are many replaced columns and few non-replaced ones. However,
1132  * heap_deform_tuple costs only O(N) while the heap_getattr way would cost
1133  * O(N^2) if there are many non-replaced columns, so it seems better to
1134  * err on the side of linear cost.
1135  */
1136  values = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
1137  isnull = (bool *) palloc(numberOfAttributes * sizeof(bool));
1138 
1139  heap_deform_tuple(tuple, tupleDesc, values, isnull);
1140 
1141  for (attoff = 0; attoff < numberOfAttributes; attoff++)
1142  {
1143  if (doReplace[attoff])
1144  {
1145  values[attoff] = replValues[attoff];
1146  isnull[attoff] = replIsnull[attoff];
1147  }
1148  }
1149 
1150  /*
1151  * create a new tuple from the values and isnull arrays
1152  */
1153  newTuple = heap_form_tuple(tupleDesc, values, isnull);
1154 
1155  pfree(values);
1156  pfree(isnull);
1157 
1158  /*
1159  * copy the identification info of the old tuple: t_ctid, t_self
1160  */
1161  newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
1162  newTuple->t_self = tuple->t_self;
1163  newTuple->t_tableOid = tuple->t_tableOid;
1164 
1165  return newTuple;
1166 }
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
HeapTupleHeader t_data
Definition: htup.h:68
void pfree(void *pointer)
Definition: mcxt.c:1031
ItemPointerData t_ctid
Definition: htup_details.h:160
ItemPointerData t_self
Definition: htup.h:65
Oid t_tableOid
Definition: htup.h:66
uintptr_t Datum
Definition: postgres.h:367
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
static Datum values[MAXATTR]
Definition: bootstrap.c:167
void * palloc(Size size)
Definition: mcxt.c:924

◆ heap_modify_tuple_by_cols()

HeapTuple heap_modify_tuple_by_cols ( HeapTuple  tuple,
TupleDesc  tupleDesc,
int  nCols,
int *  replCols,
Datum replValues,
bool replIsnull 
)

Definition at line 1181 of file heaptuple.c.

References attnum, elog, ERROR, heap_deform_tuple(), heap_form_tuple(), i, TupleDescData::natts, palloc(), pfree(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleData::t_self, HeapTupleData::t_tableOid, and values.

Referenced by autoinc(), insert_username(), moddatetime(), and tsvector_update_trigger().

1187 {
1188  int numberOfAttributes = tupleDesc->natts;
1189  Datum *values;
1190  bool *isnull;
1191  HeapTuple newTuple;
1192  int i;
1193 
1194  /*
1195  * allocate and fill values and isnull arrays from the tuple, then replace
1196  * selected columns from the input arrays.
1197  */
1198  values = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
1199  isnull = (bool *) palloc(numberOfAttributes * sizeof(bool));
1200 
1201  heap_deform_tuple(tuple, tupleDesc, values, isnull);
1202 
1203  for (i = 0; i < nCols; i++)
1204  {
1205  int attnum = replCols[i];
1206 
1207  if (attnum <= 0 || attnum > numberOfAttributes)
1208  elog(ERROR, "invalid column number %d", attnum);
1209  values[attnum - 1] = replValues[i];
1210  isnull[attnum - 1] = replIsnull[i];
1211  }
1212 
1213  /*
1214  * create a new tuple from the values and isnull arrays
1215  */
1216  newTuple = heap_form_tuple(tupleDesc, values, isnull);
1217 
1218  pfree(values);
1219  pfree(isnull);
1220 
1221  /*
1222  * copy the identification info of the old tuple: t_ctid, t_self
1223  */
1224  newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
1225  newTuple->t_self = tuple->t_self;
1226  newTuple->t_tableOid = tuple->t_tableOid;
1227 
1228  return newTuple;
1229 }
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
HeapTupleHeader t_data
Definition: htup.h:68
void pfree(void *pointer)
Definition: mcxt.c:1031
#define ERROR
Definition: elog.h:43
ItemPointerData t_ctid
Definition: htup_details.h:160
ItemPointerData t_self
Definition: htup.h:65
Oid t_tableOid
Definition: htup.h:66
uintptr_t Datum
Definition: postgres.h:367
int16 attnum
Definition: pg_attribute.h:79
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:1249
static Datum values[MAXATTR]
Definition: bootstrap.c:167
void * palloc(Size size)
Definition: mcxt.c:924
#define elog(elevel,...)
Definition: elog.h:226
int i

◆ heap_tuple_from_minimal_tuple()

HeapTuple heap_tuple_from_minimal_tuple ( MinimalTuple  mtup)

Definition at line 1458 of file heaptuple.c.

References HEAPTUPLESIZE, InvalidOid, ItemPointerSetInvalid, MINIMAL_TUPLE_OFFSET, offsetof, palloc(), HeapTupleData::t_data, HeapTupleData::t_len, MinimalTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.

Referenced by tts_minimal_copy_heap_tuple().

1459 {
1460  HeapTuple result;
1461  uint32 len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
1462 
1463  result = (HeapTuple) palloc(HEAPTUPLESIZE + len);
1464  result->t_len = len;
1465  ItemPointerSetInvalid(&(result->t_self));
1466  result->t_tableOid = InvalidOid;
1467  result->t_data = (HeapTupleHeader) ((char *) result + HEAPTUPLESIZE);
1468  memcpy((char *) result->t_data + MINIMAL_TUPLE_OFFSET, mtup, mtup->t_len);
1469  memset(result->t_data, 0, offsetof(HeapTupleHeaderData, t_infomask2));
1470  return result;
1471 }
HeapTupleData * HeapTuple
Definition: htup.h:71
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
HeapTupleHeader t_data
Definition: htup.h:68
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
unsigned int uint32
Definition: c.h:358
Oid t_tableOid
Definition: htup.h:66
#define InvalidOid
Definition: postgres_ext.h:36
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:619
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:172
void * palloc(Size size)
Definition: mcxt.c:924
#define HEAPTUPLESIZE
Definition: htup.h:73
#define offsetof(type, field)
Definition: c.h:655

◆ minimal_expand_tuple()

MinimalTuple minimal_expand_tuple ( HeapTuple  sourceTuple,
TupleDesc  tupleDesc 
)

Definition at line 957 of file heaptuple.c.

References expand_tuple().

958 {
959  MinimalTuple minimalTuple;
960 
961  expand_tuple(NULL, &minimalTuple, sourceTuple, tupleDesc);
962  return minimalTuple;
963 }
static void expand_tuple(HeapTuple *targetHeapTuple, MinimalTuple *targetMinimalTuple, HeapTuple sourceTuple, TupleDesc tupleDesc)
Definition: heaptuple.c:732

◆ minimal_tuple_from_heap_tuple()

MinimalTuple minimal_tuple_from_heap_tuple ( HeapTuple  htup)

Definition at line 1480 of file heaptuple.c.

References Assert, MINIMAL_TUPLE_OFFSET, palloc(), HeapTupleData::t_data, HeapTupleData::t_len, and MinimalTupleData::t_len.

Referenced by copytup_heap(), tts_buffer_heap_copy_minimal_tuple(), and tts_heap_copy_minimal_tuple().

1481 {
1482  MinimalTuple result;
1483  uint32 len;
1484 
1486  len = htup->t_len - MINIMAL_TUPLE_OFFSET;
1487  result = (MinimalTuple) palloc(len);
1488  memcpy(result, (char *) htup->t_data + MINIMAL_TUPLE_OFFSET, len);
1489  result->t_len = len;
1490  return result;
1491 }
HeapTupleHeader t_data
Definition: htup.h:68
uint32 t_len
Definition: htup.h:64
MinimalTupleData * MinimalTuple
Definition: htup.h:27
unsigned int uint32
Definition: c.h:358
#define Assert(condition)
Definition: c.h:732
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:619
void * palloc(Size size)
Definition: mcxt.c:924

◆ nocachegetattr()

Datum nocachegetattr ( HeapTuple  tup,
int  attnum,
TupleDesc  att 
)

Definition at line 423 of file heaptuple.c.

References Assert, att_addlength_pointer, att_align_nominal, att_align_pointer, att_isnull, attlen, attnum, byte, fetchatt, HeapTupleHasNulls, HeapTupleHasVarWidth, HeapTupleNoNulls, i, TupleDescData::natts, HeapTupleHeaderData::t_bits, HeapTupleData::t_data, HeapTupleHeaderData::t_hoff, and TupleDescAttr.

Referenced by heapgettup_pagemode().

426 {
427  HeapTupleHeader tup = tuple->t_data;
428  char *tp; /* ptr to data part of tuple */
429  bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
430  bool slow = false; /* do we have to walk attrs? */
431  int off; /* current offset within data */
432 
433  /* ----------------
434  * Three cases:
435  *
436  * 1: No nulls and no variable-width attributes.
437  * 2: Has a null or a var-width AFTER att.
438  * 3: Has nulls or var-widths BEFORE att.
439  * ----------------
440  */
441 
442  attnum--;
443 
444  if (!HeapTupleNoNulls(tuple))
445  {
446  /*
447  * there's a null somewhere in the tuple
448  *
449  * check to see if any preceding bits are null...
450  */
451  int byte = attnum >> 3;
452  int finalbit = attnum & 0x07;
453 
454  /* check for nulls "before" final bit of last byte */
455  if ((~bp[byte]) & ((1 << finalbit) - 1))
456  slow = true;
457  else
458  {
459  /* check for nulls in any "earlier" bytes */
460  int i;
461 
462  for (i = 0; i < byte; i++)
463  {
464  if (bp[i] != 0xFF)
465  {
466  slow = true;
467  break;
468  }
469  }
470  }
471  }
472 
473  tp = (char *) tup + tup->t_hoff;
474 
475  if (!slow)
476  {
477  Form_pg_attribute att;
478 
479  /*
480  * If we get here, there are no nulls up to and including the target
481  * attribute. If we have a cached offset, we can use it.
482  */
483  att = TupleDescAttr(tupleDesc, attnum);
484  if (att->attcacheoff >= 0)
485  return fetchatt(att, tp + att->attcacheoff);
486 
487  /*
488  * Otherwise, check for non-fixed-length attrs up to and including
489  * target. If there aren't any, it's safe to cheaply initialize the
490  * cached offsets for these attrs.
491  */
492  if (HeapTupleHasVarWidth(tuple))
493  {
494  int j;
495 
496  for (j = 0; j <= attnum; j++)
497  {
498  if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
499  {
500  slow = true;
501  break;
502  }
503  }
504  }
505  }
506 
507  if (!slow)
508  {
509  int natts = tupleDesc->natts;
510  int j = 1;
511 
512  /*
513  * If we get here, we have a tuple with no nulls or var-widths up to
514  * and including the target attribute, so we can use the cached offset
515  * ... only we don't have it yet, or we'd not have got here. Since
516  * it's cheap to compute offsets for fixed-width columns, we take the
517  * opportunity to initialize the cached offsets for *all* the leading
518  * fixed-width columns, in hope of avoiding future visits to this
519  * routine.
520  */
521  TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
522 
523  /* we might have set some offsets in the slow path previously */
524  while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
525  j++;
526 
527  off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
528  TupleDescAttr(tupleDesc, j - 1)->attlen;
529 
530  for (; j < natts; j++)
531  {
532  Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
533 
534  if (att->attlen <= 0)
535  break;
536 
537  off = att_align_nominal(off, att->attalign);
538 
539  att->attcacheoff = off;
540 
541  off += att->attlen;
542  }
543 
544  Assert(j > attnum);
545 
546  off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
547  }
548  else
549  {
550  bool usecache = true;
551  int i;
552 
553  /*
554  * Now we know that we have to walk the tuple CAREFULLY. But we still
555  * might be able to cache some offsets for next time.
556  *
557  * Note - This loop is a little tricky. For each non-null attribute,
558  * we have to first account for alignment padding before the attr,
559  * then advance over the attr based on its length. Nulls have no
560  * storage and no alignment padding either. We can use/set
561  * attcacheoff until we reach either a null or a var-width attribute.
562  */
563  off = 0;
564  for (i = 0;; i++) /* loop exit is at "break" */
565  {
566  Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
567 
568  if (HeapTupleHasNulls(tuple) && att_isnull(i, bp))
569  {
570  usecache = false;
571  continue; /* this cannot be the target att */
572  }
573 
574  /* If we know the next offset, we can skip the rest */
575  if (usecache && att->attcacheoff >= 0)
576  off = att->attcacheoff;
577  else if (att->attlen == -1)
578  {
579  /*
580  * We can only cache the offset for a varlena attribute if the
581  * offset is already suitably aligned, so that there would be
582  * no pad bytes in any case: then the offset will be valid for
583  * either an aligned or unaligned value.
584  */
585  if (usecache &&
586  off == att_align_nominal(off, att->attalign))
587  att->attcacheoff = off;
588  else
589  {
590  off = att_align_pointer(off, att->attalign, -1,
591  tp + off);
592  usecache = false;
593  }
594  }
595  else
596  {
597  /* not varlena, so safe to use att_align_nominal */
598  off = att_align_nominal(off, att->attalign);
599 
600  if (usecache)
601  att->attcacheoff = off;
602  }
603 
604  if (i == attnum)
605  break;
606 
607  off = att_addlength_pointer(off, att->attlen, tp + off);
608 
609  if (usecache && att->attlen <= 0)
610  usecache = false;
611  }
612  }
613 
614  return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
615 }
#define HeapTupleHasVarWidth(tuple)
Definition: htup_details.h:667
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:146
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:177
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:23
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
#define fetchatt(A, T)
Definition: tupmacs.h:39
HeapTupleHeader t_data
Definition: htup.h:68
#define HeapTupleHasNulls(tuple)
Definition: htup_details.h:661
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:174
#define HeapTupleNoNulls(tuple)
Definition: htup_details.h:664
#define byte(x, n)
Definition: rijndael.c:68
int16 attlen
Definition: pg_attribute.h:64
uint8 bits8
Definition: c.h:365
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
Definition: tupmacs.h:124
int16 attnum
Definition: pg_attribute.h:79
#define Assert(condition)
Definition: c.h:732
int i

◆ varsize_any()

size_t varsize_any ( void *  p)

Definition at line 1498 of file heaptuple.c.

References VARSIZE_ANY.

1499 {
1500  return VARSIZE_ANY(p);
1501 }
#define VARSIZE_ANY(PTR)
Definition: postgres.h:335