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

Function LookupTypeNameExtended

src/backend/parser/parse_type.c:74–219  ·  view source on GitHub ↗

* LookupTypeNameExtended * Given a TypeName object, lookup the pg_type syscache entry of the type. * Returns NULL if no such type can be found. If the type is found, * the typmod value represented in the TypeName struct is computed and * stored into *typmod_p. * * NB: on success, the caller must ReleaseSysCache the type tuple when done * with it. * * NB: direct callers of this functi

Source from the content-addressed store, hash-verified

72 * pstate is only used for error location info, and may be NULL.
73 */
74Type
75LookupTypeNameExtended(ParseState *pstate,
76 const TypeName *typeName, int32 *typmod_p,
77 bool temp_ok, bool missing_ok)
78{
79 Oid typoid;
80 HeapTuple tup;
81 int32 typmod;
82
83 if (typeName->names == NIL)
84 {
85 /* We have the OID already if it's an internally generated TypeName */
86 typoid = typeName->typeOid;
87 }
88 else if (typeName->pct_type)
89 {
90 /* Handle %TYPE reference to type of an existing field */
91 RangeVar *rel = makeRangeVar(NULL, NULL, typeName->location);
92 char *field = NULL;
93 Oid relid;
94 AttrNumber attnum;
95
96 /* deconstruct the name list */
97 switch (list_length(typeName->names))
98 {
99 case 1:
100 ereport(ERROR,
101 (errcode(ERRCODE_SYNTAX_ERROR),
102 errmsg("improper %%TYPE reference (too few dotted names): %s",
103 NameListToString(typeName->names)),
104 parser_errposition(pstate, typeName->location)));
105 break;
106 case 2:
107 rel->relname = strVal(linitial(typeName->names));
108 field = strVal(lsecond(typeName->names));
109 break;
110 case 3:
111 rel->schemaname = strVal(linitial(typeName->names));
112 rel->relname = strVal(lsecond(typeName->names));
113 field = strVal(lthird(typeName->names));
114 break;
115 case 4:
116 rel->catalogname = strVal(linitial(typeName->names));
117 rel->schemaname = strVal(lsecond(typeName->names));
118 rel->relname = strVal(lthird(typeName->names));
119 field = strVal(lfourth(typeName->names));
120 break;
121 default:
122 ereport(ERROR,
123 (errcode(ERRCODE_SYNTAX_ERROR),
124 errmsg("improper %%TYPE reference (too many dotted names): %s",
125 NameListToString(typeName->names)),
126 parser_errposition(pstate, typeName->location)));
127 break;
128 }
129
130 /*
131 * Look up the field.

Callers 2

FuncNameAsTypeFunction · 0.85
LookupTypeNameFunction · 0.85

Calls 15

makeRangeVarFunction · 0.85
list_lengthFunction · 0.85
NameListToStringFunction · 0.85
parser_errpositionFunction · 0.85
get_attnumFunction · 0.85
get_atttypeFunction · 0.85
TypeNameToStringFunction · 0.85
format_type_beFunction · 0.85
DeconstructQualifiedNameFunction · 0.85
LookupExplicitNamespaceFunction · 0.85
ObjectIdGetDatumFunction · 0.85

Tested by

no test coverage detected