Bug #14620 ERROR WHILE EXECUTING QUERY
Submitted: 3 Nov 2005 22:22 Modified: 3 Dec 2005 22:45
Reporter: oscar de la cruz Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.15 OS:Windows (XP SP1)
Assigned to: Assigned Account CPU Architecture:Any

[3 Nov 2005 22:22] oscar de la cruz
Description:
I'M TRYING STORE PROCEDURE WITH EXAMPLES GIVEN IN THE MYSQL 5.0 STORE PROCEDURES (NEW FEATURES SERIES - PART 1) ARTICLE AND I'M GETTING AN ERROR LIKE THIS :

"ERROR EXECUTING QUERY "
"MYSQL ERROR NUMBER 2013"
"LOST CONNECTION TO MYSQL SERVER DURING QUERY"

I'M TRYING  Conditions and IF-THEN-ELSE CLAUSES 

OTHER ONE IS:

"ERROR EXECUTING QUERY "

CREATE PROCEDURE p12 (IN parameter1 INT)
 BEGIN
      DECLARE variable1 INT;
      SET variable1 = parameter1 + 1;
      IF variable1 = 0 THEN
         INSERT INTO t VALUES (17);
      END IF;

      IF parameter1 = 0 THEN
         UPDATE t SET s1 = s1 + 1;
      ELSE
         UPDATE  t SET s1 = s1 + 2;
      END IF;
END;

MYSQL ERROR NUMBER 2006
MYSQL SERVER HAS GONE AWAY

WHEN I SAW THIS MESSAGE I RESTARTED THE SERVICE, BUT ALWAY GOT THE SAME ERROR WHEN I TRIED TO EXECUTE THIS QUERY

How to repeat:
+--------------+
| Tables_in_db |
+--------------+
| t            |
+--------------+
1 row in set (0.02 sec)

there's  just one field in table t 
its name is s1 
its type is INT

and this the store procedure 

CREATE PROCEDURE p12 (IN parameter1 INT)
BEGIN
 DECLARE variable1 INT;
 SET variable1 = parameter1 + 1;
 IF variable1 = 0 THEN
    INSERT INTO t VALUES (17);
 END IF; 

 IF parameter1 = 0 THEN
     UPDATE t SET s1 = s1 + 1;
 ELSE 
    UPDATE t SET s1 = s1 + 2;
 END IF; 
END
[3 Nov 2005 22:45] MySQL Verification Team
I was unable to repeat this issue:

c:\mysql\bin>mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.0.15-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database db;
Query OK, 1 row affected (0.03 sec)

mysql> use db
Database changed
mysql> create table t (s1 int) engine=innodb;
Query OK, 0 rows affected (0.09 sec)

mysql> delimiter //
mysql> CREATE PROCEDURE p12 (IN parameter1 INT)
    -> BEGIN
    ->  DECLARE variable1 INT;
    ->  SET variable1 = parameter1 + 1;
    ->  IF variable1 = 0 THEN
    ->     INSERT INTO t VALUES (17);
    ->  END IF;
    ->
    ->  IF parameter1 = 0 THEN
    ->      UPDATE t SET s1 = s1 + 1;
    ->  ELSE
    ->     UPDATE t SET s1 = s1 + 2;
    ->  END IF;
    -> END//
Query OK, 0 rows affected (0.03 sec)

mysql> insert into t values (1) //
Query OK, 1 row affected (0.06 sec)

mysql> call p12(0) //
Query OK, 1 row affected (0.08 sec)

mysql> select * from t//
+------+
| s1   |
+------+
|    2 |
+------+
1 row in set (0.00 sec)

mysql> call p12(2) //
Query OK, 1 row affected (0.03 sec)

When installing 5.0.15 you did an upgrade over an older version?
[4 Dec 2005 0: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".