From 04cd2263b9b30a29ae5d065bff2448dd2a3855ff Mon Sep 17 00:00:00 2001 From: wangfeihuo Date: Fri, 29 Nov 2024 12:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=A0=87=E9=A2=98=E3=80=91=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dstamp(3)=E7=B1=BB=E5=9E=8B=E5=8D=A0=E4=BD=8D?= =?UTF-8?q?=E7=AC=A6=E4=BC=A0=E5=8F=82=E8=BF=9B=E8=A1=8C=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=95=B0=E6=8D=AE=E4=B8=BA=E7=A9=BA=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E6=9C=89=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98.=20=EF=BC=88cherry=20picked=20commit=20from=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builtin_funcs/b_compatibility_time_funcs3.out | 15 +++++++++++++++ contrib/dolphin/plugin_utils/adt/timestamp.cpp | 4 ++-- .../builtin_funcs/b_compatibility_time_funcs3.sql | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/contrib/dolphin/expected/builtin_funcs/b_compatibility_time_funcs3.out b/contrib/dolphin/expected/builtin_funcs/b_compatibility_time_funcs3.out index 5c9231c91..43959a97a 100644 --- a/contrib/dolphin/expected/builtin_funcs/b_compatibility_time_funcs3.out +++ b/contrib/dolphin/expected/builtin_funcs/b_compatibility_time_funcs3.out @@ -2554,6 +2554,21 @@ NOTICE: RESULT COL :4714-11-23 08:00:00-08t NOTICE: RESULT COL :4714-11-24 00:00:00t NOTICE: RESULT COL :11:11:11+08t NOTICE: RESULT COL :11:11:11t +CREATE TABLE t_timestamp(id int, start_time timestamp(3) without time zone, endtime timestamp(3) with time zone); +insert into t_timestamp values (1, '2024-10-10 10:10:10.100', '2024-10-10 10:10:10.100'); +select id from t_timestamp where start_time >= '2024-10-10 10:10:10.100'::varchar and start_time <= '2024-10-10 10:10:10.100'::varchar; + id +---- + 1 +(1 row) + +select id from t_timestamp where endtime >= '2024-10-10 10:10:10.100'::varchar and endtime <= '2024-10-10 10:10:10.100'::varchar; + id +---- + 1 +(1 row) + +drop table t_timestamp; drop table test_time; drop table t_time; drop schema b_time_funcs3 cascade; diff --git a/contrib/dolphin/plugin_utils/adt/timestamp.cpp b/contrib/dolphin/plugin_utils/adt/timestamp.cpp index 69ecf04eb..734aa1872 100644 --- a/contrib/dolphin/plugin_utils/adt/timestamp.cpp +++ b/contrib/dolphin/plugin_utils/adt/timestamp.cpp @@ -1290,7 +1290,7 @@ Datum convert_text_datetime(PG_FUNCTION_ARGS) char* str = NULL; TimeErrorType time_error_type = TIME_CORRECT; str = DatumGetCString(DirectFunctionCall1(textout, textValue)); - Datum result = timestamp_internal(fcinfo, str, TIME_IN, &time_error_type); + Datum result = timestamp_internal(fcinfo, str, TEXT_TIME_EXPLICIT, &time_error_type); pfree_ext(str); PG_RETURN_TIMESTAMP(result); } @@ -1301,7 +1301,7 @@ Datum convert_text_timestamptz(PG_FUNCTION_ARGS) char* str = NULL; TimeErrorType time_error_type = TIME_CORRECT; str = DatumGetCString(DirectFunctionCall1(textout, textValue)); - Datum result = timestamptz_internal(fcinfo, str, TIME_IN, &time_error_type); + Datum result = timestamptz_internal(fcinfo, str, TEXT_TIME_EXPLICIT, &time_error_type); pfree_ext(str); PG_RETURN_TIMESTAMPTZ(result); } diff --git a/contrib/dolphin/sql/builtin_funcs/b_compatibility_time_funcs3.sql b/contrib/dolphin/sql/builtin_funcs/b_compatibility_time_funcs3.sql index 5d65e8baf..29b3e08c3 100644 --- a/contrib/dolphin/sql/builtin_funcs/b_compatibility_time_funcs3.sql +++ b/contrib/dolphin/sql/builtin_funcs/b_compatibility_time_funcs3.sql @@ -631,6 +631,11 @@ raise notice 'RESULT COL :%t', d; end; / +CREATE TABLE t_timestamp(id int, start_time timestamp(3) without time zone, endtime timestamp(3) with time zone); +insert into t_timestamp values (1, '2024-10-10 10:10:10.100', '2024-10-10 10:10:10.100'); +select id from t_timestamp where start_time >= '2024-10-10 10:10:10.100'::varchar and start_time <= '2024-10-10 10:10:10.100'::varchar; +select id from t_timestamp where endtime >= '2024-10-10 10:10:10.100'::varchar and endtime <= '2024-10-10 10:10:10.100'::varchar; +drop table t_timestamp; drop table test_time; drop table t_time; -- Gitee