Bug #17124 | error in function definition causes parser to get confused | ||
---|---|---|---|
Submitted: | 4 Feb 2006 21:11 | Modified: | 8 May 2009 19:30 |
Reporter: | Matt Borack | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | 5.0.19-BK, 5.0.18-nt | OS: | Linux (Linux, Windows XP Pro) |
Assigned to: | CPU Architecture: | Any |
[4 Feb 2006 21:11]
Matt Borack
[5 Feb 2006 12:04]
Valeriy Kravchuk
Thank you for a bug report. Verified just as described with 5.0.19-BK on Linux: openxs@suse:~/dbs/5.0> cat /tmp/c.txt use test; delimiter // drop function if exists test; create function test(p_id bigint) returns varchar(10) begin declare return_value varchar(10); set return_value = 'a'; return return_value; end;// delimiter ; openxs@suse:~/dbs/5.0> bin/mysql -uroot test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 5.0.19 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> source /tmp/c.txt Database changed Query OK, 0 rows affected, 1 warning (0.02 sec) Query OK, 0 rows affected (0.02 sec) At that moment I had changed the source in a separate session. mysql> source /tmp/c.txt Database changed Query OK, 0 rows affected (0.00 sec) ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'a' ; return return_value; end' at line 5 mysql> select version(); +-----------+ | version() | +-----------+ | 5.0.19 | +-----------+ 1 row in set (0.00 sec) At that moment I had changed the source back to correct one in a separate session. mysql> source /tmp/c.txt Database changed ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; create function test(p_id bigint) returns varchar(10) begin declare return_v' at line 1 mysql> exit Bye openxs@suse:~/dbs/5.0> bin/mysql -uroot test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 to server version: 5.0.19 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> source /tmp/c.txt Database changed Query OK, 0 rows affected, 1 warning (0.00 sec) Query OK, 0 rows affected (0.01 sec) mysql> So, this should be explained.
[12 Apr 2006 13:37]
Valeriy Kravchuk
Changed category to a more appropriate one.
[8 May 2009 19:15]
Jim Winstead
This doesn't appear to be a problem with the mysql client or its source command, the server's SQL parser appears to be getting stuck in an invalid state when there is an error in a function definition. mysql> delimiter // mysql> drop function if exists test; -> create function test(p_id bigint) -> returns varchar(10) -> begin -> return "hi"; -> end;// Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) mysql> drop function if exists test; -> create function test(p_id bigint) -> returns varchar(10) -> begin -> "hi"; -> end;// Query OK, 0 rows affected (0.00 sec) ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"hi"; end' at line 4 mysql> drop function if exists test; -> create function test(p_id bigint) -> returns varchar(10) -> begin -> return "hi"; -> end;// ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; create function test(p_id bigint) returns varchar(10) begin return "hi' at line 1 mysql> select version()// +---------------+ | version() | +---------------+ | 5.1.26-rc-log | +---------------+ 1 row in set (0.34 sec)
[8 May 2009 19:30]
Jim Winstead
I can no longer reproduce this problem with MySQL 5.1.34. This was probably another manifestation of Bug #26030, which was fixed in 5.0.68 and 5.1.28.