createTable - initialize new table in engine with specified name
(command *ast.CreateCommand)
| 150 | |
| 151 | // createTable - initialize new table in engine with specified name |
| 152 | func (engine *DbEngine) createTable(command *ast.CreateCommand) error { |
| 153 | _, exist := engine.Tables[command.Name.Token.Literal] |
| 154 | |
| 155 | if exist { |
| 156 | return &TableAlreadyExistsError{command.Name.Token.Literal} |
| 157 | } |
| 158 | |
| 159 | engine.Tables[command.Name.Token.Literal] = &Table{Columns: []*Column{}} |
| 160 | for i, columnName := range command.ColumnNames { |
| 161 | engine.Tables[command.Name.Token.Literal].Columns = append(engine.Tables[command.Name.Token.Literal].Columns, |
| 162 | &Column{ |
| 163 | Type: command.ColumnTypes[i], |
| 164 | Values: make([]ValueInterface, 0), |
| 165 | Name: columnName, |
| 166 | }) |
| 167 | } |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (engine *DbEngine) updateTable(command *ast.UpdateCommand) error { |
| 172 | table, exist := engine.Tables[command.Name.Token.Literal] |