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),
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'))
1654 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1655 errmsg(
"could not determine which collation to use for %s function",
1657 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1669 const char *src = buff;
1670 size_t srclen = nbytes;
1676 dstsize = srclen + 1;
1679 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1680 if (needed + 1 > dstsize)
1683 dstsize = needed + 1;
1685 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1686 Assert(needed + 1 <= dstsize);
1689 Assert(dst[needed] ==
'\0');
1718 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1719 errmsg(
"could not determine which collation to use for %s function",
1721 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1733 const char *src = buff;
1734 size_t srclen = nbytes;
1740 dstsize = srclen + 1;
1743 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1744 if (needed + 1 > dstsize)
1747 dstsize = needed + 1;
1749 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1750 Assert(needed + 1 <= dstsize);
1753 Assert(dst[needed] ==
'\0');
1782 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1783 errmsg(
"could not determine which collation to use for %s function",
1785 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1797 const char *src = buff;
1798 size_t srclen = nbytes;
1804 dstsize = srclen + 1;
1807 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1808 if (needed + 1 > dstsize)
1811 dstsize = needed + 1;
1813 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1814 Assert(needed + 1 <= dstsize);
1817 Assert(dst[needed] ==
'\0');
1846 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1847 errmsg(
"could not determine which collation to use for %s function",
1849 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1854 (
errcode(ERRCODE_SYNTAX_ERROR),
1855 errmsg(
"Unicode case folding can only be performed if server encoding is UTF8")));
1866 const char *src = buff;
1867 size_t srclen = nbytes;
1873 dstsize = srclen + 1;
1876 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1877 if (needed + 1 > dstsize)
1880 dstsize = needed + 1;
1882 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1883 Assert(needed + 1 <= dstsize);
1886 Assert(dst[needed] ==
'\0');
1910 for (p = result; *p; p++)
1933 for (p = result; *p; p++)
1950 int wasalnum =
false;
1957 for (p = result; *p; p++)
1966 wasalnum = ((
c >=
'A' &&
c <=
'Z') ||
1967 (
c >=
'a' &&
c <=
'z') ||
1968 (
c >=
'0' &&
c <=
'9'));
2015#define SKIP_THth(ptr, _suf) \
2019 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2020 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2025#ifdef DEBUG_TO_FROM_CHAR
2038 elog(DEBUG_elog_output,
"TO-FROM_CHAR: Dump KeyWord Index:");
2050 elog(DEBUG_elog_output,
"\t(%d) %c %d",
i,
i + 32,
index[
i]);
2053 elog(DEBUG_elog_output,
"\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
2088 isdigit((
unsigned char) n->
character[0]))
2106 else if (year < 100)
2109 else if (year < 520)
2112 else if (year < 1000)
2124 while (*
str && isspace((
unsigned char) *
str))
2151 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2152 errmsg(
"invalid combination of date conventions"),
2153 errhint(
"Do not mix Gregorian and ISO week date "
2154 "conventions in a formatting template.")));
2174 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2175 errmsg(
"conflicting values for \"%s\" field in formatting string",
2177 errdetail(
"This value contradicts a previous setting "
2178 "for the same field type.")));
2210 const char *
init = *src;
2230 result = strtol(
init, &endptr, 10);
2243 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2244 errmsg(
"source string too short for \"%s\" formatting field",
2246 errdetail(
"Field requires %d characters, but only %d remain.",
2248 errhint(
"If your source string is not fixed-width, "
2249 "try using the \"FM\" modifier.")));
2252 result = strtol(copy, &last, 10);
2255 if (used > 0 && used <
len)
2257 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2258 errmsg(
"invalid value \"%s\" for \"%s\"",
2260 errdetail(
"Field requires %d characters, but only %d could be parsed.",
2262 errhint(
"If your source string is not fixed-width, "
2263 "try using the \"FM\" modifier.")));
2270 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2271 errmsg(
"invalid value \"%s\" for \"%s\"",
2273 errdetail(
"Value must be an integer.")));
2275 if (errno == ERANGE || result < INT_MIN || result > INT_MAX)
2277 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2278 errmsg(
"value for \"%s\" in source string is out of range",
2280 errdetail(
"Value must be in the range %d to %d.",
2281 INT_MIN, INT_MAX)));
2322 unsigned char firstc;
2323 const char *
const *
a;
2334 for (
a = array; *
a != NULL;
a++)
2344 for (p = *
a + 1, n =
name + 1;; p++, n++)
2393 for (
a = array; *
a != NULL;
a++)
2395 int element_len = strlen(*
a);
2397 if (strncmp(
name, *
a, element_len) == 0)
2412 for (
a = array; *
a != NULL;
a++)
2414 char *upper_element;
2415 char *lower_element;
2420 lower_element =
str_tolower(upper_element, strlen(upper_element),
2422 pfree(upper_element);
2423 element_len = strlen(lower_element);
2426 if (strncmp(lower_name, lower_element, element_len) == 0)
2429 pfree(lower_element);
2433 pfree(lower_element);
2467 if (localized_array == NULL)
2481 for (
c = copy; *
c;
c++)
2491 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2492 errmsg(
"invalid value \"%s\" for \"%s\"",
2494 errdetail(
"The given value did not match any of "
2495 "the allowed values for this field.")));
2590#define DCH_to_char_fsec(frac_fmt, frac_val) \
2591 sprintf(s, frac_fmt, (int) (frac_val)); \
2592 if (S_THth(n->suffix)) \
2593 str_numth(s, s, S_TH_TYPE(n->suffix)); \
2616#undef DCH_to_char_fsec
2709 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2710 errmsg(
"localized string format value too long")));
2729 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2730 errmsg(
"localized string format value too long")));
2749 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2750 errmsg(
"localized string format value too long")));
2769 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2770 errmsg(
"localized string format value too long")));
2788 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2789 errmsg(
"localized string format value too long")));
2807 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2808 errmsg(
"localized string format value too long")));
2831 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2832 errmsg(
"localized string format value too long")));
2849 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2850 errmsg(
"localized string format value too long")));
2867 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2868 errmsg(
"localized string format value too long")));
2885 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2886 errmsg(
"localized string format value too long")));
2902 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2903 errmsg(
"localized string format value too long")));
2919 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2920 errmsg(
"localized string format value too long")));
2990 if (i <= 99 && i >= -99)
3031 is_interval)) % 1000);
3046 is_interval)) % 100);
3059 is_interval)) % 10);
3077 const char *
const *
months;
3178 while (*s !=
'\0' && isspace((
unsigned char) *s))
3199 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3200 errmsg(
"unmatched format separator \"%c\"",
3260 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3261 errmsg(
"unmatched format character \"%s\"",
3331 out->
ms *=
len == 1 ? 100 :
3347 out->
ff, n, escontext);
3351 out->
us *=
len == 1 ? 100000 :
3382 else if (isalpha((
unsigned char) *s))
3391 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3392 errmsg(
"invalid value \"%s\" for \"%s\"",
3394 errdetail(
"Time zone abbreviation is not recognized.")));
3402 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3404 out->
tzsign = *s ==
'-' ? -1 : +1;
3409 if (extra_skip > 0 && *(s - 1) ==
'-')
3433 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3435 out->
tzsign = *s ==
'-' ? -1 : +1;
3440 if (extra_skip > 0 && *(s - 1) ==
'-')
3591 matched = sscanf(s,
"%d,%03d%n", &millennia, &years, &nch);
3594 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3595 errmsg(
"invalid value \"%s\" for \"%s\"",
3602 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3603 errmsg(
"value for \"%s\" in source string is out of range",
"Y,YYY")));
3675 while (*s !=
'\0' && isspace((
unsigned char) *s))
3691 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3692 errmsg(
"input string is too short for datetime format")));
3694 while (*s !=
'\0' && isspace((
unsigned char) *s))
3699 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3700 errmsg(
"trailing characters remain in input string after datetime format")));
3837#ifdef DEBUG_TO_FROM_CHAR
3854#ifdef DEBUG_TO_FROM_CHAR
3855 elog(DEBUG_elog_output,
"OLD: '%s' AGE: %d", old->
str, old->
age);
3865#ifdef DEBUG_TO_FROM_CHAR
3944 fmt_len = strlen(fmt_str);
4018 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4019 errmsg(
"timestamp out of range")));
4023 tt.
tm_wday = (thisdate + 1) % 7;
4054 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4055 errmsg(
"timestamp out of range")));
4059 tt.
tm_wday = (thisdate + 1) % 7;
4131 &
tm, &fsec, &ftz, &fprec, NULL, NULL);
4141 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4142 errmsg(
"timestamp out of range")));
4168 &
tm, &fsec, &ftz, NULL, NULL, NULL);
4173 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4174 errmsg(
"date out of range: \"%s\"",
4182 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4183 errmsg(
"date out of range: \"%s\"",
4206 Oid *typid,
int32 *typmod,
int *tz,
4216 &
tm, &fsec, &ftz, &fprec, &flags, escontext))
4219 *typmod = fprec ? fprec : -1;
4243 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4244 errmsg(
"missing time zone in input string for type timestamptz")));
4249 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4250 errmsg(
"timestamptz out of range")));
4254 *typid = TIMESTAMPTZOID;
4263 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4264 errmsg(
"timestamp out of range")));
4268 *typid = TIMESTAMPOID;
4277 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4278 errmsg(
"datetime format is zoned but not timed")));
4287 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4288 errmsg(
"date out of range: \"%s\"",
4297 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4298 errmsg(
"date out of range: \"%s\"",
4326 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4327 errmsg(
"missing time zone in input string for type timetz")));
4332 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4333 errmsg(
"timetz out of range")));
4346 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4347 errmsg(
"time out of range")));
4358 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4359 errmsg(
"datetime format is not dated and not timed")));
4371 int fmt_len = strlen(fmt_str);
4440 bool incache =
false;
4487#ifdef DEBUG_TO_FROM_CHAR
4535 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4536 errmsg(
"hour \"%d\" is invalid for the 12-hour clock",
4538 errhint(
"Use the 24-hour clock, or give an hour between 1 and 12.")));
4556 if (tmfc.
cc && tmfc.
yysz <= 2)
4673 date_str,
"timestamp", escontext);
4687 date_str,
"timestamp", escontext);
4714 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4715 errmsg(
"cannot calculate day of year without year information")));
4733 static const int ysum[2][13] = {
4734 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
4735 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}};
4741 if (tmfc.
ddd <=
y[
i])
4763 date_str,
"timestamp", escontext);
4786 date_str,
"timestamp", escontext);
4798 date_str,
"timestamp", escontext);
4814 date_str,
"timestamp", escontext);
4828 if (tmfc.
tzp == NULL)
4866 memset(
str,
c, max);
4867 *(
str + max) =
'\0';
4871#define zeroize_NUM(_n) \
4877 (_n)->pre_lsign_num = 0; \
4878 (_n)->need_locale = 0; \
4880 (_n)->zero_start = 0; \
4881 (_n)->zero_end = 0; \
4912#ifdef DEBUG_TO_FROM_CHAR
4929#ifdef DEBUG_TO_FROM_CHAR
4930 elog(DEBUG_elog_output,
"OLD: \"%s\" AGE: %d", old->
str, old->
age);
4940#ifdef DEBUG_TO_FROM_CHAR
5035 *shouldFree =
false;
5053#ifdef DEBUG_TO_FROM_CHAR
5085 if (number > 3999 || number < 1)
5092 len =
snprintf(numstr,
sizeof(numstr),
"%d", number);
5095 for (p = numstr; *p !=
'\0'; p++, --
len)
5097 num = *p - (
'0' + 1);
5105 strcat(result,
"M");
5108 strcat(result,
rm100[num]);
5111 strcat(result,
rm10[num]);
5114 strcat(result,
rm1[num]);
5135 int repeatCount = 1;
5139 bool subtractionEncountered =
false;
5140 int lastSubtractedValue = 0;
5162 romanChars[
len] = currChar;
5163 romanValues[
len] = currValue;
5171 for (
int i = 0;
i <
len;
i++)
5173 char currChar = romanChars[
i];
5174 int currValue = romanValues[
i];
5180 if (subtractionEncountered && currValue >= lastSubtractedValue)
5187 if ((vCount && currValue >=
ROMAN_VAL(
'V')) ||
5188 (lCount && currValue >=
ROMAN_VAL(
'L')) ||
5189 (dCount && currValue >=
ROMAN_VAL(
'D')))
5191 if (currChar ==
'V')
5193 else if (currChar ==
'L')
5195 else if (currChar ==
'D')
5201 char nextChar = romanChars[
i + 1];
5202 int nextValue = romanValues[
i + 1];
5209 if (currValue < nextValue)
5218 if (repeatCount > 1)
5226 if ((vCount && nextValue >=
ROMAN_VAL(
'V')) ||
5227 (lCount && nextValue >=
ROMAN_VAL(
'L')) ||
5228 (dCount && nextValue >=
ROMAN_VAL(
'D')))
5230 if (nextChar ==
'V')
5232 else if (nextChar ==
'L')
5234 else if (nextChar ==
'D')
5245 subtractionEncountered =
true;
5246 lastSubtractedValue = currValue;
5247 result += (nextValue - currValue);
5252 if (currChar == nextChar)
5255 if (repeatCount > 3)
5260 result += currValue;
5266 result += currValue;
5283 struct lconv *lconv;
5293 if (lconv->negative_sign && *lconv->negative_sign)
5298 if (lconv->positive_sign && *lconv->positive_sign)
5306 if (lconv->decimal_point && *lconv->decimal_point)
5307 Np->
decimal = lconv->decimal_point;
5322 if (lconv->thousands_sep && *lconv->thousands_sep)
5325 else if (strcmp(Np->
decimal,
",") != 0)
5333 if (lconv->currency_symbol && *lconv->currency_symbol)
5364 *p = strchr(num,
'.');
5366#ifdef DEBUG_TO_FROM_CHAR
5367 elog(DEBUG_elog_output,
"get_last_relevant_decnum()");
5391 bool isread =
false;
5393#ifdef DEBUG_TO_FROM_CHAR
5394 elog(DEBUG_elog_output,
" --- scan start --- id=%s",
5413#ifdef DEBUG_TO_FROM_CHAR
5414 elog(DEBUG_elog_output,
"Try read sign (%c), locale positive: %s, negative: %s",
5425#ifdef DEBUG_TO_FROM_CHAR
5426 elog(DEBUG_elog_output,
"Try read locale pre-sign (%c)", *Np->
inout_p);
5445#ifdef DEBUG_TO_FROM_CHAR
5446 elog(DEBUG_elog_output,
"Try read simple sign (%c)", *Np->
inout_p);
5469#ifdef DEBUG_TO_FROM_CHAR
5470 elog(DEBUG_elog_output,
"Scan for numbers (%c), current number: '%s'", *Np->
inout_p, Np->
number);
5476 if (isdigit((
unsigned char) *Np->
inout_p))
5491#ifdef DEBUG_TO_FROM_CHAR
5492 elog(DEBUG_elog_output,
"Read digit (%c)", *Np->
inout_p);
5504#ifdef DEBUG_TO_FROM_CHAR
5505 elog(DEBUG_elog_output,
"Try read decimal point (%c)",
5539 !isdigit((
unsigned char) *(Np->
inout_p + 1)))
5544#ifdef DEBUG_TO_FROM_CHAR
5545 elog(DEBUG_elog_output,
"Try read locale post-sign (%c)", *Np->
inout_p);
5576 else if (isread ==
false &&
IS_LSIGN(Np->
Num) ==
false &&
5579#ifdef DEBUG_TO_FROM_CHAR
5580 elog(DEBUG_elog_output,
"Try read simple post-sign (%c)", *Np->
inout_p);
5593#define IS_PREDEC_SPACE(_n) \
5594 (IS_ZERO((_n)->Num)==false && \
5595 (_n)->number == (_n)->number_p && \
5596 *(_n)->number == '0' && \
5597 (_n)->Num->post != 0)
5613#ifdef DEBUG_TO_FROM_CHAR
5619 elog(DEBUG_elog_output,
5620 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
5640 if (Np->
sign ==
'-')
5654 else if (Np->
sign ==
'+')
5663 else if (Np->
sign ==
'-')
5778 if (Np->
sign ==
'-')
5800 if (strchr(
"0123456789.,+-", *Np->
inout_p) != NULL)
5808 char *number,
int input_len,
int to_char_out_pre_spaces,
5814 const char *pattern;
5835 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5836 errmsg(
"\"EEEE\" not supported for input")));
5837 return strcpy(inout, number);
5857 if (Np->
sign !=
'-')
5860 Np->
Num->
flag &= ~NUM_F_BRACKET;
5900 last_zero_pos = strlen(Np->
number) - 1;
5901 last_zero_pos =
Min(last_zero_pos,
5903 last_zero = Np->
number + last_zero_pos;
5916 *(Np->
number + 1) =
'\0';
5922#ifdef DEBUG_TO_FROM_CHAR
5923 elog(DEBUG_elog_output,
5924 "\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",
6032 pattern_len = strlen(pattern);
6043 memset(Np->
inout_p,
' ', pattern_len);
6044 Np->
inout_p += pattern_len - 1;
6050 Np->
inout_p += pattern_len - 1;
6068 strncmp(Np->
inout_p, pattern, pattern_len) == 0)
6069 Np->
inout_p += pattern_len - 1;
6080 Np->
inout_p += strlen(pattern) - 1;
6093 const char *number_p;
6100 strcpy(Np->
inout_p, number_p);
6110 if (roman_result < 0)
6112 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
6113 errmsg(
"invalid Roman numeral")));
6161 if (Np->
sign ==
'-')
6183 if (Np->
sign ==
'+')
6263#ifdef DEBUG_TO_FROM_CHAR
6264 elog(DEBUG_elog_output,
"TO_NUMBER (number): '%s'", Np->
number);
6275#define NUM_TOCHAR_prepare \
6277 int len = VARSIZE_ANY_EXHDR(fmt); \
6278 if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
6279 PG_RETURN_TEXT_P(cstring_to_text("")); \
6280 result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
6281 format = NUM_cache(len, &Num, fmt, &shouldFree); \
6288#define NUM_TOCHAR_finish \
6292 NUM_processor(format, &Num, VARDATA(result), numstr, 0, out_pre_spaces, sign, true, PG_GET_COLLATION()); \
6302 len = strlen(VARDATA(result)); \
6303 SET_VARSIZE(result, len + VARHDRSZ); \
6378 int out_pre_spaces = 0,
6411 if (strcmp(orgnum,
"NaN") == 0 ||
6412 strcmp(orgnum,
"Infinity") == 0 ||
6413 strcmp(orgnum,
"-Infinity") == 0)
6422 *(numstr + Num.
pre + 1) =
'.';
6424 else if (*orgnum !=
'-')
6426 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6428 strcpy(numstr + 1, orgnum);
6464 numstr = orgnum + 1;
6472 if ((p = strchr(numstr,
'.')))
6473 numstr_pre_len = p - numstr;
6475 numstr_pre_len = strlen(numstr);
6478 if (numstr_pre_len < Num.
pre)
6479 out_pre_spaces = Num.
pre - numstr_pre_len;
6481 else if (numstr_pre_len > Num.
pre)
6485 *(numstr + Num.
pre) =
'.';
6506 int out_pre_spaces = 0,
6557 numstr_pre_len = strlen(orgnum);
6562 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6563 strcpy(numstr, orgnum);
6564 *(numstr + numstr_pre_len) =
'.';
6565 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6566 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6572 if (numstr_pre_len < Num.
pre)
6573 out_pre_spaces = Num.
pre - numstr_pre_len;
6575 else if (numstr_pre_len > Num.
pre)
6579 *(numstr + Num.
pre) =
'.';
6600 int out_pre_spaces = 0,
6634 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6636 strcpy(numstr + 1, orgnum);
6649 double multi = pow((
double) 10, (
double) Num.
multi);
6669 numstr_pre_len = strlen(orgnum);
6674 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6675 strcpy(numstr, orgnum);
6676 *(numstr + numstr_pre_len) =
'.';
6677 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6678 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6684 if (numstr_pre_len < Num.
pre)
6685 out_pre_spaces = Num.
pre - numstr_pre_len;
6687 else if (numstr_pre_len > Num.
pre)
6691 *(numstr + Num.
pre) =
'.';
6712 int out_pre_spaces = 0,
6743 *(numstr + Num.
pre + 1) =
'.';
6764 float multi = pow((
double) 10, (
double) Num.
multi);
6771 numstr_pre_len = strlen(orgnum);
6774 if (numstr_pre_len >= FLT_DIG)
6776 else if (numstr_pre_len + Num.
post > FLT_DIG)
6777 Num.
post = FLT_DIG - numstr_pre_len;
6783 numstr = orgnum + 1;
6791 if ((p = strchr(numstr,
'.')))
6792 numstr_pre_len = p - numstr;
6794 numstr_pre_len = strlen(numstr);
6797 if (numstr_pre_len < Num.
pre)
6798 out_pre_spaces = Num.
pre - numstr_pre_len;
6800 else if (numstr_pre_len > Num.
pre)
6804 *(numstr + Num.
pre) =
'.';
6825 int out_pre_spaces = 0,
6856 *(numstr + Num.
pre + 1) =
'.';
6877 double multi = pow((
double) 10, (
double) Num.
multi);
6884 numstr_pre_len = strlen(orgnum);
6887 if (numstr_pre_len >= DBL_DIG)
6889 else if (numstr_pre_len + Num.
post > DBL_DIG)
6890 Num.
post = DBL_DIG - numstr_pre_len;
6896 numstr = orgnum + 1;
6904 if ((p = strchr(numstr,
'.')))
6905 numstr_pre_len = p - numstr;
6907 numstr_pre_len = strlen(numstr);
6910 if (numstr_pre_len < Num.
pre)
6911 out_pre_spaces = Num.
pre - numstr_pre_len;
6913 else if (numstr_pre_len > Num.
pre)
6917 *(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)