forked from arana-db/arana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement simple sharding over runtime API (arana-db#74)
* [WIP] feat: implement simple sharding over runtime API * fix: split init sql files * refactor: rename xxcontext and xxast * fix: pr review
- Loading branch information
Showing
52 changed files
with
1,957 additions
and
479 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 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,15 @@ | ||
CREATE DATABASE IF NOT EXISTS employees; | ||
USE employees; | ||
|
||
CREATE TABLE IF NOT EXISTS `sequence` | ||
( | ||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(64) NOT NULL, | ||
`value` BIGINT NOT NULL, | ||
`step` INT NOT NULL DEFAULT 10000, | ||
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`modified_at` TIMESTAMP NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_name` (`name`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8; |
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,36 @@ | ||
CREATE DATABASE IF NOT EXISTS employees; | ||
USE employees; | ||
|
||
DELIMITER // | ||
CREATE PROCEDURE sp_create_tab() | ||
BEGIN | ||
SET @str = ' ( | ||
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`uid` BIGINT(20) UNSIGNED NOT NULL, | ||
`name` VARCHAR(255) NOT NULL, | ||
`score` DECIMAL(6,2) DEFAULT ''0'', | ||
`nickname` VARCHAR(255) DEFAULT NULL, | ||
`gender` TINYINT(4) NULL, | ||
`birth_year` SMALLINT(5) UNSIGNED DEFAULT ''0'', | ||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`modified_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `uk_uid` (`uid`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 | ||
'; | ||
|
||
SET @j = 0; | ||
WHILE @j < 32 | ||
DO | ||
SET @table = CONCAT('student_', LPAD(@j, 4, '0')); | ||
SET @ddl = CONCAT('CREATE TABLE IF NOT EXISTS ', @table, @str); | ||
PREPARE ddl FROM @ddl; | ||
EXECUTE ddl; | ||
SET @j = @j + 1; | ||
END WHILE; | ||
END | ||
// | ||
|
||
DELIMITER ; | ||
CALL sp_create_tab; | ||
DROP PROCEDURE sp_create_tab; |
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
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
Oops, something went wrong.