feat: added functionality for insert and select
This commit is contained in:
@@ -33,9 +33,10 @@ func Run() {
|
|||||||
switch statement.PrepareStatements(inputBuffer) {
|
switch statement.PrepareStatements(inputBuffer) {
|
||||||
case PrepareSuccess:
|
case PrepareSuccess:
|
||||||
//todo
|
//todo
|
||||||
|
case PrepareSyntaxError:
|
||||||
|
fmt.Println("Syntax error, could not parse statement")
|
||||||
case PrepareUnrecognised:
|
case PrepareUnrecognised:
|
||||||
fmt.Printf("Unrecognised keyword at the start of '%s'.\n", inputBuffer.Buffer)
|
fmt.Printf("Unrecognised keyword at the start of '%s'.\n", inputBuffer.Buffer)
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch statement.ExecuteStatement(table) {
|
switch statement.ExecuteStatement(table) {
|
||||||
|
|||||||
+5
-5
@@ -151,11 +151,11 @@ func DoMetaCommands(inputBuffer *InputBuffer) MetaCommandResults {
|
|||||||
func (statement *Statement) PrepareStatements(inputBuffer *InputBuffer) PrepareResults {
|
func (statement *Statement) PrepareStatements(inputBuffer *InputBuffer) PrepareResults {
|
||||||
if strings.HasPrefix(inputBuffer.Buffer, "insert") {
|
if strings.HasPrefix(inputBuffer.Buffer, "insert") {
|
||||||
argsAssigned, err := fmt.Sscanf(inputBuffer.Buffer, "insert %d %s %s", &statement.row.id, &statement.row.username, &statement.row.email)
|
argsAssigned, err := fmt.Sscanf(inputBuffer.Buffer, "insert %d %s %s", &statement.row.id, &statement.row.username, &statement.row.email)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
fmt.Println("error parsing insert statement")
|
// fmt.Println("error parsing insert statement")
|
||||||
fmt.Println(err.Error())
|
// fmt.Println(err.Error())
|
||||||
}
|
// }
|
||||||
if argsAssigned > 3 {
|
if err != nil || argsAssigned > 3 {
|
||||||
return PrepareSyntaxError
|
return PrepareSyntaxError
|
||||||
}
|
}
|
||||||
statement.stype = StatementInsert
|
statement.stype = StatementInsert
|
||||||
|
|||||||
Reference in New Issue
Block a user