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

Function parseTypeString

src/backend/parser/parse_type.c:779–811  ·  view source on GitHub ↗

* Given a string that is supposed to be a SQL-compatible type declaration, * such as "int4" or "integer" or "character varying(32)", parse * the string and convert it to a type OID and type modifier. * If missing_ok is true, InvalidOid is returned rather than raising an error * when the type name is not found. */

Source from the content-addressed store, hash-verified

777 * when the type name is not found.
778 */
779void
780parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok)
781{
782 TypeName *typeName;
783 Type tup;
784
785 typeName = typeStringToTypeName(str);
786
787 tup = LookupTypeName(NULL, typeName, typmod_p, missing_ok);
788 if (tup == NULL)
789 {
790 if (!missing_ok)
791 ereport(ERROR,
792 (errcode(ERRCODE_UNDEFINED_OBJECT),
793 errmsg("type \"%s\" does not exist",
794 TypeNameToString(typeName)),
795 parser_errposition(NULL, typeName->location)));
796 *typeid_p = InvalidOid;
797 }
798 else
799 {
800 Form_pg_type typ = (Form_pg_type) GETSTRUCT(tup);
801
802 if (!typ->typisdefined)
803 ereport(ERROR,
804 (errcode(ERRCODE_UNDEFINED_OBJECT),
805 errmsg("type \"%s\" is only a shell",
806 TypeNameToString(typeName)),
807 parser_errposition(NULL, typeName->location)));
808 *typeid_p = typ->oid;
809 ReleaseSysCache(tup);
810 }
811}

Callers 6

pltcl_SPI_prepareFunction · 0.85
plperl_spi_prepareFunction · 0.85
PLy_spi_prepareFunction · 0.85
regtypeinFunction · 0.85
to_regtypeFunction · 0.85
parseNameAndArgTypesFunction · 0.85

Calls 7

typeStringToTypeNameFunction · 0.85
LookupTypeNameFunction · 0.85
TypeNameToStringFunction · 0.85
parser_errpositionFunction · 0.85
ReleaseSysCacheFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected