Merging into main #1

Merged
TakshakRamteke merged 21 commits from dev into main 2026-07-25 07:59:53 +00:00
Showing only changes of commit d2a5477217 - Show all commits
+17 -1
View File
@@ -20,6 +20,7 @@ const (
const ( const (
prepareSuccess prepareResults = iota prepareSuccess prepareResults = iota
prepareUnrecognised prepareUnrecognised
prepareSyntaxError
) )
const ( const (
@@ -33,8 +34,15 @@ type inputBuffer struct {
inputLength int inputLength int
} }
type row struct {
id uint
username string
email string
}
type statement struct { type statement struct {
stype statementType stype statementType
row row
} }
func doMetaCommands(inputBuffer inputBuffer) metaCommandResults { func doMetaCommands(inputBuffer inputBuffer) metaCommandResults {
@@ -50,6 +58,14 @@ func doMetaCommands(inputBuffer inputBuffer) metaCommandResults {
func prepareStatements(inputBuffer inputBuffer, statement *statement) prepareResults { func prepareStatements(inputBuffer inputBuffer, statement *statement) prepareResults {
if strings.Split(inputBuffer.buffer, " ")[0] == "insert" { if strings.Split(inputBuffer.buffer, " ")[0] == "insert" {
argsAssigned, err := fmt.Sscanf(inputBuffer.buffer, "insert %v %s %s", &statement.row.id, &statement.row.username, &statement.row.email)
if err != nil {
fmt.Println("error parsing insert statement")
fmt.Println(err.Error())
}
if argsAssigned > 3 {
return prepareSyntaxError
}
statement.stype = statementInsert statement.stype = statementInsert
return prepareSuccess return prepareSuccess
} }
@@ -109,7 +125,7 @@ func readConsole(inputBuffer inputBuffer) inputBuffer {
func main() { func main() {
inputBuffer := createInputBuffer() inputBuffer := createInputBuffer()
statement := statement{0} statement := statement{0, row{0, "", ""}}
condition := true condition := true
for condition { for condition {
printConsole() printConsole()