60#ifdef DEBUG_TO_FROM_CHAR
61#define DEBUG_elog_output DEBUG3
74#include <unicode/ustring.h>
107#define KeyWord_INDEX_SIZE ('~' - ' ')
108#define KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1)
114#define DCH_MAX_ITEM_SIZ 12
115#define NUM_MAX_ITEM_SIZ 8
161#define NODE_TYPE_END 1
162#define NODE_TYPE_ACTION 2
163#define NODE_TYPE_CHAR 3
164#define NODE_TYPE_SEPARATOR 4
165#define NODE_TYPE_SPACE 5
167#define SUFFTYPE_PREFIX 1
168#define SUFFTYPE_POSTFIX 2
170#define CLOCK_24_HOUR 0
171#define CLOCK_12_HOUR 1
179 "January",
"February",
"March",
"April",
"May",
"June",
"July",
180 "August",
"September",
"October",
"November",
"December", NULL
184 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat", NULL
194#define ADJUST_YEAR(year, is_interval) ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year)))
196#define A_D_STR "A.D."
197#define a_d_STR "a.d."
201#define B_C_STR "B.C."
202#define b_c_STR "b.c."
223#define A_M_STR "A.M."
224#define a_m_STR "a.m."
228#define P_M_STR "P.M."
229#define p_m_STR "p.m."
253{
"XII",
"XI",
"X",
"IX",
"VIII",
"VII",
"VI",
"V",
"IV",
"III",
"II",
"I", NULL};
256{
"xii",
"xi",
"x",
"ix",
"viii",
"vii",
"vi",
"v",
"iv",
"iii",
"ii",
"i", NULL};
262static const char *
const rm1[] = {
"I",
"II",
"III",
"IV",
"V",
"VI",
"VII",
"VIII",
"IX", NULL};
263static const char *
const rm10[] = {
"X",
"XX",
"XXX",
"XL",
"L",
"LX",
"LXX",
"LXXX",
"XC", NULL};
264static const char *
const rm100[] = {
"C",
"CC",
"CCC",
"CD",
"D",
"DC",
"DCC",
"DCCC",
"CM", NULL};
270#define IS_VALID_SUB_COMB(curr, next) \
271 (((curr) == 'I' && ((next) == 'V' || (next) == 'X')) || \
272 ((curr) == 'X' && ((next) == 'L' || (next) == 'C')) || \
273 ((curr) == 'C' && ((next) == 'D' || (next) == 'M')))
278#define ROMAN_VAL(r) \
285 (r) == 'M' ? 1000 : 0)
290#define MAX_ROMAN_LEN 15
296static const char *
const numTH[] = {
"ST",
"ND",
"RD",
"TH", NULL};
297static const char *
const numth[] = {
"st",
"nd",
"rd",
"th", NULL};
327#define NUM_F_DECIMAL (1 << 1)
328#define NUM_F_LDECIMAL (1 << 2)
329#define NUM_F_ZERO (1 << 3)
330#define NUM_F_BLANK (1 << 4)
331#define NUM_F_FILLMODE (1 << 5)
332#define NUM_F_LSIGN (1 << 6)
333#define NUM_F_BRACKET (1 << 7)
334#define NUM_F_MINUS (1 << 8)
335#define NUM_F_PLUS (1 << 9)
336#define NUM_F_ROMAN (1 << 10)
337#define NUM_F_MULTI (1 << 11)
338#define NUM_F_PLUS_POST (1 << 12)
339#define NUM_F_MINUS_POST (1 << 13)
340#define NUM_F_EEEE (1 << 14)
342#define NUM_LSIGN_PRE (-1)
343#define NUM_LSIGN_POST 1
344#define NUM_LSIGN_NONE 0
350#define IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL)
351#define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL)
352#define IS_ZERO(_f) ((_f)->flag & NUM_F_ZERO)
353#define IS_BLANK(_f) ((_f)->flag & NUM_F_BLANK)
354#define IS_FILLMODE(_f) ((_f)->flag & NUM_F_FILLMODE)
355#define IS_BRACKET(_f) ((_f)->flag & NUM_F_BRACKET)
356#define IS_MINUS(_f) ((_f)->flag & NUM_F_MINUS)
357#define IS_LSIGN(_f) ((_f)->flag & NUM_F_LSIGN)
358#define IS_PLUS(_f) ((_f)->flag & NUM_F_PLUS)
359#define IS_ROMAN(_f) ((_f)->flag & NUM_F_ROMAN)
360#define IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI)
361#define IS_EEEE(_f) ((_f)->flag & NUM_F_EEEE)
381#define DCH_CACHE_OVERHEAD \
382 MAXALIGN(sizeof(bool) + sizeof(int))
383#define NUM_CACHE_OVERHEAD \
384 MAXALIGN(sizeof(bool) + sizeof(int) + sizeof(NUMDesc))
386#define DCH_CACHE_SIZE \
387 ((2048 - DCH_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1)
388#define NUM_CACHE_SIZE \
389 ((1024 - NUM_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1)
391#define DCH_CACHE_ENTRIES 20
392#define NUM_CACHE_ENTRIES 20
458#define ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar))
470#ifdef DEBUG_TO_FROM_CHAR
471#define DEBUG_TMFC(_X) \
472 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", \
473 (_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
474 (_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
475 (_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
476 (_X)->yysz, (_X)->clock)
477#define DEBUG_TM(_X) \
478 elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
479 (_X)->tm_sec, (_X)->tm_year,\
480 (_X)->tm_min, (_X)->tm_wday, (_X)->tm_hour, (_X)->tm_yday,\
481 (_X)->tm_mday, (_X)->tm_isdst, (_X)->tm_mon)
483#define DEBUG_TMFC(_X)
515#define tmtcTm(_X) (&(_X)->tm)
516#define tmtcTzn(_X) ((_X)->tzn)
517#define tmtcFsec(_X) ((_X)->fsec)
520#define COPY_tm(_DST, _SRC) \
522 (_DST)->tm_sec = (_SRC)->tm_sec; \
523 (_DST)->tm_min = (_SRC)->tm_min; \
524 (_DST)->tm_hour = (_SRC)->tm_hour; \
525 (_DST)->tm_mday = (_SRC)->tm_mday; \
526 (_DST)->tm_mon = (_SRC)->tm_mon; \
527 (_DST)->tm_year = (_SRC)->tm_year; \
528 (_DST)->tm_wday = (_SRC)->tm_wday; \
529 (_DST)->tm_yday = (_SRC)->tm_yday; \
530 (_DST)->tm_gmtoff = (_SRC)->tm_gmtoff; \
536 memset(_X, 0, sizeof(*(_X))); \
537 (_X)->tm_mday = (_X)->tm_mon = 1; \
540#define ZERO_tmtc(_X) \
542 ZERO_tm( tmtcTm(_X) ); \
544 tmtcTzn(_X) = NULL; \
551#define INVALID_FOR_INTERVAL \
555 (errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
556 errmsg("invalid format specification for an interval value"), \
557 errhint("Intervals are not tied to specific calendar dates."))); \
578#define S_THth(_s) ((((_s) & DCH_S_TH) || ((_s) & DCH_S_th)) ? 1 : 0)
579#define S_TH(_s) (((_s) & DCH_S_TH) ? 1 : 0)
580#define S_th(_s) (((_s) & DCH_S_th) ? 1 : 0)
581#define S_TH_TYPE(_s) (((_s) & DCH_S_TH) ? TH_UPPER : TH_LOWER)
584#define S_FM(_s) (((_s) & DCH_S_FM) ? 1 : 0)
585#define S_SP(_s) (((_s) & DCH_S_SP) ? 1 : 0)
586#define S_TM(_s) (((_s) & DCH_S_TM) ? 1 : 0)
592#define TM_SUFFIX_LEN 2
980 -1, -1, -1, -1, -1, -1, -1, -1,
981 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
982 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
983 -1, -1, -1, -1, -1,
DCH_A_D,
DCH_B_C,
DCH_CC,
DCH_DAY, -1,
984 DCH_FF1, -1,
DCH_HH24,
DCH_IDDD,
DCH_J, -1, -1,
DCH_MI, -1,
DCH_OF,
985 DCH_P_M,
DCH_Q,
DCH_RM,
DCH_SSSSS,
DCH_TZH,
DCH_US, -1,
DCH_WW, -1,
DCH_Y_YYY,
986 -1, -1, -1, -1, -1, -1, -1,
DCH_a_d,
DCH_b_c,
DCH_cc,
987 DCH_day, -1,
DCH_ff1, -1,
DCH_hh24,
DCH_iddd,
DCH_j, -1, -1,
DCH_mi,
988 -1,
DCH_of,
DCH_p_m,
DCH_q,
DCH_rm,
DCH_sssss,
DCH_tzh,
DCH_us, -1,
DCH_ww,
1004 -1, -1, -1, -1, -1, -1, -1, -1,
1005 -1, -1, -1, -1,
NUM_COMMA, -1,
NUM_DEC, -1,
NUM_0, -1,
1006 -1, -1, -1, -1, -1, -1, -1,
NUM_9, -1, -1,
1007 -1, -1, -1, -1, -1, -1,
NUM_B,
NUM_C,
NUM_D,
NUM_E,
1008 NUM_FM,
NUM_G, -1, -1, -1, -1,
NUM_L,
NUM_MI, -1, -1,
1009 NUM_PL, -1,
NUM_RN,
NUM_SG,
NUM_TH, -1,
NUM_V, -1, -1, -1,
1010 -1, -1, -1, -1, -1, -1, -1, -1,
NUM_b,
NUM_c,
1011 NUM_d,
NUM_e,
NUM_fm,
NUM_g, -1, -1, -1, -1,
NUM_l,
NUM_mi,
1012 -1, -1,
NUM_pl, -1,
NUM_rn,
NUM_sg,
NUM_th, -1,
NUM_v, -1,
1013 -1, -1, -1, -1, -1, -1
1052#define DCH_DATED 0x01
1053#define DCH_TIMED 0x02
1054#define DCH_ZONED 0x04
1061#define OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len)
1062#define AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s)))
1082#ifdef DEBUG_TO_FROM_CHAR
1083static void dump_index(
const KeyWord *k,
const int *
index);
1084static void dump_node(
FormatNode *node,
int max);
1087static const char *
get_th(
char *num,
int type);
1103 const char *
const *array,
1118 char *number,
int input_len,
int to_char_out_pre_spaces,
1142 if ((poz = *(
index + (*
str -
' '))) > -1)
1163 for (s = suf; s->
name != NULL; s++)
1178 return (*
str > 0x20 && *
str < 0x7F &&
1179 !(*
str >=
'A' && *
str <=
'Z') &&
1180 !(*
str >=
'a' && *
str <=
'z') &&
1181 !(*
str >=
'0' && *
str <=
'9'));
1196 (
errcode(ERRCODE_SYNTAX_ERROR),
1197 errmsg(
"\"EEEE\" must be the last pattern used")));
1204 (
errcode(ERRCODE_SYNTAX_ERROR),
1205 errmsg(
"\"9\" must be ahead of \"PR\"")));
1220 (
errcode(ERRCODE_SYNTAX_ERROR),
1221 errmsg(
"\"0\" must be ahead of \"PR\"")));
1247 (
errcode(ERRCODE_SYNTAX_ERROR),
1248 errmsg(
"multiple decimal points")));
1251 (
errcode(ERRCODE_SYNTAX_ERROR),
1252 errmsg(
"cannot use \"V\" and decimal point together")));
1263 (
errcode(ERRCODE_SYNTAX_ERROR),
1264 errmsg(
"cannot use \"S\" twice")));
1267 (
errcode(ERRCODE_SYNTAX_ERROR),
1268 errmsg(
"cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together")));
1287 (
errcode(ERRCODE_SYNTAX_ERROR),
1288 errmsg(
"cannot use \"S\" and \"MI\" together")));
1297 (
errcode(ERRCODE_SYNTAX_ERROR),
1298 errmsg(
"cannot use \"S\" and \"PL\" together")));
1307 (
errcode(ERRCODE_SYNTAX_ERROR),
1308 errmsg(
"cannot use \"S\" and \"SG\" together")));
1316 (
errcode(ERRCODE_SYNTAX_ERROR),
1317 errmsg(
"cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together")));
1325 (
errcode(ERRCODE_SYNTAX_ERROR),
1326 errmsg(
"cannot use \"RN\" twice")));
1338 (
errcode(ERRCODE_SYNTAX_ERROR),
1339 errmsg(
"cannot use \"V\" and decimal point together")));
1346 (
errcode(ERRCODE_SYNTAX_ERROR),
1347 errmsg(
"cannot use \"EEEE\" twice")));
1352 (
errcode(ERRCODE_SYNTAX_ERROR),
1353 errmsg(
"\"EEEE\" is incompatible with other formats"),
1354 errdetail(
"\"EEEE\" may only be used together with digit and decimal point patterns.")));
1362 (
errcode(ERRCODE_SYNTAX_ERROR),
1363 errmsg(
"\"RN\" is incompatible with other formats"),
1364 errdetail(
"\"RN\" may only be used together with \"FM\".")));
1380#ifdef DEBUG_TO_FROM_CHAR
1381 elog(DEBUG_elog_output,
"to_char/number(): run parser");
1442 if (strchr(
"-./,':; ", *
str) == NULL)
1444 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
1445 errmsg(
"invalid datetime format separator: \"%s\"",
1460 else if (*
str ==
'"')
1474 if (*
str ==
'\\' && *(
str + 1))
1492 if (*
str ==
'\\' && *(
str + 1) ==
'"')
1498 else if (isspace((
unsigned char) *
str))
1521#ifdef DEBUG_TO_FROM_CHAR
1523#define DUMP_THth(_suf) (S_TH(_suf) ? "TH" : (S_th(_suf) ? "th" : " "))
1524#define DUMP_FM(_suf) (S_FM(_suf) ? "FM" : " ")
1532 elog(DEBUG_elog_output,
"to_from-char(): DUMP FORMAT");
1534 for (
a = 0, n = node;
a <= max; n++,
a++)
1537 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)",
1540 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_CHAR '%s'",
1544 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_END",
a);
1548 elog(DEBUG_elog_output,
"%d:\t unknown NODE!",
a);
1565 int len = strlen(num),
1568 last = *(num + (
len - 1));
1569 if (!isdigit((
unsigned char) last))
1571 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1572 errmsg(
"\"%s\" is not a number", num)));
1578 if ((
len > 1) && (num[
len - 2] ==
'1'))
1652 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1653 errmsg(
"could not determine which collation to use for %s function",
1655 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1667 const char *src = buff;
1668 size_t srclen = nbytes;
1674 dstsize = srclen + 1;
1677 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1678 if (needed + 1 > dstsize)
1681 dstsize = needed + 1;
1683 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1684 Assert(needed + 1 <= dstsize);
1687 Assert(dst[needed] ==
'\0');
1716 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1717 errmsg(
"could not determine which collation to use for %s function",
1719 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1731 const char *src = buff;
1732 size_t srclen = nbytes;
1738 dstsize = srclen + 1;
1741 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1742 if (needed + 1 > dstsize)
1745 dstsize = needed + 1;
1747 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1748 Assert(needed + 1 <= dstsize);
1751 Assert(dst[needed] ==
'\0');
1780 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1781 errmsg(
"could not determine which collation to use for %s function",
1783 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1795 const char *src = buff;
1796 size_t srclen = nbytes;
1802 dstsize = srclen + 1;
1805 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1806 if (needed + 1 > dstsize)
1809 dstsize = needed + 1;
1811 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1812 Assert(needed + 1 <= dstsize);
1815 Assert(dst[needed] ==
'\0');
1844 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1845 errmsg(
"could not determine which collation to use for %s function",
1847 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1852 (
errcode(ERRCODE_SYNTAX_ERROR),
1853 errmsg(
"Unicode case folding can only be performed if server encoding is UTF8")));
1864 const char *src = buff;
1865 size_t srclen = nbytes;
1871 dstsize = srclen + 1;
1874 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1875 if (needed + 1 > dstsize)
1878 dstsize = needed + 1;
1880 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1881 Assert(needed + 1 <= dstsize);
1884 Assert(dst[needed] ==
'\0');
1908 for (p = result; *p; p++)
1931 for (p = result; *p; p++)
1948 int wasalnum =
false;
1955 for (p = result; *p; p++)
1964 wasalnum = ((
c >=
'A' &&
c <=
'Z') ||
1965 (
c >=
'a' &&
c <=
'z') ||
1966 (
c >=
'0' &&
c <=
'9'));
2013#define SKIP_THth(ptr, _suf) \
2017 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2018 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2023#ifdef DEBUG_TO_FROM_CHAR
2036 elog(DEBUG_elog_output,
"TO-FROM_CHAR: Dump KeyWord Index:");
2048 elog(DEBUG_elog_output,
"\t(%d) %c %d",
i,
i + 32,
index[
i]);
2051 elog(DEBUG_elog_output,
"\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
2086 isdigit((
unsigned char) n->
character[0]))
2104 else if (year < 100)
2107 else if (year < 520)
2110 else if (year < 1000)
2122 while (*
str && isspace((
unsigned char) *
str))
2149 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2150 errmsg(
"invalid combination of date conventions"),
2151 errhint(
"Do not mix Gregorian and ISO week date "
2152 "conventions in a formatting template.")));
2172 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2173 errmsg(
"conflicting values for \"%s\" field in formatting string",
2175 errdetail(
"This value contradicts a previous setting "
2176 "for the same field type.")));
2208 const char *
init = *src;
2228 result = strtol(
init, &endptr, 10);
2241 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2242 errmsg(
"source string too short for \"%s\" formatting field",
2244 errdetail(
"Field requires %d characters, but only %d remain.",
2246 errhint(
"If your source string is not fixed-width, "
2247 "try using the \"FM\" modifier.")));
2250 result = strtol(copy, &last, 10);
2253 if (used > 0 && used <
len)
2255 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2256 errmsg(
"invalid value \"%s\" for \"%s\"",
2258 errdetail(
"Field requires %d characters, but only %d could be parsed.",
2260 errhint(
"If your source string is not fixed-width, "
2261 "try using the \"FM\" modifier.")));
2268 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2269 errmsg(
"invalid value \"%s\" for \"%s\"",
2271 errdetail(
"Value must be an integer.")));
2273 if (errno == ERANGE || result < INT_MIN || result > INT_MAX)
2275 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2276 errmsg(
"value for \"%s\" in source string is out of range",
2278 errdetail(
"Value must be in the range %d to %d.",
2279 INT_MIN, INT_MAX)));
2320 unsigned char firstc;
2321 const char *
const *
a;
2332 for (
a = array; *
a != NULL;
a++)
2342 for (p = *
a + 1, n =
name + 1;; p++, n++)
2391 for (
a = array; *
a != NULL;
a++)
2393 int element_len = strlen(*
a);
2395 if (strncmp(
name, *
a, element_len) == 0)
2410 for (
a = array; *
a != NULL;
a++)
2412 char *upper_element;
2413 char *lower_element;
2418 lower_element =
str_tolower(upper_element, strlen(upper_element),
2420 pfree(upper_element);
2421 element_len = strlen(lower_element);
2424 if (strncmp(lower_name, lower_element, element_len) == 0)
2427 pfree(lower_element);
2431 pfree(lower_element);
2465 if (localized_array == NULL)
2479 for (
c = copy; *
c;
c++)
2489 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2490 errmsg(
"invalid value \"%s\" for \"%s\"",
2492 errdetail(
"The given value did not match any of "
2493 "the allowed values for this field.")));
2588#define DCH_to_char_fsec(frac_fmt, frac_val) \
2589 sprintf(s, frac_fmt, (int) (frac_val)); \
2590 if (S_THth(n->suffix)) \
2591 str_numth(s, s, S_TH_TYPE(n->suffix)); \
2614#undef DCH_to_char_fsec
2707 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2708 errmsg(
"localized string format value too long")));
2727 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2728 errmsg(
"localized string format value too long")));
2747 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2748 errmsg(
"localized string format value too long")));
2767 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2768 errmsg(
"localized string format value too long")));
2786 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2787 errmsg(
"localized string format value too long")));
2805 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2806 errmsg(
"localized string format value too long")));
2829 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2830 errmsg(
"localized string format value too long")));
2847 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2848 errmsg(
"localized string format value too long")));
2865 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2866 errmsg(
"localized string format value too long")));
2883 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2884 errmsg(
"localized string format value too long")));
2900 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2901 errmsg(
"localized string format value too long")));
2917 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2918 errmsg(
"localized string format value too long")));
2988 if (i <= 99 && i >= -99)
3029 is_interval)) % 1000);
3044 is_interval)) % 100);
3057 is_interval)) % 10);
3075 const char *
const *
months;
3176 while (*s !=
'\0' && isspace((
unsigned char) *s))
3197 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3198 errmsg(
"unmatched format separator \"%c\"",
3258 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3259 errmsg(
"unmatched format character \"%s\"",
3329 out->
ms *=
len == 1 ? 100 :
3345 out->
ff, n, escontext);
3349 out->
us *=
len == 1 ? 100000 :
3380 else if (isalpha((
unsigned char) *s))
3389 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3390 errmsg(
"invalid value \"%s\" for \"%s\"",
3392 errdetail(
"Time zone abbreviation is not recognized.")));
3400 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3402 out->
tzsign = *s ==
'-' ? -1 : +1;
3407 if (extra_skip > 0 && *(s - 1) ==
'-')
3431 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3433 out->
tzsign = *s ==
'-' ? -1 : +1;
3438 if (extra_skip > 0 && *(s - 1) ==
'-')
3589 matched = sscanf(s,
"%d,%03d%n", &millennia, &years, &nch);
3592 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3593 errmsg(
"invalid input string for \"Y,YYY\"")));
3599 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3600 errmsg(
"value for \"Y,YYY\" in source string is out of range")));
3672 while (*s !=
'\0' && isspace((
unsigned char) *s))
3688 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3689 errmsg(
"input string is too short for datetime format")));
3691 while (*s !=
'\0' && isspace((
unsigned char) *s))
3696 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3697 errmsg(
"trailing characters remain in input string after datetime format")));
3834#ifdef DEBUG_TO_FROM_CHAR
3851#ifdef DEBUG_TO_FROM_CHAR
3852 elog(DEBUG_elog_output,
"OLD: '%s' AGE: %d", old->
str, old->
age);
3862#ifdef DEBUG_TO_FROM_CHAR
3941 fmt_len = strlen(fmt_str);
4015 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4016 errmsg(
"timestamp out of range")));
4020 tt.
tm_wday = (thisdate + 1) % 7;
4051 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4052 errmsg(
"timestamp out of range")));
4056 tt.
tm_wday = (thisdate + 1) % 7;
4128 &
tm, &fsec, &ftz, &fprec, NULL, NULL);
4138 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4139 errmsg(
"timestamp out of range")));
4165 &
tm, &fsec, &ftz, NULL, NULL, NULL);
4170 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4171 errmsg(
"date out of range: \"%s\"",
4179 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4180 errmsg(
"date out of range: \"%s\"",
4203 Oid *typid,
int32 *typmod,
int *tz,
4213 &
tm, &fsec, &ftz, &fprec, &flags, escontext))
4216 *typmod = fprec ? fprec : -1;
4240 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4241 errmsg(
"missing time zone in input string for type timestamptz")));
4246 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4247 errmsg(
"timestamptz out of range")));
4251 *typid = TIMESTAMPTZOID;
4260 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4261 errmsg(
"timestamp out of range")));
4265 *typid = TIMESTAMPOID;
4274 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4275 errmsg(
"datetime format is zoned but not timed")));
4284 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4285 errmsg(
"date out of range: \"%s\"",
4294 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4295 errmsg(
"date out of range: \"%s\"",
4323 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4324 errmsg(
"missing time zone in input string for type timetz")));
4329 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4330 errmsg(
"timetz out of range")));
4343 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4344 errmsg(
"time out of range")));
4355 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4356 errmsg(
"datetime format is not dated and not timed")));
4368 int fmt_len = strlen(fmt_str);
4437 bool incache =
false;
4484#ifdef DEBUG_TO_FROM_CHAR
4532 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4533 errmsg(
"hour \"%d\" is invalid for the 12-hour clock",
4535 errhint(
"Use the 24-hour clock, or give an hour between 1 and 12.")));
4553 if (tmfc.
cc && tmfc.
yysz <= 2)
4670 date_str,
"timestamp", escontext);
4684 date_str,
"timestamp", escontext);
4711 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4712 errmsg(
"cannot calculate day of year without year information")));
4730 static const int ysum[2][13] = {
4731 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
4732 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}};
4738 if (tmfc.
ddd <=
y[
i])
4760 date_str,
"timestamp", escontext);
4783 date_str,
"timestamp", escontext);
4795 date_str,
"timestamp", escontext);
4811 date_str,
"timestamp", escontext);
4825 if (tmfc.
tzp == NULL)
4863 memset(
str,
c, max);
4864 *(
str + max) =
'\0';
4868#define zeroize_NUM(_n) \
4874 (_n)->pre_lsign_num = 0; \
4875 (_n)->need_locale = 0; \
4877 (_n)->zero_start = 0; \
4878 (_n)->zero_end = 0; \
4909#ifdef DEBUG_TO_FROM_CHAR
4926#ifdef DEBUG_TO_FROM_CHAR
4927 elog(DEBUG_elog_output,
"OLD: \"%s\" AGE: %d", old->
str, old->
age);
4937#ifdef DEBUG_TO_FROM_CHAR
5032 *shouldFree =
false;
5050#ifdef DEBUG_TO_FROM_CHAR
5082 if (number > 3999 || number < 1)
5089 len =
snprintf(numstr,
sizeof(numstr),
"%d", number);
5092 for (p = numstr; *p !=
'\0'; p++, --
len)
5094 num = *p - (
'0' + 1);
5102 strcat(result,
"M");
5105 strcat(result,
rm100[num]);
5108 strcat(result,
rm10[num]);
5111 strcat(result,
rm1[num]);
5132 int repeatCount = 1;
5136 bool subtractionEncountered =
false;
5137 int lastSubtractedValue = 0;
5159 romanChars[
len] = currChar;
5160 romanValues[
len] = currValue;
5168 for (
int i = 0;
i <
len;
i++)
5170 char currChar = romanChars[
i];
5171 int currValue = romanValues[
i];
5177 if (subtractionEncountered && currValue >= lastSubtractedValue)
5184 if ((vCount && currValue >=
ROMAN_VAL(
'V')) ||
5185 (lCount && currValue >=
ROMAN_VAL(
'L')) ||
5186 (dCount && currValue >=
ROMAN_VAL(
'D')))
5188 if (currChar ==
'V')
5190 else if (currChar ==
'L')
5192 else if (currChar ==
'D')
5198 char nextChar = romanChars[
i + 1];
5199 int nextValue = romanValues[
i + 1];
5206 if (currValue < nextValue)
5215 if (repeatCount > 1)
5223 if ((vCount && nextValue >=
ROMAN_VAL(
'V')) ||
5224 (lCount && nextValue >=
ROMAN_VAL(
'L')) ||
5225 (dCount && nextValue >=
ROMAN_VAL(
'D')))
5227 if (nextChar ==
'V')
5229 else if (nextChar ==
'L')
5231 else if (nextChar ==
'D')
5242 subtractionEncountered =
true;
5243 lastSubtractedValue = currValue;
5244 result += (nextValue - currValue);
5249 if (currChar == nextChar)
5252 if (repeatCount > 3)
5257 result += currValue;
5263 result += currValue;
5280 struct lconv *lconv;
5290 if (lconv->negative_sign && *lconv->negative_sign)
5295 if (lconv->positive_sign && *lconv->positive_sign)
5303 if (lconv->decimal_point && *lconv->decimal_point)
5304 Np->
decimal = lconv->decimal_point;
5319 if (lconv->thousands_sep && *lconv->thousands_sep)
5322 else if (strcmp(Np->
decimal,
",") != 0)
5330 if (lconv->currency_symbol && *lconv->currency_symbol)
5361 *p = strchr(num,
'.');
5363#ifdef DEBUG_TO_FROM_CHAR
5364 elog(DEBUG_elog_output,
"get_last_relevant_decnum()");
5388 bool isread =
false;
5390#ifdef DEBUG_TO_FROM_CHAR
5391 elog(DEBUG_elog_output,
" --- scan start --- id=%s",
5410#ifdef DEBUG_TO_FROM_CHAR
5411 elog(DEBUG_elog_output,
"Try read sign (%c), locale positive: %s, negative: %s",
5422#ifdef DEBUG_TO_FROM_CHAR
5423 elog(DEBUG_elog_output,
"Try read locale pre-sign (%c)", *Np->
inout_p);
5442#ifdef DEBUG_TO_FROM_CHAR
5443 elog(DEBUG_elog_output,
"Try read simple sign (%c)", *Np->
inout_p);
5466#ifdef DEBUG_TO_FROM_CHAR
5467 elog(DEBUG_elog_output,
"Scan for numbers (%c), current number: '%s'", *Np->
inout_p, Np->
number);
5473 if (isdigit((
unsigned char) *Np->
inout_p))
5488#ifdef DEBUG_TO_FROM_CHAR
5489 elog(DEBUG_elog_output,
"Read digit (%c)", *Np->
inout_p);
5501#ifdef DEBUG_TO_FROM_CHAR
5502 elog(DEBUG_elog_output,
"Try read decimal point (%c)",
5536 !isdigit((
unsigned char) *(Np->
inout_p + 1)))
5541#ifdef DEBUG_TO_FROM_CHAR
5542 elog(DEBUG_elog_output,
"Try read locale post-sign (%c)", *Np->
inout_p);
5573 else if (isread ==
false &&
IS_LSIGN(Np->
Num) ==
false &&
5576#ifdef DEBUG_TO_FROM_CHAR
5577 elog(DEBUG_elog_output,
"Try read simple post-sign (%c)", *Np->
inout_p);
5590#define IS_PREDEC_SPACE(_n) \
5591 (IS_ZERO((_n)->Num)==false && \
5592 (_n)->number == (_n)->number_p && \
5593 *(_n)->number == '0' && \
5594 (_n)->Num->post != 0)
5610#ifdef DEBUG_TO_FROM_CHAR
5616 elog(DEBUG_elog_output,
5617 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
5637 if (Np->
sign ==
'-')
5651 else if (Np->
sign ==
'+')
5660 else if (Np->
sign ==
'-')
5775 if (Np->
sign ==
'-')
5797 if (strchr(
"0123456789.,+-", *Np->
inout_p) != NULL)
5805 char *number,
int input_len,
int to_char_out_pre_spaces,
5811 const char *pattern;
5832 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5833 errmsg(
"\"EEEE\" not supported for input")));
5834 return strcpy(inout, number);
5854 if (Np->
sign !=
'-')
5857 Np->
Num->
flag &= ~NUM_F_BRACKET;
5897 last_zero_pos = strlen(Np->
number) - 1;
5898 last_zero_pos =
Min(last_zero_pos,
5900 last_zero = Np->
number + last_zero_pos;
5913 *(Np->
number + 1) =
'\0';
5919#ifdef DEBUG_TO_FROM_CHAR
5920 elog(DEBUG_elog_output,
5921 "\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",
6029 pattern_len = strlen(pattern);
6040 memset(Np->
inout_p,
' ', pattern_len);
6041 Np->
inout_p += pattern_len - 1;
6047 Np->
inout_p += pattern_len - 1;
6065 strncmp(Np->
inout_p, pattern, pattern_len) == 0)
6066 Np->
inout_p += pattern_len - 1;
6077 Np->
inout_p += strlen(pattern) - 1;
6090 const char *number_p;
6097 strcpy(Np->
inout_p, number_p);
6107 if (roman_result < 0)
6109 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
6110 errmsg(
"invalid Roman numeral")));
6158 if (Np->
sign ==
'-')
6180 if (Np->
sign ==
'+')
6260#ifdef DEBUG_TO_FROM_CHAR
6261 elog(DEBUG_elog_output,
"TO_NUMBER (number): '%s'", Np->
number);
6272#define NUM_TOCHAR_prepare \
6274 int len = VARSIZE_ANY_EXHDR(fmt); \
6275 if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
6276 PG_RETURN_TEXT_P(cstring_to_text("")); \
6277 result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
6278 format = NUM_cache(len, &Num, fmt, &shouldFree); \
6285#define NUM_TOCHAR_finish \
6289 NUM_processor(format, &Num, VARDATA(result), numstr, 0, out_pre_spaces, sign, true, PG_GET_COLLATION()); \
6299 len = strlen(VARDATA(result)); \
6300 SET_VARSIZE(result, len + VARHDRSZ); \
6375 int out_pre_spaces = 0,
6408 if (strcmp(orgnum,
"NaN") == 0 ||
6409 strcmp(orgnum,
"Infinity") == 0 ||
6410 strcmp(orgnum,
"-Infinity") == 0)
6419 *(numstr + Num.
pre + 1) =
'.';
6421 else if (*orgnum !=
'-')
6423 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6425 strcpy(numstr + 1, orgnum);
6461 numstr = orgnum + 1;
6469 if ((p = strchr(numstr,
'.')))
6470 numstr_pre_len = p - numstr;
6472 numstr_pre_len = strlen(numstr);
6475 if (numstr_pre_len < Num.
pre)
6476 out_pre_spaces = Num.
pre - numstr_pre_len;
6478 else if (numstr_pre_len > Num.
pre)
6482 *(numstr + Num.
pre) =
'.';
6503 int out_pre_spaces = 0,
6554 numstr_pre_len = strlen(orgnum);
6559 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6560 strcpy(numstr, orgnum);
6561 *(numstr + numstr_pre_len) =
'.';
6562 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6563 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6569 if (numstr_pre_len < Num.
pre)
6570 out_pre_spaces = Num.
pre - numstr_pre_len;
6572 else if (numstr_pre_len > Num.
pre)
6576 *(numstr + Num.
pre) =
'.';
6597 int out_pre_spaces = 0,
6631 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6633 strcpy(numstr + 1, orgnum);
6646 double multi = pow((
double) 10, (
double) Num.
multi);
6666 numstr_pre_len = strlen(orgnum);
6671 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6672 strcpy(numstr, orgnum);
6673 *(numstr + numstr_pre_len) =
'.';
6674 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6675 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6681 if (numstr_pre_len < Num.
pre)
6682 out_pre_spaces = Num.
pre - numstr_pre_len;
6684 else if (numstr_pre_len > Num.
pre)
6688 *(numstr + Num.
pre) =
'.';
6709 int out_pre_spaces = 0,
6740 *(numstr + Num.
pre + 1) =
'.';
6761 float multi = pow((
double) 10, (
double) Num.
multi);
6768 numstr_pre_len = strlen(orgnum);
6771 if (numstr_pre_len >= FLT_DIG)
6773 else if (numstr_pre_len + Num.
post > FLT_DIG)
6774 Num.
post = FLT_DIG - numstr_pre_len;
6780 numstr = orgnum + 1;
6788 if ((p = strchr(numstr,
'.')))
6789 numstr_pre_len = p - numstr;
6791 numstr_pre_len = strlen(numstr);
6794 if (numstr_pre_len < Num.
pre)
6795 out_pre_spaces = Num.
pre - numstr_pre_len;
6797 else if (numstr_pre_len > Num.
pre)
6801 *(numstr + Num.
pre) =
'.';
6822 int out_pre_spaces = 0,
6853 *(numstr + Num.
pre + 1) =
'.';
6874 double multi = pow((
double) 10, (
double) Num.
multi);
6881 numstr_pre_len = strlen(orgnum);
6884 if (numstr_pre_len >= DBL_DIG)
6886 else if (numstr_pre_len + Num.
post > DBL_DIG)
6887 Num.
post = DBL_DIG - numstr_pre_len;
6893 numstr = orgnum + 1;
6901 if ((p = strchr(numstr,
'.')))
6902 numstr_pre_len = p - numstr;
6904 numstr_pre_len = strlen(numstr);
6907 if (numstr_pre_len < Num.
pre)
6908 out_pre_spaces = Num.
pre - numstr_pre_len;
6910 else if (numstr_pre_len > Num.
pre)
6914 *(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)
int32 numeric_int4_opt_error(Numeric num, bool *have_error)
Datum numeric_round(PG_FUNCTION_ARGS)
Numeric int64_to_numeric(int64 val)
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,...)
void err(int eval, const char *fmt,...)
Datum Int64GetDatum(int64 X)
Datum Float8GetDatum(float8 X)
#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 int64 DatumGetInt64(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum 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)
#define VARSIZE_ANY_EXHDR(PTR)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)