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')
1651 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1652 errmsg(
"could not determine which collation to use for %s function",
1654 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1666 const char *src = buff;
1667 size_t srclen = nbytes;
1673 dstsize = srclen + 1;
1676 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1677 if (needed + 1 > dstsize)
1680 dstsize = needed + 1;
1682 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1683 Assert(needed + 1 <= dstsize);
1686 Assert(dst[needed] ==
'\0');
1715 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1716 errmsg(
"could not determine which collation to use for %s function",
1718 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1730 const char *src = buff;
1731 size_t srclen = nbytes;
1737 dstsize = srclen + 1;
1740 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1741 if (needed + 1 > dstsize)
1744 dstsize = needed + 1;
1746 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1747 Assert(needed + 1 <= dstsize);
1750 Assert(dst[needed] ==
'\0');
1779 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1780 errmsg(
"could not determine which collation to use for %s function",
1782 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1794 const char *src = buff;
1795 size_t srclen = nbytes;
1801 dstsize = srclen + 1;
1804 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1805 if (needed + 1 > dstsize)
1808 dstsize = needed + 1;
1810 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1811 Assert(needed + 1 <= dstsize);
1814 Assert(dst[needed] ==
'\0');
1843 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1844 errmsg(
"could not determine which collation to use for %s function",
1846 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1851 (
errcode(ERRCODE_SYNTAX_ERROR),
1852 errmsg(
"Unicode case folding can only be performed if server encoding is UTF8")));
1863 const char *src = buff;
1864 size_t srclen = nbytes;
1870 dstsize = srclen + 1;
1873 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1874 if (needed + 1 > dstsize)
1877 dstsize = needed + 1;
1879 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1880 Assert(needed + 1 <= dstsize);
1883 Assert(dst[needed] ==
'\0');
1906 for (
char *p = result; *p; p++)
1928 for (
char *p = result; *p; p++)
1944 int wasalnum =
false;
1951 for (
char *p = result; *p; p++)
1960 wasalnum = ((
c >=
'A' &&
c <=
'Z') ||
1961 (
c >=
'a' &&
c <=
'z') ||
1962 (
c >=
'0' &&
c <=
'9'));
2008#define SKIP_THth(ptr, _suf) \
2010 if (IS_SUFFIX_THth(_suf)) \
2012 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2013 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2018#ifdef DEBUG_TO_FROM_CHAR
2029 elog(DEBUG_elog_output,
"TO-FROM_CHAR: Dump KeyWord Index:");
2041 elog(DEBUG_elog_output,
"\t(%d) %c %d",
i,
i + 32,
index[
i]);
2044 elog(DEBUG_elog_output,
"\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
2078 isdigit((
unsigned char) n->
character[0]))
2096 else if (year < 100)
2099 else if (year < 520)
2102 else if (year < 1000)
2114 while (*
str && isspace((
unsigned char) *
str))
2141 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2142 errmsg(
"invalid combination of date conventions"),
2143 errhint(
"Do not mix Gregorian and ISO week date conventions in a formatting template.")));
2163 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2164 errmsg(
"conflicting values for \"%s\" field in formatting string",
2166 errdetail(
"This value contradicts a previous setting for the same field type.")));
2198 const char *
init = *src;
2218 result = strtol(
init, &endptr, 10);
2231 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2232 errmsg(
"source string too short for \"%s\" formatting field",
2234 errdetail(
"Field requires %zu characters, but only %zu remain.",
2236 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2239 result = strtol(copy, &last, 10);
2242 if (used > 0 && used <
len)
2244 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2245 errmsg(
"invalid value \"%s\" for \"%s\"",
2247 errdetail(
"Field requires %zu characters, but only %zu could be parsed.",
2249 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2256 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2257 errmsg(
"invalid value \"%s\" for \"%s\"",
2259 errdetail(
"Value must be an integer.")));
2261 if (errno == ERANGE || result < INT_MIN || result > INT_MAX)
2263 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2264 errmsg(
"value for \"%s\" in source string is out of range",
2266 errdetail(
"Value must be in the range %d to %d.",
2267 INT_MIN, INT_MAX)));
2308 unsigned char firstc;
2319 for (
const char *
const *
a = array; *
a != NULL;
a++)
2326 for (
const char *p = *
a + 1, *n =
name + 1;; p++, n++)
2374 for (
char **
a = array; *
a != NULL;
a++)
2376 size_t element_len = strlen(*
a);
2378 if (strncmp(
name, *
a, element_len) == 0)
2393 for (
char **
a = array; *
a != NULL;
a++)
2395 char *upper_element;
2396 char *lower_element;
2401 lower_element =
str_tolower(upper_element, strlen(upper_element),
2403 pfree(upper_element);
2404 element_len = strlen(lower_element);
2407 if (strncmp(lower_name, lower_element, element_len) == 0)
2410 pfree(lower_element);
2414 pfree(lower_element);
2448 if (localized_array == NULL)
2461 for (
char *
c = copy; *
c;
c++)
2471 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2472 errmsg(
"invalid value \"%s\" for \"%s\"",
2474 errdetail(
"The given value did not match any of the allowed values for this field.")));
2567#define DCH_to_char_fsec(frac_fmt, frac_val) \
2568 sprintf(s, frac_fmt, (int) (frac_val)); \
2569 if (IS_SUFFIX_THth(n->suffix)) \
2570 str_numth(s, s, SUFFIX_TH_TYPE(n->suffix)); \
2593#undef DCH_to_char_fsec
2686 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2687 errmsg(
"localized string format value too long")));
2706 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2707 errmsg(
"localized string format value too long")));
2726 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2727 errmsg(
"localized string format value too long")));
2746 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2747 errmsg(
"localized string format value too long")));
2765 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2766 errmsg(
"localized string format value too long")));
2784 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2785 errmsg(
"localized string format value too long")));
2808 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2809 errmsg(
"localized string format value too long")));
2826 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2827 errmsg(
"localized string format value too long")));
2844 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2845 errmsg(
"localized string format value too long")));
2862 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2863 errmsg(
"localized string format value too long")));
2879 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2880 errmsg(
"localized string format value too long")));
2896 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2897 errmsg(
"localized string format value too long")));
2967 if (i <= 99 && i >= -99)
3008 is_interval)) % 1000);
3023 is_interval)) % 100);
3036 is_interval)) % 10);
3054 const char *
const *
months;
3155 while (*s !=
'\0' && isspace((
unsigned char) *s))
3176 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3177 errmsg(
"unmatched format separator \"%c\"",
3237 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3238 errmsg(
"unmatched format character \"%s\"",
3308 out->
ms *=
len == 1 ? 100 :
3324 out->
ff, n, escontext);
3328 out->
us *=
len == 1 ? 100000 :
3359 else if (isalpha((
unsigned char) *s))
3368 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3370 errdetail(
"Time zone abbreviation is not recognized.")));
3378 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3380 out->
tzsign = *s ==
'-' ? -1 : +1;
3385 if (extra_skip > 0 && *(s - 1) ==
'-')
3409 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3411 out->
tzsign = *s ==
'-' ? -1 : +1;
3416 if (extra_skip > 0 && *(s - 1) ==
'-')
3567 matched = sscanf(s,
"%d,%03d%n", &millennia, &years, &nch);
3570 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3571 errmsg(
"invalid value \"%s\" for \"%s\"", s,
"Y,YYY")));
3577 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3578 errmsg(
"value for \"%s\" in source string is out of range",
"Y,YYY")));
3650 while (*s !=
'\0' && isspace((
unsigned char) *s))
3666 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3667 errmsg(
"input string is too short for datetime format")));
3669 while (*s !=
'\0' && isspace((
unsigned char) *s))
3674 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3675 errmsg(
"trailing characters remain in input string after datetime format")));
3811#ifdef DEBUG_TO_FROM_CHAR
3828#ifdef DEBUG_TO_FROM_CHAR
3829 elog(DEBUG_elog_output,
"OLD: '%s' AGE: %d", old->
str, old->
age);
3839#ifdef DEBUG_TO_FROM_CHAR
3918 fmt_len = strlen(fmt_str);
3991 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3992 errmsg(
"timestamp out of range")));
3996 tt.
tm_wday = (thisdate + 1) % 7;
4027 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4028 errmsg(
"timestamp out of range")));
4032 tt.
tm_wday = (thisdate + 1) % 7;
4102 &
tm, &fsec, &ftz, &fprec, NULL, NULL);
4112 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4113 errmsg(
"timestamp out of range")));
4138 &
tm, &fsec, &ftz, NULL, NULL, NULL);
4143 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4151 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4174 Oid *typid,
int32 *typmod,
int *tz,
4184 &
tm, &fsec, &ftz, &fprec, &flags, escontext))
4187 *typmod = fprec ? fprec : -1;
4211 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4212 errmsg(
"missing time zone in input string for type timestamptz")));
4217 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4218 errmsg(
"timestamptz out of range")));
4222 *typid = TIMESTAMPTZOID;
4231 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4232 errmsg(
"timestamp out of range")));
4236 *typid = TIMESTAMPOID;
4245 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4246 errmsg(
"datetime format is zoned but not timed")));
4255 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4264 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4292 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4293 errmsg(
"missing time zone in input string for type timetz")));
4298 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4299 errmsg(
"timetz out of range")));
4312 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4313 errmsg(
"time out of range")));
4324 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4325 errmsg(
"datetime format is not dated and not timed")));
4337 size_t fmt_len = strlen(fmt_str);
4406 bool incache =
false;
4452#ifdef DEBUG_TO_FROM_CHAR
4500 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4502 errhint(
"Use the 24-hour clock, or give an hour between 1 and 12.")));
4520 if (tmfc.
cc && tmfc.
yysz <= 2)
4637 date_str,
"timestamp", escontext);
4651 date_str,
"timestamp", escontext);
4678 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4679 errmsg(
"cannot calculate day of year without year information")));
4697 static const int ysum[2][13] = {
4698 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
4699 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}};
4705 if (tmfc.
ddd <=
y[
i])
4727 date_str,
"timestamp", escontext);
4750 date_str,
"timestamp", escontext);
4762 date_str,
"timestamp", escontext);
4778 date_str,
"timestamp", escontext);
4792 if (tmfc.
tzp == NULL)
4834 memset(
str,
c, max);
4866#ifdef DEBUG_TO_FROM_CHAR
4883#ifdef DEBUG_TO_FROM_CHAR
4884 elog(DEBUG_elog_output,
"OLD: \"%s\" AGE: %d", old->
str, old->
age);
4894#ifdef DEBUG_TO_FROM_CHAR
4945 memset(&ent->
Num, 0,
sizeof ent->
Num);
4976 memset(Num, 0,
sizeof *Num);
4988 *shouldFree =
false;
5006#ifdef DEBUG_TO_FROM_CHAR
5037 if (number > 3999 || number < 1)
5044 len =
snprintf(numstr,
sizeof(numstr),
"%d", number);
5047 for (
char *p = numstr; *p !=
'\0'; p++, --
len)
5049 num = *p - (
'0' + 1);
5057 strcat(result,
"M");
5060 strcat(result,
rm100[num]);
5063 strcat(result,
rm10[num]);
5066 strcat(result,
rm1[num]);
5087 int repeatCount = 1;
5091 bool subtractionEncountered =
false;
5092 int lastSubtractedValue = 0;
5114 romanChars[
len] = currChar;
5115 romanValues[
len] = currValue;
5123 for (
size_t i = 0;
i <
len;
i++)
5125 char currChar = romanChars[
i];
5126 int currValue = romanValues[
i];
5132 if (subtractionEncountered && currValue >= lastSubtractedValue)
5139 if ((vCount && currValue >=
ROMAN_VAL(
'V')) ||
5140 (lCount && currValue >=
ROMAN_VAL(
'L')) ||
5141 (dCount && currValue >=
ROMAN_VAL(
'D')))
5143 if (currChar ==
'V')
5145 else if (currChar ==
'L')
5147 else if (currChar ==
'D')
5153 char nextChar = romanChars[
i + 1];
5154 int nextValue = romanValues[
i + 1];
5161 if (currValue < nextValue)
5170 if (repeatCount > 1)
5178 if ((vCount && nextValue >=
ROMAN_VAL(
'V')) ||
5179 (lCount && nextValue >=
ROMAN_VAL(
'L')) ||
5180 (dCount && nextValue >=
ROMAN_VAL(
'D')))
5182 if (nextChar ==
'V')
5184 else if (nextChar ==
'L')
5186 else if (nextChar ==
'D')
5197 subtractionEncountered =
true;
5198 lastSubtractedValue = currValue;
5199 result += (nextValue - currValue);
5204 if (currChar == nextChar)
5207 if (repeatCount > 3)
5212 result += currValue;
5218 result += currValue;
5234 struct lconv *lconv;
5244 if (lconv->negative_sign && *lconv->negative_sign)
5249 if (lconv->positive_sign && *lconv->positive_sign)
5257 if (lconv->decimal_point && *lconv->decimal_point)
5258 Np->
decimal = lconv->decimal_point;
5273 if (lconv->thousands_sep && *lconv->thousands_sep)
5276 else if (strcmp(Np->
decimal,
",") != 0)
5284 if (lconv->currency_symbol && *lconv->currency_symbol)
5314 *p = strchr(num,
'.');
5316#ifdef DEBUG_TO_FROM_CHAR
5317 elog(DEBUG_elog_output,
"get_last_relevant_decnum()");
5340 bool isread =
false;
5342#ifdef DEBUG_TO_FROM_CHAR
5343 elog(DEBUG_elog_output,
" --- scan start --- id=%s",
5362#ifdef DEBUG_TO_FROM_CHAR
5363 elog(DEBUG_elog_output,
"Try read sign (%c), locale positive: %s, negative: %s",
5374#ifdef DEBUG_TO_FROM_CHAR
5375 elog(DEBUG_elog_output,
"Try read locale pre-sign (%c)", *Np->
inout_p);
5394#ifdef DEBUG_TO_FROM_CHAR
5395 elog(DEBUG_elog_output,
"Try read simple sign (%c)", *Np->
inout_p);
5418#ifdef DEBUG_TO_FROM_CHAR
5419 elog(DEBUG_elog_output,
"Scan for numbers (%c), current number: '%s'", *Np->
inout_p, Np->
number);
5425 if (isdigit((
unsigned char) *Np->
inout_p))
5440#ifdef DEBUG_TO_FROM_CHAR
5441 elog(DEBUG_elog_output,
"Read digit (%c)", *Np->
inout_p);
5453#ifdef DEBUG_TO_FROM_CHAR
5454 elog(DEBUG_elog_output,
"Try read decimal point (%c)",
5488 !isdigit((
unsigned char) *(Np->
inout_p + 1)))
5493#ifdef DEBUG_TO_FROM_CHAR
5494 elog(DEBUG_elog_output,
"Try read locale post-sign (%c)", *Np->
inout_p);
5525 else if (isread ==
false &&
IS_LSIGN(Np->
Num) ==
false &&
5528#ifdef DEBUG_TO_FROM_CHAR
5529 elog(DEBUG_elog_output,
"Try read simple post-sign (%c)", *Np->
inout_p);
5542#define IS_PREDEC_SPACE(_n) \
5543 (IS_ZERO((_n)->Num)==false && \
5544 (_n)->number == (_n)->number_p && \
5545 *(_n)->number == '0' && \
5546 (_n)->Num->post != 0)
5561#ifdef DEBUG_TO_FROM_CHAR
5567 elog(DEBUG_elog_output,
5568 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
5588 if (Np->
sign ==
'-')
5602 else if (Np->
sign ==
'+')
5611 else if (Np->
sign ==
'-')
5726 if (Np->
sign ==
'-')
5748 if (strchr(
"0123456789.,+-", *Np->
inout_p) != NULL)
5756 char *number,
size_t input_len,
int to_char_out_pre_spaces,
5762 const char *pattern;
5783 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5784 errmsg(
"\"EEEE\" not supported for input")));
5785 return strcpy(inout, number);
5805 if (Np->
sign !=
'-')
5808 Np->
Num->
flag &= ~NUM_F_BRACKET;
5844 size_t last_zero_pos;
5848 last_zero_pos = strlen(Np->
number) - 1;
5849 last_zero_pos =
Min(last_zero_pos,
5851 last_zero = Np->
number + last_zero_pos;
5864 *(Np->
number + 1) =
'\0';
5870#ifdef DEBUG_TO_FROM_CHAR
5871 elog(DEBUG_elog_output,
5872 "\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",
5980 pattern_len = strlen(pattern);
5991 memset(Np->
inout_p,
' ', pattern_len);
5992 Np->
inout_p += pattern_len - 1;
5998 Np->
inout_p += pattern_len - 1;
6016 strncmp(Np->
inout_p, pattern, pattern_len) == 0)
6017 Np->
inout_p += pattern_len - 1;
6028 Np->
inout_p += strlen(pattern) - 1;
6041 const char *number_p;
6048 strcpy(Np->
inout_p, number_p);
6058 if (roman_result < 0)
6060 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
6061 errmsg(
"invalid Roman numeral")));
6109 if (Np->
sign ==
'-')
6131 if (Np->
sign ==
'+')
6211#ifdef DEBUG_TO_FROM_CHAR
6212 elog(DEBUG_elog_output,
"TO_NUMBER (number): '%s'", Np->
number);
6222#define NUM_TOCHAR_prepare \
6224 int len = VARSIZE_ANY_EXHDR(fmt); \
6225 if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
6226 PG_RETURN_TEXT_P(cstring_to_text("")); \
6227 result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
6228 format = NUM_cache(len, &Num, fmt, &shouldFree); \
6234#define NUM_TOCHAR_finish \
6238 NUM_processor(format, &Num, VARDATA(result), numstr, 0, out_pre_spaces, sign, true, PG_GET_COLLATION()); \
6248 len = strlen(VARDATA(result)); \
6249 SET_VARSIZE(result, len + VARHDRSZ); \
6322 int out_pre_spaces = 0,
6355 if (strcmp(orgnum,
"NaN") == 0 ||
6356 strcmp(orgnum,
"Infinity") == 0 ||
6357 strcmp(orgnum,
"-Infinity") == 0)
6366 *(numstr + Num.
pre + 1) =
'.';
6368 else if (*orgnum !=
'-')
6370 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6372 strcpy(numstr + 1, orgnum);
6381 size_t numstr_pre_len;
6408 numstr = orgnum + 1;
6416 if ((p = strchr(numstr,
'.')))
6417 numstr_pre_len = p - numstr;
6419 numstr_pre_len = strlen(numstr);
6422 if (numstr_pre_len < Num.
pre)
6423 out_pre_spaces = Num.
pre - numstr_pre_len;
6425 else if (numstr_pre_len > Num.
pre)
6429 *(numstr + Num.
pre) =
'.';
6449 int out_pre_spaces = 0,
6478 size_t numstr_pre_len;
6500 numstr_pre_len = strlen(orgnum);
6505 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6506 strcpy(numstr, orgnum);
6507 *(numstr + numstr_pre_len) =
'.';
6508 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6509 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6515 if (numstr_pre_len < Num.
pre)
6516 out_pre_spaces = Num.
pre - numstr_pre_len;
6518 else if (numstr_pre_len > Num.
pre)
6522 *(numstr + Num.
pre) =
'.';
6542 int out_pre_spaces = 0,
6576 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6578 strcpy(numstr + 1, orgnum);
6587 size_t numstr_pre_len;
6591 double multi = pow((
double) 10, (
double) Num.
multi);
6611 numstr_pre_len = strlen(orgnum);
6616 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6617 strcpy(numstr, orgnum);
6618 *(numstr + numstr_pre_len) =
'.';
6619 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6620 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6626 if (numstr_pre_len < Num.
pre)
6627 out_pre_spaces = Num.
pre - numstr_pre_len;
6629 else if (numstr_pre_len > Num.
pre)
6633 *(numstr + Num.
pre) =
'.';
6653 int out_pre_spaces = 0,
6684 *(numstr + Num.
pre + 1) =
'.';
6701 size_t numstr_pre_len;
6705 float multi = pow((
double) 10, (
double) Num.
multi);
6712 numstr_pre_len = strlen(orgnum);
6715 if (numstr_pre_len >= FLT_DIG)
6717 else if (numstr_pre_len + Num.
post > FLT_DIG)
6718 Num.
post = FLT_DIG - numstr_pre_len;
6724 numstr = orgnum + 1;
6732 if ((p = strchr(numstr,
'.')))
6733 numstr_pre_len = p - numstr;
6735 numstr_pre_len = strlen(numstr);
6738 if (numstr_pre_len < Num.
pre)
6739 out_pre_spaces = Num.
pre - numstr_pre_len;
6741 else if (numstr_pre_len > Num.
pre)
6745 *(numstr + Num.
pre) =
'.';
6765 int out_pre_spaces = 0,
6796 *(numstr + Num.
pre + 1) =
'.';
6813 size_t numstr_pre_len;
6817 double multi = pow((
double) 10, (
double) Num.
multi);
6824 numstr_pre_len = strlen(orgnum);
6827 if (numstr_pre_len >= DBL_DIG)
6829 else if (numstr_pre_len + Num.
post > DBL_DIG)
6830 Num.
post = DBL_DIG - numstr_pre_len;
6836 numstr = orgnum + 1;
6844 if ((p = strchr(numstr,
'.')))
6845 numstr_pre_len = p - numstr;
6847 numstr_pre_len = strlen(numstr);
6850 if (numstr_pre_len < Num.
pre)
6851 out_pre_spaces = Num.
pre - numstr_pre_len;
6853 else if (numstr_pre_len > Num.
pre)
6857 *(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
unsigned char pg_ascii_tolower(unsigned char ch)
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)