!6640 修复jdbc无法识别浮点数特殊值

Merge pull request !6640 from 王平云/fix1
This commit is contained in:
opengauss_bot
2024-11-12 11:31:04 +00:00
committed by Gitee
2 changed files with 9 additions and 3 deletions

View File

@ -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;
}

View File

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