fix load data insert binary data bug
This commit is contained in:
		
							
								
								
									
										16
									
								
								deps/oblib/src/common/object/ob_obj_funcs.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								deps/oblib/src/common/object/ob_obj_funcs.h
									
									
									
									
										vendored
									
									
								
							@ -1108,8 +1108,10 @@ inline int obj_print_plain_str<ObHexStringType>(const ObObj &obj, char *buffer,
 | 
				
			|||||||
    ObCharsetType src_type = ObCharset::charset_type_by_coll(obj.get_collation_type());     \
 | 
					    ObCharsetType src_type = ObCharset::charset_type_by_coll(obj.get_collation_type());     \
 | 
				
			||||||
    ObCharsetType dst_type = ObCharset::charset_type_by_coll(params.cs_type_);              \
 | 
					    ObCharsetType dst_type = ObCharset::charset_type_by_coll(params.cs_type_);              \
 | 
				
			||||||
    if (src_type == CHARSET_BINARY || src_type == dst_type || src_type == CHARSET_INVALID) {\
 | 
					    if (src_type == CHARSET_BINARY || src_type == dst_type || src_type == CHARSET_INVALID) {\
 | 
				
			||||||
      if (params.use_memcpy_) {                                                             \
 | 
					      if (obj.get_collation_type() == CS_TYPE_BINARY && params.binary_string_print_hex_) {  \
 | 
				
			||||||
        ret = databuff_memcpy(buffer, length, pos, obj.get_string_len(), obj.get_string_ptr()); \
 | 
					        ret = hex_print(obj.get_string_ptr(), obj.get_string_len(), buffer, length, pos);   \
 | 
				
			||||||
 | 
					      } else if (params.use_memcpy_) {                                                      \
 | 
				
			||||||
 | 
					        ret = databuff_memcpy(buffer, length, pos, obj.get_string_len(), obj.get_string_ptr());         \
 | 
				
			||||||
      } else {                                                                              \
 | 
					      } else {                                                                              \
 | 
				
			||||||
        ret = databuff_printf(buffer, length, pos, "%.*s", obj.get_string_len(), obj.get_string_ptr()); \
 | 
					        ret = databuff_printf(buffer, length, pos, "%.*s", obj.get_string_len(), obj.get_string_ptr()); \
 | 
				
			||||||
      }                                                                                     \
 | 
					      }                                                                                     \
 | 
				
			||||||
@ -2501,9 +2503,11 @@ template <>
 | 
				
			|||||||
    int ret = OB_SUCCESS;                                               \
 | 
					    int ret = OB_SUCCESS;                                               \
 | 
				
			||||||
    ObCharsetType src_type = ObCharset::charset_type_by_coll(obj.get_collation_type());     \
 | 
					    ObCharsetType src_type = ObCharset::charset_type_by_coll(obj.get_collation_type());     \
 | 
				
			||||||
    ObCharsetType dst_type = ObCharset::charset_type_by_coll(params.cs_type_);              \
 | 
					    ObCharsetType dst_type = ObCharset::charset_type_by_coll(params.cs_type_);              \
 | 
				
			||||||
    if (src_type == dst_type) {  \
 | 
					    if (src_type == CHARSET_BINARY && params.binary_string_print_hex_) {                    \
 | 
				
			||||||
 | 
					      ret = hex_print(obj.get_string_ptr(), obj.get_string_len(), buffer, length, pos);     \
 | 
				
			||||||
 | 
					    } else if (src_type == dst_type) {                                                      \
 | 
				
			||||||
      if (params.use_memcpy_) {                                                             \
 | 
					      if (params.use_memcpy_) {                                                             \
 | 
				
			||||||
        ret = databuff_memcpy(buffer, length, pos, obj.get_string_len(), obj.get_string_ptr()); \
 | 
					        ret = databuff_memcpy(buffer, length, pos, obj.get_string_len(), obj.get_string_ptr());         \
 | 
				
			||||||
      } else {                                                                              \
 | 
					      } else {                                                                              \
 | 
				
			||||||
        ret = databuff_printf(buffer, length, pos, "%.*s", obj.get_string_len(), obj.get_string_ptr()); \
 | 
					        ret = databuff_printf(buffer, length, pos, "%.*s", obj.get_string_len(), obj.get_string_ptr()); \
 | 
				
			||||||
      }                                                                                     \
 | 
					      }                                                                                     \
 | 
				
			||||||
@ -2667,7 +2671,9 @@ inline int obj_print_plain_str<ObLobType>(const ObObj &obj, char *buffer, int64_
 | 
				
			|||||||
  UNUSED(params);
 | 
					  UNUSED(params);
 | 
				
			||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
  ObString str = obj.get_lob_print_string(length - pos);
 | 
					  ObString str = obj.get_lob_print_string(length - pos);
 | 
				
			||||||
  if (params.use_memcpy_) {
 | 
					  if (obj.get_collation_type() == CS_TYPE_BINARY && params.binary_string_print_hex_) {
 | 
				
			||||||
 | 
					    ret = hex_print(str.ptr(), str.length(), buffer, length, pos);
 | 
				
			||||||
 | 
					  } else if (params.use_memcpy_) {
 | 
				
			||||||
    ret = databuff_memcpy(buffer, length, pos, str.length(), str.ptr());
 | 
					    ret = databuff_memcpy(buffer, length, pos, str.length(), str.ptr());
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    ret = databuff_printf(buffer, length, pos, "%.*s", str.length(), str.ptr());
 | 
					    ret = databuff_printf(buffer, length, pos, "%.*s", str.length(), str.ptr());
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								deps/oblib/src/common/object/ob_object.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								deps/oblib/src/common/object/ob_object.h
									
									
									
									
										vendored
									
									
								
							@ -656,7 +656,8 @@ struct ObObjPrintParams
 | 
				
			|||||||
      uint32_t use_memcpy_:1;
 | 
					      uint32_t use_memcpy_:1;
 | 
				
			||||||
      uint32_t skip_escape_:1;
 | 
					      uint32_t skip_escape_:1;
 | 
				
			||||||
      uint32_t beginning_space_:1;
 | 
					      uint32_t beginning_space_:1;
 | 
				
			||||||
      uint32_t reserved_:27;
 | 
					      uint32_t binary_string_print_hex_:1;
 | 
				
			||||||
 | 
					      uint32_t reserved_:26;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -86,6 +86,8 @@ public:
 | 
				
			|||||||
      bool is_from_pl = false) = 0;
 | 
					      bool is_from_pl = false) = 0;
 | 
				
			||||||
  virtual int execute_write(const uint64_t tenant_id, const char *sql,
 | 
					  virtual int execute_write(const uint64_t tenant_id, const char *sql,
 | 
				
			||||||
      int64_t &affected_rows, bool is_user_sql = false) = 0;
 | 
					      int64_t &affected_rows, bool is_user_sql = false) = 0;
 | 
				
			||||||
 | 
					  virtual int execute_write(const uint64_t tenant_id, const ObString &sql,
 | 
				
			||||||
 | 
					      int64_t &affected_rows, bool is_user_sql = false) = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // transaction interface
 | 
					  // transaction interface
 | 
				
			||||||
  virtual int start_transaction(const uint64_t &tenant_id, bool with_snap_shot = false) = 0;
 | 
					  virtual int start_transaction(const uint64_t &tenant_id, bool with_snap_shot = false) = 0;
 | 
				
			||||||
 | 
				
			|||||||
@ -371,6 +371,13 @@ int ObMySQLConnection::switch_tenant(const uint64_t tenant_id)
 | 
				
			|||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int ObMySQLConnection::execute_write(const uint64_t tenant_id, const ObString &sql,
 | 
				
			||||||
 | 
					                                     int64_t &affected_rows, bool is_user_sql)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  UNUSEDx(tenant_id, sql, affected_rows, is_user_sql);
 | 
				
			||||||
 | 
					  return OB_NOT_SUPPORTED;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ObMySQLConnection::execute_write(const uint64_t tenant_id, const char *sql,
 | 
					int ObMySQLConnection::execute_write(const uint64_t tenant_id, const char *sql,
 | 
				
			||||||
    int64_t &affected_rows, bool is_user_sql)
 | 
					    int64_t &affected_rows, bool is_user_sql)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -72,6 +72,8 @@ public:
 | 
				
			|||||||
  virtual int execute_read(const int64_t cluster_id, const uint64_t tenant_id, const ObString &sql,
 | 
					  virtual int execute_read(const int64_t cluster_id, const uint64_t tenant_id, const ObString &sql,
 | 
				
			||||||
      ObISQLClient::ReadResult &res, bool is_user_sql = false,
 | 
					      ObISQLClient::ReadResult &res, bool is_user_sql = false,
 | 
				
			||||||
      bool is_from_pl = false) override;
 | 
					      bool is_from_pl = false) override;
 | 
				
			||||||
 | 
					  virtual int execute_write(const uint64_t tenant_id, const ObString &sql,
 | 
				
			||||||
 | 
					      int64_t &affected_rows, bool is_user_sql = false) override;
 | 
				
			||||||
  virtual int execute_write(const uint64_t tenant_id, const char *sql,
 | 
					  virtual int execute_write(const uint64_t tenant_id, const char *sql,
 | 
				
			||||||
      int64_t &affected_rows, bool is_user_sql = false) override;
 | 
					      int64_t &affected_rows, bool is_user_sql = false) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -138,14 +138,14 @@ int ObCommonSqlProxy::write(const uint64_t tenant_id, const char *sql, int64_t &
 | 
				
			|||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ObCommonSqlProxy::write(const uint64_t tenant_id, const char *sql,
 | 
					int ObCommonSqlProxy::write(const uint64_t tenant_id, const ObString sql,
 | 
				
			||||||
                        int64_t &affected_rows, int64_t compatibility_mode, const ObSessionParam *param /* = nullptr*/)
 | 
					                        int64_t &affected_rows, int64_t compatibility_mode, const ObSessionParam *param /* = nullptr*/)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
  bool is_user_sql = false;
 | 
					  bool is_user_sql = false;
 | 
				
			||||||
  int64_t start = ::oceanbase::common::ObTimeUtility::current_time();
 | 
					  int64_t start = ::oceanbase::common::ObTimeUtility::current_time();
 | 
				
			||||||
  ObISQLConnection *conn = NULL;
 | 
					  ObISQLConnection *conn = NULL;
 | 
				
			||||||
  if (OB_ISNULL(sql)) {
 | 
					  if (OB_UNLIKELY(sql.empty())) {
 | 
				
			||||||
    ret = OB_INVALID_ARGUMENT;
 | 
					    ret = OB_INVALID_ARGUMENT;
 | 
				
			||||||
    LOG_WARN("empty sql");
 | 
					    LOG_WARN("empty sql");
 | 
				
			||||||
  } else if (OB_FAIL(acquire(tenant_id, conn))) {
 | 
					  } else if (OB_FAIL(acquire(tenant_id, conn))) {
 | 
				
			||||||
@ -155,7 +155,7 @@ int ObCommonSqlProxy::write(const uint64_t tenant_id, const char *sql,
 | 
				
			|||||||
    LOG_WARN("connection can not be NULL");
 | 
					    LOG_WARN("connection can not be NULL");
 | 
				
			||||||
  } else if (!is_active()) { // check client active after connection acquired
 | 
					  } else if (!is_active()) { // check client active after connection acquired
 | 
				
			||||||
    ret = OB_INACTIVE_SQL_CLIENT;
 | 
					    ret = OB_INACTIVE_SQL_CLIENT;
 | 
				
			||||||
    LOG_WARN("in active sql client", K(ret), KCSTRING(sql));
 | 
					    LOG_WARN("in active sql client", K(ret), K(sql));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  int64_t old_compatibility_mode;
 | 
					  int64_t old_compatibility_mode;
 | 
				
			||||||
  int64_t old_sql_mode = 0;
 | 
					  int64_t old_sql_mode = 0;
 | 
				
			||||||
@ -203,7 +203,7 @@ int ObCommonSqlProxy::write(const uint64_t tenant_id, const char *sql,
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  if (OB_SUCC(ret)) {
 | 
					  if (OB_SUCC(ret)) {
 | 
				
			||||||
    if (OB_FAIL(conn->execute_write(tenant_id, sql, affected_rows, is_user_sql))) {
 | 
					    if (OB_FAIL(conn->execute_write(tenant_id, sql, affected_rows, is_user_sql))) {
 | 
				
			||||||
      LOG_WARN("execute sql failed", K(ret), K(conn), K(start), KCSTRING(sql));
 | 
					      LOG_WARN("execute sql failed", K(ret), K(conn), K(start), K(sql));
 | 
				
			||||||
    } else if (old_compatibility_mode != compatibility_mode
 | 
					    } else if (old_compatibility_mode != compatibility_mode
 | 
				
			||||||
               && OB_FAIL(conn->set_session_variable("ob_compatibility_mode", old_compatibility_mode))) {
 | 
					               && OB_FAIL(conn->set_session_variable("ob_compatibility_mode", old_compatibility_mode))) {
 | 
				
			||||||
      LOG_WARN("fail to recover inner connection sql mode", K(ret));
 | 
					      LOG_WARN("fail to recover inner connection sql mode", K(ret));
 | 
				
			||||||
@ -220,7 +220,7 @@ int ObCommonSqlProxy::write(const uint64_t tenant_id, const char *sql,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  close(conn, ret);
 | 
					  close(conn, ret);
 | 
				
			||||||
  LOG_TRACE("execute sql with sql mode", KCSTRING(sql), K(compatibility_mode), K(ret));
 | 
					  LOG_TRACE("execute sql with sql mode", K(sql), K(compatibility_mode), K(ret));
 | 
				
			||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -109,7 +109,7 @@ public:
 | 
				
			|||||||
  using ObISQLClient::read;
 | 
					  using ObISQLClient::read;
 | 
				
			||||||
  // execute update sql
 | 
					  // execute update sql
 | 
				
			||||||
  virtual int write(const uint64_t tenant_id, const char *sql, int64_t &affected_rows) override;
 | 
					  virtual int write(const uint64_t tenant_id, const char *sql, int64_t &affected_rows) override;
 | 
				
			||||||
  int write(const uint64_t tenant_id, const char *sql, int64_t &affected_rows, int64_t compatibility_mode,
 | 
					  int write(const uint64_t tenant_id, const ObString sql, int64_t &affected_rows, int64_t compatibility_mode,
 | 
				
			||||||
        const ObSessionParam *session_param = nullptr);
 | 
					        const ObSessionParam *session_param = nullptr);
 | 
				
			||||||
  using ObISQLClient::write;
 | 
					  using ObISQLClient::write;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -139,9 +139,9 @@ public:
 | 
				
			|||||||
  virtual int execute_write(const uint64_t tenant_id, const char *sql,
 | 
					  virtual int execute_write(const uint64_t tenant_id, const char *sql,
 | 
				
			||||||
                            int64_t &affected_rows,
 | 
					                            int64_t &affected_rows,
 | 
				
			||||||
                            bool is_user_sql = false) override;
 | 
					                            bool is_user_sql = false) override;
 | 
				
			||||||
  int execute_write(const uint64_t tenant_id, const ObString &sql,
 | 
					  virtual int execute_write(const uint64_t tenant_id, const ObString &sql,
 | 
				
			||||||
                    int64_t &affected_rows,
 | 
					                            int64_t &affected_rows,
 | 
				
			||||||
                    bool is_user_sql = false);
 | 
					                            bool is_user_sql = false) override;
 | 
				
			||||||
  virtual int start_transaction(const uint64_t &tenant_id, bool with_snap_shot = false) override;
 | 
					  virtual int start_transaction(const uint64_t &tenant_id, bool with_snap_shot = false) override;
 | 
				
			||||||
  virtual int register_multi_data_source(const uint64_t &tenant_id,
 | 
					  virtual int register_multi_data_source(const uint64_t &tenant_id,
 | 
				
			||||||
                                         const share::ObLSID ls_id,
 | 
					                                         const share::ObLSID ls_id,
 | 
				
			||||||
 | 
				
			|||||||
@ -1228,7 +1228,7 @@ int ObLoadDataSPImpl::exec_insert(ObInsertTask &task, ObInsertResult& result)
 | 
				
			|||||||
  param.is_load_data_exec_ = true;
 | 
					  param.is_load_data_exec_ = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (OB_SUCC(ret) && OB_FAIL(GCTX.sql_proxy_->write(task.tenant_id_,
 | 
					  if (OB_SUCC(ret) && OB_FAIL(GCTX.sql_proxy_->write(task.tenant_id_,
 | 
				
			||||||
                                                     sql_str.ptr(),
 | 
					                                                     sql_str.string(),
 | 
				
			||||||
                                                     affected_rows,
 | 
					                                                     affected_rows,
 | 
				
			||||||
                                                     get_compatibility_mode(),
 | 
					                                                     get_compatibility_mode(),
 | 
				
			||||||
                                                     ¶m))) {
 | 
					                                                     ¶m))) {
 | 
				
			||||||
 | 
				
			|||||||
@ -10,9 +10,9 @@
 | 
				
			|||||||
 * See the Mulan PubL v2 for more details.
 | 
					 * See the Mulan PubL v2 for more details.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define USING_LOG_PREFIX SQL_ENG
 | 
					#define USING_LOG_PREFIX SQL_ENG
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "sql/engine/expr/ob_expr_to_outfile_row.h"
 | 
					#include "sql/engine/expr/ob_expr_to_outfile_row.h"
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include "lib/oblog/ob_log.h"
 | 
					#include "lib/oblog/ob_log.h"
 | 
				
			||||||
#include "objit/common/ob_item_type.h"
 | 
					#include "objit/common/ob_item_type.h"
 | 
				
			||||||
@ -123,12 +123,13 @@ int ObExprToOutfileRow::calc_outfile_info(const ObExpr &expr,
 | 
				
			|||||||
    LOG_WARN("session is null", K(ret));
 | 
					    LOG_WARN("session is null", K(ret));
 | 
				
			||||||
  } else if (OB_ISNULL(out_info.print_params_.tz_info_ = session->get_timezone_info())) {
 | 
					  } else if (OB_ISNULL(out_info.print_params_.tz_info_ = session->get_timezone_info())) {
 | 
				
			||||||
    ret = OB_ERR_UNEXPECTED;
 | 
					    ret = OB_ERR_UNEXPECTED;
 | 
				
			||||||
    LOG_WARN("fail to get timezone info", K(ret));
 | 
					    LOG_WARN("fail to get timezone info", K(ret));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    out_info.print_params_.use_memcpy_ = true;
 | 
					    out_info.print_params_.use_memcpy_ = true;
 | 
				
			||||||
    out_info.is_optional_ = expr.locate_param_datum(ctx, PARAM_OPTIONAL).get_bool();
 | 
					    out_info.print_params_.binary_string_print_hex_ = lib::is_oracle_mode();
 | 
				
			||||||
  }
 | 
					    out_info.is_optional_ = expr.locate_param_datum(ctx, PARAM_OPTIONAL).get_bool();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int i = 0; OB_SUCC(ret) && i < PARAM_SELECT_ITEM; ++i) {
 | 
					  for (int i = 0; OB_SUCC(ret) && i < PARAM_SELECT_ITEM; ++i) {
 | 
				
			||||||
    OZ(expr.locate_param_datum(ctx, i).to_obj(objs_array[i], expr.args_[i]->obj_meta_,
 | 
					    OZ(expr.locate_param_datum(ctx, i).to_obj(objs_array[i], expr.args_[i]->obj_meta_,
 | 
				
			||||||
                                              expr.args_[i]->obj_datum_map_));
 | 
					                                              expr.args_[i]->obj_datum_map_));
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user