From ddeeea67f3a8c0fdcec13ec7f3be8faf2169d9a9 Mon Sep 17 00:00:00 2001 From: wangpingyun <2418191738@qq.com> Date: Tue, 12 Nov 2024 14:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djdbc=E4=B8=8D=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E6=B5=AE=E7=82=B9=E6=95=B0=E7=89=B9=E6=AE=8A=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/adt/float.cpp | 11 ++++++++--- src/include/utils/builtins.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/backend/utils/adt/float.cpp b/src/common/backend/utils/adt/float.cpp index 9e84c0a5a..9959d7601 100644 --- a/src/common/backend/utils/adt/float.cpp +++ b/src/common/backend/utils/adt/float.cpp @@ -639,7 +639,7 @@ Datum float8out(PG_FUNCTION_ARGS) errno_t rc = EOK; if (isnan(num)) { - if (u_sess->attr.attr_sql.enable_binary_special_o_format) { + if (u_sess->attr.attr_sql.enable_binary_special_o_format && !is_req_from_jdbc()) { rc = strcpy_s(ascii, MAXDOUBLEWIDTH + 1, "Nan"); } else { rc = strcpy_s(ascii, MAXDOUBLEWIDTH + 1, "NaN"); @@ -649,7 +649,7 @@ Datum float8out(PG_FUNCTION_ARGS) } switch (is_infinite(num)) { case 1: - if (u_sess->attr.attr_sql.enable_binary_special_o_format) { + if (u_sess->attr.attr_sql.enable_binary_special_o_format && !is_req_from_jdbc()) { rc = strcpy_s(ascii, MAXDOUBLEWIDTH + 1, "Inf"); } else { rc = strcpy_s(ascii, MAXDOUBLEWIDTH + 1, "Infinity"); @@ -657,7 +657,7 @@ Datum float8out(PG_FUNCTION_ARGS) securec_check(rc, "\0", "\0"); break; case -1: - if (u_sess->attr.attr_sql.enable_binary_special_o_format) { + if (u_sess->attr.attr_sql.enable_binary_special_o_format && !is_req_from_jdbc()) { rc = strcpy_s(ascii, MAXDOUBLEWIDTH + 1, "-Inf"); } else { rc = strcpy_s(ascii, MAXDOUBLEWIDTH + 1, "-Infinity"); @@ -3168,3 +3168,8 @@ Datum to_binary_float_text_number(PG_FUNCTION_ARGS) PG_RETURN_FLOAT4((float4)result); } + +bool is_req_from_jdbc() +{ + return strcmp(u_sess->attr.attr_common.application_name, "PostgreSQL JDBC Driver") == 0; +} \ No newline at end of file diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 4807e94b8..18453bcdc 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -1905,5 +1905,6 @@ extern char *pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth); extern char *printTypmod(const char *typname, int32 typmod, Oid typmodout); /* float.cpp */ extern int float8_cmp_internal(float8 a, float8 b); +extern bool is_req_from_jdbc(); #endif /* BUILTINS_H */