From e4292113c0ef821640220b959faf4768c67b7399 Mon Sep 17 00:00:00 2001 From: yuchao Date: Thu, 21 Sep 2023 19:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dunix=5Ftimestamp=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=8C=87=E5=AE=9A=E4=B8=8D=E5=90=8C=E6=97=B6=E5=8C=BA?= =?UTF-8?q?=E2=80=94=E2=80=94=E8=BF=94=E5=9B=9E=E5=80=BC=E8=B7=9Fmysql?= =?UTF-8?q?=E4=B8=8D=E7=9B=B8=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expected/unix_timestamp_timezone.out | 249 ++++++++++++++++++ contrib/dolphin/parallel_schedule_dolphin | 2 +- .../dolphin/plugin_utils/adt/timestamp.cpp | 4 + .../dolphin/sql/unix_timestamp_timezone.sql | 53 ++++ 4 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 contrib/dolphin/expected/unix_timestamp_timezone.out create mode 100644 contrib/dolphin/sql/unix_timestamp_timezone.sql diff --git a/contrib/dolphin/expected/unix_timestamp_timezone.out b/contrib/dolphin/expected/unix_timestamp_timezone.out new file mode 100644 index 000000000..8263ec459 --- /dev/null +++ b/contrib/dolphin/expected/unix_timestamp_timezone.out @@ -0,0 +1,249 @@ +create schema unix_timestamp_timezone; +set current_schema = unix_timestamp_timezone; +set timezone='PRC'; +select unix_timestamp('1970-01-01+00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01+08'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+08:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+08:00'); + unix_timestamp +---------------- + 0 +(1 row) + +set timezone='+00'; +select unix_timestamp('1970-01-01+00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01+08'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+00:00'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+08:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+08:00'); + unix_timestamp +---------------- + 28800 +(1 row) + +set timezone='+04'; +select unix_timestamp('1970-01-01+00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01+08'); + unix_timestamp +---------------- + 14400 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00'); + unix_timestamp +---------------- + 14400 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+00:00'); + unix_timestamp +---------------- + 14400 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+08:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+08:00'); + unix_timestamp +---------------- + 14400 +(1 row) + +set timezone='+08'; +select unix_timestamp('1970-01-01+00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01+08'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+00:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+08:00'); + unix_timestamp +---------------- + 0 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+08:00'); + unix_timestamp +---------------- + 0 +(1 row) + +set timezone='-08'; +select unix_timestamp('1970-01-01+00'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01+08'); + unix_timestamp +---------------- + 57600 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00'); + unix_timestamp +---------------- + 57600 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+00:00'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+00:00'); + unix_timestamp +---------------- + 57600 +(1 row) + +select unix_timestamp('1970-01-01 00:00:00+08:00'); + unix_timestamp +---------------- + 28800 +(1 row) + +select unix_timestamp('1970-01-01 08:00:00+08:00'); + unix_timestamp +---------------- + 57600 +(1 row) + +reset current_schema; +drop schema unix_timestamp_timezone cascade; diff --git a/contrib/dolphin/parallel_schedule_dolphin b/contrib/dolphin/parallel_schedule_dolphin index 9b644f9e5..d93be5544 100644 --- a/contrib/dolphin/parallel_schedule_dolphin +++ b/contrib/dolphin/parallel_schedule_dolphin @@ -119,7 +119,7 @@ test: case_sensitive_test_backquote/role_test test: test_mysql_prepare db_b_rename_user_test export_set if_not_exists_test test_create_index_if_not_exists -test: test_mysql_operator test_op_xor_unsignedint test_op_blob test_op_xor_boolandfloat test_mysql_char test_op_xor_dateandtime +test: test_mysql_operator test_op_xor_unsignedint test_op_blob test_op_xor_boolandfloat test_mysql_char test_op_xor_dateandtime unix_timestamp_timezone test: json_array json_object json_quote json_contains json_contains_path json_extract json_unquote json_keys json_search json_array_append diff --git a/contrib/dolphin/plugin_utils/adt/timestamp.cpp b/contrib/dolphin/plugin_utils/adt/timestamp.cpp index eb8ec1dab..9646d1bdb 100644 --- a/contrib/dolphin/plugin_utils/adt/timestamp.cpp +++ b/contrib/dolphin/plugin_utils/adt/timestamp.cpp @@ -2535,7 +2535,11 @@ recalc_t: if (attimezone == NULL && u_sess->time_cxt.HasCTZSet) { *tzp = u_sess->time_cxt.CTimeZone; tm->tm_isdst = 0; +#ifdef DOLPHIN + tm->tm_gmtoff = -u_sess->time_cxt.CTimeZone; +#else tm->tm_gmtoff = u_sess->time_cxt.CTimeZone; +#endif tm->tm_zone = NULL; if (tzn != NULL) *tzn = NULL; diff --git a/contrib/dolphin/sql/unix_timestamp_timezone.sql b/contrib/dolphin/sql/unix_timestamp_timezone.sql new file mode 100644 index 000000000..4c550aa12 --- /dev/null +++ b/contrib/dolphin/sql/unix_timestamp_timezone.sql @@ -0,0 +1,53 @@ +create schema unix_timestamp_timezone; +set current_schema = unix_timestamp_timezone; +set timezone='PRC'; +select unix_timestamp('1970-01-01+00'); +select unix_timestamp('1970-01-01+08'); +select unix_timestamp('1970-01-01 00:00:00'); +select unix_timestamp('1970-01-01 08:00:00'); +select unix_timestamp('1970-01-01 00:00:00+00:00'); +select unix_timestamp('1970-01-01 08:00:00+00:00'); +select unix_timestamp('1970-01-01 00:00:00+08:00'); +select unix_timestamp('1970-01-01 08:00:00+08:00'); + +set timezone='+00'; +select unix_timestamp('1970-01-01+00'); +select unix_timestamp('1970-01-01+08'); +select unix_timestamp('1970-01-01 00:00:00'); +select unix_timestamp('1970-01-01 08:00:00'); +select unix_timestamp('1970-01-01 00:00:00+00:00'); +select unix_timestamp('1970-01-01 08:00:00+00:00'); +select unix_timestamp('1970-01-01 00:00:00+08:00'); +select unix_timestamp('1970-01-01 08:00:00+08:00'); + +set timezone='+04'; +select unix_timestamp('1970-01-01+00'); +select unix_timestamp('1970-01-01+08'); +select unix_timestamp('1970-01-01 00:00:00'); +select unix_timestamp('1970-01-01 08:00:00'); +select unix_timestamp('1970-01-01 00:00:00+00:00'); +select unix_timestamp('1970-01-01 08:00:00+00:00'); +select unix_timestamp('1970-01-01 00:00:00+08:00'); +select unix_timestamp('1970-01-01 08:00:00+08:00'); + +set timezone='+08'; +select unix_timestamp('1970-01-01+00'); +select unix_timestamp('1970-01-01+08'); +select unix_timestamp('1970-01-01 00:00:00'); +select unix_timestamp('1970-01-01 08:00:00'); +select unix_timestamp('1970-01-01 00:00:00+00:00'); +select unix_timestamp('1970-01-01 08:00:00+00:00'); +select unix_timestamp('1970-01-01 00:00:00+08:00'); +select unix_timestamp('1970-01-01 08:00:00+08:00'); + +set timezone='-08'; +select unix_timestamp('1970-01-01+00'); +select unix_timestamp('1970-01-01+08'); +select unix_timestamp('1970-01-01 00:00:00'); +select unix_timestamp('1970-01-01 08:00:00'); +select unix_timestamp('1970-01-01 00:00:00+00:00'); +select unix_timestamp('1970-01-01 08:00:00+00:00'); +select unix_timestamp('1970-01-01 00:00:00+08:00'); +select unix_timestamp('1970-01-01 08:00:00+08:00'); +reset current_schema; +drop schema unix_timestamp_timezone cascade; -- Gitee