summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.>2006-12-27 11:01:54 +0100
committerunknown <tomas@poseidon.>2006-12-27 11:01:54 +0100
commite5dd5e063a2b291b0169e1efb3be05dcaef36fc7 (patch)
tree694a692ab769c1326162c8eb2bebed6dd273cd52
parentfcbfb41f30d794a14241070a44bba841ea0417d7 (diff)
parentb2f62764c6257c166d6b5f84b0cd39a3aefcca16 (diff)
downloadmariadb-git-e5dd5e063a2b291b0169e1efb3be05dcaef36fc7.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1
into poseidon.:/home/tomas/mysql-5.1-new-ndb include/my_base.h: Auto merged mysql-test/Makefile.am: Auto merged mysql-test/r/ndb_dd_ddl.result: Auto merged mysql-test/t/disabled.def: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/handler.h: Auto merged sql/item_func.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged storage/ndb/include/kernel/signaldata/BackupContinueB.hpp: Auto merged storage/ndb/src/common/util/File.cpp: Auto merged storage/ndb/src/common/util/InputStream.cpp: Auto merged storage/ndb/src/common/util/socket_io.cpp: Auto merged storage/ndb/src/kernel/blocks/backup/Backup.cpp: Auto merged storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: Auto merged storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp: Auto merged storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Auto merged storage/ndb/src/kernel/vm/SimulatedBlock.cpp: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Auto merged storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Auto merged storage/ndb/src/ndbapi/NdbTransaction.cpp: Auto merged storage/ndb/src/ndbapi/Ndbif.cpp: Auto merged storage/ndb/src/ndbapi/TransporterFacade.cpp: Auto merged storage/ndb/src/ndbapi/ndberror.c: Auto merged storage/ndb/test/ndbapi/testBasic.cpp: Auto merged storage/ndb/test/ndbapi/testIndex.cpp: Auto merged storage/ndb/test/ndbapi/testSystemRestart.cpp: Auto merged storage/ndb/tools/ndb_condig.cpp: Auto merged sql/sql_plugin.cc: manual merge
-rw-r--r--include/my_base.h8
-rw-r--r--mysql-test/r/ndb_alter_table.result45
-rw-r--r--mysql-test/r/ndb_basic.result76
-rw-r--r--mysql-test/r/ndb_binlog_discover.result2
-rw-r--r--mysql-test/r/ndb_cursor.result40
-rw-r--r--mysql-test/r/ndb_dd_alter.result14
-rw-r--r--mysql-test/r/ndb_dd_ddl.result5
-rw-r--r--mysql-test/r/ndb_dd_disk2memory.result4
-rw-r--r--mysql-test/r/ndb_index_unique.result15
-rw-r--r--mysql-test/r/ndb_read_multi_range.result14
-rw-r--r--mysql-test/r/ndb_sp.result44
-rw-r--r--mysql-test/r/ndb_subquery.result39
-rw-r--r--mysql-test/r/ndb_trigger.result31
-rw-r--r--mysql-test/r/ps_7ndb.result314
-rw-r--r--mysql-test/r/rpl_ndb_dd_advance.result12
-rw-r--r--mysql-test/t/disabled.def5
-rw-r--r--mysql-test/t/ndb_alter_table.test27
-rw-r--r--mysql-test/t/ndb_basic.test53
-rw-r--r--mysql-test/t/ndb_cursor.test47
-rw-r--r--mysql-test/t/ndb_dd_alter.test4
-rw-r--r--mysql-test/t/ndb_dd_ddl.test9
-rw-r--r--mysql-test/t/ndb_dd_disk2memory.test2
-rw-r--r--mysql-test/t/ndb_index_unique.test8
-rw-r--r--mysql-test/t/ndb_read_multi_range.test15
-rw-r--r--mysql-test/t/ndb_sp.test42
-rw-r--r--mysql-test/t/ndb_subquery.test18
-rw-r--r--mysql-test/t/ndb_trigger.test30
-rw-r--r--sql/ha_ndbcluster.cc74
-rw-r--r--sql/ha_ndbcluster.h2
-rw-r--r--sql/ha_ndbcluster_binlog.cc82
-rw-r--r--sql/handler.h4
-rw-r--r--sql/sql_plugin.cc2
-rw-r--r--sql/sql_show.cc4
-rw-r--r--sql/sql_table.cc11
-rw-r--r--sql/sql_yacc.yy6
-rw-r--r--storage/ndb/include/kernel/signaldata/BackupContinueB.hpp3
-rw-r--r--storage/ndb/include/kernel/signaldata/Extent.hpp2
-rw-r--r--storage/ndb/include/mgmapi/mgmapi_config_parameters.h2
-rw-r--r--storage/ndb/ndbapi-examples/Makefile2
-rw-r--r--storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile (renamed from storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile)2
-rw-r--r--storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp (renamed from storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp)0
-rw-r--r--storage/ndb/src/kernel/blocks/ERROR_codes.txt5
-rw-r--r--storage/ndb/src/kernel/blocks/backup/Backup.cpp35
-rw-r--r--storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp1
-rw-r--r--storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp28
-rw-r--r--storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp2
-rw-r--r--storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp2
-rw-r--r--storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp7
-rw-r--r--storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp17
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp46
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp54
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp156
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp6
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp28
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp231
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp1
-rw-r--r--storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp40
-rw-r--r--storage/ndb/src/kernel/blocks/diskpage.hpp5
-rw-r--r--storage/ndb/src/kernel/blocks/lgman.cpp17
-rw-r--r--storage/ndb/src/kernel/blocks/print_file.cpp48
-rw-r--r--storage/ndb/src/kernel/blocks/tsman.cpp172
-rw-r--r--storage/ndb/src/kernel/blocks/tsman.hpp54
-rw-r--r--storage/ndb/src/mgmsrv/ConfigInfo.cpp12
-rw-r--r--storage/ndb/src/mgmsrv/MgmtSrvr.cpp2
-rw-r--r--storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp17
-rw-r--r--storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp2
-rw-r--r--storage/ndb/src/ndbapi/NdbTransaction.cpp9
-rw-r--r--storage/ndb/src/ndbapi/Ndbif.cpp5
-rw-r--r--storage/ndb/src/ndbapi/TransporterFacade.cpp8
-rw-r--r--storage/ndb/test/ndbapi/testBasic.cpp33
-rw-r--r--storage/ndb/test/ndbapi/testIndex.cpp66
-rw-r--r--storage/ndb/test/ndbapi/testSystemRestart.cpp66
-rw-r--r--storage/ndb/test/run-test/daily-basic-tests.txt12
73 files changed, 1789 insertions, 517 deletions
diff --git a/include/my_base.h b/include/my_base.h
index d0c46b35c24..14e4e3afb44 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -95,6 +95,14 @@ enum ha_key_alg {
HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */
};
+ /* Storage media types */
+
+enum ha_storage_media {
+ HA_SM_DEFAULT= 0, /* Not specified (engine default) */
+ HA_SM_DISK= 1, /* DISK storage */
+ HA_SM_MEMORY= 2 /* MAIN MEMORY storage */
+};
+
/* The following is parameter to ha_extra() */
enum ha_extra_function {
diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result
index 7facb5fa286..13c445b44ca 100644
--- a/mysql-test/r/ndb_alter_table.result
+++ b/mysql-test/r/ndb_alter_table.result
@@ -354,3 +354,48 @@ select * from t1 where a = 12;
a b c
12 403 NULL
drop table t1;
+create table t1 (a int not null, b varchar(10)) engine=ndb;
+show index from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+alter table t1 add primary key (a);
+show index from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a A 0 NULL NULL BTREE
+alter table t1 drop primary key;
+show index from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+drop table t1;
+create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL DEFAULT '0',
+ `c` varchar(254) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+alter table t1 alter b set default 1;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL DEFAULT '1',
+ `c` varchar(254) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a int not null, b int not null) engine=ndb;
+insert into t1 values (1, 300), (2, 200), (3, 100);
+select * from t1 order by a;
+a b
+1 300
+2 200
+3 100
+alter table t1 order by b;
+select * from t1 order by b;
+a b
+3 100
+2 200
+1 300
+drop table t1;
+End of 5.1 tests
diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result
index b7e893faf29..821b80e349b 100644
--- a/mysql-test/r/ndb_basic.result
+++ b/mysql-test/r/ndb_basic.result
@@ -773,4 +773,80 @@ a b
2 2
3 3
drop table t1, t2;
+create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb;
+create table if not exists t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb;
+create table t2 like t1;
+rename table t1 to t10, t2 to t20;
+drop table t10,t20;
+create table t1 (a int not null primary key, b int not null) engine=ndb;
+create table t2 (a int not null primary key, b int not null) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,30);
+insert into t2 values (1,10), (2,20), (3,30);
+select * from t1 order by a;
+a b
+1 10
+2 20
+3 30
+delete from t1 where a > 0 order by a desc limit 1;
+select * from t1 order by a;
+a b
+1 10
+2 20
+delete from t1,t2 using t1,t2 where t1.a = t2.a;
+select * from t2 order by a;
+a b
+3 30
+drop table t1,t2;
+create table t1 (a int not null primary key, b int not null) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,30);
+insert into t1 set a=1, b=100;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+insert ignore into t1 set a=1, b=100;
+select * from t1 order by a;
+a b
+1 10
+2 20
+3 30
+insert into t1 set a=1, b=1000 on duplicate key update b=b+1;
+select * from t1 order by a;
+a b
+1 11
+2 20
+3 30
+drop table t1;
+create table t1 (a int not null primary key, b int not null) engine=ndb;
+create table t2 (c int not null primary key, d int not null) engine=ndb;
+insert into t1 values (1,10), (2,10), (3,30), (4, 30);
+insert into t2 values (1,10), (2,10), (3,30), (4, 30);
+update t1 set a = 1 where a = 3;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+select * from t1 order by a;
+a b
+1 10
+2 10
+3 30
+4 30
+update t1 set b = 1 where a > 1 order by a desc limit 1;
+select * from t1 order by a;
+a b
+1 10
+2 10
+3 30
+4 1
+update t1,t2 set a = 1, c = 1 where a = 3 and c = 3;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+select * from t1 order by a;
+a b
+1 10
+2 10
+3 30
+4 1
+update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3;
+select * from t1 order by a;
+a b
+1 10
+2 10
+3 1
+4 1
+drop table t1,t2;
End of 5.1 tests
diff --git a/mysql-test/r/ndb_binlog_discover.result b/mysql-test/r/ndb_binlog_discover.result
index e81d5cfc6f3..4806047a016 100644
--- a/mysql-test/r/ndb_binlog_discover.result
+++ b/mysql-test/r/ndb_binlog_discover.result
@@ -5,7 +5,7 @@ show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Table_map # # table_id: # (mysql.apply_status)
+master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
diff --git a/mysql-test/r/ndb_cursor.result b/mysql-test/r/ndb_cursor.result
new file mode 100644
index 00000000000..b3b815ef891
--- /dev/null
+++ b/mysql-test/r/ndb_cursor.result
@@ -0,0 +1,40 @@
+drop table if exists t1;
+drop table if exists t2;
+create table t1 (
+a int not null primary key,
+b int not null
+) engine=ndb;
+create table t2 (
+a int not null primary key,
+b int not null
+) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,30), (4, 40);
+create procedure test_cursor ()
+begin
+declare done int default 0;
+declare temp_a int;
+declare temp_b int;
+declare cur1 cursor for select a,b from t1;
+declare continue handler for sqlstate '02000' set done = 1;
+open cur1;
+repeat
+fetch cur1 into temp_a, temp_b;
+if not done then
+insert into t2 values (temp_a, temp_b);
+end if;
+until done end repeat;
+close cur1;
+end;
+//
+select * from t2 order by a;
+a b
+call test_cursor();
+select * from t2 order by a;
+a b
+1 10
+2 20
+3 30
+4 40
+drop procedure test_cursor;
+drop table t1,t2;
+end of 5.1 tests
diff --git a/mysql-test/r/ndb_dd_alter.result b/mysql-test/r/ndb_dd_alter.result
index a9505747a94..fec4e5496ad 100644
--- a/mysql-test/r/ndb_dd_alter.result
+++ b/mysql-test/r/ndb_dd_alter.result
@@ -282,7 +282,13 @@ a1
18
19
20
+SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
+NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default ts
ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE;
+SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
+NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default default ts
SELECT * FROM test.t1 ORDER BY a1;
a1 a2 a3
1 2.2345 20000001
@@ -369,7 +375,7 @@ t1 CREATE TABLE `t1` (
`a13` text,
`a14` blob,
PRIMARY KEY (`a1`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 ADD INDEX a2_i (a2), ADD INDEX a3_i (a3);
SHOW CREATE TABLE test.t1;
Table Create Table
@@ -391,7 +397,7 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`a1`),
KEY `a2_i` (`a2`),
KEY `a3_i` (`a3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 DROP INDEX a2_i;
SHOW CREATE TABLE test.t1;
Table Create Table
@@ -412,7 +418,7 @@ t1 CREATE TABLE `t1` (
`a14` blob,
PRIMARY KEY (`a1`),
KEY `a3_i` (`a3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE test.t1 DROP a14;
ALTER TABLE test.t1 DROP a13;
ALTER TABLE test.t1 DROP a12;
@@ -432,7 +438,7 @@ t1 CREATE TABLE `t1` (
`a4` bit(1) DEFAULT NULL,
`a5` tinyint(4) DEFAULT NULL,
KEY `a3_i` (`a3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
DROP TABLE test.t1;
ALTER TABLESPACE ts
DROP DATAFILE './table_space/datafile.dat'
diff --git a/mysql-test/r/ndb_dd_ddl.result b/mysql-test/r/ndb_dd_ddl.result
index aab44e261b2..67857d39ab6 100644
--- a/mysql-test/r/ndb_dd_ddl.result
+++ b/mysql-test/r/ndb_dd_ddl.result
@@ -183,6 +183,11 @@ INITIAL_SIZE 1M
ENGINE NDB;
CREATE TABLE t1
(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE MEMORY
+ENGINE NDB;
+ERROR HY000: Can't create table 'test.t1' (errno: 138)
+CREATE TABLE t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
TABLESPACE ts1 STORAGE DISK
ENGINE NDB;
CREATE INDEX b_i on t1(b);
diff --git a/mysql-test/r/ndb_dd_disk2memory.result b/mysql-test/r/ndb_dd_disk2memory.result
index 9da506bf743..46661f36d1b 100644
--- a/mysql-test/r/ndb_dd_disk2memory.result
+++ b/mysql-test/r/ndb_dd_disk2memory.result
@@ -237,7 +237,7 @@ t2 CREATE TABLE `t2` (
`c2` int(11) NOT NULL,
PRIMARY KEY (`pk2`)
) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
-ALTER TABLE test.t1 ENGINE=NDBCLUSTER;
+ALTER TABLE test.t1 STORAGE MEMORY ENGINE=NDBCLUSTER;
SHOW CREATE TABLE test.t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -341,7 +341,7 @@ t1 CREATE TABLE `t1` (
KEY `a2` (`a2`),
KEY `a3` (`a3`),
KEY `a8` (`a8`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
Table Create Table
t2 CREATE TABLE `t2` (
`b1` smallint(6) NOT NULL,
diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result
index fbc3a2bb915..cc63ce69760 100644
--- a/mysql-test/r/ndb_index_unique.result
+++ b/mysql-test/r/ndb_index_unique.result
@@ -137,6 +137,21 @@ a b c
6 7 2
7 8 3
8 2 3
+create unique index bi using hash on t2(b);
+insert into t2 values(9, 3, 1);
+ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
+alter table t2 drop index bi;
+insert into t2 values(9, 3, 1);
+select * from t2 order by a;
+a b c
+2 3 5
+3 4 6
+4 5 8
+5 6 2
+6 7 2
+7 8 3
+8 2 3
+9 3 1
drop table t2;
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
diff --git a/mysql-test/r/ndb_read_multi_range.result b/mysql-test/r/ndb_read_multi_range.result
index 53c10552668..8bc0f519cde 100644
--- a/mysql-test/r/ndb_read_multi_range.result
+++ b/mysql-test/r/ndb_read_multi_range.result
@@ -428,3 +428,17 @@ NULL 7
2005-12-08 15:58:27 1
2006-02-23 15:01:35 1
DROP TABLE t1, t11, t12, t21, t22;
+CREATE TABLE t1 (id varchar(255) NOT NULL,
+tag int(11) NOT NULL,
+doc text NOT NULL,
+type varchar(150) NOT NULL,
+modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (id)
+) ENGINE=ndbcluster;
+INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP);
+SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka');
+id tag doc type
+SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila');
+id tag doc type
+sakila 1 Some text goes here text
+DROP TABLE t1;
diff --git a/mysql-test/r/ndb_sp.result b/mysql-test/r/ndb_sp.result
new file mode 100644
index 00000000000..32e6d2eddd7
--- /dev/null
+++ b/mysql-test/r/ndb_sp.result
@@ -0,0 +1,44 @@
+drop table if exists t1;
+create table t1 (
+a int not null primary key,
+b int not null
+) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,100), (4, 100);
+create procedure test_proc1 (in var_in int)
+begin
+select * from t1 where a = var_in;
+end;
+create procedure test_proc2 (out var_out int)
+begin
+select b from t1 where a = 1 into var_out;
+end;
+create procedure test_proc3 (inout var_inout int)
+begin
+select b from t1 where a = var_inout into var_inout;
+end;
+//
+call test_proc1(1);
+a b
+1 10
+call test_proc2(@test_var);
+select @test_var;
+@test_var
+10
+set @test_var = 1;
+call test_proc3(@test_var);
+select @test_var;
+@test_var
+10
+alter procedure test_proc1 comment 'new comment';
+show create procedure test_proc1;
+Procedure sql_mode Create Procedure
+test_proc1 CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc1`(in var_in int)
+ COMMENT 'new comment'
+begin
+select * from t1 where a = var_in;
+end
+drop procedure test_proc1;
+drop procedure test_proc2;
+drop procedure test_proc3;
+drop table t1;
+End of 5.1 tests
diff --git a/mysql-test/r/ndb_subquery.result b/mysql-test/r/ndb_subquery.result
index 312711ab4b7..f2c9972f774 100644
--- a/mysql-test/r/ndb_subquery.result
+++ b/mysql-test/r/ndb_subquery.result
@@ -1,11 +1,14 @@
-drop table if exists t1;
-drop table if exists t2;
+drop table if exists t1, t2, t3, t4;
create table t1 (p int not null primary key, u int not null, o int not null,
unique (u), key(o)) engine=ndb;
create table t2 (p int not null primary key, u int not null, o int not null,
unique (u), key(o)) engine=ndb;
+create table t3 (a int not null primary key, b int not null) engine=ndb;
+create table t4 (c int not null primary key, d int not null) engine=ndb;
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
+insert into t3 values (1,10), (2,10), (3,30), (4, 30);
+insert into t4 values (1,10), (2,10), (3,30), (4, 30);
explain select * from t2 where p NOT IN (select p from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where
@@ -57,5 +60,33 @@ p u
1 1
2 2
3 3
-drop table t1;
-drop table t2;
+select * from t3 where a = any (select c from t4 where c = 1) order by a;
+a b
+1 10
+select * from t3 where a in (select c from t4 where c = 1) order by a;
+a b
+1 10
+select * from t3 where a <> some (select c from t4 where c = 1) order by a;
+a b
+2 10
+3 30
+4 30
+select * from t3 where a > all (select c from t4 where c = 1) order by a;
+a b
+2 10
+3 30
+4 30
+select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a;
+a b
+1 10
+2 10
+3 30
+4 30
+select * from t3 where exists (select * from t4 where c = 1) order by a;
+a b
+1 10
+2 10
+3 30
+4 30
+drop table if exists t1, t2, t3, t4;
+End of 5.1 tests
diff --git a/mysql-test/r/ndb_trigger.result b/mysql-test/r/ndb_trigger.result
index 27f83df70c9..2aeca5db2d3 100644
--- a/mysql-test/r/ndb_trigger.result
+++ b/mysql-test/r/ndb_trigger.result
@@ -1,7 +1,9 @@
-drop table if exists t1, t2, t3;
+drop table if exists t1, t2, t3, t4, t5;
create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb;
create table t2 (op char(1), a int not null, b decimal (63,30));
create table t3 select 1 as i;
+create table t4 (a int not null primary key, b int) engine=ndb;
+create table t5 (a int not null primary key, b int) engine=ndb;
create trigger t1_bu before update on t1 for each row
begin
insert into t2 values ("u", old.a, old.b);
@@ -11,7 +13,19 @@ create trigger t1_bd before delete on t1 for each row
begin
insert into t2 values ("d", old.a, old.b);
end;//
+create trigger t4_au after update on t4
+for each row begin
+update t5 set b = b+1;
+end;
+//
+create trigger t4_ad after delete on t4
+for each row begin
+update t5 set b = b+1;
+end;
+//
insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05);
+insert into t4 values (1,1), (2,2), (3,3), (4, 4);
+insert into t5 values (1,0);
update t1 set a=5 where a != 3;
select * from t1 order by id;
id a b
@@ -115,5 +129,16 @@ select * from t2 order by op, a, b;
op a b
d 1 1.050000000000000000000000000000
d 2 2.050000000000000000000000000000
-drop tables t1, t2, t3;
-End of 5.0 tests
+update t4 set b = 10 where a = 1;
+select * from t5 order by a;
+a b
+1 1
+update t5 set b = 0;
+delete from t4 where a = 1;
+select * from t5 order by a;
+a b
+1 1
+drop trigger t4_au;
+drop trigger t4_ad;
+drop table t1, t2, t3, t4, t5;
+End of 5.1 tests
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index 9e0577f8ae2..432a07df9d0 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -1409,7 +1409,7 @@ select a,b from t1 where b = @arg00;
a b
6 six
execute stmt1 using @arg00;
-ERROR 23000: Duplicate entry '6' for key 1
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
set @arg00=NULL ;
prepare stmt1 from 'insert into t1 values(0, ? )';
execute stmt1 using @arg00;
@@ -1522,7 +1522,7 @@ a b
set @arg00=81 ;
set @arg01=1 ;
execute stmt1 using @arg00, @arg01;
-ERROR 23000: Duplicate entry '82' for key 1
+ERROR 23000: Duplicate entry '82' for key 'PRIMARY'
drop table if exists t2 ;
create table t2 (id int auto_increment primary key)
ENGINE= 'NDB' ;
@@ -1758,31 +1758,31 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` int(1) NOT NULL default '0',
- `param01` bigint(20) default NULL,
- `const02` decimal(2,1) NOT NULL default '0.0',
- `param02` decimal(65,30) default NULL,
- `const03` double NOT NULL default '0',
- `param03` double default NULL,
- `const04` varchar(3) NOT NULL default '',
+ `const01` int(1) NOT NULL DEFAULT '0',
+ `param01` bigint(20) DEFAULT NULL,
+ `const02` decimal(2,1) NOT NULL DEFAULT '0.0',
+ `param02` decimal(65,30) DEFAULT NULL,
+ `const03` double NOT NULL DEFAULT '0',
+ `param03` double DEFAULT NULL,
+ `const04` varchar(3) NOT NULL DEFAULT '',
`param04` longtext,
- `const05` varbinary(3) NOT NULL default '',
+ `const05` varbinary(3) NOT NULL DEFAULT '',
`param05` longblob,
- `const06` varchar(10) NOT NULL default '',
+ `const06` varchar(10) NOT NULL DEFAULT '',
`param06` longtext,
- `const07` date default NULL,
+ `const07` date DEFAULT NULL,
`param07` longblob,
- `const08` varchar(19) NOT NULL default '',
+ `const08` varchar(19) NOT NULL DEFAULT '',
`param08` longtext,
- `const09` datetime default NULL,
+ `const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL default '0',
- `param10` bigint(20) default NULL,
- `const11` int(4) default NULL,
- `param11` bigint(20) default NULL,
- `const12` binary(0) default NULL,
- `param12` bigint(20) default NULL,
- `param13` decimal(65,30) default NULL,
+ `const10` int(10) NOT NULL DEFAULT '0',
+ `param10` bigint(20) DEFAULT NULL,
+ `const11` int(4) DEFAULT NULL,
+ `param11` bigint(20) DEFAULT NULL,
+ `const12` binary(0) DEFAULT NULL,
+ `param12` bigint(20) DEFAULT NULL,
+ `param13` decimal(65,30) DEFAULT NULL,
`param14` longtext,
`param15` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -1912,26 +1912,26 @@ def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
def @arg11 253 67 6 Y 128 30 63
def @arg12 253 67 6 Y 128 30 63
-def @arg13 253 8192 10 Y 128 31 63
-def @arg14 253 8192 19 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 8 Y 128 31 63
+def @arg13 253 16777216 10 Y 128 31 63
+def @arg14 253 16777216 19 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 8 Y 128 31 63
def @arg17 253 20 4 Y 128 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
-def @arg20 253 8192 1 Y 0 31 8
-def @arg21 253 8192 10 Y 0 31 8
-def @arg22 253 8192 30 Y 0 31 8
-def @arg23 253 8192 8 Y 128 31 63
-def @arg24 253 8192 8 Y 0 31 8
-def @arg25 253 8192 4 Y 128 31 63
-def @arg26 253 8192 4 Y 0 31 8
-def @arg27 253 8192 10 Y 128 31 63
-def @arg28 253 8192 10 Y 0 31 8
-def @arg29 253 8192 8 Y 128 31 63
-def @arg30 253 8192 8 Y 0 31 8
-def @arg31 253 8192 3 Y 0 31 8
-def @arg32 253 8192 6 Y 0 31 8
+def @arg20 253 16777216 1 Y 0 31 8
+def @arg21 253 16777216 10 Y 0 31 8
+def @arg22 253 16777216 30 Y 0 31 8
+def @arg23 253 16777216 8 Y 128 31 63
+def @arg24 253 16777216 8 Y 0 31 8
+def @arg25 253 16777216 4 Y 128 31 63
+def @arg26 253 16777216 4 Y 0 31 8
+def @arg27 253 16777216 10 Y 128 31 63
+def @arg28 253 16777216 10 Y 0 31 8
+def @arg29 253 16777216 8 Y 128 31 63
+def @arg30 253 16777216 8 Y 0 31 8
+def @arg31 253 16777216 3 Y 0 31 8
+def @arg32 253 16777216 6 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4,
@@ -1959,26 +1959,26 @@ def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
def @arg11 253 67 0 Y 128 30 63
def @arg12 253 67 0 Y 128 30 63
-def @arg13 253 8192 0 Y 128 31 63
-def @arg14 253 8192 0 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 0 Y 128 31 63
+def @arg13 253 16777216 0 Y 128 31 63
+def @arg14 253 16777216 0 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 0 Y 128 31 63
def @arg17 253 20 0 Y 128 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
-def @arg20 253 8192 0 Y 0 31 8
-def @arg21 253 8192 0 Y 0 31 8
-def @arg22 253 8192 0 Y 0 31 8
-def @arg23 253 8192 0 Y 128 31 63
-def @arg24 253 8192 0 Y 0 31 8
-def @arg25 253 8192 0 Y 128 31 63
-def @arg26 253 8192 0 Y 0 31 8
-def @arg27 253 8192 0 Y 128 31 63
-def @arg28 253 8192 0 Y 0 31 8
-def @arg29 253 8192 0 Y 128 31 63
-def @arg30 253 8192 0 Y 0 31 8
-def @arg31 253 8192 0 Y 0 31 8
-def @arg32 253 8192 0 Y 0 31 8
+def @arg20 253 16777216 0 Y 0 31 8
+def @arg21 253 16777216 0 Y 0 31 8
+def @arg22 253 16777216 0 Y 0 31 8
+def @arg23 253 16777216 0 Y 128 31 63
+def @arg24 253 16777216 0 Y 0 31 8
+def @arg25 253 16777216 0 Y 128 31 63
+def @arg26 253 16777216 0 Y 0 31 8
+def @arg27 253 16777216 0 Y 128 31 63
+def @arg28 253 16777216 0 Y 0 31 8
+def @arg29 253 16777216 0 Y 128 31 63
+def @arg30 253 16777216 0 Y 0 31 8
+def @arg31 253 16777216 0 Y 0 31 8
+def @arg32 253 16777216 0 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
prepare stmt1 from "select
@@ -2009,26 +2009,26 @@ def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
def @arg11 253 67 6 Y 128 30 63
def @arg12 253 67 6 Y 128 30 63
-def @arg13 253 8192 10 Y 128 31 63
-def @arg14 253 8192 19 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 8 Y 128 31 63
+def @arg13 253 16777216 10 Y 128 31 63
+def @arg14 253 16777216 19 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 8 Y 128 31 63
def @arg17 253 20 4 Y 128 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
-def @arg20 253 8192 1 Y 0 31 8
-def @arg21 253 8192 10 Y 0 31 8
-def @arg22 253 8192 30 Y 0 31 8
-def @arg23 253 8192 8 Y 128 31 63
-def @arg24 253 8192 8 Y 0 31 8
-def @arg25 253 8192 4 Y 128 31 63
-def @arg26 253 8192 4 Y 0 31 8
-def @arg27 253 8192 10 Y 128 31 63
-def @arg28 253 8192 10 Y 0 31 8
-def @arg29 253 8192 8 Y 128 31 63
-def @arg30 253 8192 8 Y 0 31 8
-def @arg31 253 8192 3 Y 0 31 8
-def @arg32 253 8192 6 Y 0 31 8
+def @arg20 253 16777216 1 Y 0 31 8
+def @arg21 253 16777216 10 Y 0 31 8
+def @arg22 253 16777216 30 Y 0 31 8
+def @arg23 253 16777216 8 Y 128 31 63
+def @arg24 253 16777216 8 Y 0 31 8
+def @arg25 253 16777216 4 Y 128 31 63
+def @arg26 253 16777216 4 Y 0 31 8
+def @arg27 253 16777216 10 Y 128 31 63
+def @arg28 253 16777216 10 Y 0 31 8
+def @arg29 253 16777216 8 Y 128 31 63
+def @arg30 253 16777216 8 Y 0 31 8
+def @arg31 253 16777216 3 Y 0 31 8
+def @arg32 253 16777216 6 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
set @my_key= 0 ;
@@ -2049,26 +2049,26 @@ def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
def @arg11 253 67 0 Y 128 30 63
def @arg12 253 67 0 Y 128 30 63
-def @arg13 253 8192 0 Y 128 31 63
-def @arg14 253 8192 0 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 0 Y 128 31 63
+def @arg13 253 16777216 0 Y 128 31 63
+def @arg14 253 16777216 0 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 0 Y 128 31 63
def @arg17 253 20 0 Y 128 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
-def @arg20 253 8192 0 Y 0 31 8
-def @arg21 253 8192 0 Y 0 31 8
-def @arg22 253 8192 0 Y 0 31 8
-def @arg23 253 8192 0 Y 128 31 63
-def @arg24 253 8192 0 Y 0 31 8
-def @arg25 253 8192 0 Y 128 31 63
-def @arg26 253 8192 0 Y 0 31 8
-def @arg27 253 8192 0 Y 128 31 63
-def @arg28 253 8192 0 Y 0 31 8
-def @arg29 253 8192 0 Y 128 31 63
-def @arg30 253 8192 0 Y 0 31 8
-def @arg31 253 8192 0 Y 0 31 8
-def @arg32 253 8192 0 Y 0 31 8
+def @arg20 253 16777216 0 Y 0 31 8
+def @arg21 253 16777216 0 Y 0 31 8
+def @arg22 253 16777216 0 Y 0 31 8
+def @arg23 253 16777216 0 Y 128 31 63
+def @arg24 253 16777216 0 Y 0 31 8
+def @arg25 253 16777216 0 Y 128 31 63
+def @arg26 253 16777216 0 Y 0 31 8
+def @arg27 253 16777216 0 Y 128 31 63
+def @arg28 253 16777216 0 Y 0 31 8
+def @arg29 253 16777216 0 Y 128 31 63
+def @arg30 253 16777216 0 Y 0 31 8
+def @arg31 253 16777216 0 Y 0 31 8
+def @arg32 253 16777216 0 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
prepare stmt1 from "select ? := c1 from t9 where c1= 1" ;
@@ -2097,26 +2097,26 @@ def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
def @arg11 253 67 6 Y 128 30 63
def @arg12 253 67 6 Y 128 30 63
-def @arg13 253 8192 10 Y 128 31 63
-def @arg14 253 8192 19 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 8 Y 128 31 63
+def @arg13 253 16777216 10 Y 128 31 63
+def @arg14 253 16777216 19 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 8 Y 128 31 63
def @arg17 253 20 4 Y 128 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
-def @arg20 253 8192 1 Y 0 31 8
-def @arg21 253 8192 10 Y 0 31 8
-def @arg22 253 8192 30 Y 0 31 8
-def @arg23 253 8192 8 Y 128 31 63
-def @arg24 253 8192 8 Y 0 31 8
-def @arg25 253 8192 4 Y 128 31 63
-def @arg26 253 8192 4 Y 0 31 8
-def @arg27 253 8192 10 Y 128 31 63
-def @arg28 253 8192 10 Y 0 31 8
-def @arg29 253 8192 8 Y 128 31 63
-def @arg30 253 8192 8 Y 0 31 8
-def @arg31 253 8192 3 Y 0 31 8
-def @arg32 253 8192 6 Y 0 31 8
+def @arg20 253 16777216 1 Y 0 31 8
+def @arg21 253 16777216 10 Y 0 31 8
+def @arg22 253 16777216 30 Y 0 31 8
+def @arg23 253 16777216 8 Y 128 31 63
+def @arg24 253 16777216 8 Y 0 31 8
+def @arg25 253 16777216 4 Y 128 31 63
+def @arg26 253 16777216 4 Y 0 31 8
+def @arg27 253 16777216 10 Y 128 31 63
+def @arg28 253 16777216 10 Y 0 31 8
+def @arg29 253 16777216 8 Y 128 31 63
+def @arg30 253 16777216 8 Y 0 31 8
+def @arg31 253 16777216 3 Y 0 31 8
+def @arg32 253 16777216 6 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2141,26 +2141,26 @@ def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
def @arg11 253 67 0 Y 128 30 63
def @arg12 253 67 0 Y 128 30 63
-def @arg13 253 8192 0 Y 128 31 63
-def @arg14 253 8192 0 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 0 Y 128 31 63
+def @arg13 253 16777216 0 Y 128 31 63
+def @arg14 253 16777216 0 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 0 Y 128 31 63
def @arg17 253 20 0 Y 128 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
-def @arg20 253 8192 0 Y 0 31 8
-def @arg21 253 8192 0 Y 0 31 8
-def @arg22 253 8192 0 Y 0 31 8
-def @arg23 253 8192 0 Y 128 31 63
-def @arg24 253 8192 0 Y 0 31 8
-def @arg25 253 8192 0 Y 128 31 63
-def @arg26 253 8192 0 Y 0 31 8
-def @arg27 253 8192 0 Y 128 31 63
-def @arg28 253 8192 0 Y 0 31 8
-def @arg29 253 8192 0 Y 128 31 63
-def @arg30 253 8192 0 Y 0 31 8
-def @arg31 253 8192 0 Y 0 31 8
-def @arg32 253 8192 0 Y 0 31 8
+def @arg20 253 16777216 0 Y 0 31 8
+def @arg21 253 16777216 0 Y 0 31 8
+def @arg22 253 16777216 0 Y 0 31 8
+def @arg23 253 16777216 0 Y 128 31 63
+def @arg24 253 16777216 0 Y 0 31 8
+def @arg25 253 16777216 0 Y 128 31 63
+def @arg26 253 16777216 0 Y 0 31 8
+def @arg27 253 16777216 0 Y 128 31 63
+def @arg28 253 16777216 0 Y 0 31 8
+def @arg29 253 16777216 0 Y 128 31 63
+def @arg30 253 16777216 0 Y 0 31 8
+def @arg31 253 16777216 0 Y 0 31 8
+def @arg32 253 16777216 0 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
@@ -2187,26 +2187,26 @@ def @arg09 253 23 1 Y 128 31 63
def @arg10 253 23 1 Y 128 31 63
def @arg11 253 67 6 Y 128 30 63
def @arg12 253 67 6 Y 128 30 63
-def @arg13 253 8192 10 Y 128 31 63
-def @arg14 253 8192 19 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 8 Y 128 31 63
+def @arg13 253 16777216 10 Y 128 31 63
+def @arg14 253 16777216 19 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 8 Y 128 31 63
def @arg17 253 20 4 Y 128 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
-def @arg20 253 8192 1 Y 0 31 8
-def @arg21 253 8192 10 Y 0 31 8
-def @arg22 253 8192 30 Y 0 31 8
-def @arg23 253 8192 8 Y 128 31 63
-def @arg24 253 8192 8 Y 0 31 8
-def @arg25 253 8192 4 Y 128 31 63
-def @arg26 253 8192 4 Y 0 31 8
-def @arg27 253 8192 10 Y 128 31 63
-def @arg28 253 8192 10 Y 0 31 8
-def @arg29 253 8192 8 Y 128 31 63
-def @arg30 253 8192 8 Y 0 31 8
-def @arg31 253 8192 3 Y 0 31 8
-def @arg32 253 8192 6 Y 0 31 8
+def @arg20 253 16777216 1 Y 0 31 8
+def @arg21 253 16777216 10 Y 0 31 8
+def @arg22 253 16777216 30 Y 0 31 8
+def @arg23 253 16777216 8 Y 128 31 63
+def @arg24 253 16777216 8 Y 0 31 8
+def @arg25 253 16777216 4 Y 128 31 63
+def @arg26 253 16777216 4 Y 0 31 8
+def @arg27 253 16777216 10 Y 128 31 63
+def @arg28 253 16777216 10 Y 0 31 8
+def @arg29 253 16777216 8 Y 128 31 63
+def @arg30 253 16777216 8 Y 0 31 8
+def @arg31 253 16777216 3 Y 0 31 8
+def @arg32 253 16777216 6 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday
set @my_key= 0 ;
@@ -2225,26 +2225,26 @@ def @arg09 253 23 0 Y 128 31 63
def @arg10 253 23 0 Y 128 31 63
def @arg11 253 67 0 Y 128 30 63
def @arg12 253 67 0 Y 128 30 63
-def @arg13 253 8192 0 Y 128 31 63
-def @arg14 253 8192 0 Y 128 31 63
-def @arg15 253 8192 19 Y 128 31 63
-def @arg16 253 8192 0 Y 128 31 63
+def @arg13 253 16777216 0 Y 128 31 63
+def @arg14 253 16777216 0 Y 128 31 63
+def @arg15 253 16777216 19 Y 128 31 63
+def @arg16 253 16777216 0 Y 128 31 63
def @arg17 253 20 0 Y 128 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
-def @arg20 253 8192 0 Y 0 31 8
-def @arg21 253 8192 0 Y 0 31 8
-def @arg22 253 8192 0 Y 0 31 8
-def @arg23 253 8192 0 Y 128 31 63
-def @arg24 253 8192 0 Y 0 31 8
-def @arg25 253 8192 0 Y 128 31 63
-def @arg26 253 8192 0 Y 0 31 8
-def @arg27 253 8192 0 Y 128 31 63
-def @arg28 253 8192 0 Y 0 31 8
-def @arg29 253 8192 0 Y 128 31 63
-def @arg30 253 8192 0 Y 0 31 8
-def @arg31 253 8192 0 Y 0 31 8
-def @arg32 253 8192 0 Y 0 31 8
+def @arg20 253 16777216 0 Y 0 31 8
+def @arg21 253 16777216 0 Y 0 31 8
+def @arg22 253 16777216 0 Y 0 31 8
+def @arg23 253 16777216 0 Y 128 31 63
+def @arg24 253 16777216 0 Y 0 31 8
+def @arg25 253 16777216 0 Y 128 31 63
+def @arg26 253 16777216 0 Y 0 31 8
+def @arg27 253 16777216 0 Y 128 31 63
+def @arg28 253 16777216 0 Y 0 31 8
+def @arg29 253 16777216 0 Y 128 31 63
+def @arg30 253 16777216 0 Y 0 31 8
+def @arg31 253 16777216 0 Y 0 31 8
+def @arg32 253 16777216 0 Y 0 31 8
@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
prepare stmt1 from "select c1 into ? from t9 where c1= 1" ;
diff --git a/mysql-test/r/rpl_ndb_dd_advance.result b/mysql-test/r/rpl_ndb_dd_advance.result
index c52fe7114c4..a4614b4b484 100644
--- a/mysql-test/r/rpl_ndb_dd_advance.result
+++ b/mysql-test/r/rpl_ndb_dd_advance.result
@@ -70,7 +70,7 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`c1`),
KEY `t1_i` (`c2`,`c3`),
KEY `c5` (`c5`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
**** Show first set of ALTERs on SLAVE ****
SHOW CREATE TABLE t1;
Table Create Table
@@ -83,7 +83,7 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`c1`),
KEY `t1_i` (`c2`,`c3`),
KEY `c5` (`c5`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
**** Second set of alters test 1 ****
ALTER TABLE t1 RENAME t2;
ALTER TABLE t2 DROP INDEX c5;
@@ -102,7 +102,7 @@ t1 CREATE TABLE `t1` (
`c5` double DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `t1_i` (`c2`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
**** Show second set of ALTERs on SLAVE ****
SHOW CREATE TABLE t1;
Table Create Table
@@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` (
`c5` double DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `t1_i` (`c2`,`c3`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
**** Third and last set of alters for test1 ****
ALTER TABLE t1 CHANGE c1 c1 DOUBLE;
ALTER TABLE t1 CHANGE c2 c2 DECIMAL(10,2);
@@ -136,7 +136,7 @@ t1 CREATE TABLE `t1` (
`c5` double DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `t1_i` (`c2`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
c1 c2 c3 c5
1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL
@@ -154,7 +154,7 @@ t1 CREATE TABLE `t1` (
`c5` double DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `t1_i` (`c2`)
-) ENGINE=ndbcluster DEFAULT CHARSET=latin1
+) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SELECT * FROM t1 where c1 = 1;
c1 c2 c3 c5
1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 1c7ac8f6dba..ce7bb345aad 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -21,7 +21,6 @@ ndb_restore_partition : Problem with cluster/def/schema table that is in std_
rpl_ndb_sync : Problem with cluster/def/schema table that is in std_data/ndb_backup51; Pekka will schdule this to someone
partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table
-ps_7ndb : BUG#18950 2006-02-16 jmiller create table like does not obtain LOCK_open
rpl_ndb_2innodb : BUG#19227 2006-04-20 pekka pk delete apparently not replicated
rpl_ndb_2myisam : BUG#19227 Seems to pass currently
rpl_ndb_dd_partitions : BUG#19259 2006-04-21 rpl_ndb_dd_partitions fails on s/AMD
@@ -34,8 +33,8 @@ synchronization : Bug#24529 Test 'synchronization' fails on Mac pushb
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events
-ndb_binlog_discover : bug#21806 2006-08-24
-ndb_autodiscover3 : bug#21806
+#ndb_binlog_discover : bug#21806 2006-08-24
+#ndb_autodiscover3 : bug#21806
flush2 : Bug#24805 Pushbuild can't handle test with --disable-log-bin
mysql_upgrade : Bug#25074 mysql_upgrade gives inconsisten results
diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test
index fde9f1479f8..a7b52d54710 100644
--- a/mysql-test/t/ndb_alter_table.test
+++ b/mysql-test/t/ndb_alter_table.test
@@ -410,3 +410,30 @@ alter table t2 rename t1;
insert into t1 (b) values (401),(402),(403);
select * from t1 where a = 12;
drop table t1;
+
+# some other ALTER combinations
+# add/drop pk
+create table t1 (a int not null, b varchar(10)) engine=ndb;
+show index from t1;
+alter table t1 add primary key (a);
+show index from t1;
+alter table t1 drop primary key;
+show index from t1;
+drop table t1;
+
+# alter .. alter
+create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb;
+show create table t1;
+alter table t1 alter b set default 1;
+show create table t1;
+drop table t1;
+
+# alter .. order by
+create table t1 (a int not null, b int not null) engine=ndb;
+insert into t1 values (1, 300), (2, 200), (3, 100);
+select * from t1 order by a;
+alter table t1 order by b;
+select * from t1 order by b;
+drop table t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test
index 3348a94c044..8541c0ac0c5 100644
--- a/mysql-test/t/ndb_basic.test
+++ b/mysql-test/t/ndb_basic.test
@@ -747,4 +747,57 @@ select * from t1 order by a;
select * from t2 order by a;
drop table t1, t2;
+# create table if not exists
+--disable_warnings
+create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb;
+create table if not exists t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb;
+--enable_warnings
+
+# create like
+create table t2 like t1;
+
+# multi rename
+rename table t1 to t10, t2 to t20;
+drop table t10,t20;
+
+# delete
+create table t1 (a int not null primary key, b int not null) engine=ndb;
+create table t2 (a int not null primary key, b int not null) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,30);
+insert into t2 values (1,10), (2,20), (3,30);
+select * from t1 order by a;
+delete from t1 where a > 0 order by a desc limit 1;
+select * from t1 order by a;
+delete from t1,t2 using t1,t2 where t1.a = t2.a;
+select * from t2 order by a;
+drop table t1,t2;
+
+# insert ignore
+create table t1 (a int not null primary key, b int not null) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,30);
+--error 1062
+insert into t1 set a=1, b=100;
+insert ignore into t1 set a=1, b=100;
+select * from t1 order by a;
+insert into t1 set a=1, b=1000 on duplicate key update b=b+1;
+select * from t1 order by a;
+drop table t1;
+
+# update
+create table t1 (a int not null primary key, b int not null) engine=ndb;
+create table t2 (c int not null primary key, d int not null) engine=ndb;
+insert into t1 values (1,10), (2,10), (3,30), (4, 30);
+insert into t2 values (1,10), (2,10), (3,30), (4, 30);
+--error 1062
+update t1 set a = 1 where a = 3;
+select * from t1 order by a;
+update t1 set b = 1 where a > 1 order by a desc limit 1;
+select * from t1 order by a;
+--error 1062
+update t1,t2 set a = 1, c = 1 where a = 3 and c = 3;
+select * from t1 order by a;
+update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3;
+select * from t1 order by a;
+drop table t1,t2;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/ndb_cursor.test b/mysql-test/t/ndb_cursor.test
new file mode 100644
index 00000000000..406f8629cfe
--- /dev/null
+++ b/mysql-test/t/ndb_cursor.test
@@ -0,0 +1,47 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+--enable_warnings
+
+create table t1 (
+ a int not null primary key,
+ b int not null
+) engine=ndb;
+
+create table t2 (
+ a int not null primary key,
+ b int not null
+) engine=ndb;
+
+insert into t1 values (1,10), (2,20), (3,30), (4, 40);
+
+delimiter //;
+create procedure test_cursor ()
+begin
+ declare done int default 0;
+ declare temp_a int;
+ declare temp_b int;
+ declare cur1 cursor for select a,b from t1;
+ declare continue handler for sqlstate '02000' set done = 1;
+ open cur1;
+ repeat
+ fetch cur1 into temp_a, temp_b;
+ if not done then
+ insert into t2 values (temp_a, temp_b);
+ end if;
+ until done end repeat;
+ close cur1;
+end;
+//
+delimiter ;//
+
+select * from t2 order by a;
+call test_cursor();
+select * from t2 order by a;
+drop procedure test_cursor;
+drop table t1,t2;
+
+--echo end of 5.1 tests
diff --git a/mysql-test/t/ndb_dd_alter.test b/mysql-test/t/ndb_dd_alter.test
index 4eb76fc1ad6..6a9bdb79f6f 100644
--- a/mysql-test/t/ndb_dd_alter.test
+++ b/mysql-test/t/ndb_dd_alter.test
@@ -156,8 +156,12 @@ enable_query_log;
SELECT * FROM test.t1 ORDER BY a1;
+SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
+
ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE;
+SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
+
let $1=20;
disable_query_log;
while ($1)
diff --git a/mysql-test/t/ndb_dd_ddl.test b/mysql-test/t/ndb_dd_ddl.test
index 1a470d52c6c..aa692385b07 100644
--- a/mysql-test/t/ndb_dd_ddl.test
+++ b/mysql-test/t/ndb_dd_ddl.test
@@ -270,11 +270,18 @@ ADD DATAFILE 'datafile2.dat'
INITIAL_SIZE 1M
ENGINE NDB;
+--error 1005
+CREATE TABLE t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE MEMORY
+ENGINE NDB;
+
CREATE TABLE t1
(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
TABLESPACE ts1 STORAGE DISK
ENGINE NDB;
+
CREATE INDEX b_i on t1(b);
CREATE INDEX bc_i on t1(b, c);
@@ -351,4 +358,6 @@ engine ndb;
drop table t1;
+
+
# End 5.1 test
diff --git a/mysql-test/t/ndb_dd_disk2memory.test b/mysql-test/t/ndb_dd_disk2memory.test
index 0f819b54fb2..5975f44e087 100644
--- a/mysql-test/t/ndb_dd_disk2memory.test
+++ b/mysql-test/t/ndb_dd_disk2memory.test
@@ -111,7 +111,7 @@ SHOW CREATE TABLE test.t1;
ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK
ENGINE=NDB;
SHOW CREATE TABLE test.t2;
-ALTER TABLE test.t1 ENGINE=NDBCLUSTER;
+ALTER TABLE test.t1 STORAGE MEMORY ENGINE=NDBCLUSTER;
SHOW CREATE TABLE test.t1;
--echo
######################### End Test Section 2 #################
diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test
index a1fd432a29a..8f1a4e35ece 100644
--- a/mysql-test/t/ndb_index_unique.test
+++ b/mysql-test/t/ndb_index_unique.test
@@ -89,6 +89,14 @@ delete from t2 where a = 1;
insert into t2 values(8, 2, 3);
select * from t2 order by a;
+# Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld
+create unique index bi using hash on t2(b);
+-- error 1062
+insert into t2 values(9, 3, 1);
+alter table t2 drop index bi;
+insert into t2 values(9, 3, 1);
+select * from t2 order by a;
+
drop table t2;
CREATE TABLE t2 (
diff --git a/mysql-test/t/ndb_read_multi_range.test b/mysql-test/t/ndb_read_multi_range.test
index 8cdba49fb92..c9059bcbd6b 100644
--- a/mysql-test/t/ndb_read_multi_range.test
+++ b/mysql-test/t/ndb_read_multi_range.test
@@ -257,3 +257,18 @@ group by c
order by c;
DROP TABLE t1, t11, t12, t21, t22;
+
+# bug#19956
+CREATE TABLE t1 (id varchar(255) NOT NULL,
+ tag int(11) NOT NULL,
+ doc text NOT NULL,
+ type varchar(150) NOT NULL,
+ modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (id)
+ ) ENGINE=ndbcluster;
+
+INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP);
+SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka');
+SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila');
+
+DROP TABLE t1;
diff --git a/mysql-test/t/ndb_sp.test b/mysql-test/t/ndb_sp.test
new file mode 100644
index 00000000000..b833869cad0
--- /dev/null
+++ b/mysql-test/t/ndb_sp.test
@@ -0,0 +1,42 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (
+ a int not null primary key,
+ b int not null
+) engine=ndb;
+insert into t1 values (1,10), (2,20), (3,100), (4, 100);
+
+delimiter //;
+create procedure test_proc1 (in var_in int)
+begin
+ select * from t1 where a = var_in;
+end;
+create procedure test_proc2 (out var_out int)
+begin
+ select b from t1 where a = 1 into var_out;
+end;
+create procedure test_proc3 (inout var_inout int)
+begin
+ select b from t1 where a = var_inout into var_inout;
+end;
+//
+delimiter ;//
+call test_proc1(1);
+call test_proc2(@test_var);
+select @test_var;
+set @test_var = 1;
+call test_proc3(@test_var);
+select @test_var;
+alter procedure test_proc1 comment 'new comment';
+show create procedure test_proc1;
+drop procedure test_proc1;
+drop procedure test_proc2;
+drop procedure test_proc3;
+drop table t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test
index 9cf6527dd98..6282c31c922 100644
--- a/mysql-test/t/ndb_subquery.test
+++ b/mysql-test/t/ndb_subquery.test
@@ -2,8 +2,7 @@
-- source include/not_embedded.inc
--disable_warnings
-drop table if exists t1;
-drop table if exists t2;
+drop table if exists t1, t2, t3, t4;
--enable_warnings
##########
@@ -14,8 +13,13 @@ unique (u), key(o)) engine=ndb;
create table t2 (p int not null primary key, u int not null, o int not null,
unique (u), key(o)) engine=ndb;
+create table t3 (a int not null primary key, b int not null) engine=ndb;
+create table t4 (c int not null primary key, d int not null) engine=ndb;
+
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
+insert into t3 values (1,10), (2,10), (3,30), (4, 30);
+insert into t4 values (1,10), (2,10), (3,30), (4, 30);
# Use pk
--replace_column 9 #
@@ -63,7 +67,13 @@ where t1.u = t2.u
select * from t2 order by 1;
-drop table t1;
-drop table t2;
+select * from t3 where a = any (select c from t4 where c = 1) order by a;
+select * from t3 where a in (select c from t4 where c = 1) order by a;
+select * from t3 where a <> some (select c from t4 where c = 1) order by a;
+select * from t3 where a > all (select c from t4 where c = 1) order by a;
+select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a;
+select * from t3 where exists (select * from t4 where c = 1) order by a;
+drop table if exists t1, t2, t3, t4;
+--echo End of 5.1 tests
diff --git a/mysql-test/t/ndb_trigger.test b/mysql-test/t/ndb_trigger.test
index 2521ef17842..7a4e58033a9 100644
--- a/mysql-test/t/ndb_trigger.test
+++ b/mysql-test/t/ndb_trigger.test
@@ -14,13 +14,15 @@
#
--disable_warnings
-drop table if exists t1, t2, t3;
+drop table if exists t1, t2, t3, t4, t5;
--enable_warnings
create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb;
create table t2 (op char(1), a int not null, b decimal (63,30));
create table t3 select 1 as i;
-
+create table t4 (a int not null primary key, b int) engine=ndb;
+create table t5 (a int not null primary key, b int) engine=ndb;
+
delimiter //;
create trigger t1_bu before update on t1 for each row
begin
@@ -31,8 +33,21 @@ create trigger t1_bd before delete on t1 for each row
begin
insert into t2 values ("d", old.a, old.b);
end;//
+create trigger t4_au after update on t4
+ for each row begin
+ update t5 set b = b+1;
+ end;
+//
+create trigger t4_ad after delete on t4
+ for each row begin
+ update t5 set b = b+1;
+ end;
+//
delimiter ;//
+
insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05);
+insert into t4 values (1,1), (2,2), (3,3), (4, 4);
+insert into t5 values (1,0);
# Check that usual update works as it should
update t1 set a=5 where a != 3;
@@ -86,7 +101,14 @@ insert into t1 values (3, 1, 1.05), (5, 2, 2.05);
load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (id, a);
select * from t1 order by id;
select * from t2 order by op, a, b;
+update t4 set b = 10 where a = 1;
+select * from t5 order by a;
+update t5 set b = 0;
+delete from t4 where a = 1;
+select * from t5 order by a;
+drop trigger t4_au;
+drop trigger t4_ad;
-drop tables t1, t2, t3;
+drop table t1, t2, t3, t4, t5;
---echo End of 5.0 tests
+--echo End of 5.1 tests
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index a7a1a0536c5..ef9a4e5720a 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -133,7 +133,6 @@ static uint ndbcluster_alter_table_flags(uint flags)
}
static int ndbcluster_inited= 0;
-int ndbcluster_util_inited= 0;
static Ndb* g_ndb= NULL;
Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
@@ -157,6 +156,7 @@ static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const NDBTAB *,
// Util thread variables
pthread_t ndb_util_thread;
+int ndb_util_thread_running= 0;
pthread_mutex_t LOCK_ndb_util_thread;
pthread_cond_t COND_ndb_util_thread;
pthread_handler_t ndb_util_thread_func(void *arg);
@@ -3477,8 +3477,9 @@ int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key,
{
if (m_active_cursor && (error= close_scan()))
DBUG_RETURN(error);
- DBUG_RETURN(pk_read(start_key->key, start_key->length, buf,
- part_spec.start_part));
+ error= pk_read(start_key->key, start_key->length, buf,
+ part_spec.start_part);
+ DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error);
}
break;
case UNIQUE_ORDERED_INDEX:
@@ -3489,7 +3490,9 @@ int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key,
{
if (m_active_cursor && (error= close_scan()))
DBUG_RETURN(error);
- DBUG_RETURN(unique_index_read(start_key->key, start_key->length, buf));
+
+ error= unique_index_read(start_key->key, start_key->length, buf);
+ DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error);
}
else if (type == UNIQUE_INDEX)
DBUG_RETURN(unique_index_scan(key_info,
@@ -4803,7 +4806,7 @@ int ha_ndbcluster::create(const char *name,
if ((my_errno= create_ndb_column(col, field, info)))
DBUG_RETURN(my_errno);
- if (info->store_on_disk || getenv("NDB_DEFAULT_DISK"))
+ if (info->storage_media == HA_SM_DISK || getenv("NDB_DEFAULT_DISK"))
col.setStorageType(NdbDictionary::Column::StorageTypeDisk);
else
col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
@@ -4823,7 +4826,7 @@ int ha_ndbcluster::create(const char *name,
NdbDictionary::Column::StorageTypeMemory);
}
- if (info->store_on_disk)
+ if (info->storage_media == HA_SM_DISK)
{
if (info->tablespace)
tab.setTablespace(info->tablespace);
@@ -4832,8 +4835,18 @@ int ha_ndbcluster::create(const char *name,
}
else if (info->tablespace)
{
+ if (info->storage_media == HA_SM_MEMORY)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ ER(ER_ILLEGAL_HA_CREATE_OPTION),
+ ndbcluster_hton_name,
+ "TABLESPACE currently only supported for "
+ "STORAGE DISK");
+ DBUG_RETURN(HA_ERR_UNSUPPORTED);
+ }
tab.setTablespace(info->tablespace);
- info->store_on_disk = true; //if use tablespace, that also means store on disk
+ info->storage_media = HA_SM_DISK; //if use tablespace, that also means store on disk
}
// No primary key, create shadow key as 64 bit, auto increment
@@ -6716,6 +6729,12 @@ static int ndbcluster_init(void *p)
goto ndbcluster_init_error;
}
+ /* Wait for the util thread to start */
+ pthread_mutex_lock(&LOCK_ndb_util_thread);
+ while (!ndb_util_thread_running)
+ pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread);
+ pthread_mutex_unlock(&LOCK_ndb_util_thread);
+
ndbcluster_inited= 1;
DBUG_RETURN(FALSE);
@@ -6738,6 +6757,27 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
if (!ndbcluster_inited)
DBUG_RETURN(0);
+ ndbcluster_inited= 0;
+
+ /* wait for util thread to finish */
+ pthread_mutex_lock(&LOCK_ndb_util_thread);
+ if (ndb_util_thread_running > 0)
+ {
+ pthread_cond_signal(&COND_ndb_util_thread);
+ pthread_mutex_unlock(&LOCK_ndb_util_thread);
+
+ pthread_mutex_lock(&LOCK_ndb_util_thread);
+ while (ndb_util_thread_running > 0)
+ {
+ struct timespec abstime;
+ set_timespec(abstime, 1);
+ pthread_cond_timedwait(&COND_ndb_util_thread,
+ &LOCK_ndb_util_thread,
+ &abstime);
+ }
+ }
+ pthread_mutex_unlock(&LOCK_ndb_util_thread);
+
#ifdef HAVE_NDB_BINLOG
{
@@ -6784,7 +6824,6 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type)
pthread_mutex_destroy(&ndbcluster_mutex);
pthread_mutex_destroy(&LOCK_ndb_util_thread);
pthread_cond_destroy(&COND_ndb_util_thread);
- ndbcluster_inited= 0;
DBUG_RETURN(0);
}
@@ -8330,6 +8369,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
{
thd->cleanup();
delete thd;
+ ndb_util_thread_running= 0;
DBUG_RETURN(NULL);
}
thd->init_for_queries();
@@ -8342,6 +8382,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
thd->main_security_ctx.priv_user = 0;
thd->current_stmt_binlog_row_based= TRUE; // If in mixed mode
+ ndb_util_thread_running= 1;
+ pthread_cond_signal(&COND_ndb_util_thread);
+
/*
wait for mysql server to start
*/
@@ -8350,8 +8393,6 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
pthread_cond_wait(&COND_server_started, &LOCK_server_started);
pthread_mutex_unlock(&LOCK_server_started);
- ndbcluster_util_inited= 1;
-
/*
Wait for cluster to start
*/
@@ -8533,6 +8574,9 @@ ndb_util_thread_end:
net_end(&thd->net);
thd->cleanup();
delete thd;
+ pthread_mutex_lock(&LOCK_ndb_util_thread);
+ ndb_util_thread_running= 0;
+ pthread_mutex_unlock(&LOCK_ndb_util_thread);
DBUG_PRINT("exit", ("ndb_util_thread"));
my_thread_end();
pthread_exit(0);
@@ -9945,7 +9989,7 @@ int ha_ndbcluster::generate_scan_filter_from_key(NdbScanOperation *op,
/*
get table space info for SHOW CREATE TABLE
*/
-char* ha_ndbcluster::get_tablespace_name(THD *thd)
+char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name, uint name_len)
{
Ndb *ndb= check_ndb_in_thd(thd);
NDBDICT *ndbdict= ndb->getDictionary();
@@ -9963,7 +10007,13 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd)
ndberr= ndbdict->getNdbError();
if(ndberr.classification != NdbError::NoError)
goto err;
- return (my_strdup(ts.getName(), MYF(0)));
+ if (name)
+ {
+ strxnmov(name, name_len, ts.getName(), NullS);
+ return name;
+ }
+ else
+ return (my_strdup(ts.getName(), MYF(0)));
}
err:
if (ndberr.status == NdbError::TemporaryError)
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index c4bf5901386..50f24c7a4cf 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -823,7 +823,7 @@ private:
uint set_up_partition_info(partition_info *part_info,
TABLE *table,
void *tab);
- char* get_tablespace_name(THD *thd);
+ char* get_tablespace_name(THD *thd, char *name, uint name_len);
int set_range_data(void *tab, partition_info* part_info);
int set_list_data(void *tab, partition_info* part_info);
int complemented_read(const byte *old_data, byte *new_data,
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index 490114bf4a9..731c0d97cfe 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -81,6 +81,8 @@ THD *injector_thd= 0;
static Ndb *injector_ndb= 0;
static Ndb *schema_ndb= 0;
+static int ndbcluster_binlog_inited= 0;
+
/*
Mutex and condition used for interacting between client sql thread
and injector thread
@@ -558,29 +560,28 @@ ndbcluster_binlog_log_query(handlerton *hton, THD *thd, enum_binlog_command binl
DBUG_VOID_RETURN;
}
+
/*
- End use of the NDB Cluster table handler
- - free all global variables allocated by
- ndbcluster_init()
+ End use of the NDB Cluster binlog
+ - wait for binlog thread to shutdown
*/
static int ndbcluster_binlog_end(THD *thd)
{
- DBUG_ENTER("ndb_binlog_end");
+ DBUG_ENTER("ndbcluster_binlog_end");
- if (!ndbcluster_util_inited)
+ if (!ndbcluster_binlog_inited)
DBUG_RETURN(0);
-
- // Kill ndb utility thread
- (void) pthread_mutex_lock(&LOCK_ndb_util_thread);
- DBUG_PRINT("exit",("killing ndb util thread: %lx", ndb_util_thread));
- (void) pthread_cond_signal(&COND_ndb_util_thread);
- (void) pthread_mutex_unlock(&LOCK_ndb_util_thread);
+ ndbcluster_binlog_inited= 0;
#ifdef HAVE_NDB_BINLOG
/* wait for injector thread to finish */
+ pthread_mutex_lock(&injector_mutex);
if (ndb_binlog_thread_running > 0)
{
+ pthread_cond_signal(&injector_cond);
+ pthread_mutex_unlock(&injector_mutex);
+
pthread_mutex_lock(&injector_mutex);
while (ndb_binlog_thread_running > 0)
{
@@ -588,8 +589,9 @@ static int ndbcluster_binlog_end(THD *thd)
set_timespec(abstime, 1);
pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime);
}
- pthread_mutex_unlock(&injector_mutex);
}
+ pthread_mutex_unlock(&injector_mutex);
+
/* remove all shares */
{
@@ -617,8 +619,10 @@ static int ndbcluster_binlog_end(THD *thd)
}
pthread_mutex_unlock(&ndbcluster_mutex);
}
+
+ pthread_mutex_destroy(&injector_mutex);
+ pthread_cond_destroy(&injector_cond);
#endif
- ndbcluster_util_inited= 0;
DBUG_RETURN(0);
}
@@ -2286,31 +2290,21 @@ int ndbcluster_binlog_start()
DBUG_RETURN(-1);
}
- /*
- Wait for the ndb injector thread to finish starting up.
- */
+ ndbcluster_binlog_inited= 1;
+
+ /* Wait for the injector thread to start */
pthread_mutex_lock(&injector_mutex);
while (!ndb_binlog_thread_running)
pthread_cond_wait(&injector_cond, &injector_mutex);
pthread_mutex_unlock(&injector_mutex);
-
+
if (ndb_binlog_thread_running < 0)
DBUG_RETURN(-1);
+
DBUG_RETURN(0);
}
-static void ndbcluster_binlog_close_connection(THD *thd)
-{
- DBUG_ENTER("ndbcluster_binlog_close_connection");
- const char *save_info= thd->proc_info;
- thd->proc_info= "ndbcluster_binlog_close_connection";
- do_ndbcluster_binlog_close_connection= BCCC_exit;
- while (ndb_binlog_thread_running > 0)
- sleep(1);
- thd->proc_info= save_info;
- DBUG_VOID_RETURN;
-}
/**************************************************************
Internal helper functions for creating/dropping ndb events
@@ -3542,7 +3536,7 @@ restart:
if (abort_loop)
goto err;
schema_res= s_ndb->pollEvents(100, &schema_gci);
- } while (ndb_latest_received_binlog_epoch == schema_gci);
+ } while (schema_gci == 0 || ndb_latest_received_binlog_epoch == schema_gci);
if (ndb_binlog_running)
{
Uint64 gci= i_ndb->getLatestGCI();
@@ -3953,15 +3947,12 @@ restart:
goto restart;
}
err:
+ sql_print_information("Stopping Cluster Binlog");
DBUG_PRINT("info",("Shutting down cluster binlog thread"));
thd->proc_info= "Shutting down";
close_thread_tables(thd);
pthread_mutex_lock(&injector_mutex);
/* don't mess with the injector_ndb anymore from other threads */
- uint ndb_obj_cnt= 1; // g_ndb
- ndb_obj_cnt+= injector_ndb == 0 ? 0 : 1;
- ndb_obj_cnt+= schema_ndb == 0 ? 0 : 1;
- ndb_obj_cnt+= ndbcluster_util_inited ? 1 : 0;
injector_thd= 0;
injector_ndb= 0;
p_latest_trans_gci= 0;
@@ -3969,29 +3960,6 @@ err:
pthread_mutex_unlock(&injector_mutex);
thd->db= 0; // as not to try to free memory
- if (!ndb_extra_logging)
- sql_print_information("Stopping Cluster Binlog");
- else
- sql_print_information("Stopping Cluster Binlog: %u(%u)",
- g_ndb_cluster_connection->get_active_ndb_objects(),
- ndb_obj_cnt);
-
- /**
- * Add extra wait loop to make user "user" ndb-object go away...
- * otherwise user thread can have ongoing SUB_DATA
- */
- int sleep_cnt= 0;
- while (sleep_cnt < 300 &&
- g_ndb_cluster_connection->get_active_ndb_objects() > ndb_obj_cnt)
- {
- my_sleep(10000); // 10ms
- sleep_cnt++;
- }
- if (ndb_extra_logging)
- sql_print_information("Stopping Cluster Binlog: waited %ums %u(%u)",
- 10*sleep_cnt, g_ndb_cluster_connection->get_active_ndb_objects(),
- ndb_obj_cnt);
-
if (ndb_apply_status_share)
{
free_share(&ndb_apply_status_share);
@@ -4047,8 +4015,8 @@ err:
hash_free(&ndb_schema_objects);
- // Placed here to avoid a memory leak; TODO: check if needed
net_end(&thd->net);
+ thd->cleanup();
delete thd;
ndb_binlog_thread_running= -1;
diff --git a/sql/handler.h b/sql/handler.h
index f13aa972400..592159ec428 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -763,7 +763,7 @@ typedef struct st_ha_create_information
bool table_existed; /* 1 in create if table existed */
bool frm_only; /* 1 if no ha_create_table() */
bool varchar; /* 1 if table has a VARCHAR */
- bool store_on_disk; /* 1 if table stored on disk */
+ enum ha_storage_media storage_media; /* DEFAULT, DISK or MEMORY */
} HA_CREATE_INFO;
@@ -1409,7 +1409,7 @@ public:
{ return FALSE; }
virtual char* get_foreign_key_create_info()
{ return(NULL);} /* gets foreign key create string from InnoDB */
- virtual char* get_tablespace_name(THD *thd)
+ virtual char* get_tablespace_name(THD *thd, char *name, uint name_len)
{ return(NULL);} /* gets tablespace name from handler */
/* used in ALTER TABLE; 1 if changing storage engine is allowed */
virtual bool can_switch_engines() { return 1; }
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 6385791a3db..158525f63c3 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -983,7 +983,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
{
rw_rdlock(&THR_LOCK_plugin);
for (uint i=idx; i < total; i++)
- if (plugins[i]->state & state_mask)
+ if (plugins[i] && plugins[i]->state & state_mask)
plugins[i]=0;
rw_unlock(&THR_LOCK_plugin);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 2c122bcd5dd..c4bb6a8fc92 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1266,7 +1266,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
to the CREATE TABLE statement
*/
- if ((for_str= file->get_tablespace_name(thd)))
+ if ((for_str= file->get_tablespace_name(thd,0,0)))
{
packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE "));
packet->append(for_str, strlen(for_str));
@@ -3973,7 +3973,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
strlen(part_elem->tablespace_name), cs);
else
{
- char *ts= showing_table->file->get_tablespace_name(thd);
+ char *ts= showing_table->file->get_tablespace_name(thd,0,0);
if(ts)
{
table->field[24]->store(ts, strlen(ts), cs);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index dcc723cf4b6..7057c783701 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5306,7 +5306,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
int error;
char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN];
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
- char index_file[FN_REFLEN], data_file[FN_REFLEN];
+ char index_file[FN_REFLEN], data_file[FN_REFLEN], tablespace[FN_LEN];
char path[FN_REFLEN];
char reg_path[FN_REFLEN+1];
ha_rows copied,deleted;
@@ -5629,6 +5629,15 @@ view_err:
if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE))
create_info->key_block_size= table->s->key_block_size;
+ if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY)
+ {
+ /*
+ Regular alter table of disk stored table (no tablespace/storage change)
+ Copy tablespace name
+ */
+ if ((table->file->get_tablespace_name(thd, tablespace, FN_LEN)))
+ create_info->tablespace= tablespace;
+ }
restore_record(table, s->default_values); // Empty record for DEFAULT
List_iterator<Alter_drop> drop_it(alter_info->drop_list);
List_iterator<create_field> def_it(fields);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index eb415f8b408..4d8eda06faf 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4008,8 +4008,8 @@ create_table_option:
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.data_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR; }
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR; }
| TABLESPACE ident {Lex->create_info.tablespace= $2.str;}
- | STORAGE_SYM DISK_SYM {Lex->create_info.store_on_disk= TRUE;}
- | STORAGE_SYM MEMORY_SYM {Lex->create_info.store_on_disk= FALSE;}
+ | STORAGE_SYM DISK_SYM {Lex->create_info.storage_media= HA_SM_DISK;}
+ | STORAGE_SYM MEMORY_SYM {Lex->create_info.storage_media= HA_SM_MEMORY;}
| CONNECTION_SYM opt_equal TEXT_STRING_sys { Lex->create_info.connect_string.str= $3.str; Lex->create_info.connect_string.length= $3.length; Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION; }
| KEY_BLOCK_SIZE opt_equal ulong_num
{
@@ -4751,6 +4751,7 @@ alter:
lex->alter_info.reset();
lex->alter_info.flags= 0;
lex->no_write_to_binlog= 0;
+ lex->create_info.storage_media= HA_SM_DEFAULT;
}
alter_commands
{}
@@ -8417,6 +8418,7 @@ show_param:
if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0))
YYABORT;
lex->only_view= 0;
+ lex->create_info.storage_media= HA_SM_DEFAULT;
}
| CREATE VIEW_SYM table_ident
{
diff --git a/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp b/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp
index ff0e90d1fbd..d96173d6807 100644
--- a/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp
+++ b/storage/ndb/include/kernel/signaldata/BackupContinueB.hpp
@@ -32,7 +32,8 @@ private:
BUFFER_FULL_FRAG_COMPLETE = 3,
BUFFER_FULL_META = 4,
BACKUP_FRAGMENT_INFO = 5,
- RESET_DISK_SPEED_COUNTER = 6
+ RESET_DISK_SPEED_COUNTER = 6,
+ ZDELAY_SCAN_NEXT = 7
};
};
diff --git a/storage/ndb/include/kernel/signaldata/Extent.hpp b/storage/ndb/include/kernel/signaldata/Extent.hpp
index 86f45163be5..ea31b0968aa 100644
--- a/storage/ndb/include/kernel/signaldata/Extent.hpp
+++ b/storage/ndb/include/kernel/signaldata/Extent.hpp
@@ -74,6 +74,8 @@ struct FreeExtentReq {
Local_key key;
Uint32 table_id;
Uint32 tablespace_id;
+ Uint32 lsn_hi;
+ Uint32 lsn_lo;
} request;
struct
{
diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h
index 70af187db77..8918ec3f225 100644
--- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h
+++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h
@@ -96,6 +96,8 @@
#define CFG_DB_CHECKPOINT_SPEED 164
#define CFG_DB_CHECKPOINT_SPEED_SR 165
+#define CFG_DB_MEMREPORT_FREQUENCY 166
+
#define CFG_DB_SGA 198 /* super pool mem */
#define CFG_DB_DATA_MEM_2 199 /* used in special build in 5.1 */
diff --git a/storage/ndb/ndbapi-examples/Makefile b/storage/ndb/ndbapi-examples/Makefile
index 2a77cb20afe..6a48afccb48 100644
--- a/storage/ndb/ndbapi-examples/Makefile
+++ b/storage/ndb/ndbapi-examples/Makefile
@@ -7,7 +7,7 @@ BIN_DIRS := ndbapi_simple \
ndbapi_scan \
mgmapi_logevent \
ndbapi_simple_dual \
- mgmapi_logevent_dual
+ mgmapi_logevent2
bins: $(patsubst %, _bins_%, $(BIN_DIRS))
diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile b/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile
index 4a80a9fe087..95b43b11f6b 100644
--- a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile
+++ b/storage/ndb/ndbapi-examples/mgmapi_logevent2/Makefile
@@ -1,4 +1,4 @@
-TARGET = mgmapi_logevent_dual
+TARGET = mgmapi_logevent2
SRCS = $(TARGET).cpp
OBJS = $(TARGET).o
CXX = g++
diff --git a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp b/storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp
index 2073ec540d7..2073ec540d7 100644
--- a/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp
+++ b/storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp
diff --git a/storage/ndb/src/kernel/blocks/ERROR_codes.txt b/storage/ndb/src/kernel/blocks/ERROR_codes.txt
index 56b5b8e4bc8..83aa1183772 100644
--- a/storage/ndb/src/kernel/blocks/ERROR_codes.txt
+++ b/storage/ndb/src/kernel/blocks/ERROR_codes.txt
@@ -8,7 +8,7 @@ Next DBDICT 6007
Next DBDIH 7178
Next DBTC 8039
Next CMVMI 9000
-Next BACKUP 10036
+Next BACKUP 10038
Next DBUTIL 11002
Next DBTUX 12008
Next SUMA 13001
@@ -425,6 +425,9 @@ Backup Stuff:
10034: define backup reply error
10035: Fail to allocate buffers
+10036: Halt backup for table >= 2
+10037: Resume backup (from 10036)
+
11001: Send UTIL_SEQUENCE_REF (in master)
5028: Crash when receiving LQHKEYREQ (in non-master)
diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp
index 79970ce9723..aae64b4bb6c 100644
--- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp
+++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp
@@ -355,6 +355,25 @@ Backup::execCONTINUEB(Signal* signal)
GetTabInfoReq::SignalLength, JBB);
return;
}
+ case BackupContinueB::ZDELAY_SCAN_NEXT:
+ if (ERROR_INSERTED(10036))
+ {
+ jam();
+ sendSignalWithDelay(BACKUP_REF, GSN_CONTINUEB, signal, 300,
+ signal->getLength());
+ return;
+ }
+ else
+ {
+ jam();
+ CLEAR_ERROR_INSERT_VALUE;
+ ndbout_c("Resuming backup");
+ memmove(signal->theData, signal->theData + 1,
+ 4*ScanFragNextReq::SignalLength);
+ sendSignal(DBLQH_REF, GSN_SCAN_NEXTREQ, signal,
+ ScanFragNextReq::SignalLength, JBB);
+ return ;
+ }
default:
ndbrequire(0);
}//switch
@@ -3924,6 +3943,22 @@ Backup::checkScan(Signal* signal, BackupFilePtr filePtr)
req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
req->batch_size_rows= 16;
req->batch_size_bytes= 0;
+
+ if (ERROR_INSERTED(10036) &&
+ filePtr.p->tableId >= 2 &&
+ filePtr.p->operation.noOfRecords > 0)
+ {
+ ndbout_c("halting backup for table %d fragment: %d after %d records",
+ filePtr.p->tableId,
+ filePtr.p->fragmentNo,
+ filePtr.p->operation.noOfRecords);
+ memmove(signal->theData+1, signal->theData,
+ 4*ScanFragNextReq::SignalLength);
+ signal->theData[0] = BackupContinueB::ZDELAY_SCAN_NEXT;
+ sendSignalWithDelay(BACKUP_REF, GSN_CONTINUEB, signal,
+ 300, 1+ScanFragNextReq::SignalLength);
+ return;
+ }
if(ERROR_INSERTED(10032))
sendSignalWithDelay(DBLQH_REF, GSN_SCAN_NEXTREQ, signal,
100, ScanFragNextReq::SignalLength);
diff --git a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp
index 6474bb5b1a3..6337e252c0b 100644
--- a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp
+++ b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp
@@ -1099,6 +1099,7 @@ private:
};
Uint32 c_errorInsert3000_TableId;
+ Uint32 c_memusage_report_frequency;
};
#endif
diff --git a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp
index e83c06dc38f..bf2fa5b7584 100644
--- a/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp
+++ b/storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp
@@ -111,6 +111,7 @@ void Dbacc::execCONTINUEB(Signal* signal)
}
case ZREPORT_MEMORY_USAGE:{
jam();
+ Uint32 cnt = signal->theData[1];
static int c_currentMemUsed = 0;
int now = cpagesize ? (cnoOfAllocatedPages * 100)/cpagesize : 0;
const int thresholds[] = { 99, 90, 80, 0};
@@ -124,14 +125,22 @@ void Dbacc::execCONTINUEB(Signal* signal)
}
}
- if(now != c_currentMemUsed){
- reportMemoryUsage(signal, now > c_currentMemUsed ? 1 : -1);
+ if(now != c_currentMemUsed ||
+ (c_memusage_report_frequency && cnt + 1 == c_memusage_report_frequency))
+ {
+ reportMemoryUsage(signal,
+ now > c_currentMemUsed ? 1 :
+ now < c_currentMemUsed ? -1 : 0);
+ cnt = 0;
+ c_currentMemUsed = now;
+ }
+ else
+ {
+ cnt ++;
}
-
- c_currentMemUsed = now;
-
signal->theData[0] = ZREPORT_MEMORY_USAGE;
- sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
+ signal->theData[1] = cnt;
+ sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2);
return;
}
@@ -198,7 +207,8 @@ void Dbacc::execNDB_STTOR(Signal* signal)
csystemRestart = ZFALSE;
signal->theData[0] = ZREPORT_MEMORY_USAGE;
- sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
+ signal->theData[1] = 0;
+ sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2);
break;
default:
jam();
@@ -352,6 +362,10 @@ void Dbacc::execREAD_CONFIG_REQ(Signal* signal)
initRecords();
ndbrestart1Lab(signal);
+ c_memusage_report_frequency = 0;
+ ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY,
+ &c_memusage_report_frequency);
+
tdata0 = 0;
initialiseRecordsLab(signal, ref, senderData);
return;
diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
index 87d9b7e631f..5f00f62da87 100644
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
@@ -478,7 +478,7 @@ Dbdict::packTableIntoPages(SimpleProperties::Writer & w,
CreateFragmentationReq::SignalLength);
ndbrequire(signal->theData[0] == 0);
Uint16 *data = (Uint16*)&signal->theData[25];
- Uint32 count = 2 + data[0] * data[1];
+ Uint32 count = 2 + (1 + data[0]) * data[1];
w.add(DictTabInfo::ReplicaDataLen, 2*count);
for (Uint32 i = 0; i < count; i++)
data[i] = htons(data[i]);
diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
index a407280cf3d..af8f86b0d84 100644
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
@@ -6727,7 +6727,7 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal)
FragmentstorePtr fragPtr;
ReplicaRecordPtr replicaPtr;
getFragstore(primTabPtr.p, fragNo, fragPtr);
- fragments[count++] = c_nextLogPart++;
+ fragments[count++] = fragPtr.p->m_log_part_id;
fragments[count++] = fragPtr.p->preferredPrimary;
for (replicaPtr.i = fragPtr.p->storedReplicas;
replicaPtr.i != RNIL;
diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
index 35b78c1fb15..0be59fdf96b 100644
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
@@ -11275,7 +11275,7 @@ void Dblqh::execLCP_PREPARE_REF(Signal* signal)
/**
* First fragment mean that last LCP is complete :-)
*/
- EXECUTE_DIRECT(TSMAN, GSN_END_LCP_REQ, signal, signal->length());
+ EXECUTE_DIRECT(TSMAN, GSN_LCP_FRAG_ORD, signal, signal->length());
jamEntry();
}
@@ -11326,7 +11326,7 @@ void Dblqh::execLCP_PREPARE_CONF(Signal* signal)
/**
* First fragment mean that last LCP is complete :-)
*/
- EXECUTE_DIRECT(TSMAN, GSN_END_LCP_REQ, signal, signal->length());
+ EXECUTE_DIRECT(TSMAN, GSN_LCP_FRAG_ORD, signal, signal->length());
jamEntry();
}
@@ -11610,6 +11610,9 @@ void Dblqh::completeLcpRoundLab(Signal* signal, Uint32 lcpId)
sendSignal(LGMAN_REF, GSN_END_LCP_REQ, signal,
EndLcpReq::SignalLength, JBB);
+ EXECUTE_DIRECT(TSMAN, GSN_END_LCP_REQ, signal, EndLcpReq::SignalLength);
+ jamEntry();
+
lcpPtr.i = 0;
ptrAss(lcpPtr, lcpRecord);
lcpPtr.p->m_outstanding = 3;
diff --git a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
index 8a9242e9748..44f7954f00d 100644
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
@@ -5057,7 +5057,7 @@ void Dbtc::execLQHKEYREF(Signal* signal)
ptrAss(tcConnectptr, tcConnectRecord);
TcConnectRecord * const regTcPtr = tcConnectptr.p;
if (regTcPtr->tcConnectstate == OS_OPERATING) {
- apiConnectptr.i = regTcPtr->apiConnect;
+ Uint32 save = apiConnectptr.i = regTcPtr->apiConnect;
ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
ApiConnectRecord * const regApiPtr = apiConnectptr.p;
compare_transid1 = regApiPtr->transid[0] ^ lqhKeyRef->transId1;
@@ -5181,7 +5181,7 @@ void Dbtc::execLQHKEYREF(Signal* signal)
regApiPtr->lqhkeyreqrec--; // Compensate for extra during read
tcKeyRef->connectPtr = indexOp;
EXECUTE_DIRECT(DBTC, GSN_TCKEYREF, signal, TcKeyRef::SignalLength);
- apiConnectptr.i = regTcPtr->apiConnect;
+ apiConnectptr.i = save;
apiConnectptr.p = regApiPtr;
} else {
jam();
@@ -5206,6 +5206,8 @@ void Dbtc::execLQHKEYREF(Signal* signal)
jam();
sendtckeyconf(signal, 1);
regApiPtr->apiConnectstate = CS_CONNECTED;
+ regApiPtr->m_transaction_nodes.clear();
+ setApiConTimer(apiConnectptr.i, 0,__LINE__);
}
return;
} else if (regApiPtr->tckeyrec > 0 || regApiPtr->m_exec_flag) {
@@ -11863,17 +11865,6 @@ void Dbtc::execTCKEYREF(Signal* signal)
case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI):
case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): {
jam();
- // If we fail index access for a non-read operation during commit
- // we abort transaction
- if (commitFlg == 1) {
- jam();
- releaseIndexOperation(regApiPtr, indexOp);
- apiConnectptr.i = indexOp->connectionIndex;
- ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord);
- terrorCode = tcKeyRef->errorCode;
- abortErrorLab(signal);
- break;
- }
/**
* Increase count as it will be decreased below...
* (and the code is written to handle failing lookup on "real" table
diff --git a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
index 0ce7a2a03c2..408925e4103 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
@@ -624,7 +624,8 @@ struct Fragrecord {
DLList<ScanOp>::Head m_scanList;
- bool m_undo_complete;
+ enum { UC_LCP = 1, UC_CREATE = 2 };
+ Uint32 m_undo_complete;
Uint32 m_tablespace_id;
Uint32 m_logfile_group_id;
Disk_alloc_info m_disk_alloc_info;
@@ -988,6 +989,9 @@ ArrayPool<TupTriggerData> c_triggerPool;
,UNDO_UPDATE = File_formats::Undofile::UNDO_TUP_UPDATE
,UNDO_FREE = File_formats::Undofile::UNDO_TUP_FREE
,UNDO_CREATE = File_formats::Undofile::UNDO_TUP_CREATE
+ ,UNDO_DROP = File_formats::Undofile::UNDO_TUP_DROP
+ ,UNDO_ALLOC_EXTENT = File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT
+ ,UNDO_FREE_EXTENT = File_formats::Undofile::UNDO_TUP_FREE_EXTENT
};
struct Alloc
@@ -1020,6 +1024,30 @@ ArrayPool<TupTriggerData> c_triggerPool;
Uint32 m_table;
Uint32 m_type_length; // 16 bit type, 16 bit length
};
+
+ struct Drop
+ {
+ Uint32 m_table;
+ Uint32 m_type_length; // 16 bit type, 16 bit length
+ };
+
+ struct AllocExtent
+ {
+ Uint32 m_table;
+ Uint32 m_fragment;
+ Uint32 m_page_no;
+ Uint32 m_file_no;
+ Uint32 m_type_length;
+ };
+
+ struct FreeExtent
+ {
+ Uint32 m_table;
+ Uint32 m_fragment;
+ Uint32 m_page_no;
+ Uint32 m_file_no;
+ Uint32 m_type_length;
+ };
};
Extent_info_pool c_extent_pool;
@@ -1419,7 +1447,7 @@ public:
int nr_delete(Signal*, Uint32, Uint32 fragPtr, const Local_key*, Uint32 gci);
void nr_delete_page_callback(Signal*, Uint32 op, Uint32 page);
- void nr_delete_logbuffer_callback(Signal*, Uint32 op, Uint32 page);
+ void nr_delete_log_buffer_callback(Signal*, Uint32 op, Uint32 page);
private:
BLOCK_DEFINES(Dbtup);
@@ -2344,9 +2372,10 @@ private:
Uint32 fragId);
- void releaseFragment(Signal* signal, Uint32 tableId);
+ void releaseFragment(Signal* signal, Uint32 tableId, Uint32);
void drop_fragment_free_var_pages(Signal*);
- void drop_fragment_free_exent(Signal*, TablerecPtr, FragrecordPtr, Uint32);
+ void drop_fragment_free_extent(Signal*, TablerecPtr, FragrecordPtr, Uint32);
+ void drop_fragment_free_extent_log_buffer_callback(Signal*, Uint32, Uint32);
void drop_fragment_unmap_pages(Signal*, TablerecPtr, FragrecordPtr, Uint32);
void drop_fragment_unmap_page_callback(Signal* signal, Uint32, Uint32);
@@ -2570,6 +2599,7 @@ private:
// Trigger variables
Uint32 c_maxTriggersPerTable;
+ Uint32 c_memusage_report_frequency;
Uint32 c_errorInsert4000TableId;
Uint32 c_min_list_size[MAX_FREE_LIST + 1];
@@ -2629,6 +2659,9 @@ private:
void disk_page_commit_callback(Signal*, Uint32 opPtrI, Uint32 page_id);
void disk_page_log_buffer_callback(Signal*, Uint32 opPtrI, Uint32);
+
+ void disk_page_alloc_extent_log_buffer_callback(Signal*, Uint32, Uint32);
+ void disk_page_free_extent_log_buffer_callback(Signal*, Uint32, Uint32);
Uint64 disk_page_undo_alloc(Page*, const Local_key*,
Uint32 sz, Uint32 gci, Uint32 logfile_group_id);
@@ -2644,6 +2677,9 @@ private:
void undo_createtable_callback(Signal* signal, Uint32 opPtrI, Uint32 unused);
void undo_createtable_logsync_callback(Signal* signal, Uint32, Uint32);
+ void drop_table_log_buffer_callback(Signal*, Uint32, Uint32);
+ void drop_table_logsync_callback(Signal*, Uint32, Uint32);
+
void disk_page_set_dirty(Ptr<Page>);
void restart_setup_page(Disk_alloc_info&, Ptr<Page>);
void update_extent_pos(Disk_alloc_info&, Ptr<Extent_info>);
@@ -2677,7 +2713,7 @@ public:
private:
void disk_restart_undo_next(Signal*);
- void disk_restart_undo_lcp(Uint32, Uint32);
+ void disk_restart_undo_lcp(Uint32, Uint32, Uint32 flag);
void disk_restart_undo_callback(Signal* signal, Uint32, Uint32);
void disk_restart_undo_alloc(Apply_undo*);
void disk_restart_undo_update(Apply_undo*);
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
index 9c70cb7f0f8..1f703599cf5 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
@@ -151,10 +151,10 @@ void Dbtup::initOpConnection(Operationrec* regOperPtr)
static
inline
bool
-operator>=(const Local_key& key1, const Local_key& key2)
+operator>(const Local_key& key1, const Local_key& key2)
{
return key1.m_page_no > key2.m_page_no ||
- (key1.m_page_no == key2.m_page_no && key1.m_page_idx >= key2.m_page_idx);
+ (key1.m_page_no == key2.m_page_no && key1.m_page_idx > key2.m_page_idx);
}
void
@@ -175,8 +175,11 @@ Dbtup::dealloc_tuple(Signal* signal,
{
Local_key disk;
memcpy(&disk, ptr->get_disk_ref_ptr(regTabPtr), sizeof(disk));
+ PagePtr tmpptr;
+ tmpptr.i = m_pgman.m_ptr.i;
+ tmpptr.p = reinterpret_cast<Page*>(m_pgman.m_ptr.p);
disk_page_free(signal, regTabPtr, regFragPtr,
- &disk, *(PagePtr*)&m_pgman.m_ptr, gci);
+ &disk, tmpptr, gci);
}
if (! (bits & Tuple_header::LCP_SKIP) && lcpScan_ptr_i != RNIL)
@@ -186,7 +189,7 @@ Dbtup::dealloc_tuple(Signal* signal,
Local_key rowid = regOperPtr->m_tuple_location;
Local_key scanpos = scanOp.p->m_scanPos.m_key;
rowid.m_page_no = page->frag_page_id;
- if (rowid >= scanpos)
+ if (rowid > scanpos)
{
extra_bits = Tuple_header::LCP_KEEP; // Note REMOVE FREE
ptr->m_operation_ptr_i = lcp_keep_list;
@@ -214,6 +217,7 @@ Dbtup::commit_operation(Signal* signal,
{
ndbassert(regOperPtr->op_struct.op_type != ZDELETE);
+ Uint32 lcpScan_ptr_i= regFragPtr->m_lcp_scan_op;
Uint32 save= tuple_ptr->m_operation_ptr_i;
Uint32 bits= tuple_ptr->m_header_bits;
@@ -263,7 +267,6 @@ Dbtup::commit_operation(Signal* signal,
Local_key key;
memcpy(&key, copy->get_disk_ref_ptr(regTabPtr), sizeof(Local_key));
Uint32 logfile_group_id= regFragPtr->m_logfile_group_id;
- Uint32 lcpScan_ptr_i= regFragPtr->m_lcp_scan_op;
PagePtr diskPagePtr = *(PagePtr*)&m_pgman.m_ptr;
ndbassert(diskPagePtr.p->m_page_no == key.m_page_no);
@@ -272,19 +275,6 @@ Dbtup::commit_operation(Signal* signal,
if(copy_bits & Tuple_header::DISK_ALLOC)
{
disk_page_alloc(signal, regTabPtr, regFragPtr, &key, diskPagePtr, gci);
-
- if(lcpScan_ptr_i != RNIL)
- {
- ScanOpPtr scanOp;
- c_scanOpPool.getPtr(scanOp, lcpScan_ptr_i);
- Local_key rowid = regOperPtr->m_tuple_location;
- Local_key scanpos = scanOp.p->m_scanPos.m_key;
- rowid.m_page_no = pagePtr.p->frag_page_id;
- if(rowid >= scanpos)
- {
- copy_bits |= Tuple_header::LCP_SKIP;
- }
- }
}
if(regTabPtr->m_attributes[DD].m_no_of_varsize == 0)
@@ -311,6 +301,18 @@ Dbtup::commit_operation(Signal* signal,
copy_bits |= Tuple_header::DISK_PART;
}
+ if(lcpScan_ptr_i != RNIL && (bits & Tuple_header::ALLOC))
+ {
+ ScanOpPtr scanOp;
+ c_scanOpPool.getPtr(scanOp, lcpScan_ptr_i);
+ Local_key rowid = regOperPtr->m_tuple_location;
+ Local_key scanpos = scanOp.p->m_scanPos.m_key;
+ rowid.m_page_no = pagePtr.p->frag_page_id;
+ if(rowid > scanpos)
+ {
+ copy_bits |= Tuple_header::LCP_SKIP;
+ }
+ }
Uint32 clear=
Tuple_header::ALLOC | Tuple_header::FREE |
@@ -356,7 +358,12 @@ Dbtup::disk_page_commit_callback(Signal* signal,
regOperPtr.p->m_commit_disk_callback_page= page_id;
m_global_page_pool.getPtr(m_pgman.m_ptr, page_id);
- disk_page_set_dirty(*(Ptr<Page>*)&m_pgman.m_ptr);
+ {
+ PagePtr tmp;
+ tmp.i = m_pgman.m_ptr.i;
+ tmp.p = reinterpret_cast<Page*>(m_pgman.m_ptr.p);
+ disk_page_set_dirty(tmp);
+ }
execTUP_COMMITREQ(signal);
if(signal->theData[0] == 0)
@@ -543,7 +550,14 @@ void Dbtup::execTUP_COMMITREQ(Signal* signal)
break;
}
get_page = true;
- disk_page_set_dirty(*(Ptr<Page>*)&m_pgman.m_ptr);
+
+ {
+ PagePtr tmpptr;
+ tmpptr.i = m_pgman.m_ptr.i;
+ tmpptr.p = reinterpret_cast<Page*>(m_pgman.m_ptr.p);
+ disk_page_set_dirty(tmpptr);
+ }
+
regOperPtr.p->m_commit_disk_callback_page= res;
regOperPtr.p->op_struct.m_load_diskpage_on_commit= 0;
}
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp
index 7959606b7f4..0342f2c9e0c 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp
@@ -68,6 +68,26 @@ operator<<(NdbOut& out, const Ptr<Dbtup::Extent_info> & ptr)
return out;
}
+#if NOT_YET_FREE_EXTENT
+static
+inline
+bool
+check_free(const Dbtup::Extent_info* extP)
+{
+ Uint32 res = 0;
+ for (Uint32 i = 1; i<MAX_FREE_LIST; i++)
+ res += extP->m_free_page_count[i];
+ return res;
+}
+#error "Code for deallocting extents when they get empty"
+#error "This code is not yet complete"
+#endif
+
+#if NOT_YET_UNDO_ALLOC_EXTENT
+#error "This is needed for deallocting extents when they get empty"
+#error "This code is not complete yet"
+#endif
+
void
Dbtup::dump_disk_alloc(Dbtup::Disk_alloc_info & alloc)
{
@@ -444,23 +464,71 @@ Dbtup::disk_page_prealloc(Signal* signal,
/**
* We need to alloc an extent
*/
+#if NOT_YET_UNDO_ALLOC_EXTENT
+ Uint32 logfile_group_id = fragPtr.p->m_logfile_group_id;
+
+ err = c_lgman->alloc_log_space(logfile_group_id,
+ sizeof(Disk_undo::AllocExtent)>>2);
+ if(unlikely(err))
+ {
+ return -err;
+ }
+#endif
+
if (!c_extent_pool.seize(ext))
{
+ jam();
//XXX
err= 2;
+#if NOT_YET_UNDO_ALLOC_EXTENT
+ c_lgman->free_log_space(logfile_group_id,
+ sizeof(Disk_undo::AllocExtent)>>2);
+#endif
c_page_request_pool.release(req);
ndbout_c("no free extent info");
return -err;
}
-
+
if ((err= tsman.alloc_extent(&ext.p->m_key)) < 0)
{
+ jam();
+#if NOT_YET_UNDO_ALLOC_EXTENT
+ c_lgman->free_log_space(logfile_group_id,
+ sizeof(Disk_undo::AllocExtent)>>2);
+#endif
c_extent_pool.release(ext);
c_page_request_pool.release(req);
return err;
}
int pages= err;
+#if NOT_YET_UNDO_ALLOC_EXTENT
+ {
+ /**
+ * Do something here
+ */
+ {
+ Callback cb;
+ cb.m_callbackData= ext.i;
+ cb.m_callbackFunction =
+ safe_cast(&Dbtup::disk_page_alloc_extent_log_buffer_callback);
+ Uint32 sz= sizeof(Disk_undo::AllocExtent)>>2;
+
+ Logfile_client lgman(this, c_lgman, logfile_group_id);
+ int res= lgman.get_log_buffer(signal, sz, &cb);
+ switch(res){
+ case 0:
+ break;
+ case -1:
+ ndbrequire("NOT YET IMPLEMENTED" == 0);
+ break;
+ default:
+ execute(signal, cb, res);
+ }
+ }
+ }
+#endif
+
ndbout << "allocated " << pages << " pages: " << ext.p->m_key << endl;
ext.p->m_first_page_no = ext.p->m_key.m_page_no;
bzero(ext.p->m_free_page_count, sizeof(ext.p->m_free_page_count));
@@ -1016,6 +1084,12 @@ Dbtup::disk_page_free(Signal *signal,
extentPtr.p->m_free_space += sz;
update_extent_pos(alloc, extentPtr);
+#if NOT_YET_FREE_EXTENT
+ if (check_free(extentPtr.p) == 0)
+ {
+ ndbout_c("free: extent is free");
+ }
+#endif
}
void
@@ -1118,14 +1192,56 @@ Dbtup::disk_page_abort_prealloc_callback_1(Signal* signal,
extentPtr.p->m_free_space += sz;
update_extent_pos(alloc, extentPtr);
+#if NOT_YET_FREE_EXTENT
+ if (check_free(extentPtr.p) == 0)
+ {
+ ndbout_c("abort: extent is free");
+ }
+#endif
+}
+
+#if NOT_YET_UNDO_ALLOC_EXTENT
+void
+Dbtup::disk_page_alloc_extent_log_buffer_callback(Signal* signal,
+ Uint32 extentPtrI,
+ Uint32 unused)
+{
+ Ptr<Extent_info> extentPtr;
+ c_extent_pool.getPtr(extentPtr, extentPtrI);
+
+ Local_key key = extentPtr.p->m_key;
+ Tablespace_client2 tsman(signal, c_tsman, &key);
+
+ Ptr<Tablerec> tabPtr;
+ tabPtr.i= tsman.m_table_id;
+ ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
+
+ Ptr<Fragrecord> fragPtr;
+ getFragmentrec(fragPtr, tsman.m_fragment_id, tabPtr.p);
+
+ Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
+
+ Disk_undo::AllocExtent alloc;
+ alloc.m_table = tabPtr.i;
+ alloc.m_fragment = tsman.m_fragment_id;
+ alloc.m_page_no = key.m_page_no;
+ alloc.m_file_no = key.m_file_no;
+ alloc.m_type_length = (Disk_undo::UNDO_ALLOC_EXTENT<<16)|(sizeof(alloc)>> 2);
+
+ Logfile_client::Change c[1] = {{ &alloc, sizeof(alloc) >> 2 } };
+
+ Uint64 lsn= lgman.add_entry(c, 1);
+
+ tsman.update_lsn(&key, lsn);
}
+#endif
Uint64
Dbtup::disk_page_undo_alloc(Page* page, const Local_key* key,
Uint32 sz, Uint32 gci, Uint32 logfile_group_id)
{
- Logfile_client lsman(this, c_lgman, logfile_group_id);
-
+ Logfile_client lgman(this, c_lgman, logfile_group_id);
+
Disk_undo::Alloc alloc;
alloc.m_type_length= (Disk_undo::UNDO_ALLOC << 16) | (sizeof(alloc) >> 2);
alloc.m_page_no = key->m_page_no;
@@ -1133,7 +1249,7 @@ Dbtup::disk_page_undo_alloc(Page* page, const Local_key* key,
Logfile_client::Change c[1] = {{ &alloc, sizeof(alloc) >> 2 } };
- Uint64 lsn= lsman.add_entry(c, 1);
+ Uint64 lsn= lgman.add_entry(c, 1);
m_pgman.update_lsn(* key, lsn);
return lsn;
@@ -1144,7 +1260,7 @@ Dbtup::disk_page_undo_update(Page* page, const Local_key* key,
const Uint32* src, Uint32 sz,
Uint32 gci, Uint32 logfile_group_id)
{
- Logfile_client lsman(this, c_lgman, logfile_group_id);
+ Logfile_client lgman(this, c_lgman, logfile_group_id);
Disk_undo::Update update;
update.m_page_no = key->m_page_no;
@@ -1162,7 +1278,7 @@ Dbtup::disk_page_undo_update(Page* page, const Local_key* key,
ndbassert(4*(3 + sz + 1) == (sizeof(update) + 4*sz - 4));
- Uint64 lsn= lsman.add_entry(c, 3);
+ Uint64 lsn= lgman.add_entry(c, 3);
m_pgman.update_lsn(* key, lsn);
return lsn;
@@ -1173,7 +1289,7 @@ Dbtup::disk_page_undo_free(Page* page, const Local_key* key,
const Uint32* src, Uint32 sz,
Uint32 gci, Uint32 logfile_group_id)
{
- Logfile_client lsman(this, c_lgman, logfile_group_id);
+ Logfile_client lgman(this, c_lgman, logfile_group_id);
Disk_undo::Free free;
free.m_page_no = key->m_page_no;
@@ -1191,7 +1307,7 @@ Dbtup::disk_page_undo_free(Page* page, const Local_key* key,
ndbassert(4*(3 + sz + 1) == (sizeof(free) + 4*sz - 4));
- Uint64 lsn= lsman.add_entry(c, 3);
+ Uint64 lsn= lgman.add_entry(c, 3);
m_pgman.update_lsn(* key, lsn);
return lsn;
@@ -1221,7 +1337,7 @@ Dbtup::disk_restart_undo(Signal* signal, Uint64 lsn,
ndbrequire(len == 3);
Uint32 tableId = ptr[1] >> 16;
Uint32 fragId = ptr[1] & 0xFFFF;
- disk_restart_undo_lcp(tableId, fragId);
+ disk_restart_undo_lcp(tableId, fragId, Fragrecord::UC_LCP);
disk_restart_undo_next(signal);
return;
}
@@ -1260,10 +1376,20 @@ Dbtup::disk_restart_undo(Signal* signal, Uint64 lsn,
ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
for(Uint32 i = 0; i<MAX_FRAG_PER_NODE; i++)
if (tabPtr.p->fragrec[i] != RNIL)
- disk_restart_undo_lcp(tabPtr.i, tabPtr.p->fragid[i]);
+ disk_restart_undo_lcp(tabPtr.i, tabPtr.p->fragid[i],
+ Fragrecord::UC_CREATE);
disk_restart_undo_next(signal);
return;
}
+ case File_formats::Undofile::UNDO_TUP_DROP:
+ jam();
+ case File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT:
+ jam();
+ case File_formats::Undofile::UNDO_TUP_FREE_EXTENT:
+ jam();
+ disk_restart_undo_next(signal);
+ return;
+
case File_formats::Undofile::UNDO_END:
f_undo_done = true;
return;
@@ -1297,7 +1423,7 @@ Dbtup::disk_restart_undo_next(Signal* signal)
}
void
-Dbtup::disk_restart_undo_lcp(Uint32 tableId, Uint32 fragId)
+Dbtup::disk_restart_undo_lcp(Uint32 tableId, Uint32 fragId, Uint32 flag)
{
Ptr<Tablerec> tabPtr;
tabPtr.i= tableId;
@@ -1309,7 +1435,7 @@ Dbtup::disk_restart_undo_lcp(Uint32 tableId, Uint32 fragId)
getFragmentrec(fragPtr, fragId, tabPtr.p);
if (!fragPtr.isNull())
{
- fragPtr.p->m_undo_complete = true;
+ fragPtr.p->m_undo_complete |= flag;
}
}
}
@@ -1518,6 +1644,12 @@ Dbtup::disk_restart_alloc_extent(Uint32 tableId, Uint32 fragId,
if (tabPtr.p->tableStatus == DEFINED)
{
getFragmentrec(fragPtr, fragId, tabPtr.p);
+ if (fragPtr.p->m_undo_complete & Fragrecord::UC_CREATE)
+ {
+ jam();
+ return -1;
+ }
+
if (!fragPtr.isNull())
{
Disk_alloc_info& alloc= fragPtr.p->m_disk_alloc_info;
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
index ef52f8a87e5..52981e7fc83 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
@@ -3125,7 +3125,7 @@ Dbtup::nr_delete(Signal* signal, Uint32 senderData,
disk_page_set_dirty(disk_page);
preq.m_callback.m_callbackFunction =
- safe_cast(&Dbtup::nr_delete_logbuffer_callback);
+ safe_cast(&Dbtup::nr_delete_log_buffer_callback);
Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
res= lgman.get_log_buffer(signal, sz, &preq.m_callback);
switch(res){
@@ -3178,7 +3178,7 @@ Dbtup::nr_delete_page_callback(Signal* signal,
Callback cb;
cb.m_callbackData = userpointer;
cb.m_callbackFunction =
- safe_cast(&Dbtup::nr_delete_logbuffer_callback);
+ safe_cast(&Dbtup::nr_delete_log_buffer_callback);
Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
int res= lgman.get_log_buffer(signal, sz, &cb);
switch(res){
@@ -3198,7 +3198,7 @@ Dbtup::nr_delete_page_callback(Signal* signal,
}
void
-Dbtup::nr_delete_logbuffer_callback(Signal* signal,
+Dbtup::nr_delete_log_buffer_callback(Signal* signal,
Uint32 userpointer,
Uint32 unused)
{
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp
index 2b3093ed205..3e9469c4edf 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp
@@ -163,11 +163,12 @@ void Dbtup::execCONTINUEB(Signal* signal)
break;
case ZREL_FRAG:
ljam();
- releaseFragment(signal, dataPtr);
+ releaseFragment(signal, dataPtr, signal->theData[2]);
break;
case ZREPORT_MEMORY_USAGE:{
ljam();
static int c_currentMemUsed = 0;
+ Uint32 cnt = signal->theData[1];
Uint32 tmp = c_page_pool.getSize();
int now = tmp ? (cnoOfAllocatedPages * 100)/tmp : 0;
const int thresholds[] = { 100, 90, 80, 0 };
@@ -181,12 +182,22 @@ void Dbtup::execCONTINUEB(Signal* signal)
}
}
- if(now != c_currentMemUsed){
- reportMemoryUsage(signal, now > c_currentMemUsed ? 1 : -1);
+ if(now != c_currentMemUsed ||
+ (c_memusage_report_frequency && cnt + 1 == c_memusage_report_frequency))
+ {
+ reportMemoryUsage(signal,
+ now > c_currentMemUsed ? 1 :
+ now < c_currentMemUsed ? -1 : 0);
+ cnt = 0;
c_currentMemUsed = now;
+ }
+ else
+ {
+ cnt++;
}
signal->theData[0] = ZREPORT_MEMORY_USAGE;
- sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
+ signal->theData[1] = cnt;
+ sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 2);
return;
}
case ZBUILD_INDEX:
@@ -211,7 +222,7 @@ void Dbtup::execCONTINUEB(Signal* signal)
fragPtr.i= signal->theData[2];
ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord);
- drop_fragment_free_exent(signal, tabPtr, fragPtr, signal->theData[3]);
+ drop_fragment_free_extent(signal, tabPtr, fragPtr, signal->theData[3]);
return;
}
case ZUNMAP_PAGES:
@@ -336,6 +347,10 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal)
clastBitMask = 1;
clastBitMask = clastBitMask << 31;
+ c_memusage_report_frequency = 0;
+ ndb_mgm_get_int_parameter(p, CFG_DB_MEMREPORT_FREQUENCY,
+ &c_memusage_report_frequency);
+
initialiseRecordsLab(signal, 0, ref, senderData);
}//Dbtup::execSIZEALT_REP()
@@ -501,7 +516,8 @@ void Dbtup::execNDB_STTOR(Signal* signal)
/* RESTART. */
/*****************************************/
signal->theData[0] = ZREPORT_MEMORY_USAGE;
- sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 2000, 1);
+ signal->theData[1] = 0;
+ sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 1);
break;
default:
ljam();
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp
index 41b00b0a04b..b5010205880 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp
@@ -308,6 +308,7 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal)
if(lastAttr)
{
+ jam();
/**
* Init Disk_alloc_info
*/
@@ -319,6 +320,11 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal)
ndbrequire(tsman.get_tablespace_info(&rep) == 0);
regFragPtr.p->m_logfile_group_id= rep.tablespace.logfile_group_id;
}
+ else
+ {
+ jam();
+ regFragPtr.p->m_logfile_group_id = RNIL;
+ }
new (&regFragPtr.p->m_disk_alloc_info)
Disk_alloc_info(regTabPtr.p, rep.tablespace.extent_size);
releaseFragoperrec(fragOperPtr);
@@ -563,7 +569,12 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal)
regFragPtr.p->m_tablespace_id);
ndbrequire(tsman.get_tablespace_info(&rep) == 0);
regFragPtr.p->m_logfile_group_id= rep.tablespace.logfile_group_id;
- }
+ }
+ else
+ {
+ jam();
+ regFragPtr.p->m_logfile_group_id = RNIL;
+ }
new (&regFragPtr.p->m_disk_alloc_info)
Disk_alloc_info(regTabPtr.p, rep.tablespace.extent_size);
@@ -596,7 +607,7 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal)
ndbrequire("NOT YET IMPLEMENTED" == 0);
break;
}
- execute(signal, cb, 0);
+ execute(signal, cb, regFragPtr.p->m_logfile_group_id);
return;
}
}
@@ -873,7 +884,8 @@ Dbtup::execDROP_TAB_REQ(Signal* signal)
signal->theData[0]= ZREL_FRAG;
signal->theData[1]= tabPtr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
+ signal->theData[2]= RNIL;
+ sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
}
void Dbtup::releaseTabDescr(Tablerec* const regTabPtr)
@@ -901,7 +913,8 @@ void Dbtup::releaseTabDescr(Tablerec* const regTabPtr)
}
}
-void Dbtup::releaseFragment(Signal* signal, Uint32 tableId)
+void Dbtup::releaseFragment(Signal* signal, Uint32 tableId,
+ Uint32 logfile_group_id)
{
TablerecPtr tabPtr;
tabPtr.i= tableId;
@@ -928,16 +941,35 @@ void Dbtup::releaseFragment(Signal* signal, Uint32 tableId)
sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
return;
}
+
+#if NOT_YET_UNDO_DROP_TABLE
+#error "This code is complete, but I prefer not to enable it until I need it"
+ if (logfile_group_id != RNIL)
+ {
+ Callback cb;
+ cb.m_callbackData= tabPtr.i;
+ cb.m_callbackFunction =
+ safe_cast(&Dbtup::drop_table_log_buffer_callback);
+ Uint32 sz= sizeof(Disk_undo::Drop) >> 2;
+ int r0 = c_lgman->alloc_log_space(logfile_group_id, sz);
+
+ Logfile_client lgman(this, c_lgman, logfile_group_id);
+ int res= lgman.get_log_buffer(signal, sz, &cb);
+ switch(res){
+ case 0:
+ ljam();
+ return;
+ case -1:
+ ndbrequire("NOT YET IMPLEMENTED" == 0);
+ break;
+ default:
+ execute(signal, cb, logfile_group_id);
+ return;
+ }
+ }
+#endif
- DropTabConf * const dropConf= (DropTabConf *)signal->getDataPtrSend();
- dropConf->senderRef= reference();
- dropConf->senderData= tabPtr.p->m_dropTable.tabUserPtr;
- dropConf->tableId= tabPtr.i;
- sendSignal(tabPtr.p->m_dropTable.tabUserRef, GSN_DROP_TAB_CONF,
- signal, DropTabConf::SignalLength, JBB);
-
- releaseTabDescr(tabPtr.p);
- initTab(tabPtr.p);
+ drop_table_logsync_callback(signal, tabPtr.i, RNIL);
}
void
@@ -964,7 +996,7 @@ Dbtup::drop_fragment_unmap_pages(Signal *signal,
alloc_info.m_curr_extent_info_ptr_i= RNIL;
}
- drop_fragment_free_exent(signal, tabPtr, fragPtr, 0);
+ drop_fragment_free_extent(signal, tabPtr, fragPtr, 0);
return;
}
@@ -997,7 +1029,7 @@ Dbtup::drop_fragment_unmap_pages(Signal *signal,
}
return;
}
- drop_fragment_free_exent(signal, tabPtr, fragPtr, 0);
+ drop_fragment_free_extent(signal, tabPtr, fragPtr, 0);
}
void
@@ -1030,10 +1062,10 @@ Dbtup::drop_fragment_unmap_page_callback(Signal* signal,
}
void
-Dbtup::drop_fragment_free_exent(Signal *signal,
- TablerecPtr tabPtr,
- FragrecordPtr fragPtr,
- Uint32 pos)
+Dbtup::drop_fragment_free_extent(Signal *signal,
+ TablerecPtr tabPtr,
+ FragrecordPtr fragPtr,
+ Uint32 pos)
{
if (tabPtr.p->m_no_of_disk_attributes)
{
@@ -1043,25 +1075,32 @@ Dbtup::drop_fragment_free_exent(Signal *signal,
if(!alloc_info.m_free_extents[pos].isEmpty())
{
jam();
- Local_extent_info_list
- list(c_extent_pool, alloc_info.m_free_extents[pos]);
- Ptr<Extent_info> ext_ptr;
- list.first(ext_ptr);
+ Callback cb;
+ cb.m_callbackData= fragPtr.i;
+ cb.m_callbackFunction =
+ safe_cast(&Dbtup::drop_fragment_free_extent_log_buffer_callback);
+#if NOT_YET_UNDO_FREE_EXTENT
+ Uint32 sz= sizeof(Disk_undo::FreeExtent) >> 2;
+ int r0 = c_lgman->alloc_log_space(fragPtr.p->m_logfile_group_id, sz);
- Tablespace_client tsman(signal, c_tsman, tabPtr.i,
- fragPtr.p->fragmentId,
- fragPtr.p->m_tablespace_id);
+ Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
- tsman.free_extent(&ext_ptr.p->m_key);
- c_extent_hash.remove(ext_ptr);
- list.release(ext_ptr);
-
- signal->theData[0] = ZFREE_EXTENT;
- signal->theData[1] = tabPtr.i;
- signal->theData[2] = fragPtr.i;
- signal->theData[3] = pos;
- sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
+ int res= lgman.get_log_buffer(signal, sz, &cb);
+ switch(res){
+ case 0:
+ ljam();
+ return;
+ case -1:
+ ndbrequire("NOT YET IMPLEMENTED" == 0);
+ break;
+ default:
+ execute(signal, cb, fragPtr.p->m_logfile_group_id);
+ return;
+ }
+#else
+ execute(signal, cb, fragPtr.p->m_logfile_group_id);
return;
+#endif
}
}
@@ -1081,6 +1120,123 @@ Dbtup::drop_fragment_free_exent(Signal *signal,
}
void
+Dbtup::drop_table_log_buffer_callback(Signal* signal, Uint32 tablePtrI,
+ Uint32 logfile_group_id)
+{
+ TablerecPtr tabPtr;
+ tabPtr.i = tablePtrI;
+ ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
+
+ ndbrequire(tabPtr.p->m_no_of_disk_attributes);
+
+ Disk_undo::Drop drop;
+ drop.m_table = tabPtr.i;
+ drop.m_type_length =
+ (Disk_undo::UNDO_DROP << 16) | (sizeof(drop) >> 2);
+ Logfile_client lgman(this, c_lgman, logfile_group_id);
+
+ Logfile_client::Change c[1] = {{ &drop, sizeof(drop) >> 2 } };
+ Uint64 lsn = lgman.add_entry(c, 1);
+
+ Logfile_client::Request req;
+ req.m_callback.m_callbackData= tablePtrI;
+ req.m_callback.m_callbackFunction =
+ safe_cast(&Dbtup::drop_table_logsync_callback);
+
+ int ret = lgman.sync_lsn(signal, lsn, &req, 0);
+ switch(ret){
+ case 0:
+ return;
+ default:
+ ndbout_c("ret: %d", ret);
+ ndbrequire(false);
+ }
+}
+
+void
+Dbtup::drop_table_logsync_callback(Signal* signal,
+ Uint32 tabPtrI,
+ Uint32 logfile_group_id)
+{
+ TablerecPtr tabPtr;
+ tabPtr.i = tabPtrI;
+ ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
+
+ DropTabConf * const dropConf= (DropTabConf *)signal->getDataPtrSend();
+ dropConf->senderRef= reference();
+ dropConf->senderData= tabPtr.p->m_dropTable.tabUserPtr;
+ dropConf->tableId= tabPtr.i;
+ sendSignal(tabPtr.p->m_dropTable.tabUserRef, GSN_DROP_TAB_CONF,
+ signal, DropTabConf::SignalLength, JBB);
+
+ releaseTabDescr(tabPtr.p);
+ initTab(tabPtr.p);
+}
+
+void
+Dbtup::drop_fragment_free_extent_log_buffer_callback(Signal* signal,
+ Uint32 fragPtrI,
+ Uint32 unused)
+{
+ FragrecordPtr fragPtr;
+ fragPtr.i = fragPtrI;
+ ptrCheckGuard(fragPtr, cnoOfFragrec, fragrecord);
+
+ TablerecPtr tabPtr;
+ tabPtr.i = fragPtr.p->fragTableId;
+ ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
+
+ ndbrequire(tabPtr.p->m_no_of_disk_attributes);
+ Disk_alloc_info& alloc_info= fragPtr.p->m_disk_alloc_info;
+
+ for(Uint32 pos = 0; pos<EXTENT_SEARCH_MATRIX_SIZE; pos++)
+ {
+ if(!alloc_info.m_free_extents[pos].isEmpty())
+ {
+ jam();
+ Local_extent_info_list
+ list(c_extent_pool, alloc_info.m_free_extents[pos]);
+ Ptr<Extent_info> ext_ptr;
+ list.first(ext_ptr);
+
+#if NOT_YET_UNDO_FREE_EXTENT
+#error "This code is complete"
+#error "but not needed until we do dealloc of empty extents"
+ Disk_undo::FreeExtent free;
+ free.m_table = tabPtr.i;
+ free.m_fragment = fragPtr.p->fragmentId;
+ free.m_file_no = ext_ptr.p->m_key.m_file_no;
+ free.m_page_no = ext_ptr.p->m_key.m_page_no;
+ free.m_type_length =
+ (Disk_undo::UNDO_FREE_EXTENT << 16) | (sizeof(free) >> 2);
+ Logfile_client lgman(this, c_lgman, fragPtr.p->m_logfile_group_id);
+
+ Logfile_client::Change c[1] = {{ &free, sizeof(free) >> 2 } };
+ Uint64 lsn = lgman.add_entry(c, 1);
+#else
+ Uint64 lsn = 0;
+#endif
+
+ Tablespace_client tsman(signal, c_tsman, tabPtr.i,
+ fragPtr.p->fragmentId,
+ fragPtr.p->m_tablespace_id);
+
+ tsman.free_extent(&ext_ptr.p->m_key, lsn);
+ c_extent_hash.remove(ext_ptr);
+ list.release(ext_ptr);
+
+ signal->theData[0] = ZFREE_EXTENT;
+ signal->theData[1] = tabPtr.i;
+ signal->theData[2] = fragPtr.i;
+ signal->theData[3] = pos;
+ sendSignal(cownref, GSN_CONTINUEB, signal, 4, JBB);
+ return;
+ }
+ }
+ ndbrequire(false);
+}
+
+void
Dbtup::drop_fragment_free_var_pages(Signal* signal)
{
ljam();
@@ -1111,7 +1267,7 @@ Dbtup::drop_fragment_free_var_pages(Signal* signal)
sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
return;
}
-
+ Uint32 logfile_group_id = fragPtr.p->m_logfile_group_id ;
releaseFragPages(fragPtr.p);
Uint32 i;
for(i= 0; i<MAX_FRAG_PER_NODE; i++)
@@ -1125,7 +1281,8 @@ Dbtup::drop_fragment_free_var_pages(Signal* signal)
signal->theData[0]= ZREL_FRAG;
signal->theData[1]= tabPtr.i;
- sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
+ signal->theData[2]= logfile_group_id;
+ sendSignal(cownref, GSN_CONTINUEB, signal, 3, JBB);
return;
}
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
index b0f585e5a67..c8546209f94 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp
@@ -784,6 +784,7 @@ int Dbtup::updateAttributes(KeyReqStruct *req_struct,
memcpy(req_struct->m_tuple_ptr->get_disk_ref_ptr(regTabPtr),
inBuffer+inBufIndex+1, sz << 2);
inBufIndex += 1 + sz;
+ req_struct->in_buf_index = inBufIndex;
}
else
{
diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
index 7c734c99d2c..653a24ba6a1 100644
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
@@ -53,8 +53,7 @@ Dbtup::execACC_SCANREQ(Signal* signal)
// flags
Uint32 bits = 0;
- if (!AccScanReq::getLcpScanFlag(req->requestInfo) ||
- tablePtr.p->m_no_of_disk_attributes == 0)
+ if (!AccScanReq::getLcpScanFlag(req->requestInfo))
{
// seize from pool and link to per-fragment list
LocalDLList<ScanOp> list(c_scanOpPool, frag.m_scanList);
@@ -1051,24 +1050,21 @@ Dbtup::execLCP_FRAG_ORD(Signal* signal)
tablePtr.i = req->tableId;
ptrCheckGuard(tablePtr, cnoOfTablerec, tablerec);
- if(tablePtr.p->m_no_of_disk_attributes)
- {
- jam();
- FragrecordPtr fragPtr;
- Uint32 fragId = req->fragmentId;
- fragPtr.i = RNIL;
- getFragmentrec(fragPtr, fragId, tablePtr.p);
- ndbrequire(fragPtr.i != RNIL);
- Fragrecord& frag = *fragPtr.p;
-
- ndbrequire(frag.m_lcp_scan_op == RNIL && c_lcp_scan_op != RNIL);
- frag.m_lcp_scan_op = c_lcp_scan_op;
- ScanOpPtr scanPtr;
- c_scanOpPool.getPtr(scanPtr, frag.m_lcp_scan_op);
- ndbrequire(scanPtr.p->m_fragPtrI == RNIL);
- scanPtr.p->m_fragPtrI = fragPtr.i;
-
- scanFirst(signal, scanPtr);
- scanPtr.p->m_state = ScanOp::First;
- }
+ jam();
+ FragrecordPtr fragPtr;
+ Uint32 fragId = req->fragmentId;
+ fragPtr.i = RNIL;
+ getFragmentrec(fragPtr, fragId, tablePtr.p);
+ ndbrequire(fragPtr.i != RNIL);
+ Fragrecord& frag = *fragPtr.p;
+
+ ndbrequire(frag.m_lcp_scan_op == RNIL && c_lcp_scan_op != RNIL);
+ frag.m_lcp_scan_op = c_lcp_scan_op;
+ ScanOpPtr scanPtr;
+ c_scanOpPool.getPtr(scanPtr, frag.m_lcp_scan_op);
+ ndbrequire(scanPtr.p->m_fragPtrI == RNIL);
+ scanPtr.p->m_fragPtrI = fragPtr.i;
+
+ scanFirst(signal, scanPtr);
+ scanPtr.p->m_state = ScanOp::First;
}
diff --git a/storage/ndb/src/kernel/blocks/diskpage.hpp b/storage/ndb/src/kernel/blocks/diskpage.hpp
index 044597be1cf..c75f2a0c070 100644
--- a/storage/ndb/src/kernel/blocks/diskpage.hpp
+++ b/storage/ndb/src/kernel/blocks/diskpage.hpp
@@ -154,7 +154,10 @@ struct File_formats
,UNDO_TUP_UPDATE = 4
,UNDO_TUP_FREE = 5
,UNDO_TUP_CREATE = 6
-
+ ,UNDO_TUP_DROP = 7
+ ,UNDO_TUP_ALLOC_EXTENT = 8
+ ,UNDO_TUP_FREE_EXTENT = 9
+
,UNDO_END = 0x7FFF
,UNDO_NEXT_LSN = 0x8000
};
diff --git a/storage/ndb/src/kernel/blocks/lgman.cpp b/storage/ndb/src/kernel/blocks/lgman.cpp
index dff41ab8bca..17a4c4a4a83 100644
--- a/storage/ndb/src/kernel/blocks/lgman.cpp
+++ b/storage/ndb/src/kernel/blocks/lgman.cpp
@@ -1160,14 +1160,15 @@ Lgman::process_log_sync_waiters(Signal* signal, Ptr<Logfile_group> ptr)
bool removed= false;
Ptr<Log_waiter> waiter;
list.first(waiter);
+ Uint32 logfile_group_id = ptr.p->m_logfile_group_id;
if(waiter.p->m_sync_lsn <= ptr.p->m_last_synced_lsn)
{
removed= true;
Uint32 block = waiter.p->m_block;
SimulatedBlock* b = globalData.getBlock(block);
- b->execute(signal, waiter.p->m_callback, 0);
-
+ b->execute(signal, waiter.p->m_callback, logfile_group_id);
+
list.releaseFirst(waiter);
}
@@ -1522,12 +1523,13 @@ Lgman::process_log_buffer_waiters(Signal* signal, Ptr<Logfile_group> ptr)
bool removed= false;
Ptr<Log_waiter> waiter;
list.first(waiter);
+ Uint32 logfile_group_id = ptr.p->m_logfile_group_id;
if(waiter.p->m_size + 2*File_formats::UNDO_PAGE_WORDS < free_buffer)
{
removed= true;
Uint32 block = waiter.p->m_block;
SimulatedBlock* b = globalData.getBlock(block);
- b->execute(signal, waiter.p->m_callback, 0);
+ b->execute(signal, waiter.p->m_callback, logfile_group_id);
list.releaseFirst(waiter);
}
@@ -2061,6 +2063,7 @@ Lgman::execSTART_RECREQ(Signal* signal)
if(ptr.i != RNIL)
{
infoEvent("Applying undo to LCP: %d", m_latest_lcp);
+ ndbout_c("Applying undo to LCP: %d", m_latest_lcp);
find_log_head(signal, ptr);
return;
}
@@ -2680,13 +2683,14 @@ Lgman::execute_undo_record(Signal* signal)
case File_formats::Undofile::UNDO_LCP_FIRST:
{
Uint32 lcp = * (ptr - len + 1);
- if(lcp > m_latest_lcp)
+ if(m_latest_lcp && lcp > m_latest_lcp)
{
// Just ignore
break;
}
- if(lcp < m_latest_lcp ||
+ if(m_latest_lcp == 0 ||
+ lcp < m_latest_lcp ||
(lcp == m_latest_lcp &&
mask == File_formats::Undofile::UNDO_LCP_FIRST))
{
@@ -2699,6 +2703,9 @@ Lgman::execute_undo_record(Signal* signal)
case File_formats::Undofile::UNDO_TUP_UPDATE:
case File_formats::Undofile::UNDO_TUP_FREE:
case File_formats::Undofile::UNDO_TUP_CREATE:
+ case File_formats::Undofile::UNDO_TUP_DROP:
+ case File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT:
+ case File_formats::Undofile::UNDO_TUP_FREE_EXTENT:
tup->disk_restart_undo(signal, lsn, mask, ptr - len + 1, len);
return;
default:
diff --git a/storage/ndb/src/kernel/blocks/print_file.cpp b/storage/ndb/src/kernel/blocks/print_file.cpp
index 14b83cccaee..696658ef8de 100644
--- a/storage/ndb/src/kernel/blocks/print_file.cpp
+++ b/storage/ndb/src/kernel/blocks/print_file.cpp
@@ -304,6 +304,8 @@ print_undo_page(int count, void* ptr, Uint32 sz){
case File_formats::Undofile::UNDO_LCP:
printf("[ %lld LCP %d tab: %d frag: %d ]", lsn,
src[0], src[1] >> 16, src[1] & 0xFFFF);
+ if(g_verbosity <= 3)
+ printf("\n");
break;
case File_formats::Undofile::UNDO_TUP_ALLOC:
if(g_verbosity > 3)
@@ -340,6 +342,48 @@ print_undo_page(int count, void* ptr, Uint32 sz){
req->m_gci);
}
break;
+ case File_formats::Undofile::UNDO_TUP_CREATE:
+ {
+ Dbtup::Disk_undo::Create *req = (Dbtup::Disk_undo::Create*)src;
+ printf("[ %lld Create %d ]", lsn, req->m_table);
+ if(g_verbosity <= 3)
+ printf("\n");
+ break;
+ }
+ case File_formats::Undofile::UNDO_TUP_DROP:
+ {
+ Dbtup::Disk_undo::Drop *req = (Dbtup::Disk_undo::Drop*)src;
+ printf("[ %lld Drop %d ]", lsn, req->m_table);
+ if(g_verbosity <= 3)
+ printf("\n");
+ break;
+ }
+ case File_formats::Undofile::UNDO_TUP_ALLOC_EXTENT:
+ {
+ Dbtup::Disk_undo::AllocExtent *req = (Dbtup::Disk_undo::AllocExtent*)src;
+ printf("[ %lld AllocExtent tab: %d frag: %d file: %d page: %d ]",
+ lsn,
+ req->m_table,
+ req->m_fragment,
+ req->m_file_no,
+ req->m_page_no);
+ if(g_verbosity <= 3)
+ printf("\n");
+ break;
+ }
+ case File_formats::Undofile::UNDO_TUP_FREE_EXTENT:
+ {
+ Dbtup::Disk_undo::FreeExtent *req = (Dbtup::Disk_undo::FreeExtent*)src;
+ printf("[ %lld FreeExtent tab: %d frag: %d file: %d page: %d ]",
+ lsn,
+ req->m_table,
+ req->m_fragment,
+ req->m_file_no,
+ req->m_page_no);
+ if(g_verbosity <= 3)
+ printf("\n");
+ break;
+ }
default:
ndbout_c("[ Unknown type %d len: %d, pos: %d ]", type, len, pos);
if(!(len && type))
@@ -361,11 +405,11 @@ print_undo_page(int count, void* ptr, Uint32 sz){
}
}
}
-
+
if(count == g_uf_zero.m_undo_pages + 1)
{
}
-
+
return 0;
}
diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp
index 89725ca309e..48a8d470ccc 100644
--- a/storage/ndb/src/kernel/blocks/tsman.cpp
+++ b/storage/ndb/src/kernel/blocks/tsman.cpp
@@ -79,12 +79,14 @@ Tsman::Tsman(Block_context& ctx,
addRecSignal(GSN_START_RECREQ, &Tsman::execSTART_RECREQ);
+ addRecSignal(GSN_LCP_FRAG_ORD, &Tsman::execLCP_FRAG_ORD);
addRecSignal(GSN_END_LCP_REQ, &Tsman::execEND_LCP_REQ);
addRecSignal(GSN_GET_TABINFOREQ, &Tsman::execGET_TABINFOREQ);
m_tablespace_hash.setSize(10);
m_file_hash.setSize(10);
+ m_lcp_ongoing = false;
}
Tsman::~Tsman()
@@ -1101,6 +1103,7 @@ Tsman::load_extent_page_callback(Signal* signal,
ptr.p->m_online.m_lcp_free_extent_tail = RNIL;
ptr.p->m_online.m_data_pages = data_pages;
ptr.p->m_online.m_used_extent_cnt = 0;
+ ptr.p->m_online.m_extent_headers_per_extent_page = per_page;
Ptr<Tablespace> ts_ptr;
m_tablespace_pool.getPtr(ts_ptr, ptr.p->m_tablespace_ptr_i);
@@ -1182,9 +1185,8 @@ Tsman::scan_extent_headers(Signal* signal, Ptr<Datafile> ptr)
m_tablespace_pool.getPtr(lg_ptr, ptr.p->m_tablespace_ptr_i);
Uint32 firstFree= RNIL;
- Uint32 size = lg_ptr.p->m_extent_size;
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
+ Uint32 size = ptr.p->m_extent_size;
+ Uint32 per_page = ptr.p->m_online.m_extent_headers_per_extent_page;
Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE;
Uint32 pages= ptr.p->m_online.m_offset_data_pages - 1;
Uint32 datapages= ptr.p->m_online.m_data_pages;
@@ -1410,23 +1412,21 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal)
AllocExtentReq::ErrorCode err;
ndbrequire(m_tablespace_hash.find(ts_ptr, req.request.tablespace_id));
- Uint32 size = ts_ptr.p->m_extent_size;
Local_datafile_list tmp(m_file_pool, ts_ptr.p->m_free_files);
if (tmp.first(file_ptr))
{
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
-
+ Uint32 size = file_ptr.p->m_extent_size;
Uint32 extent = file_ptr.p->m_online.m_first_free_extent;
Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
+ Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
+ Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
Uint32 page_no = extent / per_page;
Uint32 extent_no = extent % per_page;
Page_cache_client::Request preq;
preq.m_page.m_page_no = page_no;
preq.m_page.m_file_no = file_ptr.p->m_file_no;
- preq.m_page.m_page_idx = extent;
/**
* Handling of unmapped extent header pages is not implemented
@@ -1470,6 +1470,7 @@ Tsman::execALLOC_EXTENT_REQ(Signal* signal)
*/
ndbassert(extent >= per_page);
preq.m_page.m_page_no = data_off + size * (extent - /* zero */ per_page);
+ preq.m_page.m_page_idx = extent; // extent_no
AllocExtentReq* rep = (AllocExtentReq*)signal->getDataPtr();
rep->reply.errorCode = 0;
@@ -1501,28 +1502,21 @@ void
Tsman::execFREE_EXTENT_REQ(Signal* signal)
{
jamEntry();
- Ptr<Tablespace> ts_ptr;
Ptr<Datafile> file_ptr;
FreeExtentReq req = *(FreeExtentReq*)signal->getDataPtr();
FreeExtentReq::ErrorCode err = (FreeExtentReq::ErrorCode)0;
- ndbrequire(m_tablespace_hash.find(ts_ptr, req.request.tablespace_id));
Datafile file_key;
file_key.m_file_no = req.request.key.m_file_no;
ndbrequire(m_file_hash.find(file_ptr, file_key));
- Uint32 size = ts_ptr.p->m_extent_size;
-
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
- Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
- Uint32 extent = (req.request.key.m_page_no - data_off) / size + per_page;
-
- Uint32 page_no = extent / per_page;
- Uint32 extent_no = extent % per_page;
+ struct req val = lookup_extent(req.request.key.m_page_no, file_ptr.p);
+ Uint32 extent =
+ (req.request.key.m_page_no - val.m_extent_pages) / val.m_extent_size +
+ file_ptr.p->m_online.m_extent_headers_per_extent_page;
Page_cache_client::Request preq;
- preq.m_page.m_page_no = page_no;
+ preq.m_page.m_page_no = val.m_extent_page_no;
preq.m_page.m_file_no = req.request.key.m_file_no;
ndbout << "Free extent: " << req.request.key << endl;
@@ -1539,16 +1533,38 @@ Tsman::execFREE_EXTENT_REQ(Signal* signal)
File_formats::Datafile::Extent_page* page =
(File_formats::Datafile::Extent_page*)ptr_p;
File_formats::Datafile::Extent_header* header =
- page->get_header(extent_no, size);
+ page->get_header(val.m_extent_no, val.m_extent_size);
ndbrequire(header->m_table == req.request.table_id);
header->m_table = RNIL;
- header->m_next_free_extent= file_ptr.p->m_online.m_lcp_free_extent_head;
- if(file_ptr.p->m_online.m_lcp_free_extent_head == RNIL)
- file_ptr.p->m_online.m_lcp_free_extent_tail= extent;
- file_ptr.p->m_online.m_lcp_free_extent_head= extent;
file_ptr.p->m_online.m_used_extent_cnt--;
+ if (m_lcp_ongoing)
+ {
+ jam();
+ header->m_next_free_extent= file_ptr.p->m_online.m_lcp_free_extent_head;
+ if(file_ptr.p->m_online.m_lcp_free_extent_head == RNIL)
+ file_ptr.p->m_online.m_lcp_free_extent_tail= extent;
+ file_ptr.p->m_online.m_lcp_free_extent_head= extent;
+ }
+ else
+ {
+ jam();
+ header->m_next_free_extent = file_ptr.p->m_online.m_first_free_extent;
+ if (file_ptr.p->m_online.m_first_free_extent == RNIL)
+ {
+ /**
+ * Move from full to free
+ */
+ Ptr<Tablespace> ptr;
+ m_tablespace_pool.getPtr(ptr, file_ptr.p->m_tablespace_ptr_i);
+ Local_datafile_list free(m_file_pool, ptr.p->m_free_files);
+ Local_datafile_list full(m_file_pool, ptr.p->m_full_files);
+ full.remove(file_ptr);
+ free.add(file_ptr);
+ }
+ file_ptr.p->m_online.m_first_free_extent = extent;
+ }
}
else
{
@@ -1583,18 +1599,10 @@ Tsman::update_page_free_bits(Signal* signal,
file_key.m_file_no = key->m_file_no;
ndbrequire(m_file_hash.find(file_ptr, file_key));
- Uint32 size = file_ptr.p->m_extent_size;
- Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
- Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE;
-
- Uint32 extent = (key->m_page_no - data_off) / size + per_page;
- Uint32 page_no = extent / per_page;
- Uint32 extent_no = extent % per_page;
+ struct req val = lookup_extent(key->m_page_no, file_ptr.p);
Page_cache_client::Request preq;
- preq.m_page.m_page_no = page_no;
+ preq.m_page.m_page_no = val.m_extent_page_no;
preq.m_page.m_file_no = key->m_file_no;
/**
@@ -1609,12 +1617,12 @@ Tsman::update_page_free_bits(Signal* signal,
File_formats::Datafile::Extent_page* page =
(File_formats::Datafile::Extent_page*)ptr_p;
File_formats::Datafile::Extent_header* header =
- page->get_header(extent_no, size);
+ page->get_header(val.m_extent_no, val.m_extent_size);
ndbrequire(header->m_table != RNIL);
- Uint32 page_no_in_extent = (key->m_page_no - data_off) % size;
-
+ Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val);
+
/**
* Toggle word
*/
@@ -1637,26 +1645,15 @@ Tsman::get_page_free_bits(Signal* signal, Local_key *key,
{
jamEntry();
- /**
- * XXX make into subroutine
- */
Ptr<Datafile> file_ptr;
Datafile file_key;
file_key.m_file_no = key->m_file_no;
ndbrequire(m_file_hash.find(file_ptr, file_key));
-
- Uint32 size = file_ptr.p->m_extent_size;
- Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
- Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE;
- Uint32 extent = (key->m_page_no - data_off) / size + per_page;
- Uint32 page_no = extent / per_page;
- Uint32 extent_no = extent % per_page;
+ struct req val = lookup_extent(key->m_page_no, file_ptr.p);
Page_cache_client::Request preq;
- preq.m_page.m_page_no = page_no;
+ preq.m_page.m_page_no = val.m_extent_page_no;
preq.m_page.m_file_no = key->m_file_no;
/**
@@ -1671,11 +1668,11 @@ Tsman::get_page_free_bits(Signal* signal, Local_key *key,
File_formats::Datafile::Extent_page* page =
(File_formats::Datafile::Extent_page*)ptr_p;
File_formats::Datafile::Extent_header* header =
- page->get_header(extent_no, size);
+ page->get_header(val.m_extent_no, val.m_extent_size);
ndbrequire(header->m_table != RNIL);
- Uint32 page_no_in_extent = (key->m_page_no - data_off) % size;
+ Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val);
Uint32 bits = header->get_free_bits(page_no_in_extent);
*uncommitted = (bits & UNCOMMITTED_MASK) >> UNCOMMITTED_SHIFT;
*committed = (bits & COMMITTED_MASK);
@@ -1700,19 +1697,11 @@ Tsman::unmap_page(Signal* signal, Local_key *key, Uint32 uncommitted_bits)
Datafile file_key;
file_key.m_file_no = key->m_file_no;
ndbrequire(m_file_hash.find(file_ptr, file_key));
-
- Uint32 size = file_ptr.p->m_extent_size;
- Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
- Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE;
-
- Uint32 extent = (key->m_page_no - data_off) / size + per_page;
- Uint32 page_no = extent / per_page;
- Uint32 extent_no = extent % per_page;
+
+ struct req val = lookup_extent(key->m_page_no, file_ptr.p);
Page_cache_client::Request preq;
- preq.m_page.m_page_no = page_no;
+ preq.m_page.m_page_no = val.m_extent_page_no;
preq.m_page.m_file_no = key->m_file_no;
/**
@@ -1727,12 +1716,12 @@ Tsman::unmap_page(Signal* signal, Local_key *key, Uint32 uncommitted_bits)
File_formats::Datafile::Extent_page* page =
(File_formats::Datafile::Extent_page*)ptr_p;
File_formats::Datafile::Extent_header* header =
- page->get_header(extent_no, size);
+ page->get_header(val.m_extent_no, val.m_extent_size);
ndbrequire(header->m_table != RNIL);
- Uint32 page_no_in_extent = (key->m_page_no - data_off) % size;
-
+ Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val);
+
/**
* Toggle word
*/
@@ -1767,18 +1756,10 @@ Tsman::restart_undo_page_free_bits(Signal* signal,
file_key.m_file_no = key->m_file_no;
ndbrequire(m_file_hash.find(file_ptr, file_key));
- Uint32 size = file_ptr.p->m_extent_size;
- Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
- Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE;
-
- Uint32 extent = (key->m_page_no - data_off) / size + per_page;
- Uint32 page_no = extent / per_page;
- Uint32 extent_no = extent % per_page;
-
+ struct req val = lookup_extent(key->m_page_no, file_ptr.p);
+
Page_cache_client::Request preq;
- preq.m_page.m_page_no = page_no;
+ preq.m_page.m_page_no = val.m_extent_page_no;
preq.m_page.m_file_no = key->m_file_no;
/**
@@ -1793,7 +1774,7 @@ Tsman::restart_undo_page_free_bits(Signal* signal,
File_formats::Datafile::Extent_page* page =
(File_formats::Datafile::Extent_page*)ptr_p;
File_formats::Datafile::Extent_header* header =
- page->get_header(extent_no, size);
+ page->get_header(val.m_extent_no, val.m_extent_size);
Uint64 lsn = 0;
lsn += page->m_page_header.m_page_lsn_hi; lsn <<= 32;
@@ -1816,7 +1797,7 @@ Tsman::restart_undo_page_free_bits(Signal* signal,
return 0;
}
- Uint32 page_no_in_extent = (key->m_page_no - data_off) % size;
+ Uint32 page_no_in_extent = calc_page_no_in_extent(key->m_page_no, &val);
Uint32 src = header->get_free_bits(page_no_in_extent);
ndbrequire(header->m_table == tableId);
@@ -1862,17 +1843,11 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
Datafile file_key;
file_key.m_file_no = req.key.m_file_no;
ndbrequire(m_file_hash.find(file_ptr, file_key));
-
- Uint32 size = file_ptr.p->m_extent_size;
- Uint32 data_off = file_ptr.p->m_online.m_offset_data_pages;
- Uint32 eh_words = File_formats::Datafile::extent_header_words(size);
- Uint32 per_page = File_formats::Datafile::EXTENT_PAGE_WORDS/eh_words;
-
- Uint32 extent = (req.key.m_page_no - data_off) / size;
- Uint32 extent_no = extent % per_page;
+
+ struct req val = lookup_extent(req.key.m_page_no, file_ptr.p);
Page_cache_client::Request preq;
- preq.m_page.m_page_no = 1 /* zero */ + extent / per_page;
+ preq.m_page.m_page_no = val.m_extent_page_no;
preq.m_page.m_file_no = req.key.m_file_no;
Uint32 SZ= File_formats::Datafile::EXTENT_HEADER_BITMASK_BITS_PER_PAGE;
@@ -1891,11 +1866,11 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
File_formats::Datafile::Extent_page* page =
(File_formats::Datafile::Extent_page*)ptr_p;
- header= page->get_header(extent_no, size);
+ header= page->get_header(val.m_extent_no, val.m_extent_size);
ndbrequire(header->m_table == req.request.table_id);
- Uint32 page_no_in_extent = (req.key.m_page_no - data_off) % size;
+ Uint32 page_no_in_extent = calc_page_no_in_extent(req.key.m_page_no, &val);
Uint32 word = header->get_free_word_offset(page_no_in_extent);
Uint32 shift = SZ * (page_no_in_extent & 7);
@@ -1912,7 +1887,7 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
* Search
*/
Uint32 *src= header->m_page_bitmask + word;
- for(page_no= page_no_in_extent; page_no<size; page_no++)
+ for(page_no= page_no_in_extent; page_no<val.m_extent_size; page_no++)
{
src_bits= (* src >> shift) & ((1 << SZ) - 1);
if((src_bits & UNCOMMITTED_MASK) <= reqbits)
@@ -1955,15 +1930,26 @@ Tsman::execALLOC_PAGE_REQ(Signal* signal)
found:
header->update_free_bits(page_no, src_bits | UNCOMMITTED_MASK);
rep->bits= (src_bits & UNCOMMITTED_MASK) >> UNCOMMITTED_SHIFT;
- rep->key.m_page_no= data_off + extent * size + page_no;
+ rep->key.m_page_no=
+ val.m_extent_pages + val.m_extent_no * val.m_extent_size + page_no;
rep->reply.errorCode= 0;
return;
}
void
+Tsman::execLCP_FRAG_ORD(Signal* signal)
+{
+ jamEntry();
+ ndbrequire(!m_lcp_ongoing);
+ m_lcp_ongoing = true;
+}
+
+void
Tsman::execEND_LCP_REQ(Signal* signal)
{
jamEntry();
+ ndbrequire(m_lcp_ongoing);
+ m_lcp_ongoing = false;
/**
* Move extents from "lcp" free list to real free list
diff --git a/storage/ndb/src/kernel/blocks/tsman.hpp b/storage/ndb/src/kernel/blocks/tsman.hpp
index 7c92dfcb068..018d648de07 100644
--- a/storage/ndb/src/kernel/blocks/tsman.hpp
+++ b/storage/ndb/src/kernel/blocks/tsman.hpp
@@ -63,6 +63,7 @@ protected:
void execALLOC_PAGE_REQ(Signal* signal);
+ void execLCP_FRAG_ORD(Signal*);
void execEND_LCP_REQ(Signal*);
void end_lcp(Signal*, Uint32 tablespace, Uint32 list, Uint32 file);
@@ -108,6 +109,7 @@ public:
Uint32 m_offset_data_pages; // 1(zero) + extent header pages
Uint32 m_data_pages;
Uint32 m_used_extent_cnt;
+ Uint32 m_extent_headers_per_extent_page;
} m_online;
struct {
Uint32 m_senderData;
@@ -196,6 +198,7 @@ private:
Datafile_pool m_file_pool;
Tablespace_pool m_tablespace_pool;
+ bool m_lcp_ongoing;
Datafile_hash m_file_hash;
Tablespace_list m_tablespace_list;
Tablespace_hash m_tablespace_hash;
@@ -226,15 +229,52 @@ private:
void release_extent_pages(Signal* signal, Ptr<Datafile> ptr);
void release_extent_pages_callback(Signal*, Uint32, Uint32);
+
+ struct req
+ {
+ Uint32 m_extent_pages;
+ Uint32 m_extent_size;
+ Uint32 m_extent_no; // on extent page
+ Uint32 m_extent_page_no;
+ };
+
+ struct req lookup_extent(Uint32 page_no, const Datafile*) const;
+ Uint32 calc_page_no_in_extent(Uint32 page_no, const struct req* val) const;
};
+inline
+Tsman::req
+Tsman::lookup_extent(Uint32 page_no, const Datafile * filePtrP) const
+{
+ struct req val;
+ val.m_extent_size = filePtrP->m_extent_size;
+ val.m_extent_pages = filePtrP->m_online.m_offset_data_pages;
+ Uint32 per_page = filePtrP->m_online.m_extent_headers_per_extent_page;
+
+ Uint32 extent =
+ (page_no - val.m_extent_pages) / val.m_extent_size + per_page;
+
+ val.m_extent_page_no = extent / per_page;
+ val.m_extent_no = extent % per_page;
+ return val;
+}
+
+inline
+Uint32
+Tsman::calc_page_no_in_extent(Uint32 page_no, const Tsman::req* val) const
+{
+ return (page_no - val->m_extent_pages) % val->m_extent_size;
+}
+
class Tablespace_client
{
+public:
Tsman * m_tsman;
Signal* m_signal;
Uint32 m_table_id;
Uint32 m_fragment_id;
Uint32 m_tablespace_id;
+
public:
Tablespace_client(Signal* signal, Tsman* tsman,
Uint32 table, Uint32 fragment, Uint32 tablespaceId) {
@@ -244,6 +284,8 @@ public:
m_fragment_id= fragment;
m_tablespace_id= tablespaceId;
}
+
+ Tablespace_client(Signal* signal, Tsman* tsman, Local_key* key);
/**
* Return >0 if success, no of pages in extent, sets key
@@ -274,7 +316,7 @@ public:
/**
* Free extent
*/
- int free_extent(Local_key* key);
+ int free_extent(Local_key* key, Uint64 lsn);
/**
* Update page free bits
@@ -307,6 +349,11 @@ public:
* <0 - on error
*/
int get_tablespace_info(CreateFilegroupImplReq* rep);
+
+ /**
+ * Update lsn of page corresponing to key
+ */
+ int update_lsn(Local_key* key, Uint64 lsn);
};
#include <signaldata/Extent.hpp>
@@ -351,12 +398,14 @@ Tablespace_client::alloc_page_from_extent(Local_key* key, Uint32 bits)
inline
int
-Tablespace_client::free_extent(Local_key* key)
+Tablespace_client::free_extent(Local_key* key, Uint64 lsn)
{
FreeExtentReq* req = (FreeExtentReq*)m_signal->theData;
req->request.key = *key;
req->request.table_id = m_table_id;
req->request.tablespace_id = m_tablespace_id;
+ req->request.lsn_hi = (Uint32)(lsn >> 32);
+ req->request.lsn_lo = (Uint32)(lsn & 0xFFFFFFFF);
m_tsman->execFREE_EXTENT_REQ(m_signal);
if(req->reply.errorCode == 0){
@@ -407,5 +456,4 @@ Tablespace_client::restart_undo_page_free_bits(Local_key* key,
page_lsn);
}
-
#endif
diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp
index 0a5700cd5b2..c61288e5b7c 100644
--- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp
+++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp
@@ -1288,6 +1288,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0",
"0",
STR_VALUE(MAX_INT_RNIL) },
+
+ {
+ CFG_DB_MEMREPORT_FREQUENCY,
+ "MemReportFrequency",
+ DB_TOKEN,
+ "Frequency of mem reports in seconds, 0 = only when passing %-limits",
+ ConfigInfo::CI_USED,
+ false,
+ ConfigInfo::CI_INT,
+ "0",
+ "0",
+ STR_VALUE(MAX_INT_RNIL) },
/***************************************************************************
* API
diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
index 0a849f6e00e..29cf869d7bf 100644
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -1921,7 +1921,7 @@ MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete)
m_started_nodes.push_back(nodeId);
rep->setEventType(NDB_LE_Connected);
} else {
- rep->setEventType(NDB_LE_Connected);
+ rep->setEventType(NDB_LE_Disconnected);
if(nfComplete)
{
DBUG_VOID_RETURN;
diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index cbf2b1f5525..ba2329888d2 100644
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -2190,9 +2190,14 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
impl->m_replicaCount = replicaCount;
impl->m_fragmentCount = fragCount;
DBUG_PRINT("info", ("replicaCount=%x , fragCount=%x",replicaCount,fragCount));
- for(i = 0; i < (Uint32) (fragCount*replicaCount); i++)
+ Uint32 pos = 2;
+ for(i = 0; i < (Uint32) fragCount;i++)
{
- impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[i+2]));
+ pos++; // skip logpart
+ for (Uint32 j = 0; j<(Uint32)replicaCount; j++)
+ {
+ impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[pos++]));
+ }
}
Uint32 topBit = (1 << 31);
@@ -2296,7 +2301,7 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t)
}
// blob tables - use "t2" to get values set by kernel
- if (t2->m_noOfBlobs != 0 && createBlobTables(*t2) != 0) {
+ if (t2->m_noOfBlobs != 0 && createBlobTables(t, *t2) != 0) {
int save_code = m_error.code;
(void)dropTableGlobal(*t2);
m_error.code = save_code;
@@ -2310,7 +2315,7 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t)
}
int
-NdbDictionaryImpl::createBlobTables(NdbTableImpl &t)
+NdbDictionaryImpl::createBlobTables(NdbTableImpl& orig, NdbTableImpl &t)
{
DBUG_ENTER("NdbDictionaryImpl::createBlobTables");
for (unsigned i = 0; i < t.m_columns.size(); i++) {
@@ -2319,6 +2324,10 @@ NdbDictionaryImpl::createBlobTables(NdbTableImpl &t)
continue;
NdbTableImpl bt;
NdbBlob::getBlobTable(bt, &t, &c);
+ NdbDictionary::Column::StorageType
+ d = NdbDictionary::Column::StorageTypeDisk;
+ if (orig.m_columns[i]->getStorageType() == d)
+ bt.getColumn("DATA")->setStorageType(d);
if (createTable(bt) != 0) {
DBUG_RETURN(-1);
}
diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
index c6f6e431fba..26d7c13f968 100644
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
@@ -581,7 +581,7 @@ public:
bool setTransporter(class TransporterFacade * tf);
int createTable(NdbTableImpl &t);
- int createBlobTables(NdbTableImpl& t);
+ int createBlobTables(NdbTableImpl& org, NdbTableImpl& created);
int alterTable(NdbTableImpl &t);
int dropTable(const char * name);
int dropTable(NdbTableImpl &);
diff --git a/storage/ndb/src/ndbapi/NdbTransaction.cpp b/storage/ndb/src/ndbapi/NdbTransaction.cpp
index 7d7040a6b74..5e3738823d3 100644
--- a/storage/ndb/src/ndbapi/NdbTransaction.cpp
+++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp
@@ -476,6 +476,7 @@ NdbTransaction::executeNoBlobs(ExecType aTypeOfExec,
* This timeout situation can occur if NDB crashes.
*/
ndbout << "This timeout should never occur, execute(..)" << endl;
+ theError.code = 4012;
setOperationErrorCodeAbort(4012); // Error code for "Cluster Failure"
DBUG_RETURN(-1);
}//if
@@ -1978,6 +1979,14 @@ NdbTransaction::receiveTCINDXCONF(const TcIndxConf * indxConf,
}
} else if ((tNoComp >= tNoSent) &&
(theLastExecOpInList->theCommitIndicator == 1)){
+
+ if (m_abortOption == AO_IgnoreError && theError.code != 0){
+ /**
+ * There's always a TCKEYCONF when using IgnoreError
+ */
+ return -1;
+ }
+
/**********************************************************************/
// We sent the transaction with Commit flag set and received a CONF with
// no Commit flag set. This is clearly an anomaly.
diff --git a/storage/ndb/src/ndbapi/Ndbif.cpp b/storage/ndb/src/ndbapi/Ndbif.cpp
index cd7e779d188..fba40659ec7 100644
--- a/storage/ndb/src/ndbapi/Ndbif.cpp
+++ b/storage/ndb/src/ndbapi/Ndbif.cpp
@@ -1088,6 +1088,7 @@ Ndb::check_send_timeout()
//abort();
#endif
a_con->theReleaseOnClose = true;
+ a_con->theError.code = 4012;
a_con->setOperationErrorCodeAbort(4012);
a_con->theCommitStatus = NdbTransaction::NeedAbort;
a_con->theCompletionStatus = NdbTransaction::CompletedFailure;
@@ -1275,9 +1276,9 @@ Ndb::waitCompletedTransactions(int aMilliSecondsToWait,
NDB_TICKS currTime = NdbTick_CurrentMillisecond();
NDB_TICKS maxTime = currTime + (NDB_TICKS)waitTime;
theMinNoOfEventsToWakeUp = noOfEventsToWaitFor;
+ const int maxsleep = aMilliSecondsToWait > 10 ? 10 : aMilliSecondsToWait;
do {
- if (waitTime < 1000) waitTime = 1000;
- poll_guard->wait_for_input(waitTime);
+ poll_guard->wait_for_input(maxsleep);
if (theNoOfCompletedTransactions >= (Uint32)noOfEventsToWaitFor) {
break;
}//if
diff --git a/storage/ndb/src/ndbapi/TransporterFacade.cpp b/storage/ndb/src/ndbapi/TransporterFacade.cpp
index 6e30e15a325..24bf6dbbc6a 100644
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp
@@ -1384,15 +1384,13 @@ int PollGuard::wait_for_input_in_loop(int wait_time, bool forceSend)
m_tp->forceSend(m_block_no);
else
m_tp->checkForceSend(m_block_no);
- if (wait_time == -1) //Means wait forever
- response_time= WAITFOR_RESPONSE_TIMEOUT;
- else
- response_time= wait_time;
+
NDB_TICKS curr_time = NdbTick_CurrentMillisecond();
NDB_TICKS max_time = curr_time + (NDB_TICKS)wait_time;
+ const int maxsleep = (wait_time == -1 || wait_time > 10) ? 10 : wait_time;
do
{
- wait_for_input(response_time);
+ wait_for_input(maxsleep);
Uint32 state= m_waiter->get_state();
if (state == NO_WAIT)
{
diff --git a/storage/ndb/test/ndbapi/testBasic.cpp b/storage/ndb/test/ndbapi/testBasic.cpp
index 450f1928ec3..e8e4548a91c 100644
--- a/storage/ndb/test/ndbapi/testBasic.cpp
+++ b/storage/ndb/test/ndbapi/testBasic.cpp
@@ -1249,6 +1249,29 @@ runInsertError2(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK;
}
+int
+runBug25090(NDBT_Context* ctx, NDBT_Step* step){
+
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary * dict = pNdb->getDictionary();
+
+ HugoOperations ops(*ctx->getTab());
+
+ int loops = ctx->getNumLoops();
+ const int rows = ctx->getNumRecords();
+
+ while (loops--)
+ {
+ ops.startTransaction(pNdb);
+ ops.pkReadRecord(pNdb, 1, 1);
+ ops.execute_Commit(pNdb, AO_IgnoreError);
+ sleep(10);
+ ops.closeTransaction(pNdb);
+ }
+
+ return NDBT_OK;
+}
+
NDBT_TESTSUITE(testBasic);
TESTCASE("PkInsert",
"Verify that we can insert and delete from this table using PK"
@@ -1509,6 +1532,16 @@ TESTCASE("InsertError", "" ){
TESTCASE("InsertError2", "" ){
INITIALIZER(runInsertError2);
}
+TESTCASE("Fill",
+ "Verify what happens when we fill the db" ){
+ INITIALIZER(runFillTable);
+ INITIALIZER(runPkRead);
+ FINALIZER(runClearTable2);
+}
+TESTCASE("Bug25090",
+ "Verify what happens when we fill the db" ){
+ STEP(runBug25090);
+}
NDBT_TESTSUITE_END(testBasic);
#if 0
diff --git a/storage/ndb/test/ndbapi/testIndex.cpp b/storage/ndb/test/ndbapi/testIndex.cpp
index 68635a52289..7691f036a46 100644
--- a/storage/ndb/test/ndbapi/testIndex.cpp
+++ b/storage/ndb/test/ndbapi/testIndex.cpp
@@ -1238,7 +1238,65 @@ runBug21384(NDBT_Context* ctx, NDBT_Step* step)
return NDBT_OK;
}
+int
+runBug25059(NDBT_Context* ctx, NDBT_Step* step)
+{
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary * dict = pNdb->getDictionary();
+ const NdbDictionary::Index * idx = dict->getIndex(pkIdxName,
+ ctx->getTab()->getName());
+ HugoOperations ops(*ctx->getTab(), idx);
+
+ int res = NDBT_OK;
+ int loops = ctx->getNumLoops();
+ const int rows = ctx->getNumRecords();
+
+ while (res == NDBT_OK && loops--)
+ {
+ ops.startTransaction(pNdb);
+ ops.pkReadRecord(pNdb, 10 + rand() % rows, rows);
+ int tmp;
+ if (tmp = ops.execute_Commit(pNdb, AO_IgnoreError))
+ {
+ if (tmp == 4012)
+ res = NDBT_FAILED;
+ else
+ if (ops.getTransaction()->getNdbError().code == 4012)
+ res = NDBT_FAILED;
+ }
+ ops.closeTransaction(pNdb);
+ }
+
+ loops = ctx->getNumLoops();
+ while (res == NDBT_OK && loops--)
+ {
+ ops.startTransaction(pNdb);
+ ops.pkUpdateRecord(pNdb, 10 + rand() % rows, rows);
+ int tmp;
+ int arg;
+ switch(rand() % 2){
+ case 0:
+ arg = AbortOnError;
+ break;
+ case 1:
+ arg = AO_IgnoreError;
+ ndbout_c("ignore error");
+ break;
+ }
+ if (tmp = ops.execute_Commit(pNdb, (AbortOption)arg))
+ {
+ if (tmp == 4012)
+ res = NDBT_FAILED;
+ else
+ if (ops.getTransaction()->getNdbError().code == 4012)
+ res = NDBT_FAILED;
+ }
+ ops.closeTransaction(pNdb);
+ }
+
+ return res;
+}
NDBT_TESTSUITE(testIndex);
TESTCASE("CreateAll",
@@ -1563,6 +1621,14 @@ TESTCASE("Bug21384",
FINALIZER(createPkIndex_Drop);
FINALIZER(runClearTable);
}
+TESTCASE("Bug25059",
+ "Test that unique indexes and nulls"){
+ TC_PROPERTY("LoggedIndexes", (unsigned)0);
+ INITIALIZER(createPkIndex);
+ INITIALIZER(runLoadTable);
+ STEP(runBug25059);
+ FINALIZER(createPkIndex_Drop);
+}
NDBT_TESTSUITE_END(testIndex);
int main(int argc, const char** argv){
diff --git a/storage/ndb/test/ndbapi/testSystemRestart.cpp b/storage/ndb/test/ndbapi/testSystemRestart.cpp
index 026492d6afa..bd5cd3dd3c8 100644
--- a/storage/ndb/test/ndbapi/testSystemRestart.cpp
+++ b/storage/ndb/test/ndbapi/testSystemRestart.cpp
@@ -1161,6 +1161,64 @@ runBug21536(NDBT_Context* ctx, NDBT_Step* step)
return result;
}
+int
+runBug24664(NDBT_Context* ctx, NDBT_Step* step)
+{
+ int result = NDBT_OK;
+ NdbRestarter restarter;
+ Ndb* pNdb = GETNDB(step);
+ const Uint32 nodeCount = restarter.getNumDbNodes();
+
+ int records = ctx->getNumRecords();
+ UtilTransactions utilTrans(*ctx->getTab());
+ HugoTransactions hugoTrans(*ctx->getTab());
+
+ int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
+ int dump[] = { DumpStateOrd::DihStartLcpImmediately };
+
+ int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
+ NdbLogEventHandle handle =
+ ndb_mgm_create_logevent_handle(restarter.handle, filter);
+
+ struct ndb_logevent event;
+
+ do {
+ CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
+ CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
+ while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
+ event.type != NDB_LE_LocalCheckpointStarted);
+ while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
+ event.type != NDB_LE_LocalCheckpointCompleted);
+
+ if (hugoTrans.loadTable(GETNDB(step), records) != 0){
+ return NDBT_FAILED;
+ }
+
+ restarter.insertErrorInAllNodes(10036); // Hang LCP
+ CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
+ while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
+ event.type != NDB_LE_LocalCheckpointStarted);
+ NdbSleep_SecSleep(3);
+ CHECK(utilTrans.clearTable(pNdb, records) == 0);
+ if (hugoTrans.loadTable(GETNDB(step), records) != 0){
+ return NDBT_FAILED;
+ }
+
+ restarter.insertErrorInAllNodes(10037); // Resume LCP
+ while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
+ event.type != NDB_LE_LocalCheckpointCompleted);
+
+ while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
+ event.type != NDB_LE_GlobalCheckpointCompleted);
+ while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
+ event.type != NDB_LE_GlobalCheckpointCompleted);
+ restarter.restartAll(false, false, true);
+ CHECK(restarter.waitClusterStarted() == 0);
+ } while(false);
+
+ return result;
+}
+
NDBT_TESTSUITE(testSystemRestart);
TESTCASE("SR1",
"Basic system restart test. Focus on testing restart from REDO log.\n"
@@ -1333,6 +1391,14 @@ TESTCASE("Bug21536",
STEP(runBug21536);
FINALIZER(runClearTable);
}
+TESTCASE("Bug24664",
+ "Check handling of LCP skip/keep")
+{
+ INITIALIZER(runWaitStarted);
+ INITIALIZER(runClearTable);
+ STEP(runBug24664);
+ FINALIZER(runClearTable);
+}
NDBT_TESTSUITE_END(testSystemRestart);
int main(int argc, const char** argv){
diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt
index ba4d9ece8d4..9fa6407b823 100644
--- a/storage/ndb/test/run-test/daily-basic-tests.txt
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt
@@ -231,6 +231,14 @@ max-time: 500
cmd: testTimeout
args: T1
+max-time: 500
+cmd: testBasic
+args: -n Bug25090 T1
+
+max-time: 500
+cmd: testIndex
+args: -n Bug25059 -r 3000 T1
+
# SCAN TESTS
#
max-time: 500
@@ -752,6 +760,10 @@ max-time: 300
cmd: testNodeRestart
args: -n Bug24543 T1
+max-time: 1500
+cmd: testSystemRestart
+args: -n Bug24664
+
# OLD FLEX
max-time: 500
cmd: flexBench