add expr: (#198)
This commit is contained in:
@ -41,6 +41,7 @@
|
||||
#include "ob_expr_int2ip.h"
|
||||
#include "ob_expr_int_div.h"
|
||||
#include "ob_expr_ip2int.h"
|
||||
#include "ob_expr_inet.h"
|
||||
#include "ob_expr_is.h"
|
||||
#include "ob_expr_last_exec_id.h"
|
||||
#include "ob_expr_last_trace_id.h"
|
||||
@ -187,73 +188,73 @@ namespace oceanbase {
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
|
||||
extern int cast_eval_arg(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int anytype_to_varchar_char_explicit(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int anytype_anytype_explicit(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_acos_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_and_exprN(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_asin_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_assign_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_atan2_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_atan_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_between_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_bool_expr_for_integer_type(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_bool_expr_for_float_type(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_bool_expr_for_double_type(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_bool_expr_for_other_type(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_char_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_coalesce_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_cos_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_cosh_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_exp_expr_double(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_exp_expr_number(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_ceil_floor(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_round_expr_datetime1(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_round_expr_datetime2(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_round_expr_numeric2(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_round_expr_numeric1(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_initcap_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_left_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_ln_expr_mysql(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_ln_expr_oracle_double(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_ln_expr_oracle_number(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_log10_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_log2_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_log_expr_double(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_log_expr_number(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_not_between_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_or_exprN(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_power_expr_oracle(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_right_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_sign_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_sin_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_sinh_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_sqrt_expr_mysql(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_sqrt_expr_oracle_double(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_sqrt_expr_oracle_number(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_str_to_date_expr_date(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_str_to_date_expr_time(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_str_to_date_expr_datetime(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_tan_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_tanh_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_timestampadd_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_time_to_usec_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_todays_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_to_temporal_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_translate_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_usec_to_time_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_charset_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_collation_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_coercibility_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_set_collation_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_cmp_meta_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_trunc_expr_datetime(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_trunc_expr_numeric(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_truncate_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int calc_reverse_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum);
|
||||
extern int calc_instrb_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum);
|
||||
extern int calc_convert_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum);
|
||||
extern int calc_translate_using_expr(const ObExpr&, ObEvalCtx&, ObDatum&);
|
||||
extern int cast_eval_arg(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int anytype_to_varchar_char_explicit(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int anytype_anytype_explicit(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_acos_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_and_exprN(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_asin_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_assign_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_atan2_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_atan_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_between_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_bool_expr_for_integer_type(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_bool_expr_for_float_type(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_bool_expr_for_double_type(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_bool_expr_for_other_type(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_char_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_coalesce_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_cos_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_cosh_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_exp_expr_double(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_exp_expr_number(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_ceil_floor(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_round_expr_datetime1(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_round_expr_datetime2(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_round_expr_numeric2(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_round_expr_numeric1(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_initcap_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_left_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_ln_expr_mysql(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_ln_expr_oracle_double(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_ln_expr_oracle_number(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_log10_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_log2_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_log_expr_double(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_log_expr_number(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_not_between_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_or_exprN(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_power_expr_oracle(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_right_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_sign_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_sin_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_sinh_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_sqrt_expr_mysql(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_sqrt_expr_oracle_double(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_sqrt_expr_oracle_number(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_str_to_date_expr_date(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_str_to_date_expr_time(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_str_to_date_expr_datetime(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_tan_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_tanh_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_timestampadd_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_time_to_usec_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_todays_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_to_temporal_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_translate_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_usec_to_time_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_charset_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_collation_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_coercibility_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_set_collation_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_cmp_meta_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_trunc_expr_datetime(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_trunc_expr_numeric(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_truncate_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
extern int calc_reverse_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum);
|
||||
extern int calc_instrb_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum);
|
||||
extern int calc_convert_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum);
|
||||
extern int calc_translate_using_expr(const ObExpr &, ObEvalCtx &, ObDatum &);
|
||||
|
||||
// append only, can not delete, set to NULL for mark delete
|
||||
static ObExpr::EvalFunc g_expr_eval_functions[] = {
|
||||
@ -636,37 +637,44 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
|
||||
ObExprNlsLower::calc_lower, /* 378 */
|
||||
ObExprNlsUpper::calc_upper, /* 379 */
|
||||
ObExprToOutfileRow::to_outfile_str, /* 380 */
|
||||
NULL, // ObExprIs::calc_is_infinite, /* 381 */
|
||||
NULL, // ObExprIs::calc_is_nan, /* 382 */
|
||||
NULL, // ObExprIsNot::calc_is_not_infinite, /* 383 */
|
||||
NULL, // ObExprIsNot::calc_is_not_nan, /* 384 */
|
||||
ObExprOracleNullif::eval_nullif_not_null, /* 385 */
|
||||
NULL, // ObExprNaNvl::eval_nanvl, /* 386 */
|
||||
ObExprFormat::calc_format_expr, /* 387 */
|
||||
calc_translate_using_expr, /* 388 */
|
||||
ObExprQuarter::calc_quater, /* 389 */
|
||||
ObExprBitLength::calc_bit_length, /* 390 */
|
||||
NULL, // ObExprConvertOracle::calc_convert_oracle_expr, /* 391 */
|
||||
NULL, // ObExprUnistr::calc_unistr_expr, /* 392 */
|
||||
NULL, // ObExprAsciistr::calc_asciistr_expr, /* 393 */
|
||||
NULL, // ObExprAtTimeZone::eval_at_time_zone, /* 394 */
|
||||
NULL, // ObExprAtLocal::eval_at_local, /* 395 */
|
||||
ObExprToSingleByte::calc_to_single_byte, /* 396 */
|
||||
ObExprToMultiByte::calc_to_multi_byte, /* 397 */
|
||||
NULL, // ObExprDllUdf::eval_dll_udf, /* 398 */
|
||||
NULL, // ObExprRawtonhex::calc_rawtonhex_expr, /* 399 */
|
||||
ObExprPi::eval_pi, /* 400 */
|
||||
ObExprConvertTZ::eval_convert_tz, /* 401 */
|
||||
ObExprUtcTime::eval_utc_time, /* 402 */
|
||||
ObExprUtcDate::eval_utc_date, /* 403 */
|
||||
ObExprGetFormat::calc_get_format, /* 404 */
|
||||
NULL, //ObExprCollectionConstruct::eval_collection_construct, /* 405 */
|
||||
NULL, //ObExprObjAccess::eval_obj_access, /* 406 */
|
||||
ObExprTimeFormat::calc_time_format, /* 407 */
|
||||
ObExprMakedate::calc_makedate, /* 408 */
|
||||
ObExprPeriodAdd::calc_periodadd, /* 409 */
|
||||
ObExprExportSet::eval_export_set, /* 410 */
|
||||
ObExprConvertTZ::eval_convert_tz /* 411 */
|
||||
NULL, // ObExprIs::calc_is_infinite, /* 381 */
|
||||
NULL, // ObExprIs::calc_is_nan, /* 382 */
|
||||
NULL, // ObExprIsNot::calc_is_not_infinite, /* 383 */
|
||||
NULL, // ObExprIsNot::calc_is_not_nan, /* 384 */
|
||||
ObExprOracleNullif::eval_nullif_not_null, /* 385 */
|
||||
NULL, // ObExprNaNvl::eval_nanvl, /* 386 */
|
||||
ObExprFormat::calc_format_expr, /* 387 */
|
||||
calc_translate_using_expr, /* 388 */
|
||||
ObExprQuarter::calc_quater, /* 389 */
|
||||
ObExprBitLength::calc_bit_length, /* 390 */
|
||||
NULL, // ObExprConvertOracle::calc_convert_oracle_expr, /* 391 */
|
||||
NULL, // ObExprUnistr::calc_unistr_expr, /* 392 */
|
||||
NULL, // ObExprAsciistr::calc_asciistr_expr, /* 393 */
|
||||
NULL, // ObExprAtTimeZone::eval_at_time_zone, /* 394 */
|
||||
NULL, // ObExprAtLocal::eval_at_local, /* 395 */
|
||||
ObExprToSingleByte::calc_to_single_byte, /* 396 */
|
||||
ObExprToMultiByte::calc_to_multi_byte, /* 397 */
|
||||
NULL, // ObExprDllUdf::eval_dll_udf, /* 398 */
|
||||
NULL, // ObExprRawtonhex::calc_rawtonhex_expr, /* 399 */
|
||||
ObExprPi::eval_pi, /* 400 */
|
||||
ObExprConvertTZ::eval_convert_tz, /* 401 */
|
||||
ObExprUtcTime::eval_utc_time, /* 402 */
|
||||
ObExprUtcDate::eval_utc_date, /* 403 */
|
||||
ObExprGetFormat::calc_get_format, /* 404 */
|
||||
NULL, // ObExprCollectionConstruct::eval_collection_construct, /* 405 */
|
||||
NULL, // ObExprObjAccess::eval_obj_access, /* 406 */
|
||||
ObExprTimeFormat::calc_time_format, /* 407 */
|
||||
ObExprMakedate::calc_makedate, /* 408 */
|
||||
ObExprPeriodAdd::calc_periodadd, /* 409 */
|
||||
ObExprExportSet::eval_export_set, /* 410 */
|
||||
ObExprConvertTZ::eval_convert_tz, /* 411 */
|
||||
ObExprInet6Aton::calc_inet6_aton, /* 412 */
|
||||
ObExprIsIpv4::calc_is_ipv4, /* 413 */
|
||||
ObExprIsIpv6::calc_is_ipv6, /* 414 */
|
||||
ObExprIsIpv4Mapped::calc_is_ipv4_mapped, /* 415 */
|
||||
ObExprIsIpv4Compat::calc_is_ipv4_compat, /* 416 */
|
||||
ObExprInetAton::calc_inet_aton, /* 417 */
|
||||
ObExprInet6Ntoa::calc_inet6_ntoa, /* 418 */
|
||||
};
|
||||
|
||||
REG_SER_FUNC_ARRAY(OB_SFA_SQL_EXPR_EVAL, g_expr_eval_functions, ARRAYSIZEOF(g_expr_eval_functions));
|
||||
|
||||
1108
src/sql/engine/expr/ob_expr_inet.cpp
Normal file
1108
src/sql/engine/expr/ob_expr_inet.cpp
Normal file
File diff suppressed because it is too large
Load Diff
225
src/sql/engine/expr/ob_expr_inet.h
Normal file
225
src/sql/engine/expr/ob_expr_inet.h
Normal file
@ -0,0 +1,225 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_INET_
|
||||
#define OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_INET_
|
||||
|
||||
#include "sql/engine/expr/ob_expr_operator.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObExprInetCommon {
|
||||
public :
|
||||
static int str_to_ipv4(int len, const char *str, bool& is_ip_format_invalid, in_addr* ipv4addr);
|
||||
static int str_to_ipv6(int len, const char *str, bool& is_ip_format_invalid, in6_addr* ipv6addr);
|
||||
static int ip_to_str(ObString& ip_binary, bool& is_ip_format_invalid, ObString& ip_str);
|
||||
};
|
||||
|
||||
class ObExprInetAton : public ObFuncExprOperator {
|
||||
public:
|
||||
explicit ObExprInetAton(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprInetAton();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static int calc(common::ObObj& result, const common::ObObj& text, uint64_t cast_mode);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_inet_aton(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
// helper func
|
||||
template <typename T>
|
||||
static int ob_inet_aton(T& result, const common::ObString& text, bool& is_ip_format_invalid);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprInetAton);
|
||||
};
|
||||
|
||||
inline int ObExprInetAton::calc_result_type1(
|
||||
ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
type.set_int();
|
||||
type.set_precision(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObIntType].precision_);
|
||||
type.set_scale(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObIntType].scale_);
|
||||
// set calc type
|
||||
text.set_calc_type(common::ObVarcharType);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
|
||||
class ObExprInet6Ntoa : public ObStringExprOperator {
|
||||
public:
|
||||
explicit ObExprInet6Ntoa(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprInet6Ntoa();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static int calc(common::ObObj& result, const common::ObObj& text, common::ObExprStringBuf& string_buf, uint64_t cast_mode);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_inet6_ntoa(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprInet6Ntoa);
|
||||
};
|
||||
|
||||
class ObExprInet6Aton : public ObFuncExprOperator {
|
||||
public:
|
||||
explicit ObExprInet6Aton(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprInet6Aton();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static int calc(common::ObObj& result, const common::ObObj& text, common::ObExprStringBuf& string_buf, uint64_t cast_mode);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_inet6_aton(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
// helper func
|
||||
static int inet6_aton(const ObString& ip, bool& is_ip_format_invalid, ObString& str_result);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprInet6Aton);
|
||||
};
|
||||
|
||||
inline int ObExprInet6Aton::calc_result_type1(
|
||||
ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
type.set_varbinary();
|
||||
type.set_length(16);
|
||||
type.set_collation_level(common::CS_LEVEL_COERCIBLE);
|
||||
text.set_calc_type(common::ObVarcharType);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
|
||||
class ObExprIsIpv4 : public ObFuncExprOperator {
|
||||
public:
|
||||
explicit ObExprIsIpv4(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprIsIpv4();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static int calc(common::ObObj& result, const common::ObObj& text);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_is_ipv4(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
// helper func
|
||||
template <typename T>
|
||||
static int is_ipv4(T& result, const common::ObString& text);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprIsIpv4);
|
||||
};
|
||||
|
||||
inline int ObExprIsIpv4::calc_result_type1(
|
||||
ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
type.set_tinyint();
|
||||
type.set_precision(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].precision_);
|
||||
type.set_scale(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].scale_);
|
||||
// set calc type
|
||||
text.set_calc_type(common::ObVarcharType);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
|
||||
class ObExprIsIpv4Mapped : public ObFuncExprOperator {
|
||||
public:
|
||||
explicit ObExprIsIpv4Mapped(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprIsIpv4Mapped();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static void calc(common::ObObj& result, const common::ObObj& text);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_is_ipv4_mapped(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
// helper func
|
||||
template <typename T>
|
||||
static void is_ipv4_mapped(T& result, const common::ObString& num_val);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprIsIpv4Mapped);
|
||||
};
|
||||
|
||||
inline int ObExprIsIpv4Mapped::calc_result_type1(
|
||||
ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
UNUSED(text);
|
||||
type.set_tinyint();
|
||||
type.set_precision(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].precision_);
|
||||
type.set_scale(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].scale_);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
|
||||
class ObExprIsIpv4Compat : public ObFuncExprOperator {
|
||||
public:
|
||||
explicit ObExprIsIpv4Compat(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprIsIpv4Compat();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static void calc(common::ObObj& result, const common::ObObj& text);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_is_ipv4_compat(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
// helper func
|
||||
template <typename T>
|
||||
static void is_ipv4_compat(T& result, const common::ObString& num_val);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprIsIpv4Compat);
|
||||
};
|
||||
|
||||
inline int ObExprIsIpv4Compat::calc_result_type1(
|
||||
ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
UNUSED(text);
|
||||
type.set_tinyint();
|
||||
type.set_precision(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].precision_);
|
||||
type.set_scale(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].scale_);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
|
||||
class ObExprIsIpv6 : public ObFuncExprOperator {
|
||||
public:
|
||||
explicit ObExprIsIpv6(common::ObIAllocator& alloc);
|
||||
virtual ~ObExprIsIpv6();
|
||||
virtual int calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const;
|
||||
static int calc(common::ObObj& result, const common::ObObj& text);
|
||||
virtual int calc_result1(common::ObObj& result, const common::ObObj& text, common::ObExprCtx& expr_ctx) const;
|
||||
virtual int cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
static int calc_is_ipv6(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum);
|
||||
|
||||
private:
|
||||
// helper func
|
||||
template <typename T>
|
||||
static int is_ipv6(T& result, const common::ObString& num_val);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprIsIpv6);
|
||||
};
|
||||
|
||||
inline int ObExprIsIpv6::calc_result_type1(
|
||||
ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
type.set_tinyint();
|
||||
type.set_precision(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].precision_);
|
||||
type.set_scale(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObTinyIntType].scale_);
|
||||
// set calc type
|
||||
text.set_calc_type(common::ObVarcharType);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
#endif /* OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_INET6_NTOA_ */
|
||||
@ -73,6 +73,7 @@ int ObExprInt2ip::int2ip(ObObj& result, const int64_t int_val, ObExprStringBuf&
|
||||
} else {
|
||||
in_addr addr;
|
||||
addr.s_addr = htonl(static_cast<uint32_t>(int_val));
|
||||
// Fix me,The problem with inet_ntop() is that it is available starting from Windows Vista, but the minimum supported version is Windows 2000.
|
||||
const char* iret = inet_ntop(AF_INET, &addr, buf, 16);
|
||||
if (OB_ISNULL(iret)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
||||
@ -377,7 +377,7 @@ int ObExprMod::mod_float(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
} else {
|
||||
const float left_f = left->get_float();
|
||||
const float right_f = right->get_float();
|
||||
if (fabsf(right_f) == 0.0) {
|
||||
if (fabsf(right_f) < share::ObUnitConfig::CPU_EPSILON) {
|
||||
datum.set_float(left_f);
|
||||
} else {
|
||||
datum.set_float(fmodf(left_f, right_f));
|
||||
|
||||
@ -1412,7 +1412,7 @@ int ObRelationalExprOperator::compare_nullsafe(int64_t& result, const ObObj& obj
|
||||
}
|
||||
|
||||
bool ObRelationalExprOperator::can_cmp_without_cast(
|
||||
ObExprResType type1, ObExprResType type2, ObCmpOp cmp_op, const ObSQLSessionInfo& session)
|
||||
const ObExprResType& type1, const ObExprResType& type2, ObCmpOp cmp_op, const ObSQLSessionInfo& session)
|
||||
{
|
||||
bool need_no_cast = false;
|
||||
if (ob_is_enum_or_set_type(type1.get_type()) && ob_is_enum_or_set_type(type2.get_type())) {
|
||||
@ -2222,10 +2222,7 @@ int ObSubQueryRelationalExpr::calc_resultN(
|
||||
tmp_row.count_ = param_num - 1;
|
||||
left_row = &tmp_row;
|
||||
const ObObj& idx_obj = param_array[param_num - 1];
|
||||
if (OB_ISNULL(left_row)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("left_row is null", K(left_row), K(ret));
|
||||
} else if (OB_FAIL(idx_obj.get_int(subquery_idx))) {
|
||||
if (OB_FAIL(idx_obj.get_int(subquery_idx))) {
|
||||
LOG_WARN("get subquery index failed", K(ret));
|
||||
} else if (T_WITH_ALL == subquery_key_) {
|
||||
if (OB_FAIL(calc_result_with_all(result, *left_row, subquery_idx, expr_ctx))) {
|
||||
@ -3427,8 +3424,11 @@ int ObBitwiseExprOperator::calc_(
|
||||
LOG_WARN("failed to get int64", K(obj2), K(ret));
|
||||
} else {
|
||||
ObNumber result;
|
||||
result.from((int64_v1 & int64_v2), *expr_ctx.calc_buf_);
|
||||
res.set_number(result);
|
||||
if (OB_FAIL(result.from((int64_v1 & int64_v2), *expr_ctx.calc_buf_))) {
|
||||
LOG_WARN("get ObNumber from int64 failed", K(ret), K(int64_v1 & int64_v2));
|
||||
} else {
|
||||
res.set_number(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1002,7 +1002,7 @@ public:
|
||||
static int get_equal_meta(common::ObObjMeta& meta, const common::ObObjMeta& meta1, const common::ObObjMeta& meta2);
|
||||
|
||||
OB_INLINE static bool can_cmp_without_cast(
|
||||
ObExprResType type1, ObExprResType type2, common::ObCmpOp cmp_op, common::obj_cmp_func& cmp_func)
|
||||
const ObExprResType& type1, const ObExprResType& type2, common::ObCmpOp cmp_op, common::obj_cmp_func& cmp_func)
|
||||
{
|
||||
bool need_no_cast = false;
|
||||
// Special processing shows that compare is called (for example: c1> c2),
|
||||
@ -1117,7 +1117,7 @@ protected:
|
||||
}
|
||||
|
||||
static bool can_cmp_without_cast(
|
||||
ObExprResType type1, ObExprResType type2, common::ObCmpOp cmp_op, const ObSQLSessionInfo& session);
|
||||
const ObExprResType& type1, const ObExprResType& type2, common::ObCmpOp cmp_op, const ObSQLSessionInfo& session);
|
||||
|
||||
protected:
|
||||
// only use for comparison with 2 operands(calc_result2)
|
||||
|
||||
@ -65,6 +65,7 @@
|
||||
#include "sql/engine/expr/ob_expr_not_in.h"
|
||||
#include "sql/engine/expr/ob_expr_int2ip.h"
|
||||
#include "sql/engine/expr/ob_expr_ip2int.h"
|
||||
#include "sql/engine/expr/ob_expr_inet.h"
|
||||
#include "sql/engine/expr/ob_expr_last_exec_id.h"
|
||||
#include "sql/engine/expr/ob_expr_last_trace_id.h"
|
||||
#include "sql/engine/expr/ob_expr_is.h"
|
||||
@ -446,6 +447,13 @@ void ObExprOperatorFactory::register_expr_operators()
|
||||
REG_OP(ObExprNotIn);
|
||||
REG_OP(ObExprInt2ip);
|
||||
REG_OP(ObExprIp2int);
|
||||
REG_OP(ObExprInetAton);
|
||||
REG_OP(ObExprInet6Ntoa);
|
||||
REG_OP(ObExprInet6Aton);
|
||||
REG_OP(ObExprIsIpv4);
|
||||
REG_OP(ObExprIsIpv6);
|
||||
REG_OP(ObExprIsIpv4Mapped);
|
||||
REG_OP(ObExprIsIpv4Compat);
|
||||
REG_OP(ObExprInsert);
|
||||
REG_OP(ObExprIs);
|
||||
REG_OP(ObExprIsNot);
|
||||
|
||||
@ -376,7 +376,7 @@ struct ObExprOperatorFetcher : public ObSqlExpression {
|
||||
public:
|
||||
ObExprOperatorFetcher()
|
||||
// the allocator is never used
|
||||
: ObSqlExpression(*lib::ObMallocAllocator::get_instance(), 0)
|
||||
: ObSqlExpression(*lib::ObMallocAllocator::get_instance(), 0), op_(NULL)
|
||||
{}
|
||||
|
||||
virtual int add_expr_item(const ObPostExprItem& item) override
|
||||
|
||||
Reference in New Issue
Block a user