-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip sql: use goldenscript for DML tests
- Loading branch information
1 parent
2235180
commit 0388abc
Showing
140 changed files
with
1,706 additions
and
2,168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Tests basic DELETE. | ||
|
||
# Insert some data into a table. We'll use transactions to avoid | ||
# | ||
> CREATE TABLE name (id INT PRIMARY KEY, value STRING) | ||
> INSERT INTO name VALUES (1, 'a'), (2, 'b'), (3, 'c') | ||
--- | ||
ok | ||
|
||
# Deleting from a table works. Use a transaction to keep the fixture. | ||
> BEGIN | ||
[plan,ops]> DELETE FROM name | ||
--- | ||
Delete: name | ||
└─ Scan: name | ||
storage set mvcc:TxnWrite(3, sql:Row("name", Integer(1))) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x03\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Row("name", Integer(1)), 3) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03" → "\x00"] | ||
storage set mvcc:TxnWrite(3, sql:Row("name", Integer(2))) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x03\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Row("name", Integer(2)), 3) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03" → "\x00"] | ||
storage set mvcc:TxnWrite(3, sql:Row("name", Integer(3))) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x03\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Row("name", Integer(3)), 3) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03" → "\x00"] | ||
|
||
> SELECT * FROM name | ||
> ROLLBACK | ||
--- | ||
ok | ||
|
||
# Deleting without a table, or with a missing or multiple tables errors. | ||
!> DELETE | ||
!> DELETE FROM | ||
!> DELETE FROM missing | ||
!> DELETE FROM name, foo | ||
--- | ||
Error: invalid input: unexpected end of input | ||
Error: invalid input: unexpected end of input | ||
Error: invalid input: table missing does not exist | ||
Error: invalid input: unexpected token , | ||
|
||
# Deleting in an implicit transaction works, and deletes. | ||
[ops]> DELETE FROM name | ||
--- | ||
storage set mvcc:NextVersion → 6 ["\x00" → "\x06"] | ||
storage set mvcc:TxnActive(5) → "" ["\x01\x00\x00\x00\x00\x00\x00\x00\x05" → ""] | ||
storage set mvcc:TxnWrite(5, sql:Row("name", Integer(1))) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x05\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Row("name", Integer(1)), 5) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" → "\x00"] | ||
storage set mvcc:TxnWrite(5, sql:Row("name", Integer(2))) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x05\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Row("name", Integer(2)), 5) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" → "\x00"] | ||
storage set mvcc:TxnWrite(5, sql:Row("name", Integer(3))) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x05\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Row("name", Integer(3)), 5) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" → "\x00"] | ||
storage delete mvcc:TxnWrite(5, sql:Row("name", Integer(1))) ["\x03\x00\x00\x00\x00\x00\x00\x00\x05\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00"] | ||
storage delete mvcc:TxnWrite(5, sql:Row("name", Integer(2))) ["\x03\x00\x00\x00\x00\x00\x00\x00\x05\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00"] | ||
storage delete mvcc:TxnWrite(5, sql:Row("name", Integer(3))) ["\x03\x00\x00\x00\x00\x00\x00\x00\x05\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00"] | ||
storage delete mvcc:TxnActive(5) ["\x01\x00\x00\x00\x00\x00\x00\x00\x05"] | ||
|
||
> SELECT * FROM name | ||
--- | ||
ok | ||
|
||
dump | ||
--- | ||
mvcc:NextVersion → 6 ["\x00" → "\x06"] | ||
mvcc:Version(sql:Table("name"), 1) → CREATE TABLE name ( id INTEGER PRIMARY KEY, value STRING DEFAULT NULL ) ["\x04\x00\xffname\x00\xff\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" → "\x01\x1d\x04name\x00\x02\x02id\x01\x00\x00\x01\x00\x00\x05value\x03\x01\x01\x00\x00\x00\x00"] | ||
mvcc:Version(sql:Row("name", Integer(1)), 2) → Integer(1),String("a") ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02" → "\x01\x06\x02\x02\x02\x04\x01a"] | ||
mvcc:Version(sql:Row("name", Integer(1)), 5) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" → "\x00"] | ||
mvcc:Version(sql:Row("name", Integer(2)), 2) → Integer(2),String("b") ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02" → "\x01\x06\x02\x02\x04\x04\x01b"] | ||
mvcc:Version(sql:Row("name", Integer(2)), 5) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" → "\x00"] | ||
mvcc:Version(sql:Row("name", Integer(3)), 2) → Integer(3),String("c") ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02" → "\x01\x06\x02\x02\x06\x04\x01c"] | ||
mvcc:Version(sql:Row("name", Integer(3)), 5) → None ["\x04\x02name\x00\xff\x00\xff\x02\x80\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" → "\x00"] | ||
|
||
# Bare DELETE errors. | ||
!> DELETE | ||
!> DELETE FROM | ||
--- | ||
Error: invalid input: unexpected end of input | ||
Error: invalid input: unexpected end of input | ||
|
||
# Unknown table errors. | ||
!> DELETE FROM foo | ||
--- | ||
Error: invalid input: table foo does not exist | ||
|
||
# LIMIT and ORDER BY clauses error. | ||
!> DELETE FROM name LIMIT 2 | ||
!> DELETE FROM name ORDER BY id | ||
--- | ||
Error: invalid input: unexpected token LIMIT | ||
Error: invalid input: unexpected token ORDER |
Oops, something went wrong.