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 */