1/*-------------------------------------------------------------------------
2 *
3 * parse_type.h
4 * handle type operations for parser
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/parser/parse_type.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PARSE_TYPE_H
14#define PARSE_TYPE_H
15
16#include "access/htup.h"
17#include "parser/parse_node.h"
18
19
20typedef HeapTuple Type;
21
22extern Type LookupTypeName(ParseState *pstate, const TypeName *typeName,
23 int32 *typmod_p, bool missing_ok);
24extern Type LookupTypeNameExtended(ParseState *pstate,
25 const TypeName *typeName, int32 *typmod_p,
26 bool temp_ok, bool missing_ok);
27extern Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName,
28 bool missing_ok);
29extern Type typenameType(ParseState *pstate, const TypeName *typeName,
30 int32 *typmod_p);
31extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName);
32extern void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
33 Oid *typeid_p, int32 *typmod_p);
34
35extern char *TypeNameToString(const TypeName *typeName);
36extern char *TypeNameListToString(List *typenames);
37
38extern Oid LookupCollation(ParseState *pstate, List *collnames, int location);
39extern Oid GetColumnDefCollation(ParseState *pstate, ColumnDef *coldef, Oid typeOid);
40
41extern Type typeidType(Oid id);
42
43extern Oid typeTypeId(Type tp);
44extern int16 typeLen(Type t);
45extern bool typeByVal(Type t);
46extern char *typeTypeName(Type t);
47extern Oid typeTypeRelid(Type typ);
48extern Oid typeTypeCollation(Type typ);
49extern Datum stringTypeDatum(Type tp, char *string, int32 atttypmod);
50
51extern Oid typeidTypeRelid(Oid type_id);
52extern Oid typeOrDomainTypeRelid(Oid type_id);
53
54extern TypeName *typeStringToTypeName(const char *str);
55extern void parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, bool missing_ok);
56
57/* true if typeid is composite, or domain over composite, but not RECORD */
58#define ISCOMPLEX(typeid) (typeOrDomainTypeRelid(typeid) != InvalidOid)
59
60#endif /* PARSE_TYPE_H */
61