MCPcopy Create free account
hub / github.com/apache/cloudberry / RelationGetIndexAttOptions

Function RelationGetIndexAttOptions

src/backend/utils/cache/relcache.c:5944–5991  ·  view source on GitHub ↗

* RelationGetIndexAttOptions * get AM/opclass-specific options for an index parsed into a binary form */

Source from the content-addressed store, hash-verified

5942 * get AM/opclass-specific options for an index parsed into a binary form
5943 */
5944bytea **
5945RelationGetIndexAttOptions(Relation relation, bool copy)
5946{
5947 MemoryContext oldcxt;
5948 bytea **opts = relation->rd_opcoptions;
5949 Oid relid = RelationGetRelid(relation);
5950 int natts = RelationGetNumberOfAttributes(relation); /* XXX
5951 * IndexRelationGetNumberOfKeyAttributes */
5952 int i;
5953
5954 /* Try to copy cached options. */
5955 if (opts)
5956 return copy ? CopyIndexAttOptions(opts, natts) : opts;
5957
5958 /* Get and parse opclass options. */
5959 opts = palloc0(sizeof(*opts) * natts);
5960
5961 for (i = 0; i < natts; i++)
5962 {
5963 if (criticalRelcachesBuilt && relid != AttributeRelidNumIndexId)
5964 {
5965 Datum attoptions = get_attoptions(relid, i + 1);
5966
5967 opts[i] = index_opclass_options(relation, i + 1, attoptions, false);
5968
5969 if (attoptions != (Datum) 0)
5970 pfree(DatumGetPointer(attoptions));
5971 }
5972 }
5973
5974 /* Copy parsed options to the cache. */
5975 oldcxt = MemoryContextSwitchTo(relation->rd_indexcxt);
5976 relation->rd_opcoptions = CopyIndexAttOptions(opts, natts);
5977 MemoryContextSwitchTo(oldcxt);
5978
5979 if (copy)
5980 return opts;
5981
5982 for (i = 0; i < natts; i++)
5983 {
5984 if (opts[i])
5985 pfree(opts[i]);
5986 }
5987
5988 pfree(opts);
5989
5990 return relation->rd_opcoptions;
5991}
5992
5993/*
5994 * Routines to support ereport() reports of relation-related errors

Callers 4

load_critical_indexFunction · 0.85
index_getprocinfoFunction · 0.85
get_relation_infoFunction · 0.85

Calls 6

CopyIndexAttOptionsFunction · 0.85
get_attoptionsFunction · 0.85
index_opclass_optionsFunction · 0.85
MemoryContextSwitchToFunction · 0.85
palloc0Function · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected