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

bug: Stored procedures cannot be created if the value of sql_mode includes variable no_key_error. #1388

Closed
3 tasks done
haitaoguan opened this issue Mar 15, 2023 · 1 comment · Fixed by #1392
Closed
3 tasks done
Assignees
Labels
A-bug Something isn't working

Comments

@haitaoguan
Copy link
Collaborator

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

mysql> set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_KEY_ERROR';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show variables like 'sql_mode';
+---------------+-----------------------------------------------------------------------------+
| Variable_name | Value                                                                       |
+---------------+-----------------------------------------------------------------------------+
| sql_mode      | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_KEY_ERROR |
+---------------+-----------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> DELIMITER //
mysql>     create PROCEDURE add_user(in num INT)
    ->     BEGIN
    ->         DECLARE rowid INT DEFAULT 0;
    ->         DECLARE firstname CHAR(1);
    ->         DECLARE name1 CHAR(1);
    ->         DECLARE name2 CHAR(1);
    ->         DECLARE lastname VARCHAR(3) DEFAULT '';
    ->         DECLARE sex CHAR(1);
    ->         DECLARE score CHAR(2);
    ->         WHILE rowid < num DO
    ->         SET firstname = SUBSTRING('赵钱孙李周吴郑王林杨柳刘孙陈江阮侯邹高彭徐',FLOOR(1+21*RAND()),1);
    ->         SET name1 = SUBSTRING('一二三四五六七八九十甲乙丙丁静景京晶名明铭敏闵民军君俊骏天田甜兲恬益依成城诚立莉力黎励',ROUND(1+43*RAND()),1);
    ->         SET name2 = SUBSTRING('一二三四五六七八九十甲乙丙丁静景京晶名明铭敏闵民军君俊骏天田甜兲恬益依成城诚立莉力黎励',ROUND(1+43*RAND()),1);
    ->         SET sex=FLOOR(0 + (RAND() * 2));
    ->         SET score= FLOOR(40 + (RAND() *60));
    ->         SET rowid = rowid + 1;
    ->         IF ROUND(RAND())=0 THEN
    ->         SET lastname =name1;
    ->         END IF;
    ->         IF ROUND(RAND())=1 THEN
    ->         SET lastname = CONCAT(name1,name2);
    ->         END IF;
    ->         insert INTO t_test(first_name,last_name,sex,score,copy_id) VALUES (firstname,lastname,sex,score,rowid);
    ->         END WHILE;
    ->     END //
ERROR 1607 (HY000): Cannot create stored routine `add_user`. Check warnings
mysql> DELIMITER ;
mysql> show warnings;
+---------+------+---------------------------------------------------------+
| Level   | Code | Message                                                 |
+---------+------+---------------------------------------------------------+
| Warning | 1265 | Data truncated for column 'sql_mode' at row 1           |
| Error   | 1607 | Cannot create stored routine `add_user`. Check warnings |
+---------+------+---------------------------------------------------------+
2 rows in set (0.00 sec)

Expected behavior

No response

How To Reproduce

No response

Environment

./mysqld Ver 5.7.36-StoneDB-v1.0.3 for Linux on x86_64 (build-)
build information as follow:
Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
Branch name: stonedb-5.7-dev
Last commit ID: 5c7d21a
Last commit time: Date: Mon Mar 13 17:00:17 2023 +0800
Build time: Date: Tue Mar 14 08:58:54 CST 2023

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@haitaoguan haitaoguan added the A-bug Something isn't working label Mar 15, 2023
@wisehead wisehead added this to the stonedb_5.7_v1.0.3 milestone Mar 15, 2023
@konghaiya konghaiya self-assigned this Mar 15, 2023
@konghaiya
Copy link
Collaborator

konghaiya added a commit to konghaiya/stonedb that referenced this issue Mar 15, 2023
…x. Check warnings(stoneatom#1388)

NOTE: When adding new SQL_MODE types, make sure to also add them to
the scripts used for creating the MySQL system tables
in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
konghaiya added a commit to konghaiya/stonedb that referenced this issue Mar 17, 2023
…x. Check warnings(stoneatom#1388)

NOTE: When adding new SQL_MODE types, make sure to also add them to
the scripts used for creating the MySQL system tables
in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
@mergify mergify bot closed this as completed in #1392 Mar 17, 2023
mergify bot pushed a commit that referenced this issue Mar 17, 2023
…x. Check warnings(#1388)

NOTE: When adding new SQL_MODE types, make sure to also add them to
the scripts used for creating the MySQL system tables
in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
None yet
3 participants