PostgreSQL Source Code  git master
builtins.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * builtins.h
4  * Declarations for operations on built-in types.
5  *
6  *
7  * Portions Copyright (c) 1996-2024, 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 /* Sign + the most decimal digits an 8-byte number could have */
22 #define MAXINT8LEN 20
23 
24 /* bool.c */
25 extern bool parse_bool(const char *value, bool *result);
26 extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
27 
28 /* domains.c */
29 extern void domain_check(Datum value, bool isnull, Oid domainType,
30  void **extra, MemoryContext mcxt);
31 extern bool domain_check_safe(Datum value, bool isnull, Oid domainType,
32  void **extra, MemoryContext mcxt,
33  Node *escontext);
34 extern int errdatatype(Oid datatypeOid);
35 extern int errdomainconstraint(Oid datatypeOid, const char *conname);
36 
37 /* encode.c */
38 extern uint64 hex_encode(const char *src, size_t len, char *dst);
39 extern uint64 hex_decode(const char *src, size_t len, char *dst);
40 extern uint64 hex_decode_safe(const char *src, size_t len, char *dst,
41  Node *escontext);
42 
43 /* int.c */
44 extern int2vector *buildint2vector(const int16 *int2s, int n);
45 
46 /* name.c */
47 extern void namestrcpy(Name name, const char *str);
48 extern int namestrcmp(Name name, const char *str);
49 
50 /* numutils.c */
51 extern int16 pg_strtoint16(const char *s);
52 extern int16 pg_strtoint16_safe(const char *s, Node *escontext);
53 extern int32 pg_strtoint32(const char *s);
54 extern int32 pg_strtoint32_safe(const char *s, Node *escontext);
55 extern int64 pg_strtoint64(const char *s);
56 extern int64 pg_strtoint64_safe(const char *s, Node *escontext);
57 extern uint32 uint32in_subr(const char *s, char **endloc,
58  const char *typname, Node *escontext);
59 extern uint64 uint64in_subr(const char *s, char **endloc,
60  const char *typname, Node *escontext);
61 extern int pg_itoa(int16 i, char *a);
62 extern int pg_ultoa_n(uint32 value, char *a);
63 extern int pg_ulltoa_n(uint64 value, char *a);
64 extern int pg_ltoa(int32 value, char *a);
65 extern int pg_lltoa(int64 value, char *a);
66 extern char *pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth);
67 extern char *pg_ultostr(char *str, uint32 value);
68 
69 /* oid.c */
70 extern oidvector *buildoidvector(const Oid *oids, int n);
71 extern Oid oidparse(Node *node);
72 extern int oid_cmp(const void *p1, const void *p2);
73 
74 /* regexp.c */
75 extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
76  Oid collation, bool *exact);
77 
78 /* ruleutils.c */
80 extern const char *quote_identifier(const char *ident);
81 extern char *quote_qualified_identifier(const char *qualifier,
82  const char *ident);
84  const char *leftop, Oid leftoptype,
85  Oid opoid,
86  const char *rightop, Oid rightoptype);
87 
88 /* varchar.c */
89 extern int bpchartruelen(char *s, int len);
90 
91 /* popular functions from varlena.c */
92 extern text *cstring_to_text(const char *s);
93 extern text *cstring_to_text_with_len(const char *s, int len);
94 extern char *text_to_cstring(const text *t);
95 extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
96 
97 #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
98 #define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
99 
100 /* xid.c */
101 extern int xidComparator(const void *arg1, const void *arg2);
102 extern int xidLogicalComparator(const void *arg1, const void *arg2);
103 
104 /* inet_cidr_ntop.c */
105 extern char *pg_inet_cidr_ntop(int af, const void *src, int bits,
106  char *dst, size_t size);
107 
108 /* inet_net_pton.c */
109 extern int pg_inet_net_pton(int af, const char *src,
110  void *dst, size_t size);
111 
112 /* network.c */
113 extern double convert_network_to_scalar(Datum value, Oid typid, bool *failure);
114 extern Datum network_scan_first(Datum in);
115 extern Datum network_scan_last(Datum in);
116 extern void clean_ipv6_addr(int addr_family, char *addr);
117 
118 /* numeric.c */
120 
121 /* format_type.c */
122 
123 /* Control flags for format_type_extended */
124 #define FORMAT_TYPE_TYPEMOD_GIVEN 0x01 /* typemod defined by caller */
125 #define FORMAT_TYPE_ALLOW_INVALID 0x02 /* allow invalid types */
126 #define FORMAT_TYPE_FORCE_QUALIFY 0x04 /* force qualification of type */
127 #define FORMAT_TYPE_INVALID_AS_NULL 0x08 /* NULL if undefined */
128 extern char *format_type_extended(Oid type_oid, int32 typemod, bits16 flags);
129 
130 extern char *format_type_be(Oid type_oid);
131 extern char *format_type_be_qualified(Oid type_oid);
132 extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
133 
134 extern int32 type_maximum_size(Oid type_oid, int32 typemod);
135 
136 /* quote.c */
137 extern char *quote_literal_cstr(const char *rawstr);
138 
139 #endif /* BUILTINS_H */
int pg_inet_net_pton(int af, const char *src, void *dst, size_t size)
Definition: inet_net_pton.c:62
int64 pg_strtoint64_safe(const char *s, Node *escontext)
Definition: numutils.c:651
uint64 uint64in_subr(const char *s, char **endloc, const char *typname, Node *escontext)
Definition: numutils.c:987
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:353
void clean_ipv6_addr(int addr_family, char *addr)
Definition: network.c:2095
int xidComparator(const void *arg1, const void *arg2)
Definition: xid.c:139
int64 pg_strtoint64(const char *s)
Definition: numutils.c:645
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:412
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:12596
int bpchartruelen(char *s, int len)
Definition: varchar.c:676
Datum network_scan_last(Datum in)
Definition: network.c:1704
PGDLLIMPORT bool quote_all_identifiers
Definition: ruleutils.c:323
int errdatatype(Oid datatypeOid)
Definition: domains.c:407
int pg_ltoa(int32 value, char *a)
Definition: numutils.c:1122
bool parse_bool(const char *value, bool *result)
Definition: bool.c:30
char * format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
Definition: format_type.c:112
char * quote_literal_cstr(const char *rawstr)
Definition: quote.c:103
void generate_operator_clause(fmStringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
Definition: ruleutils.c:13004
int32 pg_strtoint32_safe(const char *s, Node *escontext)
Definition: numutils.c:389
int namestrcmp(Name name, const char *str)
Definition: name.c:247
char * format_type_with_typemod(Oid type_oid, int32 typemod)
Definition: format_type.c:362
int pg_ulltoa_n(uint64 value, char *a)
Definition: numutils.c:1142
int16 pg_strtoint16(const char *s)
Definition: numutils.c:121
char * text_to_cstring(const text *t)
Definition: varlena.c:217
Oid oidparse(Node *node)
Definition: oid.c:235
int xidLogicalComparator(const void *arg1, const void *arg2)
Definition: xid.c:156
int oid_cmp(const void *p1, const void *p2)
Definition: oid.c:258
int errdomainconstraint(Oid datatypeOid, const char *conname)
Definition: domains.c:431
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:12680
uint64 hex_decode_safe(const char *src, size_t len, char *dst, Node *escontext)
Definition: encode.c:196
void namestrcpy(Name name, const char *str)
Definition: name.c:233
text * cstring_to_text_with_len(const char *s, int len)
Definition: varlena.c:196
uint32 uint32in_subr(const char *s, char **endloc, const char *typname, Node *escontext)
Definition: numutils.c:900
double convert_network_to_scalar(Datum value, Oid typid, bool *failure)
Definition: network.c:1502
uint64 hex_encode(const char *src, size_t len, char *dst)
Definition: encode.c:162
void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)
Definition: varlena.c:248
char * pg_inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size)
char * format_type_be(Oid type_oid)
Definition: format_type.c:343
int pg_lltoa(int64 value, char *a)
Definition: numutils.c:1229
char * regexp_fixed_prefix(text *text_re, bool case_insensitive, Oid collation, bool *exact)
Definition: regexp.c:1953
Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS)
Definition: numeric.c:4661
text * cstring_to_text(const char *s)
Definition: varlena.c:184
int pg_itoa(int16 i, char *a)
Definition: numutils.c:1044
int32 pg_strtoint32(const char *s)
Definition: numutils.c:383
char * pg_ultostr(char *str, uint32 value)
Definition: numutils.c:1309
oidvector * buildoidvector(const Oid *oids, int n)
Definition: oid.c:87
int2vector * buildint2vector(const int16 *int2s, int n)
Definition: int.c:114
char * pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth)
Definition: numutils.c:1269
void domain_check(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt)
Definition: domains.c:346
int16 pg_strtoint16_safe(const char *s, Node *escontext)
Definition: numutils.c:127
bool domain_check_safe(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt, Node *escontext)
Definition: domains.c:355
uint64 hex_decode(const char *src, size_t len, char *dst)
Definition: encode.c:190
Datum network_scan_first(Datum in)
Definition: network.c:1690
bool parse_bool_with_len(const char *value, size_t len, bool *result)
Definition: bool.c:36
int pg_ultoa_n(uint32 value, char *a)
Definition: numutils.c:1057
unsigned int uint32
Definition: c.h:506
uint16 bits16
Definition: c.h:514
#define PGDLLIMPORT
Definition: c.h:1316
signed short int16
Definition: c.h:493
signed int int32
Definition: c.h:494
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
const char * str
#define ident
Definition: indent_codes.h:47
static struct @155 value
int a
Definition: isn.c:69
int i
Definition: isn.c:73
const void size_t len
static char * buf
Definition: pg_test_fsync.c:73
NameData typname
Definition: pg_type.h:41
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
static pg_noinline void Size size
Definition: slab.c:607
Definition: nodes.h:129
Definition: c.h:715
Definition: c.h:741
Definition: c.h:726
Definition: c.h:687
const char * name