Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
58f7fb88
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看板
提交
58f7fb88
编写于
8月 11, 2021
作者:
L
LINxiansheng
提交者:
wangzelin.wzl
8月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request from GitHub pr175
上级
99f28352
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
800 addition
and
7 deletion
+800
-7
deps/oblib/src/lib/ob_name_def.h
deps/oblib/src/lib/ob_name_def.h
+1
-0
src/sql/CMakeLists.txt
src/sql/CMakeLists.txt
+1
-0
src/sql/code_generator/ob_static_engine_cg.cpp
src/sql/code_generator/ob_static_engine_cg.cpp
+5
-2
src/sql/engine/expr/ob_expr_eval_functions.cpp
src/sql/engine/expr/ob_expr_eval_functions.cpp
+2
-0
src/sql/engine/expr/ob_expr_export_set.cpp
src/sql/engine/expr/ob_expr_export_set.cpp
+268
-0
src/sql/engine/expr/ob_expr_export_set.h
src/sql/engine/expr/ob_expr_export_set.h
+42
-0
src/sql/engine/expr/ob_expr_operator.cpp
src/sql/engine/expr/ob_expr_operator.cpp
+4
-2
src/sql/engine/expr/ob_expr_operator_factory.cpp
src/sql/engine/expr/ob_expr_operator_factory.cpp
+2
-0
src/sql/engine/expr/ob_expr_regexp_context.cpp
src/sql/engine/expr/ob_expr_regexp_context.cpp
+1
-1
src/sql/engine/expr/ob_expr_uid.cpp
src/sql/engine/expr/ob_expr_uid.cpp
+5
-2
src/sql/parser/ob_item_type.h
src/sql/parser/ob_item_type.h
+2
-0
src/sql/parser/type_name.c
src/sql/parser/type_name.c
+1
-0
test/mysql_test/test_suite/expr/r/mysql/expr_export_set.result
...mysql_test/test_suite/expr/r/mysql/expr_export_set.result
+315
-0
test/mysql_test/test_suite/expr/t/expr_export_set.test
test/mysql_test/test_suite/expr/t/expr_export_set.test
+151
-0
未找到文件。
deps/oblib/src/lib/ob_name_def.h
浏览文件 @
58f7fb88
...
@@ -434,6 +434,7 @@
...
@@ -434,6 +434,7 @@
#define N_REPLACE "replace"
#define N_REPLACE "replace"
#define N_TRANSLATE "translate"
#define N_TRANSLATE "translate"
#define N_CONCAT "concat"
#define N_CONCAT "concat"
#define N_EXPORT_SET "export_set"
#define N_CONCAT_WS "concat_ws"
#define N_CONCAT_WS "concat_ws"
#define N_TO_OUTFILE_ROW "to_outfile_row"
#define N_TO_OUTFILE_ROW "to_outfile_row"
#define N_INSTR "instr"
#define N_INSTR "instr"
...
...
src/sql/CMakeLists.txt
浏览文件 @
58f7fb88
...
@@ -346,6 +346,7 @@ ob_set_subtarget(ob_sql engine
...
@@ -346,6 +346,7 @@ ob_set_subtarget(ob_sql engine
engine/expr/ob_expr_regexp_like.cpp
engine/expr/ob_expr_regexp_like.cpp
engine/expr/ob_expr_repeat.cpp
engine/expr/ob_expr_repeat.cpp
engine/expr/ob_expr_replace.cpp
engine/expr/ob_expr_replace.cpp
engine/expr/ob_expr_export_set.cpp
engine/expr/ob_expr_translate.cpp
engine/expr/ob_expr_translate.cpp
engine/expr/ob_expr_pi.cpp
engine/expr/ob_expr_pi.cpp
engine/expr/ob_expr_pi.h
engine/expr/ob_expr_pi.h
...
...
src/sql/code_generator/ob_static_engine_cg.cpp
浏览文件 @
58f7fb88
...
@@ -234,9 +234,12 @@ int ObStaticEngineCG::postorder_generate_op(
...
@@ -234,9 +234,12 @@ int ObStaticEngineCG::postorder_generate_op(
}
}
if
(
is_subplan
)
{
if
(
is_subplan
)
{
cur_op_exprs_
.
reset
();
cur_op_exprs_
.
reset
();
cur_op_exprs_
.
assign
(
tmp_cur_op_exprs
);
cur_op_self_produced_exprs_
.
reset
();
cur_op_self_produced_exprs_
.
reset
();
cur_op_self_produced_exprs_
.
assign
(
tmp_cur_op_self_produced_exprs
);
if
(
OB_FAIL
(
cur_op_exprs_
.
assign
(
tmp_cur_op_exprs
)))
{
LOG_WARN
(
"assign exprs failed"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
cur_op_self_produced_exprs_
.
assign
(
tmp_cur_op_self_produced_exprs
)))
{
LOG_WARN
(
"assign exprs failed"
,
K
(
ret
));
}
}
}
return
ret
;
return
ret
;
...
...
src/sql/engine/expr/ob_expr_eval_functions.cpp
浏览文件 @
58f7fb88
...
@@ -69,6 +69,7 @@
...
@@ -69,6 +69,7 @@
#include "ob_expr_regexp_replace.h"
#include "ob_expr_regexp_replace.h"
#include "ob_expr_regexp_substr.h"
#include "ob_expr_regexp_substr.h"
#include "ob_expr_repeat.h"
#include "ob_expr_repeat.h"
#include "ob_expr_export_set.h"
#include "ob_expr_replace.h"
#include "ob_expr_replace.h"
#include "ob_expr_func_dump.h"
#include "ob_expr_func_dump.h"
#include "ob_expr_func_part_hash.h"
#include "ob_expr_func_part_hash.h"
...
@@ -663,6 +664,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
...
@@ -663,6 +664,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
ObExprTimeFormat
::
calc_time_format
,
/* 407 */
ObExprTimeFormat
::
calc_time_format
,
/* 407 */
ObExprMakedate
::
calc_makedate
,
/* 408 */
ObExprMakedate
::
calc_makedate
,
/* 408 */
ObExprPeriodAdd
::
calc_periodadd
,
/* 409 */
ObExprPeriodAdd
::
calc_periodadd
,
/* 409 */
ObExprExportSet
::
eval_export_set
,
/* 401 */
};
};
REG_SER_FUNC_ARRAY
(
OB_SFA_SQL_EXPR_EVAL
,
g_expr_eval_functions
,
ARRAYSIZEOF
(
g_expr_eval_functions
));
REG_SER_FUNC_ARRAY
(
OB_SFA_SQL_EXPR_EVAL
,
g_expr_eval_functions
,
ARRAYSIZEOF
(
g_expr_eval_functions
));
...
...
src/sql/engine/expr/ob_expr_export_set.cpp
0 → 100644
浏览文件 @
58f7fb88
/**
* 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.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/expr/ob_expr_export_set.h"
#include "lib/oblog/ob_log.h"
#include "share/object/ob_obj_cast.h"
#include "sql/session/ob_sql_session_info.h"
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
sql
{
ObExprExportSet
::
ObExprExportSet
(
ObIAllocator
&
alloc
)
:
ObStringExprOperator
(
alloc
,
T_FUN_SYS_EXPORT_SET
,
N_EXPORT_SET
,
MORE_THAN_TWO
)
{
need_charset_convert_
=
false
;
}
ObExprExportSet
::~
ObExprExportSet
()
{}
int
ObExprExportSet
::
calc_result_typeN
(
ObExprResType
&
type
,
ObExprResType
*
types_array
,
int64_t
param_num
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
if
(
3
!=
param_num
&&
4
!=
param_num
&&
5
!=
param_num
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"Export_Set() should have three or four or five arguments"
,
K
(
ret
),
K
(
param_num
));
}
else
if
(
OB_ISNULL
(
types_array
)
||
OB_ISNULL
(
type_ctx
.
get_session
()))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected error. types_array or session null"
,
K
(
ret
),
KP
(
types_array
),
KP
(
type_ctx
.
get_session
()));
}
else
{
// deduce length
// Maximum occurrences of on and of in result
const
uint64_t
MAX_BIT_NUM
=
64
;
// Maximum occurrences of sep in result
const
uint64_t
MAX_SEP_NUM
=
63
;
const
int64_t
on_len
=
types_array
[
1
].
get_length
();
const
int64_t
off_len
=
types_array
[
2
].
get_length
();
int64_t
sep_len
=
1
;
int64_t
str_num
=
2
;
const
uint64_t
max_len
=
std
::
max
(
on_len
,
off_len
);
// when bits exceed uint_max or int_min, ob is not compatible to mysql.
types_array
[
0
].
set_calc_type
(
common
::
ObBitType
);
types_array
[
1
].
set_calc_type
(
common
::
ObVarcharType
);
types_array
[
2
].
set_calc_type
(
common
::
ObVarcharType
);
if
(
3
<
param_num
)
{
sep_len
=
types_array
[
3
].
get_length
();
str_num
=
3
;
types_array
[
3
].
set_calc_type
(
common
::
ObVarcharType
);
if
(
4
<
param_num
)
{
types_array
[
4
].
set_calc_type
(
common
::
ObIntType
);
}
}
common
::
ObLength
len
=
static_cast
<
common
::
ObLength
>
(
MAX_BIT_NUM
*
max_len
+
MAX_SEP_NUM
*
sep_len
);
type
.
set_length
(
len
);
type
.
set_varchar
();
// set collation_type for string type
OZ
(
ObExprOperator
::
aggregate_charsets_for_string_result_with_comparison
(
type
,
&
types_array
[
1
],
str_num
,
type_ctx
.
get_coll_type
()));
for
(
int64_t
i
=
1
;
OB_SUCC
(
ret
)
&&
i
<=
str_num
;
++
i
)
{
types_array
[
i
].
set_calc_meta
(
type
);
}
}
return
ret
;
}
int
ObExprExportSet
::
calc_resultN
(
ObObj
&
result
,
const
ObObj
*
objs_array
,
int64_t
param_num
,
ObExprCtx
&
expr_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
if
(
OB_ISNULL
(
expr_ctx
.
calc_buf_
))
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"calc_buf of expr_ctx is NULL"
,
K
(
ret
));
}
else
if
(
3
==
param_num
)
{
ObObj
tmp_n_bits
;
ObObj
tmp_sep
;
tmp_n_bits
.
set_int
(
64
);
tmp_sep
.
set_string
(
common
::
ObVarcharType
,
ObCharsetUtils
::
get_const_str
(
objs_array
[
1
].
get_collation_type
(),
','
));
if
(
OB_FAIL
(
calc_export_set
(
result
,
objs_array
[
0
],
objs_array
[
1
],
objs_array
[
2
],
tmp_sep
,
tmp_n_bits
,
expr_ctx
)))
{
LOG_WARN
(
"calc_export_set failed"
,
K
(
ret
));
}
}
else
if
(
4
==
param_num
)
{
ObObj
tmp_n_bits
;
tmp_n_bits
.
set_int
(
64
);
if
(
OB_FAIL
(
calc_export_set
(
result
,
objs_array
[
0
],
objs_array
[
1
],
objs_array
[
2
],
objs_array
[
3
],
tmp_n_bits
,
expr_ctx
)))
{
LOG_WARN
(
"calc_export_set failed"
,
K
(
ret
));
}
}
else
if
(
5
==
param_num
)
{
if
(
OB_FAIL
(
calc_export_set
(
result
,
objs_array
[
0
],
objs_array
[
1
],
objs_array
[
2
],
objs_array
[
3
],
objs_array
[
4
],
expr_ctx
)))
{
LOG_WARN
(
"calc_export_set failed"
,
K
(
ret
));
}
}
return
ret
;
}
int
ObExprExportSet
::
calc_export_set
(
ObObj
&
result
,
const
ObObj
&
bits
,
const
ObObj
&
on
,
const
ObObj
&
off
,
const
ObObj
&
sep
,
const
ObObj
&
n_bits
,
ObExprCtx
&
expr_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
if
(
bits
.
is_null
()
||
on
.
is_null
()
||
off
.
is_null
()
||
sep
.
is_null
()
||
n_bits
.
is_null
())
{
result
.
set_null
();
}
else
if
(
OB_ISNULL
(
expr_ctx
.
calc_buf_
))
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"varchar buffer not init"
,
K
(
ret
));
}
else
{
uint64_t
local_bits
;
ObString
local_on
;
ObString
local_off
;
ObString
local_sep
;
int64_t
local_n_bits
;
ObString
res
;
local_on
=
on
.
get_string
();
local_off
=
off
.
get_string
();
local_sep
=
sep
.
get_string
();
if
(
OB_FAIL
(
bits
.
get_bit
(
local_bits
)))
{
LOG_WARN
(
"fail to get bit"
,
K
(
ret
),
K
(
bits
));
}
else
if
(
OB_FAIL
(
n_bits
.
get_int
(
local_n_bits
)))
{
LOG_WARN
(
"fail to get int"
,
K
(
ret
),
K
(
n_bits
));
}
else
if
(
OB_FAIL
(
calc_export_set_inner
(
res
,
local_bits
,
local_on
,
local_off
,
local_sep
,
local_n_bits
,
*
expr_ctx
.
calc_buf_
)))
{
LOG_WARN
(
"do export set failed"
,
K
(
ret
));
}
else
{
result
.
set_string
(
result_type_
.
get_type
(),
res
);
result
.
set_collation
(
result_type_
);
}
}
return
ret
;
}
int
ObExprExportSet
::
calc_export_set_inner
(
ObString
&
ret_str
,
const
uint64_t
bits
,
const
ObString
&
on
,
const
ObString
&
off
,
const
ObString
&
sep
,
const
int64_t
n_bits
,
ObExprStringBuf
&
string_buf
)
{
int
ret
=
OB_SUCCESS
;
if
(
OB_UNLIKELY
(
n_bits
==
0
))
{
// Return empty string
ret_str
.
reset
();
}
else
if
(
OB_UNLIKELY
(
on
.
length
()
<=
0
&&
off
.
length
()
<=
0
&&
sep
.
length
()
<=
0
))
{
ret_str
.
reset
();
}
else
{
const
uint64_t
MAX_BIT_NUM
=
64UL
;
uint64_t
local_n_bits
=
static_cast
<
uint64_t
>
(
n_bits
);
local_n_bits
=
std
::
min
(
MAX_BIT_NUM
,
local_n_bits
);
const
int64_t
length_on
=
on
.
length
();
const
int64_t
length_off
=
off
.
length
();
const
int64_t
length_sep
=
sep
.
length
();
int64_t
tot_length
=
0
;
// total length for the result.
uint64_t
i
;
const
uint64_t
mask
=
1
;
//compute tot_length and save ans
tot_length
+=
(
local_n_bits
-
1
)
*
length_sep
;
for
(
i
=
0
;
i
<
local_n_bits
;
++
i
)
{
if
(
bits
&
(
mask
<<
i
)){
tot_length
+=
length_on
;
}
else
{
tot_length
+=
length_off
;
}
}
// Avoid realloc
if
(
OB_UNLIKELY
(
tot_length
<=
0
))
{
// tot_length equals to 0 indicates that length_to is zero and "to" is empty string
ret_str
.
reset
();
}
else
{
char
*
buf
=
static_cast
<
char
*>
(
string_buf
.
alloc
(
tot_length
));
if
(
OB_ISNULL
(
buf
))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
LOG_ERROR
(
"alloc memory failed."
,
K
(
ret
),
K
(
tot_length
));
}
else
{
// Core function
char
*
tmp_buf
=
buf
;
if
(
local_n_bits
>
0
)
{
if
(
bits
&
mask
)
{
MEMCPY
(
tmp_buf
,
on
.
ptr
(),
length_on
);
tmp_buf
+=
length_on
;
}
else
{
MEMCPY
(
tmp_buf
,
off
.
ptr
(),
length_off
);
tmp_buf
+=
length_off
;
}
}
for
(
i
=
1
;
i
<
local_n_bits
;
++
i
)
{
MEMCPY
(
tmp_buf
,
sep
.
ptr
(),
length_sep
);
tmp_buf
+=
length_sep
;
if
(
bits
&
(
mask
<<
i
))
{
MEMCPY
(
tmp_buf
,
on
.
ptr
(),
length_on
);
tmp_buf
+=
length_on
;
}
else
{
MEMCPY
(
tmp_buf
,
off
.
ptr
(),
length_off
);
tmp_buf
+=
length_off
;
}
}
ret_str
.
assign_ptr
(
buf
,
static_cast
<
int32_t
>
(
tot_length
));
}
}
}
return
ret
;
}
int
ObExprExportSet
::
cg_expr
(
ObExprCGCtx
&
,
const
ObRawExpr
&
,
ObExpr
&
rt_expr
)
const
{
int
ret
=
OB_SUCCESS
;
CK
(
3
==
rt_expr
.
arg_cnt_
||
4
==
rt_expr
.
arg_cnt_
||
5
==
rt_expr
.
arg_cnt_
);
rt_expr
.
eval_func_
=
&
eval_export_set
;
return
ret
;
}
int
ObExprExportSet
::
eval_export_set
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
)
{
int
ret
=
OB_SUCCESS
;
ObDatum
*
bits
=
NULL
;
ObDatum
*
on
=
NULL
;
ObDatum
*
off
=
NULL
;
ObDatum
*
sep
=
NULL
;
ObDatum
*
n_bits
=
NULL
;
int64_t
max_size
=
0
;
if
(
OB_FAIL
(
expr
.
eval_param_value
(
ctx
,
bits
,
on
,
off
,
sep
,
n_bits
)))
{
LOG_WARN
(
"evaluate parameters failed"
,
K
(
ret
));
}
else
if
(
bits
->
is_null
()
||
on
->
is_null
()
||
off
->
is_null
())
{
expr_datum
.
set_null
();
}
else
if
(
OB_NOT_NULL
(
sep
)
&&
sep
->
is_null
())
{
expr_datum
.
set_null
();
}
else
if
(
OB_NOT_NULL
(
n_bits
)
&&
n_bits
->
is_null
())
{
expr_datum
.
set_null
();
}
else
{
ObExprStrResAlloc
expr_res_alloc
(
expr
,
ctx
);
ObString
output
;
//default parm
ObString
sep_parm
;
int64_t
n_bits_parm
;
if
(
OB_ISNULL
(
sep
))
{
sep_parm
=
ObCharsetUtils
::
get_const_str
(
expr
.
datum_meta_
.
cs_type_
,
','
);
}
else
{
sep_parm
=
sep
->
get_string
();
}
if
(
OB_ISNULL
(
n_bits
))
{
n_bits_parm
=
64
;
}
else
{
n_bits_parm
=
n_bits
->
get_uint64
();
}
if
(
OB_FAIL
(
calc_export_set_inner
(
output
,
bits
->
get_uint64
(),
on
->
get_string
(),
off
->
get_string
(),
sep_parm
,
n_bits_parm
,
expr_res_alloc
)))
{
LOG_WARN
(
"do export set failed"
,
K
(
ret
));
}
else
{
expr_datum
.
set_string
(
output
);
}
}
return
ret
;
}
}
// namespace sql
}
// namespace oceanbase
src/sql/engine/expr/ob_expr_export_set.h
0 → 100644
浏览文件 @
58f7fb88
/**
* 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_EXPORT_SET_
#define OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_EXPORT_SET_
#include "sql/engine/expr/ob_expr_operator.h"
namespace
oceanbase
{
namespace
sql
{
class
ObExprExportSet
:
public
ObStringExprOperator
{
public:
explicit
ObExprExportSet
(
common
::
ObIAllocator
&
alloc
);
virtual
~
ObExprExportSet
();
virtual
int
calc_result_typeN
(
ObExprResType
&
type
,
ObExprResType
*
types_array
,
int64_t
param_num
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
;
virtual
int
calc_resultN
(
common
::
ObObj
&
result
,
const
common
::
ObObj
*
objs_array
,
int64_t
param_num
,
common
::
ObExprCtx
&
expr_ctx
)
const
;
virtual
int
calc_export_set
(
common
::
ObObj
&
result
,
const
common
::
ObObj
&
bits
,
const
common
::
ObObj
&
on
,
const
common
::
ObObj
&
off
,
const
common
::
ObObj
&
sep
,
const
common
::
ObObj
&
n_bits
,
common
::
ObExprCtx
&
expr_ctx
)
const
;
virtual
int
cg_expr
(
ObExprCGCtx
&
op_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
override
;
static
int
eval_export_set
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
);
private:
// disallow copy
DISALLOW_COPY_AND_ASSIGN
(
ObExprExportSet
);
// helper func
static
int
calc_export_set_inner
(
ObString
&
ret_str
,
const
uint64_t
bits
,
const
ObString
&
on
,
const
ObString
&
off
,
const
ObString
&
sep
,
const
int64_t
n_bits
,
ObExprStringBuf
&
string_buf
);
};
}
// namespace sql
}
// namespace oceanbase
#endif // OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_EXPORT_SET_
src/sql/engine/expr/ob_expr_operator.cpp
浏览文件 @
58f7fb88
...
@@ -4776,8 +4776,10 @@ int ObRelationalExprOperator::cg_row_cmp_expr(const int row_dimension, ObIAlloca
...
@@ -4776,8 +4776,10 @@ int ObRelationalExprOperator::cg_row_cmp_expr(const int row_dimension, ObIAlloca
ret
=
OB_ERR_UNEXPECTED
;
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected error"
,
K
(
ret
));
LOG_WARN
(
"unexpected error"
,
K
(
ret
));
}
}
if
(
OB_ISNULL
(
right_row
)
||
OB_ISNULL
(
left_row
))
{
if
(
OB_UNLIKELY
(
left_row
->
arg_cnt_
!=
right_row
->
arg_cnt_
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"right_row or left_row is null ptr"
,
K
(
ret
),
K
(
right_row
),
K
(
left_row
));
}
else
if
(
OB_UNLIKELY
(
left_row
->
arg_cnt_
!=
right_row
->
arg_cnt_
))
{
ret
=
OB_ERR_UNEXPECTED
;
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected row cnt"
,
K
(
left_row
->
arg_cnt_
),
K
(
right_row
->
arg_cnt_
));
LOG_WARN
(
"unexpected row cnt"
,
K
(
left_row
->
arg_cnt_
),
K
(
right_row
->
arg_cnt_
));
}
}
...
...
src/sql/engine/expr/ob_expr_operator_factory.cpp
浏览文件 @
58f7fb88
...
@@ -143,6 +143,7 @@
...
@@ -143,6 +143,7 @@
#include "sql/engine/expr/ob_expr_merging_frozen_time.h"
#include "sql/engine/expr/ob_expr_merging_frozen_time.h"
#include "sql/engine/expr/ob_expr_remainder.h"
#include "sql/engine/expr/ob_expr_remainder.h"
#include "sql/engine/expr/ob_expr_repeat.h"
#include "sql/engine/expr/ob_expr_repeat.h"
#include "sql/engine/expr/ob_expr_export_set.h"
#include "sql/engine/expr/ob_expr_replace.h"
#include "sql/engine/expr/ob_expr_replace.h"
#include "sql/engine/expr/ob_expr_translate.h"
#include "sql/engine/expr/ob_expr_translate.h"
#include "sql/engine/expr/ob_expr_func_part_hash.h"
#include "sql/engine/expr/ob_expr_func_part_hash.h"
...
@@ -535,6 +536,7 @@ void ObExprOperatorFactory::register_expr_operators()
...
@@ -535,6 +536,7 @@ void ObExprOperatorFactory::register_expr_operators()
REG_OP
(
ObExprFuncCeiling
);
REG_OP
(
ObExprFuncCeiling
);
REG_OP
(
ObExprFuncDump
);
REG_OP
(
ObExprFuncDump
);
REG_OP
(
ObExprRepeat
);
REG_OP
(
ObExprRepeat
);
REG_OP
(
ObExprExportSet
);
REG_OP
(
ObExprReplace
);
REG_OP
(
ObExprReplace
);
REG_OP
(
ObExprFuncPartOldHash
);
REG_OP
(
ObExprFuncPartOldHash
);
REG_OP
(
ObExprFuncPartHash
);
REG_OP
(
ObExprFuncPartHash
);
...
...
src/sql/engine/expr/ob_expr_regexp_context.cpp
浏览文件 @
58f7fb88
...
@@ -376,7 +376,7 @@ int ObExprRegexContext::like(const ObString& text, int64_t occurrence, bool& sub
...
@@ -376,7 +376,7 @@ int ObExprRegexContext::like(const ObString& text, int64_t occurrence, bool& sub
}
else
if
(
text
.
length
()
<
0
||
(
text
.
length
()
>
0
&&
OB_ISNULL
(
text
.
ptr
())))
{
}
else
if
(
text
.
length
()
<
0
||
(
text
.
length
()
>
0
&&
OB_ISNULL
(
text
.
ptr
())))
{
ret
=
OB_INVALID_ARGUMENT
;
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid param, source text is null"
,
K
(
ret
),
K
(
text
));
LOG_WARN
(
"invalid param, source text is null"
,
K
(
ret
),
K
(
text
));
}
else
if
(
reg_
.
re_nsub
>=
0
)
{
}
else
{
size_t
nsub
=
reg_
.
re_nsub
;
size_t
nsub
=
reg_
.
re_nsub
;
ob_regmatch_t
pmatch
[
nsub
+
1
];
ob_regmatch_t
pmatch
[
nsub
+
1
];
int
error
=
0
;
int
error
=
0
;
...
...
src/sql/engine/expr/ob_expr_uid.cpp
浏览文件 @
58f7fb88
...
@@ -61,8 +61,11 @@ int ObExprUid::calc_result0(ObObj& result, ObExprCtx& expr_ctx) const
...
@@ -61,8 +61,11 @@ int ObExprUid::calc_result0(ObObj& result, ObExprCtx& expr_ctx) const
const
uint64_t
sess_uid
=
session_info
->
get_user_id
();
const
uint64_t
sess_uid
=
session_info
->
get_user_id
();
// result.set_uint64_value(sess_uid);
// result.set_uint64_value(sess_uid);
number
::
ObNumber
num
;
number
::
ObNumber
num
;
num
.
from
(
sess_uid
,
*
(
expr_ctx
.
calc_buf_
));
if
(
OB_FAIL
(
num
.
from
(
sess_uid
,
*
(
expr_ctx
.
calc_buf_
))))
{
result
.
set_number
(
num
);
LOG_WARN
(
"convert int to number failed"
,
K
(
ret
),
K
(
sess_uid
));
}
else
{
result
.
set_number
(
num
);
}
}
}
return
ret
;
return
ret
;
}
}
...
...
src/sql/parser/ob_item_type.h
浏览文件 @
58f7fb88
...
@@ -426,6 +426,8 @@ typedef enum ObItemType {
...
@@ -426,6 +426,8 @@ typedef enum ObItemType {
T_FUN_SYS_QUARTER
=
711
,
T_FUN_SYS_QUARTER
=
711
,
T_FUN_SYS_BIT_LENGTH
=
712
,
T_FUN_SYS_BIT_LENGTH
=
712
,
T_FUN_SYS_PI
=
713
,
T_FUN_SYS_PI
=
713
,
T_FUN_SYS_EXPORT_SET
=
714
,
///< @note add new mysql only function type before this line
///< @note add new mysql only function type before this line
T_MYSQL_ONLY_SYS_MAX_OP
=
800
,
T_MYSQL_ONLY_SYS_MAX_OP
=
800
,
...
...
src/sql/parser/type_name.c
浏览文件 @
58f7fb88
...
@@ -1552,6 +1552,7 @@ const char* get_type_name(int type)
...
@@ -1552,6 +1552,7 @@ const char* get_type_name(int type)
case
T_HASH_PARTITION_LIST
:
return
"T_HASH_PARTITION_LIST"
;
case
T_HASH_PARTITION_LIST
:
return
"T_HASH_PARTITION_LIST"
;
case
T_RANGE_PARTITION_LIST
:
return
"T_RANGE_PARTITION_LIST"
;
case
T_RANGE_PARTITION_LIST
:
return
"T_RANGE_PARTITION_LIST"
;
case
T_LIST_PARTITION_LIST
:
return
"T_LIST_PARTITION_LIST"
;
case
T_LIST_PARTITION_LIST
:
return
"T_LIST_PARTITION_LIST"
;
case
T_FUN_SYS_EXPORT_SET
:
return
"T_FUN_SYS_EXPORT_SET"
;
default:
return
"Unknown"
;
default:
return
"Unknown"
;
}
}
}
}
test/mysql_test/test_suite/expr/r/mysql/expr_export_set.result
0 → 100644
浏览文件 @
58f7fb88
================ expression export_set ================
select export_set(0,"Y","N","-",5);
export_set(0,"Y","N","-",5)
N-N-N-N-N
select export_set(7,"Y","N","-",5);
export_set(7,"Y","N","-",5)
Y-Y-Y-N-N
select export_set(11,"Y","N","-",5);
export_set(11,"Y","N","-",5)
Y-Y-N-Y-N
select export_set(20,"Y","N","-",5);
export_set(20,"Y","N","-",5)
N-N-Y-N-Y
select export_set(9,"","","-",5);
export_set(9,"","","-",5)
----
select export_set(9,"Y","N","-",5);
export_set(9,"Y","N","-",5)
Y-N-N-Y-N
select export_set(9,"左","右","-",5);
export_set(9,"左","右","-",5)
左-右-右-左-右
select export_set(9,"上","下","-",5);
export_set(9,"上","下","-",5)
上-下-下-上-下
select export_set(5,"Y","N",".",5);
export_set(5,"Y","N",".",5)
Y.N.Y.N.N
select export_set(5,"Y","N","=",5);
export_set(5,"Y","N","=",5)
Y=N=Y=N=N
select export_set(5,"Y","N","????????",5);
export_set(5,"Y","N","????????",5)
Y????????N????????Y????????N????????N
select export_set(100,"Y","N",".",3);
export_set(100,"Y","N",".",3)
N.N.Y
select export_set(100,"Y","N",".",5);
export_set(100,"Y","N",".",5)
N.N.Y.N.N
select export_set(100,"Y","N",".",7);
export_set(100,"Y","N",".",7)
N.N.Y.N.N.Y.Y
select export_set(100,"Y","N",".",10);
export_set(100,"Y","N",".",10)
N.N.Y.N.N.Y.Y.N.N.N
select export_set(null,"Y","N",".",5);
export_set(null,"Y","N",".",5)
NULL
select export_set(0,"Y","N",".",5);
export_set(0,"Y","N",".",5)
N.N.N.N.N
select export_set(5,null,"N",".",5);
export_set(5,null,"N",".",5)
NULL
select export_set(5,'',"N",".",5);
export_set(5,'',"N",".",5)
.N..N.N
select export_set(5,"Y",null,".",5);
export_set(5,"Y",null,".",5)
NULL
select export_set(5,"Y",'',".",5);
export_set(5,"Y",'',".",5)
Y..Y..
select export_set(5,"Y","N",null,5);
export_set(5,"Y","N",null,5)
NULL
select export_set(5,"Y","N",'',5);
export_set(5,"Y","N",'',5)
YNYNN
select export_set(5,"Y","N",".",null);
export_set(5,"Y","N",".",null)
NULL
select export_set(5,"Y","N",".",0);
export_set(5,"Y","N",".",0)
select export_set(55555555555555,"YY","NN",".",0);
export_set(55555555555555,"YY","NN",".",0)
select export_set(55555555555555,"YY","NN",".......",0);
export_set(55555555555555,"YY","NN",".......",0)
select export_set(100,'',1);
export_set(100,'',1)
1,1,,1,1,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
select export_set(100,1,'');
export_set(100,1,'')
,,1,,,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
select export_set(100,1,0,'');
export_set(100,1,0,'')
0010011000000000000000000000000000000000000000000000000000000000
select export_set(1000,'',1);
export_set(1000,'',1)
1,1,1,,1,,,,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
select export_set(1000,1,'');
export_set(1000,1,'')
,,,1,,1,1,1,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
select export_set(1000,1,0,'');
export_set(1000,1,0,'')
0001011111000000000000000000000000000000000000000000000000000000
select export_set(8,"Y","N");
export_set(8,"Y","N")
N,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
select export_set(88,"Y","N");
export_set(88,"Y","N")
N,N,N,Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
select export_set(888,"Y","N");
export_set(888,"Y","N")
N,N,N,Y,Y,Y,Y,N,Y,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
select export_set(8888,"Y","N");
export_set(8888,"Y","N")
N,N,N,Y,Y,Y,N,Y,N,Y,N,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
select export_set(8,"1","0");
export_set(8,"1","0")
0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(8,"X","Y");
export_set(8,"X","Y")
Y,Y,Y,X,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y
select export_set(8,"Y","N",'+');
export_set(8,"Y","N",'+')
N+N+N+Y+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N+N
select export_set(8,"1","0",'*');
export_set(8,"1","0",'*')
0*0*0*1*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0
select export_set(8,"X","Y",'*');
export_set(8,"X","Y",'*')
Y*Y*Y*X*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y*Y
select export_set(7,1,0,"-",5);
export_set(7,1,0,"-",5)
1-1-1-0-0
select export_set(7,11,00,"-",5);
export_set(7,11,00,"-",5)
11-11-11-0-0
select export_set(7,111,000,"-",5);
export_set(7,111,000,"-",5)
111-111-111-0-0
select export_set(7,111,000,5,5);
export_set(7,111,000,5,5)
111511151115050
select export_set(true,1,0);
export_set(true,1,0)
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(true,"1","0");
export_set(true,"1","0")
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(false,1,0);
export_set(false,1,0)
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(false,"1","0");
export_set(false,"1","0")
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(1.4,1,0);
export_set(1.4,1,0)
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(2.4,1,0);
export_set(2.4,1,0)
0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
select export_set(1.4,"y","n");
export_set(1.4,"y","n")
y,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n
select export_set(2.4,"y","n");
export_set(2.4,"y","n")
n,y,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n
select export_set(9223372036854775808,"Y","N");
export_set(9223372036854775808,"Y","N")
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(9223372036854775809,"Y","N");
export_set(9223372036854775809,"Y","N")
Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(-9223372036854775808,"Y","N");
export_set(-9223372036854775808,"Y","N")
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(18446744073709551615,"Y","N");
export_set(18446744073709551615,"Y","N")
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y
select export_set(9223372036854775808,"Y","N",",",92233720368547758080000000000);
export_set(9223372036854775808,"Y","N",",",92233720368547758080000000000)
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(9223372036854775808,"Y","N",",",9223372036854775808);
export_set(9223372036854775808,"Y","N",",",9223372036854775808)
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(9223372036854775809,"Y","N",",",9223372036854775809);
export_set(9223372036854775809,"Y","N",",",9223372036854775809)
Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(9223372036854775809,"Y","N",",",9223372036854775809000000000000);
export_set(9223372036854775809,"Y","N",",",9223372036854775809000000000000)
Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(-9223372036854775808,"Y","N",",",-9223372036854775808);
export_set(-9223372036854775808,"Y","N",",",-9223372036854775808)
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(-9223372036854775808,"Y","N",",",-9223372036854775808000000000);
export_set(-9223372036854775808,"Y","N",",",-9223372036854775808000000000)
N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,Y
select export_set(18446744073709551615,"Y","N",",",18446744073709551615);
export_set(18446744073709551615,"Y","N",",",18446744073709551615)
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y
select export_set(18446744073709551615,"Y","N",",",1844674407370955161500000000000);
export_set(18446744073709551615,"Y","N",",",1844674407370955161500000000000)
Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y
select export_set();
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set(1);
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set(1,2);
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set("");
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set("","");
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set(5,5);
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set(a,2,3);
ERROR 42S22: Unknown column 'a' in 'field list'
select export_set(1,2,3,a);
ERROR 42S22: Unknown column 'a' in 'field list'
select export_set(1,2,3,4,a);
ERROR 42S22: Unknown column 'a' in 'field list'
drop table if exists test;
create table test(c1 int, c2 varchar(20), c3 varchar(20), c4 varchar(20), c5 int);
insert into test values(11,"Y","N",",",10);
insert into test values(null,"Y","N",",",10);
insert into test values(11,null,"N",",",10);
insert into test values(11,"Y",null,",",10);
insert into test values(11,"Y","N",null,10);
insert into test values(11,"Y","N",",",null);
insert into test values(null,null,null,null,null);
select export_set(c1,c2,c3,c4,c5) from test;
export_set(c1,c2,c3,c4,c5)
Y,Y,N,Y,N,N,N,N,N,N
NULL
NULL
NULL
NULL
NULL
NULL
select export_set(c1,c2,c3,c4) from test;
export_set(c1,c2,c3,c4)
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
NULL
NULL
NULL
NULL
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
NULL
select export_set(c1,c2,c3) from test;
export_set(c1,c2,c3)
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
NULL
NULL
NULL
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
NULL
insert into test values(100000,"+","-",",",1000000);
insert into test values(55555555,"+","-",",",100000);
insert into test values(7777777,"+","-",",",10000);
select export_set(c1,c2,c3,c4,5) from test;
export_set(c1,c2,c3,c4,5)
Y,Y,N,Y,N
NULL
NULL
NULL
NULL
Y,Y,N,Y,N
NULL
-,-,-,-,-
+,+,-,-,-
+,-,-,-,+
select export_set(c1,c2,c3,'??',5) from test;
export_set(c1,c2,c3,'??',5)
Y??Y??N??Y??N
NULL
NULL
NULL
Y??Y??N??Y??N
Y??Y??N??Y??N
NULL
-??-??-??-??-
+??+??-??-??-
+??-??-??-??+
select export_set(c1,c2,c3) from test;
export_set(c1,c2,c3)
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
NULL
NULL
NULL
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
Y,Y,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
NULL
-,-,-,-,-,+,-,+,-,+,+,-,-,-,-,+,+,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+,+,-,-,-,+,+,+,+,-,+,-,+,+,-,+,+,+,+,+,-,-,+,-,+,+,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+,-,-,-,+,+,+,+,+,-,+,+,-,+,-,+,-,+,+,-,+,+,+,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-
select export_set(c1) from test;
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set(c1,c2) from test;
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
select export_set() from test;
ERROR 42000: Incorrect parameter count in the call to native function 'export_set'
drop table test;
drop table if exists t1;
create table t1 as select export_set(0,"Y","N","-",5);
desc t1;
Field Type Null Key Default Extra
export_set(0,"Y","N","-",5) varchar(127) YES NULL
drop table t1;
create table t1 as select export_set(99,"YYY","NX","---",77);
desc t1;
Field Type Null Key Default Extra
export_set(99,"YYY","NX","---",77) varchar(381) YES NULL
drop table t1;
create table t1 as select export_set(99,"1","11","111",77);
desc t1;
Field Type Null Key Default Extra
export_set(99,"1","11","111",77) varchar(317) YES NULL
drop table t1;
test/mysql_test/test_suite/expr/t/expr_export_set.test
0 → 100644
浏览文件 @
58f7fb88
--
disable_query_log
set
@@
session
.
explicit_defaults_for_timestamp
=
off
;
--
enable_query_log
#/--disableabortonerror/
#/test for export_set function in ob_expr_export_set.cpp/
--
enable_abort_on_error
--
echo
================
expression
export_set
================
# 基本检查
select
export_set
(
0
,
"Y"
,
"N"
,
"-"
,
5
);
select
export_set
(
7
,
"Y"
,
"N"
,
"-"
,
5
);
select
export_set
(
11
,
"Y"
,
"N"
,
"-"
,
5
);
select
export_set
(
20
,
"Y"
,
"N"
,
"-"
,
5
);
select
export_set
(
9
,
""
,
""
,
"-"
,
5
);
select
export_set
(
9
,
"Y"
,
"N"
,
"-"
,
5
);
select
export_set
(
9
,
"左"
,
"右"
,
"-"
,
5
);
select
export_set
(
9
,
"上"
,
"下"
,
"-"
,
5
);
select
export_set
(
5
,
"Y"
,
"N"
,
"."
,
5
);
select
export_set
(
5
,
"Y"
,
"N"
,
"="
,
5
);
select
export_set
(
5
,
"Y"
,
"N"
,
"????????"
,
5
);
select
export_set
(
100
,
"Y"
,
"N"
,
"."
,
3
);
select
export_set
(
100
,
"Y"
,
"N"
,
"."
,
5
);
select
export_set
(
100
,
"Y"
,
"N"
,
"."
,
7
);
select
export_set
(
100
,
"Y"
,
"N"
,
"."
,
10
);
# 参数NULL检查
select
export_set
(
null
,
"Y"
,
"N"
,
"."
,
5
);
select
export_set
(
0
,
"Y"
,
"N"
,
"."
,
5
);
select
export_set
(
5
,
null
,
"N"
,
"."
,
5
);
select
export_set
(
5
,
''
,
"N"
,
"."
,
5
);
select
export_set
(
5
,
"Y"
,
null
,
"."
,
5
);
select
export_set
(
5
,
"Y"
,
''
,
"."
,
5
);
select
export_set
(
5
,
"Y"
,
"N"
,
null
,
5
);
select
export_set
(
5
,
"Y"
,
"N"
,
''
,
5
);
select
export_set
(
5
,
"Y"
,
"N"
,
"."
,
null
);
select
export_set
(
5
,
"Y"
,
"N"
,
"."
,
0
);
select
export_set
(
55555555555555
,
"YY"
,
"NN"
,
"."
,
0
);
select
export_set
(
55555555555555
,
"YY"
,
"NN"
,
"......."
,
0
);
select
export_set
(
100
,
''
,
1
);
select
export_set
(
100
,
1
,
''
);
select
export_set
(
100
,
1
,
0
,
''
);
select
export_set
(
1000
,
''
,
1
);
select
export_set
(
1000
,
1
,
''
);
select
export_set
(
1000
,
1
,
0
,
''
);
# 默认参数检查
select
export_set
(
8
,
"Y"
,
"N"
);
select
export_set
(
88
,
"Y"
,
"N"
);
select
export_set
(
888
,
"Y"
,
"N"
);
select
export_set
(
8888
,
"Y"
,
"N"
);
select
export_set
(
8
,
"1"
,
"0"
);
select
export_set
(
8
,
"X"
,
"Y"
);
select
export_set
(
8
,
"Y"
,
"N"
,
'+'
);
select
export_set
(
8
,
"1"
,
"0"
,
'*'
);
select
export_set
(
8
,
"X"
,
"Y"
,
'*'
);
# 参数类型不同
select
export_set
(
7
,
1
,
0
,
"-"
,
5
);
select
export_set
(
7
,
11
,
00
,
"-"
,
5
);
select
export_set
(
7
,
111
,
000
,
"-"
,
5
);
select
export_set
(
7
,
111
,
000
,
5
,
5
);
select
export_set
(
true
,
1
,
0
);
select
export_set
(
true
,
"1"
,
"0"
);
select
export_set
(
false
,
1
,
0
);
select
export_set
(
false
,
"1"
,
"0"
);
select
export_set
(
1.4
,
1
,
0
);
select
export_set
(
2.4
,
1
,
0
);
select
export_set
(
1.4
,
"y"
,
"n"
);
select
export_set
(
2.4
,
"y"
,
"n"
);
# 边界检查
# 超过uint64的上界,int64的下界,ob对溢出的处理和mysql不同,这是mysql的bug,不兼容
# 目前保证-9223372036854775808到18446744073709551615与mysql兼容
# select export_set(1111111111111111111111111111111111111111111111111111,"Y","N");
select
export_set
(
9223372036854775808
,
"Y"
,
"N"
);
select
export_set
(
9223372036854775809
,
"Y"
,
"N"
);
select
export_set
(
-
9223372036854775808
,
"Y"
,
"N"
);
select
export_set
(
18446744073709551615
,
"Y"
,
"N"
);
select
export_set
(
9223372036854775808
,
"Y"
,
"N"
,
","
,
92233720368547758080000000000
);
select
export_set
(
9223372036854775808
,
"Y"
,
"N"
,
","
,
9223372036854775808
);
select
export_set
(
9223372036854775809
,
"Y"
,
"N"
,
","
,
9223372036854775809
);
select
export_set
(
9223372036854775809
,
"Y"
,
"N"
,
","
,
9223372036854775809000000000000
);
select
export_set
(
-
9223372036854775808
,
"Y"
,
"N"
,
","
,
-
9223372036854775808
);
select
export_set
(
-
9223372036854775808
,
"Y"
,
"N"
,
","
,
-
9223372036854775808000000000
);
select
export_set
(
18446744073709551615
,
"Y"
,
"N"
,
","
,
18446744073709551615
);
select
export_set
(
18446744073709551615
,
"Y"
,
"N"
,
","
,
1844674407370955161500000000000
);
# 参数错误检查
--
error
1582
select
export_set
();
--
error
1582
select
export_set
(
1
);
--
error
1582
select
export_set
(
1
,
2
);
--
error
1582
select
export_set
(
""
);
--
error
1582
select
export_set
(
""
,
""
);
--
error
1582
select
export_set
(
5
,
5
);
--
error
1054
select
export_set
(
a
,
2
,
3
);
--
error
1054
select
export_set
(
1
,
2
,
3
,
a
);
--
error
1054
select
export_set
(
1
,
2
,
3
,
4
,
a
);
# 用表数据做参数
--
disable_warnings
drop
table
if
exists
test
;
--
enable_warnings
create
table
test
(
c1
int
,
c2
varchar
(
20
),
c3
varchar
(
20
),
c4
varchar
(
20
),
c5
int
);
insert
into
test
values
(
11
,
"Y"
,
"N"
,
","
,
10
);
insert
into
test
values
(
null
,
"Y"
,
"N"
,
","
,
10
);
insert
into
test
values
(
11
,
null
,
"N"
,
","
,
10
);
insert
into
test
values
(
11
,
"Y"
,
null
,
","
,
10
);
insert
into
test
values
(
11
,
"Y"
,
"N"
,
null
,
10
);
insert
into
test
values
(
11
,
"Y"
,
"N"
,
","
,
null
);
insert
into
test
values
(
null
,
null
,
null
,
null
,
null
);
select
export_set
(
c1
,
c2
,
c3
,
c4
,
c5
)
from
test
;
select
export_set
(
c1
,
c2
,
c3
,
c4
)
from
test
;
select
export_set
(
c1
,
c2
,
c3
)
from
test
;
insert
into
test
values
(
100000
,
"+"
,
"-"
,
","
,
1000000
);
insert
into
test
values
(
55555555
,
"+"
,
"-"
,
","
,
100000
);
insert
into
test
values
(
7777777
,
"+"
,
"-"
,
","
,
10000
);
select
export_set
(
c1
,
c2
,
c3
,
c4
,
5
)
from
test
;
select
export_set
(
c1
,
c2
,
c3
,
'??'
,
5
)
from
test
;
select
export_set
(
c1
,
c2
,
c3
)
from
test
;
--
error
1582
select
export_set
(
c1
)
from
test
;
--
error
1582
select
export_set
(
c1
,
c2
)
from
test
;
--
error
1582
select
export_set
()
from
test
;
drop
table
test
;
# ctas cases
--
disable_warnings
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
as
select
export_set
(
0
,
"Y"
,
"N"
,
"-"
,
5
);
desc
t1
;
drop
table
t1
;
create
table
t1
as
select
export_set
(
99
,
"YYY"
,
"NX"
,
"---"
,
77
);
desc
t1
;
drop
table
t1
;
create
table
t1
as
select
export_set
(
99
,
"1"
,
"11"
,
"111"
,
77
);
desc
t1
;
drop
table
t1
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录