-
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.
- Loading branch information
1 parent
32ddc42
commit 64eedaa
Showing
81 changed files
with
793 additions
and
686 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,43 @@ | ||
# Tests basic CREATE TABLE functionality. | ||
|
||
# The result contains the table name. The table is written to storage. | ||
[result,ops]> CREATE TABLE test (id INTEGER PRIMARY KEY) | ||
--- | ||
CreateTable { name: "test" } | ||
storage set mvcc:NextVersion → 2 ["\x00" → "\x02"] | ||
storage set mvcc:TxnActive(1) → "" ["\x01\x00\x00\x00\x00\x00\x00\x00\x01" → ""] | ||
storage set mvcc:TxnWrite(1, sql:Table("test")) → "" ["\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\xfftest\x00\xff\x00\xff\x00\x00" → ""] | ||
storage set mvcc:Version(sql:Table("test"), 1) → CREATE TABLE test ( id INTEGER PRIMARY KEY ) ["\x04\x00\xfftest\x00\xff\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" → "\x01\x10\x04test\x00\x01\x02id\x01\x00\x00\x01\x00\x00"] | ||
storage delete mvcc:TxnWrite(1, sql:Table("test")) ["\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\xfftest\x00\xff\x00\xff\x00\x00"] | ||
storage delete mvcc:TxnActive(1) ["\x01\x00\x00\x00\x00\x00\x00\x00\x01"] | ||
|
||
dump | ||
--- | ||
mvcc:NextVersion → 2 ["\x00" → "\x02"] | ||
mvcc:Version(sql:Table("test"), 1) → CREATE TABLE test ( id INTEGER PRIMARY KEY ) ["\x04\x00\xfftest\x00\xff\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" → "\x01\x10\x04test\x00\x01\x02id\x01\x00\x00\x01\x00\x00"] | ||
|
||
# Errors if table already exists. | ||
!> CREATE TABLE test (id INTEGER PRIMARY KEY) | ||
--- | ||
Error: invalid input: table test already exists | ||
|
||
# No table name or columns errors. | ||
!> CREATE TABLE | ||
!> CREATE TABLE name | ||
!> CREATE TABLE name () | ||
--- | ||
Error: invalid input: unexpected end of input | ||
Error: invalid input: unexpected end of input | ||
Error: invalid input: expected identifier, got ) | ||
|
||
# Missing table or column names error. | ||
!> CREATE TABLE (id INTEGER PRIMARY KEY) | ||
!> CREATE TABLE name (INTEGER PRIMARY KEY) | ||
--- | ||
Error: invalid input: expected identifier, got ( | ||
Error: invalid input: expected identifier, got INTEGER | ||
|
||
# Unterminated identifier errors. | ||
!> CREATE TABLE "name (id INTEGER PRIMARY KEY) | ||
--- | ||
Error: invalid input: unexpected end of quoted identifier |
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,38 @@ | ||
# Tests CREATE TABLE datatypes. | ||
|
||
# Create columns with all datatypes. | ||
> CREATE TABLE datatypes ( \ | ||
id INTEGER PRIMARY KEY, \ | ||
"bool" BOOL, \ | ||
"boolean" BOOLEAN, \ | ||
"double" DOUBLE, \ | ||
"float" FLOAT, \ | ||
"int" INT, \ | ||
"integer" INTEGER, \ | ||
"string" STRING, \ | ||
"text" TEXT, \ | ||
"varchar" VARCHAR \ | ||
) | ||
schema | ||
--- | ||
CREATE TABLE datatypes ( | ||
id INTEGER PRIMARY KEY, | ||
"bool" BOOLEAN DEFAULT NULL, | ||
"boolean" BOOLEAN DEFAULT NULL, | ||
"double" FLOAT DEFAULT NULL, | ||
"float" FLOAT DEFAULT NULL, | ||
"int" INTEGER DEFAULT NULL, | ||
"integer" INTEGER DEFAULT NULL, | ||
"string" STRING DEFAULT NULL, | ||
"text" STRING DEFAULT NULL, | ||
"varchar" STRING DEFAULT NULL | ||
) | ||
|
||
# Missing or unknown datatype errors. | ||
!> CREATE TABLE test (id INTEGER PRIMARY KEY, value) | ||
!> CREATE TABLE test (id INTEGER PRIMARY KEY, value FOO) | ||
!> CREATE TABLE test (id INTEGER PRIMARY KEY, value INDEX) | ||
--- | ||
Error: invalid input: unexpected token ) | ||
Error: invalid input: unexpected token foo | ||
Error: invalid input: unexpected token INDEX |
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,54 @@ | ||
# Tests column defaults. | ||
|
||
# All datatypes. | ||
> CREATE TABLE datatypes ( \ | ||
id INT PRIMARY KEY, \ | ||
"bool" BOOLEAN DEFAULT true, \ | ||
"float" FLOAT DEFAULT 3.14, \ | ||
"int" INTEGER DEFAULT 7, \ | ||
"string" STRING DEFAULT 'foo' \ | ||
) | ||
schema datatypes | ||
--- | ||
CREATE TABLE datatypes ( | ||
id INTEGER PRIMARY KEY, | ||
"bool" BOOLEAN DEFAULT TRUE, | ||
"float" FLOAT DEFAULT 3.14, | ||
"int" INTEGER DEFAULT 7, | ||
"string" STRING DEFAULT foo | ||
) | ||
|
||
# Default datatypes must match column. This includes float/integer types. | ||
!> CREATE TABLE name (id INT PRIMARY KEY, value STRING DEFAULT 7) | ||
!> CREATE TABLE name (id INT PRIMARY KEY, value INTEGER DEFAULT 3.14) | ||
!> CREATE TABLE name (id INT PRIMARY KEY, value FLOAT DEFAULT 7) | ||
--- | ||
Error: invalid input: invalid datatype INTEGER for STRING column value | ||
Error: invalid input: invalid datatype FLOAT for INTEGER column value | ||
Error: invalid input: invalid datatype INTEGER for FLOAT column value | ||
|
||
# Default values can be expressions. | ||
> CREATE TABLE expr (id INT PRIMARY KEY, value INT DEFAULT 7 + 3 * 2) | ||
schema expr | ||
--- | ||
CREATE TABLE expr ( | ||
id INTEGER PRIMARY KEY, | ||
value INTEGER DEFAULT 13 | ||
) | ||
|
||
# NULL is a value default for a nullable column (and is the implicit default). | ||
> CREATE TABLE "nullable" (id INT PRIMARY KEY, value STRING DEFAULT NULL, implicit STRING) | ||
schema nullable | ||
--- | ||
CREATE TABLE nullable ( | ||
id INTEGER PRIMARY KEY, | ||
value STRING DEFAULT NULL, | ||
implicit STRING DEFAULT NULL | ||
) | ||
|
||
# A NULL default errors for a non-nullable column, including primary keys. | ||
!> CREATE TABLE name (id INT PRIMARY KEY DEFAULT NULL) | ||
!> CREATE TABLE name (id INT PRIMARY KEY, value STRING NOT NULL DEFAULT NULL) | ||
--- | ||
Error: invalid input: invalid NULL default for non-nullable column id | ||
Error: invalid input: invalid NULL default for non-nullable column value |
Oops, something went wrong.