diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index fe450868342..37c4971497a 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -126,8 +126,8 @@ static TYPELIB command_typelib= static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"autoclose", 'a', " Auto close the screen on exit for NetWare", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"autoclose", 'a', " Auto close the screen on exit for NetWare", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"count", 'c', "Number of iterations to make. This works with -i (--sleep) only.", diff --git a/client/mysqldump.c b/client/mysqldump.c index 99670dec89c..0d0e67454f8 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1936,7 +1936,7 @@ static int init_dumping(char *database) MYSQL_ROW row; MYSQL_RES *dbinfo; - sprintf(qbuf,"SHOW CREATE DATABASE WITH IF NOT EXISTS %s", + sprintf(qbuf,"SHOW CREATE DATABASE IF NOT EXISTS %s", qdatabase); if (mysql_query_with_error_report(sock, &dbinfo, qbuf)) diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h index f8435e14d97..ff5b6aae02e 100644 --- a/innobase/include/lock0lock.h +++ b/innobase/include/lock0lock.h @@ -463,13 +463,32 @@ lock_rec_hash( ulint space, /* in: space */ ulint page_no);/* in: page number */ /************************************************************************* -Gets the table covered by an IX table lock. */ +Gets the source table of an ALTER TABLE transaction. The table must be +covered by an IX or IS table lock. */ dict_table_t* -lock_get_ix_table( -/*==============*/ - /* out: the table covered by the lock */ - lock_t* lock); /* in: table lock */ +lock_get_src_table( +/*===============*/ + /* out: the source table of transaction, + if it is covered by an IX or IS table lock; + dest if there is no source table, and + NULL if the transaction is locking more than + two tables or an inconsistency is found */ + trx_t* trx, /* in: transaction */ + dict_table_t* dest, /* in: destination of ALTER TABLE */ + ulint* mode); /* out: lock mode of the source table */ +/************************************************************************* +Determine if the given table is exclusively "owned" by the given +transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC +on the table. */ + +ibool +lock_table_exclusive( +/*=================*/ + /* out: TRUE if table is only locked by trx, + with LOCK_IX, and possibly LOCK_AUTO_INC */ + dict_table_t* table, /* in: table */ + trx_t* trx); /* in: transaction */ /************************************************************************* Checks that a transaction id is sensible, i.e., not in the future. */ diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index d4634482752..ea6d26b46fa 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -177,10 +177,12 @@ row_lock_table_for_mysql( /* out: error code or DB_SUCCESS */ row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL table handle */ - dict_table_t* table); /* in: table to LOCK_IX, or NULL + dict_table_t* table, /* in: table to lock, or NULL if prebuilt->table should be locked as LOCK_TABLE_EXP | prebuilt->select_lock_type */ + ulint mode); /* in: lock mode of table */ + /************************************************************************* Does an insert for MySQL. */ diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 479952235f0..32a6bcadecc 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -365,6 +365,21 @@ lock_deadlock_recursive( ulint* cost); /* in/out: number of calculation steps thus far: if this exceeds LOCK_MAX_N_STEPS_... we return TRUE */ + +/************************************************************************* +Gets the type of a lock. */ +UNIV_INLINE +ulint +lock_get_type( +/*==========*/ + /* out: LOCK_TABLE or LOCK_REC */ + lock_t* lock) /* in: lock */ +{ + ut_ad(lock); + + return(lock->type_mode & LOCK_TYPE_MASK); +} + /************************************************************************* Gets the nth bit of a record lock. */ UNIV_INLINE @@ -395,19 +410,6 @@ lock_rec_get_nth_bit( return(ut_bit_get_nth(b, bit_index)); } -/************************************************************************* -Gets the table covered by an IX table lock. */ - -dict_table_t* -lock_get_ix_table( -/*==============*/ - /* out: the table covered by the lock */ - lock_t* lock) /* in: table lock */ -{ - ut_a(lock->type_mode == (LOCK_TABLE | LOCK_IX)); - return(lock->un_member.tab_lock.table); -} - /*************************************************************************/ #define lock_mutex_enter_kernel() mutex_enter(&kernel_mutex) @@ -581,20 +583,6 @@ lock_get_mode( return(lock->type_mode & LOCK_MODE_MASK); } -/************************************************************************* -Gets the type of a lock. */ -UNIV_INLINE -ulint -lock_get_type( -/*==========*/ - /* out: LOCK_TABLE or LOCK_REC */ - lock_t* lock) /* in: lock */ -{ - ut_ad(lock); - - return(lock->type_mode & LOCK_TYPE_MASK); -} - /************************************************************************* Gets the wait flag of a lock. */ UNIV_INLINE @@ -614,6 +602,128 @@ lock_get_wait( return(FALSE); } +/************************************************************************* +Gets the source table of an ALTER TABLE transaction. The table must be +covered by an IX or IS table lock. */ + +dict_table_t* +lock_get_src_table( +/*===============*/ + /* out: the source table of transaction, + if it is covered by an IX or IS table lock; + dest if there is no source table, and + NULL if the transaction is locking more than + two tables or an inconsistency is found */ + trx_t* trx, /* in: transaction */ + dict_table_t* dest, /* in: destination of ALTER TABLE */ + ulint* mode) /* out: lock mode of the source table */ +{ + dict_table_t* src; + lock_t* lock; + + src = NULL; + *mode = LOCK_NONE; + + for (lock = UT_LIST_GET_FIRST(trx->trx_locks); + lock; + lock = UT_LIST_GET_NEXT(trx_locks, lock)) { + lock_table_t* tab_lock; + ulint lock_mode; + if (!(lock_get_type(lock) & LOCK_TABLE)) { + /* We are only interested in table locks. */ + continue; + } + tab_lock = &lock->un_member.tab_lock; + if (dest == tab_lock->table) { + /* We are not interested in the destination table. */ + continue; + } else if (!src) { + /* This presumably is the source table. */ + src = tab_lock->table; + if (UT_LIST_GET_LEN(src->locks) != 1 || + UT_LIST_GET_FIRST(src->locks) != lock) { + /* We only support the case when + there is only one lock on this table. */ + return(NULL); + } + } else if (src != tab_lock->table) { + /* The transaction is locking more than + two tables (src and dest): abort */ + return(NULL); + } + + /* Check that the source table is locked by + LOCK_IX or LOCK_IS. */ + lock_mode = lock_get_mode(lock); + switch (lock_mode) { + case LOCK_IX: + case LOCK_IS: + if (*mode != LOCK_NONE && *mode != lock_mode) { + /* There are multiple locks on src. */ + return(NULL); + } + *mode = lock_mode; + break; + } + } + + if (!src) { + /* No source table lock found: flag the situation to caller */ + src = dest; + } + + return(src); +} + +/************************************************************************* +Determine if the given table is exclusively "owned" by the given +transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC +on the table. */ + +ibool +lock_is_table_exclusive( +/*====================*/ + /* out: TRUE if table is only locked by trx, + with LOCK_IX, and possibly LOCK_AUTO_INC */ + dict_table_t* table, /* in: table */ + trx_t* trx) /* in: transaction */ +{ + lock_t* lock; + bool ok = FALSE; + + ut_ad(table && trx); + + for (lock = UT_LIST_GET_FIRST(table->locks); + lock; + lock = UT_LIST_GET_NEXT(locks, &lock->un_member.tab_lock)) { + if (lock->trx != trx) { + /* A lock on the table is held + by some other transaction. */ + return(FALSE); + } + + if (!(lock_get_type(lock) & LOCK_TABLE)) { + /* We are interested in table locks only. */ + continue; + } + + switch (lock_get_mode(lock)) { + case LOCK_IX: + ok = TRUE; + break; + case LOCK_AUTO_INC: + /* It is allowed for trx to hold an + auto_increment lock. */ + break; + default: + /* Other table locks than LOCK_IX are not allowed. */ + return(FALSE); + } + } + + return(ok); +} + /************************************************************************* Sets the wait flag of a lock and the back pointer in trx to lock. */ UNIV_INLINE diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 0de4b189493..adf9d6695bc 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -782,10 +782,11 @@ row_lock_table_for_mysql( /* out: error code or DB_SUCCESS */ row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL table handle */ - dict_table_t* table) /* in: table to LOCK_IX, or NULL + dict_table_t* table, /* in: table to lock, or NULL if prebuilt->table should be locked as LOCK_TABLE_EXP | prebuilt->select_lock_type */ + ulint mode) /* in: lock mode of table */ { trx_t* trx = prebuilt->trx; que_thr_t* thr; @@ -819,7 +820,7 @@ run_again: trx_start_if_not_started(trx); if (table) { - err = lock_table(0, table, LOCK_IX, thr); + err = lock_table(0, table, mode, thr); } else { err = lock_table(LOCK_TABLE_EXP, prebuilt->table, prebuilt->select_lock_type, thr); diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 27470df81c5..d3b834dd866 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -31,6 +31,7 @@ Created 12/19/1997 Heikki Tuuri #include "pars0pars.h" #include "row0mysql.h" #include "read0read.h" +#include "buf0lru.h" /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 2c8b8816da5..18387107b2f 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -367,3 +367,45 @@ CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` fro drop view v1; drop table t1; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE `test`; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + +create database mysqldump_test_db character set latin2 collate latin2_bin; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CHARACTER SET latin2 COLLATE latin2_bin */; + +USE `mysqldump_test_db`; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + +drop database mysqldump_test_db; diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 70118509d0b..4fe7f57973f 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -2,20 +2,19 @@ use test; drop table if exists t1, t9 ; create table t1 ( -a int not null, b varchar(30), +a int, b varchar(30), primary key(a) ) engine = 'NDB' ; -drop table if exists t9; create table t9 ( -c1 tinyint not null, c2 smallint, c3 mediumint, c4 int, +c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 integer, c6 bigint, c7 float, c8 double, c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4), c13 date, c14 datetime, c15 timestamp(14), c16 time, c17 year, c18 bit, c19 bool, c20 char, -c21 char(10), c22 varchar(30), c23 char(100), c24 char(100), -c25 char(100), c26 char(100), c27 char(100), c28 char(100), -c29 char(100), c30 char(100), c31 enum('one', 'two', 'three'), +c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext, +c25 blob, c26 text, c27 mediumblob, c28 mediumtext, +c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'), c32 set('monday', 'tuesday', 'wednesday'), primary key(c1) ) engine = 'NDB' ; @@ -72,14 +71,14 @@ def test t9 t9 c19 c19 1 1 1 Y 32768 0 63 def test t9 t9 c20 c20 254 1 1 Y 0 0 8 def test t9 t9 c21 c21 253 10 10 Y 0 0 8 def test t9 t9 c22 c22 253 30 30 Y 0 0 8 -def test t9 t9 c23 c23 253 100 8 Y 0 0 8 -def test t9 t9 c24 c24 253 100 8 Y 0 0 8 -def test t9 t9 c25 c25 253 100 4 Y 0 0 8 -def test t9 t9 c26 c26 253 100 4 Y 0 0 8 -def test t9 t9 c27 c27 253 100 10 Y 0 0 8 -def test t9 t9 c28 c28 253 100 10 Y 0 0 8 -def test t9 t9 c29 c29 253 100 8 Y 0 0 8 -def test t9 t9 c30 c30 253 100 8 Y 0 0 8 +def test t9 t9 c23 c23 252 255 8 Y 144 0 63 +def test t9 t9 c24 c24 252 255 8 Y 16 0 8 +def test t9 t9 c25 c25 252 65535 4 Y 144 0 63 +def test t9 t9 c26 c26 252 65535 4 Y 16 0 8 +def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63 +def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8 +def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63 +def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8 def test t9 t9 c31 c31 254 5 3 Y 256 0 8 def test t9 t9 c32 c32 254 24 7 Y 2048 0 8 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 @@ -1188,7 +1187,7 @@ c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; commit ; prepare stmt1 from 'delete from t1 where a=2' ; execute stmt1; -select a,b from t1 where a=2 order by b; +select a,b from t1 where a=2; a b execute stmt1; insert into t1 values(0,NULL); @@ -1270,18 +1269,23 @@ execute stmt1 using @arg00, @arg00; select a,b from t1 where a=@arg00; a b 2 two +execute stmt1 using @arg01, @arg00; select a,b from t1 where a=@arg01; a b +22 two execute stmt1 using @arg00, @arg01; select a,b from t1 where a=@arg00; a b 2 two set @arg00=NULL; set @arg01=2; +execute stmt1 using @arg00, @arg01; +Warnings: +Warning 1263 Data truncated; NULL supplied to NOT NULL column 'a' at row 1 select a,b from t1 order by a; a b +0 two 1 one -2 two 3 three 4 four set @arg00=0; @@ -1302,15 +1306,19 @@ create table t2 as select a,b from t1 ; prepare stmt1 from 'update t1 set a=? where b=? and a in (select ? from t2 where b = ? or a = ?)'; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 select a,b from t1 where a = @arg00 ; a b +23 two prepare stmt1 from 'update t1 set a=? where b=? and a not in (select ? from t2 where b = ? or a = ?)'; execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ; -affected rows: 0 -info: Rows matched: 0 Changed: 0 Warnings: 0 -select a,b from t1 order by a; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +select a,b from t1 order by a ; a b 1 one 2 two @@ -1319,21 +1327,25 @@ a b drop table t2 ; create table t2 ( -a int not null, b varchar(30), +a int, b varchar(30), primary key(a) ) engine = 'NDB' ; insert into t2(a,b) select a, b from t1 ; prepare stmt1 from 'update t1 set a=? where b=? and a in (select ? from t2 where b = ? or a = ?)'; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 select a,b from t1 where a = @arg00 ; a b +23 two prepare stmt1 from 'update t1 set a=? where b=? and a not in (select ? from t2 where b = ? or a = ?)'; execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ; -affected rows: 0 -info: Rows matched: 0 Changed: 0 Warnings: 0 +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 select a,b from t1 order by a ; a b 1 one @@ -1474,7 +1486,7 @@ set @arg02=82 ; set @arg03='8-2' ; prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; -select a,b from t1 where a in (@arg00,@arg02) order by a ; +select a,b from t1 where a in (@arg00,@arg02) ; a b 81 8-1 82 8-2 @@ -1489,6 +1501,7 @@ set @arg00=6 ; set @arg01=1 ; prepare stmt1 from 'insert into t1 set a=?, b=''sechs'' on duplicate key update a=a + ?, b=concat(b,''modified'') '; +execute stmt1 using @arg00, @arg01; select * from t1 order by a; a b 0 NULL @@ -1497,13 +1510,15 @@ a b 3 three 4 four 5 five -6 six +7 sixmodified 8 eight 9 nine 81 8-1 82 8-2 set @arg00=81 ; set @arg01=1 ; +execute stmt1 using @arg00, @arg01; +ERROR 23000: Duplicate entry '82' for key 1 drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'NDB' ; @@ -1526,23 +1541,32 @@ set @x1100="x1100" ; set @100=100 ; set @updated="updated" ; insert into t1 values(1000,'x1000_1') ; +insert into t1 values(@1000,@x1000_2),(@1000,@x1000_3) +on duplicate key update a = a + @100, b = concat(b,@updated) ; select a,b from t1 where a >= 1000 order by a ; a b -1000 x1000_1 +1000 x1000_3 +1100 x1000_1updated delete from t1 where a >= 1000 ; insert into t1 values(1000,'x1000_1') ; prepare stmt1 from ' insert into t1 values(?,?),(?,?) on duplicate key update a = a + ?, b = concat(b,?) '; +execute stmt1 using @1000, @x1000_2, @1000, @x1000_3, @100, @updated ; select a,b from t1 where a >= 1000 order by a ; a b -1000 x1000_1 +1000 x1000_3 +1100 x1000_1updated delete from t1 where a >= 1000 ; insert into t1 values(1000,'x1000_1') ; +execute stmt1 using @1000, @x1000_2, @1100, @x1000_3, @100, @updated ; select a,b from t1 where a >= 1000 order by a ; a b -1000 x1000_1 +1200 x1000_1updatedupdated delete from t1 where a >= 1000 ; prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; +execute stmt1; +execute stmt1; +execute stmt1; test_sequence ------ multi table tests ------ delete from t1 ; @@ -1891,13 +1915,13 @@ def @arg19 254 20 1 Y 128 31 63 def @arg20 254 8192 1 Y 0 31 8 def @arg21 254 8192 10 Y 0 31 8 def @arg22 254 8192 30 Y 0 31 8 -def @arg23 254 8192 8 Y 0 31 8 +def @arg23 254 8192 8 Y 128 31 63 def @arg24 254 8192 8 Y 0 31 8 -def @arg25 254 8192 4 Y 0 31 8 +def @arg25 254 8192 4 Y 128 31 63 def @arg26 254 8192 4 Y 0 31 8 -def @arg27 254 8192 10 Y 0 31 8 +def @arg27 254 8192 10 Y 128 31 63 def @arg28 254 8192 10 Y 0 31 8 -def @arg29 254 8192 8 Y 0 31 8 +def @arg29 254 8192 8 Y 128 31 63 def @arg30 254 8192 8 Y 0 31 8 def @arg31 254 8192 3 Y 0 31 8 def @arg32 254 8192 6 Y 128 31 63 @@ -1938,13 +1962,13 @@ def @arg19 254 20 0 Y 128 31 63 def @arg20 254 8192 0 Y 0 31 8 def @arg21 254 8192 0 Y 0 31 8 def @arg22 254 8192 0 Y 0 31 8 -def @arg23 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 128 31 63 def @arg24 254 8192 0 Y 0 31 8 -def @arg25 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 128 31 63 def @arg26 254 8192 0 Y 0 31 8 -def @arg27 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 128 31 63 def @arg28 254 8192 0 Y 0 31 8 -def @arg29 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 128 31 63 def @arg30 254 8192 0 Y 0 31 8 def @arg31 254 8192 0 Y 0 31 8 def @arg32 254 8192 0 Y 0 31 8 @@ -1988,13 +2012,13 @@ def @arg19 254 20 1 Y 128 31 63 def @arg20 254 8192 1 Y 0 31 8 def @arg21 254 8192 10 Y 0 31 8 def @arg22 254 8192 30 Y 0 31 8 -def @arg23 254 8192 8 Y 0 31 8 +def @arg23 254 8192 8 Y 128 31 63 def @arg24 254 8192 8 Y 0 31 8 -def @arg25 254 8192 4 Y 0 31 8 +def @arg25 254 8192 4 Y 128 31 63 def @arg26 254 8192 4 Y 0 31 8 -def @arg27 254 8192 10 Y 0 31 8 +def @arg27 254 8192 10 Y 128 31 63 def @arg28 254 8192 10 Y 0 31 8 -def @arg29 254 8192 8 Y 0 31 8 +def @arg29 254 8192 8 Y 128 31 63 def @arg30 254 8192 8 Y 0 31 8 def @arg31 254 8192 3 Y 0 31 8 def @arg32 254 8192 6 Y 128 31 63 @@ -2028,13 +2052,13 @@ def @arg19 254 20 0 Y 128 31 63 def @arg20 254 8192 0 Y 0 31 8 def @arg21 254 8192 0 Y 0 31 8 def @arg22 254 8192 0 Y 0 31 8 -def @arg23 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 128 31 63 def @arg24 254 8192 0 Y 0 31 8 -def @arg25 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 128 31 63 def @arg26 254 8192 0 Y 0 31 8 -def @arg27 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 128 31 63 def @arg28 254 8192 0 Y 0 31 8 -def @arg29 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 128 31 63 def @arg30 254 8192 0 Y 0 31 8 def @arg31 254 8192 0 Y 0 31 8 def @arg32 254 8192 0 Y 0 31 8 @@ -2076,13 +2100,13 @@ def @arg19 254 20 1 Y 128 31 63 def @arg20 254 8192 1 Y 0 31 8 def @arg21 254 8192 10 Y 0 31 8 def @arg22 254 8192 30 Y 0 31 8 -def @arg23 254 8192 8 Y 0 31 8 +def @arg23 254 8192 8 Y 128 31 63 def @arg24 254 8192 8 Y 0 31 8 -def @arg25 254 8192 4 Y 0 31 8 +def @arg25 254 8192 4 Y 128 31 63 def @arg26 254 8192 4 Y 0 31 8 -def @arg27 254 8192 10 Y 0 31 8 +def @arg27 254 8192 10 Y 128 31 63 def @arg28 254 8192 10 Y 0 31 8 -def @arg29 254 8192 8 Y 0 31 8 +def @arg29 254 8192 8 Y 128 31 63 def @arg30 254 8192 8 Y 0 31 8 def @arg31 254 8192 3 Y 0 31 8 def @arg32 254 8192 6 Y 128 31 63 @@ -2120,13 +2144,13 @@ def @arg19 254 20 0 Y 128 31 63 def @arg20 254 8192 0 Y 0 31 8 def @arg21 254 8192 0 Y 0 31 8 def @arg22 254 8192 0 Y 0 31 8 -def @arg23 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 128 31 63 def @arg24 254 8192 0 Y 0 31 8 -def @arg25 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 128 31 63 def @arg26 254 8192 0 Y 0 31 8 -def @arg27 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 128 31 63 def @arg28 254 8192 0 Y 0 31 8 -def @arg29 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 128 31 63 def @arg30 254 8192 0 Y 0 31 8 def @arg31 254 8192 0 Y 0 31 8 def @arg32 254 8192 0 Y 0 31 8 @@ -2166,13 +2190,13 @@ def @arg19 254 20 1 Y 128 31 63 def @arg20 254 8192 1 Y 0 31 8 def @arg21 254 8192 10 Y 0 31 8 def @arg22 254 8192 30 Y 0 31 8 -def @arg23 254 8192 8 Y 0 31 8 +def @arg23 254 8192 8 Y 128 31 63 def @arg24 254 8192 8 Y 0 31 8 -def @arg25 254 8192 4 Y 0 31 8 +def @arg25 254 8192 4 Y 128 31 63 def @arg26 254 8192 4 Y 0 31 8 -def @arg27 254 8192 10 Y 0 31 8 +def @arg27 254 8192 10 Y 128 31 63 def @arg28 254 8192 10 Y 0 31 8 -def @arg29 254 8192 8 Y 0 31 8 +def @arg29 254 8192 8 Y 128 31 63 def @arg30 254 8192 8 Y 0 31 8 def @arg31 254 8192 3 Y 0 31 8 def @arg32 254 8192 6 Y 128 31 63 @@ -2204,13 +2228,13 @@ def @arg19 254 20 0 Y 128 31 63 def @arg20 254 8192 0 Y 0 31 8 def @arg21 254 8192 0 Y 0 31 8 def @arg22 254 8192 0 Y 0 31 8 -def @arg23 254 8192 0 Y 0 31 8 +def @arg23 254 8192 0 Y 128 31 63 def @arg24 254 8192 0 Y 0 31 8 -def @arg25 254 8192 0 Y 0 31 8 +def @arg25 254 8192 0 Y 128 31 63 def @arg26 254 8192 0 Y 0 31 8 -def @arg27 254 8192 0 Y 0 31 8 +def @arg27 254 8192 0 Y 128 31 63 def @arg28 254 8192 0 Y 0 31 8 -def @arg29 254 8192 0 Y 0 31 8 +def @arg29 254 8192 0 Y 128 31 63 def @arg30 254 8192 0 Y 0 31 8 def @arg31 254 8192 0 Y 0 31 8 def @arg32 254 8192 0 Y 0 31 8 @@ -2770,14 +2794,14 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 41 4 41 41 41 41 41 41 41 41 41 41 42 4 42 42 42 42 42 42 42 42 42 42 43 4 43 43 43 43 43 43 43 43 43 43 -50 5 50 50 50 50 50 50 50 50 50 50 +50 5 50 50 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 51 5 51 51 51 51 51 51 51 51 51 51 -52 5 52 52 52 52 52 52 52 52 52 52 -53 5 53 53 53 53 53 53 53 53 53 53 -54 5 54 54 54 54 54 54 54 54 54 54 +52 5 52 52 52.00 52.00 52.00 52.00 52.00 52.00 52.00 52.00 +53 5 53 53 53.00 53.00 53.00 53.00 53.00 53.00 53.00 53.00 +54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00 55 5 55 55 55 55 55 55 55 55 55 55 -56 6 56 56 56 56 56 56 56 56 56 56 -57 6 57 57 57 57 57 57 57 57 57 57 +56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00 +57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00 60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index e8bb98d5ae0..7a811e69147 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -136,3 +136,13 @@ create view v1 as select * from t1; --exec $MYSQL_DUMP --skip-comments test drop view v1; drop table t1; + +# +# Bug #6101: create database problem +# + +--exec $MYSQL_DUMP --skip-comments --databases test + +create database mysqldump_test_db character set latin2 collate latin2_bin; +--exec $MYSQL_DUMP --skip-comments --databases mysqldump_test_db; +drop database mysqldump_test_db; diff --git a/mysql-test/t/ps_7ndb.test b/mysql-test/t/ps_7ndb.test index 22370a7f3ac..b558f2f3c21 100644 --- a/mysql-test/t/ps_7ndb.test +++ b/mysql-test/t/ps_7ndb.test @@ -12,365 +12,11 @@ use test; -- source include/have_ndb.inc let $type= 'NDB' ; ---disable_warnings -drop table if exists t1, t9 ; ---enable_warnings -eval create table t1 -( - a int not null, b varchar(30), - primary key(a) -) engine = $type ; - ---disable_warnings -drop table if exists t9; ---enable_warnings -# The used table type doesn't support BLOB/TEXT columns. -# (The server would send error 1163 .) -# So we use char(100) instead. -eval create table t9 -( - c1 tinyint not null, c2 smallint, c3 mediumint, c4 int, - c5 integer, c6 bigint, c7 float, c8 double, - c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4), - c13 date, c14 datetime, c15 timestamp(14), c16 time, - c17 year, c18 bit, c19 bool, c20 char, - c21 char(10), c22 varchar(30), c23 char(100), c24 char(100), - c25 char(100), c26 char(100), c27 char(100), c28 char(100), - c29 char(100), c30 char(100), c31 enum('one', 'two', 'three'), - c32 set('monday', 'tuesday', 'wednesday'), - primary key(c1) -) engine = $type ; +-- source include/ps_create.inc -- source include/ps_renew.inc -- source include/ps_query.inc -# The following line is deactivated, because the ndb storage engine is not able -# to do primary key column updates . -#-- source include/ps_modify.inc -# let's include all statements which will work ---disable_query_log -select '------ delete tests ------' as test_sequence ; ---enable_query_log ---source include/ps_renew.inc - -## delete without parameter -prepare stmt1 from 'delete from t1 where a=2' ; -execute stmt1; -select a,b from t1 where a=2 order by b; -# delete with row not found -execute stmt1; - -## delete with one parameter in the where clause -insert into t1 values(0,NULL); -set @arg00=NULL; -prepare stmt1 from 'delete from t1 where b=?' ; -execute stmt1 using @arg00; -select a,b from t1 where b is NULL ; -set @arg00='one'; -execute stmt1 using @arg00; -select a,b from t1 where b=@arg00; - -## truncate a table ---error 1295 -prepare stmt1 from 'truncate table t1' ; - - ---disable_query_log -select '------ update tests ------' as test_sequence ; ---enable_query_log ---source include/ps_renew.inc - -## update without parameter -prepare stmt1 from 'update t1 set b=''a=two'' where a=2' ; -execute stmt1; -select a,b from t1 where a=2; -# dummy update -execute stmt1; -select a,b from t1 where a=2; - -## update with one parameter in the set clause -set @arg00=NULL; -prepare stmt1 from 'update t1 set b=? where a=2' ; -execute stmt1 using @arg00; -select a,b from t1 where a=2; -set @arg00='two'; -execute stmt1 using @arg00; -select a,b from t1 where a=2; - -## update with one parameter in the where cause -set @arg00=2; -prepare stmt1 from 'update t1 set b=NULL where a=?' ; -execute stmt1 using @arg00; -select a,b from t1 where a=@arg00; -update t1 set b='two' where a=@arg00; -# row not found in update -set @arg00=2000; -execute stmt1 using @arg00; -select a,b from t1 where a=@arg00; - -## update on primary key column (two parameters) -set @arg00=2; -set @arg01=22; -prepare stmt1 from 'update t1 set a=? where a=?' ; -# dummy update -execute stmt1 using @arg00, @arg00; -select a,b from t1 where a=@arg00; -# deactivated primary key column update -# execute stmt1 using @arg01, @arg00; -select a,b from t1 where a=@arg01; -execute stmt1 using @arg00, @arg01; -select a,b from t1 where a=@arg00; -set @arg00=NULL; -set @arg01=2; -# deactivated primary key column update -# execute stmt1 using @arg00, @arg01; -select a,b from t1 order by a; -set @arg00=0; -execute stmt1 using @arg01, @arg00; -select a,b from t1 order by a; - -## update with subquery and several parameters -set @arg00=23; -set @arg01='two'; -set @arg02=2; -set @arg03='two'; -set @arg04=2; ---disable_warnings -drop table if exists t2; ---enable_warnings -# t2 will be of table type 'MYISAM' -create table t2 as select a,b from t1 ; -prepare stmt1 from 'update t1 set a=? where b=? - and a in (select ? from t2 - where b = ? or a = ?)'; ---enable_info -# deactivated primary key column update -# execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ; ---disable_info -select a,b from t1 where a = @arg00 ; -prepare stmt1 from 'update t1 set a=? where b=? - and a not in (select ? from t2 - where b = ? or a = ?)'; ---enable_info -execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ; ---disable_info -select a,b from t1 order by a; -drop table t2 ; -# t2 is now of table type '$type' -# The test battery for table type 'MERGE' gets here only a 'MYISAM' table -eval create table t2 -( - a int not null, b varchar(30), - primary key(a) -) engine = $type ; -insert into t2(a,b) select a, b from t1 ; -prepare stmt1 from 'update t1 set a=? where b=? - and a in (select ? from t2 - where b = ? or a = ?)'; ---enable_info -# deactivated primary key column update -# execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ; ---disable_info -select a,b from t1 where a = @arg00 ; -prepare stmt1 from 'update t1 set a=? where b=? - and a not in (select ? from t2 - where b = ? or a = ?)'; ---enable_info -execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ; ---disable_info -select a,b from t1 order by a ; -drop table t2 ; - -## update with parameters in limit -set @arg00=1; -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit 1'; -execute stmt1 ; -select a,b from t1 where b = 'bla' ; -# currently (May 2004, Version 4.1) it is impossible --- error 1064 -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; - ---disable_query_log -select '------ insert tests ------' as test_sequence ; ---enable_query_log ---source include/ps_renew.inc - -## insert without parameter -prepare stmt1 from 'insert into t1 values(5, ''five'' )'; -execute stmt1; -select a,b from t1 where a = 5; - -## insert with one parameter in values part -set @arg00='six' ; -prepare stmt1 from 'insert into t1 values(6, ? )'; -execute stmt1 using @arg00; -select a,b from t1 where b = @arg00; -# the second insert fails, because the first column is primary key ---error 1062 -execute stmt1 using @arg00; -set @arg00=NULL ; -prepare stmt1 from 'insert into t1 values(0, ? )'; -execute stmt1 using @arg00; -select a,b from t1 where b is NULL; - -## insert with two parameter in values part -set @arg00=8 ; -set @arg01='eight' ; -prepare stmt1 from 'insert into t1 values(?, ? )'; -execute stmt1 using @arg00, @arg01 ; -select a,b from t1 where b = @arg01; -# cases derived from client_test.c: test_null() -set @NULL= null ; -set @arg00= 'abc' ; -# execute must fail, because first column is primary key (-> not null) ---error 1048 -execute stmt1 using @NULL, @NULL ; ---error 1048 -execute stmt1 using @NULL, @NULL ; ---error 1048 -execute stmt1 using @NULL, @arg00 ; ---error 1048 -execute stmt1 using @NULL, @arg00 ; -let $1 = 2; -while ($1) -{ - eval set @arg01= 10000 + $1 ; - execute stmt1 using @arg01, @arg00 ; - dec $1; -} -select * from t1 where a > 10000 order by a ; -delete from t1 where a > 10000 ; -let $1 = 2; -while ($1) -{ - eval set @arg01= 10000 + $1 ; - execute stmt1 using @arg01, @NULL ; - dec $1; -} -select * from t1 where a > 10000 order by a ; -delete from t1 where a > 10000 ; -let $1 = 10; -while ($1) -{ - eval set @arg01= 10000 + $1 ; - execute stmt1 using @arg01, @arg01 ; - dec $1; -} -select * from t1 where a > 10000 order by a ; -delete from t1 where a > 10000 ; - - -## insert with two rows in values part -set @arg00=81 ; -set @arg01='8-1' ; -set @arg02=82 ; -set @arg03='8-2' ; -prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; -execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; -select a,b from t1 where a in (@arg00,@arg02) order by a ; - -## insert with two parameter in the set part -set @arg00=9 ; -set @arg01='nine' ; -prepare stmt1 from 'insert into t1 set a=?, b=? '; -execute stmt1 using @arg00, @arg01 ; -select a,b from t1 where a = @arg00 ; - -## insert with parameters in the ON DUPLICATE KEY part -set @arg00=6 ; -set @arg01=1 ; -prepare stmt1 from 'insert into t1 set a=?, b=''sechs'' - on duplicate key update a=a + ?, b=concat(b,''modified'') '; -# There is no primary key collision, so there will be no key column update -# If a key column update would be necessary occurs BUG#4312 -# deactivated, activate when BUG#4312: is solved -# execute stmt1 using @arg00, @arg01; -select * from t1 order by a; -set @arg00=81 ; -set @arg01=1 ; -# deactivated, activate when BUG#4312: is solved -# execute stmt1 using @arg00, @arg01; - -## insert, autoincrement column and ' SELECT LAST_INSERT_ID() ' -# cases derived from client_test.c: test_bug3117() ---disable_warnings -drop table if exists t2 ; ---enable_warnings -# The test battery for table type 'MERGE' gets here only a 'MYISAM' table -eval create table t2 (id int auto_increment primary key) -ENGINE= $type ; -prepare stmt1 from ' select last_insert_id() ' ; -insert into t2 values (NULL) ; -execute stmt1 ; -insert into t2 values (NULL) ; -execute stmt1 ; -drop table t2 ; - -## many parameters -set @1000=1000 ; -set @x1000_2="x1000_2" ; -set @x1000_3="x1000_3" ; - -set @x1000="x1000" ; -set @1100=1100 ; -set @x1100="x1100" ; -set @100=100 ; -set @updated="updated" ; -insert into t1 values(1000,'x1000_1') ; -# deactivated, activate when BUG#4312: is solved -# insert into t1 values(@1000,@x1000_2),(@1000,@x1000_3) -# on duplicate key update a = a + @100, b = concat(b,@updated) ; -select a,b from t1 where a >= 1000 order by a ; -delete from t1 where a >= 1000 ; -insert into t1 values(1000,'x1000_1') ; -prepare stmt1 from ' insert into t1 values(?,?),(?,?) - on duplicate key update a = a + ?, b = concat(b,?) '; -# deactivated, activate when BUG#4312: is solved -# execute stmt1 using @1000, @x1000_2, @1000, @x1000_3, @100, @updated ; -select a,b from t1 where a >= 1000 order by a ; -delete from t1 where a >= 1000 ; -insert into t1 values(1000,'x1000_1') ; -# deactivated, activate when BUG#4312: is solved -# execute stmt1 using @1000, @x1000_2, @1100, @x1000_3, @100, @updated ; -select a,b from t1 where a >= 1000 order by a ; -delete from t1 where a >= 1000 ; - -## replace -prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; ---error 1031 - -## multi table statements ---disable_query_log -select '------ multi table tests ------' as test_sequence ; ---enable_query_log -# cases derived from client_test.c: test_multi -delete from t1 ; -delete from t9 ; -insert into t1(a,b) values (1, 'one'), (2, 'two'), (3, 'three') ; -insert into t9 (c1,c21) - values (1, 'one'), (2, 'two'), (3, 'three') ; -prepare stmt_delete from " delete t1, t9 - from t1, t9 where t1.a=t9.c1 and t1.b='updated' "; -prepare stmt_update from " update t1, t9 - set t1.b='updated', t9.c21='updated' - where t1.a=t9.c1 and t1.a=? "; -prepare stmt_select1 from " select a, b from t1 order by a" ; -prepare stmt_select2 from " select c1, c21 from t9 order by c1" ; -set @arg00= 1 ; -let $1= 3 ; -while ($1) -{ - execute stmt_update using @arg00 ; - execute stmt_delete ; - execute stmt_select1 ; - execute stmt_select2 ; - set @arg00= @arg00 + 1 ; - dec $1 ; -} - +-- source include/ps_modify.inc -- source include/ps_modify1.inc -- source include/ps_conv.inc diff --git a/ndb/include/kernel/signaldata/BackupImpl.hpp b/ndb/include/kernel/signaldata/BackupImpl.hpp index 1872069daa7..2ac91570aad 100644 --- a/ndb/include/kernel/signaldata/BackupImpl.hpp +++ b/ndb/include/kernel/signaldata/BackupImpl.hpp @@ -78,15 +78,15 @@ public: STATIC_CONST( SignalLength = 3 ); enum ErrorCode { - Undefined = 200, - FailedToAllocateBuffers = 202, - FailedToSetupFsBuffers = 203, - FailedToAllocateTables = 204, - FailedInsertFileHeader = 205, - FailedInsertTableList = 206, - FailedAllocateTableMem = 207, - FailedToAllocateFileRecord = 208, - FailedToAllocateAttributeRecord = 209 + Undefined = 1340, + FailedToAllocateBuffers = 1342, + FailedToSetupFsBuffers = 1343, + FailedToAllocateTables = 1344, + FailedInsertFileHeader = 1345, + FailedInsertTableList = 1346, + FailedAllocateTableMem = 1347, + FailedToAllocateFileRecord = 1348, + FailedToAllocateAttributeRecord = 1349 }; private: Uint32 backupId; diff --git a/ndb/include/kernel/signaldata/BackupSignalData.hpp b/ndb/include/kernel/signaldata/BackupSignalData.hpp index 42eb8464d53..fb018026a49 100644 --- a/ndb/include/kernel/signaldata/BackupSignalData.hpp +++ b/ndb/include/kernel/signaldata/BackupSignalData.hpp @@ -119,12 +119,13 @@ public: private: enum ErrorCodes { - Undefined = 100, - IAmNotMaster = 101, - OutOfBackupRecord = 102, - OutOfResources = 103, - SequenceFailure = 104, - BackupDefinitionNotImplemented = 105 + Undefined = 1300, + IAmNotMaster = 1301, + OutOfBackupRecord = 1302, + OutOfResources = 1303, + SequenceFailure = 1304, + BackupDefinitionNotImplemented = 1305, + CannotBackupDiskless = 1306 }; Uint32 senderData; Uint32 errorCode; @@ -232,13 +233,13 @@ public: STATIC_CONST( SignalLength = 3 ); enum RequestType { - ClientAbort = 1, - BackupComplete = 2, - BackupFailure = 3, // General backup failure coordinator -> slave - LogBufferFull = 4, // slave -> coordinator - FileOrScanError = 5, // slave -> coordinator - BackupFailureDueToNodeFail = 6, // slave -> slave - OkToClean = 7 // master -> slave + ClientAbort = 1321, + BackupComplete = 1322, + BackupFailure = 1323, // General backup failure coordinator -> slave + LogBufferFull = 1324, // slave -> coordinator + FileOrScanError = 1325, // slave -> coordinator + BackupFailureDueToNodeFail = 1326, // slave -> slave + OkToClean = 1327 // master -> slave }; private: Uint32 requestType; diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index a23417f153a..dc4f745adb2 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -375,6 +375,7 @@ extern "C" { int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle); int ndb_mgm_get_connected_port(NdbMgmHandle handle); const char *ndb_mgm_get_connected_host(NdbMgmHandle handle); + const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz); /** * Destroy a management server handle @@ -746,6 +747,7 @@ extern "C" { int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*, int param, const char ** value); int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **); + int ndb_mgm_check_connection(NdbMgmHandle handle); #ifdef __cplusplus } #endif diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp index 80449628867..8461658748e 100644 --- a/ndb/include/mgmcommon/ConfigRetriever.hpp +++ b/ndb/include/mgmcommon/ConfigRetriever.hpp @@ -72,6 +72,7 @@ public: Uint32 get_mgmd_port() const; const char *get_mgmd_host() const; + const char *get_connectstring(char *buf, int buf_sz) const; Uint32 get_configuration_nodeid() const; private: diff --git a/ndb/include/ndbapi/ndb_cluster_connection.hpp b/ndb/include/ndbapi/ndb_cluster_connection.hpp index 59d5a038844..6fa25caf5d0 100644 --- a/ndb/include/ndbapi/ndb_cluster_connection.hpp +++ b/ndb/include/ndbapi/ndb_cluster_connection.hpp @@ -30,12 +30,14 @@ class Ndb_cluster_connection { public: Ndb_cluster_connection(const char * connect_string = 0); ~Ndb_cluster_connection(); - int connect(int reconnect= 0); + int connect(int no_retries, int retry_delay_in_seconds, int verbose); int start_connect_thread(int (*connect_callback)(void)= 0); + const char *get_connectstring(char *buf, int buf_sz) const; + int get_connected_port() const; + const char *get_connected_host() const; private: friend void* run_ndb_cluster_connection_connect_thread(void*); void connect_thread(); - char *m_connect_string; TransporterFacade *m_facade; ConfigRetriever *m_config_retriever; NdbThread *m_connect_thread; diff --git a/ndb/include/ndbapi/ndberror.h b/ndb/include/ndbapi/ndberror.h index 5c2d85b82a6..ceb1881a4cc 100644 --- a/ndb/include/ndbapi/ndberror.h +++ b/ndb/include/ndbapi/ndberror.h @@ -46,7 +46,8 @@ typedef enum ndberror_cl_internal_error = 12, ndberror_cl_function_not_implemented = 13, ndberror_cl_unknown_error_code = 14, - ndberror_cl_node_shutdown = 15 + ndberror_cl_node_shutdown = 15, + ndberror_cl_configuration = 16 } ndberror_classification_enum; diff --git a/ndb/src/common/logger/Logger.cpp b/ndb/src/common/logger/Logger.cpp index 1dc3bd43716..f6f70fbeff7 100644 --- a/ndb/src/common/logger/Logger.cpp +++ b/ndb/src/common/logger/Logger.cpp @@ -174,7 +174,7 @@ Logger::addHandler(const BaseString &logstring) { logstring.split(logdest, ";"); for(i = 0; i < logdest.size(); i++) { - DBUG_PRINT("info",("adding: %s",logdest[i])); + DBUG_PRINT("info",("adding: %s",logdest[i].c_str())); Vector v_type_args; logdest[i].split(v_type_args, ":", 2); diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index 0af5eb2f83c..744412870f5 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -90,6 +90,11 @@ const char *ConfigRetriever::get_mgmd_host() const return ndb_mgm_get_connected_host(m_handle); } +const char *ConfigRetriever::get_connectstring(char *buf, int buf_sz) const +{ + return ndb_mgm_get_connectstring(m_handle, buf, buf_sz); +} + //**************************************************************************** //**************************************************************************** diff --git a/ndb/src/kernel/blocks/backup/Backup.cpp b/ndb/src/kernel/blocks/backup/Backup.cpp index e6fe63d9014..9fc00883792 100644 --- a/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/ndb/src/kernel/blocks/backup/Backup.cpp @@ -863,6 +863,13 @@ Backup::execBACKUP_REQ(Signal* signal) sendBackupRef(senderRef, signal, senderData, BackupRef::IAmNotMaster); return; }//if + + if (m_diskless) + { + sendBackupRef(senderRef, signal, senderData, + BackupRef::CannotBackupDiskless); + return; + } if(dataLen32 != 0) { jam(); diff --git a/ndb/src/kernel/blocks/backup/Backup.hpp b/ndb/src/kernel/blocks/backup/Backup.hpp index 4dc2cd13ae0..fb29cb03b96 100644 --- a/ndb/src/kernel/blocks/backup/Backup.hpp +++ b/ndb/src/kernel/blocks/backup/Backup.hpp @@ -526,6 +526,7 @@ public: NdbNodeBitmask c_aliveNodes; DLList c_backups; Config c_defaults; + Uint32 m_diskless; STATIC_CONST(NO_OF_PAGES_META_FILE = 2); diff --git a/ndb/src/kernel/blocks/backup/BackupInit.cpp b/ndb/src/kernel/blocks/backup/BackupInit.cpp index 8daad05558b..d98541f2ea8 100644 --- a/ndb/src/kernel/blocks/backup/BackupInit.cpp +++ b/ndb/src/kernel/blocks/backup/BackupInit.cpp @@ -42,6 +42,7 @@ Backup::Backup(const Configuration & conf) : ndbrequire(p != 0); Uint32 noBackups = 0, noTables = 0, noAttribs = 0; + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &m_diskless)); ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_BACKUPS, &noBackups); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs)); diff --git a/ndb/src/mgmapi/LocalConfig.cpp b/ndb/src/mgmapi/LocalConfig.cpp index 8f1e2ee8100..1dc805557ee 100644 --- a/ndb/src/mgmapi/LocalConfig.cpp +++ b/ndb/src/mgmapi/LocalConfig.cpp @@ -298,13 +298,21 @@ char * LocalConfig::makeConnectString(char *buf, int sz) { int p= BaseString::snprintf(buf,sz,"nodeid=%d", _ownNodeId); - for (int i = 0; (i < ids.size()) && (sz-p > 0); i++) - { - if (ids[i].type != MgmId_TCP) - continue; - p+=BaseString::snprintf(buf+p,sz-p,",%s:%d", - ids[i].name.c_str(), ids[i].port); - } + if (p < sz) + for (unsigned i = 0; i < ids.size(); i++) + { + if (ids[i].type != MgmId_TCP) + continue; + int new_p= p+BaseString::snprintf(buf+p,sz-p,",%s:%d", + ids[i].name.c_str(), ids[i].port); + if (new_p < sz) + p= new_p; + else + { + buf[p]= 0; + break; + } + } buf[sz-1]=0; return buf; } diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 831d14eac52..651a4a8a725 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -84,7 +84,6 @@ typedef Parser Parser_t; #define NDB_MGM_MAX_ERR_DESC_SIZE 256 struct ndb_mgm_handle { - char * connectstring; int cfg_i; int connected; @@ -1677,6 +1676,12 @@ const char *ndb_mgm_get_connected_host(NdbMgmHandle handle) return handle->cfg.ids[handle->cfg_i].name.c_str(); } +extern "C" +const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz) +{ + return handle->cfg.makeConnectString(buf,buf_sz); +} + extern "C" int ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype) @@ -1934,4 +1939,38 @@ ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **purged){ return res; } +extern "C" +int +ndb_mgm_check_connection(NdbMgmHandle handle){ + CHECK_HANDLE(handle, 0); + CHECK_CONNECTED(handle, 0); + SocketOutputStream out(handle->socket); + SocketInputStream in(handle->socket, handle->read_timeout); + char buf[32]; + + if (out.println("check connection")) + goto ndb_mgm_check_connection_error; + + if (out.println("")) + goto ndb_mgm_check_connection_error; + + in.gets(buf, sizeof(buf)); + if(strcmp("check connection reply\n", buf)) + goto ndb_mgm_check_connection_error; + + in.gets(buf, sizeof(buf)); + if(strcmp("result: Ok\n", buf)) + goto ndb_mgm_check_connection_error; + + in.gets(buf, sizeof(buf)); + if(strcmp("\n", buf)) + goto ndb_mgm_check_connection_error; + + return 0; + +ndb_mgm_check_connection_error: + ndb_mgm_disconnect(handle); + return -1; +} + template class Vector*>; diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index bfe8b6786b4..7ef62da9bb3 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -54,10 +54,11 @@ public: * * @return true until quit/bye/exit has been typed */ - int execute(const char *_line, int _try_reconnect=-1); + int execute(const char *_line, int _try_reconnect=-1, int *error= 0); private: void printError(); + int execute_impl(const char *_line); /** * Analyse the command line, after the first token. @@ -96,7 +97,7 @@ private: void executeShow(char* parameters); void executeConnect(char* parameters); void executePurge(char* parameters); - void executeShutdown(char* parameters); + int executeShutdown(char* parameters); void executeRun(char* parameters); void executeInfo(char* parameters); void executeClusterLog(char* parameters); @@ -121,7 +122,7 @@ public: void executeStatus(int processId, const char* parameters, bool all); void executeEventReporting(int processId, const char* parameters, bool all); void executeDumpState(int processId, const char* parameters, bool all); - void executeStartBackup(char * parameters); + int executeStartBackup(char * parameters); void executeAbortBackup(char * parameters); void executeRep(char* parameters); @@ -156,6 +157,7 @@ private: bool connected; int m_verbose; int try_reconnect; + int m_error; #ifdef HAVE_GLOBAL_REPLICATION NdbRepHandle m_repserver; const char *rep_host; @@ -179,9 +181,9 @@ Ndb_mgmclient::~Ndb_mgmclient() { delete m_cmd; } -int Ndb_mgmclient::execute(const char *_line, int _try_reconnect) +int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, int *error) { - return m_cmd->execute(_line,_try_reconnect); + return m_cmd->execute(_line,_try_reconnect,error); } int Ndb_mgmclient::disconnect() @@ -227,7 +229,7 @@ extern "C" { #include #include -int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect) +int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error) { if (argc <= 0) return 0; @@ -236,7 +238,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect) { _line.appfmt(" %s", argv[i]); } - return m_cmd->execute(_line.c_str(),_try_reconnect); + return m_cmd->execute(_line.c_str(),_try_reconnect, error); } /***************************************************************************** @@ -277,7 +279,7 @@ static const char* helpText = "REP CONNECT Connect to REP server on host:port\n" #endif "PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n" -"CONNECT Connect to management server (reconnect if already connected)\n" +"CONNECT [] Connect to management server (reconnect if already connected)\n" "QUIT Quit management client\n" ; @@ -427,6 +429,8 @@ emptyString(const char* s) void CommandInterpreter::printError() { + if (ndb_mgm_check_connection(m_mgmsrv)) + connected= false; ndbout_c("* %5d: %s", ndb_mgm_get_latest_error(m_mgmsrv), ndb_mgm_get_latest_error_msg(m_mgmsrv)); @@ -469,13 +473,24 @@ CommandInterpreter::disconnect() //***************************************************************************** int -CommandInterpreter::execute(const char *_line, int _try_reconnect) +CommandInterpreter::execute(const char *_line, int _try_reconnect, + int *error) { - DBUG_ENTER("CommandInterpreter::execute"); - DBUG_PRINT("info",("line=\"%s\"",_line)); - if (_try_reconnect >= 0) try_reconnect=_try_reconnect; + int result= execute_impl(_line); + if (error) + *error= m_error; + return result; +} + +int +CommandInterpreter::execute_impl(const char *_line) +{ + DBUG_ENTER("CommandInterpreter::execute_impl"); + DBUG_PRINT("enter",("line=\"%s\"",_line)); + m_error= 0; + char * line; if(_line == NULL) { // ndbout << endl; @@ -488,84 +503,80 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect) DBUG_RETURN(true); } - for (unsigned int i = 0; i < strlen(line); ++i) { - line[i] = toupper(line[i]); - } - // if there is anything in the line proceed char* firstToken = strtok(line, " "); char* allAfterFirstToken = strtok(NULL, ""); - if (strcmp(firstToken, "HELP") == 0 || - strcmp(firstToken, "?") == 0) { + if (strcasecmp(firstToken, "HELP") == 0 || + strcasecmp(firstToken, "?") == 0) { executeHelp(allAfterFirstToken); DBUG_RETURN(true); } - else if (strcmp(firstToken, "CONNECT") == 0) { + else if (strcasecmp(firstToken, "CONNECT") == 0) { executeConnect(allAfterFirstToken); DBUG_RETURN(true); } + else if((strcasecmp(firstToken, "QUIT") == 0 || + strcasecmp(firstToken, "EXIT") == 0 || + strcasecmp(firstToken, "BYE") == 0) && + allAfterFirstToken == NULL){ + DBUG_RETURN(false); + } if (!connect()) DBUG_RETURN(true); - if (strcmp(firstToken, "SHOW") == 0) { + if (strcasecmp(firstToken, "SHOW") == 0) { executeShow(allAfterFirstToken); DBUG_RETURN(true); } - else if (strcmp(firstToken, "SHUTDOWN") == 0) { - executeShutdown(allAfterFirstToken); + else if (strcasecmp(firstToken, "SHUTDOWN") == 0) { + m_error= executeShutdown(allAfterFirstToken); DBUG_RETURN(true); } - else if (strcmp(firstToken, "CLUSTERLOG") == 0){ + else if (strcasecmp(firstToken, "CLUSTERLOG") == 0){ executeClusterLog(allAfterFirstToken); DBUG_RETURN(true); } - else if(strcmp(firstToken, "START") == 0 && + else if(strcasecmp(firstToken, "START") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ - executeStartBackup(allAfterFirstToken); + strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ + m_error= executeStartBackup(allAfterFirstToken); DBUG_RETURN(true); } - else if(strcmp(firstToken, "ABORT") == 0 && + else if(strcasecmp(firstToken, "ABORT") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ + strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ executeAbortBackup(allAfterFirstToken); DBUG_RETURN(true); } - else if (strcmp(firstToken, "PURGE") == 0) { + else if (strcasecmp(firstToken, "PURGE") == 0) { executePurge(allAfterFirstToken); DBUG_RETURN(true); } #ifdef HAVE_GLOBAL_REPLICATION - else if(strcmp(firstToken, "REPLICATION") == 0 || - strcmp(firstToken, "REP") == 0) { + else if(strcasecmp(firstToken, "REPLICATION") == 0 || + strcasecmp(firstToken, "REP") == 0) { executeRep(allAfterFirstToken); DBUG_RETURN(true); } #endif // HAVE_GLOBAL_REPLICATION - else if(strcmp(firstToken, "ENTER") == 0 && + else if(strcasecmp(firstToken, "ENTER") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "SINGLE USER MODE ", + strncasecmp(allAfterFirstToken, "SINGLE USER MODE ", sizeof("SINGLE USER MODE") - 1) == 0){ executeEnterSingleUser(allAfterFirstToken); DBUG_RETURN(true); } - else if(strcmp(firstToken, "EXIT") == 0 && + else if(strcasecmp(firstToken, "EXIT") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "SINGLE USER MODE ", + strncasecmp(allAfterFirstToken, "SINGLE USER MODE ", sizeof("SINGLE USER MODE") - 1) == 0){ executeExitSingleUser(allAfterFirstToken); DBUG_RETURN(true); } - else if (strcmp(firstToken, "ALL") == 0) { + else if (strcasecmp(firstToken, "ALL") == 0) { analyseAfterFirstToken(-1, allAfterFirstToken); - } - else if((strcmp(firstToken, "QUIT") == 0 || - strcmp(firstToken, "EXIT") == 0 || - strcmp(firstToken, "BYE") == 0) && - allAfterFirstToken == NULL){ - DBUG_RETURN(false); } else { /** * First token should be a digit, node ID @@ -573,12 +584,12 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect) int nodeId; if (! convert(firstToken, nodeId)) { - ndbout << "Invalid command: " << line << endl; + ndbout << "Invalid command: " << _line << endl; ndbout << "Type HELP for help." << endl << endl; DBUG_RETURN(true); } - if (nodeId < 0) { + if (nodeId <= 0) { ndbout << "Invalid node ID: " << firstToken << "." << endl; DBUG_RETURN(true); } @@ -639,7 +650,7 @@ CommandInterpreter::analyseAfterFirstToken(int processId, ExecuteFunction fun = 0; const char * command = 0; for(int i = 0; i*fun)(processId, allAfterSecondToken, false); ndbout << endl; @@ -705,10 +716,10 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, const char * allAfterSecondToken) { int nodeId = 0; - if(strcmp(cmd, "STOP") == 0) { + if(strcasecmp(cmd, "STOP") == 0) { ndbout_c("Executing STOP on all nodes."); (this->*fun)(nodeId, allAfterSecondToken, true); - } else if(strcmp(cmd, "RESTART") == 0) { + } else if(strcasecmp(cmd, "RESTART") == 0) { ndbout_c("Executing RESTART on all nodes."); ndbout_c("Starting shutdown. This may take a while. Please wait..."); (this->*fun)(nodeId, allAfterSecondToken, true); @@ -723,7 +734,7 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, } NdbAutoPtr ap1((char*)cl); while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) { - if(strcmp(cmd, "STATUS") != 0) + if(strcasecmp(cmd, "STATUS") != 0) ndbout_c("Executing %s on node %d.", cmd, nodeId); (this->*fun)(nodeId, allAfterSecondToken, true); ndbout << endl; @@ -751,7 +762,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, firstTokenAfterLog[i] = toupper(firstTokenAfterLog[i]); } - if (strcmp(firstTokenAfterLog, "BLOCK") != 0) { + if (strcasecmp(firstTokenAfterLog, "BLOCK") != 0) { ndbout << "Unexpected value: " << firstTokenAfterLog << ". Expected BLOCK." << endl; return false; @@ -764,7 +775,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, } char* secondTokenAfterLog = strtok(allAfterFirstToken, " "); - if (strcmp(secondTokenAfterLog, "=") != 0) { + if (strcasecmp(secondTokenAfterLog, "=") != 0) { ndbout << "Unexpected value: " << secondTokenAfterLog << ". Expected =." << endl; return false; @@ -772,7 +783,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, char* blockName = strtok(NULL, " "); bool all = false; - if (blockName != NULL && (strcmp(blockName, "ALL") == 0)) { + if (blockName != NULL && (strcasecmp(blockName, "ALL") == 0)) { all = true; } while (blockName != NULL) { @@ -823,15 +834,15 @@ CommandInterpreter::executeHelp(char* parameters) ndbout << " = " << "0 - 15" << endl; ndbout << " = " << "ALL | Any database node id" << endl; ndbout << endl; - } else if (strcmp(parameters, "SHOW") == 0) { + } else if (strcasecmp(parameters, "SHOW") == 0) { ndbout << helpTextShow; #ifdef HAVE_GLOBAL_REPLICATION - } else if (strcmp(parameters, "REPLICATION") == 0 || - strcmp(parameters, "REP") == 0) { + } else if (strcasecmp(parameters, "REPLICATION") == 0 || + strcasecmp(parameters, "REP") == 0) { ndbout << helpTextRep; #endif // HAVE_GLOBAL_REPLICATION #ifdef VM_TRACE // DEBUG ONLY - } else if (strcmp(parameters, "DEBUG") == 0) { + } else if (strcasecmp(parameters, "DEBUG") == 0) { ndbout << helpTextDebug; #endif } else { @@ -845,23 +856,23 @@ CommandInterpreter::executeHelp(char* parameters) * SHUTDOWN *****************************************************************************/ -void +int CommandInterpreter::executeShutdown(char* parameters) { ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv); if(state == NULL) { ndbout_c("Could not get status"); printError(); - return; + return 1; } NdbAutoPtr ap1((char*)state); int result = 0; result = ndb_mgm_stop(m_mgmsrv, 0, 0); if (result < 0) { - ndbout << "Shutdown failed." << endl; + ndbout << "Shutdown off NDB Cluster storage node(s) failed." << endl; printError(); - return; + return result; } ndbout << result << " NDB Cluster storage node(s) have shutdown." << endl; @@ -876,21 +887,23 @@ CommandInterpreter::executeShutdown(char* parameters) ndbout << "Unable to locate management server, " << "shutdown manually with STOP" << endl; - return; + return 1; } } } - result = 0; result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id); if (result <= 0) { - ndbout << "Shutdown failed." << endl; + ndbout << "Shutdown of NDB Cluster management server failed." << endl; printError(); - return; + if (result == 0) + return 1; + return result; } + connected = false; ndbout << "NDB Cluster management server shutdown." << endl; - exit(0); + return 0; } /***************************************************************************** @@ -939,7 +952,7 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, const char *hostname= node_state->connect_address; if (hostname == 0 || strlen(hostname) == 0 - || strcmp(hostname,"0.0.0.0") == 0) + || strcasecmp(hostname,"0.0.0.0") == 0) ndbout << " "; else ndbout << "\t@" << hostname; @@ -984,9 +997,9 @@ CommandInterpreter::executePurge(char* parameters) break; char* firstToken = strtok(parameters, " "); char* nextToken = strtok(NULL, " \0"); - if (strcmp(firstToken,"STALE") == 0 && + if (strcasecmp(firstToken,"STALE") == 0 && nextToken && - strcmp(nextToken, "SESSIONS") == 0) { + strcasecmp(nextToken, "SESSIONS") == 0) { command_ok= 1; break; } @@ -1019,9 +1032,6 @@ CommandInterpreter::executeShow(char* parameters) { int i; if (emptyString(parameters)) { - ndbout << "Cluster Configuration" << endl - << "---------------------" << endl; - ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv); if(state == NULL) { ndbout_c("Could not get status"); @@ -1081,22 +1091,24 @@ CommandInterpreter::executeShow(char* parameters) } } + ndbout << "Cluster Configuration" << endl + << "---------------------" << endl; print_nodes(state, it, "ndbd", ndb_nodes, NDB_MGM_NODE_TYPE_NDB, master_id); print_nodes(state, it, "ndb_mgmd", mgm_nodes, NDB_MGM_NODE_TYPE_MGM, 0); print_nodes(state, it, "mysqld", api_nodes, NDB_MGM_NODE_TYPE_API, 0); // ndbout << helpTextShow; return; - } else if (strcmp(parameters, "PROPERTIES") == 0 || - strcmp(parameters, "PROP") == 0) { + } else if (strcasecmp(parameters, "PROPERTIES") == 0 || + strcasecmp(parameters, "PROP") == 0) { ndbout << "SHOW PROPERTIES is not yet implemented." << endl; // ndbout << "_mgmtSrvr.getConfig()->print();" << endl; /* XXX */ - } else if (strcmp(parameters, "CONFIGURATION") == 0 || - strcmp(parameters, "CONFIG") == 0){ + } else if (strcasecmp(parameters, "CONFIGURATION") == 0 || + strcasecmp(parameters, "CONFIG") == 0){ ndbout << "SHOW CONFIGURATION is not yet implemented." << endl; //nbout << "_mgmtSrvr.getConfig()->printConfigFile();" << endl; /* XXX */ - } else if (strcmp(parameters, "PARAMETERS") == 0 || - strcmp(parameters, "PARAMS") == 0 || - strcmp(parameters, "PARAM") == 0) { + } else if (strcasecmp(parameters, "PARAMETERS") == 0 || + strcasecmp(parameters, "PARAMS") == 0 || + strcasecmp(parameters, "PARAM") == 0) { ndbout << "SHOW PARAMETERS is not yet implemented." << endl; // ndbout << "_mgmtSrvr.getConfig()->getConfigInfo()->print();" // << endl; /* XXX */ @@ -1109,6 +1121,14 @@ void CommandInterpreter::executeConnect(char* parameters) { disconnect(); + if (!emptyString(parameters)) { + if (ndb_mgm_set_connectstring(m_mgmsrv, + BaseString(parameters).trim().c_str())) + { + printError(); + return; + } + } connect(); } @@ -1132,7 +1152,7 @@ CommandInterpreter::executeClusterLog(char* parameters) /******************** * CLUSTERLOG FILTER ********************/ - if (strcmp(item, "FILTER") == 0) { + if (strcasecmp(item, "FILTER") == 0) { item = strtok_r(NULL, " ", &tmpPtr); if (item == NULL) { @@ -1141,21 +1161,21 @@ CommandInterpreter::executeClusterLog(char* parameters) while (item != NULL) { snprintf(name, sizeof(name), item); - if (strcmp(item, "ALL") == 0) { + if (strcasecmp(item, "ALL") == 0) { severity = NDB_MGM_CLUSTERLOG_ALL; - } else if (strcmp(item, "ALERT") == 0) { + } else if (strcasecmp(item, "ALERT") == 0) { severity = NDB_MGM_CLUSTERLOG_ALERT; - } else if (strcmp(item, "CRITICAL") == 0) { + } else if (strcasecmp(item, "CRITICAL") == 0) { severity = NDB_MGM_CLUSTERLOG_CRITICAL; - } else if (strcmp(item, "ERROR") == 0) { + } else if (strcasecmp(item, "ERROR") == 0) { severity = NDB_MGM_CLUSTERLOG_ERROR; - } else if (strcmp(item, "WARNING") == 0) { + } else if (strcasecmp(item, "WARNING") == 0) { severity = NDB_MGM_CLUSTERLOG_WARNING; - } else if (strcmp(item, "INFO") == 0) { + } else if (strcasecmp(item, "INFO") == 0) { severity = NDB_MGM_CLUSTERLOG_INFO; - } else if (strcmp(item, "DEBUG") == 0) { + } else if (strcasecmp(item, "DEBUG") == 0) { severity = NDB_MGM_CLUSTERLOG_DEBUG; - } else if (strcmp(item, "OFF") == 0) { + } else if (strcasecmp(item, "OFF") == 0) { severity = NDB_MGM_CLUSTERLOG_OFF; } else { isOk = false; @@ -1168,17 +1188,17 @@ CommandInterpreter::executeClusterLog(char* parameters) ndbout << "Missing argument(s)." << endl; } else if (isOk) { if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) { - if(strcmp(name, "ALL") == 0 || strcmp(name, "all") == 0) { + if(strcasecmp(name, "ALL") == 0) { ndbout << "All severities levels enabled." << endl; - } else if(strcmp(name, "OFF") == 0 || strcmp(name, "off") == 0) { + } else if(strcasecmp(name, "OFF") == 0) { ndbout << "Cluster logging enabled." << endl; } else { ndbout << name << " events disabled." << endl; } } else { - if(strcmp(name, "ALL") == 0) { + if(strcasecmp(name, "ALL") == 0) { ndbout << "All severities levels disabled." << endl; - } else if(strcmp(name, "OFF") == 0) { + } else if(strcasecmp(name, "OFF") == 0) { ndbout << "Cluster logging disabled." << endl; } else { ndbout << name << " events enabled." << endl; @@ -1191,7 +1211,7 @@ CommandInterpreter::executeClusterLog(char* parameters) /******************** * CLUSTERLOG INFO ********************/ - } else if (strcmp(item, "INFO") == 0) { + } else if (strcasecmp(item, "INFO") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; @@ -1216,7 +1236,7 @@ CommandInterpreter::executeClusterLog(char* parameters) /******************** * CLUSTERLOG OFF ********************/ - } else if (strcmp(item, "OFF") == 0) { + } else if (strcasecmp(item, "OFF") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Couldn't get status" << endl; @@ -1234,7 +1254,7 @@ CommandInterpreter::executeClusterLog(char* parameters) /******************** * CLUSTERLOG ON ********************/ - } else if (strcmp(item, "ON") == 0) { + } else if (strcasecmp(item, "ON") == 0) { Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); if(enabled == NULL) { ndbout << "Could not get status" << endl; @@ -1358,11 +1378,11 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, char * tmpPtr = 0; char * item = strtok_r(tmpString, " ", &tmpPtr); while(item != NULL){ - if(strcmp(item, "-N") == 0) + if(strcasecmp(item, "-N") == 0) nostart = 1; - if(strcmp(item, "-I") == 0) + if(strcasecmp(item, "-I") == 0) initialstart = 1; - if(strcmp(item, "-A") == 0) + if(strcasecmp(item, "-A") == 0) abort = 1; item = strtok_r(NULL, " ", &tmpPtr); } @@ -1591,7 +1611,7 @@ CommandInterpreter::executeTrace(int /*processId*/, int result = _mgmtSrvr.setTraceNo(processId, traceNo); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } #endif } @@ -1751,7 +1771,7 @@ CommandInterpreter::executeSet(int /*processId*/, } } else { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; if (configBackupFileUpdated && configPrimaryFileUpdated) { ndbout << "The configuration files are however updated and " << "the value will be used next time the process is restarted." @@ -1786,7 +1806,7 @@ void CommandInterpreter::executeGetStat(int /*processId*/, MgmtSrvr::Statistics statistics; int result = _mgmtSrvr.getStatistics(processId, statistics); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; return; } #endif @@ -1856,7 +1876,7 @@ CommandInterpreter::executeEventReporting(int processId, /***************************************************************************** * Backup *****************************************************************************/ -void +int CommandInterpreter::executeStartBackup(char* /*parameters*/) { struct ndb_mgm_reply reply; @@ -1869,7 +1889,7 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/) ndbout << "Start of backup failed" << endl; printError(); close(fd); - return; + return result; } char *tmp; @@ -1900,6 +1920,7 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/) } while(tmp && tmp[0] != 0); close(fd); + return 0; } void @@ -1966,7 +1987,7 @@ CommandInterpreter::executeRep(char* parameters) unsigned int repId; - if (!strcmp(firstToken, "CONNECT")) { + if (!strcasecmp(firstToken, "CONNECT")) { char * host = strtok(NULL, "\0"); for (unsigned int i = 0; i < strlen(host); ++i) { host[i] = tolower(host[i]); @@ -2001,30 +2022,30 @@ CommandInterpreter::executeRep(char* parameters) /******** * START ********/ - if (!strcmp(firstToken, "START")) { + if (!strcasecmp(firstToken, "START")) { unsigned int req; char *startType = strtok(NULL, "\0"); if (startType == NULL) { req = GrepReq::START; - } else if (!strcmp(startType, "SUBSCRIPTION")) { + } else if (!strcasecmp(startType, "SUBSCRIPTION")) { req = GrepReq::START_SUBSCR; - } else if (!strcmp(startType, "METALOG")) { + } else if (!strcasecmp(startType, "METALOG")) { req = GrepReq::START_METALOG; - } else if (!strcmp(startType, "METASCAN")) { + } else if (!strcasecmp(startType, "METASCAN")) { req = GrepReq::START_METASCAN; - } else if (!strcmp(startType, "DATALOG")) { + } else if (!strcasecmp(startType, "DATALOG")) { req = GrepReq::START_DATALOG; - } else if (!strcmp(startType, "DATASCAN")) { + } else if (!strcasecmp(startType, "DATASCAN")) { req = GrepReq::START_DATASCAN; - } else if (!strcmp(startType, "REQUESTOR")) { + } else if (!strcasecmp(startType, "REQUESTOR")) { req = GrepReq::START_REQUESTOR; - } else if (!strcmp(startType, "TRANSFER")) { + } else if (!strcasecmp(startType, "TRANSFER")) { req = GrepReq::START_TRANSFER; - } else if (!strcmp(startType, "APPLY")) { + } else if (!strcasecmp(startType, "APPLY")) { req = GrepReq::START_APPLY; - } else if (!strcmp(startType, "DELETE")) { + } else if (!strcasecmp(startType, "DELETE")) { req = GrepReq::START_DELETE; } else { ndbout_c("Illegal argument to command 'REPLICATION START'"); @@ -2044,7 +2065,7 @@ CommandInterpreter::executeRep(char* parameters) /******** * STOP ********/ - if (!strcmp(firstToken, "STOP")) { + if (!strcasecmp(firstToken, "STOP")) { unsigned int req; char *startType = strtok(NULL, " "); unsigned int epoch = 0; @@ -2054,7 +2075,7 @@ CommandInterpreter::executeRep(char* parameters) * Stop immediately */ req = GrepReq::STOP; - } else if (!strcmp(startType, "EPOCH")) { + } else if (!strcasecmp(startType, "EPOCH")) { char *strEpoch = strtok(NULL, "\0"); if(strEpoch == NULL) { ndbout_c("Epoch expected!"); @@ -2062,23 +2083,23 @@ CommandInterpreter::executeRep(char* parameters) } req = GrepReq::STOP; epoch=atoi(strEpoch); - } else if (!strcmp(startType, "SUBSCRIPTION")) { + } else if (!strcasecmp(startType, "SUBSCRIPTION")) { req = GrepReq::STOP_SUBSCR; - } else if (!strcmp(startType, "METALOG")) { + } else if (!strcasecmp(startType, "METALOG")) { req = GrepReq::STOP_METALOG; - } else if (!strcmp(startType, "METASCAN")) { + } else if (!strcasecmp(startType, "METASCAN")) { req = GrepReq::STOP_METASCAN; - } else if (!strcmp(startType, "DATALOG")) { + } else if (!strcasecmp(startType, "DATALOG")) { req = GrepReq::STOP_DATALOG; - } else if (!strcmp(startType, "DATASCAN")) { + } else if (!strcasecmp(startType, "DATASCAN")) { req = GrepReq::STOP_DATASCAN; - } else if (!strcmp(startType, "REQUESTOR")) { + } else if (!strcasecmp(startType, "REQUESTOR")) { req = GrepReq::STOP_REQUESTOR; - } else if (!strcmp(startType, "TRANSFER")) { + } else if (!strcasecmp(startType, "TRANSFER")) { req = GrepReq::STOP_TRANSFER; - } else if (!strcmp(startType, "APPLY")) { + } else if (!strcasecmp(startType, "APPLY")) { req = GrepReq::STOP_APPLY; - } else if (!strcmp(startType, "DELETE")) { + } else if (!strcasecmp(startType, "DELETE")) { req = GrepReq::STOP_DELETE; } else { ndbout_c("Illegal argument to command 'REPLICATION STOP'"); @@ -2097,7 +2118,7 @@ CommandInterpreter::executeRep(char* parameters) /********* * STATUS *********/ - if (!strcmp(firstToken, "STATUS")) { + if (!strcasecmp(firstToken, "STATUS")) { struct rep_state repstate; int result = ndb_rep_get_status(m_repserver, &repId, &reply, &repstate); @@ -2117,7 +2138,7 @@ CommandInterpreter::executeRep(char* parameters) /********* * QUERY (see repapi.h for querable counters) *********/ - if (!strcmp(firstToken, "QUERY")) { + if (!strcasecmp(firstToken, "QUERY")) { char *query = strtok(NULL, "\0"); int queryCounter=-1; if(query != NULL) { diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index 08d5d60cfab..84e27790705 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -60,10 +60,15 @@ static const char default_prompt[]= "ndb_mgm> "; static unsigned _try_reconnect; static char *opt_connect_str= 0; static const char *prompt= default_prompt; +static char *opt_execute_str= 0; static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_mgm"), + { "execute", 'e', + "execute command and exit", + (gptr*) &opt_execute_str, (gptr*) &opt_execute_str, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "try-reconnect", 't', "Specify number of tries for connecting to ndb_mgmd (0 = infinite)", (gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0, @@ -156,19 +161,25 @@ int main(int argc, char** argv){ opt_connect_str= buf; } - if (!isatty(0)) + if (!isatty(0) || opt_execute_str) { prompt= 0; } - ndbout << "-- NDB Cluster -- Management Client --" << endl; - signal(SIGPIPE, handler); - com = new Ndb_mgmclient(opt_connect_str,1); - while(read_and_execute(_try_reconnect)); + int ret= 0; + if (!opt_execute_str) + { + ndbout << "-- NDB Cluster -- Management Client --" << endl; + while(read_and_execute(_try_reconnect)); + } + else + { + com->execute(opt_execute_str,_try_reconnect, &ret); + } delete com; - return 0; + return ret; } diff --git a/ndb/src/mgmclient/ndb_mgmclient.hpp b/ndb/src/mgmclient/ndb_mgmclient.hpp index ea592dfdf4e..bffdf69f920 100644 --- a/ndb/src/mgmclient/ndb_mgmclient.hpp +++ b/ndb/src/mgmclient/ndb_mgmclient.hpp @@ -23,8 +23,8 @@ class Ndb_mgmclient public: Ndb_mgmclient(const char*,int verbose=0); ~Ndb_mgmclient(); - int execute(const char *_line, int _try_reconnect=-1); - int execute(int argc, char** argv, int _try_reconnect=-1); + int execute(const char *_line, int _try_reconnect=-1, int *error= 0); + int execute(int argc, char** argv, int _try_reconnect=-1, int *error= 0); int disconnect(); private: CommandInterpreter *m_cmd; diff --git a/ndb/src/mgmsrv/CommandInterpreter.cpp b/ndb/src/mgmsrv/CommandInterpreter.cpp index 2a054a01f1e..02bf24f1d9c 100644 --- a/ndb/src/mgmsrv/CommandInterpreter.cpp +++ b/ndb/src/mgmsrv/CommandInterpreter.cpp @@ -113,6 +113,11 @@ private: void * m_ptr; }; +const char *CommandInterpreter::get_error_text(int err_no) +{ + return _mgmtSrvr.getErrorText(err_no, m_err_str, sizeof(m_err_str)); +} + //***************************************************************************** //***************************************************************************** int CommandInterpreter::readAndExecute() { @@ -600,8 +605,9 @@ stopCallback(int nodeId, void * anyData, int errCode){ ndbout << "\nNode " << nodeId << " has shutdown" << endl; } else { MgmtSrvr * mgm = (MgmtSrvr *)anyData; + char err_str[1024]; ndbout << "Node " << nodeId << " has not shutdown: " - << mgm->getErrorText(errCode) << endl; + << mgm->getErrorText(errCode,err_str,sizeof(err_str)) << endl; } } @@ -653,7 +659,8 @@ versionCallback(int nodeId, int version, void * anyData, int errCode){ } else { MgmtSrvr * mgm = (MgmtSrvr *)anyData; - ndbout << mgm->getErrorText(errCode) << endl; + char err_str[1024]; + ndbout << mgm->getErrorText(errCode,err_str,sizeof(err_str)) << endl; } } @@ -671,7 +678,7 @@ void CommandInterpreter::executeStop(int processId, result = _mgmtSrvr.stopNode(processId, false, stopCallback, this); if(result != 0) - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } @@ -686,7 +693,7 @@ void CommandInterpreter::executeStart(int processId, const char* parameters, int result = _mgmtSrvr.start(processId); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -719,7 +726,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, stopCallback, this); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -760,7 +767,7 @@ CommandInterpreter::executeDumpState(int processId, const char* parameters, free(tmpString); int result = _mgmtSrvr.dumpState(processId, pars, no); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -781,7 +788,7 @@ void CommandInterpreter::executeStatus(int processId, &status, &version, &startPhase, &system, &dynamicId, &nodeGroup, &connectCount); if(result != 0){ - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; return; } @@ -875,7 +882,7 @@ void CommandInterpreter::executeLogLevel(int processId, int result = _mgmtSrvr.setNodeLogLevel(processId, logLevel); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } #endif } @@ -913,7 +920,7 @@ void CommandInterpreter::executeError(int processId, int result = _mgmtSrvr.insertError(processId, errorNo); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } free(newpar); } @@ -953,7 +960,7 @@ void CommandInterpreter::executeTrace(int processId, int result = _mgmtSrvr.setTraceNo(processId, traceNo); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } free(newpar); } @@ -974,7 +981,7 @@ void CommandInterpreter::executeLog(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::InOut, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -995,7 +1002,7 @@ void CommandInterpreter::executeLogIn(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::In, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1014,7 +1021,7 @@ void CommandInterpreter::executeLogOut(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Out, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1035,7 +1042,7 @@ void CommandInterpreter::executeLogOff(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Off, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1054,7 +1061,7 @@ void CommandInterpreter::executeTestOn(int processId, int result = _mgmtSrvr.startSignalTracing(processId); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1073,7 +1080,7 @@ void CommandInterpreter::executeTestOff(int processId, int result = _mgmtSrvr.stopSignalTracing(processId); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1126,7 +1133,7 @@ void CommandInterpreter::executeEventReporting(int processId, ndbout_c("processId %d", processId); int result = _mgmtSrvr.setEventReportingLevel(processId, logLevel); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } #endif } @@ -1136,7 +1143,7 @@ CommandInterpreter::executeStartBackup(char* parameters) { Uint32 backupId; int result = _mgmtSrvr.startBackup(backupId); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } else { // ndbout << "Start of backup ordered" << endl; } @@ -1153,7 +1160,7 @@ CommandInterpreter::executeAbortBackup(char* parameters) { } int result = _mgmtSrvr.abortBackup(bid); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } else { ndbout << "Abort of backup " << bid << " ordered" << endl; } @@ -1174,7 +1181,7 @@ CommandInterpreter::executeEnterSingleUser(char* parameters) { } int result = _mgmtSrvr.enterSingleUser(0, nodeId,0,0); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } else { ndbout << "Entering single user mode, granting access for node " << nodeId << " OK." << endl; diff --git a/ndb/src/mgmsrv/CommandInterpreter.hpp b/ndb/src/mgmsrv/CommandInterpreter.hpp index db23f76a5bd..1a5184361d6 100644 --- a/ndb/src/mgmsrv/CommandInterpreter.hpp +++ b/ndb/src/mgmsrv/CommandInterpreter.hpp @@ -55,6 +55,9 @@ public: int readAndExecute(); private: + char m_err_str[1024]; + const char *get_error_text(int err_no); + /** * Read a string, and return a pointer to it. * diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 986da71a8e8..061aa2e0cb8 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -49,6 +49,8 @@ #include +#include + #include #include #include @@ -264,16 +266,6 @@ MgmtSrvr::isEventLogFilterEnabled(int severity) static ErrorItem errorTable[] = { - {200, "Backup undefined error"}, - {202, "Backup failed to allocate buffers (check configuration)"}, - {203, "Backup failed to setup fs buffers (check configuration)"}, - {204, "Backup failed to allocate tables (check configuration)"}, - {205, "Backup failed to insert file header (check configuration)"}, - {206, "Backup failed to insert table list (check configuration)"}, - {207, "Backup failed to allocate table memory (check configuration)"}, - {208, "Backup failed to allocate file record (check configuration)"}, - {209, "Backup failed to allocate attribute record (check configuration)"}, - {MgmtSrvr::NO_CONTACT_WITH_PROCESS, "No contact with the process (dead ?)."}, {MgmtSrvr::PROCESS_NOT_CONFIGURED, "The process is not configured."}, {MgmtSrvr::WRONG_PROCESS_TYPE, @@ -1856,18 +1848,21 @@ MgmtSrvr::dumpState(int processId, const Uint32 args[], Uint32 no) //**************************************************************************** //**************************************************************************** -const char* MgmtSrvr::getErrorText(int errorCode) +const char* MgmtSrvr::getErrorText(int errorCode, char *buf, int buf_sz) { - static char text[255]; for (int i = 0; i < noOfErrorCodes; ++i) { if (errorCode == errorTable[i]._errorCode) { - return errorTable[i]._errorText; + BaseString::snprintf(buf, buf_sz, errorTable[i]._errorText); + buf[buf_sz-1]= 0; + return buf; } } - - BaseString::snprintf(text, 255, "Unknown management server error code %d", errorCode); - return text; + + ndb_error_string(errorCode, buf, buf_sz); + buf[buf_sz-1]= 0; + + return buf; } void diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 2ab11250d81..1afb0848ecc 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -466,7 +466,7 @@ public: * @param errorCode: Error code to get a match error text for. * @return The error text. */ - const char* getErrorText(int errorCode); + const char* getErrorText(int errorCode, char *buf, int buf_sz); /** * Get configuration diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 0394c4e80bb..5834d40cc78 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -244,6 +244,8 @@ ParserRow commands[] = { MGM_CMD("purge stale sessions", &MgmApiSession::purge_stale_sessions, ""), + MGM_CMD("check connection", &MgmApiSession::check_connection, ""), + MGM_END() }; @@ -579,7 +581,7 @@ MgmApiSession::insertError(Parser::Context &, m_output->println("insert error reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -597,7 +599,7 @@ MgmApiSession::setTrace(Parser::Context &, m_output->println("set trace reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -665,7 +667,7 @@ MgmApiSession::startBackup(Parser::Context &, m_output->println("start backup reply"); if(result != 0) - m_output->println("result: %s(%d)", m_mgmsrv.getErrorText(result), result); + m_output->println("result: %s(%d)", get_error_text(result), result); else{ m_output->println("result: Ok"); m_output->println("id: %d", backupId); @@ -685,7 +687,7 @@ MgmApiSession::startBackup(Parser::Context &, m_output->println("start backup reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else{ m_output->println("result: Ok"); m_output->println("id: %d", backupId); @@ -705,7 +707,7 @@ MgmApiSession::abortBackup(Parser::Context &, m_output->println("abort backup reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -727,7 +729,7 @@ MgmApiSession::repCommand(Parser::Context &, m_output->println("global replication reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else{ m_output->println("result: Ok"); m_output->println("id: %d", repReqId); @@ -749,7 +751,7 @@ MgmApiSession::dumpState(Parser::Context &, int result = m_mgmsrv.dumpState(node, args_str.c_str()); m_output->println("dump state reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -834,7 +836,7 @@ MgmApiSession::stopSignalLog(Parser::Context &, m_output->println("stop signallog"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -874,7 +876,7 @@ MgmApiSession::restart(Parser::Context &, m_output->println("restart reply"); if(result != 0){ - m_output->println("result: %d-%s", result, m_mgmsrv.getErrorText(result)); + m_output->println("result: %d-%s", result, get_error_text(result)); } else m_output->println("result: Ok"); m_output->println("restarted: %d", restarted); @@ -898,7 +900,7 @@ MgmApiSession::restartAll(Parser::Context &, m_output->println("restart reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println("restarted: %d", count); @@ -1029,7 +1031,7 @@ MgmApiSession::stop(Parser::Context &, m_output->println("stop reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println("stopped: %d", stopped); @@ -1051,7 +1053,7 @@ MgmApiSession::stopAll(Parser::Context &, m_output->println("stop reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println("stopped: %d", stopped); @@ -1067,7 +1069,7 @@ MgmApiSession::enterSingleUser(Parser::Context &, int result = m_mgmsrv.enterSingleUser(&stopped, nodeId); m_output->println("enter single user reply"); if(result != 0) { - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); } else { m_output->println("result: Ok"); @@ -1082,7 +1084,7 @@ MgmApiSession::exitSingleUser(Parser::Context &, int result = m_mgmsrv.exitSingleUser(&stopped, false); m_output->println("exit single user reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1100,7 +1102,7 @@ MgmApiSession::startSignalLog(Parser::Context &, m_output->println("start signallog reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1145,7 +1147,7 @@ MgmApiSession::logSignals(Parser::Context &, m_output->println("log signals reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1162,7 +1164,7 @@ MgmApiSession::start(Parser::Context &, m_output->println("start reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1454,6 +1456,15 @@ MgmApiSession::purge_stale_sessions(Parser_t::Context &ctx, m_output->println(""); } +void +MgmApiSession::check_connection(Parser_t::Context &ctx, + const class Properties &args) +{ + m_output->println("check connection reply"); + m_output->println("result: Ok"); + m_output->println(""); +} + template class MutexVector; template class Vector const*>; template class Vector; diff --git a/ndb/src/mgmsrv/Services.hpp b/ndb/src/mgmsrv/Services.hpp index bfc915f18f1..6a5f06a659e 100644 --- a/ndb/src/mgmsrv/Services.hpp +++ b/ndb/src/mgmsrv/Services.hpp @@ -39,10 +39,13 @@ private: OutputStream *m_output; Parser_t *m_parser; MgmtSrvr::Allocated_resources *m_allocated_resources; + char m_err_str[1024]; void getConfig_common(Parser_t::Context &ctx, const class Properties &args, bool compat = false); + const char *get_error_text(int err_no) + { return m_mgmsrv.getErrorText(err_no, m_err_str, sizeof(m_err_str)); } public: MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock); @@ -88,6 +91,7 @@ public: void listen_event(Parser_t::Context &ctx, const class Properties &args); void purge_stale_sessions(Parser_t::Context &ctx, const class Properties &args); + void check_connection(Parser_t::Context &ctx, const class Properties &args); void repCommand(Parser_t::Context &ctx, const class Properties &args); }; diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp index 698bbcde4c6..48e62c36a5f 100644 --- a/ndb/src/ndbapi/Ndbinit.cpp +++ b/ndb/src/ndbapi/Ndbinit.cpp @@ -58,7 +58,7 @@ Ndb::Ndb( const char* aDataBase , const char* aSchema) { theNoOfNdbObjects++; if (global_ndb_cluster_connection == 0) { global_ndb_cluster_connection= new Ndb_cluster_connection(ndbConnectString); - global_ndb_cluster_connection->connect(); + global_ndb_cluster_connection->connect(12,5,1); } setup(global_ndb_cluster_connection, aDataBase, aSchema); DBUG_VOID_RETURN; diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index b2043b2c2c1..f436ee56ede 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -40,10 +40,7 @@ Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string) DBUG_ENTER("Ndb_cluster_connection"); DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this)); m_facade= TransporterFacade::theFacadeInstance= new TransporterFacade(); - if (connect_string) - m_connect_string= my_strdup(connect_string,MYF(MY_WME)); - else - m_connect_string= 0; + m_config_retriever= 0; m_connect_thread= 0; m_connect_callback= 0; @@ -58,9 +55,39 @@ Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string) ndb_print_state_mutex= NdbMutex_Create(); } #endif + m_config_retriever= + new ConfigRetriever(connect_string, NDB_VERSION, NODE_TYPE_API); + if (m_config_retriever->hasError()) + { + printf("Could not connect initialize handle to management server: %s", + m_config_retriever->getErrorString()); + delete m_config_retriever; + m_config_retriever= 0; + } DBUG_VOID_RETURN; } +int Ndb_cluster_connection::get_connected_port() const +{ + if (m_config_retriever) + return m_config_retriever->get_mgmd_port(); + return -1; +} + +const char *Ndb_cluster_connection::get_connected_host() const +{ + if (m_config_retriever) + return m_config_retriever->get_mgmd_host(); + return 0; +} + +const char *Ndb_cluster_connection::get_connectstring(char *buf, int buf_sz) const +{ + if (m_config_retriever) + return m_config_retriever->get_connectstring(buf,buf_sz); + return 0; +} + extern "C" pthread_handler_decl(run_ndb_cluster_connection_connect_thread, me) { my_thread_init(); @@ -77,7 +104,7 @@ void Ndb_cluster_connection::connect_thread() int r; do { NdbSleep_SecSleep(1); - if ((r = connect(1)) == 0) + if ((r = connect(0,0,0)) == 0) break; if (r == -1) { printf("Ndb_cluster_connection::connect_thread error\n"); @@ -98,7 +125,7 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void)) int r; DBUG_ENTER("Ndb_cluster_connection::start_connect_thread"); m_connect_callback= connect_callback; - if ((r = connect(1)) == 1) + if ((r = connect(0,0,0)) == 1) { DBUG_PRINT("info",("starting thread")); m_connect_thread= @@ -117,36 +144,15 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void)) DBUG_RETURN(0); } -int Ndb_cluster_connection::connect(int reconnect) +int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, int verbose) { DBUG_ENTER("Ndb_cluster_connection::connect"); const char* error = 0; do { if (m_config_retriever == 0) - { - m_config_retriever= - new ConfigRetriever(m_connect_string, NDB_VERSION, NODE_TYPE_API); - if (m_config_retriever->hasError()) - { - printf("Could not connect initialize handle to management server", - m_config_retriever->getErrorString()); - DBUG_RETURN(-1); - } - } - else - if (reconnect == 0) - DBUG_RETURN(0); - if (reconnect) - { - int r= m_config_retriever->do_connect(0,0,0); - if (r == 1) - DBUG_RETURN(1); // mgmt server not up yet - if (r == -1) - break; - } - else - if(m_config_retriever->do_connect(12,5,1) == -1) - break; + DBUG_RETURN(-1); + if (m_config_retriever->do_connect(no_retries,retry_delay_in_seconds,verbose)) + DBUG_RETURN(1); // mgmt server not up yet Uint32 nodeId = m_config_retriever->allocNodeId(4/*retries*/,3/*delay*/); if(nodeId == 0) @@ -189,7 +195,6 @@ Ndb_cluster_connection::~Ndb_cluster_connection() abort(); TransporterFacade::theFacadeInstance= 0; } - my_free(m_connect_string,MYF(MY_ALLOW_ZERO_PTR)); if (m_config_retriever) delete m_config_retriever; DBUG_VOID_RETURN; diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 6744f4c1640..c0a6b6ba122 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -35,6 +35,7 @@ typedef struct ErrorBundle { #define NE ndberror_cl_none #define AE ndberror_cl_application +#define CE ndberror_cl_configuration #define ND ndberror_cl_no_data_found #define CV ndberror_cl_constraint_violation #define SE ndberror_cl_schema_error @@ -58,6 +59,27 @@ static const char REDO_BUFFER_MSG[]= static const char* empty_string = ""; +/* + * Error code ranges are reserved for respective block + * + * 200 - TC + * 300 - DIH + * 400 - LQH + * 600 - ACC + * 700 - DICT + * 800 - TUP + * 1200 - LQH + * 1300 - BACKUP + * 4000 - API + * 4100 - "" + * 4200 - "" + * 4300 - "" + * 4400 - "" + * 4500 - "" + * 4600 - "" + * 5000 - Management server + */ + static const ErrorBundle ErrorCodes[] = { @@ -303,6 +325,36 @@ ErrorBundle ErrorCodes[] = { */ { 4003, NI, "Function not implemented yet" }, + /** + * Backup error codes + */ + + { 1300, IE, "Undefined error" }, + { 1301, IE, "Backup issued to not master (reissue command to master)" }, + { 1302, IE, "Out of backup record" }, + { 1303, IS, "Out of resources" }, + { 1304, IE, "Sequence failure" }, + { 1305, IE, "Backup definition not implemented" }, + { 1306, AE, "Backup not supported in diskless mode (change Diskless)" }, + + { 1321, IE, "Backup aborted by application" }, + { 1322, IE, "Backup already completed" }, + { 1323, IE, "1323" }, + { 1324, IE, "Backup log buffer full" }, + { 1325, IE, "File or scan error" }, + { 1326, IE, "Backup abortet due to node failure" }, + { 1327, IE, "1327" }, + + { 1340, IE, "Backup undefined error" }, + { 1342, AE, "Backup failed to allocate buffers (check configuration)" }, + { 1343, AE, "Backup failed to setup fs buffers (check configuration)" }, + { 1344, AE, "Backup failed to allocate tables (check configuration)" }, + { 1345, AE, "Backup failed to insert file header (check configuration)" }, + { 1346, AE, "Backup failed to insert table list (check configuration)" }, + { 1347, AE, "Backup failed to allocate table memory (check configuration)" }, + { 1348, AE, "Backup failed to allocate file record (check configuration)" }, + { 1349, AE, "Backup failed to allocate attribute record (check configuration)" }, + /** * Still uncategorized */ @@ -467,6 +519,7 @@ const ErrorStatusClassification StatusClassificationMapping[] = { { ST_S, NE, "No error"}, { ST_P, AE, "Application error"}, + { ST_P, CE, "Configuration or application error"}, { ST_P, ND, "No data found"}, { ST_P, CV, "Constraint violation"}, { ST_P, SE, "Schema error"}, diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index b923207a4fe..ccb6967e2dc 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -228,10 +228,11 @@ int main(int argc, char** argv){ _tabname = argv[0]; ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str); + if (ndb_cluster_connection->connect(12,5,1)) + fatal("unable to connect"); ndb = new Ndb(ndb_cluster_connection, _dbname); if (ndb->init() != 0) fatal("init"); - ndb_cluster_connection->connect(); if (ndb->waitUntilReady(30) < 0) fatal("waitUntilReady"); dic = ndb->getDictionary(); diff --git a/sql/field.cc b/sql/field.cc index e573f6528f4..5e76c590aac 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1866,6 +1866,7 @@ int Field_long::store(double nr) else if (nr > (double) UINT_MAX32) { res= UINT_MAX32; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index c7384857d79..35bcf794d4a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2408,20 +2408,58 @@ ha_innobase::write_row( position in the source table need not be adjusted after the intermediate COMMIT, since writes by other transactions are being blocked by a MySQL table lock TL_WRITE_ALLOW_READ. */ - ut_a(prebuilt->trx->mysql_n_tables_locked == 2); - ut_a(UT_LIST_GET_LEN(prebuilt->trx->trx_locks) >= 2); - dict_table_t* table = lock_get_ix_table( - UT_LIST_GET_FIRST(prebuilt->trx->trx_locks)); + + dict_table_t* src_table; + ibool mode; + num_write_row = 0; + /* Commit the transaction. This will release the table locks, so they have to be acquired again. */ - innobase_commit(user_thd, prebuilt->trx); - /* Note that this transaction is still active. */ - user_thd->transaction.all.innodb_active_trans = 1; - /* Re-acquire the IX table lock on the source table. */ - row_lock_table_for_mysql(prebuilt, table); - /* We will need an IX lock on the destination table. */ - prebuilt->sql_stat_start = TRUE; + + /* Altering an InnoDB table */ + /* Get the source table. */ + src_table = lock_get_src_table( + prebuilt->trx, prebuilt->table, &mode); + if (!src_table) { + no_commit: + /* Unknown situation: do not commit */ + /* + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB error: ALTER TABLE is holding lock" + " on %lu tables!\n", + prebuilt->trx->mysql_n_tables_locked); + */ + ; + } else if (src_table == prebuilt->table) { + /* Source table is not in InnoDB format: + no need to re-acquire locks on it. */ + + /* Altering to InnoDB format */ + innobase_commit(user_thd, prebuilt->trx); + /* Note that this transaction is still active. */ + user_thd->transaction.all.innodb_active_trans = 1; + /* We will need an IX lock on the destination table. */ + prebuilt->sql_stat_start = TRUE; + } else { + /* Ensure that there are no other table locks than + LOCK_IX and LOCK_AUTO_INC on the destination table. */ + if (!lock_is_table_exclusive(prebuilt->table, + prebuilt->trx)) { + goto no_commit; + } + + /* Commit the transaction. This will release the table + locks, so they have to be acquired again. */ + innobase_commit(user_thd, prebuilt->trx); + /* Note that this transaction is still active. */ + user_thd->transaction.all.innodb_active_trans = 1; + /* Re-acquire the table lock on the source table. */ + row_lock_table_for_mysql(prebuilt, src_table, mode); + /* We will need an IX lock on the destination table. */ + prebuilt->sql_stat_start = TRUE; + } } num_write_row++; @@ -5145,7 +5183,8 @@ ha_innobase::external_lock( if (thd->in_lock_tables && thd->variables.innodb_table_locks) { ulint error; - error = row_lock_table_for_mysql(prebuilt, 0); + error = row_lock_table_for_mysql(prebuilt, + NULL, LOCK_TABLE_EXP); if (error != DB_SUCCESS) { error = convert_error_code_to_mysql( diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 74e3c22e443..9133de9c546 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4244,7 +4244,7 @@ bool ndbcluster_init() new Ndb_cluster_connection(ndbcluster_connectstring)) == 0) { DBUG_PRINT("error",("Ndb_cluster_connection(%s)",ndbcluster_connectstring)); - DBUG_RETURN(TRUE); + goto ndbcluster_init_error; } // Create a Ndb object to open the connection to NDB @@ -4253,25 +4253,33 @@ bool ndbcluster_init() if (g_ndb->init() != 0) { ERR_PRINT (g_ndb->getNdbError()); - DBUG_RETURN(TRUE); + goto ndbcluster_init_error; } - if ((res= g_ndb_cluster_connection->connect(1)) == 0) + if ((res= g_ndb_cluster_connection->connect(0,0,0)) == 0) { + DBUG_PRINT("info",("NDBCLUSTER storage engine at %s on port %d", + g_ndb_cluster_connection->get_connected_host(), + g_ndb_cluster_connection->get_connected_port())); g_ndb->waitUntilReady(10); } else if(res == 1) { if (g_ndb_cluster_connection->start_connect_thread()) { DBUG_PRINT("error", ("g_ndb_cluster_connection->start_connect_thread()")); - DBUG_RETURN(TRUE); + goto ndbcluster_init_error; + } + { + char buf[1024]; + DBUG_PRINT("info",("NDBCLUSTER storage engine not started, will connect using %s", + g_ndb_cluster_connection->get_connectstring(buf,sizeof(buf)))); } } else { DBUG_ASSERT(res == -1); DBUG_PRINT("error", ("permanent error")); - DBUG_RETURN(TRUE); + goto ndbcluster_init_error; } (void) hash_init(&ndbcluster_open_tables,system_charset_info,32,0,0, @@ -4281,9 +4289,12 @@ bool ndbcluster_init() ndbcluster_inited= 1; #ifdef USE_DISCOVER_ON_STARTUP if (ndb_discover_tables() != 0) - DBUG_RETURN(TRUE); + goto ndbcluster_init_error; #endif DBUG_RETURN(FALSE); + ndbcluster_init_error: + ndbcluster_end(); + DBUG_RETURN(TRUE); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 382042e2b42..226b462a2bf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1539,14 +1539,13 @@ void mysql_down_server_cb(void *, void *) // destroy callback resources void mysql_cb_destroy(void *) -{ - UnRegisterEventNotification(eh); // cleanup down event notification +{ + UnRegisterEventNotification(eh); // cleanup down event notification NX_UNWRAP_INTERFACE(ref); - - /* Deregister NSS volume deactivation event */ - NX_UNWRAP_INTERFACE(refneb); + /* Deregister NSS volume deactivation event */ + NX_UNWRAP_INTERFACE(refneb); if (neb_consumer_id) - UnRegisterConsumer(neb_consumer_id, NULL); + UnRegisterConsumer(neb_consumer_id, NULL); } @@ -1665,6 +1664,7 @@ ulong neb_event_callback(struct EventBlock *eblock) nw_panic = TRUE; event_flag= TRUE; kill_server(0); + } } return 0; @@ -1738,8 +1738,8 @@ static void init_signals(void) for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++) signal(signals[i], kill_server); mysql_cb_init(); // initialize callbacks -} +} static void start_signal_handler(void) { @@ -2262,7 +2262,13 @@ extern "C" pthread_handler_decl(handle_shutdown,arg) #endif -const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0,0}; +const char *load_default_groups[]= { +#ifdef HAVE_NDBCLUSTER_DB +"mysql_cluster", +#endif +"mysqld","server",MYSQL_BASE_VERSION,0,0}; +static const int load_default_groups_sz= +sizeof(load_default_groups)/sizeof(load_default_groups[0]); bool open_log(MYSQL_LOG *log, const char *hostname, const char *opt_name, const char *extension, @@ -2884,6 +2890,7 @@ int win_main(int argc, char **argv) int main(int argc, char **argv) #endif { + DEBUGGER_OFF; MY_INIT(argv[0]); // init my_sys library & pthreads @@ -3079,7 +3086,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); #endif /* __NT__ */ /* (void) pthread_attr_destroy(&connection_attrib); */ - + DBUG_PRINT("quit",("Exiting main thread")); #ifndef __WIN__ @@ -3129,6 +3136,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); #endif clean_up_mutexes(); my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); + exit(0); return(0); /* purecov: deadcode */ } @@ -3256,7 +3264,7 @@ int main(int argc, char **argv) and we are now stuck with it. */ if (my_strcasecmp(system_charset_info, argv[1],"mysql")) - load_default_groups[3]= argv[1]; + load_default_groups[load_default_groups_sz-2]= argv[1]; start_mode= 1; Service.Init(argv[1], mysql_service); return 0; @@ -3277,7 +3285,7 @@ int main(int argc, char **argv) opt_argv=argv; start_mode= 1; if (my_strcasecmp(system_charset_info, argv[2],"mysql")) - load_default_groups[3]= argv[2]; + load_default_groups[load_default_groups_sz-2]= argv[2]; Service.Init(argv[2], mysql_service); return 0; } @@ -6257,6 +6265,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), have_berkeley_db= SHOW_OPTION_YES; else have_berkeley_db= SHOW_OPTION_DISABLED; +#else + if (opt_bdb) + sql_print_warning("this binary does not contain BDB storage engine"); #endif break; case OPT_ISAM: @@ -6265,6 +6276,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), have_isam= SHOW_OPTION_YES; else have_isam= SHOW_OPTION_DISABLED; +#else + if (opt_isam) + sql_print_warning("this binary does not contain ISAM storage engine"); #endif break; case OPT_NDBCLUSTER: @@ -6273,6 +6287,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), have_ndbcluster= SHOW_OPTION_YES; else have_ndbcluster= SHOW_OPTION_DISABLED; +#else + if (opt_ndbcluster) + sql_print_warning("this binary does not contain NDBCLUSTER storage engine"); #endif break; case OPT_INNODB: @@ -6281,6 +6298,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), have_innodb= SHOW_OPTION_YES; else have_innodb= SHOW_OPTION_DISABLED; +#else + if (opt_innodb) + sql_print_warning("this binary does not contain INNODB storage engine"); #endif break; case OPT_INNODB_DATA_FILE_PATH: