60#ifdef DEBUG_TO_FROM_CHAR
61#define DEBUG_elog_output DEBUG3
74#include <unicode/ustring.h>
105#define KeyWord_INDEX_SIZE ('~' - ' ')
106#define KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1)
111#define DCH_MAX_ITEM_SIZ 12
112#define NUM_MAX_ITEM_SIZ 8
178 "January",
"February",
"March",
"April",
"May",
"June",
"July",
179 "August",
"September",
"October",
"November",
"December", NULL
183 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat", NULL
193#define ADJUST_YEAR(year, is_interval) ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year)))
195#define A_D_STR "A.D."
196#define a_d_STR "a.d."
200#define B_C_STR "B.C."
201#define b_c_STR "b.c."
221#define A_M_STR "A.M."
222#define a_m_STR "a.m."
226#define P_M_STR "P.M."
227#define p_m_STR "p.m."
250{
"XII",
"XI",
"X",
"IX",
"VIII",
"VII",
"VI",
"V",
"IV",
"III",
"II",
"I", NULL};
253{
"xii",
"xi",
"x",
"ix",
"viii",
"vii",
"vi",
"v",
"iv",
"iii",
"ii",
"i", NULL};
258static const char *
const rm1[] = {
"I",
"II",
"III",
"IV",
"V",
"VI",
"VII",
"VIII",
"IX", NULL};
259static const char *
const rm10[] = {
"X",
"XX",
"XXX",
"XL",
"L",
"LX",
"LXX",
"LXXX",
"XC", NULL};
260static const char *
const rm100[] = {
"C",
"CC",
"CCC",
"CD",
"D",
"DC",
"DCC",
"DCCC",
"CM", NULL};
266#define IS_VALID_SUB_COMB(curr, next) \
267 (((curr) == 'I' && ((next) == 'V' || (next) == 'X')) || \
268 ((curr) == 'X' && ((next) == 'L' || (next) == 'C')) || \
269 ((curr) == 'C' && ((next) == 'D' || (next) == 'M')))
274#define ROMAN_VAL(r) \
281 (r) == 'M' ? 1000 : 0)
286#define MAX_ROMAN_LEN 15
291static const char *
const numTH[] = {
"ST",
"ND",
"RD",
"TH", NULL};
292static const char *
const numth[] = {
"st",
"nd",
"rd",
"th", NULL};
329#define NUM_F_DECIMAL (1 << 1)
330#define NUM_F_LDECIMAL (1 << 2)
331#define NUM_F_ZERO (1 << 3)
332#define NUM_F_BLANK (1 << 4)
333#define NUM_F_FILLMODE (1 << 5)
334#define NUM_F_LSIGN (1 << 6)
335#define NUM_F_BRACKET (1 << 7)
336#define NUM_F_MINUS (1 << 8)
337#define NUM_F_PLUS (1 << 9)
338#define NUM_F_ROMAN (1 << 10)
339#define NUM_F_MULTI (1 << 11)
340#define NUM_F_PLUS_POST (1 << 12)
341#define NUM_F_MINUS_POST (1 << 13)
342#define NUM_F_EEEE (1 << 14)
347#define IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL)
348#define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL)
349#define IS_ZERO(_f) ((_f)->flag & NUM_F_ZERO)
350#define IS_BLANK(_f) ((_f)->flag & NUM_F_BLANK)
351#define IS_FILLMODE(_f) ((_f)->flag & NUM_F_FILLMODE)
352#define IS_BRACKET(_f) ((_f)->flag & NUM_F_BRACKET)
353#define IS_MINUS(_f) ((_f)->flag & NUM_F_MINUS)
354#define IS_LSIGN(_f) ((_f)->flag & NUM_F_LSIGN)
355#define IS_PLUS(_f) ((_f)->flag & NUM_F_PLUS)
356#define IS_ROMAN(_f) ((_f)->flag & NUM_F_ROMAN)
357#define IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI)
358#define IS_EEEE(_f) ((_f)->flag & NUM_F_EEEE)
377#define DCH_CACHE_OVERHEAD \
378 MAXALIGN(sizeof(bool) + sizeof(int))
379#define NUM_CACHE_OVERHEAD \
380 MAXALIGN(sizeof(bool) + sizeof(int) + sizeof(NUMDesc))
382#define DCH_CACHE_SIZE \
383 ((2048 - DCH_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1)
384#define NUM_CACHE_SIZE \
385 ((1024 - NUM_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1)
387#define DCH_CACHE_ENTRIES 20
388#define NUM_CACHE_ENTRIES 20
462#ifdef DEBUG_TO_FROM_CHAR
463#define DEBUG_TMFC(_X) \
464 elog(DEBUG_elog_output, "TMFC:\nmode %d\nhh %d\npm %d\nmi %d\nss %d\nssss %d\nd %d\ndd %d\nddd %d\nmm %d\nms: %d\nyear %d\nbc %d\nww %d\nw %d\ncc %d\nj %d\nus: %d\nyysz: %d\nclock: %d", \
465 (_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
466 (_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
467 (_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
468 (_X)->yysz, (_X)->clock_12_hour)
469#define DEBUG_TM(_X) \
470 elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
471 (_X)->tm_sec, (_X)->tm_year,\
472 (_X)->tm_min, (_X)->tm_wday, (_X)->tm_hour, (_X)->tm_yday,\
473 (_X)->tm_mday, (_X)->tm_isdst, (_X)->tm_mon)
475#define DEBUG_TMFC(_X)
506#define tmtcTm(_X) (&(_X)->tm)
507#define tmtcTzn(_X) ((_X)->tzn)
508#define tmtcFsec(_X) ((_X)->fsec)
511#define COPY_tm(_DST, _SRC) \
513 (_DST)->tm_sec = (_SRC)->tm_sec; \
514 (_DST)->tm_min = (_SRC)->tm_min; \
515 (_DST)->tm_hour = (_SRC)->tm_hour; \
516 (_DST)->tm_mday = (_SRC)->tm_mday; \
517 (_DST)->tm_mon = (_SRC)->tm_mon; \
518 (_DST)->tm_year = (_SRC)->tm_year; \
519 (_DST)->tm_wday = (_SRC)->tm_wday; \
520 (_DST)->tm_yday = (_SRC)->tm_yday; \
521 (_DST)->tm_gmtoff = (_SRC)->tm_gmtoff; \
527 memset(_X, 0, sizeof(*(_X))); \
528 (_X)->tm_mday = (_X)->tm_mon = 1; \
531#define ZERO_tmtc(_X) \
533 ZERO_tm( tmtcTm(_X) ); \
535 tmtcTzn(_X) = NULL; \
542#define INVALID_FOR_INTERVAL \
546 (errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
547 errmsg("invalid format specification for an interval value"), \
548 errhint("Intervals are not tied to specific calendar dates."))); \
558#define DCH_SUFFIX_FM 0x01
559#define DCH_SUFFIX_TH 0x02
560#define DCH_SUFFIX_th 0x04
561#define DCH_SUFFIX_SP 0x08
562#define DCH_SUFFIX_TM 0x10
607#define TM_SUFFIX_LEN 2
990 -1, -1, -1, -1, -1, -1, -1, -1,
991 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
992 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
993 -1, -1, -1, -1, -1,
DCH_A_D,
DCH_B_C,
DCH_CC,
DCH_DAY, -1,
994 DCH_FF1, -1,
DCH_HH24,
DCH_IDDD,
DCH_J, -1, -1,
DCH_MI, -1,
DCH_OF,
995 DCH_P_M,
DCH_Q,
DCH_RM,
DCH_SSSSS,
DCH_TZH,
DCH_US, -1,
DCH_WW, -1,
DCH_Y_YYY,
996 -1, -1, -1, -1, -1, -1, -1,
DCH_a_d,
DCH_b_c,
DCH_cc,
997 DCH_day, -1,
DCH_ff1, -1,
DCH_hh24,
DCH_iddd,
DCH_j, -1, -1,
DCH_mi,
998 -1,
DCH_of,
DCH_p_m,
DCH_q,
DCH_rm,
DCH_sssss,
DCH_tzh,
DCH_us, -1,
DCH_ww,
1013 -1, -1, -1, -1, -1, -1, -1, -1,
1014 -1, -1, -1, -1,
NUM_COMMA, -1,
NUM_DEC, -1,
NUM_0, -1,
1015 -1, -1, -1, -1, -1, -1, -1,
NUM_9, -1, -1,
1016 -1, -1, -1, -1, -1, -1,
NUM_B,
NUM_C,
NUM_D,
NUM_E,
1017 NUM_FM,
NUM_G, -1, -1, -1, -1,
NUM_L,
NUM_MI, -1, -1,
1018 NUM_PL, -1,
NUM_RN,
NUM_SG,
NUM_TH, -1,
NUM_V, -1, -1, -1,
1019 -1, -1, -1, -1, -1, -1, -1, -1,
NUM_b,
NUM_c,
1020 NUM_d,
NUM_e,
NUM_fm,
NUM_g, -1, -1, -1, -1,
NUM_l,
NUM_mi,
1021 -1, -1,
NUM_pl, -1,
NUM_rn,
NUM_sg,
NUM_th, -1,
NUM_v, -1,
1022 -1, -1, -1, -1, -1, -1
1060#define DCH_DATED 0x01
1061#define DCH_TIMED 0x02
1062#define DCH_ZONED 0x04
1069#define OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len)
1070#define AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s)))
1089#ifdef DEBUG_TO_FROM_CHAR
1090static void dump_index(
const KeyWord *k,
const int *
index);
1091static void dump_node(
FormatNode *node,
int max);
1110 const char *
const *array,
1125 char *number,
size_t input_len,
int to_char_out_pre_spaces,
1148 if ((poz =
index[*
str -
' ']) > -1)
1169 if (s->type !=
type)
1172 if (strncmp(
str, s->name, s->len) == 0)
1182 return (*
str > 0x20 && *
str < 0x7F &&
1183 !(*
str >=
'A' && *
str <=
'Z') &&
1184 !(*
str >=
'a' && *
str <=
'z') &&
1185 !(*
str >=
'0' && *
str <=
'9'));
1199 (
errcode(ERRCODE_SYNTAX_ERROR),
1200 errmsg(
"\"EEEE\" must be the last pattern used")));
1207 (
errcode(ERRCODE_SYNTAX_ERROR),
1208 errmsg(
"\"9\" must be ahead of \"PR\"")));
1223 (
errcode(ERRCODE_SYNTAX_ERROR),
1224 errmsg(
"\"0\" must be ahead of \"PR\"")));
1250 (
errcode(ERRCODE_SYNTAX_ERROR),
1251 errmsg(
"multiple decimal points")));
1254 (
errcode(ERRCODE_SYNTAX_ERROR),
1255 errmsg(
"cannot use \"V\" and decimal point together")));
1266 (
errcode(ERRCODE_SYNTAX_ERROR),
1267 errmsg(
"cannot use \"S\" twice")));
1270 (
errcode(ERRCODE_SYNTAX_ERROR),
1271 errmsg(
"cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together")));
1290 (
errcode(ERRCODE_SYNTAX_ERROR),
1291 errmsg(
"cannot use \"S\" and \"MI\" together")));
1300 (
errcode(ERRCODE_SYNTAX_ERROR),
1301 errmsg(
"cannot use \"S\" and \"PL\" together")));
1310 (
errcode(ERRCODE_SYNTAX_ERROR),
1311 errmsg(
"cannot use \"S\" and \"SG\" together")));
1319 (
errcode(ERRCODE_SYNTAX_ERROR),
1320 errmsg(
"cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together")));
1328 (
errcode(ERRCODE_SYNTAX_ERROR),
1329 errmsg(
"cannot use \"RN\" twice")));
1341 (
errcode(ERRCODE_SYNTAX_ERROR),
1342 errmsg(
"cannot use \"V\" and decimal point together")));
1349 (
errcode(ERRCODE_SYNTAX_ERROR),
1350 errmsg(
"cannot use \"EEEE\" twice")));
1355 (
errcode(ERRCODE_SYNTAX_ERROR),
1356 errmsg(
"\"EEEE\" is incompatible with other formats"),
1357 errdetail(
"\"EEEE\" may only be used together with digit and decimal point patterns.")));
1365 (
errcode(ERRCODE_SYNTAX_ERROR),
1366 errmsg(
"\"RN\" is incompatible with other formats"),
1367 errdetail(
"\"RN\" may only be used together with \"FM\".")));
1382#ifdef DEBUG_TO_FROM_CHAR
1383 elog(DEBUG_elog_output,
"to_char/number(): run parser");
1444 if (strchr(
"-./,':; ", *
str) == NULL)
1446 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
1447 errmsg(
"invalid datetime format separator: \"%s\"",
1462 else if (*
str ==
'"')
1476 if (*
str ==
'\\' && *(
str + 1))
1494 if (*
str ==
'\\' && *(
str + 1) ==
'"')
1500 else if (isspace((
unsigned char) *
str))
1522#ifdef DEBUG_TO_FROM_CHAR
1524#define DUMP_THth(_suf) (IS_SUFFIX_TH(_suf) ? "TH" : (IS_SUFFIX_th(_suf) ? "th" : " "))
1525#define DUMP_FM(_suf) (IS_SUFFIX_FM(_suf) ? "FM" : " ")
1533 elog(DEBUG_elog_output,
"to_from-char(): DUMP FORMAT");
1535 for (
a = 0, n = node;
a <= max; n++,
a++)
1538 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)",
1541 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_CHAR '%s'",
1545 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_END",
a);
1549 elog(DEBUG_elog_output,
"%d:\t unknown NODE!",
a);
1564 size_t len = strlen(num);
1569 last = num[
len - 1];
1570 if (!isdigit((
unsigned char) last))
1572 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1573 errmsg(
"\"%s\" is not a number", num)));
1579 if (
len > 1 && num[
len - 2] ==
'1')
1641 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1642 errmsg(
"could not determine which collation to use for %s function",
1644 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1656 const char *src = buff;
1657 size_t srclen = nbytes;
1663 dstsize = srclen + 1;
1666 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1667 if (needed + 1 > dstsize)
1670 dstsize = needed + 1;
1672 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1673 Assert(needed + 1 <= dstsize);
1676 Assert(dst[needed] ==
'\0');
1705 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1706 errmsg(
"could not determine which collation to use for %s function",
1708 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1720 const char *src = buff;
1721 size_t srclen = nbytes;
1727 dstsize = srclen + 1;
1730 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1731 if (needed + 1 > dstsize)
1734 dstsize = needed + 1;
1736 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1737 Assert(needed + 1 <= dstsize);
1740 Assert(dst[needed] ==
'\0');
1769 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1770 errmsg(
"could not determine which collation to use for %s function",
1772 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1784 const char *src = buff;
1785 size_t srclen = nbytes;
1791 dstsize = srclen + 1;
1794 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1795 if (needed + 1 > dstsize)
1798 dstsize = needed + 1;
1800 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1801 Assert(needed + 1 <= dstsize);
1804 Assert(dst[needed] ==
'\0');
1833 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1834 errmsg(
"could not determine which collation to use for %s function",
1836 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1841 (
errcode(ERRCODE_SYNTAX_ERROR),
1842 errmsg(
"Unicode case folding can only be performed if server encoding is UTF8")));
1853 const char *src = buff;
1854 size_t srclen = nbytes;
1860 dstsize = srclen + 1;
1863 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1864 if (needed + 1 > dstsize)
1867 dstsize = needed + 1;
1869 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1870 Assert(needed + 1 <= dstsize);
1873 Assert(dst[needed] ==
'\0');
1896 for (
char *p = result; *p; p++)
1918 for (
char *p = result; *p; p++)
1934 int wasalnum =
false;
1941 for (
char *p = result; *p; p++)
1950 wasalnum = ((
c >=
'A' &&
c <=
'Z') ||
1951 (
c >=
'a' &&
c <=
'z') ||
1952 (
c >=
'0' &&
c <=
'9'));
1998#define SKIP_THth(ptr, _suf) \
2000 if (IS_SUFFIX_THth(_suf)) \
2002 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2003 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2008#ifdef DEBUG_TO_FROM_CHAR
2019 elog(DEBUG_elog_output,
"TO-FROM_CHAR: Dump KeyWord Index:");
2031 elog(DEBUG_elog_output,
"\t(%d) %c %d",
i,
i + 32,
index[
i]);
2034 elog(DEBUG_elog_output,
"\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
2068 isdigit((
unsigned char) n->
character[0]))
2086 else if (year < 100)
2089 else if (year < 520)
2092 else if (year < 1000)
2104 while (*
str && isspace((
unsigned char) *
str))
2131 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2132 errmsg(
"invalid combination of date conventions"),
2133 errhint(
"Do not mix Gregorian and ISO week date conventions in a formatting template.")));
2153 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2154 errmsg(
"conflicting values for \"%s\" field in formatting string",
2156 errdetail(
"This value contradicts a previous setting for the same field type.")));
2188 const char *
init = *src;
2208 result = strtol(
init, &endptr, 10);
2221 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2222 errmsg(
"source string too short for \"%s\" formatting field",
2224 errdetail(
"Field requires %zu characters, but only %zu remain.",
2226 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2229 result = strtol(copy, &last, 10);
2232 if (used > 0 && used <
len)
2234 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2235 errmsg(
"invalid value \"%s\" for \"%s\"",
2237 errdetail(
"Field requires %zu characters, but only %zu could be parsed.",
2239 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2246 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2247 errmsg(
"invalid value \"%s\" for \"%s\"",
2249 errdetail(
"Value must be an integer.")));
2251 if (errno == ERANGE || result < INT_MIN || result > INT_MAX)
2253 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2254 errmsg(
"value for \"%s\" in source string is out of range",
2256 errdetail(
"Value must be in the range %d to %d.",
2257 INT_MIN, INT_MAX)));
2298 unsigned char firstc;
2309 for (
const char *
const *
a = array; *
a != NULL;
a++)
2316 for (
const char *p = *
a + 1, *n =
name + 1;; p++, n++)
2364 for (
char **
a = array; *
a != NULL;
a++)
2366 size_t element_len = strlen(*
a);
2368 if (strncmp(
name, *
a, element_len) == 0)
2383 for (
char **
a = array; *
a != NULL;
a++)
2385 char *upper_element;
2386 char *lower_element;
2391 lower_element =
str_tolower(upper_element, strlen(upper_element),
2393 pfree(upper_element);
2394 element_len = strlen(lower_element);
2397 if (strncmp(lower_name, lower_element, element_len) == 0)
2400 pfree(lower_element);
2404 pfree(lower_element);
2438 if (localized_array == NULL)
2451 for (
char *
c = copy; *
c;
c++)
2461 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2462 errmsg(
"invalid value \"%s\" for \"%s\"",
2464 errdetail(
"The given value did not match any of the allowed values for this field.")));
2557#define DCH_to_char_fsec(frac_fmt, frac_val) \
2558 sprintf(s, frac_fmt, (int) (frac_val)); \
2559 if (IS_SUFFIX_THth(n->suffix)) \
2560 str_numth(s, s, SUFFIX_TH_TYPE(n->suffix)); \
2583#undef DCH_to_char_fsec
2676 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2677 errmsg(
"localized string format value too long")));
2696 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2697 errmsg(
"localized string format value too long")));
2716 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2717 errmsg(
"localized string format value too long")));
2736 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2737 errmsg(
"localized string format value too long")));
2755 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2756 errmsg(
"localized string format value too long")));
2774 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2775 errmsg(
"localized string format value too long")));
2798 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2799 errmsg(
"localized string format value too long")));
2816 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2817 errmsg(
"localized string format value too long")));
2834 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2835 errmsg(
"localized string format value too long")));
2852 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2853 errmsg(
"localized string format value too long")));
2869 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2870 errmsg(
"localized string format value too long")));
2886 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2887 errmsg(
"localized string format value too long")));
2957 if (i <= 99 && i >= -99)
2998 is_interval)) % 1000);
3013 is_interval)) % 100);
3026 is_interval)) % 10);
3044 const char *
const *
months;
3145 while (*s !=
'\0' && isspace((
unsigned char) *s))
3166 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3167 errmsg(
"unmatched format separator \"%c\"",
3227 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3228 errmsg(
"unmatched format character \"%s\"",
3298 out->
ms *=
len == 1 ? 100 :
3314 out->
ff, n, escontext);
3318 out->
us *=
len == 1 ? 100000 :
3349 else if (isalpha((
unsigned char) *s))
3358 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3360 errdetail(
"Time zone abbreviation is not recognized.")));
3368 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3370 out->
tzsign = *s ==
'-' ? -1 : +1;
3375 if (extra_skip > 0 && *(s - 1) ==
'-')
3399 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3401 out->
tzsign = *s ==
'-' ? -1 : +1;
3406 if (extra_skip > 0 && *(s - 1) ==
'-')
3557 matched = sscanf(s,
"%d,%03d%n", &millennia, &years, &nch);
3560 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3561 errmsg(
"invalid value \"%s\" for \"%s\"", s,
"Y,YYY")));
3567 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3568 errmsg(
"value for \"%s\" in source string is out of range",
"Y,YYY")));
3640 while (*s !=
'\0' && isspace((
unsigned char) *s))
3656 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3657 errmsg(
"input string is too short for datetime format")));
3659 while (*s !=
'\0' && isspace((
unsigned char) *s))
3664 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3665 errmsg(
"trailing characters remain in input string after datetime format")));
3801#ifdef DEBUG_TO_FROM_CHAR
3818#ifdef DEBUG_TO_FROM_CHAR
3819 elog(DEBUG_elog_output,
"OLD: '%s' AGE: %d", old->
str, old->
age);
3829#ifdef DEBUG_TO_FROM_CHAR
3908 fmt_len = strlen(fmt_str);
3981 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3982 errmsg(
"timestamp out of range")));
3986 tt.
tm_wday = (thisdate + 1) % 7;
4017 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4018 errmsg(
"timestamp out of range")));
4022 tt.
tm_wday = (thisdate + 1) % 7;
4092 &
tm, &fsec, &ftz, &fprec, NULL, NULL);
4102 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4103 errmsg(
"timestamp out of range")));
4128 &
tm, &fsec, &ftz, NULL, NULL, NULL);
4133 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4141 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4164 Oid *typid,
int32 *typmod,
int *tz,
4174 &
tm, &fsec, &ftz, &fprec, &flags, escontext))
4177 *typmod = fprec ? fprec : -1;
4201 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4202 errmsg(
"missing time zone in input string for type timestamptz")));
4207 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4208 errmsg(
"timestamptz out of range")));
4212 *typid = TIMESTAMPTZOID;
4221 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4222 errmsg(
"timestamp out of range")));
4226 *typid = TIMESTAMPOID;
4235 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4236 errmsg(
"datetime format is zoned but not timed")));
4245 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4254 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4282 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4283 errmsg(
"missing time zone in input string for type timetz")));
4288 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4289 errmsg(
"timetz out of range")));
4302 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4303 errmsg(
"time out of range")));
4314 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4315 errmsg(
"datetime format is not dated and not timed")));
4327 size_t fmt_len = strlen(fmt_str);
4396 bool incache =
false;
4442#ifdef DEBUG_TO_FROM_CHAR
4490 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4492 errhint(
"Use the 24-hour clock, or give an hour between 1 and 12.")));
4510 if (tmfc.
cc && tmfc.
yysz <= 2)
4627 date_str,
"timestamp", escontext);
4641 date_str,
"timestamp", escontext);
4668 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4669 errmsg(
"cannot calculate day of year without year information")));
4687 static const int ysum[2][13] = {
4688 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
4689 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}};
4695 if (tmfc.
ddd <=
y[
i])
4717 date_str,
"timestamp", escontext);
4740 date_str,
"timestamp", escontext);
4752 date_str,
"timestamp", escontext);
4768 date_str,
"timestamp", escontext);
4782 if (tmfc.
tzp == NULL)
4824 memset(
str,
c, max);
4856#ifdef DEBUG_TO_FROM_CHAR
4873#ifdef DEBUG_TO_FROM_CHAR
4874 elog(DEBUG_elog_output,
"OLD: \"%s\" AGE: %d", old->
str, old->
age);
4884#ifdef DEBUG_TO_FROM_CHAR
4935 memset(&ent->
Num, 0,
sizeof ent->
Num);
4966 memset(Num, 0,
sizeof *Num);
4978 *shouldFree =
false;
4996#ifdef DEBUG_TO_FROM_CHAR
5027 if (number > 3999 || number < 1)
5034 len =
snprintf(numstr,
sizeof(numstr),
"%d", number);
5037 for (
char *p = numstr; *p !=
'\0'; p++, --
len)
5039 num = *p - (
'0' + 1);
5047 strcat(result,
"M");
5050 strcat(result,
rm100[num]);
5053 strcat(result,
rm10[num]);
5056 strcat(result,
rm1[num]);
5077 int repeatCount = 1;
5081 bool subtractionEncountered =
false;
5082 int lastSubtractedValue = 0;
5104 romanChars[
len] = currChar;
5105 romanValues[
len] = currValue;
5113 for (
size_t i = 0;
i <
len;
i++)
5115 char currChar = romanChars[
i];
5116 int currValue = romanValues[
i];
5122 if (subtractionEncountered && currValue >= lastSubtractedValue)
5129 if ((vCount && currValue >=
ROMAN_VAL(
'V')) ||
5130 (lCount && currValue >=
ROMAN_VAL(
'L')) ||
5131 (dCount && currValue >=
ROMAN_VAL(
'D')))
5133 if (currChar ==
'V')
5135 else if (currChar ==
'L')
5137 else if (currChar ==
'D')
5143 char nextChar = romanChars[
i + 1];
5144 int nextValue = romanValues[
i + 1];
5151 if (currValue < nextValue)
5160 if (repeatCount > 1)
5168 if ((vCount && nextValue >=
ROMAN_VAL(
'V')) ||
5169 (lCount && nextValue >=
ROMAN_VAL(
'L')) ||
5170 (dCount && nextValue >=
ROMAN_VAL(
'D')))
5172 if (nextChar ==
'V')
5174 else if (nextChar ==
'L')
5176 else if (nextChar ==
'D')
5187 subtractionEncountered =
true;
5188 lastSubtractedValue = currValue;
5189 result += (nextValue - currValue);
5194 if (currChar == nextChar)
5197 if (repeatCount > 3)
5202 result += currValue;
5208 result += currValue;
5224 struct lconv *lconv;
5234 if (lconv->negative_sign && *lconv->negative_sign)
5239 if (lconv->positive_sign && *lconv->positive_sign)
5247 if (lconv->decimal_point && *lconv->decimal_point)
5248 Np->
decimal = lconv->decimal_point;
5263 if (lconv->thousands_sep && *lconv->thousands_sep)
5266 else if (strcmp(Np->
decimal,
",") != 0)
5274 if (lconv->currency_symbol && *lconv->currency_symbol)
5304 *p = strchr(num,
'.');
5306#ifdef DEBUG_TO_FROM_CHAR
5307 elog(DEBUG_elog_output,
"get_last_relevant_decnum()");
5330 bool isread =
false;
5332#ifdef DEBUG_TO_FROM_CHAR
5333 elog(DEBUG_elog_output,
" --- scan start --- id=%s",
5352#ifdef DEBUG_TO_FROM_CHAR
5353 elog(DEBUG_elog_output,
"Try read sign (%c), locale positive: %s, negative: %s",
5364#ifdef DEBUG_TO_FROM_CHAR
5365 elog(DEBUG_elog_output,
"Try read locale pre-sign (%c)", *Np->
inout_p);
5384#ifdef DEBUG_TO_FROM_CHAR
5385 elog(DEBUG_elog_output,
"Try read simple sign (%c)", *Np->
inout_p);
5408#ifdef DEBUG_TO_FROM_CHAR
5409 elog(DEBUG_elog_output,
"Scan for numbers (%c), current number: '%s'", *Np->
inout_p, Np->
number);
5415 if (isdigit((
unsigned char) *Np->
inout_p))
5430#ifdef DEBUG_TO_FROM_CHAR
5431 elog(DEBUG_elog_output,
"Read digit (%c)", *Np->
inout_p);
5443#ifdef DEBUG_TO_FROM_CHAR
5444 elog(DEBUG_elog_output,
"Try read decimal point (%c)",
5478 !isdigit((
unsigned char) *(Np->
inout_p + 1)))
5483#ifdef DEBUG_TO_FROM_CHAR
5484 elog(DEBUG_elog_output,
"Try read locale post-sign (%c)", *Np->
inout_p);
5515 else if (isread ==
false &&
IS_LSIGN(Np->
Num) ==
false &&
5518#ifdef DEBUG_TO_FROM_CHAR
5519 elog(DEBUG_elog_output,
"Try read simple post-sign (%c)", *Np->
inout_p);
5532#define IS_PREDEC_SPACE(_n) \
5533 (IS_ZERO((_n)->Num)==false && \
5534 (_n)->number == (_n)->number_p && \
5535 *(_n)->number == '0' && \
5536 (_n)->Num->post != 0)
5551#ifdef DEBUG_TO_FROM_CHAR
5557 elog(DEBUG_elog_output,
5558 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
5578 if (Np->
sign ==
'-')
5592 else if (Np->
sign ==
'+')
5601 else if (Np->
sign ==
'-')
5716 if (Np->
sign ==
'-')
5738 if (strchr(
"0123456789.,+-", *Np->
inout_p) != NULL)
5746 char *number,
size_t input_len,
int to_char_out_pre_spaces,
5752 const char *pattern;
5773 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5774 errmsg(
"\"EEEE\" not supported for input")));
5775 return strcpy(inout, number);
5795 if (Np->
sign !=
'-')
5798 Np->
Num->
flag &= ~NUM_F_BRACKET;
5834 size_t last_zero_pos;
5838 last_zero_pos = strlen(Np->
number) - 1;
5839 last_zero_pos =
Min(last_zero_pos,
5841 last_zero = Np->
number + last_zero_pos;
5854 *(Np->
number + 1) =
'\0';
5860#ifdef DEBUG_TO_FROM_CHAR
5861 elog(DEBUG_elog_output,
5862 "\n\tSIGN: '%c'\n\tNUM: '%s'\n\tPRE: %d\n\tPOST: %d\n\tNUM_COUNT: %d\n\tNUM_PRE: %d\n\tSIGN_WROTE: %s\n\tZERO: %s\n\tZERO_START: %d\n\tZERO_END: %d\n\tLAST_RELEVANT: %s\n\tBRACKET: %s\n\tPLUS: %s\n\tMINUS: %s\n\tFILLMODE: %s\n\tROMAN: %s\n\tEEEE: %s",
5970 pattern_len = strlen(pattern);
5981 memset(Np->
inout_p,
' ', pattern_len);
5982 Np->
inout_p += pattern_len - 1;
5988 Np->
inout_p += pattern_len - 1;
6006 strncmp(Np->
inout_p, pattern, pattern_len) == 0)
6007 Np->
inout_p += pattern_len - 1;
6018 Np->
inout_p += strlen(pattern) - 1;
6031 const char *number_p;
6038 strcpy(Np->
inout_p, number_p);
6048 if (roman_result < 0)
6050 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
6051 errmsg(
"invalid Roman numeral")));
6099 if (Np->
sign ==
'-')
6121 if (Np->
sign ==
'+')
6201#ifdef DEBUG_TO_FROM_CHAR
6202 elog(DEBUG_elog_output,
"TO_NUMBER (number): '%s'", Np->
number);
6212#define NUM_TOCHAR_prepare \
6214 int len = VARSIZE_ANY_EXHDR(fmt); \
6215 if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
6216 PG_RETURN_TEXT_P(cstring_to_text("")); \
6217 result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
6218 format = NUM_cache(len, &Num, fmt, &shouldFree); \
6224#define NUM_TOCHAR_finish \
6228 NUM_processor(format, &Num, VARDATA(result), numstr, 0, out_pre_spaces, sign, true, PG_GET_COLLATION()); \
6238 len = strlen(VARDATA(result)); \
6239 SET_VARSIZE(result, len + VARHDRSZ); \
6312 int out_pre_spaces = 0,
6345 if (strcmp(orgnum,
"NaN") == 0 ||
6346 strcmp(orgnum,
"Infinity") == 0 ||
6347 strcmp(orgnum,
"-Infinity") == 0)
6356 *(numstr + Num.
pre + 1) =
'.';
6358 else if (*orgnum !=
'-')
6360 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6362 strcpy(numstr + 1, orgnum);
6371 size_t numstr_pre_len;
6398 numstr = orgnum + 1;
6406 if ((p = strchr(numstr,
'.')))
6407 numstr_pre_len = p - numstr;
6409 numstr_pre_len = strlen(numstr);
6412 if (numstr_pre_len < Num.
pre)
6413 out_pre_spaces = Num.
pre - numstr_pre_len;
6415 else if (numstr_pre_len > Num.
pre)
6419 *(numstr + Num.
pre) =
'.';
6439 int out_pre_spaces = 0,
6468 size_t numstr_pre_len;
6490 numstr_pre_len = strlen(orgnum);
6495 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6496 strcpy(numstr, orgnum);
6497 *(numstr + numstr_pre_len) =
'.';
6498 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6499 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6505 if (numstr_pre_len < Num.
pre)
6506 out_pre_spaces = Num.
pre - numstr_pre_len;
6508 else if (numstr_pre_len > Num.
pre)
6512 *(numstr + Num.
pre) =
'.';
6532 int out_pre_spaces = 0,
6566 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6568 strcpy(numstr + 1, orgnum);
6577 size_t numstr_pre_len;
6581 double multi = pow((
double) 10, (
double) Num.
multi);
6601 numstr_pre_len = strlen(orgnum);
6606 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6607 strcpy(numstr, orgnum);
6608 *(numstr + numstr_pre_len) =
'.';
6609 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6610 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6616 if (numstr_pre_len < Num.
pre)
6617 out_pre_spaces = Num.
pre - numstr_pre_len;
6619 else if (numstr_pre_len > Num.
pre)
6623 *(numstr + Num.
pre) =
'.';
6643 int out_pre_spaces = 0,
6674 *(numstr + Num.
pre + 1) =
'.';
6691 size_t numstr_pre_len;
6695 float multi = pow((
double) 10, (
double) Num.
multi);
6702 numstr_pre_len = strlen(orgnum);
6705 if (numstr_pre_len >= FLT_DIG)
6707 else if (numstr_pre_len + Num.
post > FLT_DIG)
6708 Num.
post = FLT_DIG - numstr_pre_len;
6714 numstr = orgnum + 1;
6722 if ((p = strchr(numstr,
'.')))
6723 numstr_pre_len = p - numstr;
6725 numstr_pre_len = strlen(numstr);
6728 if (numstr_pre_len < Num.
pre)
6729 out_pre_spaces = Num.
pre - numstr_pre_len;
6731 else if (numstr_pre_len > Num.
pre)
6735 *(numstr + Num.
pre) =
'.';
6755 int out_pre_spaces = 0,
6786 *(numstr + Num.
pre + 1) =
'.';
6803 size_t numstr_pre_len;
6807 double multi = pow((
double) 10, (
double) Num.
multi);
6814 numstr_pre_len = strlen(orgnum);
6817 if (numstr_pre_len >= DBL_DIG)
6819 else if (numstr_pre_len + Num.
post > DBL_DIG)
6820 Num.
post = DBL_DIG - numstr_pre_len;
6826 numstr = orgnum + 1;
6834 if ((p = strchr(numstr,
'.')))
6835 numstr_pre_len = p - numstr;
6837 numstr_pre_len = strlen(numstr);
6840 if (numstr_pre_len < Num.
pre)
6841 out_pre_spaces = Num.
pre - numstr_pre_len;
6843 else if (numstr_pre_len > Num.
pre)
6847 *(numstr + Num.
pre) =
'.';
int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
void DateTimeParseError(int dterr, DateTimeErrorExtra *extra, const char *str, const char *datatype, Node *escontext)
int ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc, struct pg_tm *tm)
void j2date(int jd, int *year, int *month, int *day)
const char *const months[]
int date2j(int year, int month, int day)
int DecodeTimezoneAbbrevPrefix(const char *str, int *offset, pg_tz **tz)
int DetermineTimeZoneAbbrevOffset(struct pg_tm *tm, const char *abbr, pg_tz *tzp)
char * numeric_out_sci(Numeric num, int scale)
Datum numeric_round(PG_FUNCTION_ARGS)
Numeric int64_to_numeric(int64 val)
int32 numeric_int4_safe(Numeric num, Node *escontext)
Datum numeric_power(PG_FUNCTION_ARGS)
Datum numeric_out(PG_FUNCTION_ARGS)
Datum numeric_in(PG_FUNCTION_ARGS)
Datum numeric_mul(PG_FUNCTION_ARGS)
void isoweek2date(int woy, int *year, int *mon, int *mday)
int isoweek2j(int year, int week)
int date2isoweek(int year, int mon, int mday)
bool AdjustTimestampForTypmod(Timestamp *time, int32 typmod, Node *escontext)
int date2isoyearday(int year, int mon, int mday)
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
void isoweekdate2date(int isoweek, int wday, int *year, int *mon, int *mday)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
void interval2itm(Interval span, struct pg_itm *itm)
int date2isoyear(int year, int mon, int mday)
#define FLOAT4_FITS_IN_INT32(num)
#define FLOAT8_FITS_IN_INT32(num)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
#define INTERVAL_NOT_FINITE(i)
#define IS_VALID_JULIAN(y, m, d)
#define TIMESTAMP_NOT_FINITE(j)
#define POSTGRES_EPOCH_JDATE
int tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result)
int tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result)
void AdjustTimeForTypmod(TimeADT *time, int32 typmod)
static Datum DateADTGetDatum(DateADT X)
#define PG_RETURN_DATEADT(x)
static Datum TimeTzADTPGetDatum(const TimeTzADT *X)
static Datum TimeADTGetDatum(TimeADT X)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define errsave(context,...)
#define ereport(elevel,...)
#define PG_GETARG_TEXT_PP(n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_FLOAT8(n)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_INT64(n)
#define PG_RETURN_TEXT_P(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_FLOAT4(n)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
#define PG_GET_COLLATION()
Assert(PointerIsAligned(start, uint64))
#define DTERR_TZDISP_OVERFLOW
#define DTERR_FIELD_OVERFLOW
Datum int8out(PG_FUNCTION_ARGS)
Datum int8mul(PG_FUNCTION_ARGS)
Datum dtoi8(PG_FUNCTION_ARGS)
Datum int4out(PG_FUNCTION_ARGS)
static bool pg_mul_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_sub_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
if(TABLE==NULL||TABLE_index==NULL)
int GetDatabaseEncoding(void)
int pg_mbstrlen(const char *mbstr)
int pg_mblen(const char *mbstr)
void * MemoryContextAllocZero(MemoryContext context, Size size)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
MemoryContext TopMemoryContext
char * pnstrdup(const char *in, Size len)
#define SOFT_ERROR_OCCURRED(escontext)
static Numeric DatumGetNumeric(Datum X)
#define PG_GETARG_NUMERIC(n)
static Datum NumericGetDatum(Numeric X)
static PgChecksumMode mode
void cache_locale_time(void)
char * localized_full_months[12+1]
pg_locale_t pg_newlocale_from_collation(Oid collid)
size_t pg_strfold(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t pg_strlower(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
struct lconv * PGLC_localeconv(void)
size_t pg_strtitle(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
char * localized_abbrev_months[12+1]
char * localized_full_days[7+1]
size_t pg_strupper(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
char * localized_abbrev_days[7+1]
#define MAX_MULTIBYTE_CHAR_LEN
PGDLLIMPORT pg_tz * session_timezone
static unsigned char pg_ascii_tolower(unsigned char ch)
static unsigned char pg_ascii_toupper(unsigned char ch)
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum Int64GetDatum(int64 X)
static int64 DatumGetInt64(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Datum Float8GetDatum(float8 X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
char * psprintf(const char *fmt,...)
bool scanner_isspace(char ch)
FormatNode format[DCH_CACHE_SIZE+1]
char str[DCH_CACHE_SIZE+1]
FromCharDateMode date_mode
char str[NUM_CACHE_SIZE+1]
FormatNode format[NUM_CACHE_SIZE+1]
static Datum TimestampTzGetDatum(TimestampTz X)
static Datum TimestampGetDatum(Timestamp X)
#define PG_GETARG_TIMESTAMP(n)
#define PG_RETURN_TIMESTAMP(x)
#define PG_GETARG_INTERVAL_P(n)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)