PostgreSQL Source Code git master
|
#include "postgres.h"
#include <ctype.h>
#include <unistd.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <wctype.h>
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "common/int.h"
#include "common/unicode_case.h"
#include "common/unicode_category.h"
#include "mb/pg_wchar.h"
#include "nodes/miscnodes.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"
#include "varatt.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_tz |
struct | fmt_tm |
struct | TmToChar |
struct | NUMProc |
Macros | |
#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 | IS_VALID_SUB_COMB(curr, next) |
#define | ROMAN_VAL(r) |
#define | MAX_ROMAN_LEN 15 |
#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 | DCH_DATED 0x01 |
#define | DCH_TIMED 0x02 |
#define | DCH_ZONED 0x04 |
#define | OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len) |
#define | AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s))) |
#define | SKIP_THth(ptr, _suf) |
#define | DCH_to_char_fsec(frac_fmt, frac_val) |
#define | zeroize_NUM(_n) |
#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, Node *escontext) |
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 bool | from_char_set_mode (TmFromChar *tmfc, const FromCharDateMode mode, Node *escontext) |
static bool | from_char_set_int (int *dest, const int value, const FormatNode *node, Node *escontext) |
static int | from_char_parse_int_len (int *dest, const char **src, const int len, FormatNode *node, Node *escontext) |
static int | from_char_parse_int (int *dest, const char **src, FormatNode *node, Node *escontext) |
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 bool | from_char_seq_search (int *dest, const char **src, const char *const *array, char **localized_array, Oid collid, FormatNode *node, Node *escontext) |
static bool | do_to_timestamp (text *date_txt, text *fmt, Oid collid, bool std, struct pg_tm *tm, fsec_t *fsec, struct fmt_tz *tz, int *fprec, uint32 *flags, Node *escontext) |
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 int | roman_to_int (NUMProc *Np, int input_len) |
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 * | str_casefold (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) |
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, Node *escontext) |
bool | datetime_format_has_tz (const char *fmt_str) |
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) |
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 196 of file formatting.c.
#define a_d_STR "a.d." |
Definition at line 197 of file formatting.c.
#define A_M_STR "A.M." |
Definition at line 223 of file formatting.c.
#define a_m_STR "a.m." |
Definition at line 224 of file formatting.c.
#define AD_STR "AD" |
Definition at line 198 of file formatting.c.
#define ad_STR "ad" |
Definition at line 199 of file formatting.c.
#define ADJUST_YEAR | ( | year, | |
is_interval | |||
) | ((is_interval) ? (year) : ((year) <= 0 ? -((year) - 1) : (year))) |
Definition at line 194 of file formatting.c.
#define AM_STR "AM" |
Definition at line 225 of file formatting.c.
#define am_STR "am" |
Definition at line 226 of file formatting.c.
#define AMOUNT_TEST | ( | s | ) | (Np->inout_p <= Np->inout + (input_len - (s))) |
Definition at line 1062 of file formatting.c.
#define B_C_STR "B.C." |
Definition at line 201 of file formatting.c.
#define b_c_STR "b.c." |
Definition at line 202 of file formatting.c.
#define BC_STR "BC" |
Definition at line 203 of file formatting.c.
#define bc_STR "bc" |
Definition at line 204 of file formatting.c.
#define CLOCK_12_HOUR 1 |
Definition at line 171 of file formatting.c.
#define CLOCK_24_HOUR 0 |
Definition at line 170 of file formatting.c.
#define COPY_tm | ( | _DST, | |
_SRC | |||
) |
Definition at line 520 of file formatting.c.
#define DCH_CACHE_ENTRIES 20 |
Definition at line 391 of file formatting.c.
#define DCH_CACHE_OVERHEAD MAXALIGN(sizeof(bool) + sizeof(int)) |
Definition at line 381 of file formatting.c.
#define DCH_CACHE_SIZE ((2048 - DCH_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1) |
Definition at line 386 of file formatting.c.
#define DCH_DATED 0x01 |
Definition at line 1052 of file formatting.c.
#define DCH_FLAG 0x1 /* DATE-TIME flag */ |
Definition at line 99 of file formatting.c.
#define DCH_MAX_ITEM_SIZ 12 /* max localized day name */ |
Definition at line 114 of file formatting.c.
#define DCH_S_FM 0x01 |
Definition at line 568 of file formatting.c.
#define DCH_S_SP 0x08 |
Definition at line 571 of file formatting.c.
#define DCH_S_TH 0x02 |
Definition at line 569 of file formatting.c.
#define DCH_S_th 0x04 |
Definition at line 570 of file formatting.c.
#define DCH_S_TM 0x10 |
Definition at line 572 of file formatting.c.
#define DCH_TIMED 0x02 |
Definition at line 1053 of file formatting.c.
#define DCH_to_char_fsec | ( | frac_fmt, | |
frac_val | |||
) |
#define DCH_ZONED 0x04 |
Definition at line 1054 of file formatting.c.
#define DEBUG_TM | ( | _X | ) |
Definition at line 484 of file formatting.c.
#define DEBUG_TMFC | ( | _X | ) |
Definition at line 483 of file formatting.c.
#define INVALID_FOR_INTERVAL |
#define IS_BLANK | ( | _f | ) | ((_f)->flag & NUM_F_BLANK) |
Definition at line 353 of file formatting.c.
#define IS_BRACKET | ( | _f | ) | ((_f)->flag & NUM_F_BRACKET) |
Definition at line 355 of file formatting.c.
#define IS_DECIMAL | ( | _f | ) | ((_f)->flag & NUM_F_DECIMAL) |
Definition at line 350 of file formatting.c.
#define IS_EEEE | ( | _f | ) | ((_f)->flag & NUM_F_EEEE) |
Definition at line 361 of file formatting.c.
#define IS_FILLMODE | ( | _f | ) | ((_f)->flag & NUM_F_FILLMODE) |
Definition at line 354 of file formatting.c.
#define IS_LDECIMAL | ( | _f | ) | ((_f)->flag & NUM_F_LDECIMAL) |
Definition at line 351 of file formatting.c.
#define IS_LSIGN | ( | _f | ) | ((_f)->flag & NUM_F_LSIGN) |
Definition at line 357 of file formatting.c.
#define IS_MINUS | ( | _f | ) | ((_f)->flag & NUM_F_MINUS) |
Definition at line 356 of file formatting.c.
#define IS_MULTI | ( | _f | ) | ((_f)->flag & NUM_F_MULTI) |
Definition at line 360 of file formatting.c.
#define IS_PLUS | ( | _f | ) | ((_f)->flag & NUM_F_PLUS) |
Definition at line 358 of file formatting.c.
#define IS_PREDEC_SPACE | ( | _n | ) |
Definition at line 5590 of file formatting.c.
#define IS_ROMAN | ( | _f | ) | ((_f)->flag & NUM_F_ROMAN) |
Definition at line 359 of file formatting.c.
#define IS_VALID_SUB_COMB | ( | curr, | |
next | |||
) |
Definition at line 270 of file formatting.c.
#define IS_ZERO | ( | _f | ) | ((_f)->flag & NUM_F_ZERO) |
Definition at line 352 of file formatting.c.
#define KeyWord_INDEX_FILTER | ( | _c | ) | ((_c) <= ' ' || (_c) >= '~' ? 0 : 1) |
Definition at line 108 of file formatting.c.
#define KeyWord_INDEX_SIZE ('~' - ' ') |
Definition at line 107 of file formatting.c.
#define MAX_ROMAN_LEN 15 |
Definition at line 290 of file formatting.c.
#define NODE_TYPE_ACTION 2 |
Definition at line 162 of file formatting.c.
#define NODE_TYPE_CHAR 3 |
Definition at line 163 of file formatting.c.
#define NODE_TYPE_END 1 |
Definition at line 161 of file formatting.c.
#define NODE_TYPE_SEPARATOR 4 |
Definition at line 164 of file formatting.c.
#define NODE_TYPE_SPACE 5 |
Definition at line 165 of file formatting.c.
#define NUM_CACHE_ENTRIES 20 |
Definition at line 392 of file formatting.c.
Definition at line 383 of file formatting.c.
#define NUM_CACHE_SIZE ((1024 - NUM_CACHE_OVERHEAD) / (sizeof(FormatNode) + sizeof(char)) - 1) |
Definition at line 388 of file formatting.c.
#define NUM_F_BLANK (1 << 4) |
Definition at line 330 of file formatting.c.
#define NUM_F_BRACKET (1 << 7) |
Definition at line 333 of file formatting.c.
#define NUM_F_DECIMAL (1 << 1) |
Definition at line 327 of file formatting.c.
#define NUM_F_EEEE (1 << 14) |
Definition at line 340 of file formatting.c.
#define NUM_F_FILLMODE (1 << 5) |
Definition at line 331 of file formatting.c.
#define NUM_F_LDECIMAL (1 << 2) |
Definition at line 328 of file formatting.c.
#define NUM_F_LSIGN (1 << 6) |
Definition at line 332 of file formatting.c.
#define NUM_F_MINUS (1 << 8) |
Definition at line 334 of file formatting.c.
#define NUM_F_MINUS_POST (1 << 13) |
Definition at line 339 of file formatting.c.
#define NUM_F_MULTI (1 << 11) |
Definition at line 337 of file formatting.c.
#define NUM_F_PLUS (1 << 9) |
Definition at line 335 of file formatting.c.
#define NUM_F_PLUS_POST (1 << 12) |
Definition at line 338 of file formatting.c.
#define NUM_F_ROMAN (1 << 10) |
Definition at line 336 of file formatting.c.
#define NUM_F_ZERO (1 << 3) |
Definition at line 329 of file formatting.c.
#define NUM_FLAG 0x2 /* NUMBER flag */ |
Definition at line 100 of file formatting.c.
#define NUM_LSIGN_NONE 0 |
Definition at line 344 of file formatting.c.
#define NUM_LSIGN_POST 1 |
Definition at line 343 of file formatting.c.
#define NUM_LSIGN_PRE (-1) |
Definition at line 342 of file formatting.c.
#define NUM_MAX_ITEM_SIZ 8 /* roman number (RN has 15 chars) */ |
Definition at line 115 of file formatting.c.
#define NUM_TOCHAR_finish |
Definition at line 6285 of file formatting.c.
#define NUM_TOCHAR_prepare |
Definition at line 6272 of file formatting.c.
#define OVERLOAD_TEST (Np->inout_p >= Np->inout + input_len) |
Definition at line 1061 of file formatting.c.
#define P_M_STR "P.M." |
Definition at line 228 of file formatting.c.
#define p_m_STR "p.m." |
Definition at line 229 of file formatting.c.
#define PM_STR "PM" |
Definition at line 230 of file formatting.c.
#define pm_STR "pm" |
Definition at line 231 of file formatting.c.
#define ROMAN_VAL | ( | r | ) |
Definition at line 278 of file formatting.c.
#define S_FM | ( | _s | ) | (((_s) & DCH_S_FM) ? 1 : 0) |
Definition at line 584 of file formatting.c.
#define S_SP | ( | _s | ) | (((_s) & DCH_S_SP) ? 1 : 0) |
Definition at line 585 of file formatting.c.
#define S_TH | ( | _s | ) | (((_s) & DCH_S_TH) ? 1 : 0) |
Definition at line 579 of file formatting.c.
#define S_th | ( | _s | ) | (((_s) & DCH_S_th) ? 1 : 0) |
Definition at line 580 of file formatting.c.
Definition at line 581 of file formatting.c.
Definition at line 578 of file formatting.c.
#define S_TM | ( | _s | ) | (((_s) & DCH_S_TM) ? 1 : 0) |
Definition at line 586 of file formatting.c.
#define SKIP_THth | ( | ptr, | |
_suf | |||
) |
Definition at line 2013 of file formatting.c.
#define STD_FLAG 0x4 /* STANDARD flag */ |
Definition at line 101 of file formatting.c.
#define SUFFTYPE_POSTFIX 2 |
Definition at line 168 of file formatting.c.
#define SUFFTYPE_PREFIX 1 |
Definition at line 167 of file formatting.c.
#define TH_LOWER 2 |
Definition at line 304 of file formatting.c.
#define TH_UPPER 1 |
Definition at line 303 of file formatting.c.
#define TM_SUFFIX_LEN 2 |
Definition at line 592 of file formatting.c.
#define tmtcFsec | ( | _X | ) | ((_X)->fsec) |
Definition at line 517 of file formatting.c.
#define tmtcTm | ( | _X | ) | (&(_X)->tm) |
Definition at line 515 of file formatting.c.
#define tmtcTzn | ( | _X | ) | ((_X)->tzn) |
Definition at line 516 of file formatting.c.
#define ZERO_tm | ( | _X | ) |
Definition at line 534 of file formatting.c.
#define ZERO_tmfc | ( | _X | ) | memset(_X, 0, sizeof(TmFromChar)) |
Definition at line 458 of file formatting.c.
#define ZERO_tmtc | ( | _X | ) |
Definition at line 540 of file formatting.c.
#define zeroize_NUM | ( | _n | ) |
Definition at line 4868 of file formatting.c.
enum DCH_poz |
Definition at line 635 of file formatting.c.
enum FromCharDateMode |
Enumerator | |
---|---|
FROM_CHAR_DATE_NONE | |
FROM_CHAR_DATE_GREGORIAN | |
FROM_CHAR_DATE_ISOWEEK |
Definition at line 137 of file formatting.c.
enum NUM_poz |
Definition at line 754 of file formatting.c.
|
static |
Definition at line 2094 of file formatting.c.
Referenced by DCH_from_char().
char * asc_initcap | ( | const char * | buff, |
size_t | nbytes | ||
) |
Definition at line 1944 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 1898 of file formatting.c.
References pg_ascii_tolower(), and pnstrdup().
Referenced by asc_tolower_z(), str_casefold(), and str_tolower().
|
static |
Definition at line 1993 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 1921 of file formatting.c.
References pg_ascii_toupper(), and pnstrdup().
Referenced by asc_toupper_z(), and str_toupper().
|
static |
Definition at line 1999 of file formatting.c.
References asc_toupper().
Referenced by DCH_to_char().
bool datetime_format_has_tz | ( | const char * | fmt_str | ) |
Definition at line 4365 of file formatting.c.
References DCH_cache_fetch(), DCH_CACHE_SIZE, DCH_datetime_type(), DCH_FLAG, DCH_index, DCH_keywords, DCH_suff, DCH_ZONED, DCHCacheEntry::format, format, palloc(), parse_format(), and pfree().
Referenced by jspIsMutableWalker().
|
static |
Definition at line 3928 of file formatting.c.
References collid, 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 3901 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, str, and DCHCacheEntry::valid.
Referenced by datetime_format_has_tz(), datetime_to_char_body(), and do_to_timestamp().
|
static |
Definition at line 3820 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, DCHCacheEntry::str, str, strlcpy(), TopMemoryContext, and DCHCacheEntry::valid.
Referenced by DCH_cache_fetch().
|
static |
Definition at line 3880 of file formatting.c.
References DCHCacheEntry::age, DCH_prevent_counter_overflow(), DCHCache, DCHCounter, i, n_DCHCache, DCHCacheEntry::std, DCHCacheEntry::str, str, and DCHCacheEntry::valid.
Referenced by DCH_cache_fetch().
|
static |
Definition at line 3723 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, KeyWord::id, FormatNode::key, NODE_TYPE_ACTION, NODE_TYPE_END, and FormatNode::type.
Referenced by datetime_format_has_tz(), and do_to_timestamp().
|
static |
Definition at line 3152 of file formatting.c.
References TmFromChar::abbrev, 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, TmFromChar::clock, CLOCK_12_HOUR, collid, 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, DecodeTimezoneAbbrevPrefix(), ereturn, errcode(), errdetail(), errmsg(), TmFromChar::ff, from_char_parse_int(), from_char_parse_int_len(), from_char_seq_search(), from_char_set_int(), from_char_set_mode(), TmFromChar::gmtoffset, TmFromChar::has_tz, 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_add_s32_overflow(), pg_mblen(), pg_mul_s32_overflow(), TmFromChar::pm, pnstrdup(), rm_months_lower, S_TM, SKIP_THth, TmFromChar::ss, TmFromChar::ssss, FormatNode::suffix, FormatNode::type, TmFromChar::tzh, TmFromChar::tzm, TmFromChar::tzp, TmFromChar::tzsign, TmFromChar::us, value, TmFromChar::w, TmFromChar::ww, TmFromChar::year, and TmFromChar::yysz.
Referenced by do_to_timestamp().
|
inlinestatic |
Definition at line 3709 of file formatting.c.
References DCHCache, DCHCounter, i, and n_DCHCache.
Referenced by DCH_cache_getnew(), and DCH_cache_search().
|
static |
Definition at line 2505 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, collid, 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, 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 4428 of file formatting.c.
References TmFromChar::abbrev, Assert, TmFromChar::bc, TmFromChar::cc, TmFromChar::clock, CLOCK_12_HOUR, collid, 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, DetermineTimeZoneAbbrevOffset(), DTERR_FIELD_OVERFLOW, DTERR_TZDISP_OVERFLOW, DTK_DATE_M, DTK_M, errcode(), errhint(), errmsg(), errsave, TmFromChar::ff, fmt, DCHCacheEntry::format, format, FROM_CHAR_DATE_ISOWEEK, TmFromChar::gmtoffset, fmt_tz::gmtoffset, TmFromChar::has_tz, fmt_tz::has_tz, TmFromChar::hh, HOURS_PER_DAY, i, INT64CONST, 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(), pg_add_s32_overflow(), pg_mul_s32_overflow(), pg_sub_s32_overflow(), TmFromChar::pm, SECS_PER_HOUR, SECS_PER_MINUTE, SOFT_ERROR_OCCURRED, 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, TmFromChar::tzh, TmFromChar::tzm, TmFromChar::tzp, 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 4861 of file formatting.c.
References 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 6697 of file formatting.c.
References fill_str(), FLOAT4_FITS_IN_INT32, 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_INT32_MAX, PG_RETURN_TEXT_P, NUMDesc::post, NUMDesc::pre, psprintf(), sign, val, and value.
Datum float8_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6810 of file formatting.c.
References fill_str(), FLOAT8_FITS_IN_INT32, 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, PG_INT32_MAX, PG_RETURN_TEXT_P, NUMDesc::post, NUMDesc::pre, psprintf(), sign, val, and value.
|
static |
Definition at line 2300 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 2203 of file formatting.c.
References Assert, DCH_MAX_ITEM_SIZ, generate_unaccent_rules::dest, ereturn, errcode(), errdetail(), errhint(), errmsg(), from_char_set_int(), init, is_next_separator(), FormatNode::key, len, KeyWord::name, S_FM, strlcpy(), strspace_len(), and FormatNode::suffix.
Referenced by DCH_from_char(), and from_char_parse_int().
|
static |
Definition at line 2459 of file formatting.c.
References collid, generate_unaccent_rules::dest, ereturn, errcode(), errdetail(), errmsg(), FormatNode::key, len, KeyWord::name, pstrdup(), scanner_isspace(), seq_search_ascii(), and seq_search_localized().
Referenced by DCH_from_char().
|
static |
Definition at line 2167 of file formatting.c.
References generate_unaccent_rules::dest, ereturn, errcode(), errdetail(), errmsg(), FormatNode::key, KeyWord::name, and value.
Referenced by DCH_from_char(), and from_char_parse_int_len().
|
static |
Definition at line 2140 of file formatting.c.
References ereturn, errcode(), errhint(), errmsg(), FROM_CHAR_DATE_NONE, TmFromChar::mode, and mode.
Referenced by DCH_from_char().
|
static |
Definition at line 5358 of file formatting.c.
References elog.
Referenced by NUM_processor().
|
static |
Definition at line 1563 of file formatting.c.
References ereport, errcode(), errmsg(), ERROR, len, numTH, numth, TH_UPPER, and type.
Referenced by NUM_processor(), and str_numth().
|
static |
Definition at line 1135 of file formatting.c.
References KeyWord_INDEX_FILTER, KeyWord::len, KeyWord::name, and str.
Referenced by parse_format().
Datum int4_to_char | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6491 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 6585 of file formatting.c.
References DatumGetCString(), DatumGetInt64(), DirectFunctionCall1, DirectFunctionCall2, dtoi8(), fill_str(), Float8GetDatum(), fmt, format, int64_to_numeric(), Int64GetDatum(), 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_INT32_MAX, PG_INT32_MIN, PG_RETURN_TEXT_P, NUMDesc::post, NUMDesc::pre, sign, and value.
|
static |
Definition at line 5066 of file formatting.c.