-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
141 additions
and
19 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
Submodule bptree
updated
5 files
+9 −8 | bptree.go | |
+1 −1 | bptree_del.go | |
+1 −1 | bptree_put.go | |
+1 −1 | bptree_scan.go | |
+3 −3 | meta.go |
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,39 @@ | ||
package executor | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"go-dbms/services/parser/query/dml" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
func (es *ExecutorServiceT) dmlPrepareValidate(q *dml.QueryPrepare) error { | ||
_, ok := es.tables[q.Table] | ||
if !ok { | ||
return fmt.Errorf("table not found: '%s'", q.Table) | ||
} | ||
|
||
if q.Rows < 0 { | ||
return fmt.Errorf("rows must be positive integer") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (es *ExecutorServiceT) dmlPrepare(q *dml.QueryPrepare) (io.WriterTo, error) { | ||
if err := es.dmlPrepareValidate(q); err != nil { | ||
return nil, errors.Wrapf(err, "validation error") | ||
} | ||
|
||
p := newPipe(EOS) | ||
go func() { | ||
es.tables[q.Table].PrepareSpace(q.Rows) | ||
if _, err := p.Write(EOS); err != nil { | ||
panic(err) | ||
} | ||
}() | ||
|
||
return p, nil | ||
} |
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
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,70 @@ | ||
package dml | ||
|
||
import ( | ||
"strconv" | ||
"text/scanner" | ||
|
||
"go-dbms/services/parser/errors" | ||
"go-dbms/services/parser/kwords" | ||
"go-dbms/services/parser/query" | ||
) | ||
|
||
type QueryPrepare struct { | ||
query.Query | ||
DB string | ||
Table string | ||
Rows int | ||
} | ||
|
||
|
||
func (qp *QueryPrepare) Parse(s *scanner.Scanner) (err error) { | ||
defer func () { | ||
if r := recover(); r != nil { | ||
var ok bool | ||
err, ok = r.(error) | ||
if !ok { | ||
panic(r) | ||
} | ||
} | ||
}() | ||
|
||
qp.Type = query.PREPARE | ||
|
||
qp.parseTable(s) | ||
qp.parseRows(s) | ||
|
||
return nil | ||
} | ||
|
||
func (qp *QueryPrepare) parseTable(s *scanner.Scanner) { | ||
s.Scan() | ||
if s.TokenText() != "TABLE" { | ||
panic(errors.ErrSyntax) | ||
} | ||
|
||
s.Scan() | ||
qp.Table = s.TokenText() | ||
if _, isKW := kwords.KeyWords[qp.Table]; isKW { | ||
panic(errors.ErrSyntax) | ||
} | ||
} | ||
|
||
func (qp *QueryPrepare) parseRows(s *scanner.Scanner) { | ||
s.Scan() | ||
if s.TokenText() != "ROWS" { | ||
panic(errors.ErrSyntax) | ||
} | ||
|
||
s.Scan() | ||
rows, err := strconv.Atoi(s.TokenText()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
qp.Rows = rows | ||
|
||
s.Scan() | ||
if s.TokenText() != ";" { | ||
panic(errors.ErrSyntax) | ||
} | ||
} |
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