"Go SQL DB" is a relational database that supports SQL queries for research purposes. The main goal is to show the basic principles and key design of a relational database to database enthusiasts. Therefore, to easily understand, a lot of tricks but not very rigorous design was adopted, and the amount of code was controlled at about 2000 lines (including 400 lines of unit tests).
Features
Pure Golang implementation, does not rely on any third-party packages. Goconvey was only introduced in unit tests
Close to POD (Plain Old Data) speed serialization & deserialization
SQL Parser
Tokenizer is implemented based on text/scanner
Support simple SELECT, INSERT syntax
SELECT supports WHERE of numeric type
Support LIMIT, but not support ORDER BY temporarily
If you want to know how the SQL Parser that can be used in the production environment is implemented, please refer to the SQL Parser that I stripped from CockroachDB and supports the SQL-2011 standard
No DDL is implemented for the time being, only a fixed Schema
struct Row {
Id uint32
Sex byte
Age uint8
Username [32]byte
Email [128]byte
Phone [64]byte
}
For limited support for SQL syntax, see Test Cases
Tokenizer is based on a clever implementation of the Golang language itself, there will be problems with the support of special characters in some strings, which can be solved by quoting strings with "