PostgreSQL Source Code  git master
indexing.h File Reference
#include "access/htup.h"
#include "nodes/execnodes.h"
#include "utils/relcache.h"
Include dependency graph for indexing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX_CATALOG_MULTI_INSERT_BYTES   65535
 

Typedefs

typedef struct ResultRelInfoCatalogIndexState
 

Functions

CatalogIndexState CatalogOpenIndexes (Relation heapRel)
 
void CatalogCloseIndexes (CatalogIndexState indstate)
 
void CatalogTupleInsert (Relation heapRel, HeapTuple tup)
 
void CatalogTupleInsertWithInfo (Relation heapRel, HeapTuple tup, CatalogIndexState indstate)
 
void CatalogTuplesMultiInsertWithInfo (Relation heapRel, TupleTableSlot **slot, int ntuples, CatalogIndexState indstate)
 
void CatalogTupleUpdate (Relation heapRel, ItemPointer otid, HeapTuple tup)
 
void CatalogTupleUpdateWithInfo (Relation heapRel, ItemPointer otid, HeapTuple tup, CatalogIndexState indstate)
 
void CatalogTupleDelete (Relation heapRel, ItemPointer tid)
 

Macro Definition Documentation

◆ MAX_CATALOG_MULTI_INSERT_BYTES

#define MAX_CATALOG_MULTI_INSERT_BYTES   65535

Definition at line 33 of file indexing.h.

Typedef Documentation

◆ CatalogIndexState

Definition at line 27 of file indexing.h.

Function Documentation

◆ CatalogCloseIndexes()

void CatalogCloseIndexes ( CatalogIndexState  indstate)

Definition at line 61 of file indexing.c.

62 {
63  ExecCloseIndices(indstate);
64  pfree(indstate);
65 }
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
Definition: execIndexing.c:231
void pfree(void *pointer)
Definition: mcxt.c:1169

References ExecCloseIndices(), and pfree().

Referenced by AddNewAttributeTuples(), AppendAttributeTuples(), CatalogTupleInsert(), CatalogTupleUpdate(), copyTemplateDependencies(), InsertPgAttributeTuples(), inv_truncate(), inv_write(), recordMultipleDependencies(), and swap_relation_files().

◆ CatalogOpenIndexes()

CatalogIndexState CatalogOpenIndexes ( Relation  heapRel)

Definition at line 43 of file indexing.c.

44 {
45  ResultRelInfo *resultRelInfo;
46 
47  resultRelInfo = makeNode(ResultRelInfo);
48  resultRelInfo->ri_RangeTableIndex = 0; /* dummy */
49  resultRelInfo->ri_RelationDesc = heapRel;
50  resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */
51 
52  ExecOpenIndices(resultRelInfo, false);
53 
54  return resultRelInfo;
55 }
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
Definition: execIndexing.c:156
#define makeNode(_type_)
Definition: nodes.h:587
Relation ri_RelationDesc
Definition: execnodes.h:416
TriggerDesc * ri_TrigDesc
Definition: execnodes.h:443
Index ri_RangeTableIndex
Definition: execnodes.h:413

References ExecOpenIndices(), makeNode, ResultRelInfo::ri_RangeTableIndex, ResultRelInfo::ri_RelationDesc, and ResultRelInfo::ri_TrigDesc.

Referenced by AddNewAttributeTuples(), AppendAttributeTuples(), CatalogTupleInsert(), CatalogTupleUpdate(), copyTemplateDependencies(), InsertPgAttributeTuples(), inv_truncate(), inv_write(), recordMultipleDependencies(), and swap_relation_files().

◆ CatalogTupleDelete()

void CatalogTupleDelete ( Relation  heapRel,
ItemPointer  tid 
)

Definition at line 350 of file indexing.c.

351 {
352  simple_heap_delete(heapRel, tid);
353 }
void simple_heap_delete(Relation relation, ItemPointer tid)
Definition: heapam.c:3107

References simple_heap_delete().

Referenced by AlterSetting(), ATExecAlterColumnType(), ATExecDropExpression(), changeDependenciesOn(), changeDependencyFor(), CreateComments(), CreateSharedComments(), DeleteAttributeTuples(), DeleteComments(), deleteDependencyRecordsFor(), deleteDependencyRecordsForClass(), deleteDependencyRecordsForSpecific(), DeleteInheritsTuple(), DeleteInitPrivs(), deleteOneObject(), DeleteRelationTuple(), DeleteSecurityLabel(), DeleteSequenceTuple(), DeleteSharedComments(), DeleteSharedSecurityLabel(), DeleteSystemAttributeTuples(), DelRoleMems(), drop_parent_dependency(), DropConfigurationMapping(), dropDatabaseDependencies(), dropdb(), DropObjectById(), DropRole(), DropSetting(), DropSubscription(), DropTableSpace(), EnumValuesDelete(), heap_drop_with_catalog(), index_drop(), IndexSetParentIndex(), inv_truncate(), LargeObjectDrop(), MakeConfigurationMapping(), RangeDelete(), recordExtensionInitPrivWorker(), RelationRemoveInheritance(), RemoveAttrDefaultById(), RemoveAttributeById(), RemoveConstraintById(), RemoveExtensionById(), RemoveFunctionById(), RemoveOperatorById(), RemovePartitionKeyByRelId(), RemovePolicyById(), RemovePublicationById(), RemovePublicationRelById(), RemovePublicationSchemaById(), RemoveRewriteRuleById(), RemoveStatistics(), RemoveStatisticsById(), RemoveStatisticsDataById(), RemoveSubscriptionRel(), RemoveTriggerById(), RemoveTSConfigurationById(), RemoveTypeById(), replorigin_drop_guts(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), and shdepDropDependency().

◆ CatalogTupleInsert()

void CatalogTupleInsert ( Relation  heapRel,
HeapTuple  tup 
)

Definition at line 221 of file indexing.c.

222 {
223  CatalogIndexState indstate;
224 
225  CatalogTupleCheckConstraints(heapRel, tup);
226 
227  indstate = CatalogOpenIndexes(heapRel);
228 
229  simple_heap_insert(heapRel, tup);
230 
231  CatalogIndexInsert(indstate, tup);
232  CatalogCloseIndexes(indstate);
233 }
void simple_heap_insert(Relation relation, HeapTuple tup)
Definition: heapam.c:2642
static void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
Definition: indexing.c:75
#define CatalogTupleCheckConstraints(heapRel, tup)
Definition: indexing.c:205
void CatalogCloseIndexes(CatalogIndexState indstate)
Definition: indexing.c:61
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
Definition: indexing.c:43

References CatalogCloseIndexes(), CatalogIndexInsert(), CatalogOpenIndexes(), CatalogTupleCheckConstraints, and simple_heap_insert().

Referenced by AddEnumLabel(), AddRoleMems(), AddSubscriptionRelState(), AggregateCreate(), AlterSetting(), CastCreate(), CollationCreate(), ConversionCreate(), CopyStatistics(), CreateAccessMethod(), CreateComments(), CreateConstraintEntry(), createdb(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateOpFamily(), CreatePolicy(), CreateProceduralLanguage(), CreatePublication(), CreateRole(), CreateSharedComments(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTriggerFiringOn(), CreateUserMapping(), DefineOpClass(), DefineSequence(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), EnumValuesCreate(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertPgClassTuple(), InsertRule(), LargeObjectCreate(), MakeConfigurationMapping(), NamespaceCreate(), OperatorCreate(), OperatorShellMake(), ProcedureCreate(), publication_add_relation(), publication_add_schema(), RangeCreate(), recordExtensionInitPrivWorker(), replorigin_create(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepAddDependency(), shdepChangeDep(), statext_store(), StoreAttrDefault(), storeOperators(), StorePartitionKey(), storeProcedures(), StoreSingleInheritance(), TypeCreate(), TypeShellMake(), update_attstats(), and UpdateIndexRelation().

◆ CatalogTupleInsertWithInfo()

void CatalogTupleInsertWithInfo ( Relation  heapRel,
HeapTuple  tup,
CatalogIndexState  indstate 
)

Definition at line 244 of file indexing.c.

246 {
247  CatalogTupleCheckConstraints(heapRel, tup);
248 
249  simple_heap_insert(heapRel, tup);
250 
251  CatalogIndexInsert(indstate, tup);
252 }

References CatalogIndexInsert(), CatalogTupleCheckConstraints, and simple_heap_insert().

Referenced by inv_truncate(), and inv_write().

◆ CatalogTuplesMultiInsertWithInfo()

void CatalogTuplesMultiInsertWithInfo ( Relation  heapRel,
TupleTableSlot **  slot,
int  ntuples,
CatalogIndexState  indstate 
)

Definition at line 261 of file indexing.c.

263 {
264  /* Nothing to do */
265  if (ntuples <= 0)
266  return;
267 
268  heap_multi_insert(heapRel, slot, ntuples,
269  GetCurrentCommandId(true), 0, NULL);
270 
271  /*
272  * There is no equivalent to heap_multi_insert for the catalog indexes, so
273  * we must loop over and insert individually.
274  */
275  for (int i = 0; i < ntuples; i++)
276  {
277  bool should_free;
278  HeapTuple tuple;
279 
280  tuple = ExecFetchSlotHeapTuple(slot[i], true, &should_free);
281  tuple->t_tableOid = slot[i]->tts_tableOid;
282  CatalogIndexInsert(indstate, tuple);
283 
284  if (should_free)
285  heap_freetuple(tuple);
286  }
287 }
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1644
void heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, CommandId cid, int options, BulkInsertState bistate)
Definition: heapam.c:2302
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
int i
Definition: isn.c:73
Oid t_tableOid
Definition: htup.h:66
Oid tts_tableOid
Definition: tuptable.h:131
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:813

References CatalogIndexInsert(), ExecFetchSlotHeapTuple(), GetCurrentCommandId(), heap_freetuple(), heap_multi_insert(), i, HeapTupleData::t_tableOid, and TupleTableSlot::tts_tableOid.

Referenced by copyTemplateDependencies(), InsertPgAttributeTuples(), and recordMultipleDependencies().

◆ CatalogTupleUpdate()

void CatalogTupleUpdate ( Relation  heapRel,
ItemPointer  otid,
HeapTuple  tup 
)

Definition at line 301 of file indexing.c.

302 {
303  CatalogIndexState indstate;
304 
305  CatalogTupleCheckConstraints(heapRel, tup);
306 
307  indstate = CatalogOpenIndexes(heapRel);
308 
309  simple_heap_update(heapRel, otid, tup);
310 
311  CatalogIndexInsert(indstate, tup);
312  CatalogCloseIndexes(indstate);
313 }
void simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
Definition: heapam.c:4140

References CatalogCloseIndexes(), CatalogIndexInsert(), CatalogOpenIndexes(), CatalogTupleCheckConstraints, and simple_heap_update().

Referenced by AddRoleMems(), AggregateCreate(), AlterCollation(), AlterConstraintNamespaces(), AlterDatabase(), AlterDatabaseOwner(), AlterDomainDefault(), AlterDomainNotNull(), AlterDomainValidateConstraint(), AlterEventTrigger(), AlterEventTriggerOwner_internal(), AlterExtensionNamespace(), AlterForeignDataWrapper(), AlterForeignDataWrapperOwner_internal(), AlterForeignServer(), AlterForeignServerOwner_internal(), AlterFunction(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPolicy(), AlterPublicationOptions(), AlterPublicationOwner_internal(), AlterRelationNamespaceInternal(), AlterRole(), AlterSchemaOwner_internal(), AlterSequence(), AlterSetting(), AlterStatistics(), AlterSubscription(), AlterSubscriptionOwner_internal(), AlterTableSpaceOptions(), AlterTSDictionary(), AlterTypeNamespaceInternal(), AlterTypeOwnerInternal(), AlterTypeRecurse(), AlterUserMapping(), ApplyExtensionUpdates(), ATExecAddColumn(), ATExecAddIdentity(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecAlterConstrRecurse(), ATExecChangeOwner(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropExpression(), ATExecDropIdentity(), ATExecDropNotNull(), ATExecDropOf(), ATExecForceNoForceRowSecurity(), ATExecGenericOptions(), ATExecSetCompression(), ATExecSetIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecSetRowSecurity(), ATExecSetStatistics(), ATExecSetStorage(), ATExecValidateConstraint(), change_owner_fix_column_acls(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), ConstraintSetParentConstraint(), copy_table_data(), create_toast_table(), CreateComments(), CreateProceduralLanguage(), CreateSharedComments(), CreateTransform(), CreateTriggerFiringOn(), DefineIndex(), DefineQueryRewrite(), DelRoleMems(), DetachPartitionFinalize(), EnableDisableRule(), EnableDisableTrigger(), 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(), finish_heap_swap(), index_build(), index_concurrently_swap(), index_constraint_create(), index_set_state_flags(), InsertRule(), MakeConfigurationMapping(), mark_index_clustered(), MarkInheritDetached(), MergeAttributesIntoExisting(), MergeConstraintsIntoExisting(), MergeWithExistingConstraint(), movedb(), OperatorCreate(), OperatorUpd(), pg_extension_config_dump(), ProcedureCreate(), recordExtensionInitPrivWorker(), reindex_index(), relation_mark_replica_identity(), RelationClearMissing(), RelationSetNewRelfilenode(), RemoveAttrDefaultById(), RemoveAttributeById(), RemoveConstraintById(), RemoveInheritance(), RemoveRoleFromObjectPolicy(), rename_policy(), renameatt_internal(), RenameConstraintById(), RenameDatabase(), RenameEnumLabel(), RenameRelationInternal(), RenameRewriteRule(), RenameRole(), RenameSchema(), RenameTableSpace(), renametrig_internal(), RenameTypeInternal(), RenumberEnumType(), ResetRelRewrite(), SetAttrMissing(), SetDefaultACL(), SetIndexStorageProperties(), SetMatViewPopulatedState(), SetRelationHasSubclass(), SetRelationNumChecks(), SetRelationRuleStatus(), SetRelationTableSpace(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), StoreAttrDefault(), StorePartitionBound(), TriggerSetParentTrigger(), TypeCreate(), update_attstats(), update_default_partition_oid(), update_relispartition(), UpdateSubscriptionRelState(), UpdateTwoPhaseState(), and validatePartitionedIndex().

◆ CatalogTupleUpdateWithInfo()

void CatalogTupleUpdateWithInfo ( Relation  heapRel,
ItemPointer  otid,
HeapTuple  tup,
CatalogIndexState  indstate 
)

Definition at line 324 of file indexing.c.

326 {
327  CatalogTupleCheckConstraints(heapRel, tup);
328 
329  simple_heap_update(heapRel, otid, tup);
330 
331  CatalogIndexInsert(indstate, tup);
332 }

References CatalogIndexInsert(), CatalogTupleCheckConstraints, and simple_heap_update().

Referenced by inv_truncate(), inv_write(), and swap_relation_files().