1 /*-------------------------------------------------------------------------
2  *
3  * builtins.h
4  *	  Declarations for operations on built-in types.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, 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 */
23 extern bool parse_bool(const char *value, bool *result);
24 extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
25 
26 /* domains.c */
27 extern void domain_check(Datum value, bool isnull, Oid domainType,
28 			 void **extra, MemoryContext mcxt);
29 extern int	errdatatype(Oid datatypeOid);
30 extern int	errdomainconstraint(Oid datatypeOid, const char *conname);
31 
32 /* encode.c */
33 extern unsigned hex_encode(const char *src, unsigned len, char *dst);
34 extern unsigned hex_decode(const char *src, unsigned len, char *dst);
35 
36 /* int.c */
37 extern int2vector *buildint2vector(const int16 *int2s, int n);
38 
39 /* name.c */
40 extern int	namecpy(Name n1, Name n2);
41 extern int	namestrcpy(Name name, const char *str);
42 extern int	namestrcmp(Name name, const char *str);
43 
44 /* numutils.c */
45 extern int32 pg_atoi(const char *s, int size, int c);
46 extern void pg_itoa(int16 i, char *a);
47 extern void pg_ltoa(int32 l, char *a);
48 extern void pg_lltoa(int64 ll, char *a);
49 extern char *pg_ltostr_zeropad(char *str, int32 value, int32 minwidth);
50 extern char *pg_ltostr(char *str, int32 value);
51 extern uint64 pg_strtouint64(const char *str, char **endptr, int base);
52 
53 /* float.c */
54 extern PGDLLIMPORT int extra_float_digits;
55 
56 extern double get_float8_infinity(void);
57 extern float get_float4_infinity(void);
58 extern double get_float8_nan(void);
59 extern float get_float4_nan(void);
60 extern int	is_infinite(double val);
61 extern double float8in_internal(char *num, char **endptr_p,
62 				  const char *type_name, const char *orig_string);
63 extern char *float8out_internal(double num);
64 extern int	float4_cmp_internal(float4 a, float4 b);
65 extern int	float8_cmp_internal(float8 a, float8 b);
66 
67 /* oid.c */
68 extern oidvector *buildoidvector(const Oid *oids, int n);
69 extern Oid	oidparse(Node *node);
70 extern int	oid_cmp(const void *p1, const void *p2);
71 
72 /* regexp.c */
73 extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
74 					Oid collation, bool *exact);
75 
76 /* ruleutils.c */
77 extern bool quote_all_identifiers;
78 extern const char *quote_identifier(const char *ident);
79 extern char *quote_qualified_identifier(const char *qualifier,
80 						   const char *ident);
81 extern void generate_operator_clause(fmStringInfo buf,
82 						 const char *leftop, Oid leftoptype,
83 						 Oid opoid,
84 						 const char *rightop, Oid rightoptype);
85 
86 /* varchar.c */
87 extern int	bpchartruelen(char *s, int len);
88 
89 /* popular functions from varlena.c */
90 extern text *cstring_to_text(const char *s);
91 extern text *cstring_to_text_with_len(const char *s, int len);
92 extern char *text_to_cstring(const text *t);
93 extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
94 
95 #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
96 #define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
97 
98 /* xid.c */
99 extern int	xidComparator(const void *arg1, const void *arg2);
100 
101 /* inet_cidr_ntop.c */
102 extern char *inet_cidr_ntop(int af, const void *src, int bits,
103 			   char *dst, size_t size);
104 
105 /* inet_net_pton.c */
106 extern int inet_net_pton(int af, const char *src,
107 			  void *dst, size_t size);
108 
109 /* network.c */
110 extern double convert_network_to_scalar(Datum value, Oid typid, bool *failure);
111 extern Datum network_scan_first(Datum in);
112 extern Datum network_scan_last(Datum in);
113 extern void clean_ipv6_addr(int addr_family, char *addr);
114 
115 /* numeric.c */
116 extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS);
117 
118 /* format_type.c */
119 extern char *format_type_be(Oid type_oid);
120 extern char *format_type_be_qualified(Oid type_oid);
121 extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
122 extern char *format_type_with_typemod_qualified(Oid type_oid, int32 typemod);
123 extern int32 type_maximum_size(Oid type_oid, int32 typemod);
124 
125 /* quote.c */
126 extern char *quote_literal_cstr(const char *rawstr);
127 
128 #endif							/* BUILTINS_H */
129