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
1061#define DCH_DATED 0x01
1062#define DCH_TIMED 0x02
1063#define DCH_ZONED 0x04
1070#define OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len)
1071#define AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s)))
1090#ifdef DEBUG_TO_FROM_CHAR
1091static void dump_index(
const KeyWord *k,
const int *
index);
1092static void dump_node(
FormatNode *node,
int max);
1111 const char *
const *array,
1126 char *number,
size_t input_len,
int to_char_out_pre_spaces,
1149 if ((poz =
index[*
str -
' ']) > -1)
1170 if (s->type !=
type)
1173 if (strncmp(
str, s->name, s->len) == 0)
1183 return (*
str > 0x20 && *
str < 0x7F &&
1184 !(*
str >=
'A' && *
str <=
'Z') &&
1185 !(*
str >=
'a' && *
str <=
'z') &&
1186 !(*
str >=
'0' && *
str <=
'9'));
1200 (
errcode(ERRCODE_SYNTAX_ERROR),
1201 errmsg(
"\"EEEE\" must be the last pattern used")));
1208 (
errcode(ERRCODE_SYNTAX_ERROR),
1209 errmsg(
"\"9\" must be ahead of \"PR\"")));
1224 (
errcode(ERRCODE_SYNTAX_ERROR),
1225 errmsg(
"\"0\" must be ahead of \"PR\"")));
1251 (
errcode(ERRCODE_SYNTAX_ERROR),
1252 errmsg(
"multiple decimal points")));
1255 (
errcode(ERRCODE_SYNTAX_ERROR),
1256 errmsg(
"cannot use \"V\" and decimal point together")));
1267 (
errcode(ERRCODE_SYNTAX_ERROR),
1268 errmsg(
"cannot use \"S\" twice")));
1271 (
errcode(ERRCODE_SYNTAX_ERROR),
1272 errmsg(
"cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together")));
1291 (
errcode(ERRCODE_SYNTAX_ERROR),
1292 errmsg(
"cannot use \"S\" and \"MI\" together")));
1301 (
errcode(ERRCODE_SYNTAX_ERROR),
1302 errmsg(
"cannot use \"S\" and \"PL\" together")));
1311 (
errcode(ERRCODE_SYNTAX_ERROR),
1312 errmsg(
"cannot use \"S\" and \"SG\" together")));
1320 (
errcode(ERRCODE_SYNTAX_ERROR),
1321 errmsg(
"cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together")));
1329 (
errcode(ERRCODE_SYNTAX_ERROR),
1330 errmsg(
"cannot use \"RN\" twice")));
1342 (
errcode(ERRCODE_SYNTAX_ERROR),
1343 errmsg(
"cannot use \"V\" and decimal point together")));
1350 (
errcode(ERRCODE_SYNTAX_ERROR),
1351 errmsg(
"cannot use \"EEEE\" twice")));
1356 (
errcode(ERRCODE_SYNTAX_ERROR),
1357 errmsg(
"\"EEEE\" is incompatible with other formats"),
1358 errdetail(
"\"EEEE\" may only be used together with digit and decimal point patterns.")));
1366 (
errcode(ERRCODE_SYNTAX_ERROR),
1367 errmsg(
"\"RN\" is incompatible with other formats"),
1368 errdetail(
"\"RN\" may only be used together with \"FM\".")));
1383#ifdef DEBUG_TO_FROM_CHAR
1384 elog(DEBUG_elog_output,
"to_char/number(): run parser");
1445 if (strchr(
"-./,':; ", *
str) == NULL)
1447 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
1448 errmsg(
"invalid datetime format separator: \"%s\"",
1463 else if (*
str ==
'"')
1477 if (*
str ==
'\\' && *(
str + 1))
1495 if (*
str ==
'\\' && *(
str + 1) ==
'"')
1501 else if (isspace((
unsigned char) *
str))
1523#ifdef DEBUG_TO_FROM_CHAR
1525#define DUMP_THth(_suf) (IS_SUFFIX_TH(_suf) ? "TH" : (IS_SUFFIX_th(_suf) ? "th" : " "))
1526#define DUMP_FM(_suf) (IS_SUFFIX_FM(_suf) ? "FM" : " ")
1534 elog(DEBUG_elog_output,
"to_from-char(): DUMP FORMAT");
1536 for (
a = 0, n = node;
a <= max; n++,
a++)
1539 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)",
1542 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_CHAR '%s'",
1546 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_END",
a);
1550 elog(DEBUG_elog_output,
"%d:\t unknown NODE!",
a);
1565 size_t len = strlen(num);
1570 last = num[
len - 1];
1571 if (!isdigit((
unsigned char) last))
1573 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1574 errmsg(
"\"%s\" is not a number", num)));
1580 if (
len > 1 && num[
len - 2] ==
'1')
1642 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1643 errmsg(
"could not determine which collation to use for %s function",
1645 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1657 const char *src = buff;
1658 size_t srclen = nbytes;
1664 dstsize = srclen + 1;
1667 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1668 if (needed + 1 > dstsize)
1671 dstsize = needed + 1;
1673 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1674 Assert(needed + 1 <= dstsize);
1677 Assert(dst[needed] ==
'\0');
1706 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1707 errmsg(
"could not determine which collation to use for %s function",
1709 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1721 const char *src = buff;
1722 size_t srclen = nbytes;
1728 dstsize = srclen + 1;
1731 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1732 if (needed + 1 > dstsize)
1735 dstsize = needed + 1;
1737 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1738 Assert(needed + 1 <= dstsize);
1741 Assert(dst[needed] ==
'\0');
1770 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1771 errmsg(
"could not determine which collation to use for %s function",
1773 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1785 const char *src = buff;
1786 size_t srclen = nbytes;
1792 dstsize = srclen + 1;
1795 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1796 if (needed + 1 > dstsize)
1799 dstsize = needed + 1;
1801 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1802 Assert(needed + 1 <= dstsize);
1805 Assert(dst[needed] ==
'\0');
1834 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1835 errmsg(
"could not determine which collation to use for %s function",
1837 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1842 (
errcode(ERRCODE_SYNTAX_ERROR),
1843 errmsg(
"Unicode case folding can only be performed if server encoding is UTF8")));
1854 const char *src = buff;
1855 size_t srclen = nbytes;
1861 dstsize = srclen + 1;
1864 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1865 if (needed + 1 > dstsize)
1868 dstsize = needed + 1;
1870 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1871 Assert(needed + 1 <= dstsize);
1874 Assert(dst[needed] ==
'\0');
1897 for (
char *p = result; *p; p++)
1919 for (
char *p = result; *p; p++)
1935 int wasalnum =
false;
1942 for (
char *p = result; *p; p++)
1951 wasalnum = ((
c >=
'A' &&
c <=
'Z') ||
1952 (
c >=
'a' &&
c <=
'z') ||
1953 (
c >=
'0' &&
c <=
'9'));
1999#define SKIP_THth(ptr, _suf) \
2001 if (IS_SUFFIX_THth(_suf)) \
2003 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2004 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2009#ifdef DEBUG_TO_FROM_CHAR
2020 elog(DEBUG_elog_output,
"TO-FROM_CHAR: Dump KeyWord Index:");
2032 elog(DEBUG_elog_output,
"\t(%d) %c %d",
i,
i + 32,
index[
i]);
2035 elog(DEBUG_elog_output,
"\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
2069 isdigit((
unsigned char) n->
character[0]))
2087 else if (year < 100)
2090 else if (year < 520)
2093 else if (year < 1000)
2105 while (*
str && isspace((
unsigned char) *
str))
2132 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2133 errmsg(
"invalid combination of date conventions"),
2134 errhint(
"Do not mix Gregorian and ISO week date conventions in a formatting template.")));
2154 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2155 errmsg(
"conflicting values for \"%s\" field in formatting string",
2157 errdetail(
"This value contradicts a previous setting for the same field type.")));
2189 const char *
init = *src;
2209 result = strtol(
init, &endptr, 10);
2222 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2223 errmsg(
"source string too short for \"%s\" formatting field",
2225 errdetail(
"Field requires %zu characters, but only %zu remain.",
2227 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2230 result = strtol(copy, &last, 10);
2233 if (used > 0 && used <
len)
2235 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2236 errmsg(
"invalid value \"%s\" for \"%s\"",
2238 errdetail(
"Field requires %zu characters, but only %zu could be parsed.",
2240 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2247 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2248 errmsg(
"invalid value \"%s\" for \"%s\"",
2250 errdetail(
"Value must be an integer.")));
2252 if (errno == ERANGE || result < INT_MIN || result > INT_MAX)
2254 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2255 errmsg(
"value for \"%s\" in source string is out of range",
2257 errdetail(
"Value must be in the range %d to %d.",
2258 INT_MIN, INT_MAX)));
2299 unsigned char firstc;
2310 for (
const char *
const *
a = array; *
a != NULL;
a++)
2317 for (
const char *p = *
a + 1, *n =
name + 1;; p++, n++)
2365 for (
char **
a = array; *
a != NULL;
a++)
2367 size_t element_len = strlen(*
a);
2369 if (strncmp(
name, *
a, element_len) == 0)
2384 for (
char **
a = array; *
a != NULL;
a++)
2386 char *upper_element;
2387 char *lower_element;
2392 lower_element =
str_tolower(upper_element, strlen(upper_element),
2394 pfree(upper_element);
2395 element_len = strlen(lower_element);
2398 if (strncmp(lower_name, lower_element, element_len) == 0)
2401 pfree(lower_element);
2405 pfree(lower_element);
2439 if (localized_array == NULL)
2452 for (
char *
c = copy; *
c;
c++)
2462 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2463 errmsg(
"invalid value \"%s\" for \"%s\"",
2465 errdetail(
"The given value did not match any of the allowed values for this field.")));
2558#define DCH_to_char_fsec(frac_fmt, frac_val) \
2559 sprintf(s, frac_fmt, (int) (frac_val)); \
2560 if (IS_SUFFIX_THth(n->suffix)) \
2561 str_numth(s, s, SUFFIX_TH_TYPE(n->suffix)); \
2584#undef DCH_to_char_fsec
2677 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2678 errmsg(
"localized string format value too long")));
2697 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2698 errmsg(
"localized string format value too long")));
2717 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2718 errmsg(
"localized string format value too long")));
2737 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2738 errmsg(
"localized string format value too long")));
2756 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2757 errmsg(
"localized string format value too long")));
2775 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2776 errmsg(
"localized string format value too long")));
2799 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2800 errmsg(
"localized string format value too long")));
2817 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2818 errmsg(
"localized string format value too long")));
2835 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2836 errmsg(
"localized string format value too long")));
2853 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2854 errmsg(
"localized string format value too long")));
2870 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2871 errmsg(
"localized string format value too long")));
2887 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2888 errmsg(
"localized string format value too long")));
2958 if (i <= 99 && i >= -99)
2999 is_interval)) % 1000);
3014 is_interval)) % 100);
3027 is_interval)) % 10);
3045 const char *
const *
months;
3146 while (*s !=
'\0' && isspace((
unsigned char) *s))
3167 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3168 errmsg(
"unmatched format separator \"%c\"",
3228 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3229 errmsg(
"unmatched format character \"%s\"",
3299 out->
ms *=
len == 1 ? 100 :
3315 out->
ff, n, escontext);
3319 out->
us *=
len == 1 ? 100000 :
3350 else if (isalpha((
unsigned char) *s))
3359 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3361 errdetail(
"Time zone abbreviation is not recognized.")));
3369 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3371 out->
tzsign = *s ==
'-' ? -1 : +1;
3376 if (extra_skip > 0 && *(s - 1) ==
'-')
3400 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3402 out->
tzsign = *s ==
'-' ? -1 : +1;
3407 if (extra_skip > 0 && *(s - 1) ==
'-')
3558 matched = sscanf(s,
"%d,%03d%n", &millennia, &years, &nch);
3561 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3562 errmsg(
"invalid value \"%s\" for \"%s\"", s,
"Y,YYY")));
3568 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3569 errmsg(
"value for \"%s\" in source string is out of range",
"Y,YYY")));
3641 while (*s !=
'\0' && isspace((
unsigned char) *s))
3657 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3658 errmsg(
"input string is too short for datetime format")));
3660 while (*s !=
'\0' && isspace((
unsigned char) *s))
3665 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3666 errmsg(
"trailing characters remain in input string after datetime format")));
3802#ifdef DEBUG_TO_FROM_CHAR
3819#ifdef DEBUG_TO_FROM_CHAR
3820 elog(DEBUG_elog_output,
"OLD: '%s' AGE: %d", old->
str, old->
age);
3830#ifdef DEBUG_TO_FROM_CHAR
3909 fmt_len = strlen(fmt_str);
3982 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3983 errmsg(
"timestamp out of range")));
3987 tt.
tm_wday = (thisdate + 1) % 7;
4018 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4019 errmsg(
"timestamp out of range")));
4023 tt.
tm_wday = (thisdate + 1) % 7;
4093 &
tm, &fsec, &ftz, &fprec, NULL, NULL);
4103 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4104 errmsg(
"timestamp out of range")));
4129 &
tm, &fsec, &ftz, NULL, NULL, NULL);
4134 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4142 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4165 Oid *typid,
int32 *typmod,
int *tz,
4175 &
tm, &fsec, &ftz, &fprec, &flags, escontext))
4178 *typmod = fprec ? fprec : -1;
4202 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4203 errmsg(
"missing time zone in input string for type timestamptz")));
4208 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4209 errmsg(
"timestamptz out of range")));
4213 *typid = TIMESTAMPTZOID;
4222 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4223 errmsg(
"timestamp out of range")));
4227 *typid = TIMESTAMPOID;
4236 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4237 errmsg(
"datetime format is zoned but not timed")));
4246 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4255 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4283 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4284 errmsg(
"missing time zone in input string for type timetz")));
4289 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4290 errmsg(
"timetz out of range")));
4303 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4304 errmsg(
"time out of range")));
4315 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4316 errmsg(
"datetime format is not dated and not timed")));
4328 size_t fmt_len = strlen(fmt_str);
4397 bool incache =
false;
4443#ifdef DEBUG_TO_FROM_CHAR
4491 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4493 errhint(
"Use the 24-hour clock, or give an hour between 1 and 12.")));
4511 if (tmfc.
cc && tmfc.
yysz <= 2)
4628 date_str,
"timestamp", escontext);
4642 date_str,
"timestamp", escontext);
4669 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4670 errmsg(
"cannot calculate day of year without year information")));
4688 static const int ysum[2][13] = {
4689 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
4690 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}};
4696 if (tmfc.
ddd <=
y[
i])
4718 date_str,
"timestamp", escontext);
4741 date_str,
"timestamp", escontext);
4753 date_str,
"timestamp", escontext);
4769 date_str,
"timestamp", escontext);
4783 if (tmfc.
tzp == NULL)
4825 memset(
str,
c, max);
4857#ifdef DEBUG_TO_FROM_CHAR
4874#ifdef DEBUG_TO_FROM_CHAR
4875 elog(DEBUG_elog_output,
"OLD: \"%s\" AGE: %d", old->
str, old->
age);
4885#ifdef DEBUG_TO_FROM_CHAR
4936 memset(&ent->
Num, 0,
sizeof ent->
Num);
4967 memset(Num, 0,
sizeof *Num);
4979 *shouldFree =
false;
4997#ifdef DEBUG_TO_FROM_CHAR
5028 if (number > 3999 || number < 1)
5035 len =
snprintf(numstr,
sizeof(numstr),
"%d", number);
5038 for (
char *p = numstr; *p !=
'\0'; p++, --
len)
5040 num = *p - (
'0' + 1);
5048 strcat(result,
"M");
5051 strcat(result,
rm100[num]);
5054 strcat(result,
rm10[num]);
5057 strcat(result,
rm1[num]);
5078 int repeatCount = 1;
5082 bool subtractionEncountered =
false;
5083 int lastSubtractedValue = 0;
5105 romanChars[
len] = currChar;
5106 romanValues[
len] = currValue;
5114 for (
size_t i = 0;
i <
len;
i++)
5116 char currChar = romanChars[
i];
5117 int currValue = romanValues[
i];
5123 if (subtractionEncountered && currValue >= lastSubtractedValue)
5130 if ((vCount && currValue >=
ROMAN_VAL(
'V')) ||
5131 (lCount && currValue >=
ROMAN_VAL(
'L')) ||
5132 (dCount && currValue >=
ROMAN_VAL(
'D')))
5134 if (currChar ==
'V')
5136 else if (currChar ==
'L')
5138 else if (currChar ==
'D')
5144 char nextChar = romanChars[
i + 1];
5145 int nextValue = romanValues[
i + 1];
5152 if (currValue < nextValue)
5161 if (repeatCount > 1)
5169 if ((vCount && nextValue >=
ROMAN_VAL(
'V')) ||
5170 (lCount && nextValue >=
ROMAN_VAL(
'L')) ||
5171 (dCount && nextValue >=
ROMAN_VAL(
'D')))
5173 if (nextChar ==
'V')
5175 else if (nextChar ==
'L')
5177 else if (nextChar ==
'D')
5188 subtractionEncountered =
true;
5189 lastSubtractedValue = currValue;
5190 result += (nextValue - currValue);
5195 if (currChar == nextChar)
5198 if (repeatCount > 3)
5203 result += currValue;
5209 result += currValue;
5225 struct lconv *lconv;
5235 if (lconv->negative_sign && *lconv->negative_sign)
5240 if (lconv->positive_sign && *lconv->positive_sign)
5248 if (lconv->decimal_point && *lconv->decimal_point)
5249 Np->
decimal = lconv->decimal_point;
5264 if (lconv->thousands_sep && *lconv->thousands_sep)
5267 else if (strcmp(Np->
decimal,
",") != 0)
5275 if (lconv->currency_symbol && *lconv->currency_symbol)
5305 *p = strchr(num,
'.');
5307#ifdef DEBUG_TO_FROM_CHAR
5308 elog(DEBUG_elog_output,
"get_last_relevant_decnum()");
5331 bool isread =
false;
5333#ifdef DEBUG_TO_FROM_CHAR
5334 elog(DEBUG_elog_output,
" --- scan start --- id=%s",
5353#ifdef DEBUG_TO_FROM_CHAR
5354 elog(DEBUG_elog_output,
"Try read sign (%c), locale positive: %s, negative: %s",
5365#ifdef DEBUG_TO_FROM_CHAR
5366 elog(DEBUG_elog_output,
"Try read locale pre-sign (%c)", *Np->
inout_p);
5385#ifdef DEBUG_TO_FROM_CHAR
5386 elog(DEBUG_elog_output,
"Try read simple sign (%c)", *Np->
inout_p);
5409#ifdef DEBUG_TO_FROM_CHAR
5410 elog(DEBUG_elog_output,
"Scan for numbers (%c), current number: '%s'", *Np->
inout_p, Np->
number);
5416 if (isdigit((
unsigned char) *Np->
inout_p))
5431#ifdef DEBUG_TO_FROM_CHAR
5432 elog(DEBUG_elog_output,
"Read digit (%c)", *Np->
inout_p);
5444#ifdef DEBUG_TO_FROM_CHAR
5445 elog(DEBUG_elog_output,
"Try read decimal point (%c)",
5479 !isdigit((
unsigned char) *(Np->
inout_p + 1)))
5484#ifdef DEBUG_TO_FROM_CHAR
5485 elog(DEBUG_elog_output,
"Try read locale post-sign (%c)", *Np->
inout_p);
5516 else if (isread ==
false &&
IS_LSIGN(Np->
Num) ==
false &&
5519#ifdef DEBUG_TO_FROM_CHAR
5520 elog(DEBUG_elog_output,
"Try read simple post-sign (%c)", *Np->
inout_p);
5533#define IS_PREDEC_SPACE(_n) \
5534 (IS_ZERO((_n)->Num)==false && \
5535 (_n)->number == (_n)->number_p && \
5536 *(_n)->number == '0' && \
5537 (_n)->Num->post != 0)
5552#ifdef DEBUG_TO_FROM_CHAR
5558 elog(DEBUG_elog_output,
5559 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
5579 if (Np->
sign ==
'-')
5593 else if (Np->
sign ==
'+')
5602 else if (Np->
sign ==
'-')
5717 if (Np->
sign ==
'-')
5739 if (strchr(
"0123456789.,+-", *Np->
inout_p) != NULL)
5747 char *number,
size_t input_len,
int to_char_out_pre_spaces,
5753 const char *pattern;
5774 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5775 errmsg(
"\"EEEE\" not supported for input")));
5776 return strcpy(inout, number);
5796 if (Np->
sign !=
'-')
5799 Np->
Num->
flag &= ~NUM_F_BRACKET;
5835 size_t last_zero_pos;
5839 last_zero_pos = strlen(Np->
number) - 1;
5840 last_zero_pos =
Min(last_zero_pos,
5842 last_zero = Np->
number + last_zero_pos;
5855 *(Np->
number + 1) =
'\0';
5861#ifdef DEBUG_TO_FROM_CHAR
5862 elog(DEBUG_elog_output,
5863 "\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",
5971 pattern_len = strlen(pattern);
5982 memset(Np->
inout_p,
' ', pattern_len);
5983 Np->
inout_p += pattern_len - 1;
5989 Np->
inout_p += pattern_len - 1;
6007 strncmp(Np->
inout_p, pattern, pattern_len) == 0)
6008 Np->
inout_p += pattern_len - 1;
6019 Np->
inout_p += strlen(pattern) - 1;
6032 const char *number_p;
6039 strcpy(Np->
inout_p, number_p);
6049 if (roman_result < 0)
6051 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
6052 errmsg(
"invalid Roman numeral")));
6100 if (Np->
sign ==
'-')
6122 if (Np->
sign ==
'+')
6202#ifdef DEBUG_TO_FROM_CHAR
6203 elog(DEBUG_elog_output,
"TO_NUMBER (number): '%s'", Np->
number);
6213#define NUM_TOCHAR_prepare \
6215 int len = VARSIZE_ANY_EXHDR(fmt); \
6216 if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
6217 PG_RETURN_TEXT_P(cstring_to_text("")); \
6218 result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
6219 format = NUM_cache(len, &Num, fmt, &shouldFree); \
6225#define NUM_TOCHAR_finish \
6229 NUM_processor(format, &Num, VARDATA(result), numstr, 0, out_pre_spaces, sign, true, PG_GET_COLLATION()); \
6239 len = strlen(VARDATA(result)); \
6240 SET_VARSIZE(result, len + VARHDRSZ); \
6313 int out_pre_spaces = 0,
6346 if (strcmp(orgnum,
"NaN") == 0 ||
6347 strcmp(orgnum,
"Infinity") == 0 ||
6348 strcmp(orgnum,
"-Infinity") == 0)
6357 *(numstr + Num.
pre + 1) =
'.';
6359 else if (*orgnum !=
'-')
6361 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6363 strcpy(numstr + 1, orgnum);
6372 size_t numstr_pre_len;
6399 numstr = orgnum + 1;
6407 if ((p = strchr(numstr,
'.')))
6408 numstr_pre_len = p - numstr;
6410 numstr_pre_len = strlen(numstr);
6413 if (numstr_pre_len < Num.
pre)
6414 out_pre_spaces = Num.
pre - numstr_pre_len;
6416 else if (numstr_pre_len > Num.
pre)
6420 *(numstr + Num.
pre) =
'.';
6440 int out_pre_spaces = 0,
6469 size_t numstr_pre_len;
6491 numstr_pre_len = strlen(orgnum);
6496 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6497 strcpy(numstr, orgnum);
6498 *(numstr + numstr_pre_len) =
'.';
6499 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6500 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6506 if (numstr_pre_len < Num.
pre)
6507 out_pre_spaces = Num.
pre - numstr_pre_len;
6509 else if (numstr_pre_len > Num.
pre)
6513 *(numstr + Num.
pre) =
'.';
6533 int out_pre_spaces = 0,
6567 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6569 strcpy(numstr + 1, orgnum);
6578 size_t numstr_pre_len;
6582 double multi = pow((
double) 10, (
double) Num.
multi);
6602 numstr_pre_len = strlen(orgnum);
6607 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6608 strcpy(numstr, orgnum);
6609 *(numstr + numstr_pre_len) =
'.';
6610 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6611 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6617 if (numstr_pre_len < Num.
pre)
6618 out_pre_spaces = Num.
pre - numstr_pre_len;
6620 else if (numstr_pre_len > Num.
pre)
6624 *(numstr + Num.
pre) =
'.';
6644 int out_pre_spaces = 0,
6675 *(numstr + Num.
pre + 1) =
'.';
6692 size_t numstr_pre_len;
6696 float multi = pow((
double) 10, (
double) Num.
multi);
6703 numstr_pre_len = strlen(orgnum);
6706 if (numstr_pre_len >= FLT_DIG)
6708 else if (numstr_pre_len + Num.
post > FLT_DIG)
6709 Num.
post = FLT_DIG - numstr_pre_len;
6715 numstr = orgnum + 1;
6723 if ((p = strchr(numstr,
'.')))
6724 numstr_pre_len = p - numstr;
6726 numstr_pre_len = strlen(numstr);
6729 if (numstr_pre_len < Num.
pre)
6730 out_pre_spaces = Num.
pre - numstr_pre_len;
6732 else if (numstr_pre_len > Num.
pre)
6736 *(numstr + Num.
pre) =
'.';
6756 int out_pre_spaces = 0,
6787 *(numstr + Num.
pre + 1) =
'.';
6804 size_t numstr_pre_len;
6808 double multi = pow((
double) 10, (
double) Num.
multi);
6815 numstr_pre_len = strlen(orgnum);
6818 if (numstr_pre_len >= DBL_DIG)
6820 else if (numstr_pre_len + Num.
post > DBL_DIG)
6821 Num.
post = DBL_DIG - numstr_pre_len;
6827 numstr = orgnum + 1;
6835 if ((p = strchr(numstr,
'.')))
6836 numstr_pre_len = p - numstr;
6838 numstr_pre_len = strlen(numstr);
6841 if (numstr_pre_len < Num.
pre)
6842 out_pre_spaces = Num.
pre - numstr_pre_len;
6844 else if (numstr_pre_len > Num.
pre)
6848 *(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 palloc_object(type)
#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]
const char * L_thousands_sep
const char * L_negative_sign
const char * L_currency_symbol
const char * last_relevant
const char * L_positive_sign
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)