1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* builtins.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* Declarations for operations on built-in types.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2018-01-03 05:30:12 +01:00
|
|
|
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/utils/builtins.h
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef BUILTINS_H
|
|
|
|
#define BUILTINS_H
|
|
|
|
|
2000-08-24 05:29:15 +02:00
|
|
|
#include "fmgr.h"
|
2016-12-28 18:00:00 +01:00
|
|
|
#include "nodes/nodes.h"
|
2017-01-17 18:00:00 +01:00
|
|
|
#include "utils/fmgrprotos.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2016-08-14 00:31:14 +02:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/* bool.c */
|
2009-03-09 15:34:35 +01:00
|
|
|
extern bool parse_bool(const char *value, bool *result);
|
|
|
|
extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2006-04-06 00:11:58 +02:00
|
|
|
/* domains.c */
|
Provide database object names as separate fields in error messages.
This patch addresses the problem that applications currently have to
extract object names from possibly-localized textual error messages,
if they want to know for example which index caused a UNIQUE_VIOLATION
failure. It adds new error message fields to the wire protocol, which
can carry the name of a table, table column, data type, or constraint
associated with the error. (Since the protocol spec has always instructed
clients to ignore unrecognized field types, this should not create any
compatibility problem.)
Support for providing these new fields has been added to just a limited set
of error reports (mainly, those in the "integrity constraint violation"
SQLSTATE class), but we will doubtless add them to more calls in future.
Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with
additional hacking by Tom Lane.
2013-01-29 23:06:26 +01:00
|
|
|
extern void domain_check(Datum value, bool isnull, Oid domainType,
|
|
|
|
void **extra, MemoryContext mcxt);
|
|
|
|
extern int errdatatype(Oid datatypeOid);
|
|
|
|
extern int errdomainconstraint(Oid datatypeOid, const char *conname);
|
2006-04-06 00:11:58 +02:00
|
|
|
|
2009-08-04 18:08:37 +02:00
|
|
|
/* encode.c */
|
|
|
|
extern unsigned hex_encode(const char *src, unsigned len, char *dst);
|
|
|
|
extern unsigned hex_decode(const char *src, unsigned len, char *dst);
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/* int.c */
|
2012-06-25 00:51:46 +02:00
|
|
|
extern int2vector *buildint2vector(const int16 *int2s, int n);
|
2000-10-24 22:16:48 +02:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/* name.c */
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int namecpy(Name n1, Name n2);
|
2000-01-22 15:20:56 +01:00
|
|
|
extern int namestrcpy(Name name, const char *str);
|
|
|
|
extern int namestrcmp(Name name, const char *str);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* numutils.c */
|
2014-10-31 17:02:40 +01:00
|
|
|
extern int32 pg_atoi(const char *s, int size, int c);
|
2000-08-01 20:29:35 +02:00
|
|
|
extern void pg_itoa(int16 i, char *a);
|
|
|
|
extern void pg_ltoa(int32 l, char *a);
|
2010-11-20 04:13:11 +01:00
|
|
|
extern void pg_lltoa(int64 ll, char *a);
|
2016-02-07 05:11:28 +01:00
|
|
|
extern char *pg_ltostr_zeropad(char *str, int32 value, int32 minwidth);
|
|
|
|
extern char *pg_ltostr(char *str, int32 value);
|
Widen query numbers-of-tuples-processed counters to uint64.
This patch widens SPI_processed, EState's es_processed field, PortalData's
portalPos field, FuncCallContext's call_cntr and max_calls fields,
ExecutorRun's count argument, PortalRunFetch's result, and the max number
of rows in a SPITupleTable to uint64, and deals with (I hope) all the
ensuing fallout. Some of these values were declared uint32 before, and
others "long".
I also removed PortalData's posOverflow field, since that logic seems
pretty useless given that portalPos is now always 64 bits.
The user-visible results are that command tags for SELECT etc will
correctly report tuple counts larger than 4G, as will plpgsql's GET
GET DIAGNOSTICS ... ROW_COUNT command. Queries processing more tuples
than that are still not exactly the norm, but they're becoming more
common.
Most values associated with FETCH/MOVE distances, such as PortalRun's count
argument and the count argument of most SPI functions that have one, remain
declared as "long". It's not clear whether it would be worth promoting
those to int64; but it would definitely be a large dollop of additional
API churn on top of this, and it would only help 32-bit platforms which
seem relatively less likely to see any benefit.
Andreas Scherbaum, reviewed by Christian Ullrich, additional hacking by me
2016-03-12 22:05:10 +01:00
|
|
|
extern uint64 pg_strtouint64(const char *str, char **endptr, int base);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* float.c */
|
2007-07-25 14:22:54 +02:00
|
|
|
extern PGDLLIMPORT int extra_float_digits;
|
2002-11-08 18:37:52 +01:00
|
|
|
|
2004-03-15 04:29:22 +01:00
|
|
|
extern double get_float8_infinity(void);
|
|
|
|
extern float get_float4_infinity(void);
|
|
|
|
extern double get_float8_nan(void);
|
|
|
|
extern float get_float4_nan(void);
|
|
|
|
extern int is_infinite(double val);
|
Improve portability of I/O behavior for the geometric types.
Formerly, the geometric I/O routines such as box_in and point_out relied
directly on strtod() and sprintf() for conversion of the float8 component
values of their data types. However, the behavior of those functions is
pretty platform-dependent, especially for edge-case values such as
infinities and NaNs. This was exposed by commit acdf2a8b372aec1d, which
added test cases involving boxes with infinity endpoints, and immediately
failed on Windows and AIX buildfarm members. We solved these problems
years ago in the main float8in and float8out functions, so let's fix it
by making the geometric types use that code instead of depending directly
on the platform-supplied functions.
To do this, refactor the float8in code so that it can be used to parse
just part of a string, and as a convenience make the guts of float8out
usable without going through DirectFunctionCall.
While at it, get rid of geo_ops.c's fairly shaky assumptions about the
maximum output string length for a double, by having it build results in
StringInfo buffers instead of fixed-length strings.
In passing, convert all the "invalid input syntax for type foo" messages
in this area of the code into "invalid input syntax for type %s" to reduce
the number of distinct translatable strings, per recent discussion.
We would have needed a fair number of the latter anyway for code-sharing
reasons, so we might as well just go whole hog.
Note: this patch is by no means intended to guarantee that the geometric
types uniformly behave sanely for infinity or NaN component values.
But any bugs we have in that line were there all along, they were just
harder to reach in a platform-independent way.
2016-03-30 23:25:03 +02:00
|
|
|
extern double float8in_internal(char *num, char **endptr_p,
|
|
|
|
const char *type_name, const char *orig_string);
|
|
|
|
extern char *float8out_internal(double num);
|
2016-07-15 00:45:59 +02:00
|
|
|
extern int float4_cmp_internal(float4 a, float4 b);
|
|
|
|
extern int float8_cmp_internal(float8 a, float8 b);
|
2004-03-15 04:29:22 +01:00
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/* oid.c */
|
2005-03-29 02:17:27 +02:00
|
|
|
extern oidvector *buildoidvector(const Oid *oids, int n);
|
2010-07-06 21:19:02 +02:00
|
|
|
extern Oid oidparse(Node *node);
|
2017-03-01 17:55:28 +01:00
|
|
|
extern int oid_cmp(const void *p1, const void *p2);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/* regexp.c */
|
2012-07-10 20:54:37 +02:00
|
|
|
extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
|
2013-05-29 22:58:43 +02:00
|
|
|
Oid collation, bool *exact);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1999-10-04 01:55:40 +02:00
|
|
|
/* ruleutils.c */
|
2010-07-22 03:22:35 +02:00
|
|
|
extern bool quote_all_identifiers;
|
2002-04-25 04:56:56 +02:00
|
|
|
extern const char *quote_identifier(const char *ident);
|
2009-07-16 08:33:46 +02:00
|
|
|
extern char *quote_qualified_identifier(const char *qualifier,
|
2002-09-04 22:31:48 +02:00
|
|
|
const char *ident);
|
2011-02-08 22:04:18 +01:00
|
|
|
|
1996-11-10 04:06:38 +01:00
|
|
|
/* varchar.c */
|
2016-02-03 20:17:35 +01:00
|
|
|
extern int bpchartruelen(char *s, int len);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2017-01-21 02:29:53 +01:00
|
|
|
/* popular functions from varlena.c */
|
2008-03-25 23:42:46 +01:00
|
|
|
extern text *cstring_to_text(const char *s);
|
|
|
|
extern text *cstring_to_text_with_len(const char *s, int len);
|
|
|
|
extern char *text_to_cstring(const text *t);
|
|
|
|
extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
|
|
|
|
|
|
|
|
#define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
|
|
|
|
#define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
|
|
|
|
|
2003-05-13 01:08:52 +02:00
|
|
|
/* xid.c */
|
2010-02-26 03:01:40 +01:00
|
|
|
extern int xidComparator(const void *arg1, const void *arg2);
|
1997-03-09 21:41:02 +01:00
|
|
|
|
2010-11-24 23:04:19 +01:00
|
|
|
/* inet_cidr_ntop.c */
|
2000-08-04 01:07:51 +02:00
|
|
|
extern char *inet_cidr_ntop(int af, const void *src, int bits,
|
2001-03-22 05:01:46 +01:00
|
|
|
char *dst, size_t size);
|
1998-10-03 07:41:01 +02:00
|
|
|
|
|
|
|
/* inet_net_pton.c */
|
2001-03-22 05:01:46 +01:00
|
|
|
extern int inet_net_pton(int af, const char *src,
|
|
|
|
void *dst, size_t size);
|
1998-10-03 07:41:01 +02:00
|
|
|
|
1998-10-22 22:40:50 +02:00
|
|
|
/* network.c */
|
2001-06-10 00:16:18 +02:00
|
|
|
extern double convert_network_to_scalar(Datum value, Oid typid);
|
2001-06-17 04:05:20 +02:00
|
|
|
extern Datum network_scan_first(Datum in);
|
|
|
|
extern Datum network_scan_last(Datum in);
|
2007-05-18 01:31:49 +02:00
|
|
|
extern void clean_ipv6_addr(int addr_family, char *addr);
|
1998-10-03 07:41:01 +02:00
|
|
|
|
1998-12-30 20:56:35 +01:00
|
|
|
/* numeric.c */
|
2001-10-14 01:32:34 +02:00
|
|
|
extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS);
|
2000-06-13 09:35:40 +02:00
|
|
|
|
2000-07-09 23:30:21 +02:00
|
|
|
/* format_type.c */
|
2018-02-17 23:02:15 +01:00
|
|
|
|
|
|
|
/* Control flags for format_type_extended */
|
|
|
|
#define FORMAT_TYPE_TYPEMOD_GIVEN 0x01 /* typemod defined by caller */
|
|
|
|
#define FORMAT_TYPE_ALLOW_INVALID 0x02 /* allow invalid types */
|
|
|
|
#define FORMAT_TYPE_FORCE_QUALIFY 0x04 /* force qualification of type */
|
|
|
|
extern char *format_type_extended(Oid type_oid, int32 typemod, bits16 flags);
|
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
extern char *format_type_be(Oid type_oid);
|
2013-03-20 22:19:19 +01:00
|
|
|
extern char *format_type_be_qualified(Oid type_oid);
|
2001-10-25 07:50:21 +02:00
|
|
|
extern char *format_type_with_typemod(Oid type_oid, int32 typemod);
|
2018-02-17 23:02:15 +01:00
|
|
|
|
2000-08-25 20:05:54 +02:00
|
|
|
extern int32 type_maximum_size(Oid type_oid, int32 typemod);
|
2000-07-07 21:24:43 +02:00
|
|
|
|
2000-09-05 22:25:14 +02:00
|
|
|
/* quote.c */
|
2011-02-22 22:33:44 +01:00
|
|
|
extern char *quote_literal_cstr(const char *rawstr);
|
2007-10-14 01:06:28 +02:00
|
|
|
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:18:54 +02:00
|
|
|
#endif /* BUILTINS_H */
|