Commit b1994c03 authored by tulin@dl145b.mysql.com's avatar tulin@dl145b.mysql.com

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0

into dl145b.mysql.com:/home/ndbdev/tomas/mysql-5.1
parents 8445a075 a237d201
This diff is collapsed.
......@@ -1738,61 +1738,61 @@ CREATE TABLE `t1` (
`b` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //;
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 SET SESSION SQL_MODE="" */ //
/*!50003 CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW
begin
if new.a > 10 then
set new.a := 10;
set new.a := 11;
end if;
end*/ //
end */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 SET SESSION SQL_MODE="" */ //
/*!50003 CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin
if old.a % 2 = 0 then set new.b := 12; end if;
end*/ //
end */ //
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER"*/ //
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */ //
/*!50003 CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW
begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end*/ //
end */ //
DELIMITER ;//
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER"*/ //
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */ //
/*!50003 CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW
begin
if new.a > 10 then
set @fired:= "No";
end if;
end*/ //
end */ //
DELIMITER ;//
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
......@@ -1875,3 +1875,120 @@ set @fired:= "No";
end if;
end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
DROP TABLE t1, t2;
DROP TABLE IF EXISTS `test1`;
Warnings:
Note 1051 Unknown table 'test1'
CREATE TABLE `test1` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `test2`;
Warnings:
Note 1051 Unknown table 'test2'
CREATE TABLE `test2` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TRIGGER `testref` BEFORE INSERT ON `test1` FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1; END //
INSERT INTO `test1` VALUES (1);
SELECT * FROM `test2`;
a2
1
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode
testref INSERT test1 BEGIN
INSERT INTO test2 SET a2 = NEW.a1; END BEFORE NULL
SELECT * FROM `test1`;
a1
1
SELECT * FROM `test2`;
a2
1
DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
CREATE TABLE t1 (id int);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
INSERT INTO t1 VALUES(5);
DROP FUNCTION IF EXISTS bug9056_func1;
CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b //
CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end //
DROP FUNCTION IF EXISTS bug9056_func2 //
create function bug9056_func2(f1 char binary) returns char binary
begin
set f1= concat( 'hello', f1 );
return f1;
end //
DROP PROCEDURE IF EXISTS bug9056_proc2 //
CREATE PROCEDURE bug9056_proc2(OUT a INT)
BEGIN
select sum(id) from t1 into a;
END //
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1),(2),(3),(4),(5);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP FUNCTION IF EXISTS bug9056_func1 */ //
/*!50003 CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP FUNCTION IF EXISTS bug9056_func2 */ //
/*!50003 CREATE FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
begin
set f1= concat( 'hello', f1 );
return f1;
end */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP PROCEDURE IF EXISTS bug9056_proc1 */ //
/*!50003 CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end */ //
/*!50003 SET SESSION SQL_MODE=""*/ //
/*!50003 DROP PROCEDURE IF EXISTS bug9056_proc2 */ //
/*!50003 CREATE PROCEDURE `bug9056_proc2`(OUT a INT)
BEGIN
select sum(id) from t1 into a;
END */ //
DELIMITER ;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP PROCEDURE IF EXISTS bug9056_func1;
DROP PROCEDURE IF EXISTS bug9056_func2;
DROP PROCEDURE IF EXISTS bug9056_proc1;
DROP PROCEDURE IF EXISTS bug9056_proc2;
drop table t1;
......@@ -761,3 +761,85 @@ show tables;
--replace_column 6 #
show triggers;
DROP TABLE t1, t2;
# Test of fix to BUG 12597
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test1` (
`a1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `test2`;
CREATE TABLE `test2` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DELIMITER //;
CREATE TRIGGER `testref` BEFORE INSERT ON `test1` FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1; END //
DELIMITER ;//
INSERT INTO `test1` VALUES (1);
SELECT * FROM `test2`;
# dump
--exec $MYSQL_DUMP --skip-comments --databases test > var/tmp/mysqldump.sql
#DROP TRIGGER testref;
#DROP TABLE test1;
#DROP TABLE test2;
# restore
--exec $MYSQL test < var/tmp/mysqldump.sql
SHOW TRIGGERS;
SELECT * FROM `test1`;
SELECT * FROM `test2`;
DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
CREATE TABLE t1 (id int);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
INSERT INTO t1 VALUES(5);
--disable_warnings
DROP FUNCTION IF EXISTS bug9056_func1;
DELIMITER //;
--enable_warnings
CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b //
CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end //
--disable_warnings
DROP FUNCTION IF EXISTS bug9056_func2 //
--enable_warnings
create function bug9056_func2(f1 char binary) returns char binary
begin
set f1= concat( 'hello', f1 );
return f1;
end //
--disable_warnings
DROP PROCEDURE IF EXISTS bug9056_proc2 //
--enable_warnings
CREATE PROCEDURE bug9056_proc2(OUT a INT)
BEGIN
select sum(id) from t1 into a;
END //
DELIMITER ;//
# Dump the DB and ROUTINES
--exec $MYSQL_DUMP --skip-comments --routines --databases test
# ok, now blow it all away
--disable_warnings
DROP PROCEDURE IF EXISTS bug9056_func1;
DROP PROCEDURE IF EXISTS bug9056_func2;
DROP PROCEDURE IF EXISTS bug9056_proc1;
DROP PROCEDURE IF EXISTS bug9056_proc2;
drop table t1;
--enable-warnings
......@@ -1169,6 +1169,8 @@ void Item_func_between::print(String *str)
{
str->append('(');
args[0]->print(str);
if (negated)
str->append(" not", 4);
str->append(" between ", 9);
args[1]->print(str);
str->append(" and ", 5);
......@@ -2411,6 +2413,8 @@ void Item_func_in::print(String *str)
{
str->append('(');
args[0]->print(str);
if (negated)
str->append(" not", 4);
str->append(" in (", 5);
print_args(str, 1);
str->append("))", 2);
......
......@@ -942,11 +942,12 @@ int sp_head::execute(THD *thd)
*/
thd->stmt_arena= i;
/* will binlog this separately */
if (thd->prelocked_mode == NON_PRELOCKED) //TODO: change to event union?
{
/*
Will write this SP statement into binlog separately
(TODO: consider changing the condition to "not inside event union")
*/
if (thd->prelocked_mode == NON_PRELOCKED)
thd->user_var_events_alloc= thd->mem_root;
}
ret= i->execute(thd, &ip);
......@@ -959,10 +960,20 @@ int sp_head::execute(THD *thd)
if (i->free_list)
cleanup_items(i->free_list);
i->state= Query_arena::EXECUTED;
/*
If we've set thd->user_var_events_alloc to mem_root of this SP
statement, clean all the events allocated in it.
*/
if (thd->prelocked_mode == NON_PRELOCKED)
{
reset_dynamic(&thd->user_var_events);
thd->user_var_events_alloc= NULL;//DEBUG
}
/* we should cleanup free_list and memroot, used by instruction */
thd->free_items();
free_root(&execute_mem_root, MYF(0));
free_root(&execute_mem_root, MYF(0));
/*
Check if an exception has occurred and a handler has been found
......
......@@ -89,6 +89,17 @@
#define ZCURR_PAGE_INDEX 8
#define ZLAST_LOG_PREP_REF 10
#define ZPOS_DIRTY 11
/* A number of debug items written in the page header of all log files */
#define ZPOS_LOG_TIMER 12
#define ZPOS_PAGE_I 13
#define ZPOS_PLACE_WRITTEN_FROM 14
#define ZPOS_PAGE_NO 15
#define ZPOS_PAGE_FILE_NO 16
#define ZPOS_WORD_WRITTEN 17
#define ZPOS_IN_WRITING 18
#define ZPOS_PREV_PAGE_NO 19
#define ZPOS_IN_FREE_LIST 20
/* ------------------------------------------------------------------------- */
/* CONSTANTS FOR THE VARIOUS REPLICA AND NODE TYPES. */
/* ------------------------------------------------------------------------- */
......@@ -2281,7 +2292,7 @@ private:
const LogPartRecordPtr &sltLogPartPtr);
void checkGcpCompleted(Signal* signal, Uint32 pageWritten, Uint32 wordWritten);
void initFsopenconf(Signal* signal);
void initFsrwconf(Signal* signal);
void initFsrwconf(Signal* signal, bool write);
void initLfo(Signal* signal);
void initLogfile(Signal* signal, Uint32 fileNo);
void initLogpage(Signal* signal);
......@@ -2297,7 +2308,8 @@ private:
void writeFileDescriptor(Signal* signal);
void writeFileHeaderOpen(Signal* signal, Uint32 type);
void writeInitMbyte(Signal* signal);
void writeSinglePage(Signal* signal, Uint32 pageNo, Uint32 wordWritten);
void writeSinglePage(Signal* signal, Uint32 pageNo,
Uint32 wordWritten, Uint32 place);
void buildLinkedLogPageList(Signal* signal);
void changeMbyte(Signal* signal);
Uint32 checkIfExecLog(Signal* signal);
......@@ -2306,7 +2318,7 @@ private:
void checkScanTcCompleted(Signal* signal);
void checkSrCompleted(Signal* signal);
void closeFile(Signal* signal, LogFileRecordPtr logFilePtr);
void completedLogPage(Signal* signal, Uint32 clpType);
void completedLogPage(Signal* signal, Uint32 clpType, Uint32 place);
void deleteFragrec(Uint32 fragId);
void deleteTransidHash(Signal* signal);
void findLogfile(Signal* signal,
......@@ -2404,7 +2416,9 @@ private:
void writeAbortLog(Signal* signal);
void writeCommitLog(Signal* signal, LogPartRecordPtr regLogPartPtr);
void writeCompletedGciLog(Signal* signal);
void writeDirty(Signal* signal);
void writeDbgInfoPageHeader(LogPageRecordPtr logPagePtr, Uint32 place,
Uint32 pageNo, Uint32 wordWritten);
void writeDirty(Signal* signal, Uint32 place);
void writeKey(Signal* signal);
void writeLogHeader(Signal* signal);
void writeLogWord(Signal* signal, Uint32 data);
......
......@@ -266,7 +266,16 @@ NdbOut& operator<<(NdbOut& no, const PageHeader& ph) {
printOut("Current page index:", ph.m_current_page_index);
printOut("Oldest prepare op. file No.:", ph.m_old_prepare_file_number);
printOut("Oldest prepare op. page ref.:", ph.m_old_prepare_page_reference);
printOut("Dirty flag:", ph.m_dirty_flag);
printOut("Dirty flag:", ph.m_dirty_flag);
printOut("Write Timer:", ph.m_log_timer);
printOut("Page i-val:", ph.m_page_i_value);
printOut("Place written:", ph.m_place_written_from);
printOut("Page No in File:", ph.m_page_no);
printOut("File No:", ph.m_file_no);
printOut("Word Written:", ph.m_word_written);
printOut("In Writing (should be 1)", ph.m_in_writing_flag);
printOut("Prev Page No (can be garbage)", ph.m_prev_page_no);
printOut("In Free List (should be 0):", ph.m_in_free_list);
no << endl;
return no;
}
......
......@@ -147,6 +147,17 @@ protected:
Uint32 m_old_prepare_file_number;
Uint32 m_old_prepare_page_reference;
Uint32 m_dirty_flag;
/* Debug info Start */
Uint32 m_log_timer;
Uint32 m_page_i_value;
Uint32 m_place_written_from;
Uint32 m_page_no;
Uint32 m_file_no;
Uint32 m_word_written;
Uint32 m_in_writing_flag;
Uint32 m_prev_page_no;
Uint32 m_in_free_list;
/* Debug info End */
};
//----------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment