Commit e6d3d73c authored by ndbdev@dl145b.mysql.com's avatar ndbdev@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 e4c53b73 cbbf0e21
......@@ -86,7 +86,8 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
opt_delete_master_logs=0, tty_password=0,
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_complete_insert= 0, opt_drop_database= 0,
opt_dump_triggers= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*sock=0;
static my_bool insert_pat_inited=0;
......@@ -371,6 +372,9 @@ static struct my_option my_long_options[] =
(gptr*) &path, (gptr*) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"tables", OPT_TABLES, "Overrides option --databases (-B).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"triggers", '/0', "Dump triggers for each dumped table",
(gptr*) &opt_dump_triggers, (gptr*) &opt_dump_triggers, 0, GET_BOOL,
NO_ARG, 1, 0, 0, 0, 0, 0},
#ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.",
(gptr*) &current_user, (gptr*) &current_user, 0, GET_STR, REQUIRED_ARG,
......@@ -1315,6 +1319,37 @@ 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, "\nDELIMITER //;\n");
while ((row=mysql_fetch_row(tableRes)))
{
fprintf(sql_file, "CREATE TRIGGER %s %s %s ON %s\n"
"FOR EACH ROW%s//\n\n",
quote_name(row[0], name_buff, 0),
row[4],
row[1],
result_table,
row[3]);
}
if (mysql_num_rows(tableRes))
fprintf(sql_file, "DELIMITER ;//");
mysql_free_result(tableRes);
}
}
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
result_table);
......
......@@ -954,6 +954,45 @@ char_length(a) length(a) a
2 2 12
2 4 ан
drop table t1;
set names utf8;
select 'a\\' like 'a\\';
'a\\' like 'a\\'
1
select 'aa\\' like 'a%\\';
'aa\\' like 'a%\\'
1
create table t1 (a char(10), key(a)) character set utf8;
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
select * from t1 where a like "abc%";
a
abc
abcd
select * from t1 where a like concat("abc","%");
a
abc
abcd
select * from t1 where a like "ABC%";
a
abc
abcd
select * from t1 where a like "test%";
a
test
select * from t1 where a like "te_t";
a
test
select * from t1 where a like "%a%";
a
a
abc
abcd
select * from t1 where a like "%abcd%";
a
abcd
select * from t1 where a like "%abc\d%";
a
abcd
drop table t1;
CREATE TABLE t1 (
a varchar(255) NOT NULL default '',
KEY a (a)
......
......@@ -1673,3 +1673,175 @@ a b c
3 6 three
drop view v1, v2, v3;
drop table t1;
CREATE TABLE t1 (a int, b bigint default NULL);
CREATE TABLE t2 (a int);
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|
create trigger trg2 before update on t1 for each row begin
if old.a % 2 = 0 then set new.b := 12; end if;
end|
create trigger trg3 after update on t1 for each row
begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end|
create trigger trg4 before insert on t2 for each row
begin
if new.a > 10 then
set @fired:= "No";
end if;
end|
show triggers like "t1";
Trigger Event Table Statement Timing Created
trg1 INSERT t1
begin
if new.a > 10 then
set new.a := 10;
set new.a := 11;
end if;
end BEFORE 0000-00-00 00:00:00
trg2 UPDATE t1 begin
if old.a % 2 = 0 then set new.b := 12; end if;
end BEFORE 0000-00-00 00:00:00
trg3 UPDATE t1
begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end AFTER 0000-00-00 00:00:00
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
update t1 set a = 4 where a=3;
/*!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` (
`a` int(11) default NULL,
`b` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DELIMITER //;
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//
CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1`
FOR EACH ROW begin
if old.a % 2 = 0 then set new.b := 12; end if;
end//
CREATE TRIGGER `trg3` AFTER UPDATE ON `t1`
FOR EACH ROW
begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end//
DELIMITER ;//
/*!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`;
CREATE TABLE `t2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DELIMITER //;
CREATE TRIGGER `trg4` BEFORE INSERT ON `t2`
FOR EACH ROW
begin
if new.a > 10 then
set @fired:= "No";
end if;
end//
DELIMITER ;//
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` 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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!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` (
`a` int(11) default NULL,
`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 */;
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 */;
/*!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 table t1;
show tables;
Tables_in_test
t1
t2
DROP TABLE t1, t2;
......@@ -810,6 +810,27 @@ alter table t1 modify a char(2) character set utf8;
select char_length(a), length(a), a from t1 order by a;
drop table t1;
#
# Bugs#11754: SET NAMES utf8 followed by SELECT "A\\" LIKE "A\\" returns 0
#
set names utf8;
select 'a\\' like 'a\\';
select 'aa\\' like 'a%\\';
create table t1 (a char(10), key(a)) character set utf8;
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
select * from t1 where a like "abc%";
select * from t1 where a like concat("abc","%");
select * from t1 where a like "ABC%";
select * from t1 where a like "test%";
select * from t1 where a like "te_t";
select * from t1 where a like "%a%";
select * from t1 where a like "%abcd%";
select * from t1 where a like "%abc\d%";
drop table t1;
#
# Bug#9557 MyISAM utf8 table crash
#
......
......@@ -709,3 +709,48 @@ select * from v1;
drop view v1, v2, v3;
drop table t1;
#
# Test for dumping triggers
#
CREATE TABLE t1 (a int, b bigint default NULL);
CREATE TABLE t2 (a int);
delimiter |;
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|
create trigger trg2 before update on t1 for each row begin
if old.a % 2 = 0 then set new.b := 12; end if;
end|
create trigger trg3 after update on t1 for each row
begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end|
create trigger trg4 before insert on t2 for each row
begin
if new.a > 10 then
set @fired:= "No";
end if;
end|
delimiter ;|
--replace_column 6 '0000-00-00 00:00:00'
show triggers like "t1";
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
update t1 set a = 4 where a=3;
# Triggers should be dumped by default
--exec $MYSQL_DUMP --skip-comments --databases test
# Skip dumping triggers
--exec $MYSQL_DUMP --skip-comments --databases --skip-triggers test
# Dump and reload...
--exec $MYSQL_DUMP --skip-comments --databases test > var/tmp/mysqldump.sql
drop table t1;
--exec $MYSQL test < var/tmp/mysqldump.sql
# Check that tables have been reloaded
show tables;
DROP TABLE t1, t2;
......@@ -3256,6 +3256,7 @@ log space");
net_end(&thd->net); // destructor will not free it, because net.vio is 0
pthread_mutex_lock(&LOCK_thread_count);
THD_CHECK_SENTRY(thd);
close_thread_tables(thd);
delete thd;
pthread_mutex_unlock(&LOCK_thread_count);
pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done
......
......@@ -2858,8 +2858,6 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len)
/**
* Initialize table object
*/
tabPtr.p->frag_mask = RNIL;
tabPtr.p->schemaVersion = tmpTab.TableVersion;
tabPtr.p->noOfAttributes = tmpTab.NoOfAttributes;
tabPtr.p->noOfNull = 0;
......@@ -2952,7 +2950,6 @@ Backup::execDI_FCOUNTCONF(Signal* signal)
ndbrequire(findTable(ptr, tabPtr, tableId));
ndbrequire(tabPtr.p->fragments.seize(fragCount) != false);
tabPtr.p->frag_mask = calculate_frag_mask(fragCount);
for(Uint32 i = 0; i<fragCount; i++) {
jam();
FragmentPtr fragPtr;
......@@ -3769,15 +3766,6 @@ Backup::checkFile(Signal* signal, BackupFilePtr filePtr)
* Slave functionallity: Perform logging
*
****************************************************************************/
Uint32
Backup::calculate_frag_mask(Uint32 count)
{
Uint32 mask = 1;
while (mask < count) mask <<= 1;
mask -= 1;
return mask;
}
void
Backup::execBACKUP_TRIG_REQ(Signal* signal)
{
......@@ -3794,14 +3782,6 @@ Backup::execBACKUP_TRIG_REQ(Signal* signal)
jamEntry();
c_triggerPool.getPtr(trigPtr, trigger_id);
c_tablePool.getPtr(tabPtr, trigPtr.p->tab_ptr_i);
frag_id = frag_id & tabPtr.p->frag_mask;
/*
At the moment the fragment identity known by TUP is the
actual fragment id but with possibly an extra bit set.
This is due to that ACC splits the fragment. Thus fragment id 5 can
here be either 5 or 13. Thus masking with 2 ** n - 1 where number of
fragments <= 2 ** n will always provide a correct fragment id.
*/
tabPtr.p->fragments.getPtr(fragPtr, frag_id);
if (fragPtr.p->node != getOwnNodeId()) {
jam();
......
......@@ -195,7 +195,6 @@ public:
Uint32 tableId;
Uint32 schemaVersion;
Uint32 frag_mask;
Uint32 tableType;
Uint32 noOfNull;
Uint32 noOfAttributes;
......@@ -526,8 +525,6 @@ public:
ArrayPool<Node> c_nodePool;
ArrayPool<TriggerRecord> c_triggerPool;
Uint32 calculate_frag_mask(Uint32);
void checkFile(Signal*, BackupFilePtr);
void checkScan(Signal*, BackupFilePtr);
void fragmentCompleted(Signal*, BackupFilePtr);
......
......@@ -607,7 +607,7 @@ void Dbtup::executeTrigger(Signal* signal,
for everybody else.
*/
signal->theData[0] = trigPtr->triggerId;
signal->theData[1] = regOperPtr->fragId;
signal->theData[1] = regOperPtr->fragId >> 1; // send "real" frag id
EXECUTE_DIRECT(BACKUP, GSN_BACKUP_TRIG_REQ, signal, 2);
ljamEntry();
if (signal->theData[0] == 0) {
......
......@@ -647,7 +647,7 @@ bool RestoreDataIterator::readFragmentHeader(int & ret)
}
info << "_____________________________________________________" << endl
<< "Restoring data in table: " << m_currentTable->getTableName()
<< "Processing data in table: " << m_currentTable->getTableName()
<< "(" << Header.TableId << ") fragment "
<< Header.FragmentNo << endl;
......
......@@ -29,6 +29,8 @@ public:
m_print_log = false;
m_print_data = false;
m_print_meta = false;
m_logCount = 0;
m_dataCount = 0;
}
virtual bool table(const TableS &);
......
......@@ -318,7 +318,7 @@ main(int argc, char** argv)
if (ga_restore || ga_print)
{
if (ga_restore)
if(_restore_data || _print_data)
{
RestoreDataIterator dataIter(metaData, &free_data_callback);
......@@ -365,7 +365,10 @@ main(int argc, char** argv)
for (i= 0; i < g_consumers.size(); i++)
g_consumers[i]->endOfTuples();
}
if(_restore_data || _print_log)
{
RestoreLogIterator logIter(metaData);
if (!logIter.readHeader())
{
......@@ -389,6 +392,10 @@ main(int argc, char** argv)
logIter.validateFooter(); //not implemented
for (i= 0; i < g_consumers.size(); i++)
g_consumers[i]->endOfLogEntrys();
}
if(_restore_data)
{
for(i = 0; i<metaData.getNoOfTables(); i++)
{
if (checkSysTable(metaData[i]->getTableName()))
......
......@@ -1739,7 +1739,7 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
}
wildstr+= scan;
if (w_wc == (my_wc_t)escape)
if (w_wc == (my_wc_t)escape && wildstr < wildend)
{
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <= 0)
......@@ -1811,13 +1811,17 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <=0)
return 1;
wildstr+= scan;
if (w_wc == (my_wc_t)escape)
{
wildstr+= scan;
if (wildstr < wildend)
{
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <=0)
return 1;
wildstr+= scan;
}
}
while (1)
......@@ -1843,14 +1847,12 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
if (str == str_end)
return -1;
str+= scan;
result= my_wildcmp_unicode(cs, str, str_end, wildstr, wildend,
escape, w_one, w_many,
weights);
if (result <= 0)
return result;
str+= scan;
}
}
}
......
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