Bug #7636 Stored procedure kill mysqld
Submitted: 3 Jan 2005 14:36 Modified: 25 Feb 2005 14:53
Reporter: Alejandro Burne Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S2 (Serious)
Version:5.0.2-alpha-standard-log OS:Linux (Mandrake linux 10.0)
Assigned to: Bugs System CPU Architecture:Any

[3 Jan 2005 14:36] Alejandro Burne
Description:
When I run this sp, first time run fine, second time kills mysqld; then runs fine and if you run another time mysqld die.

[me@test mysql]# more test.err

Number of processes running now: 0
050103 10:56:55  mysqld restarted
050103 10:56:55 [Warning] Asked for 196608 thread stack, but got 126976
050103 10:56:55  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
050103 10:56:55  InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 44428.
InnoDB: Doing recovery: scanned up to log sequence number 0 44428
InnoDB: Last MySQL binlog file position 0 95, file name ./test-bin.000021
050103 10:56:56  InnoDB: Flushing modified pages from the buffer pool...
050103 10:56:56  InnoDB: Started; log sequence number 0 44428
/usr/sbin/mysqld: ready for connections.
Version: '5.0.2-alpha-standard-log'  socket: '/var/lib/mysql/mysql.sock'  port:
3306  Official MySQL RPM
pure virtual method called
mysqld got signal 6;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=16777216
read_buffer_size=258048
max_used_connections=1
max_connections=100
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 92783
K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x89471a8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xbfe7e0b8, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x80915f7
0x830cb58
0x8318231
0x830cee9
0x8318650
0x837d358
0x837d37d
0x837cd5b
0x804fc43
0x805e3dd
0x805e5d7
0x8057370
0x80627da
0x80c374c
0x80c8a23
0x80cc043
0x80c8803
0x80a1c5a
0x815d458
0x815d350
0x815b564
0x815bc0b
0x80a55a3
0x80a6d59
0x80a05c8
0x809ff70
0x809f66a
0x830a30c
0x8333dea
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/Using_stack_trace.html and follow
instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8966188 = SELECT COUNT(*) FROM CompensacionesOS
   WHERE CodigoObraSocial=pCodigoOS AND
   DesdeCodigoNN<=pCodigoNN AND HastaCodigoNN>=pCodigoNN AND
   FechaInicioVigencia<=CONCAT(lPer_a,'-',lPer_m,'-01') AND
   FechaFinVigencia>=CONCAT(lPer_a,'-',lPer_m,'-01')
thd->thread_id=1
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.

Number of processes running now: 0
050103 10:57:03  mysqld restarted
050103 10:57:03 [Warning] Asked for 196608 thread stack, but got 126976
050103 10:57:04  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
050103 10:57:04  InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 44460.
InnoDB: Doing recovery: scanned up to log sequence number 0 44460
InnoDB: Last MySQL binlog file position 0 95, file name ./test-bin.000022
050103 10:57:04  InnoDB: Flushing modified pages from the buffer pool...
050103 10:57:04  InnoDB: Started; log sequence number 0 44460
/usr/sbin/mysqld: ready for connections.
Version: '5.0.2-alpha-standard-log'  socket: '/var/lib/mysql/mysql.sock'  port:
3306  Official MySQL RPM

How to repeat:
/* DATA DEFINITION */
--
-- Table structure for table `CompensacionesOS`
--

DROP TABLE IF EXISTS `CompensacionesOS`;
CREATE TABLE `CompensacionesOS` (
  `CodigoObraSocial` smallint(5) unsigned NOT NULL default '0',
  `DesdeCodigoNN` varchar(6) NOT NULL default '',
  `HastaCodigoNN` varchar(6) NOT NULL default '',
  `FechaInicioVigencia` date NOT NULL default '0000-00-00',
  `FechaFinVigencia` date NOT NULL default '9999-01-01',
  `FechaHora_cga` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `UserId` varchar(20) NOT NULL default '',
  PRIMARY KEY  (`CodigoObraSocial`,`DesdeCodigoNN`,`HastaCodigoNN`,`FechaInicioVigencia`,`FechaFinVigencia`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1 CHECKSUM=1;

--
-- Dumping data for table `CompensacionesOS`
--

/*!40000 ALTER TABLE `CompensacionesOS` DISABLE KEYS */;
LOCK TABLES `CompensacionesOS` WRITE;
INSERT INTO `CompensacionesOS` VALUES (2,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(3,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(6,'000001','020601','2000-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(6,'020603','300122','2000-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(6,'310101','440101','2000-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(12,'010101','015006','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'020101','020601','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'020603','020703','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'020801','060114','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'065001','065004','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'070101','070714','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'070716','110105','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'110201','175001','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'180101','180121','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'185002','185006','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'185009','185010','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'185014','205012','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'210101','240121','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'250101','250106','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'260101','265003','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'265010','295001','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'295003','300122','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'310101','340608','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'340701','341013','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(12,'350101','440101','1992-12-31','2004-08-31','2004-09-22 11:00:27','silvia@silvia.amr.or'),(17,'000001','440101','1993-01-01','2003-07-31','2004-09-20 11:37:08','silvia@silvia.amr.or'),(18,'000001','140104','2000-11-01','9999-01-01','2003-12-02 12:43:42','adburne'),(18,'000001','440101','1993-01-01','2000-10-31','2002-05-14 11:25:00','adburne'),(18,'140106','440101','2000-11-01','9999-01-01','2003-12-02 12:43:42','adburne'),(22,'000001','170118','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(22,'190101','330112','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(22,'350101','440101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(27,'341001','341013','1996-04-01','2001-07-31','2002-05-14 11:26:00','adburne'),(27,'420101','420203','1996-04-01','2001-07-31','2002-05-14 11:26:00','adburne'),(28,'140101','410101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(28,'430101','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(32,'000001','440101','1993-01-01','1998-04-30','2002-05-14 11:27:00','adburne'),(33,'000001','000999','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(33,'140101','410101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(41,'000001','410101','2003-09-01','9999-01-01','2004-07-22 12:20:16','adburne@adburne.amr.'),(41,'000001','440101','1993-01-01','2003-08-31','2004-07-22 12:20:16','adburne@adburne.amr.'),(41,'420301','440101','2003-09-01','9999-01-01','2004-07-22 12:20:16','adburne@adburne.amr.'),(50,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'000001','000999','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'000001','300122','1998-03-01','2000-03-15','2001-11-08 13:05:00','adburne'),(54,'010101','010706','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'015001','015006','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'020101','020503','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'020603','020606','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'020701','020703','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'020801','020804','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'030101','030516','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'030601','031313','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'040101','040301','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'050101','050411','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'060101','060111','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'065001','065004','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'070101','070112','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'070201','070212','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'070301','070611','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'070701','070702','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'070704','070716','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'080101','080617','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'080701','080715','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'080801','080902','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'090101','090108','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'100101','100116','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'100201','100711','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'105001','105001','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'110101','110105','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'110201','110212','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'110214','110217','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'110301','110405','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'120204','120903','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'121001','121936','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'130101','130115','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'130201','130304','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'140101','140104','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'150101','150111','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'160101','160104','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'170101','170117','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'180101','180121','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'185001','185006','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'185008','185010','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'185016','185017','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'190101','190102','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'200101','200136','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'205001','205007','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'210101','210207','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'215001','215008','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'220101','220204','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'230101','230232','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'235001','235001','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'240101','240121','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'250101','250106','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'260101','260527','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'260529','260532','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'265001','265003','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'265010','265010','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'270101','270101','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'270103','270103','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'280101','280110','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'285001','285007','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'290101','290110','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'295005','295008','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'300101','300122','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'310101','310122','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'310101','320104','1998-03-01','2000-03-15','2001-11-08 13:05:00','adburne'),(54,'315001','315001','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'320104','320104','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'330102','330110','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'340101','340221','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'340101','350203','1998-03-01','2000-03-15','2001-11-08 13:05:00','adburne'),(54,'340301','340608','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'340701','340707','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'340801','340822','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'340901','340909','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'341001','341013','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'350101','350102','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'350201','350203','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'360101','360107','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'360101','440101','1998-03-01','2000-03-15','2001-11-08 13:05:00','adburne'),(54,'370101','370106','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'375001','375002','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(54,'420101','420203','2000-03-31','9999-01-01','2003-12-02 12:43:42','adburne'),(82,'000001','300122','2000-07-01','9999-01-01','2003-12-02 12:43:42','adburne'),(82,'310101','310101','2000-07-01','9999-01-01','2003-12-02 12:43:42','adburne'),(82,'310104','310108','2000-07-01','9999-01-01','2003-12-02 12:43:42','adburne'),(82,'310110','440101','2000-07-01','9999-01-01','2003-12-02 12:43:42','adburne'),(84,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(87,'000001','020703','2000-06-01','9999-01-01','2003-12-02 12:43:42','adburne'),(87,'020801','300122','2000-06-01','9999-01-01','2003-12-02 12:43:42','adburne'),(87,'310101','440101','2000-06-01','9999-01-01','2003-12-02 12:43:42','adburne'),(88,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(91,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(92,'000001','020703','2000-03-01','9999-01-01','2003-12-02 12:43:42','adburne'),(94,'000001','430101','2001-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(99,'000001','440101','1993-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(129,'000001','170118','2000-11-01','2003-10-31','2004-04-29 14:00:54','silvia@silvia.amr.or'),(129,'000001','440101','1993-01-01','2000-10-31','2004-04-29 14:00:54','silvia@silvia.amr.or'),(129,'170120','440101','2000-11-01','2003-10-31','2004-04-29 14:00:54','silvia@silvia.amr.or'),(222,'000001','410101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(222,'430101','440101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(223,'000001','410101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(223,'430101','440101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(225,'000001','410101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(225,'430101','440101','1994-01-01','9999-01-01','2003-12-02 12:43:42','adburne'),(245,'000001','410101','2000-12-01','9999-01-01','2003-01-17 10:05:31','adburne@132.147.161.'),(245,'430101','440101','2000-12-01','9999-01-01','2003-01-17 10:05:31','adburne@132.147.161.'),(500,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:19:00','adburne'),(500,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:19:00','adburne'),(501,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(501,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(502,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(502,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(503,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(503,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(504,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(504,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(505,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(505,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(506,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(506,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(507,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(507,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(508,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(508,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(509,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(509,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(510,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(510,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(511,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(511,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(512,'330101','330112','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(512,'420101','420203','1997-05-01','9999-01-01','2002-06-03 14:23:00','adburne'),(712,'420101','420203','2001-01-15','9999-01-01','2003-12-02 12:43:42','adburne'),(41,'420101','420203','2004-07-01','9999-01-01','2004-07-22 12:20:16','adburne@adburne.amr.'),(17,'000001','440101','2004-09-01','9999-01-01','2004-09-20 11:37:08','silvia@silvia.amr.or');
UNLOCK TABLES;
/*!40000 ALTER TABLE `CompensacionesOS` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

/* STORE PROCEDURE DEFINITION */
CREATE PROCEDURE test (IN pCodigoOS SMALLINT, IN pCodigoNN CHAR(6),
IN pCodigoProfesion TINYINT, IN pMatriculaProfesional MEDIUMINT,
IN pCodigoProfesionCliSanHosp TINYINT, IN pMatriculaProfesionalCliSanHosp MEDIUM
IN pPorcentajeHonorarios DECIMAL(6,2), IN pPorcentajeDerechos DECIMAL(6,2),
IN pCodigoFacturacion TINYINT, IN pFechaPrestacion DATE,
OUT lImporteEspecialista DECIMAL(12,2), OUT lImporteAyudante1 DECIMAL(12,2),
OUT lImporteAyudante2 DECIMAL(12,2), OUT lImporteAyudante3 DECIMAL(12,2),
OUT lImporteAnestesista DECIMAL(12,2), OUT lImporteOperatorios DECIMAL(12,2),
OUT lImporteAnestesia DECIMAL(12,2), OUT lImporteInstrumental DECIMAL(12,2),
OUT lImporteCompensacion DECIMAL(12,2))

BEGIN
 /* Declaracion de variables comunes al sp */
 DECLARE lPer_m CHAR(2) DEFAULT '00';
 DECLARE lPer_a CHAR(4) DEFAULT '0000';
 DECLARE lBandera SMALLINT DEFAULT 0;

 /* Definicion fecha prestacion */
 SELECT DATEDIFF(CURRENT_DATE(),pFechaPrestacion) INTO lBandera;
 IF lBandera>180 THEN
  BEGIN
  SELECT RIGHT(CONCAT('00',MONTH(CURRENT_DATE())),2) INTO lPer_m;
  SELECT RIGHT(CONCAT('0000',YEAR(CURRENT_DATE())),4) INTO lPer_a;
  END;
 ELSE
  BEGIN
  SELECT RIGHT(CONCAT('00',MONTH(pFechaPrestacion)),2) INTO lPer_m;
  SELECT RIGHT(CONCAT('0000',YEAR(pFechaPrestacion)),4) INTO lPer_a;
  END;
 END IF;

 SELECT COUNT(*) FROM CompensacionesOS
  WHERE CodigoObraSocial=pCodigoOS AND
  DesdeCodigoNN<=pCodigoNN AND HastaCodigoNN>=pCodigoNN AND
  FechaInicioVigencia<=CONCAT(lPer_a,'-',lPer_m,'-01') AND
  FechaFinVigencia>=CONCAT(lPer_a,'-',lPer_m,'-01');
END

/* TESTING THE SP TWICE*/
call test (34,'420101',1,10099,1,10099,100,100,0, '2004-10-01',@a,@b,@c,@d,@e,@f,@g,@h,@i);

call test (34,'420101',1,10099,1,10099,100,100,0, '2004-10-01',@a,@b,@c,@d,@e,@f,@g,@h,@i);
[3 Jan 2005 18:18] MySQL Verification Team
Thank you for the bug report I was able to repeat on latest BK source tree
on Slackware:

libexec/mysqld: ready for connections.
Version: '5.0.3-alpha-debug-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
mysqld: sql_parse.cc:4760: void mysql_parse(THD*, char*, unsigned int): Assertion `thd->change_list.is_empty()' failed.
mysqld got signal 6;
....
[25 Feb 2005 14:53] Per-Erik Martin
This was fixed by a previous bug fix.