-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
CreateIndex
and IndexType::Normal
& `IndexType::Com…
…posite` (#154) * feat: implement `DataValue::Tuple` `>,>=,<,<=` and supports combining an arbitrary range with a vec of preceding eq ranges * feat: support `CreateIndex` and `IndexType::Normal` & `IndexType::Composite` * test: add `create_index.slt` for `CreateIndex` and add more case for `IndexType::Composite` on `where_by_index.slt` * test: add null case for `IndexType::Composite` on `where_by_index.slt` * fix: `find_statistics_meta` wrong parameters * fix: index out of bounds for `delete.rs` * fix: display for range's unbounded
- Loading branch information
Showing
64 changed files
with
1,450 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
[package] | ||
name = "fnck_sql" | ||
version = "0.0.1-alpha.11.fix3" | ||
version = "0.0.1-alpha.12" | ||
edition = "2021" | ||
authors = ["Kould <[email protected]>", "Xwg <[email protected]>"] | ||
description = "Fast Insert OLTP SQL DBMS" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::binder::{lower_case_name, Binder}; | ||
use crate::errors::DatabaseError; | ||
use crate::expression::ScalarExpression; | ||
use crate::planner::operator::create_index::CreateIndexOperator; | ||
use crate::planner::operator::scan::ScanOperator; | ||
use crate::planner::operator::Operator; | ||
use crate::planner::LogicalPlan; | ||
use crate::storage::Transaction; | ||
use crate::types::index::IndexType; | ||
use sqlparser::ast::{ObjectName, OrderByExpr}; | ||
use std::sync::Arc; | ||
|
||
impl<'a, T: Transaction> Binder<'a, T> { | ||
pub(crate) fn bind_create_index( | ||
&mut self, | ||
table_name: &ObjectName, | ||
name: &ObjectName, | ||
exprs: &[OrderByExpr], | ||
if_not_exists: bool, | ||
is_unique: bool, | ||
) -> Result<LogicalPlan, DatabaseError> { | ||
let table_name = Arc::new(lower_case_name(table_name)?); | ||
let index_name = lower_case_name(name)?; | ||
let ty = if is_unique { | ||
IndexType::Unique | ||
} else if exprs.len() == 1 { | ||
IndexType::Normal | ||
} else { | ||
IndexType::Composite | ||
}; | ||
|
||
let table = self.context.table_and_bind(table_name.clone(), None)?; | ||
let plan = ScanOperator::build(table_name.clone(), table); | ||
let mut columns = Vec::with_capacity(exprs.len()); | ||
|
||
for expr in exprs { | ||
// TODO: Expression Index | ||
match self.bind_expr(&expr.expr)? { | ||
ScalarExpression::ColumnRef(column) => columns.push(column), | ||
expr => { | ||
return Err(DatabaseError::UnsupportedStmt(format!( | ||
"create index on {}", | ||
expr | ||
))) | ||
} | ||
} | ||
} | ||
|
||
Ok(LogicalPlan::new( | ||
Operator::CreateIndex(CreateIndexOperator { | ||
table_name, | ||
columns, | ||
index_name, | ||
if_not_exists, | ||
ty, | ||
}), | ||
vec![plan], | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,8 +115,4 @@ impl ColumnDesc { | |
default, | ||
} | ||
} | ||
|
||
pub(crate) fn is_index(&self) -> bool { | ||
self.is_unique || self.is_primary | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.