Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
miniob
提交
1c40013d
M
miniob
项目概览
oceanbase
/
miniob
1 年多 前同步成功
通知
74
Star
1521
Fork
537
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
M
miniob
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
提交
1c40013d
编写于
7月 13, 2022
作者:
羽飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add newline after response
上级
6c23afd0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
42 deletion
+40
-42
src/observer/sql/executor/execute_stage.cpp
src/observer/sql/executor/execute_stage.cpp
+9
-11
src/observer/sql/parser/parse_stage.cpp
src/observer/sql/parser/parse_stage.cpp
+1
-1
src/observer/sql/stmt/select_stmt.cpp
src/observer/sql/stmt/select_stmt.cpp
+30
-30
未找到文件。
src/observer/sql/executor/execute_stage.cpp
浏览文件 @
1c40013d
...
...
@@ -176,8 +176,7 @@ void ExecuteStage::handle_request(common::StageEvent *event)
session_event
->
set_response
(
strrc
(
rc
));
}
break
;
case
SCF_BEGIN
:
{
session
->
set_trx_multi_operation_mode
(
true
);
session_event
->
set_response
(
strrc
(
RC
::
SUCCESS
));
session_event
->
set_response
(
"SUCCESS
\n
"
);
}
break
;
case
SCF_COMMIT
:
{
Trx
*
trx
=
session
->
current_trx
();
...
...
@@ -273,7 +272,6 @@ IndexScanOperator *try_to_create_index_scan_operator(FilterStmt *filter_stmt)
Expression
*
left
=
filter_unit
->
left
();
Expression
*
right
=
filter_unit
->
right
();
CompOp
comp
=
filter_unit
->
comp
();
if
(
left
->
type
()
==
ExprType
::
FIELD
&&
right
->
type
()
==
ExprType
::
VALUE
)
{
}
else
if
(
left
->
type
()
==
ExprType
::
VALUE
&&
right
->
type
()
==
ExprType
::
FIELD
)
{
std
::
swap
(
left
,
right
);
...
...
@@ -458,9 +456,9 @@ RC ExecuteStage::do_create_table(SQLStageEvent *sql_event)
RC
rc
=
db
->
create_table
(
create_table
.
relation_name
,
create_table
.
attribute_count
,
create_table
.
attributes
);
if
(
rc
==
RC
::
SUCCESS
)
{
session_event
->
set_response
(
"SUCCESS"
);
session_event
->
set_response
(
"SUCCESS
\n
"
);
}
else
{
session_event
->
set_response
(
"FAILURE"
);
session_event
->
set_response
(
"FAILURE
\n
"
);
}
return
rc
;
}
...
...
@@ -471,12 +469,12 @@ RC ExecuteStage::do_create_index(SQLStageEvent *sql_event)
const
CreateIndex
&
create_index
=
sql_event
->
query
()
->
sstr
.
create_index
;
Table
*
table
=
db
->
find_table
(
create_index
.
relation_name
);
if
(
nullptr
==
table
)
{
session_event
->
set_response
(
"FAILURE"
);
session_event
->
set_response
(
"FAILURE
\n
"
);
return
RC
::
SCHEMA_TABLE_NOT_EXIST
;
}
RC
rc
=
table
->
create_index
(
nullptr
,
create_index
.
index_name
,
create_index
.
attribute_name
);
sql_event
->
session_event
()
->
set_response
(
rc
==
RC
::
SUCCESS
?
"SUCCESS
"
:
"FAILURE
"
);
sql_event
->
session_event
()
->
set_response
(
rc
==
RC
::
SUCCESS
?
"SUCCESS
\n
"
:
"FAILURE
\n
"
);
return
rc
;
}
...
...
@@ -529,9 +527,9 @@ RC ExecuteStage::do_insert(SQLStageEvent *sql_event)
Table
*
table
=
insert_stmt
->
table
();
RC
rc
=
table
->
insert_record
(
nullptr
,
insert_stmt
->
value_amount
(),
insert_stmt
->
values
());
if
(
rc
==
RC
::
SUCCESS
)
{
session_event
->
set_response
(
"SUCCESS"
);
session_event
->
set_response
(
"SUCCESS
\n
"
);
}
else
{
session_event
->
set_response
(
"FAILURE"
);
session_event
->
set_response
(
"FAILURE
\n
"
);
}
return
rc
;
}
...
...
@@ -555,9 +553,9 @@ RC ExecuteStage::do_delete(SQLStageEvent *sql_event)
RC
rc
=
delete_oper
.
open
();
if
(
rc
!=
RC
::
SUCCESS
)
{
session_event
->
set_response
(
"FAILURE"
);
session_event
->
set_response
(
"FAILURE
\n
"
);
}
else
{
session_event
->
set_response
(
"SUCCESS"
);
session_event
->
set_response
(
"SUCCESS
\n
"
);
}
return
rc
;
}
src/observer/sql/parser/parse_stage.cpp
浏览文件 @
1c40013d
...
...
@@ -132,7 +132,7 @@ RC ParseStage::handle_request(StageEvent *event)
RC
ret
=
parse
(
sql
.
c_str
(),
query_result
);
if
(
ret
!=
RC
::
SUCCESS
)
{
// set error information to event
sql_event
->
session_event
()
->
set_response
(
"Failed to parse sql"
);
sql_event
->
session_event
()
->
set_response
(
"Failed to parse sql
\n
"
);
query_destroy
(
query_result
);
return
RC
::
INTERNAL
;
}
...
...
src/observer/sql/stmt/select_stmt.cpp
浏览文件 @
1c40013d
...
...
@@ -78,44 +78,44 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
const
char
*
field_name
=
relation_attr
.
attribute_name
;
if
(
0
==
strcmp
(
table_name
,
"*"
))
{
if
(
0
!=
strcmp
(
field_name
,
"*"
))
{
LOG_WARN
(
"invalid field name while table is *. attr=%s"
,
field_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
for
(
Table
*
table
:
tables
)
{
wildcard_fields
(
table
,
query_fields
);
}
if
(
0
!=
strcmp
(
field_name
,
"*"
))
{
LOG_WARN
(
"invalid field name while table is *. attr=%s"
,
field_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
for
(
Table
*
table
:
tables
)
{
wildcard_fields
(
table
,
query_fields
);
}
}
else
{
auto
iter
=
table_map
.
find
(
table_name
);
if
(
iter
==
table_map
.
end
())
{
LOG_WARN
(
"no such table in from list: %s"
,
table_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
Table
*
table
=
iter
->
second
;
if
(
0
==
strcmp
(
field_name
,
"*"
))
{
wildcard_fields
(
table
,
query_fields
);
}
else
{
const
FieldMeta
*
field_meta
=
table
->
table_meta
().
field
(
field_name
);
if
(
nullptr
==
field_meta
)
{
LOG_WARN
(
"no such field. field=%s.%s.%s"
,
db
->
name
(),
table
->
name
(),
field_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
query_fields
.
push_back
(
Field
(
table
,
field_meta
));
}
auto
iter
=
table_map
.
find
(
table_name
);
if
(
iter
==
table_map
.
end
())
{
LOG_WARN
(
"no such table in from list: %s"
,
table_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
Table
*
table
=
iter
->
second
;
if
(
0
==
strcmp
(
field_name
,
"*"
))
{
wildcard_fields
(
table
,
query_fields
);
}
else
{
const
FieldMeta
*
field_meta
=
table
->
table_meta
().
field
(
field_name
);
if
(
nullptr
==
field_meta
)
{
LOG_WARN
(
"no such field. field=%s.%s.%s"
,
db
->
name
(),
table
->
name
(),
field_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
query_fields
.
push_back
(
Field
(
table
,
field_meta
));
}
}
}
else
{
if
(
tables
.
size
()
!=
1
)
{
LOG_WARN
(
"invalid. I do not know the attr's table. attr=%s"
,
relation_attr
.
attribute_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
LOG_WARN
(
"invalid. I do not know the attr's table. attr=%s"
,
relation_attr
.
attribute_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
Table
*
table
=
tables
[
0
];
const
FieldMeta
*
field_meta
=
table
->
table_meta
().
field
(
relation_attr
.
attribute_name
);
if
(
nullptr
==
field_meta
)
{
LOG_WARN
(
"no such field. field=%s.%s.%s"
,
db
->
name
(),
table
->
name
(),
relation_attr
.
attribute_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
LOG_WARN
(
"no such field. field=%s.%s.%s"
,
db
->
name
(),
table
->
name
(),
relation_attr
.
attribute_name
);
return
RC
::
SCHEMA_FIELD_MISSING
;
}
query_fields
.
push_back
(
Field
(
table
,
field_meta
));
...
...
@@ -132,7 +132,7 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
// create filter statement in `where` statement
FilterStmt
*
filter_stmt
=
nullptr
;
RC
rc
=
FilterStmt
::
create
(
db
,
default_table
,
&
table_map
,
select_sql
.
conditions
,
select_sql
.
condition_num
,
filter_stmt
);
select_sql
.
conditions
,
select_sql
.
condition_num
,
filter_stmt
);
if
(
rc
!=
RC
::
SUCCESS
)
{
LOG_WARN
(
"cannot construct filter stmt"
);
return
rc
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录