Bug #22483 | Connection lost during query using stored procedure and fetching results | ||
---|---|---|---|
Submitted: | 19 Sep 2006 16:48 | Modified: | 21 Sep 2006 16:23 |
Reporter: | roger andrews | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 5.0.24 | OS: | Windows (windows, linux) |
Assigned to: | CPU Architecture: | Any |
[19 Sep 2006 16:48]
roger andrews
[20 Sep 2006 20:01]
Sveta Smirnova
Thank you for the report. Could you please provide output of SHOW CREATE PROCEDURE read_salary \G statement?
[20 Sep 2006 20:07]
roger andrews
CREATE procedure read_salary (_id INT, OUT _deptnum INT , OUT _salary NUMERIC) BEGIN SELECT deptnum,salary FROM org1 WHERE deptnum = _id; END
[21 Sep 2006 11:07]
Sveta Smirnova
To get result to OUT params of read_salary procedure I changed its definition to: CREATE DEFINER=`root`@`localhost` PROCEDURE `read_salary`(_id INT, OUT _deptnum INT , OUT _salary NUMERIC) BEGIN SELECT deptnum into _deptnum FROM org1 WHERE deptnum = _id; SELECT salary into _salary FROM org1 WHERE deptnum = _id; END Also I created table org1 as: CREATE TABLE `org1` ( `deptnum` int(11) default NULL, `salary` decimal(10,0) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; With these data I can not repeat error using current BK sources: $./bug22483 sveta ******** test Prepare/execute the CALL statement Prepare/execute the select statement Get the result metadata 2 result columns cnt: 1000 cnt: 950 cnt: 900 cnt: 850 cnt: 800 cnt: 750 cnt: 700 cnt: 650 cnt: 600 cnt: 550 cnt: 500 cnt: 450 cnt: 400 cnt: 350 cnt: 300 cnt: 250 cnt: 200 cnt: 150 cnt: 100 cnt: 50 If you think my test is incorrect, please, provide accurate output of SHOW CREATE PROCEDURE read_salary \G, SHOW CREATE TABLE org1 \G, CALL read_salary(1, @v1, @v2); and SELECT @v1, @v2; statements issued in mysql command line client. Then reopen the bug.
[21 Sep 2006 16:23]
roger andrews
unfortunately this is not normal stored procedure syntax - and would be inefficient to use on any database(why execute two select statements to return 2 columns from the same database row). My Sql specialists all agree this synatx to be very unusual. Please fix the original bug as reported. rememeber the statement works - it just randomly crashes the database. Many other uses are reporting stored procedure issues from multiple sources - and a well formed stored procedure should work. here is the create table statement to re-try CREATE TABLE ORG1 (DEPTNUM int NOT NULL, DEPTNAME char(6) NOT NULL MANAGER int NOT NULL, DIVISION char(15) NOT NULL, HRDATE date, SALARY decimal(8,2), ROW_TIMESTAMP TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP) create unique index org1_ix ON org1(deptnum)
[21 Sep 2006 16:35]
Sveta Smirnova
Results with "original" stored procedure: $./bug22483 sveta ***** test Prepare/execute the CALL statement Prepare/execute the select statement Error!! Errno: 2014,Commands out of sync; you can't run this command now As you can see there is not crash.