Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
miniob
提交
55b614bb
M
miniob
项目概览
oceanbase
/
miniob
1 年多 前同步成功
通知
74
Star
1521
Fork
537
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
M
miniob
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
提交
55b614bb
编写于
7月 09, 2022
作者:
羽飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
b938f168
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
16 addition
and
150 deletion
+16
-150
src/observer/sql/expr/tuple.h
src/observer/sql/expr/tuple.h
+0
-1
src/observer/sql/expr/tuple_cell.cpp
src/observer/sql/expr/tuple_cell.cpp
+1
-1
src/observer/sql/operator/join_operator.h
src/observer/sql/operator/join_operator.h
+1
-3
src/observer/sql/parser/#parse_stage.h#
src/observer/sql/parser/#parse_stage.h#
+0
-42
src/observer/sql/stmt/update_stmt.cpp
src/observer/sql/stmt/update_stmt.cpp
+1
-40
src/observer/storage/common/table.cpp
src/observer/storage/common/table.cpp
+13
-21
src/observer/storage/row/row.h
src/observer/storage/row/row.h
+0
-42
未找到文件。
src/observer/sql/expr/tuple.h
浏览文件 @
55b614bb
...
...
@@ -55,7 +55,6 @@ public:
}
private:
// TODO table and field cannot describe all scenerio, should be expression
const
char
*
alias_
=
nullptr
;
Expression
*
expression_
=
nullptr
;
};
...
...
src/observer/sql/expr/tuple_cell.cpp
浏览文件 @
55b614bb
src/observer/sql/operator/join_operator.h
浏览文件 @
55b614bb
...
...
@@ -18,8 +18,7 @@ See the Mulan PSL v2 for more details. */
#include "sql/operator/operator.h"
#include "rc.h"
class
JoinPredicate
;
// TODO fixme
class
JoinOperator
:
public
Operator
{
public:
...
...
@@ -35,6 +34,5 @@ public:
private:
Operator
*
left_
=
nullptr
;
Operator
*
right_
=
nullptr
;
JoinPredicate
*
predicate_
=
nullptr
;
bool
round_done_
=
true
;
};
src/observer/sql/parser/#parse_stage.h#
已删除
100644 → 0
浏览文件 @
b938f168
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
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 PSL v2 for more details. */
//
// Created by Longda on 2021/4/13.
//
#ifndef __OBSERVER_SQL_PARSE_STAGE_H__
#define __OBSERVER_SQL_PARSE_STAGE_H__
#include "common/seda/stage.h"
class ParseStage : public common::Stage {
public:
~ParseStage();
static Stage *make_stage(const std::string &tag);
protected:
// common function
ParseStage(const char *tag);
bool set_properties();
bool initialize();
void cleanup();
void handle_event(common::StageEvent *event);
void callback_event(common::StageEvent *event, common::CallbackContext *context);
protected:
common::StageEvent *handle_request(common::StageEvent *event);
private:
Stage *resolve_stage_ = nullptr;
};
#endif //__OBSERVER_SQL_PARSE_STAGE_H__
src/observer/sql/stmt/update_stmt.cpp
浏览文件 @
55b614bb
...
...
@@ -21,45 +21,6 @@ UpdateStmt::UpdateStmt(Table *table, Value *values, int value_amount)
RC
UpdateStmt
::
create
(
Db
*
db
,
const
Updates
&
update
,
Stmt
*&
stmt
)
{
// TODO
#if 0
const char *table_name = update.relation_name;
if (nullptr == db || nullptr == table_name || update.value_num <= 0) {
LOG_WARN("invalid argument. db=%p, table_name=%p, value_num=%d",
db, table_name, inserts.value_num);
return RC::INVALID_ARGUMENT;
}
// check whether the table exists
Table *table = db->find_table(table_name);
if (nullptr == table) {
LOG_WARN("no such table. db=%s, table_name=%s", db->name(), table_name);
return RC::SCHEMA_TABLE_NOT_EXIST;
}
// check the fields number
const Value *values = inserts.values;
const int value_num = inserts.value_num;
const TableMeta &table_meta = table->table_meta();
const int field_num = table_meta.field_num() - table_meta.sys_field_num();
if (field_num != value_num) {
LOG_WARN("schema mismatch. value num=%d, field num in schema=%d", value_num, field_num);
return RC::SCHEMA_FIELD_MISSING;
}
// check fields type
for (int i = table_meta.sys_field_num(); i < table_meta.field_num(); i++) {
const FieldMeta *field_meta = table_meta.field(i);
const AttrType field_type = field_meta->type();
const AttrType value_type = values[i].type;
if (field_type != value_type) { // TODO try to convert the value type to field type
LOG_WARN("field type mismatch. table=%s, field=%s, field type=%d, value_type=%d",
table_name, field_meta->name(), field_type, value_type);
return RC::SCHEMA_FIELD_TYPE_MISMATCH;
}
}
// everything alright
stmt = new InsertStmt(table, values, value_num);
#endif
stmt
=
nullptr
;
return
RC
::
INTERNAL
;
}
src/observer/storage/common/table.cpp
浏览文件 @
55b614bb
...
...
@@ -392,8 +392,9 @@ static RC scan_record_reader_adapter(Record *record, void *context)
return
RC
::
SUCCESS
;
}
RC
Table
::
scan_record
(
Trx
*
trx
,
ConditionFilter
*
filter
,
int
limit
,
void
*
context
,
void
(
*
record_reader
)(
const
char
*
data
,
void
*
context
))
RC
Table
::
scan_record
(
Trx
*
trx
,
ConditionFilter
*
filter
,
int
limit
,
void
*
context
,
void
(
*
record_reader
)(
const
char
*
data
,
void
*
context
))
{
RecordReaderScanAdapter
adapter
(
record_reader
,
context
);
return
scan_record
(
trx
,
filter
,
limit
,
(
void
*
)
&
adapter
,
scan_record_reader_adapter
);
...
...
@@ -448,7 +449,8 @@ RC Table::scan_record(Trx *trx, ConditionFilter *filter, int limit, void *contex
return
rc
;
}
RC
Table
::
scan_record_by_index
(
Trx
*
trx
,
IndexScanner
*
scanner
,
ConditionFilter
*
filter
,
int
limit
,
void
*
context
,
RC
Table
::
scan_record_by_index
(
Trx
*
trx
,
IndexScanner
*
scanner
,
ConditionFilter
*
filter
,
int
limit
,
void
*
context
,
RC
(
*
record_reader
)(
Record
*
,
void
*
))
{
RC
rc
=
RC
::
SUCCESS
;
...
...
@@ -515,9 +517,7 @@ RC Table::create_index(Trx *trx, const char *index_name, const char *attribute_n
}
if
(
table_meta_
.
index
(
index_name
)
!=
nullptr
||
table_meta_
.
find_index_by_field
((
attribute_name
)))
{
LOG_INFO
(
"Invalid input arguments, table name is %s, index %s exist or attribute %s exist index"
,
name
(),
index_name
,
attribute_name
);
name
(),
index_name
,
attribute_name
);
return
RC
::
SCHEMA_INDEX_EXIST
;
}
...
...
@@ -530,7 +530,8 @@ RC Table::create_index(Trx *trx, const char *index_name, const char *attribute_n
IndexMeta
new_index_meta
;
RC
rc
=
new_index_meta
.
init
(
index_name
,
*
field_meta
);
if
(
rc
!=
RC
::
SUCCESS
)
{
LOG_INFO
(
"Failed to init IndexMeta in table:%s, index_name:%s, field_name:%s"
,
name
(),
index_name
,
attribute_name
);
LOG_INFO
(
"Failed to init IndexMeta in table:%s, index_name:%s, field_name:%s"
,
name
(),
index_name
,
attribute_name
);
return
rc
;
}
...
...
@@ -654,10 +655,7 @@ RC Table::delete_record(Trx *trx, Record *record)
rc
=
delete_entry_of_indexes
(
record
->
data
(),
record
->
rid
(),
false
);
// 重复代码 refer to commit_delete
if
(
rc
!=
RC
::
SUCCESS
)
{
LOG_ERROR
(
"Failed to delete indexes of record (rid=%d.%d). rc=%d:%s"
,
record
->
rid
().
page_num
,
record
->
rid
().
slot_num
,
rc
,
strrc
(
rc
));
record
->
rid
().
page_num
,
record
->
rid
().
slot_num
,
rc
,
strrc
(
rc
));
}
else
{
rc
=
record_handler_
->
delete_record
(
&
record
->
rid
());
}
...
...
@@ -676,10 +674,7 @@ RC Table::commit_delete(Trx *trx, const RID &rid)
rc
=
delete_entry_of_indexes
(
record
.
data
(),
record
.
rid
(),
false
);
if
(
rc
!=
RC
::
SUCCESS
)
{
LOG_ERROR
(
"Failed to delete indexes of record(rid=%d.%d). rc=%d:%s"
,
rid
.
page_num
,
rid
.
slot_num
,
rc
,
strrc
(
rc
));
// panic?
rid
.
page_num
,
rid
.
slot_num
,
rc
,
strrc
(
rc
));
// panic?
}
rc
=
record_handler_
->
delete_record
(
&
rid
);
...
...
@@ -854,10 +849,7 @@ RC Table::sync()
rc
=
index
->
sync
();
if
(
rc
!=
RC
::
SUCCESS
)
{
LOG_ERROR
(
"Failed to flush index's pages. table=%s, index=%s, rc=%d:%s"
,
name
(),
index
->
index_meta
().
name
(),
rc
,
strrc
(
rc
));
name
(),
index
->
index_meta
().
name
(),
rc
,
strrc
(
rc
));
return
rc
;
}
}
...
...
src/observer/storage/row/row.h
已删除
100644 → 0
浏览文件 @
b938f168
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
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 PSL v2 for more details. */
//
// Created by Wangyunlai on 2022/5/3.
//
#ifndef __OBSERVER_STORAGE_ROW_ROW_H_
#define __OBSERVER_STORAGE_ROW_ROW_H_
#include <stddef.h>
#include <vector>
#include "rc.h"
#include "storage/common/index_meta.h"
#include "storage/common/field_meta.h"
#include "storage/common/record_manager.h"
class
Row
{
public:
Row
()
=
default
;
~
Row
()
=
default
;
RC
init
(
const
FieldMeta
*
fields_
,
int
num
);
RC
set_projector
();
private:
std
::
vector
<
FieldMeta
*>
fields_
;
std
::
vector
<
int
>
projector_
;
char
*
data_
;
};
#endif // __OBSERVER_STORAGE_ROW_ROW_H_
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录