From 477943c6098d153a80977ed8151bac4c0626bb2a Mon Sep 17 00:00:00 2001 From: cqliang1995 Date: Wed, 17 May 2023 08:16:49 +0000 Subject: [PATCH] fix string type null value error in dblink. --- deps/oblib/src/common/object/ob_obj_funcs.h | 6 +++++- deps/oblib/src/common/object/ob_object.h | 3 ++- src/sql/engine/dml/ob_link_op.cpp | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/deps/oblib/src/common/object/ob_obj_funcs.h b/deps/oblib/src/common/object/ob_obj_funcs.h index 7130d4b289..9d51601313 100644 --- a/deps/oblib/src/common/object/ob_obj_funcs.h +++ b/deps/oblib/src/common/object/ob_obj_funcs.h @@ -97,7 +97,11 @@ template <> UNUSED(obj); UNUSED(params); int ret = OB_SUCCESS; - ret = databuff_printf(buffer, length, pos, "NULL"); + if (params.print_null_string_value_) { + ret = databuff_printf(buffer, length, pos, "''"); + } else { + ret = databuff_printf(buffer, length, pos, "NULL"); + } return ret; } template <> diff --git a/deps/oblib/src/common/object/ob_object.h b/deps/oblib/src/common/object/ob_object.h index 86468dbffd..621dd83a6d 100644 --- a/deps/oblib/src/common/object/ob_object.h +++ b/deps/oblib/src/common/object/ob_object.h @@ -1115,7 +1115,8 @@ struct ObObjPrintParams uint32_t binary_string_print_hex_:1; uint32_t need_print_converter_:1; uint32_t print_const_expr_type_:1; - uint32_t reserved_:23; + uint32_t print_null_string_value_:1; + uint32_t reserved_:22; }; }; diff --git a/src/sql/engine/dml/ob_link_op.cpp b/src/sql/engine/dml/ob_link_op.cpp index fc5f265f94..bcb7fb8c54 100644 --- a/src/sql/engine/dml/ob_link_op.cpp +++ b/src/sql/engine/dml/ob_link_op.cpp @@ -240,6 +240,10 @@ int ObLinkOp::combine_link_stmt(const ObString &link_stmt_fmt, int64_t param_idx = param_infos.at(next_param).idx_; const ObObjParam ¶m = param_store.at(param_idx); ObObjPrintParams obj_print_params = CREATE_OBJ_PRINT_PARAM(ctx_.get_my_session()); + + if (lib::is_oracle_mode() && ObSQLUtils::is_oracle_empty_string(param)) { + obj_print_params.print_null_string_value_ = true; + } if (DBLINK_DRV_OCI == link_type_) { // Ensure that when oceanbase connects to oracle, // the target character set of param is the same as that of oci connection.