Bug #12566 Line break in stored procedure gives #42000Incorrect number of arguments
Submitted: 13 Aug 2005 7:41 Modified: 19 Sep 2005 7:34
Reporter: Niklas Lundberg Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.x OS:Windows (Windows 2003)
Assigned to: CPU Architecture:Any

[13 Aug 2005 7:41] Niklas Lundberg
Description:
When I create a stored procedure with several input parameters and put them on different lines, MySQL does not recognize the first parameter of the second line, but all others

I connect to the database with MySQL Connector/Net 1.04 and Microsoft Enterprise Library

I get the error message:
---------------------------------
System.Exception: Executing command database error ---> MySql.Data.MySqlClient.MySqlException: #42000Incorrect number of arguments for PROCEDURE mohedabio.elmah_error_log4; expected 10, got 9
   at MySql.Data.MySqlClient.PacketReader.CheckForError()
   at MySql.Data.MySqlClient.PacketReader.ReadHeader()
   at MySql.Data.MySqlClient.PacketReader.OpenPacket()
   at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
   at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
   at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume)
   at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
   at MySql.Data.MySqlClient.MySqlCommand.Consume()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DBCommandWrapper command)
   at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DBCommandWrapper command)
   at TestProject.Class1.Test() in .....

How to repeat:
This works fine:
-------------------

DELIMITER $$

DROP PROCEDURE IF EXISTS `mohedabio`.`elmah_error_log`$$
CREATE PROCEDURE `mohedabio`.`elmah_error_log`(IN ErrorID VARCHAR(37), IN Application VARCHAR(60), IN Host VARCHAR(30), IN Type VARCHAR(100), IN Source VARCHAR(60), IN Message TEXT, IN User VARCHAR(50), IN AllXml TEXT, IN StatusCode INTEGER, IN TimeUtc DATETIME)
BEGIN

INSERT
INTO
    elmah_error
    (
        `ErrorId`,
        `Application`,
        `Host`,
        `Type`,
        `Source`,
        `Message`,
        `User`,
        `AllXml`,
        `StatusCode`,
        `TimeUtc`
    )
VALUES
    (
        ErrorId,
        Application,
        Host,
        Type,
        Source,
        Message,
        User,
        AllXml,
        StatusCode,
        TimeUtc
    );
END$$

DELIMITER ;
-------------------------------
This does not work:
-------------------------------
DELIMITER $$

DROP PROCEDURE IF EXISTS `mohedabio`.`elmah_error_log`$$
CREATE PROCEDURE `mohedabio`.`elmah_error_log`(IN ErrorID VARCHAR(37), IN Application VARCHAR(60), IN Host VARCHAR(30),
IN Type VARCHAR(100), IN Source VARCHAR(60), IN Message TEXT, IN User VARCHAR(50), IN AllXml TEXT, IN StatusCode INTEGER, IN TimeUtc DATETIME)
BEGIN

INSERT
INTO
    elmah_error
    (
        `ErrorId`,
        `Application`,
        `Host`,
        `Type`,
        `Source`,
        `Message`,
        `User`,
        `AllXml`,
        `StatusCode`,
        `TimeUtc`
    )
VALUES
    (
        ErrorId,
        Application,
        Host,
        Type,
        Source,
        Message,
        User,
        AllXml,
        StatusCode,
        TimeUtc
    );
END$$

DELIMITER ;
[13 Aug 2005 18:01] Jorge del Conde
Hi!

Can you please give me the CREATE TABLE statements so that I can create the stored procedures that you used in your test case ?

Thanks!
[13 Aug 2005 20:40] Niklas Lundberg
Create table statements:

CREATE TABLE `elmah_error` (
  `ErrorId` varchar(37) NOT NULL default '',
  `Application` varchar(60) NOT NULL default '',
  `Host` varchar(30) NOT NULL default '',
  `Type` varchar(100) NOT NULL default '',
  `Source` varchar(60) NOT NULL default '',
  `Message` text NOT NULL,
  `User` varchar(50) NOT NULL default '',
  `StatusCode` int(11) NOT NULL default '0',
  `TimeUtc` datetime NOT NULL default '0000-00-00 00:00:00',
  `AllXml` text NOT NULL,
  PRIMARY KEY  (`ErrorId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
[14 Aug 2005 10:00] Niklas Lundberg
The stored procedure name is always elmah_error_log and not elmah_error_log4 , which is just a copy of the original procedure to reproduce this error, as told in the error message.
[19 Aug 2005 7:34] Vasily Kishkin
Sorry, I was not able to reproduce the bug in my test case. Could you please provide your .NET test case ?
[19 Sep 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".