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 131 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.
Definition at line 124 of file timestamp.c.
References ereport, errcode(), errmsg(), ERROR, MAX_TIMESTAMP_PRECISION, and WARNING.
Referenced by anytimestamp_typmodin(), executeDateTimeMethod(), and transformSQLValueFunction().
int date2isoweek | ( | int | year, |
int | mon, | ||
int | mday | ||
) |
Definition at line 5247 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 5302 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 5359 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(), generate_series_timestamp_support(), in_range_interval_interval(), 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(), executeDateTimeMethod(), gbt_num_compress(), generate_series_timestamp(), generate_series_timestamp_support(), 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(), executeDateTimeMethod(), gbt_tstz_compress(), get_role_password(), JsonEncodeDateTime(), uuidv7_interval(), and validateRecoveryParameters().
Definition at line 1864 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 1644 of file timestamp.c.
References gettimeofday(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.
Referenced by ApplyLauncherMain(), asyncQueueFillWarning(), autoprewarm_main(), BackgroundWriterMain(), bbsink_copystream_archive_contents(), bbsink_copystream_end_archive(), bbsink_copystream_new(), bbsink_throttle_begin_backup(), check_log_duration(), CheckPointGuts(), CleanupBackend(), clock_timestamp(), CreateCheckPoint(), CreateEndOfRecoveryRecord(), CreateOverwriteContrecordRecord(), CreateRestartPoint(), dblink_cancel_query(), DetermineSleepTime(), disable_timeout(), disable_timeouts(), do_analyze_rel(), do_start_worker(), enable_startup_progress_timeout(), enable_timeout_after(), enable_timeout_at(), enable_timeout_every(), enable_timeouts(), entry_alloc(), entry_reset(), get_role_password(), GetCurrentTransactionStopTimestamp(), GetReplicationApplyDelay(), handle_sig_alarm(), has_startup_progress_timeout_expired(), heap_vacuum_rel(), initialize_prng(), InitProcessGlobals(), KnownAssignedXidsCompress(), launcher_determine_sleep(), libpqsrv_cancel(), LockBufferForCleanup(), log_disconnections(), LogCheckpointEnd(), logicalrep_worker_launch(), LogicalRepApplyLoop(), maybe_start_bgworkers(), pa_send_data(), PerformWalRecovery(), pgfdw_abort_cleanup_begin(), pgfdw_cancel_query(), pgfdw_exec_cleanup_query(), pgfdw_finish_abort_cleanup(), 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_stat(), 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(), ReplicationSlotRelease(), reschedule_timeouts(), ResolveRecoveryConflictWithBufferPin(), ResolveRecoveryConflictWithLock(), ResolveRecoveryConflictWithVirtualXIDs(), RestoreSlotFromDisk(), send_feedback(), SetCurrentStatementStartTimestamp(), SetupApplyOrSyncWorker(), StartBackgroundWorker(), StartTransaction(), test_pattern(), test_random(), throttle(), update_synced_slots_inactive_since(), UpdateWorkerStats(), WaitExceedsMaxStandbyDelay(), WaitForWalSummarization(), 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 2149 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().
TimestampTz GetSQLCurrentTimestamp | ( | int32 | typmod | ) |
Definition at line 1662 of file timestamp.c.
References AdjustTimestampForTypmod(), and GetCurrentTransactionStartTimestamp().
Referenced by ExecEvalSQLValueFunction().
Definition at line 1676 of file timestamp.c.
References AdjustTimestampForTypmod(), GetCurrentTransactionStartTimestamp(), and timestamptz2timestamp().
Referenced by ExecEvalSQLValueFunction().
Definition at line 2028 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_avg(), leftmostvalue_interval(), pg_stat_get_wal_senders(), pg_timezone_abbrevs(), timestamp_mi(), and uuidv7_interval().
void isoweek2date | ( | int | woy, |
int * | year, | ||
int * | mon, | ||
int * | mday | ||
) |
Definition at line 5216 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 5196 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 5229 of file timestamp.c.
References isoweek2j(), and j2date().
Referenced by do_to_timestamp().
Definition at line 2058 of file timestamp.c.
References Interval::day, if(), INTERVAL_NOT_FINITE, 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 2096 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 2171 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 1801 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 6400 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 1891 of file timestamp.c.
References dt2time(), INT64CONST, 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(), executeDateTimeMethod(), 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 2191 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 2318 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 1720 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 1780 of file timestamp.c.
References INT64CONST, and start_time.
Referenced by asyncQueueFillWarning(), 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 1756 of file timestamp.c.
References INT64CONST, pg_sub_s64_overflow(), and start_time.
Referenced by ApplyLauncherMain(), autoprewarm_main(), bbsink_copystream_archive_contents(), DetermineSleepTime(), do_analyze_rel(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), libpqsrv_cancel(), LogCheckpointEnd(), pgfdw_get_cleanup_result(), recoveryApplyDelay(), WaitForWalSummarization(), WaitForWALToBecomeAvailable(), WalReceiverMain(), and WalSndComputeSleeptime().
Definition at line 46 of file timestamp.h.
References Int64GetDatum().
Referenced by date_mi_interval(), date_pl_interval(), ExecEvalSQLValueFunction(), executeDateTimeMethod(), gbt_num_fetch(), generate_series_timestamp(), generate_series_timestamp_support(), in_range_date_interval(), in_range_timestamp_interval(), leftmostvalue_timestamp(), parse_datetime(), and timestamp_mi_interval().
bool TimestampTimestampTzRequiresRewrite | ( | void | ) |
Definition at line 6369 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 1843 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(), errdetail_apply_conflict(), 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 1823 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 ExecEvalSQLValueFunction(), executeDateTimeMethod(), generate_series_timestamptz_internal(), parse_datetime(), pg_control_checkpoint(), pg_control_system(), pg_cursor(), pg_get_replication_slots(), 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_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_io_build_tuples(), pg_stat_statements_info(), pg_stat_statements_internal(), pg_xact_commit_timestamp_origin(), and uuidv7_interval().
Definition at line 1987 of file timestamp.c.
References date2j(), dt2local(), IS_VALID_JULIAN, IS_VALID_TIMESTAMP, pg_add_s64_overflow(), pg_mul_s64_overflow(), 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, unlikely, 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().