tidb
tidb copied to clipboard
runtime error: slice bounds out of range when exec prepared statement with leading newline
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Run below sql
create database if not exists test;
use test;
drop table if exists aaa;
--- test case A
prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition";
execute stmt;
use test; drop table if exists bbb;
create table bbb(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000);
-- test case B
prepare stmt2 from "\nalter table bbb last partition less than (20000)";
execute stmt2;
-- test case C
prepare stmt3 from "\nalter table bbb first partition less than (200)";
execute stmt3;
2. What did you expect to see? (Required)
Prepared statement with leading newline to create partition table should succeed.
3. What did you see instead (Required)
mysql> create database if not exists test;
Query OK, 0 rows affected, 1 warning (0.04 sec)
use test;
drop table if exists aaa;
--- test case A
prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition";
execute stmt;mysql> use test;
Database changed
drop table if exists aaa;
--- test case A
prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition";
execute stmt;mysql> drop table if exists aaa;
Query OK, 0 rows affected, 1 warning (0.04 sec)
--- test case A
prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition";
execute stmt;mysql> --- test case A
-> prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition";
execute stmt;prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 1 near "--- test case A
prepare stmt from "\ncreate table aaa(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000) maxvalue partition"" execute stmt;
mysql> execute stmt;
ERROR 1105 (HY000): runtime error: slice bounds out of range [163:162]
mysql> use test; drop table if exists bbb;
Database changed
create table bbb(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000);
-- test case B
prepare stmt2 from "\nalter table bbb last partition less than (20000)";
execute stmt2;
Query OK, 0 rows affected (0.09 sec)
mysql> create table bbb(id bigint primary key) partition by range (id) interval (100) first partition less than (100) last partition less than (10000);
Query OK, 0 rows affected (0.08 sec)
-- test case B
prepare stmt2 from "\nalter table bbb last partition less than (20000)";
execute stmt2;
mysql> -- test case B
Query OK, 0 rows affected (0.03 sec)
prepare stmt2 from "\nalter table bbb last partition less than (20000)";
execute stmt2;
mysql> prepare stmt2 from "\nalter table bbb last partition less than (20000)";
Query OK, 0 rows affected, 1 warning (0.04 sec)
execute stmt2;
mysql> execute stmt2;
ERROR 1105 (HY000): runtime error: slice bounds out of range [49:48]
mysql> -- test case C
Query OK, 0 rows affected, 2 warnings (0.04 sec)
prepare stmt3 from "\nalter table bbb first partition less than (200)";
execute stmt3;mysql> prepare stmt3 from "\nalter table bbb first partition less than (200)";
Query OK, 0 rows affected, 1 warning (0.04 sec)
execute stmt3;
mysql> execute stmt3;
ERROR 1105 (HY000): runtime error: slice bounds out of range [48:47]
4. What is your TiDB version? (Required)
Release Version: v8.2.0-alpha Edition: Community Git Commit Hash: 1469fcfd5914b165cef5a026dcc05d8e01c4882f Git Branch: heads/refs/tags/v8.2.0-alpha UTC Build Time: 2024-06-26 11:46:38 GoVersion: go1.21.10 Race Enabled: false Check Table Before Drop: false