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

lightning: fix incorrect _tidb_rowid allocator value after import for table with AUTO_ID_CACHE=1 #46171

Merged
merged 11 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test
  • Loading branch information
D3Hunter committed Aug 16, 2023
commit f0089155810dc02fdeccb5a48eb883a58c4af7d4
1 change: 1 addition & 0 deletions br/tests/lightning_csv/data/auto_incr_id-schema-create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE `auto_incr_id`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE `no_auto_incr_id`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `clustered` (
`id` int(11) NOT NULL,
v int,
PRIMARY KEY(`id`) CLUSTERED
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
4 changes: 4 additions & 0 deletions br/tests/lightning_csv/data/no_auto_incr_id.clustered.0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
4,1
5,2
6,3

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `clustered_cache1` (
`id` int(11) NOT NULL,
v int,
PRIMARY KEY(`id`) CLUSTERED
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_ID_CACHE 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
4,1
5,2
6,3

4 changes: 4 additions & 0 deletions br/tests/lightning_csv/data/no_auto_incr_id.no_pk-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE `no_pk` (
`id` int(11) NOT NULL,
v int
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
4 changes: 4 additions & 0 deletions br/tests/lightning_csv/data/no_auto_incr_id.no_pk.0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
4,1
5,2
6,3

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `nonclustered` (
`id` int(11) NOT NULL,
v int,
PRIMARY KEY(`id`) NONCLUSTERED
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
4,1
5,2
6,3

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `nonclustered_cache1` (
`id` int(11) NOT NULL,
v int,
PRIMARY KEY(`id`) NONCLUSTERED
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_ID_CACHE 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
4,1
5,2
6,3

17 changes: 14 additions & 3 deletions br/tests/lightning_csv/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function run_with() {
fi

run_sql 'DROP DATABASE IF EXISTS csv'
run_sql 'DROP DATABASE IF EXISTS auto_incr_id'
run_sql 'DROP DATABASE IF EXISTS no_auto_incr_id'

run_lightning --backend $backend --config $config_file

Expand Down Expand Up @@ -45,11 +47,20 @@ function run_with() {
check_not_contains 'id:'

for table in clustered nonclustered clustered_cache1 nonclustered_cache1; do
run_sql "select count(*) from csv.$table"
run_sql "select count(*) from auto_incr_id.$table"
check_contains 'count(*): 3'
# insert should work
run_sql "insert into csv.$table(v) values(1)"
run_sql "select count(*) from csv.$table"
run_sql "insert into auto_incr_id.$table(v) values(1)"
run_sql "select count(*) from auto_incr_id.$table"
check_contains 'count(*): 4'
done

for table in clustered nonclustered clustered_cache1 nonclustered_cache1 no_pk; do
run_sql "select count(*) from no_auto_incr_id.$table"
check_contains 'count(*): 3'
# insert should work
run_sql "insert into no_auto_incr_id.$table values(1, 1)"
run_sql "select count(*) from no_auto_incr_id.$table"
check_contains 'count(*): 4'
done
}
Expand Down