Commit a4789f52 authored by Monty's avatar Monty

More tests for SEQUENCE's

- Test with LOCK TABLES
- Test mysqldump
- Don't update rows for sequence tables if values doesn't change. This is
  needed as InnoDB gives an error for updates where values doesn't change.
parent 8acf4d6f
CREATE SEQUENCE a1 engine=aria;
CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024;
insert into t1 values (1),(2);
CREATE SEQUENCE x1 engine=innodb;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `a1` (
`next_value` bigint(21) NOT NULL COMMENT 'next not cached value',
`min_value` bigint(21) NOT NULL COMMENT 'min value',
`max_value` bigint(21) NOT NULL COMMENT 'max value',
`start` bigint(21) NOT NULL COMMENT 'start value',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache` bigint(21) NOT NULL COMMENT 'cache size',
`cycle` tinyint(1) unsigned NOT NULL COMMENT 'cycle state',
`round` bigint(21) NOT NULL COMMENT 'How many cycles has been done'
) ENGINE=Aria SEQUENCE=1;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `a1` VALUES (1,1,9223372036854775806,1,1,1000,0,0);
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1024;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(2);
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `x1` (
`next_value` bigint(21) NOT NULL COMMENT 'next not cached value',
`min_value` bigint(21) NOT NULL COMMENT 'min value',
`max_value` bigint(21) NOT NULL COMMENT 'max value',
`start` bigint(21) NOT NULL COMMENT 'start value',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache` bigint(21) NOT NULL COMMENT 'cache size',
`cycle` tinyint(1) unsigned NOT NULL COMMENT 'cycle state',
`round` bigint(21) NOT NULL COMMENT 'How many cycles has been done'
) ENGINE=InnoDB SEQUENCE=1;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `x1` VALUES (1,1,9223372036854775806,1,1,1000,0,0);
DROP TABLE a1,t1,x1;
#
# Testing mysqldump of sequences
#
# Embedded server doesn't support external clients
--source include/not_embedded.inc
--source include/have_aria.inc
--source include/have_innodb.inc
CREATE SEQUENCE a1 engine=aria;
CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024;
insert into t1 values (1),(2);
CREATE SEQUENCE x1 engine=innodb;
--exec $MYSQL_DUMP --compact test
DROP TABLE a1,t1,x1;
...@@ -82,3 +82,34 @@ ERROR HY000: Storage engine SEQUENCE of the table `test`.`s1` doesn't have this ...@@ -82,3 +82,34 @@ ERROR HY000: Storage engine SEQUENCE of the table `test`.`s1` doesn't have this
delete from s1 where next_value > 0; delete from s1 where next_value > 0;
ERROR HY000: Storage engine SEQUENCE of the table `test`.`s1` doesn't have this option ERROR HY000: Storage engine SEQUENCE of the table `test`.`s1` doesn't have this option
drop sequence s1; drop sequence s1;
#
# SHOW TABLES
#
create sequence s1;
create table t1 (a int);
create view v1 as select * from s1;
show full tables;
Tables_in_test Table_type
s1 SEQUENCE
t1 BASE TABLE
v1 VIEW
SELECT TABLE_TYPE,ENGINE FROM INFORMATION_SCHEMA.TABLES where table_schema="test";
TABLE_TYPE ENGINE
SEQUENCE MyISAM
BASE TABLE MyISAM
VIEW NULL
drop table t1,s1;
drop view v1;
#
# LOCK TABLES (as in mysqldump)
#
create sequence s1 engine=innodb;
LOCK TABLES s1 READ;
SELECT * from s1;
next_value min_value max_value start increment cache cycle round
1 1 9223372036854775806 1 1 1000 0 0
UNLOCK TABLES;
LOCK TABLES s1 WRITE;
insert into s1 values (1,1,9223372036854775806, 1, 1, 1000, 0, 0);
UNLOCK TABLES;
drop table s1;
...@@ -65,3 +65,28 @@ update s1 set next_value=100; ...@@ -65,3 +65,28 @@ update s1 set next_value=100;
--error ER_ILLEGAL_HA --error ER_ILLEGAL_HA
delete from s1 where next_value > 0; delete from s1 where next_value > 0;
drop sequence s1; drop sequence s1;
--echo #
--echo # SHOW TABLES
--echo #
create sequence s1;
create table t1 (a int);
create view v1 as select * from s1;
show full tables;
SELECT TABLE_TYPE,ENGINE FROM INFORMATION_SCHEMA.TABLES where table_schema="test";
drop table t1,s1;
drop view v1;
--echo #
--echo # LOCK TABLES (as in mysqldump)
--echo #
create sequence s1 engine=innodb;
LOCK TABLES s1 READ;
SELECT * from s1;
UNLOCK TABLES;
LOCK TABLES s1 WRITE;
insert into s1 values (1,1,9223372036854775806, 1, 1, 1000, 0, 0);
UNLOCK TABLES;
drop table s1;
...@@ -6041,7 +6041,13 @@ int handler::update_first_row(uchar *new_data) ...@@ -6041,7 +6041,13 @@ int handler::update_first_row(uchar *new_data)
{ {
int end_error; int end_error;
if (!(error= ha_rnd_next(table->record[1]))) if (!(error= ha_rnd_next(table->record[1])))
{
/*
We have to do the memcmp as otherwise we may get error 169 from InnoDB
*/
if (memcmp(table->record[0], table->record[1], table->s->reclength))
error= update_row(table->record[1], new_data); error= update_row(table->record[1], new_data);
}
end_error= ha_rnd_end(); end_error= ha_rnd_end();
if (!error) if (!error)
error= end_error; error= end_error;
......
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