Bug #11474 crash server after use stored procedure
Submitted: 21 Jun 2005 8:30 Modified: 16 Jul 2005 20:26
Reporter: Valentin Komissarov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.7 OS:Windows (win32)
Assigned to: CPU Architecture:Any

[21 Jun 2005 8:30] Valentin Komissarov
Description:
crash server after call stored procedure.

If record bee deleted from table docms - server do not crash, 
if xID_AccountTypes IS NOT NULL - then procedure run correctly, but server crash after client disconnect :(

Data in InnoDB Engine.

How to repeat:
CREATE TABLE `docms` (
  `ID` int(11) unsigned NOT NULL auto_increment,
  `MasterID` int(11) unsigned default NULL,
  `ID_Owners` tinyint(4) unsigned NOT NULL,
  `ID_DocmTypes` tinyint(4) unsigned NOT NULL,
  `ID_DocmState` tinyint(4) unsigned NOT NULL default '1',
  `IsMaster` tinyint(1) unsigned NOT NULL default '1',
  `ID_FirmsSource` mediumint(9) unsigned default NULL,
  `ID_FirmsDest` mediumint(9) unsigned default NULL,
  `ID_Departments` smallint(6) unsigned default NULL,
  `ID_DepartmentsDest` smallint(6) unsigned default NULL,
  `ID_CurrencyTypes` tinyint(4) unsigned default NULL,
  `ID_PayTypes` tinyint(4) unsigned default NULL,
  `ID_CashDepartments` smallint(6) unsigned default NULL,
  `DocmSum` double(15,3) unsigned NOT NULL default '0.000',
  `DocmSumNDS` double(15,3) unsigned NOT NULL default '0.000',
  `DocmPaySum` double(15,3) unsigned NOT NULL default '0.000',
  `DocmDiscount` double(15,3) unsigned NOT NULL default '0.000',
  `DateDocm` datetime default NULL,
  `DocmNum` varchar(12) default NULL,
  `Comments` varchar(255) default NULL,
  `ID_UserInsert` tinyint(4) unsigned NOT NULL,
  `DateInsert` datetime default NULL,
  `ID_UserUpdate` tinyint(4) unsigned NOT NULL,
  `DateUpdate` datetime default NULL,
  `ID_UserExecute` mediumint(9) unsigned default NULL,
  PRIMARY KEY  (`ID`),
  KEY `idx_ID_DocmTypes` (`ID_DocmTypes`),
  KEY `idx_ID_FirmsSource` (`ID_FirmsSource`),
  KEY `idx_ID_FirmsDest` (`ID_FirmsDest`),
  KEY `idx_ID_CurrencyTypes` (`ID_CurrencyTypes`),
  KEY `idx_ID_PayTypes` (`ID_PayTypes`),
  KEY `idx_ID_UserInsert` (`ID_UserInsert`),
  KEY `idx_ID_UserUpdate` (`ID_UserUpdate`),
  KEY `idx_ID_Owners` (`ID_Owners`),
  KEY `idx_ID_Departments` (`ID_Departments`),
  KEY `idx_ID_DepartmentsDest` (`ID_DepartmentsDest`),
  KEY `idx_ID_UserExecute` (`ID_UserExecute`),
  KEY `idx_ID_DocmState` (`ID_DocmState`),
  KEY `idx_ID_CashDepartments` (`ID_CashDepartments`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

CREATE TABLE `docmlines` (
  `ID` int(11) unsigned NOT NULL auto_increment,
  `ID_Docms` int(11) unsigned NOT NULL,
  `ID_Departments` smallint(6) unsigned NOT NULL,
  `ID_Goods` mediumint(9) unsigned NOT NULL,
  `ID_Measure` smallint(6) unsigned NOT NULL,
  `LineCount` double(15,3) unsigned NOT NULL default '0.000',
  `LinePrice` double(15,3) unsigned NOT NULL default '0.000',
  `LinePriceNDS` double(15,3) unsigned NOT NULL default '0.000',
  `LineSum` double(15,3) unsigned NOT NULL default '0.000',
  `LineSumNDS` double(15,3) unsigned NOT NULL default '0.000',
  `ID_UserInsert` tinyint(4) unsigned NOT NULL,
  `DateInsert` datetime default NULL,
  `ID_UserUpdate` tinyint(4) unsigned NOT NULL,
  `DateUpdate` datetime default NULL,
  `Checked` tinyint(1) unsigned NOT NULL default '0',
  PRIMARY KEY  (`ID`),
  KEY `idx_ID_Docms` (`ID_Docms`),
  KEY `idx_ID_Departments` (`ID_Departments`),
  KEY `idx_ID_Goods` (`ID_Goods`),
  KEY `idx_ID_Measure` (`ID_Measure`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

INSERT INTO `docms` (`ID`, `MasterID`, `ID_Owners`, `ID_DocmTypes`, `ID_DocmState`, `IsMaster`, `ID_FirmsSource`, `ID_FirmsDest`, `ID_Departments`, `ID_DepartmentsDest`, `ID_CurrencyTypes`, `ID_PayTypes`, `ID_CashDepartments`, `DocmSum`, `DocmSumNDS`, `DocmPaySum`, `DocmDiscount`, `DateDocm`, `DocmNum`, `Comments`, `ID_UserInsert`, `DateInsert`, `ID_UserUpdate`, `DateUpdate`, `ID_UserExecute`) VALUES 
(71,NULL,3,26,6,0,14,NULL,5,NULL,1,1,NULL,15759.990,18912.000,0.000,0.000,'2005-06-01 00:00:00','','',1,'2005-06-07 16:36:29',1,'2005-06-07 16:36:29',18);

COMMIT;

INSERT INTO `docmlines` (`ID`, `ID_Docms`, `ID_Departments`, `ID_Goods`, `ID_Measure`, `LineCount`, `LinePrice`, `LinePriceNDS`, `LineSum`, `LineSumNDS`, `ID_UserInsert`, `DateInsert`, `ID_UserUpdate`, `DateUpdate`, `Checked`) VALUES 
  (85,71,5,31,1,19.200,820.833,985.000,15759.990,18912.000,1,'2005-06-07 16:36:29',1,'2005-06-07 16:36:29',0),
  (86,71,5,70,2,1.000,0.000,0.000,0.000,0.000,1,'2005-06-07 16:36:29',1,'2005-06-07 16:36:29',0);

COMMIT;

CREATE PROCEDURE `gp_Del_Docms`(iID INTEGER)
    NOT DETERMINISTIC
    SQL SECURITY DEFINER
    COMMENT 'ALPHA-VERSION
#Visor:27.04.2005'
BEGIN
 START TRANSACTION;
 CALL `lp_Del_Docms`(iID);
 COMMIT;
END;

CREATE PROCEDURE `lp_Del_Docms`(iID INTEGER)
    NOT DETERMINISTIC
    SQL SECURITY DEFINER
    COMMENT 'ALPHA-VERSION
#Visor: 27.04.05; 25.05.05'
BEGIN
  DECLARE xID_AccountTypes TINYINT;

  SET @OResult=0;

/*  SELECT
        dts.ID_AccountTypes
        INTO
        xID_AccountTypes
    FROM docms d
    LEFT JOIN docmtypesstate dts use index(idx_ID_DocmTypes) ON dts.ID_Owners = d.ID_Owners
     AND dts.ID_DocmTypes = d.ID_DocmTypes
     AND dts.ID_DocmState = d.ID_DocmState
   WHERE d.ID = iID;*/

  SET xID_AccountTypes=6;

  SET @OResult = -8;
  IF (xID_AccountTypes IS NULL) THEN
    DELETE
      FROM `docmlines`
     WHERE ID_Docms = iID;

    DELETE
      FROM `docms`
     WHERE ID = iID;
     
     SET @OResult = 1;
  END IF;

END;

CALL gp_Del_Docms(71);
[21 Jun 2005 9:00] Vasily Kishkin
I tried on 5.0.8. Server was not crashed. Could you please try your test on 5.0.8 ?
[21 Jun 2005 12:00] Valentin Komissarov
I do not have MySQL 5.0.8, and do not build this version.
MySQL - 
mysql-nt.exe version 5.0.7
OS -
Win XP SP2
Win2k
Win2k AS SP2

Client - 
EMS MySQL Manager 3.2.0.1 Lite 
Delphi components

client library - into build 5.0.7
[21 Jun 2005 15:50] MySQL Verification Team
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[21 Jun 2005 15:50] MySQL Verification Team
Thank you for taking the time to report a problem.  Unfortunately
you are not using a current version of the product your reported a
problem with -- the problem might already be fixed. Please download
a new version from http://www.mysql.com/downloads/

If you are able to reproduce the bug with one of the latest versions,
please change the version on this bug report to the version you
tested and change the status back to "Open".  Again, thank you for
your continued support of MySQL.
[21 Jun 2005 18:35] Heikki Tuuri
Vasily and Sinisa,

5.0.7 is the latest released version.

Vasily, did you test on Windows?

Regards,

Heikki
[21 Jun 2005 18:49] Heikki Tuuri
Hi!

I was able to repeat the problem with a 5.0.8 built 4 hours ago. I used the default latin1 charset.

Looks like MySQL fails to release the locks that it takes on the tables in the stored procedure. InnoDB complains when I end the client connection.

Regards,

Heikki

heikki@hundin:~/mysql-5.0/sql> ./mysqld
050621 20:40:43  InnoDB: Started; log sequence number 0 1039592913
050621 20:40:43 [Warning] mysql.user table is not updated to new password format
; Disabling new password usage until mysql_fix_privilege_tables is run
050621 20:40:43 [Note] ./mysqld: ready for connections.
Version: '5.0.8-beta-log'  socket: '/home/heikki/bugsocket'  port: 3307  Source
distribution
050621 20:47:24  InnoDB: Error: MySQL is freeing a thd
InnoDB: though trx->n_mysql_tables_in_use is 2
InnoDB: and trx->mysql_n_tables_locked is 2.
TRANSACTION 0 0, not started, process no 1624, OS thread id 180235
mysql tables in use 2, locked 2
MySQL thread id 2, query id 22 localhost heikki
 len 632; hex 065c6e05e8b5400801000000010000004c52b84203000000010000000100000000
00000000000000ffffffff0000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000001000000ffffffffffffffff00
0000000000000000000000916ef73d000000000014000d446f636d0000000098ee1d0bf4f51d0b85
355d08e513000000000000e8b5400800000000000000000000000000000000000000000bc0020058
06000002000000020000000000000000000000102700000000000000000000000000000100000000
0000000000000000000000000000000a00000044617465e814874001000000000000000000000000
0000006174650008000b446174655570646174650009000f49445f55736572457865637574650004
030b0b00030000000000000000000000000000000000000000000000000000000000000000000000
000a400000000000000000000000000c00000a08c61a0b000000000000000000000000c0011d0b00
0000000000000000000000000000000000000000000a0f0000000000000000030000000000000000
000000000000000000000004501d0bbc020000a26f48087800000081f20e00000000000000000000
000000000000000000000000000000000000000000000000000000ac6f4808000000000000000000
00000000000000000000000000000000000000000000000f001d00002a03000000050800000000;
asc  \n   @         LR B

                                                 n =        Docm             5]
          @                         X                    '
                Date   @                ate    DateUpdate    ID_UserExecute
                                       @
                                                 P       oH x
                         oH                                      *          ;

...............
heikki@hundin:~/mysql-5.0/client> ./mysql test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.8-beta-log

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

mysql> CREATE TABLE `docms` (
    ->   `ID` int(11) unsigned NOT NULL auto_increment,
    ->   `MasterID` int(11) unsigned default NULL,
    ->   `ID_Owners` tinyint(4) unsigned NOT NULL,
    ->   `ID_DocmTypes` tinyint(4) unsigned NOT NULL,
    ->   `ID_DocmState` tinyint(4) unsigned NOT NULL default '1',
    ->   `IsMaster` tinyint(1) unsigned NOT NULL default '1',
    ->   `ID_FirmsSource` mediumint(9) unsigned default NULL,
    ->   `ID_FirmsDest` mediumint(9) unsigned default NULL,
    ->   `ID_Departments` smallint(6) unsigned default NULL,
    ->   `ID_DepartmentsDest` smallint(6) unsigned default NULL,
    ->   `ID_CurrencyTypes` tinyint(4) unsigned default NULL,
    ->   `ID_PayTypes` tinyint(4) unsigned default NULL,
    ->   `ID_CashDepartments` smallint(6) unsigned default NULL,
    ->   `DocmSum` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DocmSumNDS` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DocmPaySum` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DocmDiscount` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DateDocm` datetime default NULL,
    ->   `DocmNum` varchar(12) default NULL,
    ->   `Comments` varchar(255) default NULL,
    ->   `ID_UserInsert` tinyint(4) unsigned NOT NULL,
    ->   `DateInsert` datetime default NULL,
    ->   `ID_UserUpdate` tinyint(4) unsigned NOT NULL,
    ->   `DateUpdate` datetime default NULL,
    ->   `ID_UserExecute` mediumint(9) unsigned default NULL,
    ->   PRIMARY KEY  (`ID`),
    ->   KEY `idx_ID_DocmTypes` (`ID_DocmTypes`),
    ->   KEY `idx_ID_FirmsSource` (`ID_FirmsSource`),
    ->   KEY `idx_ID_FirmsDest` (`ID_FirmsDest`),
    ->   KEY `idx_ID_CurrencyTypes` (`ID_CurrencyTypes`),
    ->   KEY `idx_ID_PayTypes` (`ID_PayTypes`),
    ->   KEY `idx_ID_UserInsert` (`ID_UserInsert`),
    ->   KEY `idx_ID_UserUpdate` (`ID_UserUpdate`),
    ->   KEY `idx_ID_Owners` (`ID_Owners`),
    ->   KEY `idx_ID_Departments` (`ID_Departments`),
    ->   KEY `idx_ID_DepartmentsDest` (`ID_DepartmentsDest`),
    ->   KEY `idx_ID_UserExecute` (`ID_UserExecute`),
    ->   KEY `idx_ID_DocmState` (`ID_DocmState`),
    ->   KEY `idx_ID_CashDepartments` (`ID_CashDepartments`)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
ERROR 1115 (42000): Unknown character set: 'cp1251'
mysql> CREATE TABLE `docms` (
    ->   `ID` int(11) unsigned NOT NULL auto_increment,
    ->   `MasterID` int(11) unsigned default NULL,
    ->   `ID_Owners` tinyint(4) unsigned NOT NULL,
    ->   `ID_DocmTypes` tinyint(4) unsigned NOT NULL,
    ->   `ID_DocmState` tinyint(4) unsigned NOT NULL default '1',
    ->   `IsMaster` tinyint(1) unsigned NOT NULL default '1',
    ->   `ID_FirmsSource` mediumint(9) unsigned default NULL,
    ->   `ID_FirmsDest` mediumint(9) unsigned default NULL,
    ->   `ID_Departments` smallint(6) unsigned default NULL,
    ->   `ID_DepartmentsDest` smallint(6) unsigned default NULL,
    ->   `ID_CurrencyTypes` tinyint(4) unsigned default NULL,
    ->   `ID_PayTypes` tinyint(4) unsigned default NULL,
    ->   `ID_CashDepartments` smallint(6) unsigned default NULL,
    ->   `DocmSum` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DocmSumNDS` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DocmPaySum` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DocmDiscount` double(15,3) unsigned NOT NULL default '0.000',
    ->   `DateDocm` datetime default NULL,
    ->   `DocmNum` varchar(12) default NULL,
    ->   `Comments` varchar(255) default NULL,
    ->   `ID_UserInsert` tinyint(4) unsigned NOT NULL,
    ->   `DateInsert` datetime default NULL,
    ->   `ID_UserUpdate` tinyint(4) unsigned NOT NULL,
    ->   `DateUpdate` datetime default NULL,
    ->   `ID_UserExecute` mediumint(9) unsigned default NULL,
    ->   PRIMARY KEY  (`ID`),
    ->   KEY `idx_ID_DocmTypes` (`ID_DocmTypes`),
    ->   KEY `idx_ID_FirmsSource` (`ID_FirmsSource`),
    ->   KEY `idx_ID_FirmsDest` (`ID_FirmsDest`),
    ->   KEY `idx_ID_CurrencyTypes` (`ID_CurrencyTypes`),
    ->   KEY `idx_ID_PayTypes` (`ID_PayTypes`),
    ->   KEY `idx_ID_UserInsert` (`ID_UserInsert`),
    ->   KEY `idx_ID_UserUpdate` (`ID_UserUpdate`),
    ->   KEY `idx_ID_Owners` (`ID_Owners`),
    ->   KEY `idx_ID_Departments` (`ID_Departments`),
    ->   KEY `idx_ID_DepartmentsDest` (`ID_DepartmentsDest`),
    ->   KEY `idx_ID_UserExecute` (`ID_UserExecute`),
    ->   KEY `idx_ID_DocmState` (`ID_DocmState`),
    ->   KEY `idx_ID_CashDepartments` (`ID_CashDepartments`)
    -> ) ENGINE=InnoDB ;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE `docmlines` (
    ->   `ID` int(11) unsigned NOT NULL auto_increment,
    ->   `ID_Docms` int(11) unsigned NOT NULL,
    ->   `ID_Departments` smallint(6) unsigned NOT NULL,
    ->   `ID_Goods` mediumint(9) unsigned NOT NULL,
    ->   `ID_Measure` smallint(6) unsigned NOT NULL,
    ->   `LineCount` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LinePrice` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LinePriceNDS` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LineSum` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LineSumNDS` double(15,3) unsigned NOT NULL default '0.000',
    ->   `ID_UserInsert` tinyint(4) unsigned NOT NULL,
    ->   `DateInsert` datetime default NULL,
    ->   `ID_UserUpdate` tinyint(4) unsigned NOT NULL,
    ->   `DateUpdate` datetime default NULL,
    ->   `Checked` tinyint(1) unsigned NOT NULL default '0',
    ->   PRIMARY KEY  (`ID`),
    ->   KEY `idx_ID_Docms` (`ID_Docms`),
    ->   KEY `idx_ID_Departments` (`ID_Departments`),
    ->   KEY `idx_ID_Goods` (`ID_Goods`),
    ->   KEY `idx_ID_Measure` (`ID_Measure`)
    -> ) ENGINE=InnoDB DEFAULT ;
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 '' at
line 22
mysql> CREATE TABLE `docmlines` (
    ->   `ID` int(11) unsigned NOT NULL auto_increment,
    ->   `ID_Docms` int(11) unsigned NOT NULL,
    ->   `ID_Departments` smallint(6) unsigned NOT NULL,
    ->   `ID_Goods` mediumint(9) unsigned NOT NULL,
    ->   `ID_Measure` smallint(6) unsigned NOT NULL,
    ->   `LineCount` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LinePrice` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LinePriceNDS` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LineSum` double(15,3) unsigned NOT NULL default '0.000',
    ->   `LineSumNDS` double(15,3) unsigned NOT NULL default '0.000',
    ->   `ID_UserInsert` tinyint(4) unsigned NOT NULL,
    ->   `DateInsert` datetime default NULL,
    ->   `ID_UserUpdate` tinyint(4) unsigned NOT NULL,
    ->   `DateUpdate` datetime default NULL,
    ->   `Checked` tinyint(1) unsigned NOT NULL default '0',
    ->   PRIMARY KEY  (`ID`),
    ->   KEY `idx_ID_Docms` (`ID_Docms`),
    ->   KEY `idx_ID_Departments` (`ID_Departments`),
    ->   KEY `idx_ID_Goods` (`ID_Goods`),
    ->   KEY `idx_ID_Measure` (`ID_Measure`)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO `docms` (`ID`, `MasterID`, `ID_Owners`, `ID_DocmTypes`,
    -> `ID_DocmState`, `IsMaster`, `ID_FirmsSource`, `ID_FirmsDest`, `ID_Departm
ents`,
    -> `ID_DepartmentsDest`, `ID_CurrencyTypes`, `ID_PayTypes`, `ID_CashDepartme
nts`,
    -> `DocmSum`, `DocmSumNDS`, `DocmPaySum`, `DocmDiscount`, `DateDocm`, `DocmN
um`,
    -> `Comments`, `ID_UserInsert`, `DateInsert`, `ID_UserUpdate`, `DateUpdate`,
    -> `ID_UserExecute`) VALUES
    -> (71,NULL,3,26,6,0,14,NULL,5,NULL,1,1,NULL,15759.990,18912.000,0.000,0.000
,
    -> '2005-06-01 00:00:00','','',1,'2005-06-07 16:36:29',1,'2005-06-07 16:36:2
9',18);
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO `docmlines` (`ID`, `ID_Docms`, `ID_Departments`, `ID_Goods`,
    -> `ID_Measure`, `LineCount`, `LinePrice`, `LinePriceNDS`, `LineSum`, `LineS
umNDS`,
    -> `ID_UserInsert`, `DateInsert`, `ID_UserUpdate`, `DateUpdate`, `Checked`)
VALUES
    ->
    ->   (85,71,5,31,1,19.200,820.833,985.000,15759.990,18912.000,1,'2005-06-07
16:36:29',
    -> 1,'2005-06-07 16:36:29',0),
    ->   (86,71,5,70,2,1.000,0.000,0.000,0.000,0.000,1,'2005-06-07 16:36:29',1,
    -> '2005-06-07 16:36:29',0);
;Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql>
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter //
mysql> CREATE PROCEDURE `gp_Del_Docms`(iID INTEGER)
    ->     NOT DETERMINISTIC
    ->     SQL SECURITY DEFINER
    ->     COMMENT 'ALPHA-VERSION
    '> #Visor:27.04.2005'
    -> BEGIN
    ->  START TRANSACTION;
    ->  CALL `lp_Del_Docms`(iID);
    ->  COMMIT;
    -> END;
    -> //
ERROR 1418 (HY000): This routine has none of DETERMINISTIC, NO SQL, or READS SQL
 DATA in its declaration and binary logging is enabled (you *might* want to use
the less safe log_bin_trust_routine_creators variable)
mysql> CREATE PROCEDURE `gp_Del_Docms`(iID INTEGER)
    ->     DETERMINISTIC
    ->     SQL SECURITY DEFINER
    ->     COMMENT 'ALPHA-VERSION
    '> #Visor:27.04.2005'
    -> BEGIN
    ->  START TRANSACTION;
    ->  CALL `lp_Del_Docms`(iID);
    ->  COMMIT;
    -> END;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE PROCEDURE `lp_Del_Docms`(iID INTEGER)
    ->     DETERMINISTIC
    ->     SQL SECURITY DEFINER
    ->     COMMENT 'ALPHA-VERSION
    '> #Visor: 27.04.05; 25.05.05'
    -> BEGIN
    ->   DECLARE xID_AccountTypes TINYINT;
    ->
    ->   SET @OResult=0;
    ->
    -> /*  SELECT
   /*>         dts.ID_AccountTypes
   /*>         INTO
   /*>         xID_AccountTypes
   /*>     FROM docms d
   /*>     LEFT JOIN docmtypesstate dts use index(idx_ID_DocmTypes) ON dts.ID_Ow
ners =
   /*> d.ID_Owners
   /*>      AND dts.ID_DocmTypes = d.ID_DocmTypes
   /*>      AND dts.ID_DocmState = d.ID_DocmState
   /*>    WHERE d.ID = iID;*/
    ->
    ->   SET xID_AccountTypes=6;
    ->
    ->   SET @OResult = -8;
    ->   IF (xID_AccountTypes IS NULL) THEN
    ->     DELETE
    ->       FROM `docmlines`
    ->      WHERE ID_Docms = iID;
    ->
    ->     DELETE
    ->       FROM `docms`
    ->      WHERE ID = iID;
    ->
    ->      SET @OResult = 1;
    ->   END IF;
    ->
    -> END;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
heikki@hundin:~/mysql-5.0/client> ./mysql test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.8-beta-log

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

mysql> CALL gp_Del_Docms(71);
Query OK, 0 rows affected (0.01 sec)

mysql> drop procedure lp_Del_Docms;
Query OK, 0 rows affected (0.01 sec)

mysql> delimiter //
mysql> exit
Bye
[22 Jun 2005 12:34] MySQL Verification Team
Heikki,

Fix for this bug is in 5.0.8 Changelog.