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
......@@ -87,7 +87,7 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
opt_complete_insert= 0, opt_drop_database= 0,
opt_dump_triggers= 0;
opt_dump_triggers= 0, opt_routines=0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*sock=0;
static my_bool insert_pat_inited=0;
......@@ -339,6 +339,9 @@ static struct my_option my_long_options[] =
{"result-file", 'r',
"Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"routines", 'R', "Dump routines FUNCTIONS and PROCEDURES.",
(gptr*) &opt_routines, (gptr*) &opt_routines, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET,
"Add 'SET NAMES default_character_set' to the output. Enabled by default; suppress with --skip-set-charset.",
(gptr*) &opt_set_charset, (gptr*) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1,
......@@ -1177,6 +1180,112 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
check_io(xml_file);
}
/*
dump_routines_for_db
-- retrievs list of routines for a given db, and prints out
the CREATE PROCEDURE definition into the output (the dump).
This function has logic to print the appropriate syntax depending on whether
this is a procedure or functions
RETURN 0 succes, 1 if error
*/
static uint dump_routines_for_db (char *db)
{
char query_buff[512], routine_type[10];
char db_name_buff[NAME_LEN+3], name_buff[NAME_LEN+3];
int i;
FILE *sql_file = md_result_file;
MYSQL_RES *routine_res= NULL;
MYSQL_RES *routine_list_res= NULL;
MYSQL_ROW row, routine_list_row;
DBUG_ENTER("dump_routines_for_db");
mysql_real_escape_string(sock, db_name_buff, db, strlen(db));
DBUG_PRINT("enter", ("db: '%s'", db_name_buff));
/* nice comments */
if (opt_comments)
fprintf(sql_file, "\n--\n-- Dumping routines for database '%s'\n--\n", db);
/*
not using "mysql_query_with_error_report" because of privileges
*/
if (opt_lock)
mysql_query(sock, "LOCK TABLES mysql.proc READ");
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
fprintf(sql_file, "DELIMITER //\n");
/* 0, retrieve and dump functions, 1, procedures */
for (i=0; i <= 1; i++)
{
my_snprintf(routine_type, sizeof(routine_type),
"%s", i == 0 ? "FUNCTION" : "PROCEDURE");
my_snprintf(query_buff, sizeof(query_buff),
"SHOW %s STATUS WHERE Db = '%s'",
routine_type, db_name_buff);
if (mysql_query_with_error_report(sock, &routine_list_res, query_buff))
DBUG_RETURN(1);
if (mysql_num_rows(routine_list_res))
{
while((routine_list_row= mysql_fetch_row(routine_list_res)))
{
DBUG_PRINT("info", ("retrieving CREATE %s for %s", routine_type, name_buff));
mysql_real_escape_string(sock, name_buff,
routine_list_row[1], strlen(routine_list_row[1]));
my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE %s %s",
routine_type, name_buff);
if (mysql_query_with_error_report(sock, &routine_res, query_buff))
DBUG_RETURN(1);
while ((row=mysql_fetch_row(routine_res)))
{
/*
the user can see routine names, but NOT the routine body of other
routines that are not the creator of!
*/
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
name_buff, row[2], strlen(row[2])));
if (strlen(row[2]))
{
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/ //\n",
row[1] /* sql_mode */);
if (opt_drop)
fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */ //\n",
routine_type, name_buff);
/*
the i==0 is temporary until we can figure out why functions
can't be in comments
*/
/* create proc/func body */;
fprintf(sql_file, "/*!50003 %s */ //\n", row[2]);
}
} /* end of routine printing */
} /* end of list of routines */
mysql_free_result(routine_res);
routine_res=NULL;
}
mysql_free_result(routine_list_res);
routine_list_res=NULL;
} /* end of for i (0 .. 1) */
/* set the delimiter back to ';' */
fprintf(sql_file, "DELIMITER ;\n");
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;\n");
/* again, no error report due to permissions */
if (opt_lock)
mysql_query(sock, "UNLOCK TABLES");
DBUG_RETURN(0);
}
/*
getTableStructure -- retrievs database structure, prints out corresponding
......@@ -1330,41 +1439,6 @@ static uint get_table_structure(char *table, char *db)
fprintf(sql_file, "%s;\n", row[1]);
check_io(sql_file);
mysql_free_result(tableRes);
if (opt_dump_triggers &&
mysql_get_server_version(sock) >= 50009)
{
my_snprintf(query_buff, sizeof(query_buff),
"SHOW TRIGGERS LIKE %s",
quote_for_like(table, name_buff));
if (mysql_query_with_error_report(sock, &tableRes, query_buff))
{
if (path)
my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
}
if (mysql_num_rows(tableRes))
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\
DELIMITER //;\n");
while ((row=mysql_fetch_row(tableRes)))
{
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/ //\n\
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s*/ //\n\n",
row[6], /* sql_mode */
quote_name(row[0], name_buff, 0), /* Trigger */
row[4], /* Timing */
row[1], /* Event */
result_table,
row[3] /* Statement */);
}
if (mysql_num_rows(tableRes))
fprintf(sql_file,
"DELIMITER ;//\n\
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;");
mysql_free_result(tableRes);
}
}
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
result_table);
......@@ -1657,6 +1731,68 @@ continue_xml:
} /* get_table_structure */
/*
dump_triggers_for_table
Dumps the triggers given a table/db name. This should be called after
the tables have been dumped in case a trigger depends on the existence
of a table
INPUT
char * tablename and db name
RETURNS
0 Failure
1 Succes
*/
static void dump_triggers_for_table (char *table, char *db)
{
MYSQL_RES *result;
MYSQL_ROW row;
char *result_table;
char name_buff[NAME_LEN+3], table_buff[NAME_LEN*2+3];
char query_buff[512];
FILE *sql_file = md_result_file;
DBUG_ENTER("dump_triggers_for_table");
DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
result_table= quote_name(table, table_buff, 1);
my_snprintf(query_buff, sizeof(query_buff),
"SHOW TRIGGERS LIKE %s",
quote_for_like(table, name_buff));
if (mysql_query_with_error_report(sock, &result, query_buff))
{
if (path)
my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR);
DBUG_VOID_RETURN;
}
if (mysql_num_rows(result))
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\
DELIMITER //;\n");
while ((row=mysql_fetch_row(result)))
{
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */ //\n\
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s */ //\n\n",
row[6], /* sql_mode */
quote_name(row[0], name_buff, 0), /* Trigger */
row[4], /* Timing */
row[1], /* Event */
result_table,
row[3] /* Statement */);
}
if (mysql_num_rows(result))
fprintf(sql_file,
"DELIMITER ;//\n\
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;");
mysql_free_result(result);
DBUG_VOID_RETURN;
}
static char *add_load_option(char *ptr,const char *object,
const char *statement)
{
......@@ -2376,8 +2512,17 @@ static int dump_all_tables_in_db(char *database)
dump_table(numrows,table);
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
order_by= 0;
if (opt_dump_triggers && ! opt_xml &&
mysql_get_server_version(sock) >= 50009)
dump_triggers_for_table(table, database);
}
}
if (opt_routines && !opt_xml &&
mysql_get_server_version(sock) >= 50009)
{
DBUG_PRINT("info", ("Dumping routines for database %s", database));
dump_routines_for_db(database);
}
if (opt_xml)
{
fputs("</database>\n", md_result_file);
......@@ -2569,6 +2714,9 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DBUG_PRINT("info",("Dumping table %s", table_name));
numrows= get_table_structure(table_name, db);
dump_table(numrows, table_name);
if (opt_dump_triggers &&
mysql_get_server_version(sock) >= 50009)
dump_triggers_for_table(table_name, db);
}
/* Dump each selected view */
......@@ -2580,6 +2728,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
get_view_structure(table_name, db);
}
}
/* obtain dump of routines (procs/functions) */
if (opt_routines && !opt_xml &&
mysql_get_server_version(sock) >= 50009)
{
DBUG_PRINT("info", ("Dumping routines for database %s", db));
dump_routines_for_db(db);
}
hash_free(&dump_tables);
my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
order_by= 0;
......
......@@ -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);
......@@ -960,6 +961,16 @@ int sp_head::execute(THD *thd)
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));
......
......@@ -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);
......
......@@ -267,6 +267,15 @@ NdbOut& operator<<(NdbOut& no, const PageHeader& ph) {
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("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