Skip to content

Commit

Permalink
Disable new tests that don't work with in-memory tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktobey committed Aug 27, 2024
1 parent afcbe28 commit 088261e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
29 changes: 20 additions & 9 deletions enginetest/queries/generated_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ var GeneratedColumnTests = []ScriptTest{
{
Name: "creating unique index on stored generated column",
SetUpScript: []string{
"create table t1 (a int primary key, b int as (a * a) stored)",
"create table t1 (a int primary key, b int as (a * a) stored, c int as (0) stored)",
"insert into t1(a) values (-1), (-2)",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -289,26 +289,31 @@ var GeneratedColumnTests = []ScriptTest{
"CREATE TABLE `t1` (\n" +
" `a` int NOT NULL,\n" +
" `b` int GENERATED ALWAYS AS ((`a` * `a`)) STORED,\n" +
" `c` int GENERATED ALWAYS AS (0) STORED,\n" +
" PRIMARY KEY (`a`),\n" +
" UNIQUE KEY `i1` (`b`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
Query: "select * from t1 where b = 4 order by a",
Expected: []sql.Row{{-2, 4}},
Expected: []sql.Row{{-2, 4, 0}},
},
{
Query: "select * from t1 order by a",
Expected: []sql.Row{{-2, 4}, {-1, 1}},
Expected: []sql.Row{{-2, 4, 0}, {-1, 1, 0}},
},
{
Query: "select * from t1 order by b",
Expected: []sql.Row{{-1, 1}, {-2, 4}},
Expected: []sql.Row{{-1, 1, 0}, {-2, 4, 0}},
},
{
Query: "insert into t1(a) values (2)",
ExpectedErr: sql.ErrUniqueKeyViolation,
},
{
Query: "create unique index i2 on t1(c)",
ExpectedErr: sql.ErrUniqueKeyViolation,
},
},
},
{
Expand Down Expand Up @@ -1140,7 +1145,7 @@ var GeneratedColumnTests = []ScriptTest{
{
Name: "creating unique index on virtual generated column",
SetUpScript: []string{
"create table t1 (a int primary key, b int as (a * a) virtual)",
"create table t1 (a int primary key, b int as (a * a) virtual, c int as (0) virtual)",
"insert into t1(a) values (-1), (-2)",
},
Assertions: []ScriptTestAssertion{
Expand All @@ -1154,27 +1159,33 @@ var GeneratedColumnTests = []ScriptTest{
"CREATE TABLE `t1` (\n" +
" `a` int NOT NULL,\n" +
" `b` int GENERATED ALWAYS AS ((`a` * `a`)),\n" +
" `c` int GENERATED ALWAYS AS (0),\n" +
" PRIMARY KEY (`a`),\n" +
" KEY `i1` (`b`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
Skip: true, // https://github.com/dolthub/dolt/issues/8275
},
{
Query: "select * from t1 where b = 4 order by a",
Expected: []sql.Row{{-2, 4}},
Expected: []sql.Row{{-2, 4, 0}},
},
{
Query: "select * from t1 order by a",
Expected: []sql.Row{{-2, 4}, {-1, 1}},
Expected: []sql.Row{{-2, 4, 0}, {-1, 1, 0}},
},
{
Query: "select * from t1 order by b",
Expected: []sql.Row{{-1, 1}, {-2, 4}},
Expected: []sql.Row{{-1, 1, 0}, {-2, 4, 0}},
},
{
Query: "insert into t1(a) values (2)",
ExpectedErr: sql.ErrUniqueKeyViolation,
Skip: true,
Skip: true, // https://github.com/dolthub/go-mysql-server/issues/2643
},
{
Query: "create unique index i2 on t1(c)",
ExpectedErr: sql.ErrUniqueKeyViolation,
Skip: true, // https://github.com/dolthub/go-mysql-server/issues/2643
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions memory/table_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ func (td *TableData) errIfDuplicateEntryExist(cols []string, idxName string) err
columnMapping, err := td.columnIndexes(cols)

// We currently skip validating duplicates on unique virtual columns.
// Right now trying to validate them would just trigger a panic.
// See https://github.com/dolthub/go-mysql-server/issues/2643
for _, i := range columnMapping {
if td.schema.Schema[i].Virtual {
return nil
Expand Down
7 changes: 5 additions & 2 deletions memory/table_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ func (t *tableEditor) pkColsDiffer(row, row2 sql.Row) bool {
// Returns whether the values for the columns given match in the two rows provided
func columnsMatch(colIndexes []int, prefixLengths []uint16, row sql.Row, row2 sql.Row, schema sql.Schema) bool {
for i, idx := range colIndexes {
// Skip validating unique virtual columns.
// Right now trying to validate them would just trigger a panic.
// See https://github.com/dolthub/go-mysql-server/issues/2643
if schema[idx].Virtual {
continue
return false
}
v1 := row[idx]
v2 := row2[idx]
Expand Down Expand Up @@ -733,7 +736,7 @@ func (k *keylessTableEditAccumulator) GetByCols(value sql.Row, cols []int, prefi
}

for _, r := range k.adds {
if columnsMatch(cols, prefixLengths, r, value, nil) {
if columnsMatch(cols, prefixLengths, r, value, k.tableData.schema.Schema) {
if deleteCount == 0 {
return r, true, nil
}
Expand Down

0 comments on commit 088261e

Please sign in to comment.