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

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.

References ExecCloseIndices(), and pfree().

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

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

◆ CatalogOpenIndexes()

CatalogIndexState CatalogOpenIndexes ( Relation  heapRel)

Definition at line 43 of file indexing.c.

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

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 }
Relation ri_RelationDesc
Definition: execnodes.h:412
Index ri_RangeTableIndex
Definition: execnodes.h:409
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
Definition: execIndexing.c:151
TriggerDesc * ri_TrigDesc
Definition: execnodes.h:424
#define makeNode(_type_)
Definition: nodes.h:575

◆ CatalogTupleDelete()

void CatalogTupleDelete ( Relation  heapRel,
ItemPointer  tid 
)

Definition at line 350 of file indexing.c.

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(), RemovePublicationRelById(), RemoveRewriteRuleById(), RemoveStatistics(), RemoveStatisticsById(), RemoveSubscriptionRel(), RemoveTriggerById(), RemoveTSConfigurationById(), RemoveTypeById(), replorigin_drop(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), and shdepDropDependency().

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

◆ CatalogTupleInsert()

void CatalogTupleInsert ( Relation  heapRel,
HeapTuple  tup 
)

Definition at line 221 of file indexing.c.

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(), CreateTrigger(), CreateUserMapping(), DefineOpClass(), DefineSequence(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), EnumValuesCreate(), IndexSetParentIndex(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertPgClassTuple(), InsertRule(), LargeObjectCreate(), MakeConfigurationMapping(), NamespaceCreate(), OperatorCreate(), OperatorShellMake(), ProcedureCreate(), publication_add_relation(), RangeCreate(), recordExtensionInitPrivWorker(), replorigin_create(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepAddDependency(), shdepChangeDep(), StoreAttrDefault(), storeOperators(), StorePartitionKey(), storeProcedures(), StoreSingleInheritance(), TypeCreate(), TypeShellMake(), update_attstats(), and UpdateIndexRelation().

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 }
static void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
Definition: indexing.c:75
void simple_heap_insert(Relation relation, HeapTuple tup)
Definition: heapam.c:2384
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
Definition: indexing.c:43
void CatalogCloseIndexes(CatalogIndexState indstate)
Definition: indexing.c:61
#define CatalogTupleCheckConstraints(heapRel, tup)
Definition: indexing.c:204

◆ CatalogTupleInsertWithInfo()

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

Definition at line 244 of file indexing.c.

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

Referenced by inv_truncate(), and inv_write().

246 {
247  CatalogTupleCheckConstraints(heapRel, tup);
248 
249  simple_heap_insert(heapRel, tup);
250 
251  CatalogIndexInsert(indstate, tup);
252 }
static void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
Definition: indexing.c:75
void simple_heap_insert(Relation relation, HeapTuple tup)
Definition: heapam.c:2384
#define CatalogTupleCheckConstraints(heapRel, tup)
Definition: indexing.c:204

◆ CatalogTuplesMultiInsertWithInfo()

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

Definition at line 261 of file indexing.c.

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

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

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 }
Oid tts_tableOid
Definition: tuptable.h:131
static void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
Definition: indexing.c:75
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
Oid t_tableOid
Definition: htup.h:66
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
Definition: execTuples.c:1614
int i
void heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, CommandId cid, int options, BulkInsertState bistate)
Definition: heapam.c:2097
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:761

◆ CatalogTupleUpdate()

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

Definition at line 301 of file indexing.c.

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

Referenced by AddRoleMems(), AggregateCreate(), 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(), ATExecAlterConstraint(), ATExecChangeOwner(), ATExecDetachPartition(), ATExecDisableRowSecurity(), ATExecDropColumn(), ATExecDropConstraint(), ATExecDropExpression(), ATExecDropIdentity(), ATExecDropNotNull(), ATExecDropOf(), ATExecEnableRowSecurity(), ATExecForceNoForceRowSecurity(), ATExecGenericOptions(), ATExecSetIdentity(), ATExecSetNotNull(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecSetStatistics(), ATExecSetStorage(), ATExecSetTableSpace(), ATExecSetTableSpaceNoStorage(), ATExecValidateConstraint(), change_owner_fix_column_acls(), changeDependenciesOf(), changeDependenciesOn(), changeDependencyFor(), ConstraintSetParentConstraint(), copy_table_data(), create_toast_table(), CreateComments(), CreateProceduralLanguage(), CreateSharedComments(), CreateTransform(), CreateTrigger(), DefineIndex(), DefineQueryRewrite(), DelRoleMems(), 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(), 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(), RenameTypeInternal(), RenumberEnumType(), SetAttrMissing(), SetDefaultACL(), SetMatViewPopulatedState(), SetRelationHasSubclass(), SetRelationNumChecks(), SetRelationRuleStatus(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepChangeDep(), statext_store(), StoreAttrDefault(), StorePartitionBound(), TypeCreate(), update_attstats(), update_default_partition_oid(), update_relispartition(), UpdateStatisticsForTypeChange(), UpdateSubscriptionRelState(), validatePartitionedIndex(), and visitDependenciesOf().

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 }
static void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
Definition: indexing.c:75
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
Definition: indexing.c:43
void simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
Definition: heapam.c:3885
void CatalogCloseIndexes(CatalogIndexState indstate)
Definition: indexing.c:61
#define CatalogTupleCheckConstraints(heapRel, tup)
Definition: indexing.c:204

◆ CatalogTupleUpdateWithInfo()

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

Definition at line 324 of file indexing.c.

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

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

326 {
327  CatalogTupleCheckConstraints(heapRel, tup);
328 
329  simple_heap_update(heapRel, otid, tup);
330 
331  CatalogIndexInsert(indstate, tup);
332 }
static void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
Definition: indexing.c:75
void simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
Definition: heapam.c:3885
#define CatalogTupleCheckConstraints(heapRel, tup)
Definition: indexing.c:204