PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <ctype.h>
#include <unistd.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <wchar.h>
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "mb/pg_wchar.h"
#include "parser/scansup.h"
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/datetime.h"
#include "utils/formatting.h"
#include "utils/memutils.h"
#include "utils/numeric.h"
#include "utils/pg_locale.h"
Go to the source code of this file.
Data Structures | |
struct | KeySuffix |
struct | KeyWord |
struct | FormatNode |
struct | NUMDesc |
struct | DCHCacheEntry |
struct | NUMCacheEntry |
struct | TmFromChar |
struct | fmt_tm |
struct | TmToChar |
struct | NUMProc |
Macros | |
#define | RETURN_ERROR(throw_error) |
#define | CHECK_ERROR |
#define | DCH_FLAG 0x1 /* DATE-TIME flag */ |
#define | NUM_FLAG 0x2 /* NUMBER flag */ |
#define | STD_FLAG 0x4 /* STANDARD flag */ |
#define | KeyWord_INDEX_SIZE ('~' - ' ') |
#define | KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1) |
#define | DCH_MAX_ITEM_SIZ 12 /* max localized day name */ |
#define | NUM_MAX_ITEM_SIZ 8 /* roman number (RN has 15 chars) */ |
#define | NODE_TYPE_END 1 |
#define | NODE_TYPE_ACTION 2 |
#define | NODE_TYPE_CHAR 3 |
#define | NODE_TYPE_SEPARATOR 4 |
#define | NODE_TYPE_SPACE 5 |
#define | SUFFTYPE_PREFIX 1 |
#define | SUFFTYPE_POSTFIX 2 |
#define | CLOCK_24_HOUR 0 |
#define | CLOCK_12_HOUR 1 |
#define | ADJUST_YEAR(year, is_interval) ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year))) |
#define | A_D_STR "A.D." |
#define | a_d_STR "a.d." |
#define | AD_STR "AD" |
#define | ad_STR "ad" |
#define | B_C_STR "B.C." |
#define | b_c_STR "b.c." |
#define | BC_STR "BC" |
#define | bc_STR "bc" |
#define | A_M_STR "A.M." |
#define | a_m_STR "a.m." |
#define | AM_STR "AM" |
#define | am_STR "am" |
#define | P_M_STR "P.M." |
#define | p_m_STR "p.m." |
#define | PM_STR "PM" |
#define | pm_STR "pm" |
#define | TH_UPPER 1 |
#define | TH_LOWER 2 |
#define | NUM_F_DECIMAL (1 << 1) |
#define | NUM_F_LDECIMAL (1 << 2) |
#define | NUM_F_ZERO (1 << 3) |
#define | NUM_F_BLANK (1 << 4) |
#define | NUM_F_FILLMODE (1 << 5) |
#define | NUM_F_LSIGN (1 << 6) |
#define | NUM_F_BRACKET (1 << 7) |
#define | NUM_F_MINUS (1 << 8) |
#define | NUM_F_PLUS (1 << 9) |
#define | NUM_F_ROMAN (1 << 10) |
#define | NUM_F_MULTI (1 << 11) |
#define | NUM_F_PLUS_POST (1 << 12) |
#define | NUM_F_MINUS_POST (1 << 13) |
#define | NUM_F_EEEE (1 << 14) |
#define | NUM_LSIGN_PRE (-1) |
#define | NUM_LSIGN_POST 1 |
#define | NUM_LSIGN_NONE 0 |
#define | IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL) |
#define | IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL) |
#define | IS_ZERO(_f) ((_f)->flag & NUM_F_ZERO) |
#define | IS_BLANK(_f) ((_f)->flag & NUM_F_BLANK) |
#define | IS_FILLMODE(_f) ((_f)->flag & NUM_F_FILLMODE) |
#define | IS_BRACKET(_f) ((_f)->flag & NUM_F_BRACKET) |
#define | IS_MINUS(_f) ((_f)->flag & NUM_F_MINUS) |
#define | IS_LSIGN(_f) ((_f)->flag & NUM_F_LSIGN) |
#define | IS_PLUS(_f) ((_f)->flag & NUM_F_PLUS) |
#define | IS_ROMAN(_f) ((_f)->flag & NUM_F_ROMAN) |
#define | IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI) |
#define | IS_EEEE(_f) ((_f)->flag & NUM_F_EEEE) |
#define | DCH_CACHE_OVERHEAD MAXALIGN(sizeof(bool) + sizeof(int)) |
#define | NUM_CACHE_OVERHEAD MAXALIGN(sizeof(bool) + sizeof(int) + sizeof(NUMDesc)) |
#define | DCH_CACHE_SIZE ((2048 - DCH_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1) |
#define | NUM_CACHE_SIZE ((1024 - NUM_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1) |
#define | DCH_CACHE_ENTRIES 20 |
#define | NUM_CACHE_ENTRIES 20 |
#define | ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar)) |
#define | DEBUG_TMFC(_X) |
#define | DEBUG_TM(_X) |
#define | tmtcTm(_X) (&(_X)->tm) |
#define | tmtcTzn(_X) ((_X)->tzn) |
#define | tmtcFsec(_X) ((_X)->fsec) |
#define | COPY_tm(_DST, _SRC) |
#define | ZERO_tm(_X) |
#define | ZERO_tmtc(_X) |
#define | INVALID_FOR_INTERVAL |
#define | DCH_S_FM 0x01 |
#define | DCH_S_TH 0x02 |
#define | DCH_S_th 0x04 |
#define | DCH_S_SP 0x08 |
#define | DCH_S_TM 0x10 |
#define | S_THth(_s) ((((_s) & DCH_S_TH) || ((_s) & DCH_S_th)) ? 1 : 0) |
#define | S_TH(_s) (((_s) & DCH_S_TH) ? 1 : 0) |
#define | S_th(_s) (((_s) & DCH_S_th) ? 1 : 0) |
#define | S_TH_TYPE(_s) (((_s) & DCH_S_TH) ? TH_UPPER : TH_LOWER) |
#define | S_FM(_s) (((_s) & DCH_S_FM) ? 1 : 0) |
#define | S_SP(_s) (((_s) & DCH_S_SP) ? 1 : 0) |
#define | S_TM(_s) (((_s) & DCH_S_TM) ? 1 : 0) |
#define | TM_SUFFIX_LEN 2 |
#define | SKIP_THth(ptr, _suf) |
#define | DCH_to_char_fsec(frac_fmt, frac_val) |
#define | zeroize_NUM(_n) |
#define | OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len) |
#define | AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s))) |
#define | IS_PREDEC_SPACE(_n) |
#define | NUM_TOCHAR_prepare |
#define | NUM_TOCHAR_finish |
Typedefs | |
typedef struct TmToChar | TmToChar |
typedef struct NUMProc | NUMProc |
Functions | |
static const KeyWord * | index_seq_search (const char *str, const KeyWord *kw, const int *index) |
static const KeySuffix * | suff_search (const char *str, const KeySuffix *suf, int type) |
static bool | is_separator_char (const char *str) |
static void | NUMDesc_prepare (NUMDesc *num, FormatNode *n) |
static void | parse_format (FormatNode *node, const char *str, const KeyWord *kw, const KeySuffix *suf, const int *index, uint32 flags, NUMDesc *Num) |
static void | DCH_to_char (FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid collid) |
static void | DCH_from_char (FormatNode *node, const char *in, TmFromChar *out, Oid collid, bool std, bool *have_error) |
static const char * | get_th (char *num, int type) |
static char * | str_numth (char *dest, char *num, int type) |
static int | adjust_partial_year_to_2020 (int year) |
static int | strspace_len (const char *str) |
static void | from_char_set_mode (TmFromChar *tmfc, const FromCharDateMode mode, bool *have_error) |
static void | from_char_set_int (int *dest, const int value, const FormatNode *node, bool *have_error) |
static int | from_char_parse_int_len (int *dest, const char **src, const int len, FormatNode *node, bool *have_error) |
static int | from_char_parse_int (int *dest, const char **src, FormatNode *node, bool *have_error) |
static int | seq_search_ascii (const char *name, const char *const *array, int *len) |
static int | seq_search_localized (const char *name, char **array, int *len, Oid collid) |
static int | from_char_seq_search (int *dest, const char **src, const char *const *array, char **localized_array, Oid collid, FormatNode *node, bool *have_error) |
static void | do_to_timestamp (text *date_txt, text *fmt, Oid collid, bool std, struct pg_tm *tm, fsec_t *fsec, int *fprec, uint32 *flags, bool *have_error) |
static char * | fill_str (char *str, int c, int max) |
static FormatNode * | NUM_cache (int len, NUMDesc *Num, text *pars_str, bool *shouldFree) |
static char * | int_to_roman (int number) |
static void | NUM_prepare_locale (NUMProc *Np) |
static char * | get_last_relevant_decnum (char *num) |
static void | NUM_numpart_from_char (NUMProc *Np, int id, int input_len) |
static void | NUM_numpart_to_char (NUMProc *Np, int id) |
static char * | NUM_processor (FormatNode *node, NUMDesc *Num, char *inout, char *number, int input_len, int to_char_out_pre_spaces, int sign, bool is_to_char, Oid collid) |
static DCHCacheEntry * | DCH_cache_getnew (const char *str, bool std) |
static DCHCacheEntry * | DCH_cache_search (const char *str, bool std) |
static DCHCacheEntry * | DCH_cache_fetch (const char *str, bool std) |
static NUMCacheEntry * | NUM_cache_getnew (const char *str) |
static NUMCacheEntry * | NUM_cache_search (const char *str) |
static NUMCacheEntry * | NUM_cache_fetch (const char *str) |
char * | str_tolower (const char *buff, size_t nbytes, Oid collid) |
char * | str_toupper (const char *buff, size_t nbytes, Oid collid) |
char * | str_initcap (const char *buff, size_t nbytes, Oid collid) |
char * | asc_tolower (const char *buff, size_t nbytes) |
char * | asc_toupper (const char *buff, size_t nbytes) |
char * | asc_initcap (const char *buff, size_t nbytes) |
static char * | str_tolower_z (const char *buff, Oid collid) |
static char * | str_toupper_z (const char *buff, Oid collid) |
static char * | str_initcap_z (const char *buff, Oid collid) |
static char * | asc_tolower_z (const char *buff) |
static char * | asc_toupper_z (const char *buff) |
static bool | is_next_separator (FormatNode *n) |
static void | DCH_prevent_counter_overflow (void) |
static int | DCH_datetime_type (FormatNode *node, bool *have_error) |
static text * | datetime_to_char_body (TmToChar *tmtc, text *fmt, bool is_interval, Oid collid) |
Datum | timestamp_to_char (PG_FUNCTION_ARGS) |
Datum | timestamptz_to_char (PG_FUNCTION_ARGS) |
Datum | interval_to_char (PG_FUNCTION_ARGS) |
Datum | to_timestamp (PG_FUNCTION_ARGS) |
Datum | to_date (PG_FUNCTION_ARGS) |
Datum | parse_datetime (text *date_txt, text *fmt, Oid collid, bool strict, Oid *typid, int32 *typmod, int *tz, bool *have_error) |
static void | NUM_prevent_counter_overflow (void) |
static void | NUM_eat_non_data_chars (NUMProc *Np, int n, int input_len) |
Datum | numeric_to_number (PG_FUNCTION_ARGS) |
Datum | numeric_to_char (PG_FUNCTION_ARGS) |
Datum | int4_to_char (PG_FUNCTION_ARGS) |
Datum | int8_to_char (PG_FUNCTION_ARGS) |
Datum | float4_to_char (PG_FUNCTION_ARGS) |
Datum | float8_to_char (PG_FUNCTION_ARGS) |
int | datetime_format_flags (const char *fmt_str, bool *have_error) |
Variables | |
static const char *const | months_full [] |
static const char *const | days_short [] |
static const char *const | adbc_strings [] = {ad_STR, bc_STR, AD_STR, BC_STR, NULL} |
static const char *const | adbc_strings_long [] = {a_d_STR, b_c_STR, A_D_STR, B_C_STR, NULL} |
static const char *const | ampm_strings [] = {am_STR, pm_STR, AM_STR, PM_STR, NULL} |
static const char *const | ampm_strings_long [] = {a_m_STR, p_m_STR, A_M_STR, P_M_STR, NULL} |
static const char *const | rm_months_upper [] |
static const char *const | rm_months_lower [] |
static const char *const | rm1 [] = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", NULL} |
static const char *const | rm10 [] = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", NULL} |
static const char *const | rm100 [] = {"C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", NULL} |
static const char *const | numTH [] = {"ST", "ND", "RD", "TH", NULL} |
static const char *const | numth [] = {"st", "nd", "rd", "th", NULL} |
static DCHCacheEntry * | DCHCache [DCH_CACHE_ENTRIES] |
static int | n_DCHCache = 0 |
static int | DCHCounter = 0 |
static NUMCacheEntry * | NUMCache [NUM_CACHE_ENTRIES] |
static int | n_NUMCache = 0 |
static int | NUMCounter = 0 |
static const KeySuffix | DCH_suff [] |
static const KeyWord | DCH_keywords [] |
static const KeyWord | NUM_keywords [] |
static const int | DCH_index [KeyWord_INDEX_SIZE] |
static const int | NUM_index [KeyWord_INDEX_SIZE] |
#define A_D_STR "A.D." |
Definition at line 237 of file formatting.c.
#define a_d_STR "a.d." |
Definition at line 238 of file formatting.c.
#define A_M_STR "A.M." |
Definition at line 264 of file formatting.c.
#define a_m_STR "a.m." |
Definition at line 265 of file formatting.c.
#define AD_STR "AD" |
Definition at line 239 of file formatting.c.
#define ad_STR "ad" |
Definition at line 240 of file formatting.c.
#define ADJUST_YEAR | ( | year, | |
is_interval | |||
) | ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year))) |
Definition at line 235 of file formatting.c.
#define AM_STR "AM" |
Definition at line 266 of file formatting.c.
#define am_STR "am" |
Definition at line 267 of file formatting.c.
#define AMOUNT_TEST | ( | s | ) | (Np->inout_p <= Np->inout + (input_len - (s))) |
Definition at line 5194 of file formatting.c.
#define B_C_STR "B.C." |
Definition at line 242 of file formatting.c.
#define b_c_STR "b.c." |
Definition at line 243 of file formatting.c.
#define BC_STR "BC" |
Definition at line 244 of file formatting.c.
#define bc_STR "bc" |
Definition at line 245 of file formatting.c.
#define CHECK_ERROR |
Definition at line 130 of file formatting.c.
#define CLOCK_12_HOUR 1 |
Definition at line 212 of file formatting.c.
#define CLOCK_24_HOUR 0 |
Definition at line 211 of file formatting.c.
#define COPY_tm | ( | _DST, | |
_SRC | |||
) |
Definition at line 525 of file formatting.c.
#define DCH_CACHE_ENTRIES 20 |
Definition at line 406 of file formatting.c.
Definition at line 396 of file formatting.c.
#define DCH_CACHE_SIZE ((2048 - DCH_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1) |
Definition at line 401 of file formatting.c.
#define DCH_FLAG 0x1 /* DATE-TIME flag */ |
Definition at line 140 of file formatting.c.
#define DCH_MAX_ITEM_SIZ 12 /* max localized day name */ |
Definition at line 155 of file formatting.c.
#define DCH_S_FM 0x01 |
Definition at line 573 of file formatting.c.
#define DCH_S_SP 0x08 |
Definition at line 576 of file formatting.c.
#define DCH_S_TH 0x02 |
Definition at line 574 of file formatting.c.
#define DCH_S_th 0x04 |
Definition at line 575 of file formatting.c.
#define DCH_S_TM 0x10 |
Definition at line 577 of file formatting.c.
#define DCH_to_char_fsec | ( | frac_fmt, | |
frac_val | |||
) |
#define DEBUG_TM | ( | _X | ) |
Definition at line 489 of file formatting.c.
#define DEBUG_TMFC | ( | _X | ) |
Definition at line 488 of file formatting.c.
#define INVALID_FOR_INTERVAL |
#define IS_BLANK | ( | _f | ) | ((_f)->flag & NUM_F_BLANK) |
Definition at line 368 of file formatting.c.
#define IS_BRACKET | ( | _f | ) | ((_f)->flag & NUM_F_BRACKET) |
Definition at line 370 of file formatting.c.
#define IS_DECIMAL | ( | _f | ) | ((_f)->flag & NUM_F_DECIMAL) |
Definition at line 365 of file formatting.c.
#define IS_EEEE | ( | _f | ) | ((_f)->flag & NUM_F_EEEE) |
Definition at line 376 of file formatting.c.
#define IS_FILLMODE | ( | _f | ) | ((_f)->flag & NUM_F_FILLMODE) |
Definition at line 369 of file formatting.c.
#define IS_LDECIMAL | ( | _f | ) | ((_f)->flag & NUM_F_LDECIMAL) |
Definition at line 366 of file formatting.c.
#define IS_LSIGN | ( | _f | ) | ((_f)->flag & NUM_F_LSIGN) |
Definition at line 372 of file formatting.c.
#define IS_MINUS | ( | _f | ) | ((_f)->flag & NUM_F_MINUS) |
Definition at line 371 of file formatting.c.
#define IS_MULTI | ( | _f | ) | ((_f)->flag & NUM_F_MULTI) |
Definition at line 375 of file formatting.c.
#define IS_PLUS | ( | _f | ) | ((_f)->flag & NUM_F_PLUS) |
Definition at line 373 of file formatting.c.
#define IS_PREDEC_SPACE | ( | _n | ) |
Definition at line 5405 of file formatting.c.
#define IS_ROMAN | ( | _f | ) | ((_f)->flag & NUM_F_ROMAN) |
Definition at line 374 of file formatting.c.
#define IS_ZERO | ( | _f | ) | ((_f)->flag & NUM_F_ZERO) |
Definition at line 367 of file formatting.c.
#define KeyWord_INDEX_FILTER | ( | _c | ) | ((_c) <= ' ' || (_c) >= '~' ? 0 : 1) |
Definition at line 149 of file formatting.c.
#define KeyWord_INDEX_SIZE ('~' - ' ') |
Definition at line 148 of file formatting.c.
#define NODE_TYPE_ACTION 2 |
Definition at line 203 of file formatting.c.
#define NODE_TYPE_CHAR 3 |
Definition at line 204 of file formatting.c.
#define NODE_TYPE_END 1 |
Definition at line 202 of file formatting.c.
#define NODE_TYPE_SEPARATOR 4 |
Definition at line 205 of file formatting.c.
#define NODE_TYPE_SPACE 5 |
Definition at line 206 of file formatting.c.
#define NUM_CACHE_ENTRIES 20 |
Definition at line 407 of file formatting.c.
Definition at line 398 of file formatting.c.
#define NUM_CACHE_SIZE ((1024 - NUM_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1) |
Definition at line 403 of file formatting.c.
#define NUM_F_BLANK (1 << 4) |
Definition at line 345 of file formatting.c.
#define NUM_F_BRACKET (1 << 7) |
Definition at line 348 of file formatting.c.
#define NUM_F_DECIMAL (1 << 1) |
Definition at line 342 of file formatting.c.
#define NUM_F_EEEE (1 << 14) |
Definition at line 355 of file formatting.c.
#define NUM_F_FILLMODE (1 << 5) |
Definition at line 346 of file formatting.c.
#define NUM_F_LDECIMAL (1 << 2) |
Definition at line 343 of file formatting.c.
#define NUM_F_LSIGN (1 << 6) |
Definition at line 347 of file formatting.c.
#define NUM_F_MINUS (1 << 8) |
Definition at line 349 of file formatting.c.
#define NUM_F_MINUS_POST (1 << 13) |
Definition at line 354 of file formatting.c.
#define NUM_F_MULTI (1 << 11) |
Definition at line 352 of file formatting.c.
#define NUM_F_PLUS (1 << 9) |
Definition at line 350 of file formatting.c.
#define NUM_F_PLUS_POST (1 << 12) |
Definition at line 353 of file formatting.c.
#define NUM_F_ROMAN (1 << 10) |
Definition at line 351 of file formatting.c.
#define NUM_F_ZERO (1 << 3) |
Definition at line 344 of file formatting.c.
#define NUM_FLAG 0x2 /* NUMBER flag */ |
Definition at line 141 of file formatting.c.
#define NUM_LSIGN_NONE 0 |
Definition at line 359 of file formatting.c.
#define NUM_LSIGN_POST 1 |
Definition at line 358 of file formatting.c.
#define NUM_LSIGN_PRE (-1) |
Definition at line 357 of file formatting.c.
#define NUM_MAX_ITEM_SIZ 8 /* roman number (RN has 15 chars) */ |
Definition at line 156 of file formatting.c.
#define NUM_TOCHAR_finish |
Definition at line 6113 of file formatting.c.
#define NUM_TOCHAR_prepare |
Definition at line 6100 of file formatting.c.
#define OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len) |
Definition at line 5193 of file formatting.c.
#define P_M_STR "P.M." |
Definition at line 269 of file formatting.c.
#define p_m_STR "p.m." |
Definition at line 270 of file formatting.c.
#define PM_STR "PM" |
Definition at line 271 of file formatting.c.
#define pm_STR "pm" |
Definition at line 272 of file formatting.c.
#define RETURN_ERROR | ( | throw_error | ) |
Definition at line 117 of file formatting.c.
#define S_FM | ( | _s | ) | (((_s) & DCH_S_FM) ? 1 : 0) |
Definition at line 589 of file formatting.c.
#define S_SP | ( | _s | ) | (((_s) & DCH_S_SP) ? 1 : 0) |
Definition at line 590 of file formatting.c.
#define S_TH | ( | _s | ) | (((_s) & DCH_S_TH) ? 1 : 0) |
Definition at line 584 of file formatting.c.
#define S_th | ( | _s | ) | (((_s) & DCH_S_th) ? 1 : 0) |
Definition at line 585 of file formatting.c.
Definition at line 586 of file formatting.c.
Definition at line 583 of file formatting.c.
#define S_TM | ( | _s | ) | (((_s) & DCH_S_TM) ? 1 : 0) |
Definition at line 591 of file formatting.c.
#define SKIP_THth | ( | ptr, | |
_suf | |||
) |
Definition at line 2174 of file formatting.c.
#define STD_FLAG 0x4 /* STANDARD flag */ |
Definition at line 142 of file formatting.c.
#define SUFFTYPE_POSTFIX 2 |
Definition at line 209 of file formatting.c.
#define SUFFTYPE_PREFIX 1 |
Definition at line 208 of file formatting.c.
#define TH_LOWER 2 |
Definition at line 319 of file formatting.c.
#define TH_UPPER 1 |
Definition at line 318 of file formatting.c.
#define TM_SUFFIX_LEN 2 |
Definition at line 597 of file formatting.c.
#define tmtcFsec | ( | _X | ) | ((_X)->fsec) |
Definition at line 522 of file formatting.c.
#define tmtcTm | ( | _X | ) | (&(_X)->tm) |
Definition at line 520 of file formatting.c.
#define tmtcTzn | ( | _X | ) | ((_X)->tzn) |
Definition at line 521 of file formatting.c.
#define ZERO_tm | ( | _X | ) |
Definition at line 539 of file formatting.c.
#define ZERO_tmfc | ( | _X | ) | memset(_X, 0, sizeof(TmFromChar)) |
Definition at line 469 of file formatting.c.
#define ZERO_tmtc | ( | _X | ) |
Definition at line 545 of file formatting.c.
#define zeroize_NUM | ( | _n | ) |
Definition at line 4841 of file formatting.c.
enum DCH_poz |
Definition at line 640 of file formatting.c.
enum FromCharDateMode |
Enumerator | |
---|---|
FROM_CHAR_DATE_NONE | |
FROM_CHAR_DATE_GREGORIAN | |
FROM_CHAR_DATE_ISOWEEK |
Definition at line 178 of file formatting.c.
enum NUM_poz |
Definition at line 759 of file formatting.c.
|
static |
char* asc_initcap | ( | const char * | buff, |
size_t | nbytes | ||
) |
Definition at line 2105 of file formatting.c.
References pg_ascii_tolower(), pg_ascii_toupper(), and pnstrdup().
Referenced by str_initcap().
char* asc_tolower | ( | const char * | buff, |
size_t | nbytes | ||
) |
Definition at line 2059 of file formatting.c.
References pg_ascii_tolower(), and pnstrdup().
Referenced by asc_tolower_z(), and str_tolower().
|
static |
Definition at line 2154 of file formatting.c.
References asc_tolower().
Referenced by DCH_to_char(), and NUM_processor().
char* asc_toupper | ( | const char * | buff, |
size_t | nbytes | ||
) |
Definition at line 2082 of file formatting.c.
References pg_ascii_toupper(), and pnstrdup().
Referenced by asc_toupper_z(), and str_toupper().
|
static |
Definition at line 2160 of file formatting.c.
References asc_toupper().
Referenced by DCH_to_char().
int datetime_format_flags | ( | const char * | fmt_str, |
bool * | have_error | ||
) |
Definition at line 6716 of file formatting.c.
Referenced by jspIsMutableWalker().
|
static |
Definition at line 4048 of file formatting.c.
References cstring_to_text(), DCH_cache_fetch(), DCH_CACHE_SIZE, DCH_FLAG, DCH_index, DCH_keywords, DCH_MAX_ITEM_SIZ, DCH_suff, DCH_to_char(), fmt, DCHCacheEntry::format, format, palloc(), parse_format(), pfree(), res, and text_to_cstring().
Referenced by interval_to_char(), timestamp_to_char(), and timestamptz_to_char().
|
static |
Definition at line 4021 of file formatting.c.
References DCH_cache_getnew(), DCH_cache_search(), DCH_FLAG, DCH_index, DCH_keywords, DCH_suff, DCHCacheEntry::format, parse_format(), STD_FLAG, generate_unaccent_rules::str, and DCHCacheEntry::valid.
Referenced by datetime_to_char_body(), and do_to_timestamp().
|
static |
Definition at line 3940 of file formatting.c.
References DCHCacheEntry::age, Assert(), DCH_CACHE_ENTRIES, DCH_CACHE_SIZE, DCH_prevent_counter_overflow(), DCHCache, DCHCounter, elog, i, MemoryContextAllocZero(), n_DCHCache, DCHCacheEntry::std, generate_unaccent_rules::str, DCHCacheEntry::str, strlcpy(), TopMemoryContext, and DCHCacheEntry::valid.
Referenced by DCH_cache_fetch().
|
static |
Definition at line 4000 of file formatting.c.
References DCHCacheEntry::age, DCH_prevent_counter_overflow(), DCHCache, DCHCounter, i, n_DCHCache, DCHCacheEntry::std, generate_unaccent_rules::str, DCHCacheEntry::str, and DCHCacheEntry::valid.
Referenced by DCH_cache_fetch().
|
static |
Definition at line 3836 of file formatting.c.
References DCH_A_D, DCH_a_d, DCH_A_M, DCH_a_m, DCH_AD, DCH_ad, DCH_AM, DCH_am, DCH_B_C, DCH_b_c, DCH_BC, DCH_bc, DCH_CC, DCH_D, DCH_DATED, DCH_DAY, DCH_Day, DCH_day, DCH_DD, DCH_DDD, DCH_DY, DCH_Dy, DCH_dy, DCH_FF1, DCH_FF2, DCH_FF3, DCH_FF4, DCH_FF5, DCH_FF6, DCH_FX, DCH_HH, DCH_HH12, DCH_HH24, DCH_I, DCH_ID, DCH_IDDD, DCH_IY, DCH_IYY, DCH_IYYY, DCH_J, DCH_MI, DCH_MM, DCH_MON, DCH_Mon, DCH_mon, DCH_MONTH, DCH_Month, DCH_month, DCH_MS, DCH_OF, DCH_P_M, DCH_p_m, DCH_PM, DCH_pm, DCH_Q, DCH_RM, DCH_rm, DCH_SS, DCH_SSSS, DCH_TIMED, DCH_TZ, DCH_tz, DCH_TZH, DCH_TZM, DCH_US, DCH_W, DCH_WW, DCH_Y, DCH_Y_YYY, DCH_YY, DCH_YYY, DCH_YYYY, DCH_ZONED, ereport, errcode(), errmsg(), ERROR, KeyWord::id, FormatNode::key, KeyWord::name, NODE_TYPE_ACTION, NODE_TYPE_END, RETURN_ERROR, and FormatNode::type.
Referenced by do_to_timestamp().
|
static |
Definition at line 3322 of file formatting.c.
References adbc_strings, adbc_strings_long, adjust_partial_year_to_2020(), ampm_strings, ampm_strings_long, Assert(), TmFromChar::bc, cache_locale_time(), TmFromChar::cc, FormatNode::character, CHECK_ERROR, TmFromChar::clock, CLOCK_12_HOUR, TmFromChar::d, KeyWord::date_mode, days, days_short, DCH_A_D, DCH_a_d, DCH_A_M, DCH_a_m, DCH_AD, DCH_ad, DCH_AM, DCH_am, DCH_B_C, DCH_b_c, DCH_BC, DCH_bc, DCH_CC, DCH_D, DCH_DAY, DCH_Day, DCH_day, DCH_DD, DCH_DDD, DCH_DY, DCH_Dy, DCH_dy, DCH_FF1, DCH_FF2, DCH_FF3, DCH_FF4, DCH_FF5, DCH_FF6, DCH_FX, DCH_HH, DCH_HH12, DCH_HH24, DCH_I, DCH_ID, DCH_IDDD, DCH_IW, DCH_IY, DCH_IYY, DCH_IYYY, DCH_J, DCH_MI, DCH_MM, DCH_MON, DCH_Mon, DCH_mon, DCH_MONTH, DCH_Month, DCH_month, DCH_MS, DCH_OF, DCH_P_M, DCH_p_m, DCH_PM, DCH_pm, DCH_Q, DCH_RM, DCH_rm, DCH_SS, DCH_SSSS, DCH_TZ, DCH_tz, DCH_TZH, DCH_TZM, DCH_US, DCH_W, DCH_WW, DCH_Y, DCH_Y_YYY, DCH_YY, DCH_YYY, DCH_YYYY, TmFromChar::dd, TmFromChar::ddd, ereport, errcode(), errmsg(), ERROR, TmFromChar::ff, from_char_parse_int(), from_char_parse_int_len(), from_char_seq_search(), from_char_set_int(), from_char_set_mode(), TmFromChar::hh, KeyWord::id, InvalidOid, is_separator_char(), TmFromChar::j, FormatNode::key, len, localized_abbrev_days, localized_abbrev_months, localized_full_days, localized_full_months, TmFromChar::mi, TmFromChar::mm, months, months_full, MONTHS_PER_YEAR, TmFromChar::ms, KeyWord::name, NODE_TYPE_ACTION, NODE_TYPE_CHAR, NODE_TYPE_END, NODE_TYPE_SEPARATOR, NODE_TYPE_SPACE, pg_mblen(), TmFromChar::pm, RETURN_ERROR, rm_months_lower, S_TM, SKIP_THth, TmFromChar::ss, TmFromChar::ssss, FormatNode::suffix, FormatNode::type, TmFromChar::tzh, TmFromChar::tzm, TmFromChar::tzsign, TmFromChar::us, value, TmFromChar::w, TmFromChar::ww, TmFromChar::year, and TmFromChar::yysz.
Referenced by do_to_timestamp().
|
inlinestatic |
Definition at line 3820 of file formatting.c.
References DCHCache, DCHCounter, i, and n_DCHCache.
Referenced by DCH_cache_getnew(), and DCH_cache_search().
|
static |
Definition at line 2678 of file formatting.c.
References A_D_STR, a_d_STR, A_M_STR, a_m_STR, AD_STR, ad_STR, ADJUST_YEAR, AM_STR, am_STR, asc_tolower_z(), asc_toupper_z(), B_C_STR, b_c_STR, BC_STR, bc_STR, cache_locale_time(), FormatNode::character, date2isoweek(), date2isoyear(), date2isoyearday(), date2j(), days, days_short, DCH_A_D, DCH_a_d, DCH_A_M, DCH_a_m, DCH_AD, DCH_ad, DCH_AM, DCH_am, DCH_B_C, DCH_b_c, DCH_BC, DCH_bc, DCH_CC, DCH_D, DCH_DAY, DCH_Day, DCH_day, DCH_DD, DCH_DDD, DCH_DY, DCH_Dy, DCH_dy, DCH_FF1, DCH_FF2, DCH_FF3, DCH_FF4, DCH_FF5, DCH_FF6, DCH_HH, DCH_HH12, DCH_HH24, DCH_I, DCH_ID, DCH_IDDD, DCH_IW, DCH_IY, DCH_IYY, DCH_IYYY, DCH_J, DCH_MAX_ITEM_SIZ, DCH_MI, DCH_MM, DCH_MON, DCH_Mon, DCH_mon, DCH_MONTH, DCH_Month, DCH_month, DCH_MS, DCH_OF, DCH_P_M, DCH_p_m, DCH_PM, DCH_pm, DCH_Q, DCH_RM, DCH_rm, DCH_SS, DCH_SSSS, DCH_to_char_fsec, DCH_TZ, DCH_tz, DCH_TZH, DCH_TZM, DCH_US, DCH_W, DCH_WW, DCH_Y, DCH_Y_YYY, DCH_YY, DCH_YYY, DCH_YYYY, ereport, errcode(), errmsg(), ERROR, TmToChar::fsec, HOURS_PER_DAY, i, KeyWord::id, INVALID_FOR_INTERVAL, FormatNode::key, KeyWord::len, localized_abbrev_days, localized_abbrev_months, localized_full_days, localized_full_months, months, months_full, MONTHS_PER_YEAR, NODE_TYPE_ACTION, NODE_TYPE_END, P_M_STR, p_m_STR, pfree(), PM_STR, pm_STR, rm_months_lower, rm_months_upper, S_FM, S_TH_TYPE, S_THth, S_TM, SECS_PER_HOUR, SECS_PER_MINUTE, sprintf, generate_unaccent_rules::str, str_initcap_z(), str_numth(), str_tolower_z(), str_toupper_z(), FormatNode::suffix, TmToChar::tm, tm, pg_tm::tm_gmtoff, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, TM_SUFFIX_LEN, pg_tm::tm_wday, pg_tm::tm_yday, pg_tm::tm_year, tmtcTzn, and FormatNode::type.
Referenced by datetime_to_char_body().
|
static |
Definition at line 4510 of file formatting.c.
References Assert(), TmFromChar::bc, TmFromChar::cc, CHECK_ERROR, TmFromChar::clock, CLOCK_12_HOUR, TmFromChar::d, DateTimeParseError(), DAY, DCH_cache_fetch(), DCH_CACHE_SIZE, DCH_datetime_type(), DCH_FLAG, DCH_from_char(), DCH_index, DCH_keywords, DCH_suff, TmFromChar::dd, TmFromChar::ddd, DEBUG_TM, DEBUG_TMFC, DTERR_FIELD_OVERFLOW, DTERR_TZDISP_OVERFLOW, DTK_DATE_M, DTK_M, ereport, errcode(), errhint(), errmsg(), ERROR, TmFromChar::ff, fmt, DCHCacheEntry::format, format, FROM_CHAR_DATE_ISOWEEK, TmFromChar::hh, HOURS_PER_DAY, i, isleap, isoweek2date(), isoweek2j(), isoweekdate2date(), TmFromChar::j, j2date(), MAX_TZDISP_HOUR, TmFromChar::mi, MINS_PER_HOUR, TmFromChar::mm, TmFromChar::mode, MONTH, MONTHS_PER_YEAR, TmFromChar::ms, palloc(), parse_format(), pfree(), TmFromChar::pm, psprintf(), RETURN_ERROR, SECS_PER_HOUR, SECS_PER_MINUTE, TmFromChar::ss, TmFromChar::ssss, STD_FLAG, text_to_cstring(), tm, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, pg_tm::tm_zone, TmFromChar::tzh, TmFromChar::tzm, TmFromChar::tzsign, TmFromChar::us, USECS_PER_SEC, ValidateDate(), VARSIZE_ANY_EXHDR, TmFromChar::w, TmFromChar::ww, x, y, TmFromChar::year, YEAR, TmFromChar::yysz, ZERO_tm, and ZERO_tmfc.
Referenced by parse_datetime(), to_date(), and to_timestamp().
|
static |
Definition at line 4834 of file formatting.c.
References generate_unaccent_rules::str.
Referenced by float4_to_char(), float8_to_char(), int4_to_char(), int8_to_char(), int_to_roman(), and numeric_to_char().
Datum float4_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6516 of file formatting.c.
References fill_str(), fmt, format, int_to_roman(), IS_EEEE, IS_MULTI, IS_ROMAN, NUMDesc::multi, NUM_TOCHAR_finish, NUM_TOCHAR_prepare, palloc(), PG_GETARG_FLOAT4, PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, NUMDesc::post, NUMDesc::pre, psprintf(), sign, val, and value.
Datum float8_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6618 of file formatting.c.
References fill_str(), fmt, format, int_to_roman(), IS_EEEE, IS_MULTI, IS_ROMAN, NUMDesc::multi, NUM_TOCHAR_finish, NUM_TOCHAR_prepare, palloc(), PG_GETARG_FLOAT8, PG_GETARG_TEXT_PP, NUMDesc::post, NUMDesc::pre, psprintf(), sign, val, and value.
|
static |
Definition at line 2471 of file formatting.c.
References generate_unaccent_rules::dest, from_char_parse_int_len(), FormatNode::key, and KeyWord::len.
Referenced by DCH_from_char().
|
static |
Definition at line 2368 of file formatting.c.
References Assert(), CHECK_ERROR, DCH_MAX_ITEM_SIZ, generate_unaccent_rules::dest, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, from_char_set_int(), init, is_next_separator(), FormatNode::key, len, KeyWord::name, RETURN_ERROR, S_FM, strlcpy(), strspace_len(), and FormatNode::suffix.
Referenced by DCH_from_char(), and from_char_parse_int().
|
static |
Definition at line 2629 of file formatting.c.
References generate_unaccent_rules::dest, ereport, errcode(), errdetail(), errmsg(), ERROR, FormatNode::key, len, KeyWord::name, pstrdup(), RETURN_ERROR, scanner_isspace(), seq_search_ascii(), and seq_search_localized().
Referenced by DCH_from_char().
|
static |
Definition at line 2327 of file formatting.c.
References generate_unaccent_rules::dest, ereport, errcode(), errdetail(), errmsg(), ERROR, FormatNode::key, KeyWord::name, RETURN_ERROR, and value.
Referenced by DCH_from_char(), and from_char_parse_int_len().
|
static |
Definition at line 2300 of file formatting.c.
References ereport, errcode(), errhint(), errmsg(), ERROR, FROM_CHAR_DATE_NONE, TmFromChar::mode, mode, and RETURN_ERROR.
Referenced by DCH_from_char().
|
static |
|
static |
Definition at line 1542 of file formatting.c.
References ereport, errcode(), errmsg(), ERROR, len, numTH, numth, TH_UPPER, and generate_unaccent_rules::type.
Referenced by NUM_processor(), and str_numth().
|
static |
Definition at line 1125 of file formatting.c.
References KeyWord_INDEX_FILTER, KeyWord::len, KeyWord::name, and generate_unaccent_rules::str.
Referenced by parse_format().
Datum int4_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6316 of file formatting.c.
References DatumGetCString, DirectFunctionCall1, fill_str(), fmt, format, Int32GetDatum, int4out(), int_to_roman(), IS_EEEE, IS_MULTI, IS_ROMAN, NUMDesc::multi, NUM_TOCHAR_finish, NUM_TOCHAR_prepare, palloc(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, NUMDesc::post, NUMDesc::pre, psprintf(), sign, val, and value.
Datum int8_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6410 of file formatting.c.
References DatumGetCString, DatumGetInt32, DatumGetInt64, DirectFunctionCall1, DirectFunctionCall2, dtoi8(), fill_str(), Float8GetDatum(), fmt, format, int64_to_numeric(), Int64GetDatum(), int84(), int8mul(), int8out(), int_to_roman(), IS_EEEE, IS_MULTI, IS_ROMAN, NUMDesc::multi, NUM_TOCHAR_finish, NUM_TOCHAR_prepare, numeric_out_sci(), palloc(), PG_GETARG_INT64, PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, NUMDesc::post, NUMDesc::pre, sign, and value.
|
static |
Definition at line 5034 of file formatting.c.
References fill_str(), len, palloc(), rm1, rm10, rm100, and snprintf.
Referenced by float4_to_char(), float8_to_char(), int4_to_char(), int8_to_char(), and numeric_to_char().
Datum interval_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4193 of file formatting.c.