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

into moonbone.local:/work/tmp_merge-5.0-opt-mysql
This commit is contained in:
evgen@moonbone.local 2006-06-21 02:21:11 +04:00
commit d924f70cc7
54 changed files with 1340 additions and 772 deletions

File diff suppressed because it is too large Load Diff

View File

@ -735,6 +735,9 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define DBL_MAX 1.79769313486231470e+308
#define FLT_MAX ((float)3.40282346638528860e+38)
#endif
#ifndef SSIZE_MAX
#define SSIZE_MAX ((~((size_t) 0)) / 2)
#endif
#if !defined(HAVE_ISINF) && !defined(isinf)
#define isinf(X) 0

View File

@ -2570,14 +2570,14 @@ do not allow the discard. We also reserve the data dictionary latch. */
}
}
funct_exit:
trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx);
if (graph) {
que_graph_free(graph);
}
trx_commit_for_mysql(trx);
trx->op_info = "";
return((int) err);
@ -2707,10 +2707,10 @@ row_import_tablespace_for_mysql(
}
funct_exit:
row_mysql_unlock_data_dictionary(trx);
trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx);
trx->op_info = "";
return((int) err);
@ -3398,6 +3398,8 @@ fputs(" InnoDB: You are trying to drop table ", stderr);
}
funct_exit:
trx_commit_for_mysql(trx);
if (locked_dictionary) {
row_mysql_unlock_data_dictionary(trx);
}
@ -3408,8 +3410,6 @@ funct_exit:
que_graph_free(graph);
trx_commit_for_mysql(trx);
trx->op_info = "";
#ifndef UNIV_HOTBACKUP
@ -3488,10 +3488,10 @@ loop:
}
}
row_mysql_unlock_data_dictionary(trx);
trx_commit_for_mysql(trx);
row_mysql_unlock_data_dictionary(trx);
trx->op_info = "";
return(err);
@ -3905,6 +3905,8 @@ row_rename_table_for_mysql(
}
}
funct_exit:
trx_commit_for_mysql(trx);
if (!recovering_temp_table) {
row_mysql_unlock_data_dictionary(trx);
}
@ -3917,8 +3919,6 @@ funct_exit:
mem_heap_free(heap);
}
trx_commit_for_mysql(trx);
trx->op_info = "";
return((int) err);

View File

@ -1064,11 +1064,12 @@ row_sel_try_search_shortcut(
ut_ad(plan->pcur.latch_mode == node->latch_mode);
plan->n_rows_fetched++;
ret = SEL_FOUND;
func_exit:
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
return(SEL_FOUND);
return(ret);
}
/*************************************************************************

View File

@ -890,19 +890,28 @@ sub mtr_kill_processes ($) {
sub mtr_kill_process ($$$$) {
my $pid= shift;
my $signal= shift;
my $retries= shift;
my $total_retries= shift;
my $timeout= shift;
while (1)
for (my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt)
{
mtr_debug("Sending $signal to $pid...");
kill($signal, $pid);
last unless kill (0, $pid) and $retries--;
unless (kill (0, $pid))
{
mtr_debug("Process $pid died.");
return;
}
mtr_debug("Sleep $timeout second waiting for processes to die");
mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
sleep($timeout);
}
mtr_debug("Process $pid is still alive after $total_retries " .
"of sending signal $signal.");
}
##############################################################################

View File

@ -2860,22 +2860,58 @@ sub im_stop($) {
# Try graceful shutdown.
mtr_debug("IM-main pid: $instance_manager->{'pid'}");
mtr_debug("Stopping IM-main...");
mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);
# If necessary, wait for angel process to die.
if (defined $instance_manager->{'angel_pid'})
{
mtr_debug("IM-angel pid: $instance_manager->{'angel_pid'}");
mtr_debug("Waiting for IM-angel to die...");
my $total_attempts= 10;
for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
{
unless (kill (0, $instance_manager->{'angel_pid'}))
{
mtr_debug("IM-angel died.");
last;
}
sleep(1);
}
}
# Check that all processes died.
my $clean_shutdown= 0;
while (1)
{
last if kill (0, $instance_manager->{'pid'});
if (kill (0, $instance_manager->{'pid'}))
{
mtr_debug("IM-main is still alive.");
last;
}
last if (defined $instance_manager->{'angel_pid'}) &&
kill (0, $instance_manager->{'angel_pid'});
if (defined $instance_manager->{'angel_pid'} &&
kill (0, $instance_manager->{'angel_pid'}))
{
mtr_debug("IM-angel is still alive.");
last;
}
foreach my $pid (@mysqld_pids)
{
last if kill (0, $pid);
if (kill (0, $pid))
{
mtr_debug("Guarded mysqld ($pid) is still alive.");
last;
}
}
$clean_shutdown= 1;
@ -2886,15 +2922,21 @@ sub im_stop($) {
unless ($clean_shutdown)
{
mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
if defined $instance_manager->{'angel_pid'};
if (defined $instance_manager->{'angel_pid'})
{
mtr_debug("Killing IM-angel...");
mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
}
mtr_debug("Killing IM-main...");
mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1);
# Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM
# will not stop them on shutdown. So, we should firstly try to end them
# legally.
mtr_debug("Killing guarded mysqld(s)...");
mtr_kill_processes(\@mysqld_pids);
# Complain in error log so that a warning will be shown.

View File

@ -202,35 +202,6 @@ select count(*) from t1 where id not in (1,2);
count(*)
1
drop table t1;
create table t1 (f1 char(1), f2 int);
insert into t1 values (1,0),('a',1),('z',2);
select f1 from t1 where f1 in (1,'z');
f1
1
z
select f2 from t1 where f2 in (1,'z');
f2
0
1
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'z'
select f1 from t1 where 'z' in (1,f1);
f1
z
select * from t1 where 'z' in (f2,f1);
f1 f2
1 0
a 1
z 2
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'z'
Warning 1292 Truncated incorrect DOUBLE value: 'z'
Warning 1292 Truncated incorrect DOUBLE value: 'z'
select * from t1 where 1 in (f2,f1);
f1 f2
1 0
a 1
drop table t1;
CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 VALUES (44), (45), (46);
SELECT * FROM t1 WHERE a IN (45);

View File

@ -785,8 +785,8 @@ select f1 from t1 where "2006-1-1" between f1 and 'zzz';
f1
Warnings:
Warning 1292 Incorrect date value: 'zzz' for column 'f1' at row 1
Warning 1292 Truncated incorrect INTEGER value: 'zzz'
Warning 1292 Truncated incorrect INTEGER value: 'zzz'
Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
f1
2006-01-01

View File

@ -1,3 +1,4 @@
Success: the process has been started.
SHOW INSTANCES;
instance_name status
mysqld1 online

View File

@ -1,44 +1,45 @@
--------------------------------------------------------------------
-- 1.1.1.
--------------------------------------------------------------------
Success: the process has been started.
SHOW INSTANCES;
instance_name status
mysqld1 online
mysqld2 offline
SHOW INSTANCE STATUS mysqld1;
instance_name status version
mysqld1 online VERSION
SHOW INSTANCE STATUS mysqld2;
instance_name status version
mysqld2 offline VERSION
--------------------------------------------------------------------
-- 1.1.2.
--------------------------------------------------------------------
START INSTANCE mysqld2;
SHOW INSTANCES;
instance_name status
mysqld1 online
mysqld2 online
SHOW INSTANCE STATUS mysqld1;
instance_name status version
mysqld1 online VERSION
SHOW INSTANCE STATUS mysqld2;
instance_name status version
mysqld2 online VERSION
Success: the process has been started.
SHOW VARIABLES LIKE 'port';
Variable_name Value
port IM_MYSQLD1_PORT
port IM_MYSQLD2_PORT
--------------------------------------------------------------------
-- 1.1.3.
--------------------------------------------------------------------
STOP INSTANCE mysqld2;
SHOW INSTANCES;
instance_name status
mysqld1 online
mysqld2 offline
SHOW INSTANCE STATUS mysqld1;
instance_name status version
mysqld1 online VERSION
SHOW INSTANCE STATUS mysqld2;
instance_name status version
mysqld2 offline VERSION
Success: the process has been stopped.
--------------------------------------------------------------------
-- 1.1.4.
--------------------------------------------------------------------
START INSTANCE mysqld3;
ERROR HY000: Bad instance name. Check that the instance with such a name exists
START INSTANCE mysqld1;
ERROR HY000: The instance is already started
--------------------------------------------------------------------
-- 1.1.5.
--------------------------------------------------------------------
STOP INSTANCE mysqld3;
ERROR HY000: Bad instance name. Check that the instance with such a name exists
--------------------------------------------------------------------
-- 1.1.6.
--------------------------------------------------------------------
SHOW INSTANCES;
instance_name status
mysqld1 online
@ -50,20 +51,25 @@ SHOW INSTANCES;
instance_name status
mysqld1 online
mysqld2 offline
--------------------------------------------------------------------
-- 1.1.7.
--------------------------------------------------------------------
START INSTANCE mysqld2;
SHOW INSTANCES;
instance_name status
mysqld1 online
mysqld2 online
Success: the process has been started.
Killing the process...
Sleeping...
Success: the process was killed.
SHOW INSTANCES;
instance_name status
mysqld1 online
mysqld2 offline
--------------------------------------------------------------------
-- 1.1.8.
--------------------------------------------------------------------
SHOW INSTANCE STATUS;
ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use
--------------------------------------------------------------------
-- BUG#12813
--------------------------------------------------------------------
START INSTANCE mysqld1,mysqld2,mysqld3;
ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use
STOP INSTANCE mysqld1,mysqld2,mysqld3;

View File

@ -1,3 +1,4 @@
Success: the process has been started.
SHOW INSTANCES;
instance_name status
mysqld1 online
@ -42,7 +43,9 @@ skip-innodb VALUE
skip-bdb VALUE
skip-ndbcluster VALUE
START INSTANCE mysqld2;
Success: the process has been started.
STOP INSTANCE mysqld2;
Success: the process has been stopped.
SHOW mysqld1 LOG FILES;
Logfile Path File size
ERROR LOG PATH FILE_SIZE

View File

@ -305,3 +305,29 @@ insert delayed into v1 values (1);
ERROR HY000: 'test.v1' is not BASE TABLE
drop table t1;
drop view v1;
create table t1 (id int primary key, data int);
insert into t1 values (1, 1), (2, 2), (3, 3);
select row_count();
row_count()
3
insert ignore into t1 values (1, 1);
select row_count();
row_count()
0
replace into t1 values (1, 11);
select row_count();
row_count()
2
replace into t1 values (4, 4);
select row_count();
row_count()
1
insert into t1 values (2, 2) on duplicate key update data= data + 10;
select row_count();
row_count()
2
insert into t1 values (5, 5) on duplicate key update data= data + 10;
select row_count();
row_count()
1
drop table t1;

View File

@ -67,3 +67,9 @@ Select_priv
N
use test;
use test;
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
unlock tables;
drop table t1;

View File

@ -747,6 +747,14 @@ select count(id1) from t1 where id2 = 10;
count(id1)
5
drop table t1;
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
SELECT * FROM t1;
a b
xxxxxxxxx bbbbbb
xxxxxxxxx bbbbbb
DROP TABLE t1;
set storage_engine=MyISAM;
drop table if exists t1,t2,t3;
--- Testing varchar ---

View File

@ -1458,7 +1458,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
@ -1764,7 +1763,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11)
) */;
@ -1822,7 +1820,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
@ -1915,7 +1912,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` int(11),
@ -1923,13 +1919,11 @@ DROP TABLE IF EXISTS `v1`;
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11)
) */;
DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 DROP TABLE IF EXISTS `v3`*/;
/*!50001 CREATE TABLE `v3` (
`a` int(11),
`b` int(11),
@ -2490,7 +2484,6 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 CREATE TABLE `v0` (
`a` int(11),
`b` varchar(32),
@ -2498,7 +2491,6 @@ DROP TABLE IF EXISTS `v0`;
) */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` varchar(32),
@ -2506,16 +2498,11 @@ DROP TABLE IF EXISTS `v1`;
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11),
`b` varchar(32),
`c` varchar(32)
) */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
@ -2770,3 +2757,62 @@ p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
select 42
drop function f;
drop procedure p;
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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 */;
/*!40000 DROP DATABASE IF EXISTS `mysqldump_test_db`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_test_db`;
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 (1232131),(4711),(3231),(815);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v1` AS select `t1`.`id` AS `id` from `t1` */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!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 view v1;
drop table t1;
drop database mysqldump_test_db;

View File

@ -0,0 +1,47 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop database if exists test1;
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
CALL simpleproc3();
select * from t2;
id comment
1 testtest 1
2 test 2
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
id fname
1 testtest 1
2 test
use test1;
select * from t1;
id fname
1 testtest 1
2 test
drop database test1;
drop database test1;

View File

@ -2730,6 +2730,12 @@ ERROR HY000: Key 'a' doesn't exist in table 't1'
EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
ERROR HY000: Key 'a' doesn't exist in table 't1'
DROP TABLE t1;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01')
0 1 1 1
DROP TABLE t1;
CREATE TABLE t1 (
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',

View File

@ -485,6 +485,10 @@ set sql_mode=2097152;
select @@sql_mode;
@@sql_mode
STRICT_TRANS_TABLES
set sql_mode=4194304;
select @@sql_mode;
@@sql_mode
STRICT_ALL_TABLES
set sql_mode=16384+(65536*4);
select @@sql_mode;
@@sql_mode

View File

@ -169,21 +169,22 @@ select @log;
@log
(BEFORE_INSERT: new=(id=1, data=2))
set @log:= "";
replace t1 values (1, 3), (2, 2);
insert into t1 (id, data) values (1, 3), (2, 2) on duplicate key update data= data + 1;
select @log;
@log
(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(BEFORE_INSERT: new=(id=2, data=2))(AFTER_INSERT: new=(id=2, data=2))
alter table t1 add ts timestamp default now();
(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1, data=2))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=2))(BEFORE_INSERT: new=(id=2, data=2))(AFTER_INSERT: new=(id=2, data=2))
set @log:= "";
replace t1 (id, data) values (1, 4);
replace t1 values (1, 4), (3, 3);
select @log;
@log
(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=3))(AFTER_DELETE: old=(id=1, data=3))(AFTER_INSERT: new=(id=1, data=4))
(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=2))(AFTER_DELETE: old=(id=1, data=2))(AFTER_INSERT: new=(id=1, data=4))(BEFORE_INSERT: new=(id=3, data=3))(AFTER_INSERT: new=(id=3, data=3))
drop trigger t1_bd;
drop trigger t1_ad;
set @log:= "";
insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2;
replace t1 values (1, 5);
select @log;
@log
(BEFORE_INSERT: new=(id=1, data=5))(BEFORE_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(AFTER_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(BEFORE_INSERT: new=(id=3, data=3))(AFTER_INSERT: new=(id=3, data=3))
(BEFORE_INSERT: new=(id=1, data=5))(AFTER_INSERT: new=(id=1, data=5))
drop table t1;
create table t1 (id int primary key, data varchar(10), fk int);
create table t2 (event varchar(100));
@ -493,15 +494,9 @@ select * from t1;
i k
3 13
replace into t1 values (3, 3);
ERROR 42S22: Unknown column 'at' in 'NEW'
select * from t1;
i k
3 3
alter table t1 add ts timestamp default now();
replace into t1 (i, k) values (3, 13);
ERROR 42S22: Unknown column 'at' in 'OLD'
select * from t1;
i k ts
i k
drop table t1, t2;
create table t1 (i int, bt int, k int, key(k)) engine=myisam;
create table t2 (i int);
@ -574,18 +569,11 @@ i k
1 1
2 2
replace into t1 values (2, 4);
ERROR 42S22: Unknown column 'bt' in 'NEW'
ERROR 42S22: Unknown column 'bt' in 'OLD'
select * from t1;
i k
1 1
2 2
alter table t1 add ts timestamp default now();
replace into t1 (i, k) values (2, 11);
ERROR 42S22: Unknown column 'bt' in 'OLD'
select * from t1;
i k ts
1 1 0000-00-00 00:00:00
2 2 0000-00-00 00:00:00
drop table t1, t2;
drop function if exists bug5893;
create table t1 (col1 int, col2 int);

View File

@ -109,18 +109,6 @@ select count(*) from t1 where id not in (1);
select count(*) from t1 where id not in (1,2);
drop table t1;
#
# Bug#18360 Incorrect type coercion in IN() results in false comparison
#
create table t1 (f1 char(1), f2 int);
insert into t1 values (1,0),('a',1),('z',2);
select f1 from t1 where f1 in (1,'z');
select f2 from t1 where f2 in (1,'z');
select f1 from t1 where 'z' in (1,f1);
select * from t1 where 'z' in (f2,f1);
select * from t1 where 1 in (f2,f1);
drop table t1;
# End of 4.1 tests
#

View File

@ -1,2 +1,3 @@
--run-as-service
--log=$MYSQLTEST_VARDIR/log/im.log
--monitoring-interval=1

View File

@ -10,6 +10,22 @@
###########################################################################
# Wait for mysqld1 (guarded instance) to start.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 3
# Check that start conditions are as expected.
SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted
###########################################################################
# Kill the IM main process and check that the IM Angel will restart the main
# process.
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30

View File

@ -0,0 +1 @@
--monitoring-interval=1

View File

@ -17,11 +17,23 @@
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.1.
--echo --------------------------------------------------------------------
# Wait for mysqld1 (guarded instance) to start.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 3
# Check that start conditions are as expected.
SHOW INSTANCES;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld2;
###########################################################################
#
@ -33,20 +45,24 @@ SHOW INSTANCE STATUS mysqld2;
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.2.
--echo --------------------------------------------------------------------
START INSTANCE mysqld2;
# FIXME
--sleep 3
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
SHOW INSTANCES;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld2;
# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
# synchronous. Even waiting for mysqld to start by looking at its pid file is
# not enough, because IM may not detect that mysqld has started.
# SHOW INSTANCES;
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
--connection mysql_con
--replace_result $IM_MYSQLD1_PORT IM_MYSQLD1_PORT
--replace_result $IM_MYSQLD2_PORT IM_MYSQLD2_PORT
SHOW VARIABLES LIKE 'port';
--connection default
@ -61,15 +77,19 @@ SHOW VARIABLES LIKE 'port';
#
###########################################################################
STOP INSTANCE mysqld2;
# FIXME
--sleep 3
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.3.
--echo --------------------------------------------------------------------
SHOW INSTANCES;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld1;
--replace_column 3 VERSION
SHOW INSTANCE STATUS mysqld2;
STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
# synchronous. Even waiting for mysqld to start by looking at its pid file is
# not enough, because IM may not detect that mysqld has started.
# SHOW INSTANCES;
###########################################################################
#
@ -81,16 +101,17 @@ SHOW INSTANCE STATUS mysqld2;
#
###########################################################################
--error 3000
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.4.
--echo --------------------------------------------------------------------
--error 3000 # ER_BAD_INSTANCE_NAME
START INSTANCE mysqld3;
--error 3002
--error 3002 # ER_INSTANCE_ALREADY_STARTED
START INSTANCE mysqld1;
# FIXME TODO
# BUG#12813: START/STOP INSTANCE commands accept a list as argument
# START INSTANCE mysqld1, mysqld2;
###########################################################################
#
# 1.1.5. Check that Instance Manager reports correct errors for 'STOP INSTANCE'
@ -101,27 +122,40 @@ START INSTANCE mysqld1;
#
###########################################################################
--error 3000
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.5.
--echo --------------------------------------------------------------------
--error 3000 # ER_BAD_INSTANCE_NAME
STOP INSTANCE mysqld3;
# TODO: IM should be fixed.
# BUG#12673: Instance Manager allows to stop the instance many times
# --error 3002
# --error 3002 # ER_INSTANCE_ALREADY_STARTED
# STOP INSTANCE mysqld2;
# FIXME TODO
# BUG#12813: START/STOP INSTANCE commands accept a list as argument
# STOP INSTANCE mysqld1, mysqld2;
###########################################################################
#
# 1.1.6. Check that Instance Manager is able to restart guarded instances.
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.6.
--echo --------------------------------------------------------------------
SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
# Give some time to IM to detect that mysqld was restarted. It should be longer
# than monitoring interval.
--sleep 3
SHOW INSTANCES;
###########################################################################
#
@ -129,17 +163,26 @@ SHOW INSTANCES;
#
###########################################################################
SHOW INSTANCES;
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.7.
--echo --------------------------------------------------------------------
START INSTANCE mysqld2;
# FIXME
--sleep 3
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
SHOW INSTANCES;
# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
# synchronous. Even waiting for mysqld to start by looking at its pid file is
# not enough, because IM may not detect that mysqld has started.
# SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
SHOW INSTANCES;
# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
# synchronous. Even waiting for mysqld to start by looking at its pid file is
# not enough, because IM may not detect that mysqld has started.
# SHOW INSTANCES;
###########################################################################
#
@ -147,7 +190,13 @@ SHOW INSTANCES;
# incomplete SHOW INSTANCE STATUS command.
#
###########################################################################
--error 1149
--echo
--echo --------------------------------------------------------------------
--echo -- 1.1.8.
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
SHOW INSTANCE STATUS;
#
@ -159,8 +208,13 @@ SHOW INSTANCE STATUS;
# a list as argument.
#
--error 1149
--echo
--echo --------------------------------------------------------------------
--echo -- BUG#12813
--echo --------------------------------------------------------------------
--error ER_SYNTAX_ERROR
START INSTANCE mysqld1,mysqld2,mysqld3;
--error 1149
--error ER_SYNTAX_ERROR
STOP INSTANCE mysqld1,mysqld2,mysqld3;

View File

@ -0,0 +1 @@
--monitoring-interval=1

View File

@ -17,6 +17,17 @@
# - the second instance is offline;
#
# Wait for mysqld1 (guarded instance) to start.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
# Let IM detect that mysqld1 is online. This delay should be longer than
# monitoring interval.
--sleep 3
# Check that start conditions are as expected.
SHOW INSTANCES;
#
@ -40,11 +51,10 @@ SHOW INSTANCE OPTIONS mysqld2;
#
START INSTANCE mysqld2;
# FIXME
-- sleep 3
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
STOP INSTANCE mysqld2;
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
#
# Check 'SHOW LOG FILES' command:

View File

@ -2196,3 +2196,16 @@ drop table t2, t1;
#
--error ER_TABLE_CANT_HANDLE_SPKEYS
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
# These files are to be modified ONLY BY INNOBASE guys. #
# #
# Use innodb_mysql.[test|result] files instead. #
# #
# If nevertheless you need to make some changes here, please, forward #
# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com #
# (otherwise your changes may be erased). #
# #
#######################################################################

View File

@ -187,3 +187,26 @@ create view v1 as select * from t1;
insert delayed into v1 values (1);
drop table t1;
drop view v1;
#
# Test for values returned by ROW_COUNT() function
# (and thus for values returned by mysql_affected_rows())
# for various forms of INSERT
#
create table t1 (id int primary key, data int);
insert into t1 values (1, 1), (2, 2), (3, 3);
select row_count();
insert ignore into t1 values (1, 1);
select row_count();
# Reports that 2 rows are affected (1 deleted + 1 inserted)
replace into t1 values (1, 11);
select row_count();
replace into t1 values (4, 4);
select row_count();
# Reports that 2 rows are affected. This conforms to documentation.
# (Useful for differentiating inserts from updates).
insert into t1 values (2, 2) on duplicate key update data= data + 10;
select row_count();
insert into t1 values (5, 5) on duplicate key update data= data + 10;
select row_count();
drop table t1;

View File

@ -1,66 +1,115 @@
#!/bin/sh
if [ $# -ne 2 ]; then
echo "Usage: kill_n_check.sh <pid file path> killed|restarted"
###########################################################################
# NOTE: this script returns 0 (success) even in case of failure. This is
# because this script is executed under mysql-test-run[.pl] and it's better to
# examine particular problem in log file, than just having said that the test
# case has failed.
###########################################################################
check_restart()
{
if [ ! -r "$pid_path" ]; then
user_msg='the process was killed'
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
if [ $? -eq 0 -a "$original_pid" = "$new_pid" ]; then
user_msg='the process was not restarted'
return 1
fi
user_msg='the process was restarted'
return 0
}
###########################################################################
if [ $# -ne 3 ]; then
echo "Usage: kill_n_check.sh <pid file path> killed|restarted <timeout>"
exit 0
fi
pid_path="$1"
expected_result="$2"
total_timeout="$3"
if [ -z "$pid_path" -o ! -r "$pid_path" ]; then
echo "Error: invalid PID path ($pid_path) or PID file does not exist."
if [ "$expected_result" != 'killed' -a \
"$expected_result" != 'restarted' ]; then
echo "Error: invalid second argument ('killed' or 'restarted' expected)."
exit 0
fi
if [ "$expected_result" != "killed" -a \
"$expected_result" != "restarted" ]; then
echo "Error: expected result must be either 'killed' or 'restarted'."
if [ -z "$pid_path" ]; then
echo "Error: invalid PID path ($pid_path)."
exit 0
fi
# echo "PID path: '$pid_path'"
if [ $expected_result = 'killed' -a ! -r "$pid_path" ]; then
echo "Error: PID file ($pid_path) does not exist."
exit 0
fi
if [ -z "$total_timeout" ]; then
echo "Error: timeout is not specified."
exit 0
fi
###########################################################################
original_pid=`cat "$pid_path"`
# echo "Original PID: $original_pid"
echo "Killing the process..."
kill -9 $original_pid
###########################################################################
echo "Sleeping..."
sleep 3
new_pid=""
[ -r "$pid_path" ] && new_pid=`cat "$pid_path"`
# echo "New PID: $new_pid"
if [ "$expected_result" = "restarted" ]; then
if [ -z "$new_pid" ]; then
echo "Error: the process was killed."
exit 0
fi
# Wait for the process to restart.
if [ "$original_pid" -eq "$new_pid" ]; then
echo "Error: the process was not restarted."
exit 0
fi
echo "Success: the process was restarted."
cur_attempt=1
while true; do
if check_restart; then
echo "Success: $user_msg."
exit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
echo "Error: $user_msg."
exit 0
else # $expected_result = killed
else # $expected_result == killed
# Here we have to sleep for some long time to ensure that the process will
# not be restarted.
sleep $total_timeout
new_pid=`cat "$pid_path" 2>/dev/null`
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
echo "Error: the process was restarted."
exit 0
else
echo "Success: the process was killed."
fi
echo "Success: the process was killed."
exit 0
fi

View File

@ -171,4 +171,30 @@ use test;
#
connection default;
#
# Bug #17264: MySQL Server freeze
#
connection locker;
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
connection writer;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
connection reader;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
connection locker;
--sleep 2
unlock tables;
connection writer;
reap;
connection reader;
reap;
connection locker;
drop table t1;
# End of 5.0 tests

View File

@ -697,6 +697,15 @@ select count(*) from t1 where id2 = 10;
select count(id1) from t1 where id2 = 10;
drop table t1;
#
# BUG#18036 - update of table joined to self reports table as crashed
#
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
SELECT * FROM t1;
DROP TABLE t1;
# End of 4.1 tests
#
@ -823,4 +832,3 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
--error 1064
create table t4 (c1 int) engine=myisam pack_keys=2;
drop table t1, t2, t3;

View File

@ -1161,3 +1161,20 @@ show create procedure p;
drop function f;
drop procedure p;
#
# BUG#17201 Spurious 'DROP DATABASE' in output,
# also confusion between tables and views.
# Example code from Markus Popp
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
create view v1 as select * from t1;
insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db
drop view v1;
drop table t1;
drop database mysqldump_test_db;

View File

@ -0,0 +1,63 @@
#
# Test of auto_increment
# BUG#11932
#
# Bug reported that master and slave get out of sync after TRUNCATE
# TABLE.
#
# Test supplied by Are Casilla
source include/master-slave.inc;
--disable_warnings
connection master;
drop database if exists test1;
--enable_warnings
create database test1;
use test1;
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `t1` VALUES (1, 'blablabla');
CREATE TABLE `t2` (
`id` int(10) NOT NULL auto_increment,
`comment` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO `t2` VALUES (1, 'testtest 1');
INSERT INTO `t2` VALUES (2, 'test 2');
DELIMITER $;
CREATE PROCEDURE simpleproc3 ()
NOT DETERMINISTIC
BEGIN
INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
INSERT INTO t1 (fname) VALUES('test');
END
$
DELIMITER ;$
CALL simpleproc3();
select * from t2;
TRUNCATE TABLE `t1`;
CALL simpleproc3();
select * from t1;
save_master_pos;
connection slave;
sync_with_master;
use test1;
select * from t1;
drop database test1;
connection master;
drop database test1;

View File

@ -2285,6 +2285,25 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
DROP TABLE t1;
#
# Bug #18759 "Incorrect string to numeric conversion"
#
# This test is here so that the behavior will not be changed to 4.1
# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string
# will be converted internally to real (double) value and it is not
# as accurate as bigint (longlong) for integers. Thus the results may
# vary. In 5.1 internally it is decimal, which is a string type and
# will be more accurate. Due to rather big changes needed to fix this
# in 4.1 or 5.0 it is not desired to do it in the stable versions.
#
# This test is here only to make sure that behavior is not changed in
# 4.1 and 5.0
#
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
DROP TABLE t1;
# End of 4.1 tests
#

View File

@ -258,6 +258,9 @@ drop table t1, t2;
select @@sql_mode;
set sql_mode=2097152;
select @@sql_mode;
# BUG#14675
set sql_mode=4194304;
select @@sql_mode;
set sql_mode=16384+(65536*4);
select @@sql_mode;
--error 1231

View File

@ -185,24 +185,26 @@ select @log;
set @log:= "";
insert ignore t1 values (1, 2);
select @log;
# REPLACE: before insert trigger should be called for both records,
# but then for first one update will be executed (and both update
# triggers should fire). For second after insert trigger will be
# called as for usual insert
# INSERT ... ON DUPLICATE KEY UPDATE ...
set @log:= "";
replace t1 values (1, 3), (2, 2);
insert into t1 (id, data) values (1, 3), (2, 2) on duplicate key update data= data + 1;
select @log;
# Now let us change table in such way that REPLACE on won't be executed
# using update.
alter table t1 add ts timestamp default now();
# REPLACE (also test for bug#13479 "REPLACE activates UPDATE trigger,
# not the DELETE and INSERT triggers")
# We define REPLACE as INSERT which DELETEs old rows which conflict with
# row being inserted. So for the first record in statement below we will
# call before insert trigger, then delete will be executed (and both delete
# triggers should fire). Finally after insert trigger will be called.
# For the second record we will just call both on insert triggers.
set @log:= "";
# This REPLACE should be executed via DELETE and INSERT so proper
# triggers should be invoked.
replace t1 (id, data) values (1, 4);
replace t1 values (1, 4), (3, 3);
select @log;
# Finally let us test INSERT ... ON DUPLICATE KEY UPDATE ...
# Now we will drop ON DELETE triggers to test REPLACE which is internally
# executed via update
drop trigger t1_bd;
drop trigger t1_ad;
set @log:= "";
insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2;
replace t1 values (1, 5);
select @log;
# This also drops associated triggers
@ -531,14 +533,11 @@ alter table t1 add primary key (i);
--error 1054
insert into t1 values (3, 4) on duplicate key update k= k + 10;
select * from t1;
# The following statement will delete old row and won't
# insert new one since after delete trigger will fail.
--error 1054
replace into t1 values (3, 3);
select * from t1;
# Change table in such way that REPLACE will delete row
alter table t1 add ts timestamp default now();
--error 1054
replace into t1 (i, k) values (3, 13);
select * from t1;
# Also drops all triggers
drop table t1, t2;
@ -594,11 +593,6 @@ select * from t1;
--error 1054
replace into t1 values (2, 4);
select * from t1;
# Change table in such way that REPLACE will delete row
alter table t1 add ts timestamp default now();
--error 1054
replace into t1 (i, k) values (2, 11);
select * from t1;
# Also drops all triggers
drop table t1, t2;

View File

@ -0,0 +1,66 @@
#!/bin/sh
###########################################################################
pid_path="$1"
total_attempts="$2"
event="$3"
case "$3" in
started)
check_fn='check_started';
;;
stopped)
check_fn='check_stopped';
;;
*)
echo "Error: invalid third argument ('started' or 'stopped' expected)."
exit 0
esac
###########################################################################
check_started()
{
[ ! -r "$pid_path" ] && return 1
new_pid=`cat "$pid_path" 2>/dev/null`
[ $? -eq 0 -a "$original_pid" = "$new_pid" ] && return 1
return 0
}
###########################################################################
check_stopped()
{
[ -r "$pid_path" ] && return 1
return 0
}
###########################################################################
cur_attempt=1
while true; do
if ( eval $check_fn ); then
echo "Success: the process has been $event."
exit 0
fi
[ $cur_attempt -ge $total_attempts ] && break
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
echo "Error: the process has not been $event in $total_attempts secs."
exit 0

View File

@ -96,6 +96,7 @@ public:
public:
ConfigValuesFactory(Uint32 keys = 50, Uint32 data = 10); // Initial
ConfigValuesFactory(ConfigValues * m_cfg); //
~ConfigValuesFactory();
ConfigValues * m_cfg;
ConfigValues * getConfigValues();

View File

@ -294,6 +294,12 @@ ConfigValuesFactory::ConfigValuesFactory(ConfigValues * cfg){
}
}
ConfigValuesFactory::~ConfigValuesFactory()
{
if(m_cfg)
free(m_cfg);
}
ConfigValues *
ConfigValuesFactory::create(Uint32 keys, Uint32 data){
Uint32 sz = sizeof(ConfigValues);
@ -528,7 +534,7 @@ ConfigValuesFactory::extractCurrentSection(const ConfigValues::ConstIterator & c
}
}
ConfigValues * ret = fac->m_cfg;
ConfigValues * ret = fac->getConfigValues();
delete fac;
return ret;
}

View File

@ -1945,7 +1945,7 @@ ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned int version) {
}
delete prop;
return (ndb_mgm_configuration*)cvf.m_cfg;
return (ndb_mgm_configuration*)cvf.getConfigValues();
} while(0);
delete prop;

View File

@ -2241,11 +2241,11 @@ ConfigInfo::ConfigInfo()
if (!m_info.getCopy(param._section, &section)) {
Properties newsection(true);
m_info.put(param._section, &newsection);
// Get copy of section
m_info.getCopy(param._section, &section);
}
// Get copy of section
m_info.getCopy(param._section, &section);
// Create pinfo (parameter info) entry
Properties pinfo(true);
pinfo.put("Id", param._paramId);
@ -2299,6 +2299,7 @@ ConfigInfo::ConfigInfo()
// Replace section with modified section
m_info.put(param._section, section, true);
delete section;
if(param._type != ConfigInfo::CI_SECTION){
Properties * p;

View File

@ -1863,7 +1863,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
break;
case GSN_EVENT_REP:
{
EventReport *rep = CAST_PTR(EventReport, signal->getDataPtrSend());
EventReport *rep = (EventReport*) signal->getDataPtr();
if (rep->getNodeId() == 0)
rep->setNodeId(refToNode(signal->theSendersBlockRef));
eventReport(signal->getDataPtr());

View File

@ -19,7 +19,7 @@ static int nope = 0; /* for use in asserts; shuts lint up */
/* macros for manipulating states, small version */
#define states long
#define states1 states /* for later use in regexec() decision */
#define states1 long /* for later use in regexec() decision. Ensure Win64 definition is correct.*/
#define CLEAR(v) ((v) = 0)
#define SET0(v, n) ((v) &= ~((states) 1 << (n)))
#define SET1(v, n) ((v) |= (states) 1 << (n))

View File

@ -271,10 +271,7 @@ int Guardian_thread::init()
{
if (!(instance->options.nonguarded))
if (guard(instance, TRUE)) /* do not lock guardian */
{
instance_map->unlock();
return 1;
}
}
return 0;

View File

@ -215,7 +215,7 @@ int Instance_map::flush_instances()
hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0,
get_instance_key, delete_instance, 0);
rc= load();
guardian->init();
guardian->init(); // TODO: check error status.
pthread_mutex_unlock(&LOCK_instance_map);
guardian->unlock();
return rc;

View File

@ -147,6 +147,25 @@ void manager(const Options &options)
if (create_pid_file(options.pid_file_name, manager_pid))
return;
/*
Initialize signals and alarm-infrastructure.
NOTE: To work nicely with LinuxThreads, the signal thread is the first
thread in the process.
NOTE:
After init_thr_alarm() call it's possible to call thr_alarm() (from
different threads), that results in sending ALARM signal to the alarm
thread (which can be the main thread). That signal can interrupt
blocking calls.
In other words, a blocking call can be interrupted in the main thread
after init_thr_alarm().
*/
sigset_t mask;
set_signals(&mask);
/* create guardian thread */
{
pthread_t guardian_thd_id;
@ -154,9 +173,16 @@ void manager(const Options &options)
int rc;
/*
NOTE: Guardian should be shutdown first. Only then all other threads
need to be stopped. This should be done, as guardian is responsible for
shutting down the instances, and this is a long operation.
NOTE: Guardian should be shutdown first. Only then all other threads
need to be stopped. This should be done, as guardian is responsible
for shutting down the instances, and this is a long operation.
NOTE: Guardian uses thr_alarm() when detects current state of
instances (is_running()), but it is not interfere with
flush_instances() later in the code, because until flush_instances()
complete in the main thread, Guardian thread is not permitted to
process instances. And before flush_instances() there is no instances
to proceed.
*/
pthread_attr_init(&guardian_thd_attr);
@ -172,10 +198,8 @@ void manager(const Options &options)
}
/*
To work nicely with LinuxThreads, the signal thread is the first thread
in the process.
*/
/* Load instances. */
int signo;
bool shutdown_complete;
@ -189,11 +213,6 @@ void manager(const Options &options)
return;
}
/* Initialize signals and alarm-infrastructure. */
sigset_t mask;
set_signals(&mask);
/* create the listener */
{
pthread_t listener_thd_id;

View File

@ -4566,7 +4566,7 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
}
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,tmp);
}
@ -4632,7 +4632,7 @@ int Field_timestamp::store(longlong nr, bool unsigned_val)
nr, MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,timestamp);
}
@ -4656,7 +4656,7 @@ longlong Field_timestamp::val_int(void)
THD *thd= table ? table->in_use : current_thd;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr);
else
#endif
@ -4686,7 +4686,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
val_buffer->length(field_length);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr);
else
#endif
@ -4751,7 +4751,7 @@ bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate)
long temp;
THD *thd= table ? table->in_use : current_thd;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr);
else
#endif
@ -4788,7 +4788,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr)
{
int32 a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
a=sint4korr(a_ptr);
b=sint4korr(b_ptr);
@ -4806,7 +4806,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr)
void Field_timestamp::sort_string(char *to,uint length __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
if (!table->s->db_low_byte_first)
if (!table || !table->s->db_low_byte_first)
{
to[0] = ptr[0];
to[1] = ptr[1];
@ -4836,7 +4836,7 @@ void Field_timestamp::set_time()
long tmp= (long) thd->query_start();
set_notnull();
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,tmp);
}
@ -5238,7 +5238,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
from, len, MYSQL_TIMESTAMP_DATE, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,tmp);
}
@ -5299,7 +5299,7 @@ int Field_date::store(longlong nr, bool unsigned_val)
MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr, nr);
}
@ -5325,7 +5325,7 @@ double Field_date::val_real(void)
{
int32 j;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
j=sint4korr(ptr);
else
#endif
@ -5338,7 +5338,7 @@ longlong Field_date::val_int(void)
{
int32 j;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
j=sint4korr(ptr);
else
#endif
@ -5354,7 +5354,7 @@ String *Field_date::val_str(String *val_buffer,
val_buffer->alloc(field_length);
int32 tmp;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
tmp=sint4korr(ptr);
else
#endif
@ -5372,7 +5372,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr)
{
int32 a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
a=sint4korr(a_ptr);
b=sint4korr(b_ptr);
@ -5390,7 +5390,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr)
void Field_date::sort_string(char *to,uint length __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
if (!table->s->db_low_byte_first)
if (!table || !table->s->db_low_byte_first)
{
to[0] = ptr[0];
to[1] = ptr[1];
@ -5630,7 +5630,7 @@ int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
from, len, MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int8store(ptr,tmp);
}
@ -5683,7 +5683,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val)
MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int8store(ptr,nr);
}
@ -5712,7 +5712,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
}
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int8store(ptr,tmp);
}
@ -5739,7 +5739,7 @@ longlong Field_datetime::val_int(void)
{
longlong j;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
j=sint8korr(ptr);
else
#endif
@ -5759,7 +5759,7 @@ String *Field_datetime::val_str(String *val_buffer,
int part3;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
tmp=sint8korr(ptr);
else
#endif
@ -5824,7 +5824,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr)
{
longlong a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
a=sint8korr(a_ptr);
b=sint8korr(b_ptr);
@ -5842,7 +5842,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr)
void Field_datetime::sort_string(char *to,uint length __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
if (!table->s->db_low_byte_first)
if (!table || !table->s->db_low_byte_first)
{
to[0] = ptr[0];
to[1] = ptr[1];

View File

@ -813,7 +813,7 @@ public:
if ((*null_value= is_null()))
return 0;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
return sint4korr(ptr);
#endif
long tmp;

View File

@ -6684,6 +6684,17 @@ ha_innobase::store_lock(
&& !thd->tablespace_op
&& thd->lex->sql_command != SQLCOM_TRUNCATE
&& thd->lex->sql_command != SQLCOM_OPTIMIZE
#ifdef __WIN__
/*
for alter table on win32 for succesfull operation
completion it is used TL_WRITE(=10) lock instead of
TL_WRITE_ALLOW_READ(=6), however here in innodb handler
TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes
race condition when several clients do alter table
simultaneously (bug #17264). This fix avoids the problem.
*/
&& thd->lex->sql_command != SQLCOM_ALTER_TABLE
#endif
&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
lock_type = TL_WRITE_ALLOW_WRITE;

View File

@ -80,9 +80,6 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
NOTES
Aggregation rules:
If all items are constants the type will be aggregated from all items.
If there are some non-constant items then only types of non-constant
items will be used for aggregation.
If there are DATE/TIME fields/functions in the list and no string
fields/functions in the list then:
The INT_RESULT type will be used for aggregation instead of original
@ -141,7 +138,8 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
}
continue;
}
if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM)
if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM &&
items[i]->result_type() != INT_RESULT)
{
field= ((Item_field *)items[i]->real_item())->field;
break;
@ -169,34 +167,29 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
}
}
}
/* Reset to 0 on first occurence of non-const item. 1 otherwise */
bool is_const= items[0]->const_item();
/*
If the first item is a date/time function then its result should be
compared as int
*/
if (field)
{
/* Suppose we are comparing dates and some non-constant items are present. */
/* Suppose we are comparing dates */
type[0]= INT_RESULT;
is_const= 0;
}
else
type[0]= items[0]->result_type();
for (i= 0; i < nitems ; i++)
{
if (!items[i]->const_item())
{
Item_result result= field && items[i]->result_as_longlong() ?
INT_RESULT : items[i]->result_type();
type[0]= is_const ? result : item_cmp_type(type[0], result);
is_const= 0;
}
else if (is_const)
type[0]= item_cmp_type(type[0], items[i]->result_type());
else if (field)
convert_constant_item(thd, field, &items[i]);
Item_result result= items[i]->result_type();
/*
Use INT_RESULT as result type for DATE/TIME fields/functions and
for constants successfully converted to DATE/TIME
*/
if (field &&
((!items[i]->const_item() && items[i]->result_as_longlong()) ||
(items[i]->const_item() && convert_constant_item(thd, field,
&items[i]))))
result= INT_RESULT;
type[0]= item_cmp_type(type[0], result);
}
if (res == Item::FUNC_ITEM && field)

View File

@ -5872,7 +5872,8 @@ The minimum value for this variable is 4096.",
"Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
(gptr*) &global_system_variables.read_buff_size,
(gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE,
0},
{"read_only", OPT_READONLY,
"Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege",
(gptr*) &opt_readonly,
@ -5883,12 +5884,12 @@ The minimum value for this variable is 4096.",
(gptr*) &global_system_variables.read_rnd_buff_size,
(gptr*) &max_system_variables.read_rnd_buff_size, 0,
GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD,
~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
{"record_buffer", OPT_RECORD_BUFFER,
"Alias for read_buffer_size",
(gptr*) &global_system_variables.read_buff_size,
(gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0},
128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
#ifdef HAVE_REPLICATION
{"relay_log_purge", OPT_RELAY_LOG_PURGE,
"0 = do not purge relay logs. 1 = purge them as soon as they are no more needed.",

View File

@ -1057,16 +1057,19 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
to convert the latter operation internally to an UPDATE.
We also should not perform this conversion if we have
timestamp field with ON UPDATE which is different from DEFAULT.
Another case when conversion should not be performed is when
we have ON DELETE trigger on table so user may notice that
we cheat here. Note that it is ok to do such conversion for
tables which have ON UPDATE but have no ON DELETE triggers,
we just should not expose this fact to users by invoking
ON UPDATE triggers.
*/
if (last_uniq_key(table,key_nr) &&
!table->file->referenced_by_foreign_key() &&
(table->timestamp_field_type == TIMESTAMP_NO_AUTO_SET ||
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH) &&
(!table->triggers || !table->triggers->has_delete_triggers()))
{
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_BEFORE, TRUE))
goto before_trg_err;
if (thd->clear_next_insert_id)
{
/* Reset auto-increment cacheing if we do an update */
@ -1077,13 +1080,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
table->record[0])))
goto err;
info->deleted++;
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_AFTER,
TRUE));
/* Update logfile and count */
info->copied++;
goto ok_or_after_trg_err;
/*
Since we pretend that we have done insert we should call
its after triggers.
*/
goto after_trg_n_copied_inc;
}
else
{
@ -1107,10 +1108,6 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
}
}
info->copied++;
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
TRG_ACTION_AFTER, TRUE));
}
else if ((error=table->file->write_row(table->record[0])))
{
@ -1118,14 +1115,14 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
(error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE))
goto err;
table->file->restore_auto_increment();
goto ok_or_after_trg_err;
}
else
{
info->copied++;
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
TRG_ACTION_AFTER, TRUE));
}
after_trg_n_copied_inc:
info->copied++;
trg_error= (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
TRG_ACTION_AFTER, TRUE));
ok_or_after_trg_err:
if (key)

View File

@ -8834,6 +8834,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
null_pack_length-=hidden_null_pack_length;
keyinfo->key_parts= ((field_count-param->hidden_field_count)+
test(null_pack_length));
set_if_smaller(table->s->max_rows, rows_limit);
param->end_write_records= rows_limit;
table->distinct= 1;
table->s->keys= 1;
if (blob_count)

View File

@ -859,7 +859,12 @@ reopen_tables:
}
}
}
/*
Set exclude_from_table_unique_test value back to FALSE. It is needed for
further check in multi_update::prepare whether to use record cache.
*/
lex->select_lex.exclude_from_table_unique_test= FALSE;
if (thd->fill_derived_tables() &&
mysql_handle_derived(lex, &mysql_derived_filling))
DBUG_RETURN(TRUE);
@ -1038,7 +1043,7 @@ int multi_update::prepare(List<Item> &not_used_values,
for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf)
{
TABLE *table=table_ref->table;
if (!(tables_to_update & table->map) &&
if ((tables_to_update & table->map) &&
unique_table(thd, table_ref, update_tables))
table->no_cache= 1; // Disable row cache
}