PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 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   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 SpecTokenOffsetNumber   0xfffe
 
#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 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 HeapTupleHeaderGetOid(tup)
 
#define HeapTupleHeaderSetOid(tup, oid)
 
#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 HeapTupleGetOid(tuple)   HeapTupleHeaderGetOid((tuple)->t_data)
 
#define HeapTupleSetOid(tuple, oid)   HeapTupleHeaderSetOid((tuple)->t_data, (oid))
 
#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)
 
Datum nocachegetattr (HeapTuple tup, int attnum, TupleDesc att)
 
Datum heap_getsysattr (HeapTuple tup, int attnum, TupleDesc tupleDesc, 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)
 

Macro Definition Documentation

#define BITMAPLEN (   NATTS)    (((int)(NATTS) + 7) / 8)
#define fastgetattr (   tup,
  attnum,
  tupleDesc,
  isnull 
)
Value:
( \
AssertMacro((attnum) > 0), \
(*(isnull) = false), \
( \
(tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
( \
fetchatt((tupleDesc)->attrs[(attnum)-1], \
(char *) (tup)->t_data + (tup)->t_data->t_hoff + \
(tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
) \
: \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
: \
( \
att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
( \
(*(isnull) = true), \
) \
: \
( \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
) \
)
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:21
#define fetchatt(A, T)
Definition: tupmacs.h:37
#define AssertMacro(condition)
Definition: c.h:676
#define HeapTupleNoNulls(tuple)
Definition: htup_details.h:665
uintptr_t Datum
Definition: postgres.h:372
#define NULL
Definition: c.h:229
Datum nocachegetattr(HeapTuple tup, int attnum, TupleDesc att)
Definition: heaptuple.c:352

Definition at line 719 of file htup_details.h.

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

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

Definition at line 656 of file htup_details.h.

Referenced by _int_matchsel(), aclitemout(), add_function_defaults(), AddEnumLabel(), AddRoleMems(), AfterTriggerSetState(), AggregateCreate(), AlterCollation(), AlterConstraintNamespaces(), AlterDatabaseOwner(), AlterDomainAddConstraint(), AlterDomainDefault(), AlterDomainDropConstraint(), AlterDomainNotNull(), AlterDomainValidateConstraint(), AlterEventTrigger(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPublicationOptions(), AlterPublicationOwner_internal(), AlterPublicationTables(), AlterRelationNamespaceInternal(), AlterRole(), AlterRoleSet(), AlterSchemaOwner_internal(), AlterSeqNamespaces(), AlterSequence(), AlterSubscriptionOwner_internal(), AlterTableMoveAll(), AlterTSDictionary(), AlterTypeNamespaceInternal(), AlterTypeOwner(), AlterTypeOwner_oid(), AlterTypeOwnerInternal(), amvalidate(), appendAggOrderBy(), appendFunctionName(), ApplyExtensionUpdates(), assignOperTypes(), assignProcTypes(), ATAddForeignKeyConstraint(), ATExecAddColumn(), ATExecAddIdentity(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecChangeOwner(), ATExecDetachPartition(), ATExecDisableRowSecurity(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropIdentity(), ATExecDropNotNull(), ATExecDropOf(), ATExecEnableRowSecurity(), ATExecForceNoForceRowSecurity(), ATExecGenericOptions(), ATExecSetIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecSetTableSpace(), ATExecValidateConstraint(), ATPostAlterTypeCleanup(), ATPrepAlterColumnType(), ATPrepChangePersistence(), AttrDefaultFetch(), blvalidate(), booltestsel(), boot_openrel(), brinvalidate(), btvalidate(), build_coercion_expression(), build_datatype(), build_function_result_tupdesc_t(), BuildEventTriggerCache(), BuildIndexValueDescription(), BuildTupleRemapInfo(), CacheInvalidateHeapTuple(), CacheInvalidateRelcacheByTuple(), calc_arraycontsel(), calc_rangesel(), call_pltcl_start_proc(), change_owner_fix_column_acls(), change_owner_recurse_to_sequences(), changeDependencyFor(), check_amop_signature(), check_amproc_signature(), check_enable_rls(), check_for_column_name_collision(), check_hash_func_signature(), check_of_type(), check_role(), check_safe_enum_use(), check_session_authorization(), check_TSCurrentConfig(), CheckConstraintFetch(), checkDomainOwner(), checkEnumOwner(), CheckFunctionValidatorAccess(), CheckIndexCompatible(), CheckMyDatabase(), checkSharedDependencies(), cluster(), cluster_rel(), CollationIsVisible(), column_privilege_check(), compatible_oper(), compile_plperl_function(), compile_pltcl_function(), compute_return_type(), ComputeIndexAttrs(), ComputePartitionAttrs(), ConstraintNameIsUsed(), constraints_equivalent(), ConstructTupleDescriptor(), ConversionIsVisible(), create_toast_table(), CreateCast(), CreateFunction(), CreateInheritance(), CreateRole(), CreateSchemaCommand(), CreateStatistics(), CreateTransform(), CreateTrigger(), decompile_conbin(), DefineCollation(), DefineDomain(), DefineIndex(), DefineOpClass(), DefineQueryRewrite(), DefineTSConfiguration(), DefineType(), deleteDependencyRecordsFor(), deleteDependencyRecordsForClass(), deparseOpExpr(), deparseScalarArrayOpExpr(), do_autovacuum(), do_compile(), do_setval(), drop_parent_dependency(), DropConfigurationMapping(), DropRole(), EnableDisableRule(), EnableDisableTrigger(), enum_cmp_internal(), enum_out(), enum_send(), eqjoinsel_inner(), eqjoinsel_semi(), equality_ops_are_compatible(), errdatatype(), estimate_hash_bucketsize(), evaluate_function(), examine_attribute(), exec_object_restorecon(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitAgg(), ExecuteDoStmt(), expand_all_col_privileges(), expand_function_arguments(), 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_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(), format_operator_internal(), format_operator_parts(), format_procedure_internal(), format_procedure_parts(), format_type_internal(), func_get_detail(), func_parallel(), func_strict(), func_volatile(), FuncNameAsType(), FuncnameGetCandidates(), FunctionIsVisible(), generate_collation_name(), generate_function_name(), generate_operator_name(), generate_qualified_relation_name(), generate_relation_name(), generateClonedIndexStmt(), get_agg_clause_costs_walker(), get_am_name(), get_am_type_oid(), get_array_type(), get_attavgwidth(), get_attidentity(), get_attname(), get_attnum(), get_attstatsslot(), get_atttype(), get_atttypetypmodcoll(), get_atttypmod(), get_base_element_type(), get_collation(), get_collation_name(), get_commutator(), get_compatible_hash_operators(), get_constraint_index(), get_constraint_name(), get_database_list(), get_database_name(), get_db_info(), get_domain_constraint_oid(), get_element_type(), get_extension_name(), get_extension_schema(), get_func_arg_info(), get_func_cost(), get_func_leakproof(), get_func_name(), get_func_namespace(), get_func_nargs(), get_func_retset(), get_func_rettype(), get_func_rows(), get_func_signature(), get_func_trftypes(), get_func_variadictype(), get_index_constraint(), get_language_name(), get_mergejoin_opfamilies(), get_namespace_name(), get_negator(), get_object_address_type(), 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_opcode(), get_oper_expr(), get_opfamily_member(), get_opfamily_proc(), get_opname(), get_oprjoin(), get_oprrest(), get_ordering_op_for_equality_op(), get_ordering_op_properties(), get_partition_parent(), get_pkey_attnames(), get_primary_key_attnos(), get_publication_name(), get_range_subtype(), get_rel_name(), get_rel_namespace(), get_rel_oids(), get_rel_persistence(), get_rel_relkind(), get_rel_tablespace(), get_rel_type_id(), get_relation_constraint_oid(), get_relation_statistics(), 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_transform_fromsql(), get_transform_tosql(), 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(), getBaseTypeAndTypmod(), getConstraintTypeDescription(), GetDefaultOpClass(), getExtensionOfObject(), GetFdwRoutineByServerId(), GetForeignDataWrapper(), GetForeignServer(), GetForeignServerIdByRelId(), GetForeignTable(), GetIndexAmRoutineByAmId(), getObjectDescription(), getObjectIdentityParts(), getOpFamilyDescription(), getOpFamilyIdentity(), getOwnedSequences(), getProcedureTypeDescription(), GetPublication(), GetPublicationRelations(), getRelationDescription(), getRelationIdentity(), GetRelationPublicationActions(), GetRelationPublications(), getRelationTypeDescription(), GetSubscription(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), gettype(), getTypeBinaryInputInfo(), getTypeBinaryOutputInfo(), getTypeInputInfo(), getTypeIOParam(), getTypeOutputInfo(), GetUserNameFromId(), ginvalidate(), gistproperty(), 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_constraint_create(), index_set_state_flags(), index_update_stats(), indexam_property(), IndexGetRelation(), IndexSupportsBackwardScan(), init_sql_fcache(), initialize_peragg(), InitializeSessionUserId(), InitPostgres(), inline_function(), inline_set_returning_function(), 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_collation_cache(), lookup_ts_config_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupAggWithArgs(), LookupOpclassInfo(), ltreeparentsel(), 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(), mv_GenerateOper(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), nextval_internal(), nulltestsel(), op_hashjoinable(), op_input_types(), op_mergejoinable(), OpClassCacheLookup(), OpclassIsVisible(), OperatorGet(), OperatorIsVisible(), OperatorUpd(), OpernameGetCandidates(), OpernameGetOprid(), opfamily_can_sort_type(), OpFamilyCacheLookup(), OpfamilyIsVisible(), oprfuncid(), ParseFuncOrColumn(), parseTypeString(), patternsel(), 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_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_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_proc_aclmask(), pg_proc_ownercheck(), pg_publication_ownercheck(), pg_relation_filenode(), pg_relation_filepath(), 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(), plperl_validator(), plpgsql_compile(), plpgsql_parse_cwordtype(), plpgsql_parse_wordtype(), plpgsql_validator(), plpython_validator(), PLy_input_datum_func2(), PLy_output_datum_func2(), PLy_procedure_create(), prepare_column_cache(), prepare_sql_fn_parse_info(), print_function_arguments(), print_function_rettype(), ProcedureCreate(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForRenameAttribute(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), read_seq_tuple(), recheck_cast_function_args(), recomputeNamespacePath(), recordExtObjInitPriv(), regclassout(), regconfigout(), regdictionaryout(), regoperout(), regprocout(), regtypeout(), reindex_index(), ReindexMultipleTables(), relation_mark_replica_identity(), RelationBuildDesc(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationCacheInitializePhase3(), RelationGetExclusionInfo(), RelationGetFKeyList(), RelationGetIndexList(), relationHasPrimaryKey(), RelationHasUnloggedIndex(), RelationInitIndexAccessInfo(), RelationInitPhysicalAddr(), RelationIsVisible(), RelationReloadIndexInfo(), RelationSetNewRelfilenode(), RemoveAttrDefaultById(), RemoveAttributeById(), RemoveConstraintById(), removeExtObjInitPriv(), RemoveFunctionById(), RemoveInheritance(), RemoveObjects(), 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_add_cast_to(), ri_GenerateQual(), ri_GenerateQualCollation(), ri_LoadConstraintInfo(), roles_has_privs_of(), roles_is_member_of(), scalararraysel_containment(), scalarineqsel(), SearchSysCacheAttName(), 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(), SetFunctionArgType(), SetFunctionReturnType(), SetMatViewPopulatedState(), SetRelationHasSubclass(), SetRelationNumChecks(), SetRelationRuleStatus(), shdepChangeDep(), shdepDropDependency(), shdepDropOwned(), shdepReassignOwned(), simplify_function(), sort_order_cmp(), spgvalidate(), SPI_gettype(), StatisticsObjIsVisible(), StoreAttrDefault(), StorePartitionBound(), stringTypeDatum(), superuser_arg(), swap_relation_files(), table_recheck_autovac(), test_indoption(), transformArrayType(), transformColumnNameList(), transformColumnType(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), triggered_change_notification(), TSConfigIsVisible(), TSDictionaryIsVisible(), TSParserIsVisible(), tsquerysel(), TSTemplateIsVisible(), TupleDescInitEntry(), typeByVal(), TypeCreate(), typeidTypeRelid(), typeInheritsFrom(), typeIsOfTypedTable(), TypeIsVisible(), typeLen(), typenameType(), typenameTypeMod(), typeTypeCollation(), typeTypeName(), typeTypeRelid(), vac_truncate_clog(), vac_update_datfrozenxid(), vac_update_relstats(), validateCheckConstraint(), var_eq_const(), var_eq_non_const(), and verify_dictoptions().

#define HEAP2_XACT_MASK   0xE000 /* visibility-related bits */
#define HEAP_COMBOCID   0x0020 /* t_cid is a combo cid */
#define heap_getattr (   tup,
  attnum,
  tupleDesc,
  isnull 
)
Value:
( \
((attnum) > 0) ? \
( \
((attnum) > (int) HeapTupleHeaderGetNatts((tup)->t_data)) ? \
( \
(*(isnull) = true), \
) \
: \
fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
) \
: \
heap_getsysattr((tup), (attnum), (tupleDesc), (isnull)) \
)
#define fastgetattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:719
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: heaptuple.c:552
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:532
uintptr_t Datum
Definition: postgres.h:372
#define NULL
Definition: c.h:229

Definition at line 769 of file htup_details.h.

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

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

Definition at line 177 of file htup_details.h.

Referenced by heap_fill_tuple(), and index_form_tuple().

#define HEAP_HASNULL   0x0001 /* has null attribute(s) */
#define HEAP_HASOID   0x0008 /* has an object-id field */
#define HEAP_HASVARWIDTH   0x0002 /* has variable-width attribute(s) */

Definition at line 176 of file htup_details.h.

Referenced by heap_fill_tuple(), and index_form_tuple().

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

Definition at line 266 of file htup_details.h.

Referenced by heap_prepare_freeze_tuple().

#define HEAP_LOCK_MASK
Value:
#define HEAP_XMAX_KEYSHR_LOCK
Definition: htup_details.h:179
#define HEAP_XMAX_SHR_LOCK
Definition: htup_details.h:185
#define HEAP_XMAX_EXCL_LOCK
Definition: htup_details.h:181

Definition at line 187 of file htup_details.h.

Referenced by xmax_infomask_changed().

#define HEAP_LOCKED_UPGRADED (   infomask)
Value:
( \
((infomask) & HEAP_XMAX_IS_MULTI) != 0 && \
((infomask) & HEAP_XMAX_LOCK_ONLY) != 0 && \
(((infomask) & (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)) == 0) \
)
#define HEAP_XMAX_KEYSHR_LOCK
Definition: htup_details.h:179
#define HEAP_XMAX_LOCK_ONLY
Definition: htup_details.h:182
#define HEAP_XMAX_EXCL_LOCK
Definition: htup_details.h:181
#define HEAP_XMAX_IS_MULTI
Definition: htup_details.h:194

Definition at line 238 of file htup_details.h.

Referenced by compute_new_xmax_infomask(), Do_MultiXactIdWait(), DoesMultiXactIdConflict(), FreezeMultiXactId(), heap_lock_updated_tuple_rec(), heap_tuple_needs_freeze(), heap_update(), HeapTupleSatisfiesUpdate(), HeapTupleSatisfiesVacuum(), and pgrowlocks().

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

Definition at line 199 of file htup_details.h.

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

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

Definition at line 196 of file htup_details.h.

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

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

Definition at line 262 of file htup_details.h.

Referenced by heap_page_items(), tuple_data_split(), and tuple_data_split_internal().

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

Definition at line 267 of file htup_details.h.

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

Definition at line 277 of file htup_details.h.

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

Definition at line 195 of file htup_details.h.

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

#define HEAP_XACT_MASK   0xFFF0 /* visibility-related bits */
#define HEAP_XMAX_EXCL_LOCK   0x0040 /* xmax is exclusive locker */
#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_IS_SHR_LOCKED (   infomask)    (((infomask) & HEAP_LOCK_MASK) == HEAP_XMAX_SHR_LOCK)
#define HEAP_XMAX_KEYSHR_LOCK   0x0010 /* xmax is a key-shared 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)

Definition at line 185 of file htup_details.h.

Referenced by compute_new_xmax_infomask(), and GetMultiXactIdHintBits().

#define HEAP_XMIN_FROZEN   (HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID)

Definition at line 191 of file htup_details.h.

Referenced by heap_prepare_freeze_tuple().

#define HEAP_XMIN_INVALID   0x0200 /* t_xmin invalid/aborted */
#define HeapTupleAllFixed (   tuple)    (!((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH))

Definition at line 671 of file htup_details.h.

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

Definition at line 692 of file htup_details.h.

Referenced by heap_update().

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

Definition at line 683 of file htup_details.h.

Referenced by heap_update().

#define HeapTupleGetOid (   tuple)    HeapTupleHeaderGetOid((tuple)->t_data)

Definition at line 695 of file htup_details.h.

Referenced by AddEnumLabel(), AfterTriggerSetState(), AlterConstraintNamespaces(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDropConstraint(), AlterDomainValidateConstraint(), AlterEventTrigger(), AlterEventTriggerOwner(), AlterEventTriggerOwner_internal(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner(), AlterForeignServerOwner_internal(), AlterObjectOwner_internal(), AlterOpFamily(), AlterPolicy(), AlterPublication(), AlterPublicationOptions(), AlterPublicationOwner(), AlterPublicationOwner_internal(), AlterPublicationTables(), AlterRole(), AlterRoleSet(), AlterSchemaOwner(), AlterSchemaOwner_internal(), AlterSubscription(), AlterSubscriptionOwner(), AlterSubscriptionOwner_internal(), AlterTableMoveAll(), AlterTableSpaceOptions(), AlterTSConfiguration(), AlterTypeOwner(), ATExecAddColumn(), ATExecAddOf(), ATExecAlterColumnType(), ATExecAlterConstraint(), ATExecDropConstraint(), ATExecValidateConstraint(), ATRewriteTable(), boot_openrel(), build_datatype(), CacheInvalidateHeapTuple(), CacheInvalidateRelcacheByTuple(), CatalogCacheComputeTupleHashValue(), check_db_file_conflict(), check_of_type(), check_role(), check_session_authorization(), checkDomainOwner(), checkEnumOwner(), CheckIndexCompatible(), CollationCreate(), compile_plperl_function(), ConversionCreate(), CopyTo(), create_proc_lang(), createdb(), CreateFunction(), CreateRole(), CreateStatistics(), CreateTransform(), decompile_conbin(), DefineDomain(), DefineIndex(), DefineOpClass(), do_autovacuum(), DropConfigurationMapping(), DropRole(), DropSubscription(), DropTableSpace(), EnableDisableRule(), EnableDisableTrigger(), enum_endpoint(), enum_in(), enum_range_internal(), enum_recv(), exec_object_restorecon(), ExecAlterExtensionStmt(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecuteDoStmt(), ExtractReplicaIdentity(), fetch_statentries_for_relation(), find_typed_table_dependencies(), FuncnameGetCandidates(), get_am_type_oid(), get_database_list(), get_database_oid(), get_db_info(), get_domain_constraint_oid(), get_extension_oid(), get_object_address_attrdef(), get_object_address_defacl(), get_object_address_opf_member(), get_object_address_usermapping(), get_opclass_oid(), get_opfamily_oid(), get_primary_key_attnos(), get_rel_oids(), get_relation_constraint_oid(), get_relation_policy_oid(), get_rewrite_oid(), get_subscription_list(), get_tablespace_oid(), get_trigger_oid(), GetAllTablesPublicationRelations(), GetAllTablesPublications(), getConstraintTypeDescription(), GetDefaultOpClass(), getRelationsInNamespace(), GetSysCacheOid(), gettype(), getTypeIOParam(), GetUserMapping(), heap_getsysattr(), heap_insert(), heap_modify_tuple(), heap_modify_tuple_by_cols(), heap_prepare_insert(), heap_update(), InitializeSessionUserId(), InitPostgres(), InsertRule(), lazy_scan_heap(), load_enum_cache_data(), lookup_C_func(), LookupTypeNameOid(), makeConfigurationDependencies(), MakeConfigurationMapping(), makeDictionaryDependencies(), makeOperatorDependencies(), makeParserDependencies(), makeTSTemplateDependencies(), movedb(), objectsInSchemaToOids(), OperatorGet(), OpernameGetCandidates(), OpernameGetOprid(), oprid(), parseTypeString(), pgstat_collect_oids(), PLy_input_datum_func2(), PLy_output_datum_func2(), print_function_arguments(), ProcedureCreate(), record_C_func(), reform_and_rewrite_tuple(), ReindexMultipleTables(), RelationBuildDesc(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationGetStatExtList(), RelidByRelfilenode(), remove_dbtablespaces(), RemoveAttrDefault(), rename_policy(), RenameRewriteRule(), RenameRole(), RenameSchema(), RenameTableSpace(), renametrig(), ResolveOpClass(), SetDefaultACL(), SetSubscriptionRelState(), SPI_modifytuple(), toast_flatten_tuple(), transformColumnDefinition(), transformColumnType(), transformOfType(), TypeCreate(), typenameTypeId(), typenameTypeIdAndMod(), typeTypeId(), vac_truncate_clog(), and validateCheckConstraint().

#define HeapTupleHasExternal (   tuple)    (((tuple)->t_data->t_infomask & HEAP_HASEXTERNAL) != 0)
#define HeapTupleHasNulls (   tuple)    (((tuple)->t_data->t_infomask & HEAP_HASNULL) != 0)
#define HeapTupleHasVarWidth (   tuple)    (((tuple)->t_data->t_infomask & HEAP_HASVARWIDTH) != 0)

Definition at line 668 of file htup_details.h.

Referenced by nocachegetattr().

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

Definition at line 512 of file htup_details.h.

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

Definition at line 497 of file htup_details.h.

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

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

Definition at line 527 of file htup_details.h.

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

#define HeapTupleHeaderGetNatts (   tup)    ((tup)->t_infomask2 & HEAP_NATTS_MASK)
#define HeapTupleHeaderGetOid (   tup)
Value:
( \
((tup)->t_infomask & HEAP_HASOID) ? \
*((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \
: \
)
unsigned int Oid
Definition: postgres_ext.h:31
#define InvalidOid
Definition: postgres_ext.h:36
#define HEAP_HASOID
Definition: htup_details.h:178

Definition at line 465 of file htup_details.h.

Referenced by heap_page_items(), suppress_redundant_updates_trigger(), toast_flatten_tuple_to_datum(), toast_insert_or_update(), and tuple_to_stringinfo().

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

Definition at line 385 of file htup_details.h.

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

#define HeapTupleHeaderGetSpeculativeToken (   tup)
Value:
( \
ItemPointerGetBlockNumber(&(tup)->t_ctid) \
)
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:423
#define AssertMacro(condition)
Definition: c.h:676
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:75

Definition at line 428 of file htup_details.h.

Referenced by HeapTupleSatisfiesDirty().

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

Definition at line 540 of file htup_details.h.

Referenced by HeapTupleHeaderGetDatum().

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

Definition at line 517 of file htup_details.h.

Referenced by ExecScanHashTableForUnmatched().

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

Definition at line 502 of file htup_details.h.

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

#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:323
#define HEAP_XMAX_INVALID
Definition: htup_details.h:193
#define HEAP_HOT_UPDATED
Definition: htup_details.h:266

Definition at line 485 of file htup_details.h.

Referenced by heap_get_root_tuples(), and heap_prune_chain().

#define HeapTupleHeaderIsSpeculative (   tup)
Value:
( \
)
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:85
#define SpecTokenOffsetNumber
Definition: htup_details.h:285

Definition at line 423 of file htup_details.h.

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

#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:202
#define HEAP_COMBOCID
Definition: htup_details.h:180
#define Assert(condition)
Definition: c.h:675

Definition at line 399 of file htup_details.h.

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

#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:202
#define HEAP_COMBOCID
Definition: htup_details.h:180
#define Assert(condition)
Definition: c.h:675

Definition at line 391 of file htup_details.h.

Referenced by 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().

#define HeapTupleHeaderSetDatumLength (   tup,
  len 
)    SET_VARSIZE(tup, len)
#define HeapTupleHeaderSetHeapOnly (   tup)
Value:
( \
(tup)->t_infomask2 |= HEAP_ONLY_TUPLE \
)
#define HEAP_ONLY_TUPLE
Definition: htup_details.h:267

Definition at line 507 of file htup_details.h.

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

Definition at line 492 of file htup_details.h.

Referenced by heap_xlog_update().

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

Definition at line 522 of file htup_details.h.

Referenced by ExecHashJoin().

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

Definition at line 535 of file htup_details.h.

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

#define HeapTupleHeaderSetOid (   tup,
  oid 
)
Value:
do { \
Assert((tup)->t_infomask & HEAP_HASOID); \
*((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) = (oid); \
} while (0)
unsigned int Oid
Definition: postgres_ext.h:31
#define Assert(condition)
Definition: c.h:675
#define HEAP_HASOID
Definition: htup_details.h:178

Definition at line 473 of file htup_details.h.

Referenced by suppress_redundant_updates_trigger(), toast_flatten_tuple_to_datum(), and toast_insert_or_update().

#define HeapTupleHeaderSetSpeculativeToken (   tup,
  token 
)
Value:
( \
ItemPointerSet(&(tup)->t_ctid, token, SpecTokenOffsetNumber) \
)
#define SpecTokenOffsetNumber
Definition: htup_details.h:285
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:104

Definition at line 434 of file htup_details.h.

Referenced by ExecInsert().

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

Definition at line 450 of file htup_details.h.

Referenced by ExecEvalWholeRowVar(), heap_copy_tuple_as_datum(), heap_form_tuple(), toast_flatten_tuple_to_datum(), and TQRemapRecord().

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

Definition at line 460 of file htup_details.h.

Referenced by ExecEvalWholeRowVar(), heap_copy_tuple_as_datum(), heap_form_tuple(), toast_flatten_tuple_to_datum(), and TQRemapRecord().

#define HeapTupleHeaderSetXmin (   tup,
  xid 
)
#define HeapTupleHeaderSetXminCommitted (   tup)
Value:
( \
((tup)->t_infomask |= HEAP_XMIN_COMMITTED) \
)
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:323
#define AssertMacro(condition)
Definition: c.h:676
#define HEAP_XMIN_COMMITTED
Definition: htup_details.h:189

Definition at line 334 of file htup_details.h.

#define HeapTupleHeaderSetXminFrozen (   tup)
Value:
( \
((tup)->t_infomask |= HEAP_XMIN_FROZEN) \
)
#define HEAP_XMIN_FROZEN
Definition: htup_details.h:191
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:323
#define AssertMacro(condition)
Definition: c.h:676

Definition at line 346 of file htup_details.h.

Referenced by fill_seq_with_data(), and heap_prepare_insert().

#define HeapTupleHeaderSetXminInvalid (   tup)
Value:
( \
((tup)->t_infomask |= HEAP_XMIN_INVALID) \
)
#define AssertMacro(condition)
Definition: c.h:676
#define HEAP_XMIN_INVALID
Definition: htup_details.h:190
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:318

Definition at line 340 of file htup_details.h.

#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:202
#define Assert(condition)
Definition: c.h:675

Definition at line 417 of file htup_details.h.

Referenced by heap_execute_freeze_tuple().

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

Definition at line 329 of file htup_details.h.

Referenced by heap_mask(), and HeapTupleSatisfiesMVCC().

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

Definition at line 677 of file htup_details.h.

Referenced by heap_hot_search_buffer(), IndexBuildHeapRangeScan(), and lazy_scan_heap().

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

Definition at line 665 of file htup_details.h.

Referenced by heap_attisnull(), and nocachegetattr().

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

Definition at line 689 of file htup_details.h.

Referenced by heap_update().

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

Definition at line 680 of file htup_details.h.

Referenced by heap_update().

#define MaxAttrSize   (10 * 1024 * 1024)

Definition at line 586 of file htup_details.h.

Referenced by anybit_typmodin(), and anychar_typmodin().

#define MaxHeapAttributeNumber   1600 /* 8 * 200 */
#define MinHeapTupleSize   MAXALIGN(SizeofHeapTupleHeader)

Definition at line 562 of file htup_details.h.

Referenced by heap_page_items().

#define MINIMAL_TUPLE_DATA_OFFSET   offsetof(MinimalTupleData, t_infomask2)

Definition at line 624 of file htup_details.h.

Referenced by readtup_heap(), and writetup_heap().

#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)

Definition at line 622 of file htup_details.h.

#define SpecTokenOffsetNumber   0xfffe

Definition at line 285 of file htup_details.h.

Referenced by heap_finish_speculative().

Typedef Documentation

Function Documentation

bool heap_attisnull ( HeapTuple  tup,
int  attnum 
)

Definition at line 297 of file heaptuple.c.

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

Referenced by AlterDomainNotNull(), ATRewriteTable(), build_function_result_tupdesc_t(), check_index_is_clusterable(), CheckIndexCompatible(), ExecEvalRowNullInt(), fmgr_info_cxt_security(), 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(), ri_NullCheck(), slot_attisnull(), statext_is_kind_built(), and transformFkeyCheckAttrs().

298 {
299  if (attnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
300  return true;
301 
302  if (attnum > 0)
303  {
304  if (HeapTupleNoNulls(tup))
305  return false;
306  return att_isnull(attnum - 1, tup->t_data->t_bits);
307  }
308 
309  switch (attnum)
310  {
318  /* these are never null */
319  break;
320 
321  default:
322  elog(ERROR, "invalid attnum: %d", attnum);
323  }
324 
325  return false;
326 }
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:163
#define ObjectIdAttributeNumber
Definition: sysattr.h:22
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:21
#define MinCommandIdAttributeNumber
Definition: sysattr.h:24
HeapTupleHeader t_data
Definition: htup.h:67
#define ERROR
Definition: elog.h:43
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:532
#define TableOidAttributeNumber
Definition: sysattr.h:27
#define HeapTupleNoNulls(tuple)
Definition: htup_details.h:665
#define MaxCommandIdAttributeNumber
Definition: sysattr.h:26
#define MaxTransactionIdAttributeNumber
Definition: sysattr.h:25
#define SelfItemPointerAttributeNumber
Definition: sysattr.h:21
#define elog
Definition: elog.h:219
#define MinTransactionIdAttributeNumber
Definition: sysattr.h:23
Size heap_compute_data_size ( TupleDesc  tupleDesc,
Datum values,
bool isnull 
)

Definition at line 85 of file heaptuple.c.

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

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

88 {
89  Size data_length = 0;
90  int i;
91  int numberOfAttributes = tupleDesc->natts;
92  Form_pg_attribute *att = tupleDesc->attrs;
93 
94  for (i = 0; i < numberOfAttributes; i++)
95  {
96  Datum val;
97  Form_pg_attribute atti;
98 
99  if (isnull[i])
100  continue;
101 
102  val = values[i];
103  atti = att[i];
104 
105  if (ATT_IS_PACKABLE(atti) &&
107  {
108  /*
109  * we're anticipating converting to a short varlena header, so
110  * adjust length and don't count any alignment
111  */
112  data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
113  }
114  else if (atti->attlen == -1 &&
116  {
117  /*
118  * we want to flatten the expanded value so that the constructed
119  * tuple doesn't depend on it
120  */
121  data_length = att_align_nominal(data_length, atti->attalign);
122  data_length += EOH_get_flat_size(DatumGetEOHP(val));
123  }
124  else
125  {
126  data_length = att_align_datum(data_length, atti->attalign,
127  atti->attlen, val);
128  data_length = att_addlength_datum(data_length, atti->attlen,
129  val);
130  }
131  }
132 
133  return data_length;
134 }
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:144
#define VARATT_IS_EXTERNAL_EXPANDED(PTR)
Definition: postgres.h:323
Form_pg_attribute * attrs
Definition: tupdesc.h:74
int natts
Definition: tupdesc.h:73
#define att_align_datum(cur_offset, attalign, attlen, attdatum)
Definition: tupmacs.h:101
#define VARATT_CAN_MAKE_SHORT(PTR)
Definition: postgres.h:271
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
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:274
uintptr_t Datum
Definition: postgres.h:372
size_t Size
Definition: c.h:356
#define DatumGetPointer(X)
Definition: postgres.h:555
static Datum values[MAXATTR]
Definition: bootstrap.c:163
#define att_addlength_datum(cur_offset, attlen, attdatum)
Definition: tupmacs.h:160
#define ATT_IS_PACKABLE(att)
Definition: heaptuple.c:67
int i
long val
Definition: informix.c:689
MinimalTuple heap_copy_minimal_tuple ( MinimalTuple  mtup)

Definition at line 1479 of file heaptuple.c.

References palloc(), result, and MinimalTupleData::t_len.

Referenced by ExecCopySlotMinimalTuple(), tuplesort_gettupleslot(), and tuplestore_gettupleslot().

1480 {
1482 
1483  result = (MinimalTuple) palloc(mtup->t_len);
1484  memcpy(result, mtup, mtup->t_len);
1485  return result;
1486 }
return result
Definition: formatting.c:1632
MinimalTupleData * MinimalTuple
Definition: htup.h:27
void * palloc(Size size)
Definition: mcxt.c:849
Datum heap_copy_tuple_as_datum ( HeapTuple  tuple,
TupleDesc  tupleDesc 
)

Definition at line 656 of file heaptuple.c.

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

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

657 {
658  HeapTupleHeader td;
659 
660  /*
661  * If the tuple contains any external TOAST pointers, we have to inline
662  * those fields to meet the conventions for composite-type Datums.
663  */
664  if (HeapTupleHasExternal(tuple))
665  return toast_flatten_tuple_to_datum(tuple->t_data,
666  tuple->t_len,
667  tupleDesc);
668 
669  /*
670  * Fast path for easy case: just make a palloc'd copy and insert the
671  * correct composite-Datum header fields (since those may not be set if
672  * the given tuple came from disk, rather than from heap_form_tuple).
673  */
674  td = (HeapTupleHeader) palloc(tuple->t_len);
675  memcpy((char *) td, (char *) tuple->t_data, tuple->t_len);
676 
678  HeapTupleHeaderSetTypeId(td, tupleDesc->tdtypeid);
679  HeapTupleHeaderSetTypMod(td, tupleDesc->tdtypmod);
680 
681  return PointerGetDatum(td);
682 }
Oid tdtypeid
Definition: tupdesc.h:77
#define HeapTupleHeaderSetTypeId(tup, typeid)
Definition: htup_details.h:450
#define PointerGetDatum(X)
Definition: postgres.h:562
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
int32 tdtypmod
Definition: tupdesc.h:78
#define HeapTupleHeaderSetDatumLength(tup, len)
Definition: htup_details.h:442
HeapTupleHeader t_data
Definition: htup.h:67
uint32 t_len
Definition: htup.h:64
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
Definition: tuptoaster.c:1187
#define HeapTupleHeaderSetTypMod(tup, typmod)
Definition: htup_details.h:460
#define HeapTupleHasExternal(tuple)
Definition: htup_details.h:674
void * palloc(Size size)
Definition: mcxt.c:849
HeapTuple heap_copytuple ( HeapTuple  tuple)

Definition at line 608 of file heaptuple.c.

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

Referenced by acquire_sample_rows(), AlterConstraintNamespaces(), AlterDomainValidateConstraint(), AlterExtensionNamespace(), AlterTypeOwner(), ATExecAlterConstraint(), ATExecDropConstraint(), ATExecValidateConstraint(), changeDependencyFor(), copytup_cluster(), EnableDisableTrigger(), EvalPlanQualFetch(), EvalPlanQualFetchRowMarks(), exec_move_row(), ExecCopySlotTuple(), ExecLockRows(), form_tuple_array(), gather_merge_readnext(), get_catalog_object_by_oid(), get_tuple_from_datum(), GetDatabaseTuple(), GetDatabaseTupleByOid(), GetTupleForTrigger(), index_update_stats(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), RelationInitIndexAccessInfo(), RemoveInheritance(), rename_policy(), RenameEnumLabel(), RenameTableSpace(), renametrig(), RenumberEnumType(), reorderqueue_push(), ResetSequence(), rewrite_heap_tuple(), ScanPgRelation(), SearchSysCacheCopy(), SearchSysCacheCopyAttName(), shdepChangeDep(), SPI_copytuple(), and TQRemapTuple().

609 {
610  HeapTuple newTuple;
611 
612  if (!HeapTupleIsValid(tuple) || tuple->t_data == NULL)
613  return NULL;
614 
615  newTuple = (HeapTuple) palloc(HEAPTUPLESIZE + tuple->t_len);
616  newTuple->t_len = tuple->t_len;
617  newTuple->t_self = tuple->t_self;
618  newTuple->t_tableOid = tuple->t_tableOid;
619  newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
620  memcpy((char *) newTuple->t_data, (char *) tuple->t_data, tuple->t_len);
621  return newTuple;
622 }
HeapTupleData * HeapTuple
Definition: htup.h:70
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
HeapTupleHeader t_data
Definition: htup.h:67
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:77
#define NULL
Definition: c.h:229
void * palloc(Size size)
Definition: mcxt.c:849
#define HEAPTUPLESIZE
Definition: htup.h:72
void heap_copytuple_with_tuple ( HeapTuple  src,
HeapTuple  dest 
)

Definition at line 634 of file heaptuple.c.

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

Referenced by CatalogCacheCreateEntry(), and SearchCatCacheList().

635 {
636  if (!HeapTupleIsValid(src) || src->t_data == NULL)
637  {
638  dest->t_data = NULL;
639  return;
640  }
641 
642  dest->t_len = src->t_len;
643  dest->t_self = src->t_self;
644  dest->t_tableOid = src->t_tableOid;
645  dest->t_data = (HeapTupleHeader) palloc(src->t_len);
646  memcpy((char *) dest->t_data, (char *) src->t_data, src->t_len);
647 }
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
HeapTupleHeader t_data
Definition: htup.h:67
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:77
#define NULL
Definition: c.h:229
void * palloc(Size size)
Definition: mcxt.c:849
void heap_deform_tuple ( HeapTuple  tuple,
TupleDesc  tupleDesc,
Datum values,
bool isnull 
)

Definition at line 933 of file heaptuple.c.

References att_addlength_pointer, att_align_nominal, att_align_pointer, att_isnull, tupleDesc::attrs, fetchatt, HeapTupleHasNulls, HeapTupleHeaderGetNatts, Min, tupleDesc::natts, HeapTupleHeaderData::t_bits, HeapTupleData::t_data, and HeapTupleHeaderData::t_hoff.

Referenced by ATRewriteTable(), CopyTo(), do_convert_tuple(), ExecEvalFieldStoreDeForm(), 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(), SPI_modifytuple(), toast_delete(), toast_flatten_tuple(), toast_flatten_tuple_to_datum(), toast_insert_or_update(), TQExamineRecord(), TQRemapTuple(), and tuple_equals_slot().

935 {
936  HeapTupleHeader tup = tuple->t_data;
937  bool hasnulls = HeapTupleHasNulls(tuple);
938  Form_pg_attribute *att = tupleDesc->attrs;
939  int tdesc_natts = tupleDesc->natts;
940  int natts; /* number of atts to extract */
941  int attnum;
942  char *tp; /* ptr to tuple data */
943  long off; /* offset in tuple data */
944  bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
945  bool slow = false; /* can we use/set attcacheoff? */
946 
947  natts = HeapTupleHeaderGetNatts(tup);
948 
949  /*
950  * In inheritance situations, it is possible that the given tuple actually
951  * has more fields than the caller is expecting. Don't run off the end of
952  * the caller's arrays.
953  */
954  natts = Min(natts, tdesc_natts);
955 
956  tp = (char *) tup + tup->t_hoff;
957 
958  off = 0;
959 
960  for (attnum = 0; attnum < natts; attnum++)
961  {
962  Form_pg_attribute thisatt = att[attnum];
963 
964  if (hasnulls && att_isnull(attnum, bp))
965  {
966  values[attnum] = (Datum) 0;
967  isnull[attnum] = true;
968  slow = true; /* can't use attcacheoff anymore */
969  continue;
970  }
971 
972  isnull[attnum] = false;
973 
974  if (!slow && thisatt->attcacheoff >= 0)
975  off = thisatt->attcacheoff;
976  else if (thisatt->attlen == -1)
977  {
978  /*
979  * We can only cache the offset for a varlena attribute if the
980  * offset is already suitably aligned, so that there would be no
981  * pad bytes in any case: then the offset will be valid for either
982  * an aligned or unaligned value.
983  */
984  if (!slow &&
985  off == att_align_nominal(off, thisatt->attalign))
986  thisatt->attcacheoff = off;
987  else
988  {
989  off = att_align_pointer(off, thisatt->attalign, -1,
990  tp + off);
991  slow = true;
992  }
993  }
994  else
995  {
996  /* not varlena, so safe to use att_align_nominal */
997  off = att_align_nominal(off, thisatt->attalign);
998 
999  if (!slow)
1000  thisatt->attcacheoff = off;
1001  }
1002 
1003  values[attnum] = fetchatt(thisatt, tp + off);
1004 
1005  off = att_addlength_pointer(off, thisatt->attlen, tp + off);
1006 
1007  if (thisatt->attlen <= 0)
1008  slow = true; /* can't use attcacheoff anymore */
1009  }
1010 
1011  /*
1012  * If tuple doesn't have all the atts indicated by tupleDesc, read the
1013  * rest as null
1014  */
1015  for (; attnum < tdesc_natts; attnum++)
1016  {
1017  values[attnum] = (Datum) 0;
1018  isnull[attnum] = true;
1019  }
1020 }
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:144
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:163
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:21
#define Min(x, y)
Definition: c.h:806
Form_pg_attribute * attrs
Definition: tupdesc.h:74
int natts
Definition: tupdesc.h:73
#define fetchatt(A, T)
Definition: tupmacs.h:37
HeapTupleHeader t_data
Definition: htup.h:67
#define HeapTupleHeaderGetNatts(tup)
Definition: htup_details.h:532
#define HeapTupleHasNulls(tuple)
Definition: htup_details.h:662
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:172
uint8 bits8
Definition: c.h:275
uintptr_t Datum
Definition: postgres.h:372
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
Definition: tupmacs.h:122
static Datum values[MAXATTR]
Definition: bootstrap.c:163
void heap_fill_tuple ( TupleDesc  tupleDesc,
Datum values,
bool isnull,
char *  data,
Size  data_size,
uint16 infomask,
bits8 bit 
)

Definition at line 146 of file heaptuple.c.

References Assert, att_align_nominal, tupleDesc::attrs, DatumGetCString, DatumGetEOHP(), DatumGetPointer, EOH_flatten_into(), EOH_get_flat_size(), HEAP_HASEXTERNAL, HEAP_HASNULL, HEAP_HASVARWIDTH, HIGHBIT, i, tupleDesc::natts, NULL, SET_VARSIZE_SHORT, store_att_byval, val, VARATT_CAN_MAKE_SHORT, VARATT_CONVERTED_SHORT_SIZE, VARATT_IS_EXTERNAL, VARATT_IS_EXTERNAL_EXPANDED, VARATT_IS_SHORT, VARDATA, VARLENA_ATT_IS_PACKABLE, VARSIZE, VARSIZE_EXTERNAL, and VARSIZE_SHORT.

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

150 {
151  bits8 *bitP;
152  int bitmask;
153  int i;
154  int numberOfAttributes = tupleDesc->natts;
155  Form_pg_attribute *att = tupleDesc->attrs;
156 
157 #ifdef USE_ASSERT_CHECKING
158  char *start = data;
159 #endif
160 
161  if (bit != NULL)
162  {
163  bitP = &bit[-1];
164  bitmask = HIGHBIT;
165  }
166  else
167  {
168  /* just to keep compiler quiet */
169  bitP = NULL;
170  bitmask = 0;
171  }
172 
173  *infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTERNAL);
174 
175  for (i = 0; i < numberOfAttributes; i++)
176  {
177  Size data_length;
178 
179  if (bit != NULL)
180  {
181  if (bitmask != HIGHBIT)
182  bitmask <<= 1;
183  else
184  {
185  bitP += 1;
186  *bitP = 0x0;
187  bitmask = 1;
188  }
189 
190  if (isnull[i])
191  {
192  *infomask |= HEAP_HASNULL;
193  continue;
194  }
195 
196  *bitP |= bitmask;
197  }
198 
199  /*
200  * XXX we use the att_align macros on the pointer value itself, not on
201  * an offset. This is a bit of a hack.
202  */
203 
204  if (att[i]->attbyval)
205  {
206  /* pass-by-value */
207  data = (char *) att_align_nominal(data, att[i]->attalign);
208  store_att_byval(data, values[i], att[i]->attlen);
209  data_length = att[i]->attlen;
210  }
211  else if (att[i]->attlen == -1)
212  {
213  /* varlena */
215 
216  *infomask |= HEAP_HASVARWIDTH;
217  if (VARATT_IS_EXTERNAL(val))
218  {
220  {
221  /*
222  * we want to flatten the expanded value so that the
223  * constructed tuple doesn't depend on it
224  */
226 
227  data = (char *) att_align_nominal(data,
228  att[i]->attalign);
229  data_length = EOH_get_flat_size(eoh);
230  EOH_flatten_into(eoh, data, data_length);
231  }
232  else
233  {
234  *infomask |= HEAP_HASEXTERNAL;
235  /* no alignment, since it's short by definition */
236  data_length = VARSIZE_EXTERNAL(val);
237  memcpy(data, val, data_length);
238  }
239  }
240  else if (VARATT_IS_SHORT(val))
241  {
242  /* no alignment for short varlenas */
243  data_length = VARSIZE_SHORT(val);
244  memcpy(data, val, data_length);
245  }
246  else if (VARLENA_ATT_IS_PACKABLE(att[i]) &&
248  {
249  /* convert to short varlena -- no alignment */
250  data_length = VARATT_CONVERTED_SHORT_SIZE(val);
251  SET_VARSIZE_SHORT(data, data_length);
252  memcpy(data + 1, VARDATA(val), data_length - 1);
253  }
254  else
255  {
256  /* full 4-byte header varlena */
257  data = (char *) att_align_nominal(data,
258  att[i]->attalign);
259  data_length = VARSIZE(val);
260  memcpy(data, val, data_length);
261  }
262  }
263  else if (att[i]->attlen == -2)
264  {
265  /* cstring ... never needs alignment */
266  *infomask |= HEAP_HASVARWIDTH;
267  Assert(att[i]->attalign == 'c');
268  data_length = strlen(DatumGetCString(values[i])) + 1;
269  memcpy(data, DatumGetPointer(values[i]), data_length);
270  }
271  else
272  {
273  /* fixed-length pass-by-reference */
274  data = (char *) att_align_nominal(data, att[i]->attalign);
275  Assert(att[i]->attlen > 0);
276  data_length = att[i]->attlen;
277  memcpy(data, DatumGetPointer(values[i]), data_length);
278  }
279 
280  data += data_length;
281  }
282 
283  Assert((data - start) == data_size);
284 }
#define SET_VARSIZE_SHORT(PTR, len)
Definition: postgres.h:329
#define VARDATA(PTR)
Definition: postgres.h:303
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:144
#define VARATT_IS_EXTERNAL_EXPANDED(PTR)
Definition: postgres.h:323
#define VARSIZE(PTR)
Definition: postgres.h:304
Form_pg_attribute * attrs
Definition: tupdesc.h:74
int natts
Definition: tupdesc.h:73
#define VARATT_IS_EXTERNAL(PTR)
Definition: postgres.h:314
char * Pointer
Definition: c.h:245
#define HEAP_HASNULL
Definition: htup_details.h:175
#define DatumGetCString(X)
Definition: postgres.h:572
#define VARATT_IS_SHORT(PTR)
Definition: postgres.h:325
#define VARATT_CAN_MAKE_SHORT(PTR)
Definition: postgres.h:271
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
Size EOH_get_flat_size(ExpandedObjectHeader *eohptr)
Definition: expandeddatum.c:75
#define HEAP_HASVARWIDTH
Definition: htup_details.h:176
#define HIGHBIT
Definition: c.h:972
#define VARSIZE_SHORT(PTR)
Definition: postgres.h:306
ExpandedObjectHeader * DatumGetEOHP(Datum d)
Definition: expandeddatum.c:29
#define VARATT_CONVERTED_SHORT_SIZE(PTR)
Definition: postgres.h:274
#define store_att_byval(T, newdatum, attlen)
Definition: tupmacs.h:222
uint8 bits8
Definition: c.h:275
#define VARLENA_ATT_IS_PACKABLE(att)
Definition: heaptuple.c:70
void EOH_flatten_into(ExpandedObjectHeader *eohptr, void *result, Size allocated_size)
Definition: expandeddatum.c:81
#define NULL
Definition: c.h:229
Datum bit(PG_FUNCTION_ARGS)
Definition: varbit.c:361
#define Assert(condition)
Definition: c.h:675
size_t Size
Definition: c.h:356
#define DatumGetPointer(X)
Definition: postgres.h:555
static Datum values[MAXATTR]
Definition: bootstrap.c:163
int i
#define HEAP_HASEXTERNAL
Definition: htup_details.h:177
long val
Definition: informix.c:689
#define VARSIZE_EXTERNAL(PTR)
Definition: postgres.h:310
MinimalTuple heap_form_minimal_tuple ( TupleDesc  tupleDescriptor,
Datum values,
bool isnull 
)

Definition at line 1390 of file heaptuple.c.

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

Referenced by ExecCopySlotMinimalTuple(), and tuplestore_putvalues().

1393 {
1394  MinimalTuple tuple; /* return tuple */
1395  Size len,
1396  data_len;
1397  int hoff;
1398  bool hasnull = false;
1399  int numberOfAttributes = tupleDescriptor->natts;
1400  int i;
1401 
1402  if (numberOfAttributes > MaxTupleAttributeNumber)
1403  ereport(ERROR,
1404  (errcode(ERRCODE_TOO_MANY_COLUMNS),
1405  errmsg("number of columns (%d) exceeds limit (%d)",
1406  numberOfAttributes, MaxTupleAttributeNumber)));
1407 
1408  /*
1409  * Check for nulls
1410  */
1411  for (i = 0; i < numberOfAttributes; i++)
1412  {
1413  if (isnull[i])
1414  {
1415  hasnull = true;
1416  break;
1417  }
1418  }
1419 
1420  /*
1421  * Determine total space needed
1422  */
1424 
1425  if (hasnull)
1426  len += BITMAPLEN(numberOfAttributes);
1427 
1428  if (tupleDescriptor->tdhasoid)
1429  len += sizeof(Oid);
1430 
1431  hoff = len = MAXALIGN(len); /* align user data safely */
1432 
1433  data_len = heap_compute_data_size(tupleDescriptor, values, isnull);
1434 
1435  len += data_len;
1436 
1437  /*
1438  * Allocate and zero the space needed.
1439  */
1440  tuple = (MinimalTuple) palloc0(len);
1441 
1442  /*
1443  * And fill in the information.
1444  */
1445  tuple->t_len = len;
1446  HeapTupleHeaderSetNatts(tuple, numberOfAttributes);
1447  tuple->t_hoff = hoff + MINIMAL_TUPLE_OFFSET;
1448 
1449  if (tupleDescriptor->tdhasoid) /* else leave infomask = 0 */
1450  tuple->t_infomask = HEAP_HASOID;
1451 
1452  heap_fill_tuple(tupleDescriptor,
1453  values,
1454  isnull,
1455  (char *) tuple + hoff,
1456  data_len,
1457  &tuple->t_infomask,
1458  (hasnull ? tuple->t_bits : NULL));
1459 
1460  return tuple;
1461 }
void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
Definition: heaptuple.c:146
bool tdhasoid
Definition: tupdesc.h:79
#define MaxTupleAttributeNumber
Definition: htup_details.h:33
int errcode(int sqlerrcode)
Definition: elog.c:575
#define BITMAPLEN(NATTS)
Definition: htup_details.h:548
unsigned int Oid
Definition: postgres_ext.h:31
int natts
Definition: tupdesc.h:73
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:643
#define ERROR
Definition: elog.h:43
MinimalTupleData * MinimalTuple
Definition: htup.h:27
#define ereport(elevel, rest)
Definition: elog.h:122
#define SizeofMinimalTupleHeader
Definition: htup_details.h:650
void * palloc0(Size size)
Definition: mcxt.c:878
#define NULL
Definition: c.h:229
#define HeapTupleHeaderSetNatts(tup, natts)
Definition: htup_details.h:535
size_t Size
Definition: c.h:356
#define MAXALIGN(LEN)
Definition: c.h:588
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:620
Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:85
static Datum values[MAXATTR]
Definition: bootstrap.c:163
int errmsg(const char *fmt,...)
Definition: elog.c:797
int i
#define HEAP_HASOID
Definition: htup_details.h:178
HeapTuple heap_form_tuple ( TupleDesc  tupleDescriptor,
Datum values,
bool isnull 
)

Definition at line 692 of file heaptuple.c.

References BITMAPLEN, ereport, errcode(), errmsg(), ERROR, heap_compute_data_size(), heap_fill_tuple(), HEAP_HASOID, HeapTupleHeaderSetDatumLength, HeapTupleHeaderSetNatts, HeapTupleHeaderSetTypeId, HeapTupleHeaderSetTypMod, HEAPTUPLESIZE, i, InvalidOid, ItemPointerSetInvalid, MAXALIGN, MaxTupleAttributeNumber, tupleDesc::natts, NULL, 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, tupleDesc::tdhasoid, tupleDesc::tdtypeid, and tupleDesc::tdtypmod.

Referenced by aclexplode(), AddEnumLabel(), AddRoleMems(), AggregateCreate(), AlterSetting(), ATRewriteTable(), brin_metapage_info(), build_dummy_tuple(), BuildTupleFromCStrings(), CollationCreate(), ConversionCreate(), CopyFrom(), 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(), do_convert_tuple(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), elements_worker_jsonb(), EnumValuesCreate(), exec_move_row(), ExecCopySlotTuple(), ExecEvalFieldStoreForm(), ExecEvalRow(), 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(), 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_prepared_xact(), pg_sequence_parameters(), pg_stat_file(), pg_stat_get_archiver(), pg_stat_get_wal_receiver(), 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(), SetSubscriptionRelState(), shdepAddDependency(), shdepChangeDep(), SPI_modifytuple(), ssl_extension_info(), StoreAttrDefault(), StoreCatalogInheritance1(), storeGettuple(), storeOperators(), StorePartitionKey(), storeProcedures(), toast_build_flattened_tuple(), toast_flatten_tuple(), toast_save_datum(), TQRemapTuple(), tsvector_unnest(), TypeCreate(), TypeShellMake(), update_attstats(), and UpdateIndexRelation().

695 {
696  HeapTuple tuple; /* return tuple */
697  HeapTupleHeader td; /* tuple data */
698  Size len,
699  data_len;
700  int hoff;
701  bool hasnull = false;
702  int numberOfAttributes = tupleDescriptor->natts;
703  int i;
704 
705  if (numberOfAttributes > MaxTupleAttributeNumber)
706  ereport(ERROR,
707  (errcode(ERRCODE_TOO_MANY_COLUMNS),
708  errmsg("number of columns (%d) exceeds limit (%d)",
709  numberOfAttributes, MaxTupleAttributeNumber)));
710 
711  /*
712  * Check for nulls
713  */
714  for (i = 0; i < numberOfAttributes; i++)
715  {
716  if (isnull[i])
717  {
718  hasnull = true;
719  break;
720  }
721  }
722 
723  /*
724  * Determine total space needed
725  */
726  len = offsetof(HeapTupleHeaderData, t_bits);
727 
728  if (hasnull)
729  len += BITMAPLEN(numberOfAttributes);
730 
731  if (tupleDescriptor->tdhasoid)
732  len += sizeof(Oid);
733 
734  hoff = len = MAXALIGN(len); /* align user data safely */
735 
736  data_len = heap_compute_data_size(tupleDescriptor, values, isnull);
737 
738  len += data_len;
739 
740  /*
741  * Allocate and zero the space needed. Note that the tuple body and
742  * HeapTupleData management structure are allocated in one chunk.
743  */
744  tuple = (HeapTuple) palloc0(HEAPTUPLESIZE + len);
745  tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
746 
747  /*
748  * And fill in the information. Note we fill the Datum fields even though
749  * this tuple may never become a Datum. This lets HeapTupleHeaderGetDatum
750  * identify the tuple type if needed.
751  */
752  tuple->t_len = len;
753  ItemPointerSetInvalid(&(tuple->t_self));
754  tuple->t_tableOid = InvalidOid;
755 
757  HeapTupleHeaderSetTypeId(td, tupleDescriptor->tdtypeid);
758  HeapTupleHeaderSetTypMod(td, tupleDescriptor->tdtypmod);
759  /* We also make sure that t_ctid is invalid unless explicitly set */
761 
762  HeapTupleHeaderSetNatts(td, numberOfAttributes);
763  td->t_hoff = hoff;
764 
765  if (tupleDescriptor->tdhasoid) /* else leave infomask = 0 */
766  td->t_infomask = HEAP_HASOID;
767 
768  heap_fill_tuple(tupleDescriptor,
769  values,
770  isnull,
771  (char *) td + hoff,
772  data_len,
773  &td->t_infomask,
774  (hasnull ? td->t_bits : NULL));
775 
776  return tuple;
777 }
void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
Definition: heaptuple.c:146
HeapTupleData * HeapTuple
Definition: htup.h:70
Oid tdtypeid
Definition: tupdesc.h:77
#define HeapTupleHeaderSetTypeId(tup, typeid)
Definition: htup_details.h:450
bool tdhasoid
Definition: tupdesc.h:79
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:163
#define MaxTupleAttributeNumber
Definition: htup_details.h:33
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
int errcode(int sqlerrcode)
Definition: elog.c:575
#define BITMAPLEN(NATTS)
Definition: htup_details.h:548
unsigned int Oid
Definition: postgres_ext.h:31
int natts
Definition: tupdesc.h:73
int32 tdtypmod
Definition: tupdesc.h:78
#define HeapTupleHeaderSetDatumLength(tup, len)
Definition: htup_details.h:442
HeapTupleHeader t_data
Definition: htup.h:67
#define ERROR
Definition: elog.h:43
ItemPointerData t_ctid
Definition: htup_details.h:150
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:122
void * palloc0(Size size)
Definition: mcxt.c:878
#define HeapTupleHeaderSetTypMod(tup, typmod)
Definition: htup_details.h:460
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:229
#define HeapTupleHeaderSetNatts(tup, natts)
Definition: htup_details.h:535
size_t Size
Definition: c.h:356
#define MAXALIGN(LEN)
Definition: c.h:588
Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:85
static Datum values[MAXATTR]
Definition: bootstrap.c:163
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:149
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define HEAPTUPLESIZE
Definition: htup.h:72
int i
#define HEAP_HASOID
Definition: htup_details.h:178
#define offsetof(type, field)
Definition: c.h:555
void heap_free_minimal_tuple ( MinimalTuple  mtup)

Definition at line 1467 of file heaptuple.c.

References pfree().

Referenced by ExecClearTuple(), ExecStoreMinimalTuple(), ExecStoreTuple(), and writetup_heap().

1468 {
1469  pfree(mtup);
1470 }
void pfree(void *pointer)
Definition: mcxt.c:950
void heap_freetuple ( HeapTuple  htup)

Definition at line 1372 of file heaptuple.c.

References pfree().

Referenced by acquire_inherited_sample_rows(), acquire_sample_rows(), AddEnumLabel(), 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(), 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(), ATExecValidateConstraint(), build_tuplestore_recursively(), CatalogCacheCreateEntry(), change_owner_fix_column_acls(), changeDependencyFor(), CollationCreate(), ConversionCreate(), copyTemplateDependencies(), create_toast_table(), CreateAccessMethod(), CreateCast(), CreateComments(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateOpFamily(), CreatePolicy(), CreatePublication(), CreateSharedComments(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), crosstab(), DefineOpClass(), DefineQueryRewrite(), DefineSequence(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), EnableDisableRule(), EnableDisableTrigger(), EnumValuesCreate(), EvalPlanQualSetTuple(), examine_attribute(), exec_assign_value(), exec_move_row(), exec_stmt_block(), exec_stmt_return_query(), ExecARDeleteTriggers(), ExecARUpdateTriggers(), ExecBRDeleteTriggers(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecClearTuple(), ExecIRDeleteTriggers(), ExecIRInsertTriggers(), ExecIRUpdateTriggers(), ExecLockRows(), ExecReScanAgg(), ExecReScanSetOp(), ExecScanSubPlan(), ExecSetParamPlan(), ExecStoreMinimalTuple(), ExecStoreTuple(), ExtractReplicaIdentity(), file_acquire_sample_rows(), heap_delete(), heap_insert(), heap_update(), index_build(), 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(), RelationInitPhysicalAddr(), RelationReloadIndexInfo(), RelationSetNewRelfilenode(), RemoveConstraintById(), RemoveInheritance(), RemoveRoleFromObjectPolicy(), renameatt_internal(), RenameConstraintById(), RenameEnumLabel(), RenameRelationInternal(), RenameRewriteRule(), RenameSchema(), RenameTypeInternal(), RenumberEnumType(), replorigin_create(), rewrite_heap_dead_tuple(), rewrite_heap_tuple(), SearchCatCache(), SearchCatCacheList(), SetMatViewPopulatedState(), SetRelationHasSubclass(), SetRelationNumChecks(), SetRelationRuleStatus(), SetSecurityLabel(), SetSharedSecurityLabel(), SetSubscriptionRelState(), shdepAddDependency(), shdepChangeDep(), SPI_freetuple(), statext_store(), StoreAttrDefault(), StoreCatalogInheritance1(), storeOperators(), StorePartitionBound(), storeProcedures(), swap_relation_files(), table_recheck_autovac(), toast_save_datum(), TypeShellMake(), update_attstats(), UpdateIndexRelation(), vac_update_datfrozenxid(), writetup_cluster(), and xpath_table().

1373 {
1374  pfree(htup);
1375 }
void pfree(void *pointer)
Definition: mcxt.c:950
Datum heap_getsysattr ( HeapTuple  tup,
int  attnum,
TupleDesc  tupleDesc,
bool isnull 
)

Definition at line 552 of file heaptuple.c.

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

Referenced by ExecInterpExpr(), and slot_getattr().

553 {
554  Datum result;
555 
556  Assert(tup);
557 
558  /* Currently, no sys attribute ever reads as NULL. */
559  *isnull = false;
560 
561  switch (attnum)
562  {
564  /* pass-by-reference datatype */
565  result = PointerGetDatum(&(tup->t_self));
566  break;
568  result = ObjectIdGetDatum(HeapTupleGetOid(tup));
569  break;
572  break;
575  break;
578 
579  /*
580  * cmin and cmax are now both aliases for the same field, which
581  * can in fact also be a combo command id. XXX perhaps we should
582  * return the "real" cmin or cmax if possible, that is if we are
583  * inside the originating transaction?
584  */
586  break;
588  result = ObjectIdGetDatum(tup->t_tableOid);
589  break;
590  default:
591  elog(ERROR, "invalid attnum: %d", attnum);
592  result = 0; /* keep compiler quiet */
593  break;
594  }
595  return result;
596 }
#define ObjectIdAttributeNumber
Definition: sysattr.h:22
#define PointerGetDatum(X)
Definition: postgres.h:562
return result
Definition: formatting.c:1632
#define MinCommandIdAttributeNumber
Definition: sysattr.h:24
HeapTupleHeader t_data
Definition: htup.h:67
#define HeapTupleHeaderGetRawXmax(tup)
Definition: htup_details.h:369
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
ItemPointerData t_self
Definition: htup.h:65
#define TableOidAttributeNumber
Definition: sysattr.h:27
Oid t_tableOid
Definition: htup.h:66
#define MaxCommandIdAttributeNumber
Definition: sysattr.h:26
#define MaxTransactionIdAttributeNumber
Definition: sysattr.h:25
#define TransactionIdGetDatum(X)
Definition: postgres.h:527
uintptr_t Datum
Definition: postgres.h:372
#define Assert(condition)
Definition: c.h:675
#define HeapTupleHeaderGetRawXmin(tup)
Definition: htup_details.h:302
#define HeapTupleHeaderGetRawCommandId(tup)
Definition: htup_details.h:385
#define CommandIdGetDatum(X)
Definition: postgres.h:548
#define SelfItemPointerAttributeNumber
Definition: sysattr.h:21
#define elog
Definition: elog.h:219
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
#define MinTransactionIdAttributeNumber
Definition: sysattr.h:23
HeapTuple heap_modify_tuple ( HeapTuple  tuple,
TupleDesc  tupleDesc,
Datum replValues,
bool replIsnull,
bool doReplace 
)

Definition at line 791 of file heaptuple.c.

References heap_deform_tuple(), heap_form_tuple(), HeapTupleGetOid, HeapTupleSetOid, tupleDesc::natts, palloc(), pfree(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleData::t_self, HeapTupleData::t_tableOid, tupleDesc::tdhasoid, and values.

Referenced by AddRoleMems(), AlterCollation(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDefault(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPolicy(), AlterPublicationOptions(), AlterRole(), AlterSchemaOwner_internal(), AlterSetting(), AlterSubscription(), AlterTableSpaceOptions(), AlterTSDictionary(), AlterTypeOwnerInternal(), AlterUserMapping(), ApplyExtensionUpdates(), ATExecAlterColumnGenericOptions(), 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(), InsertRule(), inv_truncate(), inv_write(), MakeConfigurationMapping(), movedb(), OperatorCreate(), pg_extension_config_dump(), plperl_modify_tuple(), PLy_modify_tuple(), ProcedureCreate(), recordExtensionInitPrivWorker(), RemoveRoleFromObjectPolicy(), RenameRole(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), SetSubscriptionRelState(), statext_store(), StorePartitionBound(), TypeCreate(), and update_attstats().

796 {
797  int numberOfAttributes = tupleDesc->natts;
798  int attoff;
799  Datum *values;
800  bool *isnull;
801  HeapTuple newTuple;
802 
803  /*
804  * allocate and fill values and isnull arrays from either the tuple or the
805  * repl information, as appropriate.
806  *
807  * NOTE: it's debatable whether to use heap_deform_tuple() here or just
808  * heap_getattr() only the non-replaced columns. The latter could win if
809  * there are many replaced columns and few non-replaced ones. However,
810  * heap_deform_tuple costs only O(N) while the heap_getattr way would cost
811  * O(N^2) if there are many non-replaced columns, so it seems better to
812  * err on the side of linear cost.
813  */
814  values = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
815  isnull = (bool *) palloc(numberOfAttributes * sizeof(bool));
816 
817  heap_deform_tuple(tuple, tupleDesc, values, isnull);
818 
819  for (attoff = 0; attoff < numberOfAttributes; attoff++)
820  {
821  if (doReplace[attoff])
822  {
823  values[attoff] = replValues[attoff];
824  isnull[attoff] = replIsnull[attoff];
825  }
826  }
827 
828  /*
829  * create a new tuple from the values and isnull arrays
830  */
831  newTuple = heap_form_tuple(tupleDesc, values, isnull);
832 
833  pfree(values);
834  pfree(isnull);
835 
836  /*
837  * copy the identification info of the old tuple: t_ctid, t_self, and OID
838  * (if any)
839  */
840  newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
841  newTuple->t_self = tuple->t_self;
842  newTuple->t_tableOid = tuple->t_tableOid;
843  if (tupleDesc->tdhasoid)
844  HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple));
845 
846  return newTuple;
847 }
bool tdhasoid
Definition: tupdesc.h:79
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:692
int natts
Definition: tupdesc.h:73
HeapTupleHeader t_data
Definition: htup.h:67
#define HeapTupleSetOid(tuple, oid)
Definition: htup_details.h:698
void pfree(void *pointer)
Definition: mcxt.c:950
ItemPointerData t_ctid
Definition: htup_details.h:150
ItemPointerData t_self
Definition: htup.h:65
Oid t_tableOid
Definition: htup.h:66
uintptr_t Datum
Definition: postgres.h:372
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:933
static Datum values[MAXATTR]
Definition: bootstrap.c:163
void * palloc(Size size)
Definition: mcxt.c:849
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
HeapTuple heap_modify_tuple_by_cols ( HeapTuple  tuple,
TupleDesc  tupleDesc,
int  nCols,
int *  replCols,
Datum replValues,
bool replIsnull 
)

Definition at line 862 of file heaptuple.c.

References elog, ERROR, heap_deform_tuple(), heap_form_tuple(), HeapTupleGetOid, HeapTupleSetOid, i, tupleDesc::natts, palloc(), pfree(), HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleData::t_self, HeapTupleData::t_tableOid, tupleDesc::tdhasoid, and values.

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

868 {
869  int numberOfAttributes = tupleDesc->natts;
870  Datum *values;
871  bool *isnull;
872  HeapTuple newTuple;
873  int i;
874 
875  /*
876  * allocate and fill values and isnull arrays from the tuple, then replace
877  * selected columns from the input arrays.
878  */
879  values = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
880  isnull = (bool *) palloc(numberOfAttributes * sizeof(bool));
881 
882  heap_deform_tuple(tuple, tupleDesc, values, isnull);
883 
884  for (i = 0; i < nCols; i++)
885  {
886  int attnum = replCols[i];
887 
888  if (attnum <= 0 || attnum > numberOfAttributes)
889  elog(ERROR, "invalid column number %d", attnum);
890  values[attnum - 1] = replValues[i];
891  isnull[attnum - 1] = replIsnull[i];
892  }
893 
894  /*
895  * create a new tuple from the values and isnull arrays
896  */
897  newTuple = heap_form_tuple(tupleDesc, values, isnull);
898 
899  pfree(values);
900  pfree(isnull);
901 
902  /*
903  * copy the identification info of the old tuple: t_ctid, t_self, and OID
904  * (if any)
905  */
906  newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
907  newTuple->t_self = tuple->t_self;
908  newTuple->t_tableOid = tuple->t_tableOid;
909  if (tupleDesc->tdhasoid)
910  HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple));
911 
912  return newTuple;
913 }
bool tdhasoid
Definition: tupdesc.h:79
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:692
int natts
Definition: tupdesc.h:73
HeapTupleHeader t_data
Definition: htup.h:67
#define HeapTupleSetOid(tuple, oid)
Definition: htup_details.h:698
void pfree(void *pointer)
Definition: mcxt.c:950
#define ERROR
Definition: elog.h:43
ItemPointerData t_ctid
Definition: htup_details.h:150
ItemPointerData t_self
Definition: htup.h:65
Oid t_tableOid
Definition: htup.h:66
uintptr_t Datum
Definition: postgres.h:372
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:933
static Datum values[MAXATTR]
Definition: bootstrap.c:163
void * palloc(Size size)
Definition: mcxt.c:849
int i
#define elog
Definition: elog.h:219
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
HeapTuple heap_tuple_from_minimal_tuple ( MinimalTuple  mtup)

Definition at line 1498 of file heaptuple.c.

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

Referenced by ExecCopySlotTuple().

1499 {
1500  HeapTuple result;
1501  uint32 len = mtup->t_len + MINIMAL_TUPLE_OFFSET;
1502 
1503  result = (HeapTuple) palloc(HEAPTUPLESIZE + len);
1504  result->t_len = len;
1505  ItemPointerSetInvalid(&(result->t_self));
1506  result->t_tableOid = InvalidOid;
1507  result->t_data = (HeapTupleHeader) ((char *) result + HEAPTUPLESIZE);
1508  memcpy((char *) result->t_data + MINIMAL_TUPLE_OFFSET, mtup, mtup->t_len);
1509  memset(result->t_data, 0, offsetof(HeapTupleHeaderData, t_infomask2));
1510  return result;
1511 }
HeapTupleData * HeapTuple
Definition: htup.h:70
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
return result
Definition: formatting.c:1632
HeapTupleHeader t_data
Definition: htup.h:67
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
unsigned int uint32
Definition: c.h:268
Oid t_tableOid
Definition: htup.h:66
#define InvalidOid
Definition: postgres_ext.h:36
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:620
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:149
void * palloc(Size size)
Definition: mcxt.c:849
#define HEAPTUPLESIZE
Definition: htup.h:72
#define offsetof(type, field)
Definition: c.h:555
MinimalTuple minimal_tuple_from_heap_tuple ( HeapTuple  htup)

Definition at line 1520 of file heaptuple.c.

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

Referenced by copytup_heap(), and ExecCopySlotMinimalTuple().

1521 {
1523  uint32 len;
1524 
1526  len = htup->t_len - MINIMAL_TUPLE_OFFSET;
1527  result = (MinimalTuple) palloc(len);
1528  memcpy(result, (char *) htup->t_data + MINIMAL_TUPLE_OFFSET, len);
1529  result->t_len = len;
1530  return result;
1531 }
return result
Definition: formatting.c:1632
HeapTupleHeader t_data
Definition: htup.h:67
uint32 t_len
Definition: htup.h:64
MinimalTupleData * MinimalTuple
Definition: htup.h:27
unsigned int uint32
Definition: c.h:268
#define Assert(condition)
Definition: c.h:675
#define MINIMAL_TUPLE_OFFSET
Definition: htup_details.h:620
void * palloc(Size size)
Definition: mcxt.c:849
Datum nocachegetattr ( HeapTuple  tup,
int  attnum,
TupleDesc  att 
)

Definition at line 352 of file heaptuple.c.

References Assert, att_addlength_pointer, att_align_nominal, att_align_pointer, att_isnull, tupleDesc::attrs, byte, fetchatt, HeapTupleHasNulls, HeapTupleHasVarWidth, HeapTupleNoNulls, i, tupleDesc::natts, HeapTupleHeaderData::t_bits, HeapTupleData::t_data, and HeapTupleHeaderData::t_hoff.

355 {
356  HeapTupleHeader tup = tuple->t_data;
358  char *tp; /* ptr to data part of tuple */
359  bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
360  bool slow = false; /* do we have to walk attrs? */
361  int off; /* current offset within data */
362 
363  /* ----------------
364  * Three cases:
365  *
366  * 1: No nulls and no variable-width attributes.
367  * 2: Has a null or a var-width AFTER att.
368  * 3: Has nulls or var-widths BEFORE att.
369  * ----------------
370  */
371 
372  attnum--;
373 
374  if (!HeapTupleNoNulls(tuple))
375  {
376  /*
377  * there's a null somewhere in the tuple
378  *
379  * check to see if any preceding bits are null...
380  */
381  int byte = attnum >> 3;
382  int finalbit = attnum & 0x07;
383 
384  /* check for nulls "before" final bit of last byte */
385  if ((~bp[byte]) & ((1 << finalbit) - 1))
386  slow = true;
387  else
388  {
389  /* check for nulls in any "earlier" bytes */
390  int i;
391 
392  for (i = 0; i < byte; i++)
393  {
394  if (bp[i] != 0xFF)
395  {
396  slow = true;
397  break;
398  }
399  }
400  }
401  }
402 
403  tp = (char *) tup + tup->t_hoff;
404 
405  if (!slow)
406  {
407  /*
408  * If we get here, there are no nulls up to and including the target
409  * attribute. If we have a cached offset, we can use it.
410  */
411  if (att[attnum]->attcacheoff >= 0)
412  {
413  return fetchatt(att[attnum],
414  tp + att[attnum]->attcacheoff);
415  }
416 
417  /*
418  * Otherwise, check for non-fixed-length attrs up to and including
419  * target. If there aren't any, it's safe to cheaply initialize the
420  * cached offsets for these attrs.
421  */
422  if (HeapTupleHasVarWidth(tuple))
423  {
424  int j;
425 
426  for (j = 0; j <= attnum; j++)
427  {
428  if (att[j]->attlen <= 0)
429  {
430  slow = true;
431  break;
432  }
433  }
434  }
435  }
436 
437  if (!slow)
438  {
439  int natts = tupleDesc->natts;
440  int j = 1;
441 
442  /*
443  * If we get here, we have a tuple with no nulls or var-widths up to
444  * and including the target attribute, so we can use the cached offset
445  * ... only we don't have it yet, or we'd not have got here. Since
446  * it's cheap to compute offsets for fixed-width columns, we take the
447  * opportunity to initialize the cached offsets for *all* the leading
448  * fixed-width columns, in hope of avoiding future visits to this
449  * routine.
450  */
451  att[0]->attcacheoff = 0;
452 
453  /* we might have set some offsets in the slow path previously */
454  while (j < natts && att[j]->attcacheoff > 0)
455  j++;
456 
457  off = att[j - 1]->attcacheoff + att[j - 1]->attlen;
458 
459  for (; j < natts; j++)
460  {
461  if (att[j]->attlen <= 0)
462  break;
463 
464  off = att_align_nominal(off, att[j]->attalign);
465 
466  att[j]->attcacheoff = off;
467 
468  off += att[j]->attlen;
469  }
470 
471  Assert(j > attnum);
472 
473  off = att[attnum]->attcacheoff;
474  }
475  else
476  {
477  bool usecache = true;
478  int i;
479 
480  /*
481  * Now we know that we have to walk the tuple CAREFULLY. But we still
482  * might be able to cache some offsets for next time.
483  *
484  * Note - This loop is a little tricky. For each non-null attribute,
485  * we have to first account for alignment padding before the attr,
486  * then advance over the attr based on its length. Nulls have no
487  * storage and no alignment padding either. We can use/set
488  * attcacheoff until we reach either a null or a var-width attribute.
489  */
490  off = 0;
491  for (i = 0;; i++) /* loop exit is at "break" */
492  {
493  if (HeapTupleHasNulls(tuple) && att_isnull(i, bp))
494  {
495  usecache = false;
496  continue; /* this cannot be the target att */
497  }
498 
499  /* If we know the next offset, we can skip the rest */
500  if (usecache && att[i]->attcacheoff >= 0)
501  off = att[i]->attcacheoff;
502  else if (att[i]->attlen == -1)
503  {
504  /*
505  * We can only cache the offset for a varlena attribute if the
506  * offset is already suitably aligned, so that there would be
507  * no pad bytes in any case: then the offset will be valid for
508  * either an aligned or unaligned value.
509  */
510  if (usecache &&
511  off == att_align_nominal(off, att[i]->attalign))
512  att[i]->attcacheoff = off;
513  else
514  {
515  off = att_align_pointer(off, att[i]->attalign, -1,
516  tp + off);
517  usecache = false;
518  }
519  }
520  else
521  {
522  /* not varlena, so safe to use att_align_nominal */
523  off = att_align_nominal(off, att[i]->attalign);
524 
525  if (usecache)
526  att[i]->attcacheoff = off;
527  }
528 
529  if (i == attnum)
530  break;
531 
532  off = att_addlength_pointer(off, att[i]->attlen, tp + off);
533 
534  if (usecache && att[i]->attlen <= 0)
535  usecache = false;
536  }
537  }
538 
539  return fetchatt(att[attnum], tp + off);
540 }
#define HeapTupleHasVarWidth(tuple)
Definition: htup_details.h:668
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:144
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
Definition: htup_details.h:163
#define att_isnull(ATT, BITS)
Definition: tupmacs.h:21
Form_pg_attribute * attrs
Definition: tupdesc.h:74
int natts
Definition: tupdesc.h:73
#define fetchatt(A, T)
Definition: tupmacs.h:37
HeapTupleHeader t_data
Definition: htup.h:67
#define HeapTupleHasNulls(tuple)
Definition: htup_details.h:662
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:172
#define HeapTupleNoNulls(tuple)
Definition: htup_details.h:665
#define byte(x, n)
Definition: rijndael.c:68
uint8 bits8
Definition: c.h:275
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
Definition: tupmacs.h:122
#define Assert(condition)
Definition: c.h:675
int i