1/*-------------------------------------------------------------------------
2 *
3 * builtins.h
4 * Declarations for operations on built-in types.
5 *
6 *
7 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/utils/builtins.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef BUILTINS_H
15#define BUILTINS_H
16
17#include "fmgr.h"
18#include "nodes/nodes.h"
19#include "utils/fmgrprotos.h"
20
21
22/* bool.c */
23extern bool parse_bool(const char *value, bool *result);
24extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
25
26/* domains.c */
27extern void domain_check(Datum value, bool isnull, Oid domainType,
28 void **extra, MemoryContext mcxt);
29extern int errdatatype(Oid datatypeOid);
30extern int errdomainconstraint(Oid datatypeOid, const char *conname);
31
32/* encode.c */
33extern unsigned hex_encode(const char *src, unsigned len, char *dst);
34extern unsigned hex_decode(const char *src, unsigned len, char *dst);
35
36/* int.c */
37extern int2vector *buildint2vector(const int16 *int2s, int n);
38
39/* name.c */
40extern int namecpy(Name n1, const NameData *n2);
41extern int namestrcpy(Name name, const char *str);
42extern int namestrcmp(Name name, const char *str);
43
44/* numutils.c */
45extern int32 pg_atoi(const char *s, int size, int c);
46extern int16 pg_strtoint16(const char *s);
47extern int32 pg_strtoint32(const char *s);
48extern void pg_itoa(int16 i, char *a);
49extern void pg_ltoa(int32 l, char *a);
50extern void pg_lltoa(int64 ll, char *a);
51extern char *pg_ltostr_zeropad(char *str, int32 value, int32 minwidth);
52extern char *pg_ltostr(char *str, int32 value);
53extern uint64 pg_strtouint64(const char *str, char **endptr, int base);
54
55/* oid.c */
56extern oidvector *buildoidvector(const Oid *oids, int n);
57extern Oid oidparse(Node *node);
58extern int oid_cmp(const void *p1, const void *p2);
59
60/* regexp.c */
61extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
62 Oid collation, bool *exact);
63
64/* ruleutils.c */
65extern bool quote_all_identifiers;
66extern const char *quote_identifier(const char *ident);
67extern char *quote_qualified_identifier(const char *qualifier,
68 const char *ident);
69extern void generate_operator_clause(fmStringInfo buf,
70 const char *leftop, Oid leftoptype,
71 Oid opoid,
72 const char *rightop, Oid rightoptype);
73
74/* varchar.c */
75extern int bpchartruelen(char *s, int len);
76
77/* popular functions from varlena.c */
78extern text *cstring_to_text(const char *s);
79extern text *cstring_to_text_with_len(const char *s, int len);
80extern char *text_to_cstring(const text *t);
81extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
82
83#define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
84#define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
85
86/* xid.c */
87extern int xidComparator(const void *arg1, const void *arg2);
88
89/* inet_cidr_ntop.c */
90extern char *inet_cidr_ntop(int af, const void *src, int bits,
91 char *dst, size_t size);
92
93/* inet_net_pton.c */
94extern int inet_net_pton(int af, const char *src,
95 void *dst, size_t size);
96
97/* network.c */
98extern double convert_network_to_scalar(Datum value, Oid typid, bool *failure);
99extern Datum network_scan_first(Datum in);
100extern Datum network_scan_last(Datum in);
101extern void clean_ipv6_addr(int addr_family, char *addr);
102
103/* numeric.c */
104extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS);
105
106/* format_type.c */
107
108/* Control flags for format_type_extended */
109#define FORMAT_TYPE_TYPEMOD_GIVEN 0x01 /* typemod defined by caller */
110#define FORMAT_TYPE_ALLOW_INVALID 0x02 /* allow invalid types */
111#define FORMAT_TYPE_FORCE_QUALIFY 0x04 /* force qualification of type */
112extern char *format_type_extended(Oid type_oid, int32 typemod, bits16 flags);
113
114extern char *format_type_be(Oid type_oid);
115extern char *format_type_be_qualified(Oid type_oid);
116extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
117
118extern int32 type_maximum_size(Oid type_oid, int32 typemod);
119
120/* quote.c */
121extern char *quote_literal_cstr(const char *rawstr);
122
123#endif /* BUILTINS_H */
124