Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipping auto_increment on error tests #2464

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 104 additions & 103 deletions enginetest/queries/insert_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,109 +1279,6 @@ var InsertScripts = []ScriptTest{
},
},
},
{
Name: "auto increment does not increment on error",
SetUpScript: []string{
"create table auto1 (pk int primary key auto_increment);",
"insert into auto1 values (null);",
"create table auto2 (pk int primary key auto_increment, c int not null);",
"insert into auto2 values (null, 1);",
},
Assertions: []ScriptTestAssertion{
{
Query: "show create table auto1;",
Expected: []sql.Row{
{"auto1", "CREATE TABLE `auto1` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto1 values (1);",
ExpectedErr: sql.ErrPrimaryKeyViolation,
},
{
Query: "show create table auto1;",
Expected: []sql.Row{
{"auto1", "CREATE TABLE `auto1` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto1 values (null);",
Expected: []sql.Row{
{types.OkResult{RowsAffected: 1, InsertID: 2}},
},
},
{
Query: "show create table auto1;",
Expected: []sql.Row{
{"auto1", "CREATE TABLE `auto1` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "select * from auto1;",
Expected: []sql.Row{
{1},
{2},
},
},

{
Query: "show create table auto2;",
Expected: []sql.Row{
{"auto2", "CREATE TABLE `auto2` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" `c` int NOT NULL,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto2 values (null, null);",
ExpectedErr: sql.ErrInsertIntoNonNullableProvidedNull,
},
{
Query: "show create table auto2;",
Expected: []sql.Row{
{"auto2", "CREATE TABLE `auto2` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" `c` int NOT NULL,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto2 values (null, 2);",
Expected: []sql.Row{
{types.OkResult{RowsAffected: 1, InsertID: 2}},
},
},
{
Query: "show create table auto2;",
Expected: []sql.Row{
{"auto2", "CREATE TABLE `auto2` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" `c` int NOT NULL,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "select * from auto2;",
Expected: []sql.Row{
{1, 1},
{2, 2},
},
},
},
},
{
Name: "sql_mode=NO_AUTO_VALUE_ON_ZERO",
SetUpScript: []string{
Expand Down Expand Up @@ -2923,4 +2820,108 @@ var InsertBrokenScripts = []ScriptTest{
},
},
},
{
// https://github.com/dolthub/dolt/issues/3157
Name: "auto increment does not increment on error",
SetUpScript: []string{
"create table auto1 (pk int primary key auto_increment);",
"insert into auto1 values (null);",
"create table auto2 (pk int primary key auto_increment, c int not null);",
"insert into auto2 values (null, 1);",
},
Assertions: []ScriptTestAssertion{
{
Query: "show create table auto1;",
Expected: []sql.Row{
{"auto1", "CREATE TABLE `auto1` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto1 values (1);",
ExpectedErr: sql.ErrPrimaryKeyViolation,
},
{
Query: "show create table auto1;",
Expected: []sql.Row{
{"auto1", "CREATE TABLE `auto1` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto1 values (null);",
Expected: []sql.Row{
{types.OkResult{RowsAffected: 1, InsertID: 2}},
},
},
{
Query: "show create table auto1;",
Expected: []sql.Row{
{"auto1", "CREATE TABLE `auto1` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "select * from auto1;",
Expected: []sql.Row{
{1},
{2},
},
},

{
Query: "show create table auto2;",
Expected: []sql.Row{
{"auto2", "CREATE TABLE `auto2` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" `c` int NOT NULL,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto2 values (null, null);",
ExpectedErr: sql.ErrInsertIntoNonNullableProvidedNull,
},
{
Query: "show create table auto2;",
Expected: []sql.Row{
{"auto2", "CREATE TABLE `auto2` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" `c` int NOT NULL,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "insert into auto2 values (null, 2);",
Expected: []sql.Row{
{types.OkResult{RowsAffected: 1, InsertID: 2}},
},
},
{
Query: "show create table auto2;",
Expected: []sql.Row{
{"auto2", "CREATE TABLE `auto2` (\n" +
" `pk` int NOT NULL AUTO_INCREMENT,\n" +
" `c` int NOT NULL,\n" +
" PRIMARY KEY (`pk`)\n" +
") ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
},
},
{
Query: "select * from auto2;",
Expected: []sql.Row{
{1, 1},
{2, 2},
},
},
},
},
}