Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d9819f

Browse files
committed
Measure epoch of timestamp-without-time-zone from local not UTC midnight.
This patch reverts commit191ef2band thereby restores the pre-7.3 behavior of EXTRACT(EPOCH FROMtimestamp-without-tz). Per discussion, the more recent behavior wasmisguided on a couple of grounds: it makes it hard to get anon-timezone-aware epoch value for a timestamp, and it makes this onecase dependent on the value of the timezone GUC, which is incompatiblewith having timestamp_part() labeled as immutable.The other behavior is still available (in all releases) by explicitlycasting the timestamp to timestamp with time zone before applying EXTRACT.This will need to be called out as an incompatible change in the 9.2release notes. Although having mutable behavior in a function markedimmutable is clearly a bug, we're not going to back-patch such a change.
1 parent442da68 commit0d9819f

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6684,8 +6684,10 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
66846684
<term><literal>epoch</literal></term>
66856685
<listitem>
66866686
<para>
6687-
For <type>date</type> and <type>timestamp</type> values, the
6687+
For <type>timestamp with time zone</type> values, the
66886688
number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
6689+
for <type>date</type> and <type>timestamp</type> values, the
6690+
number of seconds since 1970-01-01 00:00:00 local time;
66896691
for <type>interval</type> values, the total number
66906692
of seconds in the interval
66916693
</para>

‎src/backend/utils/adt/timestamp.c

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,32 +4066,13 @@ timestamp_part(PG_FUNCTION_ARGS)
40664066
switch (val)
40674067
{
40684068
caseDTK_EPOCH:
4069-
{
4070-
inttz;
4071-
TimestampTztimestamptz;
4072-
4073-
/*
4074-
* convert to timestamptz to produce consistent results
4075-
*/
4076-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4077-
ereport(ERROR,
4078-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4079-
errmsg("timestamp out of range")));
4080-
4081-
tz=DetermineTimeZoneOffset(tm,session_timezone);
4082-
4083-
if (tm2timestamp(tm,fsec,&tz,&timestamptz)!=0)
4084-
ereport(ERROR,
4085-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4086-
errmsg("timestamp out of range")));
4087-
40884069
#ifdefHAVE_INT64_TIMESTAMP
4089-
result= (timestamptz-SetEpochTimestamp()) /1000000.0;
4070+
result= (timestamp-SetEpochTimestamp()) /1000000.0;
40904071
#else
4091-
result=timestamptz-SetEpochTimestamp();
4072+
result=timestamp-SetEpochTimestamp();
40924073
#endif
40934074
break;
4094-
}
4075+
40954076
caseDTK_DOW:
40964077
caseDTK_ISODOW:
40974078
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp