diff --git a/contrib/dolphin/expected/unix_timestamp_timezone.out b/contrib/dolphin/expected/unix_timestamp_timezone.out new file mode 100644 index 0000000000000000000000000000000000000000..8263ec459224173111e67567ce646a43f9bf447a --- /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 9b644f9e5cef235aed3b7bc088a753b52979585c..d93be5544e1368535db8a353075f9ba5e07baf24 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 eb8ec1dab0d72436ffd724690eb440e20d9760ad..9646d1bdbc5878eced4f00fde4ddae186d77dc7c 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 0000000000000000000000000000000000000000..4c550aa128e2a0b30ebb5182ced120783549a0f9 --- /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;