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

Commita6888fd

Browse files
committed
Refactor timestamp2timestamptz_opt_error()
While casting from timestamp to timestamptz we do timestamp2tm() thentm2timestamp(). This commit eliminates call to tm2timestamp(). Instead, itdirectly applies timezone offset to the original timestamp value. That makesupcoming datetime overflow handling in jsonpath easier. That should also saveus some CPU cycles.Discussion:https://postgr.es/m/CAPpHfdvRPRh_mTGar5WmDeRZ%3DU5dOXHdxspYYD%3D76m3knNGjXA%40mail.gmail.comAuthor: Alexander KorotkovReviewed-by: Tom Lane
1 parentdb477b6 commita6888fd

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
returnresult;
5218+
}
5219+
elseif (have_error)
5220+
{
5221+
*have_error= true;
5222+
return (TimestampTz)0;
5223+
}
52155224
}
52165225

52175226
if (have_error)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp