PostgreSQL Source Code
git master
|
Go to the source code of this file.
Variables | |
PGDLLIMPORT TimestampTz | PgStartTime |
PGDLLIMPORT TimestampTz | PgReloadTime |
#define INTERVAL_FULL_PRECISION (0xFFFF) |
Definition at line 78 of file timestamp.h.
#define INTERVAL_FULL_RANGE (0x7FFF) |
Definition at line 76 of file timestamp.h.
Definition at line 73 of file timestamp.h.
#define INTERVAL_PRECISION | ( | t | ) | ((t) & INTERVAL_PRECISION_MASK) |
Definition at line 81 of file timestamp.h.
#define INTERVAL_PRECISION_MASK (0xFFFF) |
Definition at line 79 of file timestamp.h.
#define INTERVAL_RANGE | ( | t | ) | (((t) >> 16) & INTERVAL_RANGE_MASK) |
Definition at line 82 of file timestamp.h.
#define INTERVAL_RANGE_MASK (0x7FFF) |
Definition at line 77 of file timestamp.h.
#define INTERVAL_TYPMOD | ( | p, | |
r | |||
) | ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK)) |
Definition at line 80 of file timestamp.h.
#define PG_GETARG_INTERVAL_P | ( | n | ) | DatumGetIntervalP(PG_GETARG_DATUM(n)) |
Definition at line 65 of file timestamp.h.
#define PG_GETARG_TIMESTAMP | ( | n | ) | DatumGetTimestamp(PG_GETARG_DATUM(n)) |
Definition at line 63 of file timestamp.h.
#define PG_GETARG_TIMESTAMPTZ | ( | n | ) | DatumGetTimestampTz(PG_GETARG_DATUM(n)) |
Definition at line 64 of file timestamp.h.
#define PG_RETURN_INTERVAL_P | ( | x | ) | return IntervalPGetDatum(x) |
Definition at line 69 of file timestamp.h.
#define PG_RETURN_TIMESTAMP | ( | x | ) | return TimestampGetDatum(x) |
Definition at line 67 of file timestamp.h.
#define PG_RETURN_TIMESTAMPTZ | ( | x | ) | return TimestampTzGetDatum(x) |
Definition at line 68 of file timestamp.h.
Definition at line 72 of file timestamp.h.
#define timestamptz_cmp_internal | ( | dt1, | |
dt2 | |||
) | timestamp_cmp_internal(dt1, dt2) |
Definition at line 127 of file timestamp.h.
#define TimestampTzPlusMilliseconds | ( | tz, | |
ms | |||
) | ((tz) + ((ms) * (int64) 1000)) |
Definition at line 85 of file timestamp.h.
#define TimestampTzPlusSeconds | ( | tz, | |
s | |||
) | ((tz) + ((s) * (int64) 1000000)) |
Definition at line 86 of file timestamp.h.
int date2isoweek | ( | int | year, |
int | mon, | ||
int | mday | ||
) |
Definition at line 4518 of file timestamp.c.
References date2j(), and j2day().
Referenced by DCH_to_char(), extract_date(), timestamp_part_common(), timestamp_trunc(), timestamptz_part_common(), and timestamptz_trunc_internal().
int date2isoyear | ( | int | year, |
int | mon, | ||
int | mday | ||
) |
Definition at line 4573 of file timestamp.c.
References date2j(), and j2day().
Referenced by date2isoyearday(), DCH_to_char(), extract_date(), timestamp_part_common(), and timestamptz_part_common().
int date2isoyearday | ( | int | year, |
int | mon, | ||
int | mday | ||
) |
Definition at line 4630 of file timestamp.c.
References date2isoyear(), date2j(), and isoweek2j().
Referenced by DCH_to_char().
Definition at line 40 of file timestamp.h.
References DatumGetPointer().
Referenced by abs_interval(), check_timezone(), convert_timevalue_to_scalar(), gbt_intv_compress(), gbt_time_dist(), gbt_time_penalty(), gbt_ts_dist(), in_range_interval_interval(), interval_accum(), interval_accum_inv(), interval_avg(), interval_combine(), interval_dist(), time_dist(), timestamp_mi(), ts_dist(), and tstz_dist().
Definition at line 28 of file timestamp.h.
References DatumGetInt64().
Referenced by compareDatetime(), convert_timevalue_to_scalar(), gbt_num_compress(), generate_series_timestamp(), in_range_timestamp_interval(), JsonEncodeDateTime(), map_sql_value_to_xml_value(), and timestamp_fastcmp().
|
inlinestatic |
Definition at line 34 of file timestamp.h.
References DatumGetInt64().
Referenced by compareDatetime(), convert_timevalue_to_scalar(), gbt_tstz_compress(), get_role_password(), JsonEncodeDateTime(), and validateRecoveryParameters().
Definition at line 1811 of file timestamp.c.
References USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.
Referenced by DecodeDateTime(), DecodeTimeOnly(), and timestamp2tm().
TimestampTz GetCurrentTimestamp | ( | void | ) |
Definition at line 1582 of file timestamp.c.
References gettimeofday(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.
Referenced by ApplyLauncherMain(), ApplyWorkerMain(), asyncQueueFillWarning(), autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), bbsink_copystream_archive_contents(), bbsink_copystream_end_archive(), bbsink_copystream_new(), bbsink_throttle_begin_backup(), check_log_duration(), CheckPointGuts(), CleanupBackgroundWorker(), clock_timestamp(), CreateCheckPoint(), CreateEndOfRecoveryRecord(), CreateOverwriteContrecordRecord(), CreateRestartPoint(), DetermineSleepTime(), disable_timeout(), disable_timeouts(), do_analyze_rel(), do_start_bgworker(), do_start_worker(), enable_startup_progress_timeout(), enable_timeout_after(), enable_timeout_at(), enable_timeout_every(), enable_timeouts(), entry_reset(), get_role_password(), GetCurrentTransactionStopTimestamp(), GetReplicationApplyDelay(), GetSnapshotCurrentTimestamp(), handle_sig_alarm(), has_startup_progress_timeout_expired(), heap_vacuum_rel(), initialize_drandom_seed(), InitProcessGlobals(), KnownAssignedXidsCompress(), launcher_determine_sleep(), LockBufferForCleanup(), log_disconnections(), LogCheckpointEnd(), logicalrep_worker_launch(), LogicalRepApplyLoop(), maybe_start_bgworkers(), pa_send_data(), PerformWalRecovery(), pgfdw_cancel_query(), pgfdw_exec_cleanup_query(), pgfdw_get_cleanup_result(), pgss_shmem_startup(), pgstat_build_snapshot(), pgstat_report_activity(), pgstat_report_analyze(), pgstat_report_archiver(), pgstat_report_autovac(), pgstat_report_checksum_failures_in_db(), pgstat_report_vacuum(), pgstat_reset(), pgstat_reset_after_failure(), pgstat_reset_counters(), pgstat_reset_of_kind(), pgstat_reset_slru(), PostgresSingleUserMain(), PostmasterMain(), PrepareTransaction(), process_syncing_tables_for_apply(), ProcessConfigFileInternal(), ProcessPendingWrites(), ProcessRepliesIfAny(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcSleep(), rebuild_database_list(), RecordTransactionAbort(), RecordTransactionAbortPrepared(), RecordTransactionCommitPrepared(), recoveryApplyDelay(), reschedule_timeouts(), ResolveRecoveryConflictWithBufferPin(), ResolveRecoveryConflictWithLock(), ResolveRecoveryConflictWithVirtualXIDs(), send_feedback(), SetCurrentStatementStartTimestamp(), StartTransaction(), test_pattern(), throttle(), UpdateWorkerStats(), WaitExceedsMaxStandbyDelay(), WaitForWALToBecomeAvailable(), WalReceiverMain(), WalSndKeepalive(), WalSndLoop(), WalSndUpdateProgress(), WalSndWaitForWal(), WalSndWriteData(), XLogBackgroundFlush(), XLogFileRead(), XLogPrefetchResetStats(), XLogPrefetchShmemInit(), XLogRestorePoint(), XLogSendPhysical(), XLogWalRcvSendHSFeedback(), and XLogWalRcvSendReply().
void GetEpochTime | ( | struct pg_tm * | tm | ) |
Definition at line 2091 of file timestamp.c.
References elog(), epoch, ERROR, pg_gmtime(), 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 date_in(), PGTYPESdate_from_asc(), and SetEpochTimestamp().
Definition at line 1984 of file timestamp.c.
References Interval::day, Interval::month, MONTHS_PER_YEAR, Interval::time, pg_itm::tm_hour, pg_itm::tm_mday, pg_itm::tm_min, pg_itm::tm_mon, pg_itm::tm_sec, pg_itm::tm_usec, pg_itm::tm_year, USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.
Referenced by interval_out(), interval_part_common(), interval_to_char(), and interval_trunc().
Definition at line 58 of file timestamp.h.
References PointerGetDatum().
Referenced by abs_interval(), gbt_intveq(), gbt_intvge(), gbt_intvgt(), gbt_intvkey_cmp(), gbt_intvle(), gbt_intvlt(), in_range_date_interval(), in_range_interval_interval(), in_range_timestamp_interval(), interval_accum(), interval_accum_inv(), interval_avg(), interval_combine(), leftmostvalue_interval(), pg_stat_get_wal_senders(), pg_timezone_abbrevs(), and timestamp_mi().
void isoweek2date | ( | int | woy, |
int * | year, | ||
int * | mon, | ||
int * | mday | ||
) |
Definition at line 4487 of file timestamp.c.
References isoweek2j(), and j2date().
Referenced by do_to_timestamp(), timestamp_trunc(), and timestamptz_trunc_internal().
int isoweek2j | ( | int | year, |
int | week | ||
) |
Definition at line 4467 of file timestamp.c.
References date2j(), and j2day().
Referenced by date2isoyearday(), do_to_timestamp(), isoweek2date(), and isoweekdate2date().
void isoweekdate2date | ( | int | isoweek, |
int | wday, | ||
int * | year, | ||
int * | mon, | ||
int * | mday | ||
) |
Definition at line 4500 of file timestamp.c.
References isoweek2j(), and j2date().
Referenced by do_to_timestamp().
Definition at line 2011 of file timestamp.c.
References Interval::day, if(), Interval::month, MONTHS_PER_YEAR, pg_add_s64_overflow(), pg_mul_s64_overflow(), Interval::time, pg_itm::tm_hour, pg_itm::tm_mday, pg_itm::tm_min, pg_itm::tm_mon, pg_itm::tm_sec, pg_itm::tm_usec, pg_itm::tm_year, USECS_PER_HOUR, USECS_PER_MINUTE, and USECS_PER_SEC.
Referenced by interval_trunc(), timestamp_age(), and timestamptz_age().
Definition at line 2040 of file timestamp.c.
References Interval::day, if(), Interval::month, MONTHS_PER_YEAR, Interval::time, pg_itm_in::tm_mday, pg_itm_in::tm_mon, pg_itm_in::tm_usec, and pg_itm_in::tm_year.
Referenced by interval_in(), and pg_timezone_abbrevs().
Timestamp SetEpochTimestamp | ( | void | ) |
Definition at line 2113 of file timestamp.c.
References GetEpochTime(), tm, and tm2timestamp().
Referenced by dttofmtasc_replace(), PGTYPEStimestamp_from_asc(), timestamp_in(), timestamp_part_common(), timestamptz_in(), and timestamptz_part_common().
TimestampTz time_t_to_timestamptz | ( | pg_time_t | tm | ) |
Definition at line 1748 of file timestamp.c.
References POSTGRES_EPOCH_JDATE, SECS_PER_DAY, tm, UNIX_EPOCH_JDATE, and USECS_PER_SEC.
Referenced by pg_control_checkpoint(), pg_control_system(), pg_ls_dir_files(), and pg_stat_file().
TimestampTz timestamp2timestamptz_opt_overflow | ( | Timestamp | timestamp, |
int * | overflow | ||
) |
Definition at line 5569 of file timestamp.c.
References DetermineTimeZoneOffset(), dt2local(), ereport, errcode(), errmsg(), ERROR, IS_VALID_TIMESTAMP, MIN_TIMESTAMP, session_timezone, timestamp2tm(), TIMESTAMP_NOBEGIN, TIMESTAMP_NOEND, TIMESTAMP_NOT_FINITE, and tm.
Referenced by timestamp2timestamptz(), and timestamp_cmp_timestamptz_internal().
int timestamp2tm | ( | Timestamp | dt, |
int * | tzp, | ||
struct pg_tm * | tm, | ||
fsec_t * | fsec, | ||
const char ** | tzn, | ||
pg_tz * | attimezone | ||
) |
Definition at line 1838 of file timestamp.c.
References dt2time(), j2date(), pg_localtime(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, session_timezone, tm, pg_tm::tm_gmtoff, 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_year, pg_tm::tm_zone, TMODULO, UNIX_EPOCH_JDATE, USECS_PER_DAY, and USECS_PER_SEC.
Referenced by DetermineTimeZoneAbbrevOffsetTS(), GetCurrentTimeUsec(), JsonEncodeDateTime(), make_timestamptz_at_timezone(), map_sql_value_to_xml_value(), PGTYPEStimestamp_add_interval(), PGTYPEStimestamp_fmt_asc(), PGTYPEStimestamp_to_asc(), timestamp2timestamptz_opt_overflow(), timestamp_age(), timestamp_date(), timestamp_out(), timestamp_part_common(), timestamp_pl_interval(), timestamp_recv(), timestamp_time(), timestamp_to_char(), timestamp_trunc(), timestamp_zone(), timestamptz2timestamp(), timestamptz_age(), timestamptz_date(), timestamptz_out(), timestamptz_part_common(), timestamptz_pl_interval_internal(), timestamptz_recv(), timestamptz_time(), timestamptz_timetz(), timestamptz_to_char(), timestamptz_to_str(), timestamptz_trunc_internal(), timestamptz_zone(), and timetz_zone().
Definition at line 2133 of file timestamp.c.
Referenced by date_cmp_timestamp_internal(), generate_series_timestamp(), generate_series_timestamptz_internal(), timestamp_cmp(), timestamp_eq(), timestamp_fastcmp(), timestamp_ge(), timestamp_gt(), timestamp_larger(), timestamp_le(), timestamp_lt(), timestamp_ne(), and timestamp_smaller().
int32 timestamp_cmp_timestamptz_internal | ( | Timestamp | timestampVal, |
TimestampTz | dt2 | ||
) |
Definition at line 2248 of file timestamp.c.
References timestamp2timestamptz_opt_overflow(), TIMESTAMP_IS_NOBEGIN, TIMESTAMP_IS_NOEND, and timestamptz_cmp_internal.
Referenced by cmpTimestampToTimestampTz(), timestamp_cmp_timestamptz(), timestamp_eq_timestamptz(), timestamp_ge_timestamptz(), timestamp_gt_timestamptz(), timestamp_le_timestamptz(), timestamp_lt_timestamptz(), timestamp_ne_timestamptz(), timestamptz_cmp_timestamp(), timestamptz_eq_timestamp(), timestamptz_ge_timestamp(), timestamptz_gt_timestamp(), timestamptz_le_timestamp(), timestamptz_lt_timestamp(), and timestamptz_ne_timestamp().
void TimestampDifference | ( | TimestampTz | start_time, |
TimestampTz | stop_time, | ||
long * | secs, | ||
int * | microsecs | ||
) |
Definition at line 1667 of file timestamp.c.
References start_time, and USECS_PER_SEC.
Referenced by check_log_duration(), has_startup_progress_timeout_expired(), heap_vacuum_rel(), launcher_determine_sleep(), log_disconnections(), LogRecoveryConflict(), pgstat_report_activity(), pgstat_update_dbstats(), ProcSleep(), and schedule_alarm().
bool TimestampDifferenceExceeds | ( | TimestampTz | start_time, |
TimestampTz | stop_time, | ||
int | msec | ||
) |
Definition at line 1727 of file timestamp.c.
References start_time.
Referenced by asyncQueueFillWarning(), AutoVacLauncherMain(), do_analyze_rel(), do_start_worker(), heap_vacuum_rel(), LockBufferForCleanup(), logicalrep_worker_launch(), maybe_start_bgworkers(), pa_send_data(), pgstat_report_stat(), process_syncing_tables_for_apply(), ProcSleep(), ResolveRecoveryConflictWithVirtualXIDs(), send_feedback(), WaitForWALToBecomeAvailable(), WalSndUpdateProgress(), and XLogBackgroundFlush().
long TimestampDifferenceMilliseconds | ( | TimestampTz | start_time, |
TimestampTz | stop_time | ||
) |
Definition at line 1703 of file timestamp.c.
References pg_sub_s64_overflow(), and start_time.
Referenced by ApplyLauncherMain(), autoprewarm_main(), bbsink_copystream_archive_contents(), DetermineSleepTime(), do_analyze_rel(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), LogCheckpointEnd(), pgfdw_get_cleanup_result(), recoveryApplyDelay(), WaitForWALToBecomeAvailable(), WalReceiverMain(), and WalSndComputeSleeptime().
Definition at line 46 of file timestamp.h.
References Int64GetDatum().
Referenced by date_mi_interval(), date_pl_interval(), gbt_num_fetch(), generate_series_timestamp(), in_range_date_interval(), in_range_timestamp_interval(), leftmostvalue_timestamp(), parse_datetime(), sql_localtimestamp(), and timestamp_mi_interval().
bool TimestampTimestampTzRequiresRewrite | ( | void | ) |
Definition at line 5538 of file timestamp.c.
References pg_get_timezone_offset(), and session_timezone.
Referenced by ATColumnChangeRequiresRewrite().
const char* timestamptz_to_str | ( | TimestampTz | t | ) |
Definition at line 1790 of file timestamp.c.
References buf, EncodeDateTime(), EncodeSpecialTimestamp(), MAXDATELEN, snprintf, strlcpy(), timestamp2tm(), TIMESTAMP_NOT_FINITE, timestamptz_to_time_t(), tm, USE_ISO_DATES, and USECS_PER_SEC.
Referenced by CreateRestartPoint(), getRecoveryStopReason(), InitWalRecovery(), PerformWalRecovery(), pg_decode_commit_prepared_txn(), pg_decode_commit_txn(), pg_decode_prepare_txn(), pg_decode_rollback_prepared_txn(), pg_decode_stream_commit(), pg_decode_stream_prepare(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), recoveryStopsAfter(), recoveryStopsBefore(), xact_desc_abort(), xact_desc_commit(), xact_desc_prepare(), xlog_desc(), and xlogrecovery_redo().
pg_time_t timestamptz_to_time_t | ( | TimestampTz | t | ) |
Definition at line 1770 of file timestamp.c.
References POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.
Referenced by DetermineTimeZoneAbbrevOffsetTS(), InitProcessGlobals(), and timestamptz_to_str().
|
inlinestatic |
Definition at line 52 of file timestamp.h.
References Int64GetDatum().
Referenced by current_timestamp(), generate_series_timestamptz_internal(), MakeOldSnapshotTimeMappingTuple(), parse_datetime(), pg_control_checkpoint(), pg_control_system(), pg_cursor(), pg_last_committed_xact(), pg_lock_status(), pg_ls_dir_files(), pg_prepared_statement(), pg_prepared_xact(), pg_stat_file(), pg_stat_get_activity(), pg_stat_get_archiver(), pg_stat_get_io(), pg_stat_get_recovery_prefetch(), pg_stat_get_replication_slot(), pg_stat_get_slru(), pg_stat_get_subscription(), pg_stat_get_subscription_stats(), pg_stat_get_wal(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_info(), and pg_xact_commit_timestamp_origin().
Definition at line 1934 of file timestamp.c.
References date2j(), dt2local(), IS_VALID_JULIAN, IS_VALID_TIMESTAMP, POSTGRES_EPOCH_JDATE, 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, and USECS_PER_DAY.
Referenced by check_recovery_target_time(), parse_datetime(), PGTYPEStimestamp_add_interval(), PGTYPEStimestamp_current(), PGTYPEStimestamp_defmt_scan(), PGTYPEStimestamp_from_asc(), SetEpochTimestamp(), timestamp_in(), timestamp_pl_interval(), timestamp_trunc(), timestamp_zone(), timestamptz2timestamp(), timestamptz_in(), timestamptz_pl_interval_internal(), timestamptz_trunc_internal(), timestamptz_zone(), and to_timestamp().
|
extern |
Definition at line 56 of file timestamp.c.
Referenced by pg_conf_load_time(), and ProcessConfigFileInternal().
|
extern |
Definition at line 53 of file timestamp.c.
Referenced by pg_postmaster_start_time(), PostgresSingleUserMain(), and PostmasterMain().