72#include "utils/fmgroids.h"
104 const List *indexColNames,
106 const Oid *collationIds,
107 const Oid *opclassIds);
109 int numatts,
Oid indexoid);
114 const Oid *collationOids,
115 const Oid *opclassOids,
116 const int16 *coloptions,
160 foreach(indexoidscan, indexoidlist)
167 elog(
ERROR,
"cache lookup failed for index %u", indexoid);
214 if ((is_alter_table || heapRel->
rd_rel->relispartition) &&
218 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
219 errmsg(
"multiple primary keys for table \"%s\" are not allowed",
232 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
233 errmsg(
"primary keys cannot use NULLS NOT DISTINCT indexes")));
249 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
250 errmsg(
"primary keys cannot be expressions")));
260 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
264 if (!attform->attnotnull)
266 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
267 errmsg(
"primary key column \"%s\" is not marked NOT NULL",
282 const List *indexColNames,
284 const Oid *collationIds,
285 const Oid *opclassIds)
312 for (
i = 0;
i < numatts;
i++)
323 to->attislocal =
true;
324 to->attcollation = (
i < numkeyatts) ? collationIds[
i] :
InvalidOid;
329 if (colnames_item == NULL)
330 elog(
ERROR,
"too few entries in colnames list");
332 colnames_item =
lnext(indexColNames, colnames_item);
347 elog(
ERROR,
"invalid column number %d", atnum);
351 to->atttypid = from->atttypid;
352 to->attlen = from->attlen;
353 to->attndims = from->attndims;
354 to->atttypmod = from->atttypmod;
355 to->attbyval = from->attbyval;
356 to->attalign = from->attalign;
357 to->attstorage = from->attstorage;
358 to->attcompression = from->attcompression;
365 if (indexpr_item == NULL)
366 elog(
ERROR,
"too few entries in indexprs list");
376 elog(
ERROR,
"cache lookup failed for type %u", keyType);
382 to->atttypid = keyType;
383 to->attlen = typeTup->typlen;
385 to->attbyval = typeTup->typbyval;
386 to->attalign = typeTup->typalign;
387 to->attstorage = typeTup->typstorage;
410 to->atttypid, to->attcollation,
428 if (i < indexInfo->ii_NumIndexKeyAttrs)
432 elog(
ERROR,
"cache lookup failed for opclass %u", opclassIds[
i]);
435 keyType = opclassTup->opckeytype;
446 if (keyType == ANYELEMENTOID && opclassTup->opcintype == ANYARRAYOID)
450 elog(
ERROR,
"could not get element type of array type %u",
461 if (
OidIsValid(keyType) && keyType != to->atttypid)
465 elog(
ERROR,
"cache lookup failed for type %u", keyType);
468 to->atttypid = keyType;
470 to->attlen = typeTup->typlen;
471 to->attbyval = typeTup->typbyval;
472 to->attalign = typeTup->typalign;
473 to->attstorage = typeTup->typstorage;
502 for (
i = 0;
i < numatts;
i += 1)
566 const Oid *collationOids,
567 const Oid *opclassOids,
568 const int16 *coloptions,
582 bool nulls[Natts_pg_index] = {0};
610 exprsDatum = (
Datum) 0;
625 predDatum = (
Datum) 0;
655 values[Anum_pg_index_indexprs - 1] = exprsDatum;
656 if (exprsDatum == (
Datum) 0)
657 nulls[Anum_pg_index_indexprs - 1] =
true;
658 values[Anum_pg_index_indpred - 1] = predDatum;
659 if (predDatum == (
Datum) 0)
660 nulls[Anum_pg_index_indpred - 1] =
true;
726 const char *indexRelationName,
728 Oid parentIndexRelid,
729 Oid parentConstraintId,
732 const List *indexColNames,
735 const Oid *collationIds,
736 const Oid *opclassIds,
737 const Datum *opclassOptions,
738 const int16 *coloptions,
743 bool allow_system_table_mods,
751 bool shared_relation;
752 bool mapped_relation;
767 Assert((constr_flags == 0) ||
772 relkind = partitioned ? RELKIND_PARTITIONED_INDEX : RELKIND_INDEX;
784 shared_relation = heapRelation->
rd_rel->relisshared;
786 relpersistence = heapRelation->
rd_rel->relpersistence;
792 elog(
ERROR,
"must index at least one column");
794 if (!allow_system_table_mods &&
798 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
799 errmsg(
"user-defined indexes on system catalog tables are not supported")));
822 Oid collation = collationIds[
i];
823 Oid opclass = opclassIds[
i];
827 if ((opclass == TEXT_BTREE_PATTERN_OPS_OID ||
828 opclass == VARCHAR_BTREE_PATTERN_OPS_OID ||
829 opclass == BPCHAR_BTREE_PATTERN_OPS_OID) &&
836 elog(
ERROR,
"cache lookup failed for operator class %u", opclass);
838 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
839 errmsg(
"nondeterministic collations are not supported for operator class \"%s\"",
853 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
854 errmsg(
"concurrent index creation on system catalog tables is not supported")));
860 if (concurrent && is_exclusion)
862 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
863 errmsg(
"concurrent index creation for exclusion constraints is not supported")));
871 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
872 errmsg(
"shared indexes cannot be created after initdb")));
877 if (shared_relation && tableSpaceId != GLOBALTABLESPACE_OID)
878 elog(
ERROR,
"shared relations must be placed in pg_global tablespace");
891 (
errcode(ERRCODE_DUPLICATE_TABLE),
892 errmsg(
"relation \"%s\" already exists, skipping",
893 indexRelationName)));
899 (
errcode(ERRCODE_DUPLICATE_TABLE),
900 errmsg(
"relation \"%s\" already exists",
901 indexRelationName)));
914 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
941 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
942 errmsg(
"pg_class index OID value not set when in binary upgrade mode")));
948 if ((relkind == RELKIND_INDEX) &&
951 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
952 errmsg(
"index relfilenumber value not set when in binary upgrade mode")));
986 allow_system_table_mods,
1008 indexRelation->
rd_rel->relowner = heapRelation->
rd_rel->relowner;
1009 indexRelation->
rd_rel->relam = accessMethodId;
1046 collationIds, opclassIds, coloptions,
1047 isprimary, is_exclusion,
1090 char constraintType;
1094 constraintType = CONSTRAINT_PRIMARY;
1096 constraintType = CONSTRAINT_UNIQUE;
1097 else if (is_exclusion)
1098 constraintType = CONSTRAINT_EXCLUSION;
1101 elog(
ERROR,
"constraint must be PRIMARY, UNIQUE or EXCLUDE");
1112 allow_system_table_mods,
1115 *constraintId = localaddr.
objectId;
1119 bool have_simple_col =
false;
1132 have_simple_col =
true;
1142 if (!have_simple_col)
1176 if (
OidIsValid(collationIds[
i]) && collationIds[
i] != DEFAULT_COLLATION_OID)
1221 indexRelationId, 0, is_internal);
1277 index_build(heapRelation, indexRelation, indexInfo,
false,
true);
1286 return indexRelationId;
1300 Oid tablespaceOid,
const char *newName)
1308 Datum indclassDatum,
1311 Datum *opclassOptions;
1331 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1332 errmsg(
"concurrent index creation for exclusion constraints is not supported")));
1337 elog(
ERROR,
"cache lookup failed for index %u", oldIndexId);
1339 Anum_pg_index_indclass);
1343 Anum_pg_index_indoption);
1349 elog(
ERROR,
"cache lookup failed for relation %u", oldIndexId);
1351 Anum_pg_class_reloptions, &isnull);
1364 Anum_pg_index_indexprs);
1375 Anum_pg_index_indpred);
1429 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1431 dat =
SysCacheGetAttr(ATTNUM, tp, Anum_pg_attribute_attstattarget, &isnull);
1433 stattargets[
i].
value = dat;
1434 stattargets[
i].
isnull = isnull;
1452 indexRelation->
rd_rel->relam,
1485 Oid indexRelationId)
1489 int save_sec_context;
1524 index_build(heapRel, indexRelation, indexInfo,
false,
true);
1568 Oid indexConstraintOid;
1584 elog(
ERROR,
"could not find tuple for relation %u", oldIndexId);
1588 elog(
ERROR,
"could not find tuple for relation %u", newIndexId);
1598 isPartition = newClassForm->relispartition;
1599 newClassForm->relispartition = oldClassForm->relispartition;
1600 oldClassForm->relispartition = isPartition;
1614 elog(
ERROR,
"could not find tuple for relation %u", oldIndexId);
1618 elog(
ERROR,
"could not find tuple for relation %u", newIndexId);
1627 newIndexForm->indisprimary = oldIndexForm->indisprimary;
1628 oldIndexForm->indisprimary =
false;
1629 newIndexForm->indisexclusion = oldIndexForm->indisexclusion;
1630 oldIndexForm->indisexclusion =
false;
1631 newIndexForm->indimmediate = oldIndexForm->indimmediate;
1632 oldIndexForm->indimmediate =
true;
1635 newIndexForm->indisreplident = oldIndexForm->indisreplident;
1638 newIndexForm->indisclustered = oldIndexForm->indisclustered;
1644 newIndexForm->indisvalid =
true;
1645 oldIndexForm->indisvalid =
false;
1646 oldIndexForm->indisclustered =
false;
1647 oldIndexForm->indisreplident =
false;
1664 constraintOids =
lappend_oid(constraintOids, indexConstraintOid);
1669 foreach(lc, constraintOids)
1682 elog(
ERROR,
"could not find tuple for constraint %u", constraintOid);
1686 if (conForm->conindid == oldIndexId)
1688 conForm->conindid = newIndexId;
1697 Anum_pg_trigger_tgconstraint,
1708 if (tgForm->tgconstrindid != oldIndexId)
1715 tgForm->tgconstrindid = newIndexId;
1734 bool nulls[Natts_pg_description] = {0};
1735 bool replaces[Natts_pg_description] = {0};
1738 replaces[Anum_pg_description_objoid - 1] =
true;
1741 Anum_pg_description_objoid,
1745 Anum_pg_description_classoid,
1749 Anum_pg_description_objsubid,
1761 values, nulls, replaces);
1885 Oid indexRelationId,
1886 Oid parentConstraintId,
1888 const char *constraintName,
1889 char constraintType,
1891 bool allow_system_table_mods,
1900 bool mark_as_primary;
1903 bool is_without_overlaps;
1915 if (!allow_system_table_mods &&
1919 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1920 errmsg(
"user-defined indexes on system catalog tables are not supported")));
1924 constraintType != CONSTRAINT_EXCLUSION)
1925 elog(
ERROR,
"constraints cannot have index expressions");
1987 is_without_overlaps,
2026 trigger->
trigname = (constraintType == CONSTRAINT_PRIMARY) ?
2027 "PK_ConstraintTrigger" :
2028 "Unique_ConstraintTrigger";
2032 trigger->
row =
true;
2033 trigger->
timing = TRIGGER_TYPE_AFTER;
2034 trigger->
events = TRIGGER_TYPE_INSERT | TRIGGER_TYPE_UPDATE;
2056 (mark_as_primary || deferrable))
2062 bool marked_as_primary =
false;
2069 elog(
ERROR,
"cache lookup failed for index %u", indexRelationId);
2072 if (mark_as_primary && !indexForm->indisprimary)
2074 indexForm->indisprimary =
true;
2076 marked_as_primary =
true;
2079 if (deferrable && indexForm->indimmediate)
2081 indexForm->indimmediate =
false;
2095 if (marked_as_primary)
2141 (!concurrent && !concurrent_lock_mode));
2163 userHeapRelation =
table_open(heapId, lockmode);
2164 userIndexRelation =
index_open(indexId, lockmode);
2220 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2221 errmsg(
"DROP INDEX CONCURRENTLY must be first action in transaction")));
2324 if (RELKIND_HAS_STORAGE(userIndexRelation->
rd_rel->relkind))
2352 elog(
ERROR,
"cache lookup failed for index %u", indexId);
2435 numAtts = indexStruct->indnatts;
2437 elog(
ERROR,
"invalid indnatts %d for index %u",
2445 indexStruct->indnkeyatts,
2446 index->rd_rel->relam,
2449 indexStruct->indisunique,
2450 indexStruct->indnullsnotdistinct,
2451 indexStruct->indisready,
2453 index->rd_indam->amsummarizing,
2454 indexStruct->indisexclusion && indexStruct->indisunique);
2457 for (
i = 0;
i < numAtts;
i++)
2461 if (indexStruct->indisexclusion)
2495 numAtts = indexStruct->indnatts;
2497 elog(
ERROR,
"invalid indnatts %d for index %u",
2505 indexStruct->indnkeyatts,
2506 index->rd_rel->relam,
2509 indexStruct->indisunique,
2510 indexStruct->indnullsnotdistinct,
2511 indexStruct->indisready,
2513 index->rd_indam->amsummarizing,
2514 indexStruct->indisexclusion && indexStruct->indisunique);
2517 for (
i = 0;
i < numAtts;
i++)
2537 const Oid *collations1,
const Oid *collations2,
2538 const Oid *opfamilies1,
const Oid *opfamilies2,
2591 if (collations1[
i] != collations2[
i])
2593 if (opfamilies1[
i] != opfamilies2[
i])
2605 bool found_whole_row;
2611 if (found_whole_row)
2629 bool found_whole_row;
2635 if (found_whole_row)
2680 if (
index->rd_rel->relam != BTREE_AM_OID)
2681 elog(
ERROR,
"unexpected non-btree speculative unique index");
2692 for (
i = 0;
i < indnkeyatts;
i++)
2701 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
2756 else if (keycol != 0)
2769 if (indexpr_item == NULL)
2770 elog(
ERROR,
"wrong number of index expressions");
2780 if (indexpr_item != NULL)
2781 elog(
ERROR,
"wrong number of index expressions");
2832 if (reltuples == 0 && rel->
rd_rel->reltuples < 0)
2852 if (rel->
rd_rel->relkind != RELKIND_INDEX)
2894 elog(
ERROR,
"could not find tuple for relation %u", relid);
2898 Assert(rd_rel->relkind != RELKIND_PARTITIONED_INDEX);
2903 if (rd_rel->relhasindex != hasindex)
2905 rd_rel->relhasindex = hasindex;
2911 if (rd_rel->relpages != (
int32) relpages)
2913 rd_rel->relpages = (
int32) relpages;
2916 if (rd_rel->reltuples != (
float4) reltuples)
2918 rd_rel->reltuples = (
float4) reltuples;
2921 if (rd_rel->relallvisible != (
int32) relallvisible)
2923 rd_rel->relallvisible = (
int32) relallvisible;
2981 int save_sec_context;
3011 (
errmsg_internal(
"building index \"%s\" on table \"%s\" with request for %d parallel workers",
3029 const int progress_index[] = {
3037 const int64 progress_vals[] = {
3060 if (indexRelation->
rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
3110 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3114 Assert(!indexForm->indcheckxmin);
3116 indexForm->indcheckxmin =
true;
3219 if (predicate != NULL)
3221 if (!
ExecQual(predicate, econtext))
3238 indexRelation, indexInfo,
3329 int save_sec_context;
3333 const int progress_index[] = {
3340 const int64 progress_vals[] = {
3377 ivinfo.
index = indexRelation;
3378 ivinfo.
heaprel = heapRelation;
3404 const int progress_index[] = {
3409 const int64 progress_vals[] = {
3436 "validate_index found %.0f heap tuples, %.0f index tuples; inserted %.0f missing tuples",
3486 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3494 Assert(indexForm->indislive);
3495 Assert(!indexForm->indisready);
3496 Assert(!indexForm->indisvalid);
3497 indexForm->indisready =
true;
3501 Assert(indexForm->indislive);
3502 Assert(indexForm->indisready);
3503 Assert(!indexForm->indisvalid);
3504 indexForm->indisvalid =
true;
3521 indexForm->indisvalid =
false;
3522 indexForm->indisclustered =
false;
3523 indexForm->indisreplident =
false;
3534 Assert(!indexForm->indisvalid);
3535 Assert(!indexForm->indisclustered);
3536 Assert(!indexForm->indisreplident);
3537 indexForm->indisready =
false;
3538 indexForm->indislive =
false;
3565 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3570 result =
index->indrelid;
3580 bool skip_constraint_checks,
char persistence,
3587 int save_sec_context;
3590 volatile bool skipped_constraint =
false;
3593 bool set_tablespace =
false;
3629 const int progress_cols[] = {
3633 const int64 progress_vals[] = {
3688 if (iRel->
rd_rel->relkind == RELKIND_PARTITIONED_INDEX)
3689 elog(
ERROR,
"cannot reindex partitioned index \"%s.%s\"",
3699 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3700 errmsg(
"cannot reindex temporary tables of other sessions")));
3710 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3711 errmsg(
"cannot reindex invalid index on TOAST table")));
3726 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3727 errmsg(
"cannot move system relation \"%s\"",
3733 set_tablespace =
true;
3767 if (skip_constraint_checks)
3770 skipped_constraint =
true;
3785 index_build(heapRelation, iRel, indexInfo,
true,
true);
3818 if (!skipped_constraint)
3830 elog(
ERROR,
"cache lookup failed for index %u", indexId);
3833 index_bad = (!indexForm->indisvalid ||
3834 !indexForm->indisready ||
3835 !indexForm->indislive);
3840 indexForm->indcheckxmin =
false;
3842 indexForm->indcheckxmin =
true;
3843 indexForm->indisvalid =
true;
3844 indexForm->indisready =
true;
3845 indexForm->indislive =
true;
3864 (
errmsg(
"index \"%s\" was reindexed",
3926 bool result =
false;
3948 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3949 elog(
ERROR,
"cannot reindex partitioned table \"%s.%s\"",
3953 toast_relid = rel->
rd_rel->reltoastrelid;
4007 persistence = RELPERSISTENCE_UNLOGGED;
4009 persistence = RELPERSISTENCE_PERMANENT;
4011 persistence = rel->
rd_rel->relpersistence;
4015 foreach(indexId, indexIds)
4029 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4030 errmsg(
"cannot reindex invalid index \"%s.%s\" on TOAST table, skipping",
4045 persistence, params);
4063 result |= (indexIds !=
NIL);
4127 elog(
ERROR,
"cannot reindex while reindexing");
4159 elog(
ERROR,
"cannot reindex while reindexing");
4161 elog(
ERROR,
"cannot modify reindex state during a parallel operation");
4174 elog(
ERROR,
"cannot modify reindex state during a parallel operation");
IndexAmRoutine * GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
#define AttrNumberGetAttrOffset(attNum)
#define InvalidAttrNumber
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
void pgstat_progress_end_command(void)
@ PROGRESS_COMMAND_CREATE_INDEX
static Datum values[MAXATTR]
void index_register(Oid heap, Oid ind, const IndexInfo *indexInfo)
#define RelationGetNumberOfBlocks(reln)
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
TransactionId MultiXactId
#define PointerIsValid(pointer)
#define FLEXIBLE_ARRAY_MEMBER
#define MemSet(start, val, len)
#define OidIsValid(objectId)
bool IsToastNamespace(Oid namespaceId)
bool IsSystemRelation(Relation relation)
RelFileNumber GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogRelation(Relation relation)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
void recordDependencyOnSingleRelExpr(const ObjectAddress *depender, Node *expr, Oid relId, DependencyType behavior, DependencyType self_behavior, bool reverse_self)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void free_object_addresses(ObjectAddresses *addrs)
@ DEPENDENCY_PARTITION_PRI
@ DEPENDENCY_PARTITION_SEC
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
void EventTriggerCollectSimpleCommand(ObjectAddress address, ObjectAddress secondaryObject, Node *parsetree)
ExprState * ExecPrepareQual(List *qual, EState *estate)
List * ExecPrepareExprList(List *nodes, EState *estate)
void check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo, ItemPointer tupleid, const Datum *values, const bool *isnull, EState *estate, bool newIndex)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#define GetPerTupleExprContext(estate)
static bool ExecQual(ExprState *state, ExprContext *econtext)
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
#define palloc0_array(type, count)
Datum Int64GetDatum(int64 X)
void systable_endscan(SysScanDesc sysscan)
void systable_inplace_update_cancel(void *state)
void systable_inplace_update_begin(Relation relation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, const ScanKeyData *key, HeapTuple *oldtupcopy, void **state)
void systable_inplace_update_finish(void *state, HeapTuple tuple)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
int NewGUCNestLevel(void)
void RestrictSearchPath(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
void DeleteRelationTuple(Oid relid)
void DeleteAttributeTuples(Oid relid)
void RemoveStatistics(Oid relid, AttrNumber attnum)
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, int flags)
void CopyStatistics(Oid fromrelid, Oid torelid)
void InsertPgClassTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Datum relacl, Datum reloptions)
void InsertPgAttributeTuples(Relation pg_attribute_rel, TupleDesc tupdesc, Oid new_rel_oid, const FormExtraData_pg_attribute tupdesc_extra[], CatalogIndexState indstate)
Relation heap_create(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, RelFileNumber relfilenumber, Oid accessmtd, TupleDesc tupDesc, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, bool allow_system_table_mods, TransactionId *relfrozenxid, MultiXactId *relminmxid, bool create_storage)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
bool ReindexIsProcessingIndex(Oid indexOid)
static bool validate_index_callback(ItemPointer itemptr, void *opaque)
void validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
void index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
void ResetReindexState(int nestLevel)
Oid IndexGetRelation(Oid indexId, bool missing_ok)
static int reindexingNestLevel
void index_concurrently_set_dead(Oid heapId, Oid indexId)
Oid index_create(Relation heapRelation, const char *indexRelationName, Oid indexRelationId, Oid parentIndexRelid, Oid parentConstraintId, RelFileNumber relFileNumber, IndexInfo *indexInfo, const List *indexColNames, Oid accessMethodId, Oid tableSpaceId, const Oid *collationIds, const Oid *opclassIds, const Datum *opclassOptions, const int16 *coloptions, const NullableDatum *stattargets, Datum reloptions, bits16 flags, bits16 constr_flags, bool allow_system_table_mods, bool is_internal, Oid *constraintId)
static Oid currentlyReindexedHeap
static void ResetReindexProcessing(void)
void index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
static void RemoveReindexPending(Oid indexOid)
static List * pendingReindexedIndexes
void index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
bool CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2, const Oid *collations1, const Oid *collations2, const Oid *opfamilies1, const Oid *opfamilies2, const AttrMap *attmap)
RelFileNumber binary_upgrade_next_index_pg_class_relfilenumber
IndexInfo * BuildDummyIndexInfo(Relation index)
bool reindex_relation(const ReindexStmt *stmt, Oid relid, int flags, const ReindexParams *params)
void SerializeReindexState(Size maxsize, char *start_address)
static void index_update_stats(Relation rel, bool hasindex, double reltuples)
IndexInfo * BuildIndexInfo(Relation index)
static bool relationHasPrimaryKey(Relation rel)
static void SetReindexProcessing(Oid heapOid, Oid indexOid)
static void IndexCheckExclusion(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo)
static void InitializeAttributeOids(Relation indexRelation, int numatts, Oid indexoid)
Oid index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId, Oid tablespaceOid, const char *newName)
Oid binary_upgrade_next_index_pg_class_oid
static void AppendAttributeTuples(Relation indexRelation, const Datum *attopts, const NullableDatum *stattargets)
void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
void index_check_primary_key(Relation heapRel, const IndexInfo *indexInfo, bool is_alter_table, const IndexStmt *stmt)
bool ReindexIsProcessingHeap(Oid heapOid)
static bool ReindexIsCurrentlyProcessingIndex(Oid indexOid)
void RestoreReindexState(const void *reindexstate)
static TupleDesc ConstructTupleDescriptor(Relation heapRelation, const IndexInfo *indexInfo, const List *indexColNames, Oid accessMethodId, const Oid *collationIds, const Oid *opclassIds)
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isreindex, bool parallel)
ObjectAddress index_constraint_create(Relation heapRelation, Oid indexRelationId, Oid parentConstraintId, const IndexInfo *indexInfo, const char *constraintName, char constraintType, bits16 constr_flags, bool allow_system_table_mods, bool is_internal)
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
static void SetReindexPending(List *indexes)
void index_concurrently_build(Oid heapRelationId, Oid indexRelationId)
static void UpdateIndexRelation(Oid indexoid, Oid heapoid, Oid parentIndexId, const IndexInfo *indexInfo, const Oid *collationOids, const Oid *opclassOids, const int16 *coloptions, bool primary, bool isexclusion, bool immediate, bool isvalid, bool isready)
static Oid currentlyReindexedIndex
Size EstimateReindexStateSpace(void)
void reindex_index(const ReindexStmt *stmt, Oid indexId, bool skip_constraint_checks, char persistence, const ReindexParams *params)
#define INDEX_CREATE_IS_PRIMARY
#define INDEX_CREATE_IF_NOT_EXISTS
#define REINDEX_REL_PROCESS_TOAST
#define INDEX_CREATE_PARTITIONED
#define REINDEXOPT_MISSING_OK
#define INDEX_CREATE_INVALID
#define INDEX_CONSTR_CREATE_WITHOUT_OVERLAPS
static int64 itemptr_encode(ItemPointer itemptr)
#define INDEX_CREATE_ADD_CONSTRAINT
#define INDEX_CREATE_SKIP_BUILD
#define INDEX_CONSTR_CREATE_UPDATE_INDEX
#define REINDEX_REL_FORCE_INDEXES_UNLOGGED
#define INDEX_CONSTR_CREATE_REMOVE_OLD_DEPS
#define INDEX_CONSTR_CREATE_DEFERRABLE
#define REINDEXOPT_REPORT_PROGRESS
#define INDEX_CONSTR_CREATE_MARK_AS_PRIMARY
#define REINDEX_REL_SUPPRESS_INDEX_USE
#define REINDEX_REL_FORCE_INDEXES_PERMANENT
#define INDEX_CONSTR_CREATE_INIT_DEFERRED
#define INDEX_CREATE_CONCURRENT
#define REINDEXOPT_VERBOSE
#define REINDEX_REL_CHECK_CONSTRAINTS
bytea * index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions, bool validate)
IndexBulkDeleteResult * index_bulk_delete(IndexVacuumInfo *info, IndexBulkDeleteResult *istat, IndexBulkDeleteCallback callback, void *callback_state)
void index_insert_cleanup(Relation indexRelation, IndexInfo *indexInfo)
void index_close(Relation relation, LOCKMODE lockmode)
Relation try_index_open(Oid relationId, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogCloseIndexes(CatalogIndexState indstate)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
int2vector * buildint2vector(const int16 *int2s, int n)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
invalidindex index d is invalid
if(TABLE==NULL||TABLE_index==NULL)
List * lappend(List *list, void *datum)
List * list_delete_oid(List *list, Oid datum)
List * list_copy(const List *oldlist)
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
void LockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
void LockRelation(Relation relation, LOCKMODE lockmode)
void WaitForLockers(LOCKTAG heaplocktag, LOCKMODE lockmode, bool progress)
void UnlockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode)
#define SET_LOCKTAG_RELATION(locktag, dboid, reloid)
#define AccessExclusiveLock
#define ShareUpdateExclusiveLock
char * get_rel_name(Oid relid)
bool get_rel_relispartition(Oid relid)
char get_rel_persistence(Oid relid)
bool get_index_isvalid(Oid index_oid)
Datum get_attoptions(Oid relid, int16 attnum)
Oid get_rel_namespace(Oid relid)
RegProcedure get_opcode(Oid opno)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
bool get_collation_isdeterministic(Oid colloid)
Oid get_base_element_type(Oid typid)
char * get_namespace_name(Oid nspid)
Oid get_relname_relid(const char *relname, Oid relnamespace)
Expr * make_ands_explicit(List *andclauses)
IndexInfo * makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions, List *predicates, bool unique, bool nulls_not_distinct, bool isready, bool concurrent, bool summarizing, bool withoutoverlaps)
List * make_ands_implicit(Expr *clause)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext TopMemoryContext
#define IsBootstrapProcessingMode()
#define SECURITY_RESTRICTED_OPERATION
#define CHECK_FOR_INTERRUPTS()
#define IsNormalProcessingMode()
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
#define InvalidMultiXactId
void namestrcpy(Name name, const char *str)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
#define InvokeObjectPostAlterHookArg(classId, objectId, subId, auxiliaryId, is_internal)
#define InvokeObjectPostCreateHookArg(classId, objectId, subId, is_internal)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
#define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id)
oidvector * buildoidvector(const Oid *oids, int n)
char * nodeToString(const void *obj)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
List * SystemFuncName(char *name)
List * get_partition_ancestors(Oid relid)
#define ATTRIBUTE_FIXED_PART_SIZE
FormData_pg_attribute * Form_pg_attribute
FormData_pg_class * Form_pg_class
Oid CreateConstraintEntry(const char *constraintName, Oid constraintNamespace, char constraintType, bool isDeferrable, bool isDeferred, bool isEnforced, bool isValidated, Oid parentConstrId, Oid relId, const int16 *constraintKey, int constraintNKeys, int constraintNTotalKeys, Oid domainId, Oid indexRelId, Oid foreignRelId, const int16 *foreignKey, const Oid *pfEqOp, const Oid *ppEqOp, const Oid *ffEqOp, int foreignNKeys, char foreignUpdateType, char foreignDeleteType, const int16 *fkDeleteSetCols, int numFkDeleteSetCols, char foreignMatchType, const Oid *exclOp, Node *conExpr, const char *conBin, bool conIsLocal, int16 conInhCount, bool conNoInherit, bool conPeriod, bool is_internal)
bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, const char *conname)
FormData_pg_constraint * Form_pg_constraint
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long deleteDependencyRecordsForClass(Oid classId, Oid objectId, Oid refclassId, char deptype)
long changeDependenciesOf(Oid classId, Oid oldObjectId, Oid newObjectId)
List * get_index_ref_constraints(Oid indexId)
long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
Oid get_index_constraint(Oid indexId)
FormData_pg_index * Form_pg_index
bool DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending, const char *childname)
void StoreSingleInheritance(Oid relationId, Oid parentOid, int32 seqNumber)
static int list_length(const List *l)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
FormData_pg_opclass * Form_pg_opclass
const char * pg_rusage_show(const PGRUsage *ru0)
void pg_rusage_init(PGRUsage *ru0)
FormData_pg_trigger * Form_pg_trigger
FormData_pg_type * Form_pg_type
void pgstat_copy_relation_stats(Relation dst, Relation src)
void pgstat_drop_relation(Relation rel)
int plan_create_index_workers(Oid tableOid, Oid indexOid)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
void TransferPredicateLocksToHeapRelation(Relation relation)
#define PROGRESS_CREATEIDX_PHASE_BUILD
#define PROGRESS_CREATEIDX_PHASE_VALIDATE_TABLESCAN
#define PROGRESS_CREATEIDX_ACCESS_METHOD_OID
#define PROGRESS_CREATEIDX_TUPLES_TOTAL
#define PROGRESS_CREATEIDX_PHASE_VALIDATE_SORT
#define PROGRESS_SCAN_BLOCKS_DONE
#define PROGRESS_CREATEIDX_TUPLES_DONE
#define PROGRESS_CREATEIDX_SUBPHASE
#define PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE
#define PROGRESS_CREATEIDX_PHASE
#define PROGRESS_CREATEIDX_COMMAND_REINDEX
#define PROGRESS_CLUSTER_INDEX_REBUILD_COUNT
#define PROGRESS_CREATEIDX_PHASE_VALIDATE_IDXSCAN
#define PROGRESS_SCAN_BLOCKS_TOTAL
#define PROGRESS_CREATEIDX_INDEX_OID
#define PROGRESS_CREATEIDX_COMMAND
void * stringToNode(const char *str)
#define RelationGetForm(relation)
#define RelationGetRelid(relation)
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationGetDescr(relation)
#define RelationIsMapped(relation)
#define RelationGetRelationName(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationIsValid(relation)
#define RelationGetNamespace(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
List * RelationGetIndexList(Relation relation)
List * RelationGetDummyIndexExpressions(Relation relation)
void RelationInitIndexAccessInfo(Relation relation)
List * RelationGetIndexPredicate(Relation relation)
void RelationSetNewRelfilenumber(Relation relation, char persistence)
void RelationForgetRelation(Oid rid)
List * RelationGetIndexExpressions(Relation relation)
void RelationAssumeNewRelfilelocator(Relation relation)
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
#define InvalidRelFileNumber
#define RelFileNumberIsValid(relnumber)
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Size mul_size(Size s1, Size s2)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
Snapshot GetTransactionSnapshot(void)
Snapshot GetLatestSnapshot(void)
void UnregisterSnapshot(Snapshot snapshot)
void PushActiveSnapshot(Snapshot snapshot)
bool ActiveSnapshotSet(void)
Snapshot RegisterSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
void log_smgrcreate(const RelFileLocator *rlocator, ForkNumber forkNum)
void RelationDropStorage(Relation rel)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
MemoryContext ecxt_per_tuple_memory
TupleTableSlot * ecxt_scantuple
ambuildempty_function ambuildempty
uint16 * ii_ExclusionStrats
ExprState * ii_PredicateState
List * ii_ExpressionsState
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS]
BufferAccessStrategy strategy
struct IndexAmRoutine * rd_indam
MemoryContext rd_indexcxt
RelFileLocator rd_locator
Oid currentlyReindexedHeap
Oid currentlyReindexedIndex
int numPendingReindexedIndexes
Oid pendingReindexedIndexes[FLEXIBLE_ARRAY_MEMBER]
int16 values[FLEXIBLE_ARRAY_MEMBER]
Oid values[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define SearchSysCacheCopy1(cacheId, key1)
Relation try_table_open(Oid relationId, LOCKMODE lockmode)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static void table_endscan(TableScanDesc scan)
static void table_index_validate_scan(Relation table_rel, Relation index_rel, struct IndexInfo *index_info, Snapshot snapshot, struct ValidateIndexState *state)
static TableScanDesc table_beginscan_strat(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, bool allow_strat, bool allow_sync)
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
void CheckTableNotInUse(Relation rel, const char *stmt)
bool CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
void SetRelationHasSubclass(Oid relationId, bool relhassubclass)
void SetRelationTableSpace(Relation rel, Oid newTableSpaceId, RelFileNumber newRelFilenumber)
#define InvalidCompressionMethod
#define InvalidTransactionId
ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char *queryString, Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid, Oid funcoid, Oid parentTriggerOid, Node *whenClause, bool isInternal, bool in_partition)
TupleDesc CreateTemplateTupleDesc(int natts)
void populate_compact_attribute(TupleDesc tupdesc, int attnum)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
void tuplesort_performsort(Tuplesortstate *state)
void tuplesort_end(Tuplesortstate *state)
void tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
Tuplesortstate * tuplesort_begin_datum(Oid datumType, Oid sortOperator, Oid sortCollation, bool nullsFirstFlag, int workMem, SortCoordinate coordinate, int sortopt)
static Datum slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen)
int GetCurrentTransactionNestLevel(void)
void CommandCounterIncrement(void)
TransactionId GetTopTransactionIdIfAny(void)
void StartTransactionCommand(void)
bool IsInParallelMode(void)
void CommitTransactionCommand(void)