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

runtime error: slice bounds out of range when exec prepared statement with leading newline #54283

Closed
fubinzh opened this issue Jun 27, 2024 · 3 comments · Fixed by #54493
Closed
Assignees
Labels
affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/tablepartition This issue is related to Table Partition of TiDB. impact/panic severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@fubinzh
Copy link

fubinzh commented Jun 27, 2024

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: 1469fcf
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

@fubinzh fubinzh added the type/bug The issue is confirmed as a bug. label Jun 27, 2024
@fubinzh fubinzh changed the title runtime error: slice bounds out of range when exec prepared statement with lead newline runtime error: slice bounds out of range when exec prepared statement with leading newline Jun 27, 2024
@fubinzh
Copy link
Author

fubinzh commented Jun 27, 2024

/component tidb

Copy link

ti-chi-bot bot commented Jun 27, 2024

@fubinzh: The label(s) component/tidb cannot be applied, because the repository doesn't have them.

In response to this:

/component tidb

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@kennytm kennytm added the component/tablepartition This issue is related to Table Partition of TiDB. label Jun 27, 2024
@fubinzh
Copy link
Author

fubinzh commented Jun 27, 2024

/severity major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/tablepartition This issue is related to Table Partition of TiDB. impact/panic severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants