PostgreSQL Source Code
git master
|
Go to the source code of this file.
Data Structures | |
struct | datetkn |
Macros | |
#define | MAXTZLEN 10 |
#define | USE_POSTGRES_DATES 0 |
#define | USE_ISO_DATES 1 |
#define | USE_SQL_DATES 2 |
#define | USE_GERMAN_DATES 3 |
#define | INTSTYLE_POSTGRES 0 |
#define | INTSTYLE_POSTGRES_VERBOSE 1 |
#define | INTSTYLE_SQL_STANDARD 2 |
#define | INTSTYLE_ISO_8601 3 |
#define | INTERVAL_FULL_RANGE (0x7FFF) |
#define | INTERVAL_MASK(b) (1 << (b)) |
#define | MAX_INTERVAL_PRECISION 6 |
#define | DTERR_BAD_FORMAT (-1) |
#define | DTERR_FIELD_OVERFLOW (-2) |
#define | DTERR_MD_FIELD_OVERFLOW (-3) /* triggers hint about DateStyle */ |
#define | DTERR_INTERVAL_OVERFLOW (-4) |
#define | DTERR_TZDISP_OVERFLOW (-5) |
#define | DAGO "ago" |
#define | DCURRENT "current" |
#define | EPOCH "epoch" |
#define | INVALID "invalid" |
#define | EARLY "-infinity" |
#define | LATE "infinity" |
#define | NOW "now" |
#define | TODAY "today" |
#define | TOMORROW "tomorrow" |
#define | YESTERDAY "yesterday" |
#define | ZULU "zulu" |
#define | DMICROSEC "usecond" |
#define | DMILLISEC "msecond" |
#define | DSECOND "second" |
#define | DMINUTE "minute" |
#define | DHOUR "hour" |
#define | DDAY "day" |
#define | DWEEK "week" |
#define | DMONTH "month" |
#define | DQUARTER "quarter" |
#define | DYEAR "year" |
#define | DDECADE "decade" |
#define | DCENTURY "century" |
#define | DMILLENNIUM "millennium" |
#define | DA_D "ad" |
#define | DB_C "bc" |
#define | DTIMEZONE "timezone" |
#define | AM 0 |
#define | PM 1 |
#define | HR24 2 |
#define | AD 0 |
#define | BC 1 |
#define | RESERV 0 |
#define | MONTH 1 |
#define | YEAR 2 |
#define | DAY 3 |
#define | JULIAN 4 |
#define | TZ 5 /* fixed-offset timezone abbreviation */ |
#define | DTZ 6 /* fixed-offset timezone abbrev, DST */ |
#define | DYNTZ 7 /* dynamic timezone abbr (unimplemented) */ |
#define | IGNORE_DTF 8 |
#define | AMPM 9 |
#define | HOUR 10 |
#define | MINUTE 11 |
#define | SECOND 12 |
#define | MILLISECOND 13 |
#define | MICROSECOND 14 |
#define | DOY 15 |
#define | DOW 16 |
#define | UNITS 17 |
#define | ADBC 18 |
#define | AGO 19 |
#define | ABS_BEFORE 20 |
#define | ABS_AFTER 21 |
#define | ISODATE 22 |
#define | ISOTIME 23 |
#define | DTZMOD 28 /* "DST" as a separate word */ |
#define | UNKNOWN_FIELD 31 |
#define | DTK_NUMBER 0 |
#define | DTK_STRING 1 |
#define | DTK_DATE 2 |
#define | DTK_TIME 3 |
#define | DTK_TZ 4 |
#define | DTK_AGO 5 |
#define | DTK_SPECIAL 6 |
#define | DTK_EARLY 9 |
#define | DTK_LATE 10 |
#define | DTK_EPOCH 11 |
#define | DTK_NOW 12 |
#define | DTK_YESTERDAY 13 |
#define | DTK_TODAY 14 |
#define | DTK_TOMORROW 15 |
#define | DTK_ZULU 16 |
#define | DTK_DELTA 17 |
#define | DTK_SECOND 18 |
#define | DTK_MINUTE 19 |
#define | DTK_HOUR 20 |
#define | DTK_DAY 21 |
#define | DTK_WEEK 22 |
#define | DTK_MONTH 23 |
#define | DTK_QUARTER 24 |
#define | DTK_YEAR 25 |
#define | DTK_DECADE 26 |
#define | DTK_CENTURY 27 |
#define | DTK_MILLENNIUM 28 |
#define | DTK_MILLISEC 29 |
#define | DTK_MICROSEC 30 |
#define | DTK_JULIAN 31 |
#define | DTK_DOW 32 |
#define | DTK_DOY 33 |
#define | DTK_TZ_HOUR 34 |
#define | DTK_TZ_MINUTE 35 |
#define | DTK_ISOYEAR 36 |
#define | DTK_ISODOW 37 |
#define | DTK_M(t) (0x01 << (t)) |
#define | DTK_ALL_SECS_M (DTK_M(SECOND) | DTK_M(MILLISECOND) | DTK_M(MICROSECOND)) |
#define | DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY)) |
#define | DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND)) |
#define | MAXDATELEN 128 |
#define | MAXDATEFIELDS 25 |
#define | TOKMAXLEN 10 |
#define | FMODULO(t, q, u) |
#define | TMODULO(t, q, u) |
#define | DAYS_PER_YEAR 365.25 /* assumes leap year every four years */ |
#define | MONTHS_PER_YEAR 12 |
#define | DAYS_PER_MONTH 30 /* assumes exactly 30 days per month */ |
#define | HOURS_PER_DAY 24 /* assume no daylight savings time changes */ |
#define | SECS_PER_YEAR (36525 * 864) /* avoid floating-point computation */ |
#define | SECS_PER_DAY 86400 |
#define | SECS_PER_HOUR 3600 |
#define | SECS_PER_MINUTE 60 |
#define | MINS_PER_HOUR 60 |
#define | USECS_PER_DAY INT64CONST(86400000000) |
#define | USECS_PER_HOUR INT64CONST(3600000000) |
#define | USECS_PER_MINUTE INT64CONST(60000000) |
#define | USECS_PER_SEC INT64CONST(1000000) |
#define | isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) |
#define | JULIAN_MINYEAR (-4713) |
#define | JULIAN_MINMONTH (11) |
#define | JULIAN_MINDAY (24) |
#define | JULIAN_MAXYEAR (5874898) |
#define | JULIAN_MAXMONTH (6) |
#define | JULIAN_MAXDAY (3) |
#define | IS_VALID_JULIAN(y, m, d) |
#define | MIN_TIMESTAMP INT64CONST(-211813488000000000) |
#define | END_TIMESTAMP INT64CONST(9223371331200000000) |
#define | IS_VALID_TIMESTAMP(t) (MIN_TIMESTAMP <= (t) && (t) < END_TIMESTAMP) |
#define | UTIME_MINYEAR (1901) |
#define | UTIME_MINMONTH (12) |
#define | UTIME_MINDAY (14) |
#define | UTIME_MAXYEAR (2038) |
#define | UTIME_MAXMONTH (01) |
#define | UTIME_MAXDAY (18) |
#define | IS_VALID_UTIME(y, m, d) |
#define | DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1) |
#define | DT_NOEND (INT64CONST(0x7fffffffffffffff)) |
#define | TIMESTAMP_NOBEGIN(j) do {(j) = DT_NOBEGIN;} while (0) |
#define | TIMESTAMP_NOEND(j) do {(j) = DT_NOEND;} while (0) |
#define | TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN) |
#define | TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND) |
#define | TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) |
Typedefs | |
typedef int32 | fsec_t |
Functions | |
int | DecodeInterval (char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec_t *fsec) |
int | DecodeTime (char *str, int *tmask, struct tm *tm, fsec_t *fsec) |
void | EncodeDateTime (struct tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str, bool EuroDates) |
void | EncodeInterval (struct tm *tm, fsec_t fsec, int style, char *str) |
int | tm2timestamp (struct tm *tm, fsec_t fsec, int *tzp, timestamp *result) |
int | DecodeUnits (int field, char *lowtoken, int *val) |
bool | CheckDateTokenTables (void) |
void | EncodeDateOnly (struct tm *tm, int style, char *str, bool EuroDates) |
int | GetEpochTime (struct tm *tm) |
int | ParseDateTime (char *timestr, char *lowstr, char **field, int *ftype, int *numfields, char **endstr) |
int | DecodeDateTime (char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec_t *fsec, bool EuroDates) |
void | j2date (int jd, int *year, int *month, int *day) |
void | GetCurrentDateTime (struct tm *tm) |
int | date2j (int y, int m, int d) |
void | TrimTrailingZeros (char *str) |
void | dt2time (double jd, int *hour, int *min, int *sec, fsec_t *fsec) |
int | PGTYPEStimestamp_defmt_scan (char **str, char *fmt, timestamp *d, int *year, int *month, int *day, int *hour, int *minute, int *second, int *tz) |
Variables | |
char * | pgtypes_date_weekdays_short [] |
char * | pgtypes_date_months [] |
char * | months [] |
char * | days [] |
const int | day_tab [2][13] |
#define DAYS_PER_MONTH 30 /* assumes exactly 30 days per month */ |
#define DAYS_PER_YEAR 365.25 /* assumes leap year every four years */ |
#define DTERR_MD_FIELD_OVERFLOW (-3) /* triggers hint about DateStyle */ |
#define DTK_ALL_SECS_M (DTK_M(SECOND) | DTK_M(MILLISECOND) | DTK_M(MICROSECOND)) |
#define FMODULO | ( | t, | |
q, | |||
u | |||
) |
#define HOURS_PER_DAY 24 /* assume no daylight savings time changes */ |
#define IS_VALID_JULIAN | ( | y, | |
m, | |||
d | |||
) |
#define IS_VALID_TIMESTAMP | ( | t | ) | (MIN_TIMESTAMP <= (t) && (t) < END_TIMESTAMP) |
#define IS_VALID_UTIME | ( | y, | |
m, | |||
d | |||
) |
#define SECS_PER_YEAR (36525 * 864) /* avoid floating-point computation */ |
#define TIMESTAMP_IS_NOBEGIN | ( | j | ) | ((j) == DT_NOBEGIN) |
#define TIMESTAMP_NOBEGIN | ( | j | ) | do {(j) = DT_NOBEGIN;} while (0) |
#define TIMESTAMP_NOT_FINITE | ( | j | ) | (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) |
#define TMODULO | ( | t, | |
q, | |||
u | |||
) |
bool CheckDateTokenTables | ( | void | ) |
Definition at line 4811 of file datetime.c.
References Assert, CheckDateTokenTable(), date2j(), datetktbl, deltatktbl, POSTGRES_EPOCH_JDATE, szdatetktbl, szdeltatktbl, and UNIX_EPOCH_JDATE.
Referenced by PostmasterMain().
int date2j | ( | int | y, |
int | m, | ||
int | d | ||
) |
Definition at line 286 of file datetime.c.
References y.
Referenced by CheckDateTokenTables(), date2isoweek(), date2isoyear(), date2isoyearday(), date_in(), DCH_to_char(), DecodeDateTime(), DecodeNumber(), DetermineTimeZoneOffsetInternal(), EncodeDateTime(), extract_date(), GetSQLCurrentDate(), isoweek2j(), make_date(), make_timestamp_internal(), parse_datetime(), PGTYPESdate_dayofweek(), PGTYPESdate_defmt_asc(), PGTYPESdate_fmt_asc(), PGTYPESdate_from_asc(), PGTYPESdate_julmdy(), PGTYPESdate_mdyjul(), PGTYPESdate_to_asc(), PGTYPESdate_today(), timestamp2tm(), timestamp_date(), timestamp_part_common(), timestamp_pl_interval(), timestamp_to_char(), timestamptz_date(), timestamptz_part_common(), timestamptz_pl_interval_internal(), timestamptz_to_char(), tm2timestamp(), to_date(), and ValidateDate().
int DecodeDateTime | ( | char ** | field, |
int * | ftype, | ||
int | nf, | ||
int * | dtype, | ||
struct tm * | tm, | ||
fsec_t * | fsec, | ||
bool | EuroDates | ||
) |
Definition at line 1782 of file dt_common.c.
References ADBC, AM, AMPM, BC, date2j(), DAY, day_tab, DecodeDate(), DecodeNumber(), DecodeNumberField(), DecodePosixTimezone(), DecodeSpecial(), DecodeTime(), DecodeTimezone(), DOW, dt2time(), DTK_DATE, DTK_DATE_M, DTK_DAY, DTK_HOUR, DTK_JULIAN, DTK_M, DTK_MINUTE, DTK_MONTH, DTK_NOW, DTK_NUMBER, DTK_SECOND, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TIME_M, DTK_TODAY, DTK_TOMORROW, DTK_TZ, DTK_YEAR, DTK_YESTERDAY, DTK_ZULU, DTZ, DTZMOD, GetCurrentDateTime(), HOUR, HR24, i, IGNORE_DTF, isleap, ISOTIME, j2date(), MINUTE, MONTH, PM, RESERV, SECOND, strtoint(), tm, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_wday, pg_tm::tm_year, type, TZ, UNITS, USECS_PER_DAY, val, value, and YEAR.
int DecodeInterval | ( | char ** | field, |
int * | ftype, | ||
int | nf, | ||
int * | dtype, | ||
struct tm * | tm, | ||
fsec_t * | fsec | ||
) |
Definition at line 326 of file interval.c.
References AdjustFractDays(), AdjustFractSeconds(), AGO, Assert, ClearPgTm(), DAY, DAYS_PER_MONTH, DecodeTime(), DecodeUnits(), DTERR_BAD_FORMAT, DTERR_FIELD_OVERFLOW, DTK_ALL_SECS_M, DTK_CENTURY, DTK_DATE, DTK_DATE_M, DTK_DAY, DTK_DECADE, DTK_DELTA, DTK_HOUR, DTK_M, DTK_MICROSEC, DTK_MILLENNIUM, DTK_MILLISEC, DTK_MINUTE, DTK_MONTH, DTK_NUMBER, DTK_SECOND, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TIME_M, DTK_TZ, DTK_WEEK, DTK_YEAR, HOUR, i, IGNORE_DTF, INTERVAL_FULL_RANGE, INTERVAL_MASK, IntervalStyle, INTSTYLE_POSTGRES_VERBOSE, INTSTYLE_SQL_STANDARD, MICROSECOND, MILLISECOND, MINUTE, MONTH, MONTHS_PER_YEAR, range(), RESERV, SECOND, SECS_PER_DAY, SECS_PER_HOUR, SECS_PER_MINUTE, strtoint(), 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, type, TZ, UNITS, USECS_PER_SEC, val, and YEAR.
Referenced by PGTYPESinterval_from_asc().
Definition at line 1437 of file dt_common.c.
References DTK_TIME_M, i, str, strtoint(), tm, pg_tm::tm_hour, pg_tm::tm_min, pg_tm::tm_sec, and USECS_PER_SEC.
Referenced by DecodeDateTime().
int DecodeUnits | ( | int | field, |
char * | lowtoken, | ||
int * | val | ||
) |
Definition at line 536 of file dt_common.c.
References datebsearch(), deltacache, deltatktbl, szdeltatktbl, token, TOKMAXLEN, type, datetkn::type, UNKNOWN_FIELD, val, and datetkn::value.
void dt2time | ( | double | jd, |
int * | hour, | ||
int * | min, | ||
int * | sec, | ||
fsec_t * | fsec | ||
) |
Definition at line 1068 of file dt_common.c.
References USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.
Referenced by DecodeDateTime().
void EncodeDateOnly | ( | struct tm * | tm, |
int | style, | ||
char * | str, | ||
bool | EuroDates | ||
) |
Definition at line 669 of file dt_common.c.
References Assert, MONTHS_PER_YEAR, sprintf, str, tm, pg_tm::tm_mday, pg_tm::tm_mon, pg_tm::tm_year, USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, and USE_SQL_DATES.
void EncodeDateTime | ( | struct tm * | tm, |
fsec_t | fsec, | ||
bool | print_tz, | ||
int | tz, | ||
const char * | tzn, | ||
int | style, | ||
char * | str, | ||
bool | EuroDates | ||
) |
Definition at line 753 of file dt_common.c.
References date2j(), days, MAXTZLEN, MINS_PER_HOUR, months, SECS_PER_HOUR, sprintf, str, tm, pg_tm::tm_hour, pg_tm::tm_isdst, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_wday, pg_tm::tm_year, TrimTrailingZeros(), USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, and USE_SQL_DATES.
Definition at line 759 of file interval.c.
References AddISO8601IntPart(), AddPostgresIntPart(), AddVerboseIntPart(), AppendSeconds(), INTSTYLE_ISO_8601, INTSTYLE_POSTGRES, INTSTYLE_POSTGRES_VERBOSE, INTSTYLE_SQL_STANDARD, MAX_INTERVAL_PRECISION, sprintf, str, tm, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, and pg_tm::tm_year.
Referenced by PGTYPESinterval_to_asc().
void GetCurrentDateTime | ( | struct tm * | tm | ) |
Definition at line 1060 of file dt_common.c.
References abstime2tm(), and tm.
Referenced by DecodeDateTime().
int GetEpochTime | ( | struct tm * | tm | ) |
Definition at line 949 of file dt_common.c.
References epoch, tm, pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, and pg_tm::tm_year.
void j2date | ( | int | jd, |
int * | year, | ||
int * | month, | ||
int * | day | ||
) |
Definition at line 311 of file datetime.c.
References MONTHS_PER_YEAR, and y.
Referenced by date2timestamptz_opt_overflow(), date_out(), DecodeDateTime(), DecodeNumber(), DecodeTimeOnly(), do_to_timestamp(), executeDateTimeMethod(), extract_date(), isoweek2date(), isoweekdate2date(), JsonEncodeDateTime(), map_sql_value_to_xml_value(), PGTYPESdate_fmt_asc(), PGTYPESdate_julmdy(), PGTYPESdate_to_asc(), timestamp2tm(), timestamp_pl_interval(), timestamptz_pl_interval_internal(), and ValidateDate().
int ParseDateTime | ( | char * | timestr, |
char * | lowstr, | ||
char ** | field, | ||
int * | ftype, | ||
int * | numfields, | ||
char ** | endstr | ||
) |
Definition at line 1600 of file dt_common.c.
References DTK_DATE, DTK_NUMBER, DTK_SPECIAL, DTK_STRING, DTK_TIME, DTK_TZ, MAXDATEFIELDS, and pg_tolower().
int PGTYPEStimestamp_defmt_scan | ( | char ** | str, |
char * | fmt, | ||
timestamp * | d, | ||
int * | year, | ||
int * | month, | ||
int * | day, | ||
int * | hour, | ||
int * | minute, | ||
int * | second, | ||
int * | tz | ||
) |
Definition at line 2521 of file dt_common.c.
References datetktbl, day_tab, days, DecodeTimezone(), DTZ, err(), fmt, free, isleap, j, un_fmt_comb::luint_val, months, MONTHS_PER_YEAR, pg_strcasecmp(), pgtypes_alloc(), pgtypes_date_months, pgtypes_date_weekdays_short, pgtypes_defmt_scan(), PGTYPES_TYPE_STRING_MALLOCED, PGTYPES_TYPE_UINT, PGTYPES_TYPE_UINT_LONG, PGTYPEStimestamp_defmt_scan(), str, un_fmt_comb::str_val, szdatetktbl, tm, tm2timestamp(), pg_tm::tm_hour, pg_tm::tm_mday, pg_tm::tm_min, pg_tm::tm_mon, pg_tm::tm_sec, pg_tm::tm_year, token, type, TZ, un_fmt_comb::uint_val, and datetkn::value.
Referenced by PGTYPEStimestamp_defmt_asc(), and PGTYPEStimestamp_defmt_scan().
Definition at line 41 of file timestamp.c.
References date2j(), dt2local(), IS_VALID_JULIAN, IS_VALID_TIMESTAMP, pg_add_s64_overflow(), pg_mul_s64_overflow(), time2t(), 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, unlikely, and USECS_PER_DAY.
void TrimTrailingZeros | ( | char * | str | ) |
|
extern |
Definition at line 75 of file datetime.c.
Referenced by DecodeDateTime(), PGTYPEStimestamp_add_interval(), PGTYPEStimestamp_defmt_scan(), timestamp_age(), timestamp_pl_interval(), timestamptz_age(), timestamptz_pl_interval_internal(), and ValidateDate().
|
extern |
Definition at line 84 of file datetime.c.
Referenced by AdjustDays(), brin_minmax_multi_distance_interval(), date_mii(), date_pli(), DCH_from_char(), DCH_to_char(), dttofmtasc_replace(), EncodeDateTime(), interval_cmp_value(), make_interval(), PGTYPEStimestamp_defmt_scan(), and PrintTiming().
|
extern |
Definition at line 81 of file datetime.c.
Referenced by DCH_from_char(), DCH_to_char(), dttofmtasc_replace(), EncodeDateTime(), make_interval(), PGTYPESdate_defmt_asc(), PGTYPESdate_fmt_asc(), and PGTYPEStimestamp_defmt_scan().
|
extern |
Definition at line 499 of file dt_common.c.
Referenced by dttofmtasc_replace(), PGTYPESdate_defmt_asc(), and PGTYPEStimestamp_defmt_scan().
|
extern |
Definition at line 497 of file dt_common.c.
Referenced by dttofmtasc_replace(), PGTYPESdate_fmt_asc(), and PGTYPEStimestamp_defmt_scan().