Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
f8b75754
O
oceanbase
项目概览
Metz
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f8b75754
编写于
8月 31, 2021
作者:
2
2149
提交者:
wangzelin.wzl
8月 31, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add expr: (#198)
上级
4c03c716
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
3673 addition
and
109 deletion
+3673
-109
deps/oblib/src/lib/ob_name_def.h
deps/oblib/src/lib/ob_name_def.h
+7
-0
src/sql/CMakeLists.txt
src/sql/CMakeLists.txt
+1
-0
src/sql/engine/expr/ob_expr_eval_functions.cpp
src/sql/engine/expr/ob_expr_eval_functions.cpp
+106
-98
src/sql/engine/expr/ob_expr_inet.cpp
src/sql/engine/expr/ob_expr_inet.cpp
+1108
-0
src/sql/engine/expr/ob_expr_inet.h
src/sql/engine/expr/ob_expr_inet.h
+225
-0
src/sql/engine/expr/ob_expr_int2ip.cpp
src/sql/engine/expr/ob_expr_int2ip.cpp
+1
-0
src/sql/engine/expr/ob_expr_mod.cpp
src/sql/engine/expr/ob_expr_mod.cpp
+1
-1
src/sql/engine/expr/ob_expr_operator.cpp
src/sql/engine/expr/ob_expr_operator.cpp
+7
-7
src/sql/engine/expr/ob_expr_operator.h
src/sql/engine/expr/ob_expr_operator.h
+2
-2
src/sql/engine/expr/ob_expr_operator_factory.cpp
src/sql/engine/expr/ob_expr_operator_factory.cpp
+8
-0
src/sql/engine/expr/ob_sql_expression.h
src/sql/engine/expr/ob_sql_expression.h
+1
-1
src/sql/parser/ob_item_type.h
src/sql/parser/ob_item_type.h
+7
-0
src/sql/parser/type_name.c
src/sql/parser/type_name.c
+7
-0
src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp
src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp
+2
-0
src/sql/resolver/expr/ob_raw_expr_util.cpp
src/sql/resolver/expr/ob_raw_expr_util.cpp
+3
-0
src/sql/resolver/ob_resolver_utils.cpp
src/sql/resolver/ob_resolver_utils.cpp
+2
-0
test/mysql_test/test_suite/expr/r/mysql/expr_inet_new.result
test/mysql_test/test_suite/expr/r/mysql/expr_inet_new.result
+711
-0
test/mysql_test/test_suite/expr/r/mysql/expr_inet_old.result
test/mysql_test/test_suite/expr/r/mysql/expr_inet_old.result
+718
-0
test/mysql_test/test_suite/expr/t/expr_inet_new.test
test/mysql_test/test_suite/expr/t/expr_inet_new.test
+373
-0
test/mysql_test/test_suite/expr/t/expr_inet_old.test
test/mysql_test/test_suite/expr/t/expr_inet_old.test
+383
-0
未找到文件。
deps/oblib/src/lib/ob_name_def.h
浏览文件 @
f8b75754
...
...
@@ -425,6 +425,13 @@
#define N_DBMS_LOB_CONVERT_CLOB_CHARSET "dbms_lob_convert_clob_charset"
#define N_IP2INT "ip2int"
#define N_INT2IP "int2ip"
#define N_INETATON "inet_aton"
#define N_INET6ATON "inet6_aton"
#define N_INET6NTOA "inet6_ntoa"
#define N_IS_IPV4 "is_ipv4"
#define N_IS_IPV6 "is_ipv6"
#define N_IS_IPV4_MAPPED "is_ipv4_mapped"
#define N_IS_IPV4_COMPAT "is_ipv4_compat"
#define N_UPPER "upper"
#define N_SIGN "sign"
#define N_LOWER "lower"
...
...
src/sql/CMakeLists.txt
浏览文件 @
f8b75754
...
...
@@ -278,6 +278,7 @@ ob_set_subtarget(ob_sql engine
engine/expr/ob_expr_int_div.cpp
engine/expr/ob_expr_interval.cpp
engine/expr/ob_expr_ip2int.cpp
engine/expr/ob_expr_inet.cpp
engine/expr/ob_expr_is.cpp
engine/expr/ob_expr_is_serving_tenant.cpp
engine/expr/ob_expr_last_exec_id.cpp
...
...
src/sql/engine/expr/ob_expr_eval_functions.cpp
浏览文件 @
f8b75754
...
...
@@ -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
));
...
...
src/sql/engine/expr/ob_expr_inet.cpp
0 → 100644
浏览文件 @
f8b75754
此差异已折叠。
点击以展开。
src/sql/engine/expr/ob_expr_inet.h
0 → 100644
浏览文件 @
f8b75754
/**
* 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_ */
src/sql/engine/expr/ob_expr_int2ip.cpp
浏览文件 @
f8b75754
...
...
@@ -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
;
...
...
src/sql/engine/expr/ob_expr_mod.cpp
浏览文件 @
f8b75754
...
...
@@ -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
));
...
...
src/sql/engine/expr/ob_expr_operator.cpp
浏览文件 @
f8b75754
...
...
@@ -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
);
}
}
}
}
...
...
src/sql/engine/expr/ob_expr_operator.h
浏览文件 @
f8b75754
...
...
@@ -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)
...
...
src/sql/engine/expr/ob_expr_operator_factory.cpp
浏览文件 @
f8b75754
...
...
@@ -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
);
...
...
src/sql/engine/expr/ob_sql_expression.h
浏览文件 @
f8b75754
...
...
@@ -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
...
...
src/sql/parser/ob_item_type.h
浏览文件 @
f8b75754
...
...
@@ -428,6 +428,13 @@ typedef enum ObItemType {
T_FUN_SYS_PI
=
713
,
T_FUN_SYS_EXPORT_SET
=
714
,
T_FUN_SYS_INET6NTOA
=
715
,
T_FUN_SYS_INET6ATON
=
716
,
T_FUN_SYS_IS_IPV4
=
717
,
T_FUN_SYS_IS_IPV6
=
718
,
T_FUN_SYS_IS_IPV4_MAPPED
=
719
,
T_FUN_SYS_IS_IPV4_COMPAT
=
720
,
T_FUN_SYS_INETATON
=
721
,
///< @note add new mysql only function type before this line
T_MYSQL_ONLY_SYS_MAX_OP
=
800
,
...
...
src/sql/parser/type_name.c
浏览文件 @
f8b75754
...
...
@@ -173,6 +173,13 @@ const char* get_type_name(int type)
case
T_FUN_SYS_MD5
:
return
"T_FUN_SYS_MD5"
;
case
T_FUN_SYS_IP2INT
:
return
"T_FUN_SYS_IP2INT"
;
case
T_FUN_SYS_INT2IP
:
return
"T_FUN_SYS_INT2IP"
;
case
T_FUN_SYS_INET6NTOA
:
return
"T_FUN_SYS_INET6NTOA"
;
case
T_FUN_SYS_INET6ATON
:
return
"T_FUN_SYS_INET6ATON"
;
case
T_FUN_SYS_INETATON
:
return
"T_FUN_SYS_INETATON"
;
case
T_FUN_SYS_IS_IPV4
:
return
"T_FUN_SYS_IS_IPV4"
;
case
T_FUN_SYS_IS_IPV6
:
return
"T_FUN_SYS_IS_IPV6"
;
case
T_FUN_SYS_IS_IPV4_MAPPED
:
return
"T_FUN_SYS_IS_IPV4_MAPPED"
;
case
T_FUN_SYS_IS_IPV4_COMPAT
:
return
"T_FUN_SYS_IS_IPV4_COMPAT"
;
case
T_FUN_SYS_INSERT
:
return
"T_FUN_SYS_INSERT"
;
case
T_FUN_SYS_LENGTH
:
return
"T_FUN_SYS_LENGTH"
;
case
T_FUN_SYS_HEX
:
return
"T_FUN_SYS_HEX"
;
...
...
src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp
浏览文件 @
f8b75754
...
...
@@ -3547,6 +3547,8 @@ int ObRawExprResolverImpl::process_fun_sys_node(const ParseNode* node, ObRawExpr
type
=
ObExprOperatorFactory
::
get_type_by_name
(
"pow"
);
}
else
if
(
0
==
func_name
.
case_compare
(
"ws"
))
{
type
=
ObExprOperatorFactory
::
get_type_by_name
(
"word_segment"
);
}
else
if
(
0
==
func_name
.
case_compare
(
"inet_ntoa"
))
{
type
=
ObExprOperatorFactory
::
get_type_by_name
(
"int2ip"
);
}
else
{
type
=
ObExprOperatorFactory
::
get_type_by_name
(
func_name
);
}
...
...
src/sql/resolver/expr/ob_raw_expr_util.cpp
浏览文件 @
f8b75754
...
...
@@ -667,6 +667,9 @@ int ObRawExprUtils::function_alias(ObRawExprFactory& expr_factory, ObSysFunRawEx
}
else
if
(
0
==
expr
->
get_func_name
().
case_compare
(
"ws"
))
{
// ws is synonym for word_segment
expr
->
set_func_name
(
"word_segment"
);
}
else
if
(
0
==
expr
->
get_func_name
().
case_compare
(
"inet_ntoa"
))
{
// inet_ntoa is synonym for int2ip
expr
->
set_func_name
(
"int2ip"
);
}
else
{
}
return
ret
;
...
...
src/sql/resolver/ob_resolver_utils.cpp
浏览文件 @
f8b75754
...
...
@@ -3245,6 +3245,8 @@ int ObResolverUtils::resolve_generated_column_info(
type
=
ObExprOperatorFactory
::
get_type_by_name
(
"pow"
);
}
else
if
(
0
==
func_name
.
case_compare
(
"ws"
))
{
type
=
ObExprOperatorFactory
::
get_type_by_name
(
"word_segment"
);
}
else
if
(
0
==
func_name
.
case_compare
(
"inet_ntoa"
))
{
type
=
ObExprOperatorFactory
::
get_type_by_name
(
"int2ip"
);
}
else
{
type
=
ObExprOperatorFactory
::
get_type_by_name
(
func_name
);
}
...
...
test/mysql_test/test_suite/expr/r/mysql/expr_inet_new.result
0 → 100644
浏览文件 @
f8b75754
此差异已折叠。
点击以展开。
test/mysql_test/test_suite/expr/r/mysql/expr_inet_old.result
0 → 100644
浏览文件 @
f8b75754
此差异已折叠。
点击以展开。
test/mysql_test/test_suite/expr/t/expr_inet_new.test
0 → 100644
浏览文件 @
f8b75754
--
disable_query_log
set
@@
session
.
explicit_defaults_for_timestamp
=
off
;
--
enable_query_log
--
disable_warnings
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
#
# Testing of misc functions
#
select
inet_ntoa
(
null
),
inet_aton
(
null
);
select
inet_ntoa
(
inet_aton
(
"255.255.255.255.255.255.255.255"
));
select
inet_aton
(
"255.255.255.255.255"
),
inet_aton
(
"255.255.1.255"
),
inet_aton
(
"0.1.255"
);
select
inet_ntoa
(
1099511627775
),
inet_ntoa
(
4294902271
),
inet_ntoa
(
511
);
select
inet_aton
(
"0.255.255.255.255"
);
select
inet_aton
(
"255.255.255.0000"
);
select
hex
(
inet_aton
(
'127'
));
select
hex
(
inet_aton
(
'127.1'
));
select
hex
(
inet_aton
(
'127.1.1'
));
select
inet_aton
(
"122.256"
);
select
inet_aton
(
"122.226."
);
select
inet_aton
(
""
);
--
echo
--
echo
# -- INET6_ATON: checking NULL, invalid types, out-of range values...
--
echo
SELECT
INET6_ATON
(
NULL
)
IS
NULL
;
SELECT
INET6_ATON
(
123
)
IS
NULL
;
SELECT
INET6_ATON
(
123.45
)
IS
NULL
;
SELECT
INET6_ATON
(
str_to_date
(
'2014,2,28 09'
,
'%Y,%m,%d %h'
))
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1..3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'-1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.256'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.4.5'
)
IS
NULL
;
SELECT
INET6_ATON
(
'0001.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'0x1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'a.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.4:80'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.4/32'
)
IS
NULL
;
SELECT
INET6_ATON
(
'oceanbase'
)
IS
NULL
;
SELECT
INET6_ATON
(
':::'
)
IS
NULL
;
SELECT
INET6_ATON
(
':1:2:3'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1:2:3:'
)
IS
NULL
;
SELECT
INET6_ATON
(
':1::2:3'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1::2:3:'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::00001'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::00001:2'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::12345'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1020::3040::5060'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::ABCZ'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::0x1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::1.0x2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::a.b.c.d'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::FFFF:0x1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::FFFF:1.0x2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::FFFF:a.b.c.d'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::1.2.3.4:ABCD'
)
IS
NULL
;
--
echo
# NOTE: such addresses are supported because getaddrinfo() supports them.
--
echo
# This is just to record the current behaviour.
SELECT
HEX
(
INET6_ATON
(
'::ABCD:1.2.3.4'
));
--
echo
--
echo
# -- INET6_ATON: checking binary representation...
--
echo
SELECT
HEX
(
INET6_ATON
(
'0.0.0.0'
));
SELECT
HEX
(
INET6_ATON
(
'00.00.00.00'
));
SELECT
HEX
(
INET6_ATON
(
'000.000.000.000'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'01.02.03.04'
));
SELECT
HEX
(
INET6_ATON
(
'001.002.003.004'
));
SELECT
HEX
(
INET6_ATON
(
'255.255.255.255'
));
SELECT
HEX
(
INET6_ATON
(
'::'
));
SELECT
HEX
(
INET6_ATON
(
'0::0'
));
SELECT
HEX
(
INET6_ATON
(
'1::2'
));
SELECT
HEX
(
INET6_ATON
(
'0::'
));
SELECT
HEX
(
INET6_ATON
(
'1::'
));
SELECT
HEX
(
INET6_ATON
(
'::0'
));
SELECT
HEX
(
INET6_ATON
(
'::1'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'::2:3:4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1::3:4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2::4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3::5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4::6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5::7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5:6::8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5:6:7::'
));
SELECT
HEX
(
INET6_ATON
(
'0000:0000::0000:0001'
));
SELECT
HEX
(
INET6_ATON
(
'1234:5678:9abc:def0:4321:8765:cba9:0fed'
));
SELECT
HEX
(
INET6_ATON
(
'0000:0000:0000:0000:0000:0000:0000:0001'
));
SELECT
HEX
(
INET6_ATON
(
'::C0A8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::c0a8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::192.168.1.2'
));
SELECT
HEX
(
INET6_ATON
(
'::FfFf:C0a8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::ffff:c0a8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::ffff:192.168.1.2'
));
SELECT
HEX
(
INET6_ATON
(
'::01.2.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::1.02.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::1.2.03.4'
));
SELECT
HEX
(
INET6_ATON
(
'::1.2.3.04'
));
SELECT
HEX
(
INET6_ATON
(
'::1.2.3.00'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:01.2.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.02.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.2.03.4'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.2.3.04'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.2.3.00'
));
--
echo
--
echo
# -- INET6_ATON: checking the length is either 4 or 16...
--
echo
SELECT
LENGTH
(
INET6_ATON
(
'0.0.0.0'
));
SELECT
LENGTH
(
INET6_ATON
(
'255.255.255.255'
));
SELECT
LENGTH
(
INET6_ATON
(
'::'
));
SELECT
LENGTH
(
INET6_ATON
(
'1020:3040:5060:7080:90A0:B0C0:D0E0:F010'
));
--
echo
--
echo
# -- INET6_NTOA: checking NULL, invalid types, out-of range values...
--
echo
SELECT
INET6_NTOA
(
NULL
);
SELECT
INET6_NTOA
(
123
);
SELECT
INET6_NTOA
(
123.456
);
SELECT
INET6_NTOA
(
str_to_date
(
'2014,2,28 09'
,
'%Y,%m,%d %h'
));
SELECT
INET6_NTOA
(
UNHEX
(
'C0A801'
));
# 3 bytes -> NULL
SELECT
INET6_NTOA
(
UNHEX
(
'C0A80102'
));
# 4 bytes -> 192.168.1.2
SELECT
INET6_NTOA
(
UNHEX
(
'C0A8010203'
));
# 5 bytes -> NULL
SELECT
INET6_NTOA
(
UNHEX
(
'0102030405060708090A0B0C0D0E0F'
));
# 15 bytes -> NULL
SELECT
INET6_NTOA
(
UNHEX
(
'0102030405060708090A0B0C0D0E0F10'
));
# 16 bytes -> IP
SELECT
INET6_NTOA
(
UNHEX
(
'0102030405060708090A0B0C0D0E0F1011'
));
# 17 bytes -> NULL
SELECT
INET6_NTOA
(
'1234'
),
INET6_NTOA
(
BINARY
(
'1234'
));
SELECT
INET6_NTOA
(
'0123456789abcdef'
),
INET6_NTOA
(
BINARY
(
'0123456789abcdef'
));
--
echo
--
echo
# -- Checking double-conversion...
--
echo
SELECT
INET6_NTOA
(
INET6_ATON
(
'::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0::0'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1::2'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::0'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::2:3:4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1::3:4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2::4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3::5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4::6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5::7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5:6::8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5:6:7::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000::0000:0001'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1234:5678:9abc:def0:4321:8765:cba9:0fed'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000:0000:0000:0000:0000:0000:0001'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000:0000:0000:1:1:255.255.255.255'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000:0000:0000:0001:0001:255.255.255.255'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::C0A8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::c0a8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::192.168.1.2'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FfFf:C0a8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::ffff:c0a8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::ffff:192.168.1.2'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::01.2.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.02.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.2.03.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.2.3.04'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.2.3.00'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:01.2.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.02.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.2.03.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.2.3.04'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.2.3.00'
));
--
echo
--
echo
# -- Comparing INET_ATON() and INET6_ATON()...
--
echo
SELECT
HEX
(
INET_ATON
(
'192.168.1.2'
));
SELECT
HEX
(
INET6_ATON
(
'192.168.1.2'
));
SELECT
HEX
(
INET_ATON
(
'255.255.255.255'
));
SELECT
HEX
(
INET6_ATON
(
'255.255.255.255'
));
SELECT
HEX
(
INET_ATON
(
'192.168.08.2'
));
SELECT
HEX
(
INET6_ATON
(
'192.168.08.2'
));
SELECT
HEX
(
INET_ATON
(
'192.168.0x8.2'
));
SELECT
HEX
(
INET6_ATON
(
'192.168.0x8.2'
));
SELECT
HEX
(
INET_ATON
(
'1.2.255'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.255'
));
SELECT
HEX
(
INET_ATON
(
'1.2.256'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.256'
));
SELECT
HEX
(
INET_ATON
(
'1.0002.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'1.0002.3.4'
));
SELECT
HEX
(
INET_ATON
(
'1.2.3.4.5'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.3.4.5'
));
--
echo
--
echo
# -- Checking mix of INET- and INET6- functions...
--
echo
SELECT
HEX
(
INET6_ATON
(
INET_NTOA
(
INET_ATON
(
'1.2.3.4'
))))
AS
x
;
--
echo
--
echo
# -- Checking IS_IPV4() / IS_IPV6()...
--
echo
SELECT
IS_IPV4
(
NULL
);
SELECT
IS_IPV4
(
1
);
SELECT
IS_IPV4
(
1.0
);
SELECT
IS_IPV4
(
'1.2.3.4'
);
SELECT
IS_IPV4
(
'001.02.000.255'
);
SELECT
IS_IPV4
(
'::1.2.0.255'
);
SELECT
IS_IPV4
(
'::1'
);
SELECT
IS_IPV4
(
BINARY
(
'1.2.3.4'
));
SELECT
IS_IPV6
(
NULL
);
SELECT
IS_IPV6
(
1
);
SELECT
IS_IPV6
(
1.0
);
SELECT
IS_IPV6
(
'1.2.3.4'
);
SELECT
IS_IPV6
(
'001.02.000.255'
);
SELECT
IS_IPV6
(
'::001.02.000.255'
);
SELECT
IS_IPV6
(
'::1.2.0.255'
);
SELECT
IS_IPV6
(
'::1'
);
SELECT
IS_IPV6
(
'0000:0000:0000:0000:0000:0000:0000:0001'
);
SELECT
IS_IPV6
(
BINARY
(
'0000:0000:0000:0000:0000:0000:0000:0001'
));
--
echo
--
echo
# -- Checking IS_IPV4_MAPPED() and IS_IPV4_COMPAT()...
--
echo
SELECT
IS_IPV4_MAPPED
(
NULL
),
IS_IPV4_COMPAT
(
NULL
);
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::FFFF:1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::FFFF:1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::ABCD:1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::ABCD:1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::1'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::1'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::'
));
# NOTE: IS_IPV4_COMPAT() / IS_IPV4_MAPPED() could work with "regular strings in
# binary collation" too, but there is no way to create a "regular string"
# starting with \0.
--
echo
--
echo
# -- Checking IS_IPV4_COMPAT()...
--
echo
--
echo
--
echo
# -- Working with a table...
--
echo
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
ip
INT
UNSIGNED
);
CREATE
TABLE
t2
(
ip
VARBINARY
(
16
));
--
echo
INSERT
INTO
t1
VALUES
(
INET_ATON
(
'1.2.3.4'
)),
(
INET_ATON
(
'255.255.255.255'
));
SELECT
INET_NTOA
(
ip
)
FROM
t1
;
--
echo
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.3.4'
)),
(
INET6_ATON
(
'255.255.255.255'
)),
(
INET6_ATON
(
'::1.2.3.4'
)),
(
INET6_ATON
(
'::ffff:255.255.255.255'
)),
(
INET6_ATON
(
'::'
)),
(
INET6_ATON
(
'::1'
)),
(
INET6_ATON
(
'1020:3040:5060:7080:90A0:B0C0:D0E0:F010'
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
--
echo
--
echo
# test different sql mode
--
echo
set
sql_mode
=
STRICT_TRANS_TABLES
;
select
@@
sql_mode
;
DELETE
FROM
t2
;
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.0002.3.4'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.255'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.256'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'192.168.0x8.2'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.256"
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.226."
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
""
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
SELECT
INET6_ATON
(
'1.0002.3.4'
);
SELECT
INET6_ATON
(
""
);
--
echo
set
sql_mode
=
STRICT_ALL_TABLES
;
select
@@
sql_mode
;
DELETE
FROM
t2
;
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.0002.3.4'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.255'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.256'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'192.168.0x8.2'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.256"
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.226."
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
""
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
SELECT
INET6_ATON
(
'1.0002.3.4'
);
SELECT
INET6_ATON
(
""
);
--
echo
set
sql_mode
=
''
;
select
@@
sql_mode
;
DELETE
FROM
t2
;
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.0002.3.4'
));
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.255'
));
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.256'
));
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'192.168.0x8.2'
));
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.256"
));
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.226."
));
INSERT
INTO
t2
VALUES
(
inet_aton
(
""
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
SELECT
INET6_ATON
(
'1.0002.3.4'
);
SELECT
INET6_ATON
(
""
);
DROP
TABLE
t1
;
DROP
TABLE
t2
;
--
echo
--
echo
# -- Done misc test.
--
echo
--
echo
#
--
echo
# End of tests
--
echo
#
test/mysql_test/test_suite/expr/t/expr_inet_old.test
0 → 100644
浏览文件 @
f8b75754
connect
(
sys_jianhua
,
$OBMYSQL_MS0
,
root
@
sys
,,
oceanbase
,
$OBMYSQL_PORT
);
connection
sys_jianhua
;
alter
system
set
_enable_static_typing_engine
=
false
;
connect
(
mysql_jianhua
,
$OBMYSQL_MS0
,
root
@
mysql
,
''
,
test
,
$OBMYSQL_PORT
);
connection
mysql_jianhua
;
--
disable_query_log
set
@@
session
.
explicit_defaults_for_timestamp
=
off
;
--
enable_query_log
--
disable_warnings
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
#
# Testing of misc functions
#
select
inet_ntoa
(
null
),
inet_aton
(
null
);
select
inet_ntoa
(
inet_aton
(
"255.255.255.255.255.255.255.255"
));
select
inet_aton
(
"255.255.255.255.255"
),
inet_aton
(
"255.255.1.255"
),
inet_aton
(
"0.1.255"
);
select
inet_ntoa
(
1099511627775
),
inet_ntoa
(
4294902271
),
inet_ntoa
(
511
);
select
inet_aton
(
"0.255.255.255.255"
);
select
inet_aton
(
"255.255.255.0000"
);
select
hex
(
inet_aton
(
'127'
));
select
hex
(
inet_aton
(
'127.1'
));
select
hex
(
inet_aton
(
'127.1.1'
));
select
inet_aton
(
"122.256"
);
select
inet_aton
(
"122.226."
);
select
inet_aton
(
""
);
--
echo
--
echo
# -- INET6_ATON: checking NULL, invalid types, out-of range values...
--
echo
SELECT
INET6_ATON
(
NULL
)
IS
NULL
;
SELECT
INET6_ATON
(
123
)
IS
NULL
;
SELECT
INET6_ATON
(
123.45
)
IS
NULL
;
SELECT
INET6_ATON
(
str_to_date
(
'2014,2,28 09'
,
'%Y,%m,%d %h'
))
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1..3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'-1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.256'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.4.5'
)
IS
NULL
;
SELECT
INET6_ATON
(
'0001.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'0x1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'a.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.4:80'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1.2.3.4/32'
)
IS
NULL
;
SELECT
INET6_ATON
(
'oceanbase'
)
IS
NULL
;
SELECT
INET6_ATON
(
':::'
)
IS
NULL
;
SELECT
INET6_ATON
(
':1:2:3'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1:2:3:'
)
IS
NULL
;
SELECT
INET6_ATON
(
':1::2:3'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1::2:3:'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::00001'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::00001:2'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::12345'
)
IS
NULL
;
SELECT
INET6_ATON
(
'1020::3040::5060'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::ABCZ'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::0x1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::1.0x2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::a.b.c.d'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::FFFF:0x1.2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::FFFF:1.0x2.3.4'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::FFFF:a.b.c.d'
)
IS
NULL
;
SELECT
INET6_ATON
(
'::1.2.3.4:ABCD'
)
IS
NULL
;
--
echo
# NOTE: such addresses are supported because getaddrinfo() supports them.
--
echo
# This is just to record the current behaviour.
SELECT
HEX
(
INET6_ATON
(
'::ABCD:1.2.3.4'
));
--
echo
--
echo
# -- INET6_ATON: checking binary representation...
--
echo
SELECT
HEX
(
INET6_ATON
(
'0.0.0.0'
));
SELECT
HEX
(
INET6_ATON
(
'00.00.00.00'
));
SELECT
HEX
(
INET6_ATON
(
'000.000.000.000'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'01.02.03.04'
));
SELECT
HEX
(
INET6_ATON
(
'001.002.003.004'
));
SELECT
HEX
(
INET6_ATON
(
'255.255.255.255'
));
SELECT
HEX
(
INET6_ATON
(
'::'
));
SELECT
HEX
(
INET6_ATON
(
'0::0'
));
SELECT
HEX
(
INET6_ATON
(
'1::2'
));
SELECT
HEX
(
INET6_ATON
(
'0::'
));
SELECT
HEX
(
INET6_ATON
(
'1::'
));
SELECT
HEX
(
INET6_ATON
(
'::0'
));
SELECT
HEX
(
INET6_ATON
(
'::1'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'::2:3:4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1::3:4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2::4:5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3::5:6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4::6:7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5::7:8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5:6::8'
));
SELECT
HEX
(
INET6_ATON
(
'1:2:3:4:5:6:7::'
));
SELECT
HEX
(
INET6_ATON
(
'0000:0000::0000:0001'
));
SELECT
HEX
(
INET6_ATON
(
'1234:5678:9abc:def0:4321:8765:cba9:0fed'
));
SELECT
HEX
(
INET6_ATON
(
'0000:0000:0000:0000:0000:0000:0000:0001'
));
SELECT
HEX
(
INET6_ATON
(
'::C0A8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::c0a8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::192.168.1.2'
));
SELECT
HEX
(
INET6_ATON
(
'::FfFf:C0a8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::ffff:c0a8:0102'
));
SELECT
HEX
(
INET6_ATON
(
'::ffff:192.168.1.2'
));
SELECT
HEX
(
INET6_ATON
(
'::01.2.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::1.02.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::1.2.03.4'
));
SELECT
HEX
(
INET6_ATON
(
'::1.2.3.04'
));
SELECT
HEX
(
INET6_ATON
(
'::1.2.3.00'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:01.2.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.02.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.2.03.4'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.2.3.04'
));
SELECT
HEX
(
INET6_ATON
(
'::FFFF:1.2.3.00'
));
--
echo
--
echo
# -- INET6_ATON: checking the length is either 4 or 16...
--
echo
SELECT
LENGTH
(
INET6_ATON
(
'0.0.0.0'
));
SELECT
LENGTH
(
INET6_ATON
(
'255.255.255.255'
));
SELECT
LENGTH
(
INET6_ATON
(
'::'
));
SELECT
LENGTH
(
INET6_ATON
(
'1020:3040:5060:7080:90A0:B0C0:D0E0:F010'
));
--
echo
--
echo
# -- INET6_NTOA: checking NULL, invalid types, out-of range values...
--
echo
SELECT
INET6_NTOA
(
NULL
);
SELECT
INET6_NTOA
(
123
);
SELECT
INET6_NTOA
(
123.456
);
SELECT
INET6_NTOA
(
str_to_date
(
'2014,2,28 09'
,
'%Y,%m,%d %h'
));
SELECT
INET6_NTOA
(
UNHEX
(
'C0A801'
));
# 3 bytes -> NULL
SELECT
INET6_NTOA
(
UNHEX
(
'C0A80102'
));
# 4 bytes -> 192.168.1.2
SELECT
INET6_NTOA
(
UNHEX
(
'C0A8010203'
));
# 5 bytes -> NULL
SELECT
INET6_NTOA
(
UNHEX
(
'0102030405060708090A0B0C0D0E0F'
));
# 15 bytes -> NULL
SELECT
INET6_NTOA
(
UNHEX
(
'0102030405060708090A0B0C0D0E0F10'
));
# 16 bytes -> IP
SELECT
INET6_NTOA
(
UNHEX
(
'0102030405060708090A0B0C0D0E0F1011'
));
# 17 bytes -> NULL
SELECT
INET6_NTOA
(
'1234'
),
INET6_NTOA
(
BINARY
(
'1234'
));
SELECT
INET6_NTOA
(
'0123456789abcdef'
),
INET6_NTOA
(
BINARY
(
'0123456789abcdef'
));
--
echo
--
echo
# -- Checking double-conversion...
--
echo
SELECT
INET6_NTOA
(
INET6_ATON
(
'::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0::0'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1::2'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::0'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::2:3:4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1::3:4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2::4:5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3::5:6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4::6:7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5::7:8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5:6::8'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1:2:3:4:5:6:7::'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000::0000:0001'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'1234:5678:9abc:def0:4321:8765:cba9:0fed'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000:0000:0000:0000:0000:0000:0001'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000:0000:0000:1:1:255.255.255.255'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'0000:0000:0000:0000:0001:0001:255.255.255.255'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::C0A8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::c0a8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::192.168.1.2'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FfFf:C0a8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::ffff:c0a8:0102'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::ffff:192.168.1.2'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::01.2.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.02.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.2.03.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.2.3.04'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::1.2.3.00'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:01.2.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.02.3.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.2.03.4'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.2.3.04'
));
SELECT
INET6_NTOA
(
INET6_ATON
(
'::FFFF:1.2.3.00'
));
--
echo
--
echo
# -- Comparing INET_ATON() and INET6_ATON()...
--
echo
SELECT
HEX
(
INET_ATON
(
'192.168.1.2'
));
SELECT
HEX
(
INET6_ATON
(
'192.168.1.2'
));
SELECT
HEX
(
INET_ATON
(
'255.255.255.255'
));
SELECT
HEX
(
INET6_ATON
(
'255.255.255.255'
));
SELECT
HEX
(
INET_ATON
(
'192.168.08.2'
));
SELECT
HEX
(
INET6_ATON
(
'192.168.08.2'
));
SELECT
HEX
(
INET_ATON
(
'192.168.0x8.2'
));
SELECT
HEX
(
INET6_ATON
(
'192.168.0x8.2'
));
SELECT
HEX
(
INET_ATON
(
'1.2.255'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.255'
));
SELECT
HEX
(
INET_ATON
(
'1.2.256'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.256'
));
SELECT
HEX
(
INET_ATON
(
'1.0002.3.4'
));
SELECT
HEX
(
INET6_ATON
(
'1.0002.3.4'
));
SELECT
HEX
(
INET_ATON
(
'1.2.3.4.5'
));
SELECT
HEX
(
INET6_ATON
(
'1.2.3.4.5'
));
--
echo
--
echo
# -- Checking mix of INET- and INET6- functions...
--
echo
SELECT
HEX
(
INET6_ATON
(
INET_NTOA
(
INET_ATON
(
'1.2.3.4'
))))
AS
x
;
--
echo
--
echo
# -- Checking IS_IPV4() / IS_IPV6()...
--
echo
SELECT
IS_IPV4
(
NULL
);
SELECT
IS_IPV4
(
1
);
SELECT
IS_IPV4
(
1.0
);
SELECT
IS_IPV4
(
'1.2.3.4'
);
SELECT
IS_IPV4
(
'001.02.000.255'
);
SELECT
IS_IPV4
(
'::1.2.0.255'
);
SELECT
IS_IPV4
(
'::1'
);
SELECT
IS_IPV4
(
BINARY
(
'1.2.3.4'
));
SELECT
IS_IPV6
(
NULL
);
SELECT
IS_IPV6
(
1
);
SELECT
IS_IPV6
(
1.0
);
SELECT
IS_IPV6
(
'1.2.3.4'
);
SELECT
IS_IPV6
(
'001.02.000.255'
);
SELECT
IS_IPV6
(
'::001.02.000.255'
);
SELECT
IS_IPV6
(
'::1.2.0.255'
);
SELECT
IS_IPV6
(
'::1'
);
SELECT
IS_IPV6
(
'0000:0000:0000:0000:0000:0000:0000:0001'
);
SELECT
IS_IPV6
(
BINARY
(
'0000:0000:0000:0000:0000:0000:0000:0001'
));
--
echo
--
echo
# -- Checking IS_IPV4_MAPPED() and IS_IPV4_COMPAT()...
--
echo
SELECT
IS_IPV4_MAPPED
(
NULL
),
IS_IPV4_COMPAT
(
NULL
);
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::FFFF:1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::FFFF:1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::ABCD:1.2.3.4'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::ABCD:1.2.3.4'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::1'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::1'
));
SELECT
IS_IPV4_MAPPED
(
INET6_ATON
(
'::'
)),
IS_IPV4_COMPAT
(
INET6_ATON
(
'::'
));
# NOTE: IS_IPV4_COMPAT() / IS_IPV4_MAPPED() could work with "regular strings in
# binary collation" too, but there is no way to create a "regular string"
# starting with \0.
--
echo
--
echo
# -- Checking IS_IPV4_COMPAT()...
--
echo
--
echo
--
echo
# -- Working with a table...
--
echo
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
ip
INT
UNSIGNED
);
CREATE
TABLE
t2
(
ip
VARBINARY
(
16
));
--
echo
INSERT
INTO
t1
VALUES
(
INET_ATON
(
'1.2.3.4'
)),
(
INET_ATON
(
'255.255.255.255'
));
SELECT
INET_NTOA
(
ip
)
FROM
t1
;
--
echo
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.3.4'
)),
(
INET6_ATON
(
'255.255.255.255'
)),
(
INET6_ATON
(
'::1.2.3.4'
)),
(
INET6_ATON
(
'::ffff:255.255.255.255'
)),
(
INET6_ATON
(
'::'
)),
(
INET6_ATON
(
'::1'
)),
(
INET6_ATON
(
'1020:3040:5060:7080:90A0:B0C0:D0E0:F010'
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
--
echo
--
echo
# test different sql mode
--
echo
set
sql_mode
=
STRICT_TRANS_TABLES
;
select
@@
sql_mode
;
DELETE
FROM
t2
;
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.0002.3.4'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.255'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.256'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'192.168.0x8.2'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.256"
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.226."
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
""
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
SELECT
INET6_ATON
(
'1.0002.3.4'
);
SELECT
INET6_ATON
(
""
);
--
echo
set
sql_mode
=
STRICT_ALL_TABLES
;
select
@@
sql_mode
;
DELETE
FROM
t2
;
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.0002.3.4'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.255'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.256'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'192.168.0x8.2'
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.256"
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.226."
));
--
error
1210
INSERT
INTO
t2
VALUES
(
inet_aton
(
""
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
SELECT
INET6_ATON
(
'1.0002.3.4'
);
SELECT
INET6_ATON
(
""
);
--
echo
set
sql_mode
=
''
;
select
@@
sql_mode
;
DELETE
FROM
t2
;
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.0002.3.4'
));
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.255'
));
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'1.2.256'
));
INSERT
INTO
t2
VALUES
(
INET6_ATON
(
'192.168.0x8.2'
));
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.256"
));
INSERT
INTO
t2
VALUES
(
inet_aton
(
"122.226."
));
INSERT
INTO
t2
VALUES
(
inet_aton
(
""
));
SELECT
INET6_NTOA
(
ip
),
HEX
(
ip
),
LENGTH
(
ip
)
FROM
t2
;
SELECT
INET6_ATON
(
'1.0002.3.4'
);
SELECT
INET6_ATON
(
""
);
DROP
TABLE
t1
;
DROP
TABLE
t2
;
--
echo
--
echo
# -- Done misc test.
--
echo
--
echo
#
--
echo
# End of tests
--
echo
#
connection
sys_jianhua
;
alter
system
set
_enable_static_typing_engine
=
true
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录