* LookupTypeNameOid * Given a TypeName object, lookup the pg_type syscache entry of the type. * Returns InvalidOid if no such type can be found. If the type is found, * return its Oid. * * NB: direct callers of this function need to be aware that the type OID * returned may correspond to a shell type. Most code should go through * typenameTypeId instead. * * pstate is only used for e
| 231 | * pstate is only used for error location info, and may be NULL. |
| 232 | */ |
| 233 | Oid |
| 234 | LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok) |
| 235 | { |
| 236 | Oid typoid; |
| 237 | Type tup; |
| 238 | |
| 239 | tup = LookupTypeName(pstate, typeName, NULL, missing_ok); |
| 240 | if (tup == NULL) |
| 241 | { |
| 242 | if (!missing_ok) |
| 243 | ereport(ERROR, |
| 244 | (errcode(ERRCODE_UNDEFINED_OBJECT), |
| 245 | errmsg("type \"%s\" does not exist", |
| 246 | TypeNameToString(typeName)), |
| 247 | parser_errposition(pstate, typeName->location))); |
| 248 | |
| 249 | return InvalidOid; |
| 250 | } |
| 251 | |
| 252 | typoid = ((Form_pg_type) GETSTRUCT(tup))->oid; |
| 253 | ReleaseSysCache(tup); |
| 254 | |
| 255 | return typoid; |
| 256 | } |
| 257 | |
| 258 | /* |
| 259 | * typenameType - given a TypeName, return a Type structure and typmod |
no test coverage detected