Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
eatonphil committed Apr 27, 2020
1 parent 3bd3797 commit 65cfcb2
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,35 @@ $ git clone [email protected]:eatonphil/gosql
$ cd gosql
$ go run cmd/main.go
Welcome to gosql.
# CREATE TABLE users (name TEXT, age INT);
# CREATE TABLE users (id INT PRIMARY KEY, name TEXT, age INT);
ok
# INSERT INTO users VALUES ('Stephen', 16);
ok
# SELECT name, age FROM users;
name | age
----------+------
Stephen | 16
(1 result)
# \d users
Table "users"
Column | Type | Nullable
---------+---------+-----------
id | integer | not null
name | text |
age | integer |
Indexes:
"users_pkey" PRIMARY KEY, rbtree ("id")

# INSERT INTO users VALUES (1, 'Corey', 34);
ok
# INSERT INTO users VALUES ('Adrienne', 23);
# INSERT INTO users VALUES (1, 'Max', 29);
Error inserting values: Duplicate key value violates unique constraint
# INSERT INTO users VALUES (2, 'Max', 29);
ok
# SELECT age + 2, name FROM users WHERE age = 23;
age | name
------+-----------
25 | Adrienne
# SELECT * FROM users WHERE id = 2;
id | name | age
-----+------+------
2 | Max | 29
(1 result)
ok
# SELECT age, name FROM users WHERE age = 23 OR age = 16;
age | name
------+-----------
16 | Stephen
23 | Adrienne
(2 results)
ok
# SELECT name FROM users;
name
------------
Stephen
Adrienne
# SELECT id, name, age + 3 FROM users WHERE id = 2 OR id = 1;
id | name | ?column?
-----+-------+-----------
1 | Corey | 37
2 | Max | 32
(2 results)
ok
```
Expand All @@ -59,18 +58,20 @@ ok

## Contributing

* Add a new operator (such as `<`, `>`, etc.) supported by PostgreSQL
* Add a new data type supported by PostgreSQL
* Add a new operator (such as `-`, `*`, etc.)
* Add a new data type (such as `VARCHAR(n)``)

In each case, you'll probably have to add support in the lexer,
parser, and in-memory backend. I recommend going in that order.

In all cases, make sure the code is formatted (`make fmt`) and passes
tests (`make test`). New code should have tests.
In all cases, make sure the code is formatted (`make fmt`), linted
(`make lint`) and passes tests (`make test`). New code should have
tests.

## Blog series

* [Writing a SQL database from scratch in Go](https://notes.eatonphil.com/database-basics.html)
* [Binary expressions and WHERE filters](https://notes.eatonphil.com/database-basics-expressions-and-where.html)

## Further reading

Expand Down

0 comments on commit 65cfcb2

Please sign in to comment.