Support hex string for load data formats

This commit is contained in:
wjhh2008
2024-06-17 20:27:47 +00:00
committed by ob-robot
parent ba29ae32f8
commit 8cf399af82
4 changed files with 25 additions and 8 deletions

View File

@ -3080,10 +3080,12 @@ int ObLoadDataSPImpl::ToolBox::init(ObExecContext &ctx, ObLoadDataStmt &load_stm
}
}
if (OB_SUCC(ret)) {
char *buf = NULL;
int64_t buf_len = DEFAULT_BUF_LENGTH;
bool need_extend = true;
while (OB_SUCC(ret) && need_extend) {
char *buf = NULL;
int64_t pos = 0;
buf_len *= 2;
if (OB_ISNULL(buf = static_cast<char*>(ctx.get_allocator().alloc(buf_len)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("no memory", K(ret), K(buf_len));
@ -3114,6 +3116,14 @@ int ObLoadDataSPImpl::ToolBox::init(ObExecContext &ctx, ObLoadDataStmt &load_stm
cur_query_str.length(), cur_query_str.ptr()));
OX (load_info.assign_ptr(buf, pos));
}
if (OB_SUCC(ret)) {
need_extend = false;
} else {
if (OB_SIZE_OVERFLOW == ret) {
ret = OB_SUCCESS;
need_extend = true;
}
}
}
if (OB_SUCC(ret)) {

View File

@ -10202,19 +10202,19 @@ field_term_list field_term
;
field_term:
TERMINATED BY STRING_VALUE
TERMINATED BY text_string
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FIELD_TERMINATED_STR, 1, $3);
}
| OPTIONALLY ENCLOSED BY STRING_VALUE
| OPTIONALLY ENCLOSED BY text_string
{
malloc_non_terminal_node($$, result->malloc_pool_, T_OPTIONALLY_CLOSED_STR, 1, $4);
}
| ENCLOSED BY STRING_VALUE
| ENCLOSED BY text_string
{
malloc_non_terminal_node($$, result->malloc_pool_, T_CLOSED_STR, 1, $3);
}
| ESCAPED BY STRING_VALUE
| ESCAPED BY text_string
{
malloc_non_terminal_node($$, result->malloc_pool_, T_ESCAPED_STR, 1, $3);
}
@ -10290,11 +10290,11 @@ line_term_list line_term
;
line_term:
TERMINATED BY STRING_VALUE
TERMINATED BY text_string
{
malloc_non_terminal_node($$, result->malloc_pool_, T_LINE_TERMINATED_STR, 1, $3);
}
| STARTING BY STRING_VALUE
| STARTING BY text_string
{
malloc_non_terminal_node($$, result->malloc_pool_, T_LINE_START_STR, 1, $3);
}

View File

@ -1393,6 +1393,9 @@ int ObLoadDataResolver::resolve_string_node(const ParseNode &node, ObString &tar
OZ (ObResolverUtils::escape_char_for_oracle_mode(*allocator_, target_str, cs_type));
}
break;
case T_HEX_STRING:
target_str.assign_ptr(node.str_value_, static_cast<int32_t>(node.str_len_));
break;
case T_OPTIONALLY_CLOSED_STR:
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "optionally enclosed string");

View File

@ -4992,6 +4992,10 @@ int ObSelectResolver::resolve_into_const_node(const ParseNode *node, ObObj &obj)
obj.set_varchar(node_str);
obj.set_collation_type(cs_type);
}
} else if (T_HEX_STRING == node->type_) {
ObString node_str(node->str_len_, node->str_value_);
obj.set_varchar(node_str);
obj.set_collation_type(CS_TYPE_BINARY);
} else if (T_QUESTIONMARK == node->type_) {
obj.set_unknown(node->value_);
} else {