60#ifdef DEBUG_TO_FROM_CHAR
61#define DEBUG_elog_output DEBUG3
97#define KeyWord_INDEX_SIZE ('~' - ' ')
98#define KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1)
103#define DCH_MAX_ITEM_SIZ 12
104#define NUM_MAX_ITEM_SIZ 8
170 "January",
"February",
"March",
"April",
"May",
"June",
"July",
171 "August",
"September",
"October",
"November",
"December", NULL
175 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat", NULL
185#define ADJUST_YEAR(year, is_interval) ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year)))
187#define A_D_STR "A.D."
188#define a_d_STR "a.d."
192#define B_C_STR "B.C."
193#define b_c_STR "b.c."
213#define A_M_STR "A.M."
214#define a_m_STR "a.m."
218#define P_M_STR "P.M."
219#define p_m_STR "p.m."
242{
"XII",
"XI",
"X",
"IX",
"VIII",
"VII",
"VI",
"V",
"IV",
"III",
"II",
"I", NULL};
245{
"xii",
"xi",
"x",
"ix",
"viii",
"vii",
"vi",
"v",
"iv",
"iii",
"ii",
"i", NULL};
250static const char *
const rm1[] = {
"I",
"II",
"III",
"IV",
"V",
"VI",
"VII",
"VIII",
"IX", NULL};
251static const char *
const rm10[] = {
"X",
"XX",
"XXX",
"XL",
"L",
"LX",
"LXX",
"LXXX",
"XC", NULL};
252static const char *
const rm100[] = {
"C",
"CC",
"CCC",
"CD",
"D",
"DC",
"DCC",
"DCCC",
"CM", NULL};
258#define IS_VALID_SUB_COMB(curr, next) \
259 (((curr) == 'I' && ((next) == 'V' || (next) == 'X')) || \
260 ((curr) == 'X' && ((next) == 'L' || (next) == 'C')) || \
261 ((curr) == 'C' && ((next) == 'D' || (next) == 'M')))
266#define ROMAN_VAL(r) \
273 (r) == 'M' ? 1000 : 0)
278#define MAX_ROMAN_LEN 15
283static const char *
const numTH[] = {
"ST",
"ND",
"RD",
"TH", NULL};
284static const char *
const numth[] = {
"st",
"nd",
"rd",
"th", NULL};
321#define NUM_F_DECIMAL (1 << 1)
322#define NUM_F_LDECIMAL (1 << 2)
323#define NUM_F_ZERO (1 << 3)
324#define NUM_F_BLANK (1 << 4)
325#define NUM_F_FILLMODE (1 << 5)
326#define NUM_F_LSIGN (1 << 6)
327#define NUM_F_BRACKET (1 << 7)
328#define NUM_F_MINUS (1 << 8)
329#define NUM_F_PLUS (1 << 9)
330#define NUM_F_ROMAN (1 << 10)
331#define NUM_F_MULTI (1 << 11)
332#define NUM_F_PLUS_POST (1 << 12)
333#define NUM_F_MINUS_POST (1 << 13)
334#define NUM_F_EEEE (1 << 14)
339#define IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL)
340#define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL)
341#define IS_ZERO(_f) ((_f)->flag & NUM_F_ZERO)
342#define IS_BLANK(_f) ((_f)->flag & NUM_F_BLANK)
343#define IS_FILLMODE(_f) ((_f)->flag & NUM_F_FILLMODE)
344#define IS_BRACKET(_f) ((_f)->flag & NUM_F_BRACKET)
345#define IS_MINUS(_f) ((_f)->flag & NUM_F_MINUS)
346#define IS_LSIGN(_f) ((_f)->flag & NUM_F_LSIGN)
347#define IS_PLUS(_f) ((_f)->flag & NUM_F_PLUS)
348#define IS_ROMAN(_f) ((_f)->flag & NUM_F_ROMAN)
349#define IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI)
350#define IS_EEEE(_f) ((_f)->flag & NUM_F_EEEE)
369#define DCH_CACHE_OVERHEAD \
370 MAXALIGN(sizeof(bool) + sizeof(int))
371#define NUM_CACHE_OVERHEAD \
372 MAXALIGN(sizeof(bool) + sizeof(int) + sizeof(NUMDesc))
374#define DCH_CACHE_SIZE \
375 ((2048 - DCH_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1)
376#define NUM_CACHE_SIZE \
377 ((1024 - NUM_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1)
379#define DCH_CACHE_ENTRIES 20
380#define NUM_CACHE_ENTRIES 20
454#ifdef DEBUG_TO_FROM_CHAR
455#define DEBUG_TMFC(_X) \
456 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", \
457 (_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
458 (_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
459 (_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
460 (_X)->yysz, (_X)->clock_12_hour)
461#define DEBUG_TM(_X) \
462 elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
463 (_X)->tm_sec, (_X)->tm_year,\
464 (_X)->tm_min, (_X)->tm_wday, (_X)->tm_hour, (_X)->tm_yday,\
465 (_X)->tm_mday, (_X)->tm_isdst, (_X)->tm_mon)
467#define DEBUG_TMFC(_X)
498#define tmtcTm(_X) (&(_X)->tm)
499#define tmtcTzn(_X) ((_X)->tzn)
500#define tmtcFsec(_X) ((_X)->fsec)
503#define COPY_tm(_DST, _SRC) \
505 (_DST)->tm_sec = (_SRC)->tm_sec; \
506 (_DST)->tm_min = (_SRC)->tm_min; \
507 (_DST)->tm_hour = (_SRC)->tm_hour; \
508 (_DST)->tm_mday = (_SRC)->tm_mday; \
509 (_DST)->tm_mon = (_SRC)->tm_mon; \
510 (_DST)->tm_year = (_SRC)->tm_year; \
511 (_DST)->tm_wday = (_SRC)->tm_wday; \
512 (_DST)->tm_yday = (_SRC)->tm_yday; \
513 (_DST)->tm_gmtoff = (_SRC)->tm_gmtoff; \
519 memset(_X, 0, sizeof(*(_X))); \
520 (_X)->tm_mday = (_X)->tm_mon = 1; \
523#define ZERO_tmtc(_X) \
525 ZERO_tm( tmtcTm(_X) ); \
527 tmtcTzn(_X) = NULL; \
534#define INVALID_FOR_INTERVAL \
538 (errcode(ERRCODE_INVALID_DATETIME_FORMAT), \
539 errmsg("invalid format specification for an interval value"), \
540 errhint("Intervals are not tied to specific calendar dates."))); \
550#define DCH_SUFFIX_FM 0x01
551#define DCH_SUFFIX_TH 0x02
552#define DCH_SUFFIX_th 0x04
553#define DCH_SUFFIX_SP 0x08
554#define DCH_SUFFIX_TM 0x10
599#define TM_SUFFIX_LEN 2
982 -1, -1, -1, -1, -1, -1, -1, -1,
983 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
984 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
985 -1, -1, -1, -1, -1,
DCH_A_D,
DCH_B_C,
DCH_CC,
DCH_DAY, -1,
986 DCH_FF1, -1,
DCH_HH24,
DCH_IDDD,
DCH_J, -1, -1,
DCH_MI, -1,
DCH_OF,
987 DCH_P_M,
DCH_Q,
DCH_RM,
DCH_SSSSS,
DCH_TZH,
DCH_US, -1,
DCH_WW, -1,
DCH_Y_YYY,
988 -1, -1, -1, -1, -1, -1, -1,
DCH_a_d,
DCH_b_c,
DCH_cc,
989 DCH_day, -1,
DCH_ff1, -1,
DCH_hh24,
DCH_iddd,
DCH_j, -1, -1,
DCH_mi,
990 -1,
DCH_of,
DCH_p_m,
DCH_q,
DCH_rm,
DCH_sssss,
DCH_tzh,
DCH_us, -1,
DCH_ww,
1005 -1, -1, -1, -1, -1, -1, -1, -1,
1006 -1, -1, -1, -1,
NUM_COMMA, -1,
NUM_DEC, -1,
NUM_0, -1,
1007 -1, -1, -1, -1, -1, -1, -1,
NUM_9, -1, -1,
1008 -1, -1, -1, -1, -1, -1,
NUM_B,
NUM_C,
NUM_D,
NUM_E,
1009 NUM_FM,
NUM_G, -1, -1, -1, -1,
NUM_L,
NUM_MI, -1, -1,
1010 NUM_PL, -1,
NUM_RN,
NUM_SG,
NUM_TH, -1,
NUM_V, -1, -1, -1,
1011 -1, -1, -1, -1, -1, -1, -1, -1,
NUM_b,
NUM_c,
1012 NUM_d,
NUM_e,
NUM_fm,
NUM_g, -1, -1, -1, -1,
NUM_l,
NUM_mi,
1013 -1, -1,
NUM_pl, -1,
NUM_rn,
NUM_sg,
NUM_th, -1,
NUM_v, -1,
1014 -1, -1, -1, -1, -1, -1
1053#define DCH_DATED 0x01
1054#define DCH_TIMED 0x02
1055#define DCH_ZONED 0x04
1062#define OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len)
1063#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);
1103 const char *
const *array,
1118 char *number,
size_t input_len,
int to_char_out_pre_spaces,
1141 if ((poz =
index[*
str -
' ']) > -1)
1162 if (s->type !=
type)
1165 if (strncmp(
str, s->name, s->len) == 0)
1175 return (*
str > 0x20 && *
str < 0x7F &&
1176 !(*
str >=
'A' && *
str <=
'Z') &&
1177 !(*
str >=
'a' && *
str <=
'z') &&
1178 !(*
str >=
'0' && *
str <=
'9'));
1192 (
errcode(ERRCODE_SYNTAX_ERROR),
1193 errmsg(
"\"EEEE\" must be the last pattern used")));
1200 (
errcode(ERRCODE_SYNTAX_ERROR),
1201 errmsg(
"\"9\" must be ahead of \"PR\"")));
1216 (
errcode(ERRCODE_SYNTAX_ERROR),
1217 errmsg(
"\"0\" must be ahead of \"PR\"")));
1243 (
errcode(ERRCODE_SYNTAX_ERROR),
1244 errmsg(
"multiple decimal points")));
1247 (
errcode(ERRCODE_SYNTAX_ERROR),
1248 errmsg(
"cannot use \"V\" and decimal point together")));
1259 (
errcode(ERRCODE_SYNTAX_ERROR),
1260 errmsg(
"cannot use \"S\" twice")));
1263 (
errcode(ERRCODE_SYNTAX_ERROR),
1264 errmsg(
"cannot use \"S\" and \"PL\"/\"MI\"/\"SG\"/\"PR\" together")));
1283 (
errcode(ERRCODE_SYNTAX_ERROR),
1284 errmsg(
"cannot use \"S\" and \"MI\" together")));
1293 (
errcode(ERRCODE_SYNTAX_ERROR),
1294 errmsg(
"cannot use \"S\" and \"PL\" together")));
1303 (
errcode(ERRCODE_SYNTAX_ERROR),
1304 errmsg(
"cannot use \"S\" and \"SG\" together")));
1312 (
errcode(ERRCODE_SYNTAX_ERROR),
1313 errmsg(
"cannot use \"PR\" and \"S\"/\"PL\"/\"MI\"/\"SG\" together")));
1321 (
errcode(ERRCODE_SYNTAX_ERROR),
1322 errmsg(
"cannot use \"RN\" twice")));
1334 (
errcode(ERRCODE_SYNTAX_ERROR),
1335 errmsg(
"cannot use \"V\" and decimal point together")));
1342 (
errcode(ERRCODE_SYNTAX_ERROR),
1343 errmsg(
"cannot use \"EEEE\" twice")));
1348 (
errcode(ERRCODE_SYNTAX_ERROR),
1349 errmsg(
"\"EEEE\" is incompatible with other formats"),
1350 errdetail(
"\"EEEE\" may only be used together with digit and decimal point patterns.")));
1358 (
errcode(ERRCODE_SYNTAX_ERROR),
1359 errmsg(
"\"RN\" is incompatible with other formats"),
1360 errdetail(
"\"RN\" may only be used together with \"FM\".")));
1375#ifdef DEBUG_TO_FROM_CHAR
1376 elog(DEBUG_elog_output,
"to_char/number(): run parser");
1437 if (strchr(
"-./,':; ", *
str) == NULL)
1439 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
1440 errmsg(
"invalid datetime format separator: \"%s\"",
1455 else if (*
str ==
'"')
1469 if (*
str ==
'\\' && *(
str + 1))
1487 if (*
str ==
'\\' && *(
str + 1) ==
'"')
1493 else if (isspace((
unsigned char) *
str))
1515#ifdef DEBUG_TO_FROM_CHAR
1517#define DUMP_THth(_suf) (IS_SUFFIX_TH(_suf) ? "TH" : (IS_SUFFIX_th(_suf) ? "th" : " "))
1518#define DUMP_FM(_suf) (IS_SUFFIX_FM(_suf) ? "FM" : " ")
1526 elog(DEBUG_elog_output,
"to_from-char(): DUMP FORMAT");
1528 for (
a = 0, n = node;
a <= max; n++,
a++)
1531 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)",
1534 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_CHAR '%s'",
1538 elog(DEBUG_elog_output,
"%d:\t NODE_TYPE_END",
a);
1542 elog(DEBUG_elog_output,
"%d:\t unknown NODE!",
a);
1557 size_t len = strlen(num);
1562 last = num[
len - 1];
1563 if (!isdigit((
unsigned char) last))
1565 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1566 errmsg(
"\"%s\" is not a number", num)));
1572 if (
len > 1 && num[
len - 2] ==
'1')
1634 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1635 errmsg(
"could not determine which collation to use for %s function",
1637 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1649 const char *src = buff;
1650 size_t srclen = nbytes;
1656 dstsize = srclen + 1;
1659 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1660 if (needed + 1 > dstsize)
1663 dstsize = needed + 1;
1665 needed =
pg_strlower(dst, dstsize, src, srclen, mylocale);
1666 Assert(needed + 1 <= dstsize);
1669 Assert(dst[needed] ==
'\0');
1698 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1699 errmsg(
"could not determine which collation to use for %s function",
1701 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1713 const char *src = buff;
1714 size_t srclen = nbytes;
1720 dstsize = srclen + 1;
1723 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1724 if (needed + 1 > dstsize)
1727 dstsize = needed + 1;
1729 needed =
pg_strupper(dst, dstsize, src, srclen, mylocale);
1730 Assert(needed + 1 <= dstsize);
1733 Assert(dst[needed] ==
'\0');
1762 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1763 errmsg(
"could not determine which collation to use for %s function",
1765 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1777 const char *src = buff;
1778 size_t srclen = nbytes;
1784 dstsize = srclen + 1;
1787 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1788 if (needed + 1 > dstsize)
1791 dstsize = needed + 1;
1793 needed =
pg_strtitle(dst, dstsize, src, srclen, mylocale);
1794 Assert(needed + 1 <= dstsize);
1797 Assert(dst[needed] ==
'\0');
1826 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
1827 errmsg(
"could not determine which collation to use for %s function",
1829 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
1834 (
errcode(ERRCODE_SYNTAX_ERROR),
1835 errmsg(
"Unicode case folding can only be performed if server encoding is UTF8")));
1846 const char *src = buff;
1847 size_t srclen = nbytes;
1853 dstsize = srclen + 1;
1856 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1857 if (needed + 1 > dstsize)
1860 dstsize = needed + 1;
1862 needed =
pg_strfold(dst, dstsize, src, srclen, mylocale);
1863 Assert(needed + 1 <= dstsize);
1866 Assert(dst[needed] ==
'\0');
1889 for (
char *p = result; *p; p++)
1911 for (
char *p = result; *p; p++)
1927 int wasalnum =
false;
1934 for (
char *p = result; *p; p++)
1943 wasalnum = ((
c >=
'A' &&
c <=
'Z') ||
1944 (
c >=
'a' &&
c <=
'z') ||
1945 (
c >=
'0' &&
c <=
'9'));
1991#define SKIP_THth(ptr, _suf) \
1993 if (IS_SUFFIX_THth(_suf)) \
1995 if (*(ptr)) (ptr) += pg_mblen(ptr); \
1996 if (*(ptr)) (ptr) += pg_mblen(ptr); \
2001#ifdef DEBUG_TO_FROM_CHAR
2012 elog(DEBUG_elog_output,
"TO-FROM_CHAR: Dump KeyWord Index:");
2024 elog(DEBUG_elog_output,
"\t(%d) %c %d",
i,
i + 32,
index[
i]);
2027 elog(DEBUG_elog_output,
"\n\t\tUsed positions: %d,\n\t\tFree positions: %d",
2061 isdigit((
unsigned char) n->
character[0]))
2079 else if (year < 100)
2082 else if (year < 520)
2085 else if (year < 1000)
2097 while (*
str && isspace((
unsigned char) *
str))
2124 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2125 errmsg(
"invalid combination of date conventions"),
2126 errhint(
"Do not mix Gregorian and ISO week date conventions in a formatting template.")));
2146 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2147 errmsg(
"conflicting values for \"%s\" field in formatting string",
2149 errdetail(
"This value contradicts a previous setting for the same field type.")));
2181 const char *
init = *src;
2201 result = strtol(
init, &endptr, 10);
2214 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2215 errmsg(
"source string too short for \"%s\" formatting field",
2217 errdetail(
"Field requires %zu characters, but only %zu remain.",
2219 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2222 result = strtol(copy, &last, 10);
2225 if (used > 0 && used <
len)
2227 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2228 errmsg(
"invalid value \"%s\" for \"%s\"",
2230 errdetail(
"Field requires %zu characters, but only %zu could be parsed.",
2232 errhint(
"If your source string is not fixed-width, try using the \"FM\" modifier.")));
2239 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2240 errmsg(
"invalid value \"%s\" for \"%s\"",
2242 errdetail(
"Value must be an integer.")));
2244 if (errno == ERANGE || result < INT_MIN || result > INT_MAX)
2246 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2247 errmsg(
"value for \"%s\" in source string is out of range",
2249 errdetail(
"Value must be in the range %d to %d.",
2250 INT_MIN, INT_MAX)));
2291 unsigned char firstc;
2302 for (
const char *
const *
a = array; *
a != NULL;
a++)
2309 for (
const char *p = *
a + 1, *n =
name + 1;; p++, n++)
2357 for (
char **
a = array; *
a != NULL;
a++)
2359 size_t element_len = strlen(*
a);
2361 if (strncmp(
name, *
a, element_len) == 0)
2376 for (
char **
a = array; *
a != NULL;
a++)
2378 char *upper_element;
2379 char *lower_element;
2384 lower_element =
str_tolower(upper_element, strlen(upper_element),
2386 pfree(upper_element);
2387 element_len = strlen(lower_element);
2390 if (strncmp(lower_name, lower_element, element_len) == 0)
2393 pfree(lower_element);
2397 pfree(lower_element);
2431 if (localized_array == NULL)
2444 for (
char *
c = copy; *
c;
c++)
2454 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
2455 errmsg(
"invalid value \"%s\" for \"%s\"",
2457 errdetail(
"The given value did not match any of the allowed values for this field.")));
2550#define DCH_to_char_fsec(frac_fmt, frac_val) \
2551 sprintf(s, frac_fmt, (int) (frac_val)); \
2552 if (IS_SUFFIX_THth(n->suffix)) \
2553 str_numth(s, s, SUFFIX_TH_TYPE(n->suffix)); \
2576#undef DCH_to_char_fsec
2669 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2670 errmsg(
"localized string format value too long")));
2689 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2690 errmsg(
"localized string format value too long")));
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")));
2748 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2749 errmsg(
"localized string format value too long")));
2767 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2768 errmsg(
"localized string format value too long")));
2791 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2792 errmsg(
"localized string format value too long")));
2809 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2810 errmsg(
"localized string format value too long")));
2827 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2828 errmsg(
"localized string format value too long")));
2845 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
2846 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")));
2950 if (i <= 99 && i >= -99)
2991 is_interval)) % 1000);
3006 is_interval)) % 100);
3019 is_interval)) % 10);
3037 const char *
const *
months;
3138 while (*s !=
'\0' && isspace((
unsigned char) *s))
3159 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3160 errmsg(
"unmatched format separator \"%c\"",
3220 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3221 errmsg(
"unmatched format character \"%s\"",
3291 out->
ms *=
len == 1 ? 100 :
3307 out->
ff, n, escontext);
3311 out->
us *=
len == 1 ? 100000 :
3342 else if (isalpha((
unsigned char) *s))
3351 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3353 errdetail(
"Time zone abbreviation is not recognized.")));
3361 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3363 out->
tzsign = *s ==
'-' ? -1 : +1;
3368 if (extra_skip > 0 && *(s - 1) ==
'-')
3392 if (*s ==
'+' || *s ==
'-' || *s ==
' ')
3394 out->
tzsign = *s ==
'-' ? -1 : +1;
3399 if (extra_skip > 0 && *(s - 1) ==
'-')
3550 matched = sscanf(s,
"%d,%03d%n", &millennia, &years, &nch);
3553 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3554 errmsg(
"invalid value \"%s\" for \"%s\"", s,
"Y,YYY")));
3560 (
errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
3561 errmsg(
"value for \"%s\" in source string is out of range",
"Y,YYY")));
3633 while (*s !=
'\0' && isspace((
unsigned char) *s))
3649 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3650 errmsg(
"input string is too short for datetime format")));
3652 while (*s !=
'\0' && isspace((
unsigned char) *s))
3657 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
3658 errmsg(
"trailing characters remain in input string after datetime format")));
3794#ifdef DEBUG_TO_FROM_CHAR
3811#ifdef DEBUG_TO_FROM_CHAR
3812 elog(DEBUG_elog_output,
"OLD: '%s' AGE: %d", old->
str, old->
age);
3822#ifdef DEBUG_TO_FROM_CHAR
3901 fmt_len = strlen(fmt_str);
3974 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3975 errmsg(
"timestamp out of range")));
3979 tt.
tm_wday = (thisdate + 1) % 7;
4010 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4011 errmsg(
"timestamp out of range")));
4015 tt.
tm_wday = (thisdate + 1) % 7;
4085 &
tm, &fsec, &ftz, &fprec, NULL, NULL);
4095 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4096 errmsg(
"timestamp out of range")));
4121 &
tm, &fsec, &ftz, NULL, NULL, NULL);
4126 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4134 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4157 Oid *typid,
int32 *typmod,
int *tz,
4167 &
tm, &fsec, &ftz, &fprec, &flags, escontext))
4170 *typmod = fprec ? fprec : -1;
4194 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4195 errmsg(
"missing time zone in input string for type timestamptz")));
4200 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4201 errmsg(
"timestamptz out of range")));
4205 *typid = TIMESTAMPTZOID;
4214 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4215 errmsg(
"timestamp out of range")));
4219 *typid = TIMESTAMPOID;
4228 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4229 errmsg(
"datetime format is zoned but not timed")));
4238 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4247 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4275 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4276 errmsg(
"missing time zone in input string for type timetz")));
4281 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4282 errmsg(
"timetz out of range")));
4295 (
errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4296 errmsg(
"time out of range")));
4307 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4308 errmsg(
"datetime format is not dated and not timed")));
4320 size_t fmt_len = strlen(fmt_str);
4389 bool incache =
false;
4435#ifdef DEBUG_TO_FROM_CHAR
4483 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4485 errhint(
"Use the 24-hour clock, or give an hour between 1 and 12.")));
4503 if (tmfc.
cc && tmfc.
yysz <= 2)
4620 date_str,
"timestamp", escontext);
4634 date_str,
"timestamp", escontext);
4661 (
errcode(ERRCODE_INVALID_DATETIME_FORMAT),
4662 errmsg(
"cannot calculate day of year without year information")));
4680 static const int ysum[2][13] = {
4681 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
4682 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}};
4688 if (tmfc.
ddd <=
y[
i])
4710 date_str,
"timestamp", escontext);
4733 date_str,
"timestamp", escontext);
4745 date_str,
"timestamp", escontext);
4761 date_str,
"timestamp", escontext);
4775 if (tmfc.
tzp == NULL)
4817 memset(
str,
c, max);
4849#ifdef DEBUG_TO_FROM_CHAR
4866#ifdef DEBUG_TO_FROM_CHAR
4867 elog(DEBUG_elog_output,
"OLD: \"%s\" AGE: %d", old->
str, old->
age);
4877#ifdef DEBUG_TO_FROM_CHAR
4928 memset(&ent->
Num, 0,
sizeof ent->
Num);
4959 memset(Num, 0,
sizeof *Num);
4971 *shouldFree =
false;
4989#ifdef DEBUG_TO_FROM_CHAR
5020 if (number > 3999 || number < 1)
5027 len =
snprintf(numstr,
sizeof(numstr),
"%d", number);
5030 for (
char *p = numstr; *p !=
'\0'; p++, --
len)
5032 num = *p - (
'0' + 1);
5040 strcat(result,
"M");
5043 strcat(result,
rm100[num]);
5046 strcat(result,
rm10[num]);
5049 strcat(result,
rm1[num]);
5070 int repeatCount = 1;
5074 bool subtractionEncountered =
false;
5075 int lastSubtractedValue = 0;
5097 romanChars[
len] = currChar;
5098 romanValues[
len] = currValue;
5106 for (
size_t i = 0;
i <
len;
i++)
5108 char currChar = romanChars[
i];
5109 int currValue = romanValues[
i];
5115 if (subtractionEncountered && currValue >= lastSubtractedValue)
5122 if ((vCount && currValue >=
ROMAN_VAL(
'V')) ||
5123 (lCount && currValue >=
ROMAN_VAL(
'L')) ||
5124 (dCount && currValue >=
ROMAN_VAL(
'D')))
5126 if (currChar ==
'V')
5128 else if (currChar ==
'L')
5130 else if (currChar ==
'D')
5136 char nextChar = romanChars[
i + 1];
5137 int nextValue = romanValues[
i + 1];
5144 if (currValue < nextValue)
5153 if (repeatCount > 1)
5161 if ((vCount && nextValue >=
ROMAN_VAL(
'V')) ||
5162 (lCount && nextValue >=
ROMAN_VAL(
'L')) ||
5163 (dCount && nextValue >=
ROMAN_VAL(
'D')))
5165 if (nextChar ==
'V')
5167 else if (nextChar ==
'L')
5169 else if (nextChar ==
'D')
5180 subtractionEncountered =
true;
5181 lastSubtractedValue = currValue;
5182 result += (nextValue - currValue);
5187 if (currChar == nextChar)
5190 if (repeatCount > 3)
5195 result += currValue;
5201 result += currValue;
5217 struct lconv *lconv;
5227 if (lconv->negative_sign && *lconv->negative_sign)
5232 if (lconv->positive_sign && *lconv->positive_sign)
5240 if (lconv->decimal_point && *lconv->decimal_point)
5241 Np->
decimal = lconv->decimal_point;
5256 if (lconv->thousands_sep && *lconv->thousands_sep)
5259 else if (strcmp(Np->
decimal,
",") != 0)
5267 if (lconv->currency_symbol && *lconv->currency_symbol)
5297 *p = strchr(num,
'.');
5299#ifdef DEBUG_TO_FROM_CHAR
5300 elog(DEBUG_elog_output,
"get_last_relevant_decnum()");
5323 bool isread =
false;
5325#ifdef DEBUG_TO_FROM_CHAR
5326 elog(DEBUG_elog_output,
" --- scan start --- id=%s",
5345#ifdef DEBUG_TO_FROM_CHAR
5346 elog(DEBUG_elog_output,
"Try read sign (%c), locale positive: %s, negative: %s",
5357#ifdef DEBUG_TO_FROM_CHAR
5358 elog(DEBUG_elog_output,
"Try read locale pre-sign (%c)", *Np->
inout_p);
5377#ifdef DEBUG_TO_FROM_CHAR
5378 elog(DEBUG_elog_output,
"Try read simple sign (%c)", *Np->
inout_p);
5401#ifdef DEBUG_TO_FROM_CHAR
5402 elog(DEBUG_elog_output,
"Scan for numbers (%c), current number: '%s'", *Np->
inout_p, Np->
number);
5408 if (isdigit((
unsigned char) *Np->
inout_p))
5423#ifdef DEBUG_TO_FROM_CHAR
5424 elog(DEBUG_elog_output,
"Read digit (%c)", *Np->
inout_p);
5436#ifdef DEBUG_TO_FROM_CHAR
5437 elog(DEBUG_elog_output,
"Try read decimal point (%c)",
5471 !isdigit((
unsigned char) *(Np->
inout_p + 1)))
5476#ifdef DEBUG_TO_FROM_CHAR
5477 elog(DEBUG_elog_output,
"Try read locale post-sign (%c)", *Np->
inout_p);
5508 else if (isread ==
false &&
IS_LSIGN(Np->
Num) ==
false &&
5511#ifdef DEBUG_TO_FROM_CHAR
5512 elog(DEBUG_elog_output,
"Try read simple post-sign (%c)", *Np->
inout_p);
5525#define IS_PREDEC_SPACE(_n) \
5526 (IS_ZERO((_n)->Num)==false && \
5527 (_n)->number == (_n)->number_p && \
5528 *(_n)->number == '0' && \
5529 (_n)->Num->post != 0)
5544#ifdef DEBUG_TO_FROM_CHAR
5550 elog(DEBUG_elog_output,
5551 "SIGN_WROTE: %d, CURRENT: %d, NUMBER_P: \"%s\", INOUT: \"%s\"",
5571 if (Np->
sign ==
'-')
5585 else if (Np->
sign ==
'+')
5594 else if (Np->
sign ==
'-')
5709 if (Np->
sign ==
'-')
5731 if (strchr(
"0123456789.,+-", *Np->
inout_p) != NULL)
5739 char *number,
size_t input_len,
int to_char_out_pre_spaces,
5745 const char *pattern;
5766 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5767 errmsg(
"\"EEEE\" not supported for input")));
5768 return strcpy(inout, number);
5788 if (Np->
sign !=
'-')
5791 Np->
Num->
flag &= ~NUM_F_BRACKET;
5827 size_t last_zero_pos;
5831 last_zero_pos = strlen(Np->
number) - 1;
5832 last_zero_pos =
Min(last_zero_pos,
5834 last_zero = Np->
number + last_zero_pos;
5847 *(Np->
number + 1) =
'\0';
5853#ifdef DEBUG_TO_FROM_CHAR
5854 elog(DEBUG_elog_output,
5855 "\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",
5963 pattern_len = strlen(pattern);
5974 memset(Np->
inout_p,
' ', pattern_len);
5975 Np->
inout_p += pattern_len - 1;
5981 Np->
inout_p += pattern_len - 1;
5999 strncmp(Np->
inout_p, pattern, pattern_len) == 0)
6000 Np->
inout_p += pattern_len - 1;
6011 Np->
inout_p += strlen(pattern) - 1;
6024 const char *number_p;
6031 strcpy(Np->
inout_p, number_p);
6041 if (roman_result < 0)
6043 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
6044 errmsg(
"invalid Roman numeral")));
6092 if (Np->
sign ==
'-')
6114 if (Np->
sign ==
'+')
6194#ifdef DEBUG_TO_FROM_CHAR
6195 elog(DEBUG_elog_output,
"TO_NUMBER (number): '%s'", Np->
number);
6205#define NUM_TOCHAR_prepare \
6207 int len = VARSIZE_ANY_EXHDR(fmt); \
6208 if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
6209 PG_RETURN_TEXT_P(cstring_to_text("")); \
6210 result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
6211 format = NUM_cache(len, &Num, fmt, &shouldFree); \
6217#define NUM_TOCHAR_finish \
6221 NUM_processor(format, &Num, VARDATA(result), numstr, 0, out_pre_spaces, sign, true, PG_GET_COLLATION()); \
6231 len = strlen(VARDATA(result)); \
6232 SET_VARSIZE(result, len + VARHDRSZ); \
6305 int out_pre_spaces = 0,
6338 if (strcmp(orgnum,
"NaN") == 0 ||
6339 strcmp(orgnum,
"Infinity") == 0 ||
6340 strcmp(orgnum,
"-Infinity") == 0)
6349 *(numstr + Num.
pre + 1) =
'.';
6351 else if (*orgnum !=
'-')
6353 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6355 strcpy(numstr + 1, orgnum);
6364 size_t numstr_pre_len;
6391 numstr = orgnum + 1;
6399 if ((p = strchr(numstr,
'.')))
6400 numstr_pre_len = p - numstr;
6402 numstr_pre_len = strlen(numstr);
6405 if (numstr_pre_len < Num.
pre)
6406 out_pre_spaces = Num.
pre - numstr_pre_len;
6408 else if (numstr_pre_len > Num.
pre)
6412 *(numstr + Num.
pre) =
'.';
6432 int out_pre_spaces = 0,
6461 size_t numstr_pre_len;
6483 numstr_pre_len = strlen(orgnum);
6488 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6489 strcpy(numstr, orgnum);
6490 *(numstr + numstr_pre_len) =
'.';
6491 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6492 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6498 if (numstr_pre_len < Num.
pre)
6499 out_pre_spaces = Num.
pre - numstr_pre_len;
6501 else if (numstr_pre_len > Num.
pre)
6505 *(numstr + Num.
pre) =
'.';
6525 int out_pre_spaces = 0,
6559 numstr = (
char *)
palloc(strlen(orgnum) + 2);
6561 strcpy(numstr + 1, orgnum);
6570 size_t numstr_pre_len;
6574 double multi = pow((
double) 10, (
double) Num.
multi);
6594 numstr_pre_len = strlen(orgnum);
6599 numstr = (
char *)
palloc(numstr_pre_len + Num.
post + 2);
6600 strcpy(numstr, orgnum);
6601 *(numstr + numstr_pre_len) =
'.';
6602 memset(numstr + numstr_pre_len + 1,
'0', Num.
post);
6603 *(numstr + numstr_pre_len + Num.
post + 1) =
'\0';
6609 if (numstr_pre_len < Num.
pre)
6610 out_pre_spaces = Num.
pre - numstr_pre_len;
6612 else if (numstr_pre_len > Num.
pre)
6616 *(numstr + Num.
pre) =
'.';
6636 int out_pre_spaces = 0,
6667 *(numstr + Num.
pre + 1) =
'.';
6684 size_t numstr_pre_len;
6688 float multi = pow((
double) 10, (
double) Num.
multi);
6695 numstr_pre_len = strlen(orgnum);
6698 if (numstr_pre_len >= FLT_DIG)
6700 else if (numstr_pre_len + Num.
post > FLT_DIG)
6701 Num.
post = FLT_DIG - numstr_pre_len;
6707 numstr = orgnum + 1;
6715 if ((p = strchr(numstr,
'.')))
6716 numstr_pre_len = p - numstr;
6718 numstr_pre_len = strlen(numstr);
6721 if (numstr_pre_len < Num.
pre)
6722 out_pre_spaces = Num.
pre - numstr_pre_len;
6724 else if (numstr_pre_len > Num.
pre)
6728 *(numstr + Num.
pre) =
'.';
6748 int out_pre_spaces = 0,
6779 *(numstr + Num.
pre + 1) =
'.';
6796 size_t numstr_pre_len;
6800 double multi = pow((
double) 10, (
double) Num.
multi);
6807 numstr_pre_len = strlen(orgnum);
6810 if (numstr_pre_len >= DBL_DIG)
6812 else if (numstr_pre_len + Num.
post > DBL_DIG)
6813 Num.
post = DBL_DIG - numstr_pre_len;
6819 numstr = orgnum + 1;
6827 if ((p = strchr(numstr,
'.')))
6828 numstr_pre_len = p - numstr;
6830 numstr_pre_len = strlen(numstr);
6833 if (numstr_pre_len < Num.
pre)
6834 out_pre_spaces = Num.
pre - numstr_pre_len;
6836 else if (numstr_pre_len > Num.
pre)
6840 *(numstr + Num.
pre) =
'.';
int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
void DateTimeParseError(int dterr, DateTimeErrorExtra *extra, const char *str, const char *datatype, Node *escontext)
int ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc, struct pg_tm *tm)
void j2date(int jd, int *year, int *month, int *day)
const char *const months[]
int date2j(int year, int month, int day)
int DecodeTimezoneAbbrevPrefix(const char *str, int *offset, pg_tz **tz)
int DetermineTimeZoneAbbrevOffset(struct pg_tm *tm, const char *abbr, pg_tz *tzp)
char * numeric_out_sci(Numeric num, int scale)
Datum numeric_round(PG_FUNCTION_ARGS)
Numeric int64_to_numeric(int64 val)
int32 numeric_int4_safe(Numeric num, Node *escontext)
Datum numeric_power(PG_FUNCTION_ARGS)
Datum numeric_out(PG_FUNCTION_ARGS)
Datum numeric_in(PG_FUNCTION_ARGS)
Datum numeric_mul(PG_FUNCTION_ARGS)
void isoweek2date(int woy, int *year, int *mon, int *mday)
int isoweek2j(int year, int week)
int date2isoweek(int year, int mon, int mday)
bool AdjustTimestampForTypmod(Timestamp *time, int32 typmod, Node *escontext)
int date2isoyearday(int year, int mon, int mday)
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
void isoweekdate2date(int isoweek, int wday, int *year, int *mon, int *mday)
int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, const char **tzn, pg_tz *attimezone)
void interval2itm(Interval span, struct pg_itm *itm)
int date2isoyear(int year, int mon, int mday)
#define FLOAT4_FITS_IN_INT32(num)
#define FLOAT8_FITS_IN_INT32(num)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
#define INTERVAL_NOT_FINITE(i)
#define IS_VALID_JULIAN(y, m, d)
#define TIMESTAMP_NOT_FINITE(j)
#define POSTGRES_EPOCH_JDATE
int tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result)
int tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result)
void AdjustTimeForTypmod(TimeADT *time, int32 typmod)
static Datum DateADTGetDatum(DateADT X)
#define PG_RETURN_DATEADT(x)
static Datum TimeTzADTPGetDatum(const TimeTzADT *X)
static Datum TimeADTGetDatum(TimeADT X)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define errsave(context,...)
#define ereport(elevel,...)
#define palloc_object(type)
#define PG_GETARG_TEXT_PP(n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_FLOAT8(n)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_INT64(n)
#define PG_RETURN_TEXT_P(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_FLOAT4(n)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
#define PG_GET_COLLATION()
Assert(PointerIsAligned(start, uint64))
#define DTERR_TZDISP_OVERFLOW
#define DTERR_FIELD_OVERFLOW
Datum int8out(PG_FUNCTION_ARGS)
Datum int8mul(PG_FUNCTION_ARGS)
Datum dtoi8(PG_FUNCTION_ARGS)
Datum int4out(PG_FUNCTION_ARGS)
static bool pg_mul_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_sub_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
if(TABLE==NULL||TABLE_index==NULL)
int GetDatabaseEncoding(void)
int pg_mbstrlen(const char *mbstr)
int pg_mblen(const char *mbstr)
void * MemoryContextAllocZero(MemoryContext context, Size size)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
MemoryContext TopMemoryContext
char * pnstrdup(const char *in, Size len)
#define SOFT_ERROR_OCCURRED(escontext)
static Numeric DatumGetNumeric(Datum X)
#define PG_GETARG_NUMERIC(n)
static Datum NumericGetDatum(Numeric X)
static PgChecksumMode mode
void cache_locale_time(void)
char * localized_full_months[12+1]
pg_locale_t pg_newlocale_from_collation(Oid collid)
size_t pg_strfold(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
size_t pg_strlower(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
struct lconv * PGLC_localeconv(void)
size_t pg_strtitle(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
char * localized_abbrev_months[12+1]
char * localized_full_days[7+1]
size_t pg_strupper(char *dst, size_t dstsize, const char *src, ssize_t srclen, pg_locale_t locale)
char * localized_abbrev_days[7+1]
#define MAX_MULTIBYTE_CHAR_LEN
PGDLLIMPORT pg_tz * session_timezone
static unsigned char pg_ascii_tolower(unsigned char ch)
static unsigned char pg_ascii_toupper(unsigned char ch)
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum Int64GetDatum(int64 X)
static int64 DatumGetInt64(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Datum Float8GetDatum(float8 X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
char * psprintf(const char *fmt,...)
bool scanner_isspace(char ch)
FormatNode format[DCH_CACHE_SIZE+1]
char str[DCH_CACHE_SIZE+1]
FromCharDateMode date_mode
char str[NUM_CACHE_SIZE+1]
FormatNode format[NUM_CACHE_SIZE+1]
const char * L_thousands_sep
const char * L_negative_sign
const char * L_currency_symbol
const char * last_relevant
const char * L_positive_sign
static Datum TimestampTzGetDatum(TimestampTz X)
static Datum TimestampGetDatum(Timestamp X)
#define PG_GETARG_TIMESTAMP(n)
#define PG_RETURN_TIMESTAMP(x)
#define PG_GETARG_INTERVAL_P(n)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)