From f37ee2fdd6e27a83e59c9cd03bbb057effafac83 Mon Sep 17 00:00:00 2001 From: Wang Yuxuan Date: Thu, 7 Nov 2024 22:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20!7165=20=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E5=AF=B9to=5Fchar=E8=B0=83=E7=94=A8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/adt/formatting.cpp | 4 +++- src/test/regress/expected/hw_functions.out | 6 ++++++ src/test/regress/sql/hw_functions.sql | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/backend/utils/adt/formatting.cpp b/src/common/backend/utils/adt/formatting.cpp index 0367cf913c..71d4b7869a 100644 --- a/src/common/backend/utils/adt/formatting.cpp +++ b/src/common/backend/utils/adt/formatting.cpp @@ -4638,7 +4638,9 @@ Datum blob_to_char_default(PG_FUNCTION_ARGS) Datum unknown_to_char2(PG_FUNCTION_ARGS) { - Datum result = DirectFunctionCall2(numeric_to_char, PG_GETARG_DATUM(0), PG_GETARG_DATUM(1)); + Datum arg0 = DirectFunctionCall3(numeric_in, PG_GETARG_DATUM(0), NUMERICOID, -1); + Datum arg1 = DirectFunctionCall1(textin, PG_GETARG_DATUM(1)); + Datum result = DirectFunctionCall2(numeric_to_char, arg0, arg1); PG_RETURN_DATUM(result); } diff --git a/src/test/regress/expected/hw_functions.out b/src/test/regress/expected/hw_functions.out index d19360d0be..f8604a9272 100644 --- a/src/test/regress/expected/hw_functions.out +++ b/src/test/regress/expected/hw_functions.out @@ -957,4 +957,10 @@ SELECT to_char('',''); (1 row) +SELECT to_char('2020-08-26 14:57:33','yyyy-mon-dd hh24:mi:ss'); +ERROR: invalid input syntax for type numeric: "2020-08-26 14:57:33" +CONTEXT: referenced column: to_char +SELECT to_char('2020','yyyy-mon-dd hh24:mi:ss'); +ERROR: multiple decimal points +CONTEXT: referenced column: to_char drop schema basefunc cascade; diff --git a/src/test/regress/sql/hw_functions.sql b/src/test/regress/sql/hw_functions.sql index f18e611f02..d637c951c6 100644 --- a/src/test/regress/sql/hw_functions.sql +++ b/src/test/regress/sql/hw_functions.sql @@ -373,5 +373,7 @@ SELECT to_char(c1, 873) FROM blob_table ; DROP TABLE blob_table; DROP TABLE blob_t; SELECT to_char('',''); +SELECT to_char('2020-08-26 14:57:33','yyyy-mon-dd hh24:mi:ss'); +SELECT to_char('2020','yyyy-mon-dd hh24:mi:ss'); drop schema basefunc cascade; -- Gitee