Skip to content

Commit a6888fd

Browse files
committed
Refactor timestamp2timestamptz_opt_error()
While casting from timestamp to timestamptz we do timestamp2tm() then tm2timestamp(). This commit eliminates call to tm2timestamp(). Instead, it directly applies timezone offset to the original timestamp value. That makes upcoming datetime overflow handling in jsonpath easier. That should also save us some CPU cycles. Discussion: https://postgr.es/m/CAPpHfdvRPRh_mTGar5WmDeRZ%3DU5dOXHdxspYYD%3D76m3knNGjXA%40mail.gmail.com Author: Alexander Korotkov Reviewed-by: Tom Lane
1 parent db477b6 commit a6888fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5210,8 +5210,17 @@ timestamp2timestamptz_opt_error(Timestamp timestamp, bool *have_error)
52105210
{
52115211
tz = DetermineTimeZoneOffset(tm, session_timezone);
52125212

5213-
if (!tm2timestamp(tm, fsec, &tz, &result))
5213+
result = dt2local(timestamp, -tz);
5214+
5215+
if (IS_VALID_TIMESTAMP(result))
5216+
{
52145217
return result;
5218+
}
5219+
else if (have_error)
5220+
{
5221+
*have_error = true;
5222+
return (TimestampTz) 0;
5223+
}
52155224
}
52165225

52175226
if (have_error)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy