Merging into main #1
@@ -16,6 +16,7 @@ func Run() {
|
||||
|
||||
inputBuffer := NewInputBuffer()
|
||||
statement := NewStatement()
|
||||
table := NewTable()
|
||||
for {
|
||||
PrintConsole()
|
||||
inputBuffer.ReadConsole()
|
||||
@@ -37,7 +38,7 @@ func Run() {
|
||||
continue
|
||||
}
|
||||
|
||||
statement.ExecuteStatement()
|
||||
statement.ExecuteStatement(table)
|
||||
fmt.Println("Executed")
|
||||
|
||||
}
|
||||
|
||||
+19
-1
@@ -41,10 +41,28 @@ type Statement struct {
|
||||
row row
|
||||
}
|
||||
|
||||
const (
|
||||
_pageSize = 4096
|
||||
maxPages = 100
|
||||
)
|
||||
|
||||
type Table struct {
|
||||
numOfRows uint
|
||||
pages [maxPages]any
|
||||
}
|
||||
|
||||
func NewStatement() *Statement {
|
||||
return &Statement{0, row{0, "", ""}}
|
||||
}
|
||||
|
||||
func NewTable() *Table {
|
||||
newTable := Table{numOfRows: 0}
|
||||
for i := range maxPages {
|
||||
newTable.pages[i] = nil
|
||||
}
|
||||
return &newTable
|
||||
}
|
||||
|
||||
func DoMetaCommands(inputBuffer *InputBuffer) MetaCommandResults {
|
||||
metacommand := MetaCommandUnrecognised
|
||||
if inputBuffer.Buffer == ".exit" {
|
||||
@@ -76,7 +94,7 @@ func (statement *Statement) PrepareStatements(inputBuffer *InputBuffer) PrepareR
|
||||
return PrepareUnrecognised
|
||||
}
|
||||
|
||||
func (statement *Statement) ExecuteStatement() {
|
||||
func (statement *Statement) ExecuteStatement(table *Table) {
|
||||
switch statement.stype {
|
||||
case StatementInsert:
|
||||
fmt.Println("This is where the logic of insert statement should go")
|
||||
|
||||
Reference in New Issue
Block a user