63 #include "utils/fmgroids.h"
82 Datum *opclassOptions,
85 const List *exclusionOpNames,
87 const char *accessMethodName,
91 bool iswithoutoverlaps,
94 int *ddl_save_nestlevel);
96 const List *colnames,
const List *exclusionOpNames,
97 bool primary,
bool isconstraint);
178 const char *accessMethodName,
179 const List *attributeList,
180 const List *exclusionOpNames,
181 bool isWithoutOverlaps)
187 Datum *opclassOptions;
198 int numberOfAttributes;
214 isconstraint =
false;
217 Assert(numberOfAttributes > 0);
224 (
errcode(ERRCODE_UNDEFINED_OBJECT),
225 errmsg(
"access method \"%s\" does not exist",
228 accessMethodId = accessMethodForm->oid;
243 indexInfo =
makeIndexInfo(numberOfAttributes, numberOfAttributes,
244 accessMethodId,
NIL,
NIL,
false,
false,
245 false,
false, amsummarizing);
252 typeIds, collationIds, opclassIds, opclassOptions,
253 coloptions, attributeList,
254 exclusionOpNames, relationId,
255 accessMethodName, accessMethodId,
256 amcanorder, isconstraint, isWithoutOverlaps,
InvalidOid,
262 elog(
ERROR,
"cache lookup failed for index %u", oldId);
271 indexForm->indisvalid))
278 old_natts = indexForm->indnkeyatts;
279 Assert(old_natts == numberOfAttributes);
287 ret = (memcmp(old_indclass->
values, opclassIds, old_natts *
sizeof(
Oid)) == 0 &&
288 memcmp(old_indcollation->
values, collationIds, old_natts *
sizeof(
Oid)) == 0);
297 for (
i = 0;
i < old_natts;
i++)
312 for (
i = 0;
i < old_natts;
i++)
317 pfree(oldOpclassOptions);
329 old_natts *
sizeof(
Oid)) == 0;
334 for (
i = 0;
i < old_natts && ret;
i++)
340 if ((IsPolymorphicType(left) || IsPolymorphicType(right)) &&
365 if (!opts1 && !opts2)
368 for (
i = 0;
i < natts;
i++)
373 if (opt1 == (
Datum) 0)
375 if (opt2 == (
Datum) 0)
380 else if (opt2 == (
Datum) 0)
441 for (
i = 0;
i < n_old_snapshots;
i++)
450 int n_newer_snapshots;
459 for (
j =
i;
j < n_old_snapshots;
j++)
463 for (k = 0; k < n_newer_snapshots; k++)
469 if (k >= n_newer_snapshots)
472 pfree(newer_snapshots);
539 Oid parentConstraintId,
543 bool check_not_in_use,
548 char *indexRelationName;
549 char *accessMethodName;
553 Datum *opclassOptions;
559 List *allIndexParams;
565 bool amissummarizing;
575 int numberOfAttributes;
576 int numberOfKeyAttributes;
583 Oid root_save_userid;
584 int root_save_sec_context;
585 int root_save_nestlevel;
596 if (
stmt->reset_default_tblspc)
646 stmt->indexIncludingParams);
649 if (numberOfKeyAttributes <= 0)
651 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
652 errmsg(
"must specify at least one column")));
655 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
656 errmsg(
"cannot use more than %d columns in an index",
692 exclusion =
stmt->excludeOpNames ||
stmt->iswithoutoverlaps;
695 switch (rel->
rd_rel->relkind)
697 case RELKIND_RELATION:
698 case RELKIND_MATVIEW:
699 case RELKIND_PARTITIONED_TABLE:
704 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
705 errmsg(
"cannot create index on relation \"%s\"",
719 partitioned = rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE;
728 if (
stmt->concurrent)
730 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
731 errmsg(
"cannot create index on partitioned table \"%s\" concurrently",
740 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
741 errmsg(
"cannot create indexes on temporary tables of other sessions")));
749 if (check_not_in_use)
762 aclresult =
object_aclcheck(NamespaceRelationId, namespaceId, root_save_userid,
773 if (
stmt->tableSpace)
778 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
779 errmsg(
"cannot specify default tablespace for partitioned relations")));
794 aclresult =
object_aclcheck(TableSpaceRelationId, tablespaceId, root_save_userid,
806 if (rel->
rd_rel->relisshared)
807 tablespaceId = GLOBALTABLESPACE_OID;
808 else if (tablespaceId == GLOBALTABLESPACE_OID)
810 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
811 errmsg(
"only shared relations can be placed in pg_global tablespace")));
821 indexRelationName =
stmt->idxname;
822 if (indexRelationName == NULL)
826 stmt->excludeOpNames,
833 accessMethodName =
stmt->accessMethod;
841 if (strcmp(accessMethodName,
"rtree") == 0)
844 (
errmsg(
"substituting access method \"gist\" for obsolete method \"rtree\"")));
845 accessMethodName =
"gist";
851 (
errcode(ERRCODE_UNDEFINED_OBJECT),
852 errmsg(
"access method \"%s\" does not exist",
856 accessMethodId = accessMethodForm->oid;
864 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
865 errmsg(
"access method \"%s\" does not support unique indexes",
869 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
870 errmsg(
"access method \"%s\" does not support included columns",
874 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
875 errmsg(
"access method \"%s\" does not support multicolumn indexes",
877 if (exclusion && amRoutine->
amgettuple == NULL)
879 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
880 errmsg(
"access method \"%s\" does not support exclusion constraints",
893 if (
stmt->whereClause)
900 NULL, NULL,
false,
false);
910 numberOfKeyAttributes,
915 stmt->nulls_not_distinct,
926 typeIds, collationIds, opclassIds, opclassOptions,
927 coloptions, allIndexParams,
928 stmt->excludeOpNames, tableId,
929 accessMethodName, accessMethodId,
930 amcanorder,
stmt->isconstraint,
stmt->iswithoutoverlaps,
931 root_save_userid, root_save_sec_context,
932 &root_save_nestlevel);
950 if (partitioned && (
stmt->unique || exclusion))
953 const char *constraint_type;
957 constraint_type =
"PRIMARY KEY";
958 else if (
stmt->unique)
959 constraint_type =
"UNIQUE";
960 else if (
stmt->excludeOpNames)
961 constraint_type =
"EXCLUDE";
965 constraint_type = NULL;
972 for (
i = 0;
i <
key->partnatts;
i++)
991 key->partopcintype[
i],
992 key->partopcintype[
i],
995 elog(
ERROR,
"missing operator %d(%u,%u) in partition opfamily %u",
996 eq_strategy,
key->partopcintype[
i],
key->partopcintype[
i],
997 key->partopfamily[
i]);
1007 if (
stmt->unique && !
stmt->iswithoutoverlaps && accessMethodId != BTREE_AM_OID)
1009 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1010 errmsg(
"cannot match partition key to an index using access method \"%s\"",
1011 accessMethodName)));
1017 if (
key->partattrs[
i] == 0)
1019 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1020 errmsg(
"unsupported %s constraint with partition key definition",
1022 errdetail(
"%s constraints cannot be used when partition keys include expressions.",
1037 if (
key->partcollation[
i] != collationIds[
j])
1046 if (
stmt->unique && !
stmt->iswithoutoverlaps)
1055 if (ptkey_eqop == idx_eqop)
1071 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1072 errmsg(
"cannot match partition key to index on column \"%s\" using non-equal operator \"%s\"",
1085 key->partattrs[
i] - 1);
1087 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1088 errmsg(
"unique constraint on partitioned table must include all partitioning columns"),
1089 errdetail(
"%s constraint on table \"%s\" lacks column \"%s\" which is part of the partition key.",
1107 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1108 errmsg(
"index creation on system columns is not supported")));
1126 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1127 errmsg(
"index creation on system columns is not supported")));
1139 if (
stmt->isconstraint && !quiet)
1141 const char *constraint_type;
1144 constraint_type =
"PRIMARY KEY";
1145 else if (
stmt->unique)
1146 constraint_type =
"UNIQUE";
1147 else if (
stmt->excludeOpNames)
1148 constraint_type =
"EXCLUDE";
1152 constraint_type = NULL;
1156 (
errmsg_internal(
"%s %s will create implicit index \"%s\" for table \"%s\"",
1157 is_alter_table ?
"ALTER TABLE / ADD" :
"CREATE TABLE /",
1174 flags = constr_flags = 0;
1175 if (
stmt->isconstraint)
1177 if (skip_build || concurrent || partitioned)
1179 if (
stmt->if_not_exists)
1192 if (partitioned &&
stmt->relation && !
stmt->relation->inh)
1200 if (
stmt->deferrable)
1202 if (
stmt->initdeferred)
1204 if (
stmt->iswithoutoverlaps)
1208 index_create(rel, indexRelationName, indexRelationId, parentIndexId,
1210 stmt->oldNumber, indexInfo, indexColNames,
1211 accessMethodId, tablespaceId,
1212 collationIds, opclassIds, opclassOptions,
1213 coloptions, NULL, reloptions,
1214 flags, constr_flags,
1216 &createdConstraintId);
1249 if (
stmt->idxcomment != NULL)
1264 if ((!
stmt->relation ||
stmt->relation->inh) && partdesc->
nparts > 0)
1266 int nparts = partdesc->
nparts;
1268 bool invalidate_parent =
false;
1291 if (total_parts < 0)
1304 memcpy(part_oids, partdesc->
oids,
sizeof(
Oid) * nparts);
1314 parentIndex =
index_open(indexRelationId, lockmode);
1327 for (
int i = 0;
i < nparts;
i++)
1329 Oid childRelid = part_oids[
i];
1331 Oid child_save_userid;
1332 int child_save_sec_context;
1333 int child_save_nestlevel;
1342 &child_save_sec_context);
1353 if (childrel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1357 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1358 errmsg(
"cannot create unique index on partitioned table \"%s\"",
1360 errdetail(
"Table \"%s\" contains partitions that are foreign tables.",
1365 child_save_sec_context);
1376 foreach(cell, childidxs)
1422 createdConstraintId,
1426 invalidate_parent =
true;
1452 child_save_sec_context);
1461 bool found_whole_row;
1499 if (found_whole_row)
1500 elog(
ERROR,
"cannot convert whole-row table reference");
1507 if (found_whole_row)
1508 elog(
ERROR,
"cannot convert whole-row table reference");
1516 root_save_sec_context);
1521 createdConstraintId,
1523 is_alter_table, check_rights,
1527 child_save_sec_context);
1535 invalidate_parent =
true;
1548 if (invalidate_parent)
1557 elog(
ERROR,
"cache lookup failed for index %u",
1653 const int progress_cols[] = {
1657 const int64 progress_vals[] = {
1760 limitXmin = snapshot->
xmin;
1844 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1845 errmsg(
"functions in index predicate must be marked IMMUTABLE")));
1862 Datum *opclassOptions,
1864 const List *attList,
1865 const List *exclusionOpNames,
1867 const char *accessMethodName,
1871 bool iswithoutoverlaps,
1873 int ddl_sec_context,
1874 int *ddl_save_nestlevel)
1881 int save_sec_context;
1884 if (exclusionOpNames)
1890 nextExclOp =
list_head(exclusionOpNames);
1896 if (iswithoutoverlaps && exclusionOpNames ==
NIL)
1910 foreach(lc, attList)
1919 if (attribute->
name != NULL)
1932 (
errcode(ERRCODE_UNDEFINED_COLUMN),
1933 errmsg(
"column \"%s\" named in key does not exist",
1937 (
errcode(ERRCODE_UNDEFINED_COLUMN),
1938 errmsg(
"column \"%s\" does not exist",
1943 atttype = attform->atttypid;
1944 attcollation = attform->attcollation;
1954 if (attn >= nkeycols)
1956 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1957 errmsg(
"expressions are not supported in included columns")));
1997 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1998 errmsg(
"functions in index expression must be marked IMMUTABLE")));
2002 typeOids[attn] = atttype;
2008 if (attn >= nkeycols)
2012 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2013 errmsg(
"including column does not support a collation")));
2016 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2017 errmsg(
"including column does not support an operator class")));
2020 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2021 errmsg(
"including column does not support ASC/DESC options")));
2024 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2025 errmsg(
"including column does not support NULLS FIRST/LAST options")));
2028 opclassOptions[attn] = (
Datum) 0;
2029 colOptions[attn] = 0;
2066 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
2067 errmsg(
"could not determine which collation to use for index expression"),
2068 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
2074 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2075 errmsg(
"collations are not supported by type %s",
2079 collationOids[attn] = attcollation;
2139 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2140 errmsg(
"operator %s is not commutative",
2142 errdetail(
"Only commutative operators can be used in exclusion constraints.")));
2162 elog(
ERROR,
"cache lookup failed for opfamily %u",
2167 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2168 errmsg(
"operator %s is not a member of operator family \"%s\"",
2171 errdetail(
"The exclusion operator must be related to the index operator class for the constraint.")));
2177 nextExclOp =
lnext(exclusionOpNames, nextExclOp);
2179 else if (iswithoutoverlaps)
2184 if (attn == nkeycols - 1)
2200 colOptions[attn] = 0;
2205 colOptions[attn] |= INDOPTION_DESC;
2210 colOptions[attn] |= INDOPTION_NULLS_FIRST;
2213 colOptions[attn] |= INDOPTION_NULLS_FIRST;
2220 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2221 errmsg(
"access method \"%s\" does not support ASC/DESC options",
2222 accessMethodName)));
2225 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2226 errmsg(
"access method \"%s\" does not support NULLS FIRST/LAST options",
2227 accessMethodName)));
2235 opclassOptions[attn] =
2237 NULL, NULL,
false,
false);
2240 opclassOptions[attn] = (
Datum) 0;
2254 const char *accessMethodName,
Oid accessMethodId)
2269 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2270 errmsg(
"data type %s has no default operator class for access method \"%s\"",
2272 errhint(
"You must specify an operator class for the index or define a default operator class for the data type.")));
2300 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2301 errmsg(
"operator class \"%s\" does not exist for access method \"%s\"",
2302 opcname, accessMethodName)));
2308 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2309 errmsg(
"operator class \"%s\" does not exist for access method \"%s\"",
2317 opClassId = opform->oid;
2318 opInputType = opform->opcintype;
2322 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2323 errmsg(
"operator class \"%s\" does not accept data type %s",
2342 int ncompatible = 0;
2343 int ncompatiblepreferred = 0;
2370 Anum_pg_opclass_opcmethod,
2382 if (!opclass->opcdefault)
2384 if (opclass->opcintype == type_id)
2387 result = opclass->oid;
2389 else if (nexact == 0 &&
2394 ncompatiblepreferred++;
2395 result = opclass->oid;
2397 else if (ncompatiblepreferred == 0)
2400 result = opclass->oid;
2413 errmsg(
"there are multiple default operator classes for data type %s",
2417 ncompatiblepreferred == 1 ||
2418 (ncompatiblepreferred == 0 && ncompatible == 1))
2467 elog(
ERROR,
"cache lookup failed for operator class %u", opclass);
2470 errcode(ERRCODE_UNDEFINED_OBJECT),
2474 errdetail(
"Could not translate strategy number %d for operator class \"%s\" for access method \"%s\".",
2489 elog(
ERROR,
"cache lookup failed for operator family %u", opfamily);
2492 errcode(ERRCODE_UNDEFINED_OBJECT),
2496 errdetail(
"There is no suitable operator in operator family \"%s\" for access method \"%s\".",
2533 name1chars = strlen(name1);
2536 name2chars = strlen(name2);
2542 overhead += strlen(
label) + 1;
2552 while (name1chars + name2chars > availchars)
2554 if (name1chars > name2chars)
2560 name1chars =
pg_mbcliplen(name1, name1chars, name1chars);
2562 name2chars =
pg_mbcliplen(name2, name2chars, name2chars);
2565 name =
palloc(name1chars + name2chars + overhead + 1);
2566 memcpy(
name, name1, name1chars);
2571 memcpy(
name + ndx, name2, name2chars);
2611 const char *
label,
Oid namespaceid,
2627 if (!isconstraint ||
2634 snprintf(modlabel,
sizeof(modlabel),
"%s%d",
label, ++pass);
2647 const List *colnames,
const List *exclusionOpNames,
2648 bool primary,
bool isconstraint)
2661 else if (exclusionOpNames !=
NIL)
2669 else if (isconstraint)
2708 foreach(lc, colnames)
2710 const char *
name = (
const char *)
lfirst(lc);
2713 buf[buflen++] =
'_';
2720 buflen += strlen(
buf + buflen);
2740 foreach(lc, indexElems)
2743 const char *origname;
2744 const char *curname;
2751 else if (ielem->
name)
2752 origname = ielem->
name;
2764 foreach(lc2, result)
2766 if (strcmp(curname, (
char *)
lfirst(lc2)) == 0)
2777 memcpy(
buf, origname, nlen);
2778 strcpy(
buf + nlen, nbuf);
2800 bool concurrently =
false;
2802 char *tablespacename = NULL;
2805 foreach(lc,
stmt->params)
2809 if (strcmp(opt->
defname,
"verbose") == 0)
2811 else if (strcmp(opt->
defname,
"concurrently") == 0)
2813 else if (strcmp(opt->
defname,
"tablespace") == 0)
2817 (
errcode(ERRCODE_SYNTAX_ERROR),
2818 errmsg(
"unrecognized REINDEX option \"%s\"",
2825 "REINDEX CONCURRENTLY");
2835 if (tablespacename != NULL)
2876 "REINDEX DATABASE");
2880 elog(
ERROR,
"unrecognized object type: %d",
2925 if (relkind == RELKIND_PARTITIONED_INDEX)
2928 persistence != RELPERSISTENCE_TEMP)
2966 if (relId != oldRelId &&
OidIsValid(oldRelId))
2984 if (relkind != RELKIND_INDEX &&
2985 relkind != RELKIND_PARTITIONED_INDEX)
2987 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3002 if (relId != oldRelId)
3011 state->locked_table_oid = table_oid;
3050 (
errmsg(
"table \"%s\" has no indexes that can be reindexed concurrently",
3064 (
errmsg(
"table \"%s\" has no indexes to reindex",
3092 bool concurrent_warning =
false;
3093 bool tablespace_warning =
false;
3094 const char *objectName =
stmt->name;
3110 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3111 errmsg(
"cannot reindex system catalogs concurrently")));
3134 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3135 errmsg(
"can only reindex the currently open database")));
3149 "ReindexMultipleTables",
3161 Anum_pg_class_relnamespace,
3179 Oid relid = classtuple->oid;
3188 if (classtuple->relkind != RELKIND_RELATION &&
3189 classtuple->relkind != RELKIND_MATVIEW)
3193 if (classtuple->relpersistence == RELPERSISTENCE_TEMP &&
3213 if (classtuple->relisshared &&
3224 if (!concurrent_warning)
3226 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3227 errmsg(
"cannot reindex system catalogs concurrently, skipping all")));
3228 concurrent_warning =
true;
3238 bool skip_rel =
false;
3244 if (RELKIND_HAS_STORAGE(classtuple->relkind) &&
3257 if (!tablespace_warning)
3259 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
3260 errmsg(
"cannot move system relations, skipping all")));
3261 tablespace_warning =
true;
3276 if (relid == RelationRelationId)
3305 if (errinfo->
relkind == RELKIND_PARTITIONED_TABLE)
3306 errcontext(
"while reindexing partitioned table \"%s.%s\"",
3308 else if (errinfo->
relkind == RELKIND_PARTITIONED_INDEX)
3309 errcontext(
"while reindexing partitioned index \"%s.%s\"",
3332 Assert(RELKIND_HAS_PARTITIONS(relkind));
3342 errcallback.
arg = (
void *) &errinfo;
3347 relkind == RELKIND_PARTITIONED_TABLE ?
3348 "REINDEX TABLE" :
"REINDEX INDEX");
3370 foreach(lc, inhoids)
3380 if (!RELKIND_HAS_STORAGE(partkind))
3383 Assert(partkind == RELKIND_INDEX ||
3384 partkind == RELKIND_RELATION);
3425 char relpersistence;
3465 Assert(!RELKIND_HAS_PARTITIONS(relkind));
3468 relpersistence != RELPERSISTENCE_TEMP)
3478 else if (relkind == RELKIND_INDEX)
3502 (
errmsg(
"table \"%s.%s\" was reindexed",
3542 typedef struct ReindexIndexInfo
3559 char *relationName = NULL;
3560 char *relationNamespace = NULL;
3562 const int progress_index[] = {
3568 int64 progress_vals[4];
3577 "ReindexConcurrent",
3601 case RELKIND_RELATION:
3602 case RELKIND_MATVIEW:
3603 case RELKIND_TOASTVALUE:
3615 heapRelationIds =
lappend_oid(heapRelationIds, relationOid);
3621 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3622 errmsg(
"cannot reindex system catalogs concurrently")));
3640 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3641 errmsg(
"cannot move system relation \"%s\"",
3651 if (!indexRelation->
rd_index->indisvalid)
3653 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3654 errmsg(
"skipping reindex of invalid index \"%s.%s\"",
3657 errhint(
"Use DROP INDEX or REINDEX INDEX.")));
3658 else if (indexRelation->
rd_index->indisexclusion)
3660 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3661 errmsg(
"cannot reindex exclusion constraint index \"%s.%s\" concurrently, skipping",
3666 ReindexIndexInfo *
idx;
3672 idx->indexId = cellOid;
3686 Oid toastOid = heapRelation->
rd_rel->reltoastrelid;
3694 heapRelationIds =
lappend_oid(heapRelationIds, toastOid);
3704 if (!indexRelation->
rd_index->indisvalid)
3706 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3707 errmsg(
"skipping reindex of invalid index \"%s.%s\"",
3710 errhint(
"Use DROP INDEX or REINDEX INDEX.")));
3713 ReindexIndexInfo *
idx;
3722 idx->indexId = cellOid;
3743 ReindexIndexInfo *
idx;
3751 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3752 errmsg(
"cannot reindex system catalogs concurrently")));
3762 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3763 errmsg(
"cannot reindex invalid index on TOAST table")));
3786 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3787 errmsg(
"cannot move system relation \"%s\"",
3803 idx->indexId = relationOid;
3811 case RELKIND_PARTITIONED_TABLE:
3812 case RELKIND_PARTITIONED_INDEX:
3816 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
3817 errmsg(
"cannot reindex this type of relation concurrently")));
3828 if (indexIds ==
NIL)
3834 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3835 errmsg(
"cannot move non-shared relation to tablespace \"%s\"",
3865 foreach(lc, indexIds)
3867 char *concurrentName;
3869 ReindexIndexInfo *newidx;
3874 int save_sec_context;
3902 if (indexRel->
rd_rel->relpersistence == RELPERSISTENCE_TEMP)
3903 elog(
ERROR,
"cannot reindex a temporary table concurrently");
3908 progress_vals[1] = 0;
3909 progress_vals[2] =
idx->indexId;
3910 progress_vals[3] =
idx->amId;
3922 heapRel->
rd_rel->relkind != RELKIND_TOASTVALUE)
3925 tablespaceid = indexRel->
rd_rel->reltablespace;
3945 newidx->indexId = newIndexId;
3946 newidx->safe =
idx->safe;
3947 newidx->tableId =
idx->tableId;
3948 newidx->amId =
idx->amId;
3950 newIndexIds =
lappend(newIndexIds, newidx);
3960 relationLocks =
lappend(relationLocks, lockrelid);
3963 relationLocks =
lappend(relationLocks, lockrelid);
3997 foreach(lc, heapRelationIds)
4009 relationLocks =
lappend(relationLocks, lockrelid);
4015 lockTags =
lappend(lockTags, heaplocktag);
4024 foreach(lc, relationLocks)
4055 foreach(lc, newIndexIds)
4057 ReindexIndexInfo *newidx =
lfirst(lc);
4083 progress_vals[2] = newidx->indexId;
4084 progress_vals[3] = newidx->amId;
4114 foreach(lc, newIndexIds)
4116 ReindexIndexInfo *newidx =
lfirst(lc);
4147 progress_vals[2] = newidx->indexId;
4148 progress_vals[3] = newidx->amId;
4157 limitXmin = snapshot->
xmin;
4206 forboth(lc, indexIds, lc2, newIndexIds)
4208 ReindexIndexInfo *oldidx =
lfirst(lc);
4209 ReindexIndexInfo *newidx =
lfirst(lc2);
4271 foreach(lc, indexIds)
4273 ReindexIndexInfo *oldidx =
lfirst(lc);
4310 foreach(lc, indexIds)
4315 object.
classId = RelationRelationId;
4316 object.objectId =
idx->indexId;
4317 object.objectSubId = 0;
4336 foreach(lc, relationLocks)
4349 if (relkind == RELKIND_INDEX)
4351 (
errmsg(
"index \"%s.%s\" was reindexed",
4352 relationNamespace, relationName),
4357 foreach(lc, newIndexIds)
4360 Oid indOid =
idx->indexId;
4363 (
errmsg(
"index \"%s.%s\" was reindexed",
4370 (
errmsg(
"table \"%s.%s\" was reindexed",
4371 relationNamespace, relationName),
4401 Assert(partitionIdx->
rd_rel->relkind == RELKIND_INDEX ||
4402 partitionIdx->
rd_rel->relkind == RELKIND_PARTITIONED_INDEX);
4409 Anum_pg_inherits_inhrelid,
4413 Anum_pg_inherits_inhseqno,
4455 if (inhForm->inhparent != parentOid)
4458 elog(
ERROR,
"bogus pg_inherit row: inhrelid %u inhparent %u",
4459 inhForm->inhrelid, inhForm->inhparent);
4528 elog(
ERROR,
"cache lookup failed for relation %u", relationId);
Datum idx(PG_FUNCTION_ARGS)
bool has_privs_of_role(Oid member, Oid role)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
IndexAmRoutine * GetIndexAmRoutine(Oid amhandler)
bytea *(* amoptions_function)(Datum reloptions, bool validate)
Datum array_eq(PG_FUNCTION_ARGS)
void free_attrmap(AttrMap *map)
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
#define InvalidAttrNumber
char * get_tablespace_name(Oid spc_oid)
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
Oid GetDefaultTablespace(char relpersistence, bool partitioned)
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_incr_param(int index, int64 incr)
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
bool bms_is_member(int x, const Bitmapset *a)
#define InvalidSubTransactionId
#define OidIsValid(objectId)
bool IsToastNamespace(Oid namespaceId)
bool IsSystemRelation(Relation relation)
bool IsCatalogRelationOid(Oid relid)
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
bool contain_mutable_functions_after_planning(Expr *expr)
char * get_database_name(Oid dbid)
bool defGetBoolean(DefElem *def)
char * defGetString(DefElem *def)
void performMultipleDeletions(const ObjectAddresses *objects, DropBehavior behavior, int flags)
ObjectAddresses * new_object_addresses(void)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
@ DEPENDENCY_PARTITION_PRI
@ DEPENDENCY_PARTITION_SEC
#define PERFORM_DELETION_CONCURRENT_LOCK
#define PERFORM_DELETION_INTERNAL
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void EventTriggerCollectSimpleCommand(ObjectAddress address, ObjectAddress secondaryObject, Node *parsetree)
#define palloc_object(type)
#define palloc_array(type, count)
#define DirectFunctionCall2(func, arg1, arg2)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
StrategyNumber GistTranslateStratnum(Oid opclass, StrategyNumber strat)
bool allowSystemTableMods
int NewGUCNestLevel(void)
void RestrictSearchPath(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
HeapTuple heap_copytuple(HeapTuple tuple)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
Oid IndexGetRelation(Oid indexId, bool missing_ok)
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)
void index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
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)
bool reindex_relation(const ReindexStmt *stmt, Oid relid, int flags, const ReindexParams *params)
Oid index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId, Oid tablespaceOid, const char *newName)
void index_check_primary_key(Relation heapRel, const IndexInfo *indexInfo, bool is_alter_table, const IndexStmt *stmt)
void index_concurrently_build(Oid heapRelationId, Oid indexRelationId)
IndexInfo * BuildIndexInfo(Relation index)
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_CONCURRENTLY
#define REINDEXOPT_MISSING_OK
#define INDEX_CREATE_INVALID
#define INDEX_CONSTR_CREATE_WITHOUT_OVERLAPS
#define INDEX_CREATE_ADD_CONSTRAINT
#define INDEX_CREATE_SKIP_BUILD
#define INDEX_CONSTR_CREATE_DEFERRABLE
#define REINDEXOPT_REPORT_PROGRESS
#define INDEX_CONSTR_CREATE_INIT_DEFERRED
#define INDEX_CREATE_CONCURRENT
#define REINDEXOPT_VERBOSE
#define REINDEX_REL_CHECK_CONSTRAINTS
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
static bool ReindexRelationConcurrently(const ReindexStmt *stmt, Oid relationOid, const ReindexParams *params)
char * makeObjectName(const char *name1, const char *name2, const char *label)
void ExecReindex(ParseState *pstate, const ReindexStmt *stmt, bool isTopLevel)
ObjectAddress DefineIndex(Oid tableId, IndexStmt *stmt, Oid indexRelationId, Oid parentIndexId, Oid parentConstraintId, int total_parts, bool is_alter_table, bool check_rights, bool check_not_in_use, bool skip_build, bool quiet)
static void set_indexsafe_procflags(void)
static void reindex_error_callback(void *arg)
static void ComputeIndexAttrs(IndexInfo *indexInfo, Oid *typeOids, Oid *collationOids, Oid *opclassOids, Datum *opclassOptions, int16 *colOptions, const List *attList, const List *exclusionOpNames, Oid relId, const char *accessMethodName, Oid accessMethodId, bool amcanorder, bool isconstraint, bool iswithoutoverlaps, Oid ddl_userid, int ddl_sec_context, int *ddl_save_nestlevel)
static void ReindexIndex(const ReindexStmt *stmt, const ReindexParams *params, bool isTopLevel)
void IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
static char * ChooseIndexNameAddition(const List *colnames)
static void ReindexMultipleTables(const ReindexStmt *stmt, const ReindexParams *params)
static bool CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts)
static void update_relispartition(Oid relationId, bool newval)
bool CheckIndexCompatible(Oid oldId, const char *accessMethodName, const List *attributeList, const List *exclusionOpNames, bool isWithoutOverlaps)
void WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
Oid ResolveOpClass(const List *opclass, Oid attrType, const char *accessMethodName, Oid accessMethodId)
static void ReindexPartitions(const ReindexStmt *stmt, Oid relid, const ReindexParams *params, bool isTopLevel)
struct ReindexErrorInfo ReindexErrorInfo
static Oid ReindexTable(const ReindexStmt *stmt, const ReindexParams *params, bool isTopLevel)
static void CheckPredicate(Expr *predicate)
static void ReindexMultipleInternal(const ReindexStmt *stmt, const List *relids, const ReindexParams *params)
static void RangeVarCallbackForReindexIndex(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
void GetOperatorFromWellKnownStrategy(Oid opclass, Oid atttype, Oid *opid, StrategyNumber *strat)
static List * ChooseIndexColumnNames(const List *indexElems)
static char * ChooseIndexName(const char *tabname, Oid namespaceId, const List *colnames, const List *exclusionOpNames, bool primary, bool isconstraint)
char * ChooseRelationName(const char *name1, const char *name2, const char *label, Oid namespaceid, bool isconstraint)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
void CacheInvalidateRelcacheByRelid(Oid relid)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
List * lcons_oid(Oid datum, List *list)
List * list_concat_copy(const List *list1, const List *list2)
void UnlockRelationOid(Oid relid, LOCKMODE lockmode)
void WaitForLockersMultiple(List *locktags, LOCKMODE lockmode, bool progress)
void LockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
void WaitForLockers(LOCKTAG heaplocktag, LOCKMODE lockmode, bool progress)
void UnlockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode)
bool VirtualXactLock(VirtualTransactionId vxid, bool wait)
#define VirtualTransactionIdIsValid(vxid)
#define SET_LOCKTAG_RELATION(locktag, dboid, reloid)
#define VirtualTransactionIdEquals(vxid1, vxid2)
#define SetInvalidVirtualTransactionId(vxid)
#define AccessExclusiveLock
#define ShareUpdateExclusiveLock
char get_rel_persistence(Oid relid)
char * get_opname(Oid opno)
bool get_index_isvalid(Oid index_oid)
Oid get_opclass_input_type(Oid opclass)
Oid get_opclass_family(Oid opclass)
char * get_namespace_name(Oid nspid)
bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
Datum get_attoptions(Oid relid, int16 attnum)
char get_rel_relkind(Oid relid)
Oid get_rel_namespace(Oid relid)
RegProcedure get_opcode(Oid opno)
int get_op_opfamily_strategy(Oid opno, Oid opfamily)
char * get_rel_name(Oid relid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
bool type_is_collatable(Oid typid)
Oid getBaseType(Oid typid)
Oid get_relname_relid(const char *relname, Oid relnamespace)
Oid get_commutator(Oid opno)
void op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
List * make_ands_implicit(Expr *clause)
IndexInfo * makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions, List *predicates, bool unique, bool nulls_not_distinct, bool isready, bool concurrent, bool summarizing)
int pg_mbcliplen(const char *mbstr, int len, int limit)
char * pstrdup(const char *in)
void pfree(void *pointer)
void MemoryContextDelete(MemoryContext context)
MemoryContext PortalContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define ALLOCSET_SMALL_SIZES
#define IsBootstrapProcessingMode()
#define SECURITY_RESTRICTED_OPERATION
#define CHECK_FOR_INTERRUPTS()
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
bool isTempNamespace(Oid namespaceId)
Oid get_collation_oid(List *collname, bool missing_ok)
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
Oid get_namespace_oid(const char *nspname, bool missing_ok)
char * NameListToString(const List *names)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
TYPCATEGORY TypeCategory(Oid type)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
bool IsPreferredType(TYPCATEGORY category, Oid type)
int parser_errposition(ParseState *pstate, int location)
Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError)
@ PARTITION_STRATEGY_HASH
@ REINDEX_OBJECT_DATABASE
PartitionKey RelationGetPartitionKey(Relation rel)
PartitionDesc RelationGetPartitionDesc(Relation rel, bool omit_detached)
FormData_pg_am * Form_pg_am
FormData_pg_attribute * Form_pg_attribute
static void fix_dependencies(ArchiveHandle *AH)
int errdetail_relkind_not_supported(char relkind)
FormData_pg_class * Form_pg_class
Oid get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
void ConstraintSetParentConstraint(Oid childConstrId, Oid parentConstrId, Oid childTableId)
bool ConstraintNameExists(const char *conname, Oid namespaceid)
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long deleteDependencyRecordsForClass(Oid classId, Oid objectId, Oid refclassId, char deptype)
FormData_pg_index * Form_pg_index
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
void StoreSingleInheritance(Oid relationId, Oid parentOid, int32 seqNumber)
bool has_superclass(Oid relationId)
FormData_pg_inherits * Form_pg_inherits
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define list_make1_oid(x1)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
FormData_pg_opclass * Form_pg_opclass
FormData_pg_opfamily * Form_pg_opfamily
const char * pg_rusage_show(const PGRUsage *ru0)
void pg_rusage_init(PGRUsage *ru0)
size_t strlcpy(char *dst, const char *src, size_t siz)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
#define PROC_IS_AUTOVACUUM
PGPROC * ProcNumberGetProc(ProcNumber procNumber)
VirtualTransactionId * GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0, bool allDbs, int excludeVacuum, int *nvxids)
#define PROGRESS_CREATEIDX_PHASE_WAIT_4
#define PROGRESS_CREATEIDX_PHASE_BUILD
#define PROGRESS_CREATEIDX_PARTITIONS_DONE
#define PROGRESS_CREATEIDX_PHASE_WAIT_1
#define PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY
#define PROGRESS_CREATEIDX_ACCESS_METHOD_OID
#define PROGRESS_WAITFOR_DONE
#define PROGRESS_CREATEIDX_PHASE_WAIT_3
#define PROGRESS_WAITFOR_TOTAL
#define PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY
#define PROGRESS_CREATEIDX_COMMAND_CREATE
#define PROGRESS_WAITFOR_CURRENT_PID
#define PROGRESS_CREATEIDX_PHASE_WAIT_2
#define PROGRESS_CREATEIDX_PHASE
#define PROGRESS_CREATEIDX_PHASE_VALIDATE_IDXSCAN
#define PROGRESS_CREATEIDX_PHASE_WAIT_5
#define PROGRESS_CREATEIDX_INDEX_OID
#define PROGRESS_CREATEIDX_PARTITIONS_TOTAL
#define PROGRESS_CREATEIDX_COMMAND
char * format_operator(Oid operator_oid)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationGetNamespace(relation)
List * RelationGetIndexList(Relation relation)
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
bytea * index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
Datum transformRelOptions(Datum oldOptions, List *defList, const char *namspace, char *validnsps[], bool acceptOidsOff, bool isReset)
#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)
Snapshot GetTransactionSnapshot(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)
#define RTOverlapStrategyNumber
#define RTEqualStrategyNumber
#define HTEqualStrategyNumber
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
struct ErrorContextCallback * previous
void(* callback)(void *arg)
amoptions_function amoptions
amgettuple_function amgettuple
SortByNulls nulls_ordering
uint16 * ii_ExclusionStrats
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS]
SubTransactionId oldFirstRelfilelocatorSubid
SubTransactionId oldCreateSubid
Oid values[FLEXIBLE_ARRAY_MEMBER]
#define FirstLowInvalidHeapAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheExists1(cacheId, key1)
Relation try_table_open(Oid relationId, LOCKMODE lockmode)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, struct ScanKeyData *key)
static void table_endscan(TableScanDesc scan)
void CheckTableNotInUse(Relation rel, const char *stmt)
void SetRelationHasSubclass(Oid relationId, bool relhassubclass)
void RangeVarCallbackMaintainsTable(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
#define InvalidTransactionId
#define TupleDescAttr(tupdesc, i)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
void CommandCounterIncrement(void)
void PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
void StartTransactionCommand(void)
void CommitTransactionCommand(void)