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

Function OpClassCacheLookup

src/backend/commands/opclasscmds.c:169–219  ·  view source on GitHub ↗

* OpClassCacheLookup * Look up an existing opclass by name. * * Returns a syscache tuple reference, or NULL if not found. */

Source from the content-addressed store, hash-verified

167 * Returns a syscache tuple reference, or NULL if not found.
168 */
169static HeapTuple
170OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
171{
172 char *schemaname;
173 char *opcname;
174 HeapTuple htup;
175
176 /* deconstruct the name list */
177 DeconstructQualifiedName(opclassname, &schemaname, &opcname);
178
179 if (schemaname)
180 {
181 /* Look in specific schema only */
182 Oid namespaceId;
183
184 namespaceId = LookupExplicitNamespace(schemaname, missing_ok);
185 if (!OidIsValid(namespaceId))
186 htup = NULL;
187 else
188 htup = SearchSysCache3(CLAAMNAMENSP,
189 ObjectIdGetDatum(amID),
190 PointerGetDatum(opcname),
191 ObjectIdGetDatum(namespaceId));
192 }
193 else
194 {
195 /* Unqualified opclass name, so search the search path */
196 Oid opcID = OpclassnameGetOpcid(amID, opcname);
197
198 if (!OidIsValid(opcID))
199 htup = NULL;
200 else
201 htup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opcID));
202 }
203
204 if (!HeapTupleIsValid(htup) && !missing_ok)
205 {
206 HeapTuple amtup;
207
208 amtup = SearchSysCache1(AMOID, ObjectIdGetDatum(amID));
209 if (!HeapTupleIsValid(amtup))
210 elog(ERROR, "cache lookup failed for access method %u", amID);
211 ereport(ERROR,
212 (errcode(ERRCODE_UNDEFINED_OBJECT),
213 errmsg("operator class \"%s\" does not exist for access method \"%s\"",
214 NameListToString(opclassname),
215 NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
216 }
217
218 return htup;
219}
220
221/*
222 * get_opclass_oid

Callers 1

get_opclass_oidFunction · 0.85

Calls 9

DeconstructQualifiedNameFunction · 0.85
LookupExplicitNamespaceFunction · 0.85
SearchSysCache3Function · 0.85
ObjectIdGetDatumFunction · 0.85
OpclassnameGetOpcidFunction · 0.85
SearchSysCache1Function · 0.85
NameListToStringFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected