This repository has been archived by the owner on Dec 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use prev row id for auto random and add a test
- Loading branch information
Showing
10 changed files
with
60 additions
and
9 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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
Empty file.
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 @@ | ||
CREATE DATABASE `auto_random` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; |
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,5 @@ | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
CREATE TABLE `t` ( | ||
`id` bigint unsigned primary key auto_random, | ||
`s` varchar(32) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; |
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,5 @@ | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
INSERT INTO `t` (`s`) VALUES | ||
(""), | ||
(""), | ||
(""); |
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,45 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2020 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
|
||
# FIXME: auto-random is only stable on master currently. | ||
check_cluster_version 4 0 0 AUTO_RANDOM || exit 0 | ||
|
||
for backend in tidb importer local; do | ||
if [ "$backend" = 'local' ]; then | ||
check_cluster_version 4 0 0 'local backend' || continue | ||
fi | ||
|
||
run_sql 'DROP DATABASE IF EXISTS auto_random;' | ||
run_lightning --backend $backend | ||
|
||
run_sql "SELECT count(*) from auto_random.t" | ||
check_contains "count(*): 3" | ||
|
||
run_sql "SELECT id & b'000001111111111111111111111111111111111111111111111111111111111' as inc FROM auto_random.t" | ||
check_contains 'inc: 1' | ||
check_contains 'inc: 2' | ||
check_contains 'inc: 3' | ||
|
||
# auto random base is 4 | ||
run_sql "INSERT INTO auto_random.t VALUES ();" | ||
run_sql "SELECT id & b'000001111111111111111111111111111111111111111111111111111111111' as inc FROM alter_random.t" | ||
if [ "$backend" = 'tidb' ]; then | ||
check_contains 'inc: 2000001' | ||
else | ||
check_contains 'inc: 4' | ||
fi | ||
done |