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-2022, 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 int errdatatype(Oid datatypeOid);
32 extern int errdomainconstraint(Oid datatypeOid, const char *conname);
33 
34 /* encode.c */
35 extern uint64 hex_encode(const char *src, size_t len, char *dst);
36 extern uint64 hex_decode(const char *src, size_t len, char *dst);
37 
38 /* int.c */
39 extern int2vector *buildint2vector(const int16 *int2s, int n);
40 
41 /* name.c */
42 extern void namestrcpy(Name name, const char *str);
43 extern int namestrcmp(Name name, const char *str);
44 
45 /* numutils.c */
46 extern int16 pg_strtoint16(const char *s);
47 extern int16 pg_strtoint16_safe(const char *s, Node *escontext);
48 extern int32 pg_strtoint32(const char *s);
49 extern int32 pg_strtoint32_safe(const char *s, Node *escontext);
50 extern int64 pg_strtoint64(const char *s);
51 extern int64 pg_strtoint64_safe(const char *s, Node *escontext);
52 extern int pg_itoa(int16 i, char *a);
53 extern int pg_ultoa_n(uint32 value, char *a);
54 extern int pg_ulltoa_n(uint64 value, char *a);
55 extern int pg_ltoa(int32 value, char *a);
56 extern int pg_lltoa(int64 value, char *a);
57 extern char *pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth);
58 extern char *pg_ultostr(char *str, uint32 value);
59 
60 /* oid.c */
61 extern oidvector *buildoidvector(const Oid *oids, int n);
62 extern Oid oidparse(Node *node);
63 extern int oid_cmp(const void *p1, const void *p2);
64 
65 /* regexp.c */
66 extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
67  Oid collation, bool *exact);
68 
69 /* ruleutils.c */
71 extern const char *quote_identifier(const char *ident);
72 extern char *quote_qualified_identifier(const char *qualifier,
73  const char *ident);
75  const char *leftop, Oid leftoptype,
76  Oid opoid,
77  const char *rightop, Oid rightoptype);
78 
79 /* varchar.c */
80 extern int bpchartruelen(char *s, int len);
81 
82 /* popular functions from varlena.c */
83 extern text *cstring_to_text(const char *s);
84 extern text *cstring_to_text_with_len(const char *s, int len);
85 extern char *text_to_cstring(const text *t);
86 extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
87 
88 #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
89 #define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
90 
91 /* xid.c */
92 extern int xidComparator(const void *arg1, const void *arg2);
93 extern int xidLogicalComparator(const void *arg1, const void *arg2);
94 
95 /* inet_cidr_ntop.c */
96 extern char *pg_inet_cidr_ntop(int af, const void *src, int bits,
97  char *dst, size_t size);
98 
99 /* inet_net_pton.c */
100 extern int pg_inet_net_pton(int af, const char *src,
101  void *dst, size_t size);
102 
103 /* network.c */
104 extern double convert_network_to_scalar(Datum value, Oid typid, bool *failure);
105 extern Datum network_scan_first(Datum in);
106 extern Datum network_scan_last(Datum in);
107 extern void clean_ipv6_addr(int addr_family, char *addr);
108 
109 /* numeric.c */
111 
112 /* format_type.c */
113 
114 /* Control flags for format_type_extended */
115 #define FORMAT_TYPE_TYPEMOD_GIVEN 0x01 /* typemod defined by caller */
116 #define FORMAT_TYPE_ALLOW_INVALID 0x02 /* allow invalid types */
117 #define FORMAT_TYPE_FORCE_QUALIFY 0x04 /* force qualification of type */
118 #define FORMAT_TYPE_INVALID_AS_NULL 0x08 /* NULL if undefined */
119 extern char *format_type_extended(Oid type_oid, int32 typemod, bits16 flags);
120 
121 extern char *format_type_be(Oid type_oid);
122 extern char *format_type_be_qualified(Oid type_oid);
123 extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
124 
125 extern int32 type_maximum_size(Oid type_oid, int32 typemod);
126 
127 /* quote.c */
128 extern char *quote_literal_cstr(const char *rawstr);
129 
130 #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:278
char * format_type_be_qualified(Oid type_oid)
Definition: format_type.c:349
void clean_ipv6_addr(int addr_family, char *addr)
Definition: network.c:2095
int xidComparator(const void *arg1, const void *arg2)
Definition: xid.c:136
int64 pg_strtoint64(const char *s)
Definition: numutils.c:272
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:408
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:11529
int bpchartruelen(char *s, int len)
Definition: varchar.c:672
Datum network_scan_last(Datum in)
Definition: network.c:1704
PGDLLIMPORT bool quote_all_identifiers
Definition: ruleutils.c:324
int errdatatype(Oid datatypeOid)
Definition: domains.c:360
int pg_ltoa(int32 value, char *a)
Definition: numutils.c:431
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:102
void generate_operator_clause(fmStringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
Definition: ruleutils.c:11937
int32 pg_strtoint32_safe(const char *s, Node *escontext)
Definition: numutils.c:193
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:358
int pg_ulltoa_n(uint64 value, char *a)
Definition: numutils.c:451
int16 pg_strtoint16(const char *s)
Definition: numutils.c:102
char * text_to_cstring(const text *t)
Definition: varlena.c:222
Oid oidparse(Node *node)
Definition: oid.c:314
int xidLogicalComparator(const void *arg1, const void *arg2)
Definition: xid.c:157
int oid_cmp(const void *p1, const void *p2)
Definition: oid.c:336
int errdomainconstraint(Oid datatypeOid, const char *conname)
Definition: domains.c:384
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:11613
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:201
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:161
void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)
Definition: varlena.c:253
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:339
int pg_lltoa(int64 value, char *a)
Definition: numutils.c:538
char * regexp_fixed_prefix(text *text_re, bool case_insensitive, Oid collation, bool *exact)
Definition: regexp.c:1939
Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS)
Definition: numeric.c:4471
text * cstring_to_text(const char *s)
Definition: varlena.c:189
int pg_itoa(int16 i, char *a)
Definition: numutils.c:353
int32 pg_strtoint32(const char *s)
Definition: numutils.c:187
char * pg_ultostr(char *str, uint32 value)
Definition: numutils.c:618
oidvector * buildoidvector(const Oid *oids, int n)
Definition: oid.c:167
int2vector * buildint2vector(const int16 *int2s, int n)
Definition: int.c:114
char * pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth)
Definition: numutils.c:578
void domain_check(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt)
Definition: domains.c:327
int16 pg_strtoint16_safe(const char *s, Node *escontext)
Definition: numutils.c:108
uint64 hex_decode(const char *src, size_t len, char *dst)
Definition: encode.c:193
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:366
unsigned int uint32
Definition: c.h:442
uint16 bits16
Definition: c.h:450
#define PGDLLIMPORT
Definition: c.h:1252
signed short int16
Definition: c.h:429
signed int int32
Definition: c.h:430
const char * name
Definition: encode.c:561
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
static struct @143 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:67
uintptr_t Datum
Definition: postgres.h:412
unsigned int Oid
Definition: postgres_ext.h:31
Definition: nodes.h:118
Definition: c.h:651
Definition: c.h:677
Definition: c.h:662
Definition: c.h:623