From: Martin Skold Date: October 14 2009 2:12pm Subject: bzr commit into mysql-5.1-telco-6.3 branch (Martin.Skold:3104) Bug#35990 Bug#47865 List-Archive: http://lists.mysql.com/commits/86832 X-Bug: 35990,47865 Message-Id: <200910141412.n9EECfLD006764@quadfish.liljeholmen.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/marty/MySQL/mysql-5.1-telco-6.3/ 3104 Martin Skold 2009-10-14 [merge] Merge modified: mysql-test/suite/ndb/r/ndb_alter_table_backup.result mysql-test/suite/ndb/r/ndb_auto_increment.result mysql-test/suite/ndb/r/ndb_insert.result mysql-test/suite/ndb/t/ndb_auto_increment.test mysql-test/suite/ndb/t/ndb_insert.test sql/ha_ndbcluster.cc === modified file 'mysql-test/suite/ndb/r/ndb_alter_table_backup.result' --- a/mysql-test/suite/ndb/r/ndb_alter_table_backup.result 2007-11-07 03:48:11 +0000 +++ b/mysql-test/suite/ndb/r/ndb_alter_table_backup.result 2009-10-08 09:48:07 +0000 @@ -17,7 +17,7 @@ t1 CREATE TABLE `t1` ( `f` datetime DEFAULT NULL, `g` binary(4) DEFAULT NULL, PRIMARY KEY (`a`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) ENGINE=ndbcluster AUTO_INCREMENT=31 DEFAULT CHARSET=latin1 SELECT * FROM t1 WHERE a = 1 or a = 10 or a = 20 or a = 30 ORDER BY a; a b c d e f g 1 5 3.40282e+38 1.2686868689898e+308 666.66 2007-10-23 23:23:23 1111 @@ -42,7 +42,7 @@ t1 CREATE TABLE `t1` ( `f` datetime DEFAULT NULL, `g` binary(4) DEFAULT NULL, PRIMARY KEY (`a`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +) ENGINE=ndbcluster AUTO_INCREMENT=31 DEFAULT CHARSET=latin1 SELECT * FROM t1 WHERE a = 1 or a = 10 or a = 20 or a = 30 ORDER BY a; a b c d e f g 1 5 3.40282e+38 1.2686868689898e+308 666.66 2007-10-23 23:23:23 1111 === modified file 'mysql-test/suite/ndb/r/ndb_auto_increment.result' --- a/mysql-test/suite/ndb/r/ndb_auto_increment.result 2009-09-03 07:49:50 +0000 +++ b/mysql-test/suite/ndb/r/ndb_auto_increment.result 2009-10-08 09:58:57 +0000 @@ -499,3 +499,13 @@ evend_id server_id drop trigger tr1; drop table t1, t2; drop trigger if exists tr1; +create table t1 (a int primary key auto_increment, b int) engine=ndb; +insert into t1 values (null,1),(null,2),(null,3); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL AUTO_INCREMENT, + `b` int(11) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=ndbcluster AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +drop table t1; === modified file 'mysql-test/suite/ndb/r/ndb_insert.result' --- a/mysql-test/suite/ndb/r/ndb_insert.result 2008-11-24 18:24:47 +0000 +++ b/mysql-test/suite/ndb/r/ndb_insert.result 2009-10-14 14:12:28 +0000 @@ -671,3 +671,11 @@ a b 2 NULL 3 NULL drop table t1; +create table t1(code varchar(64) not null, PRIMARY KEY (code)) ENGINE=NDBCluster; +insert into t1 values ('code'); +insert into t1 values ('code'); +ERROR 23000: Duplicate entry 'code' for key 'PRIMARY' +set sql_mode='STRICT_TRANS_TABLES'; +insert into t1 values ('code'); +ERROR 23000: Duplicate entry 'code' for key 'PRIMARY' +drop table t1; === modified file 'mysql-test/suite/ndb/t/ndb_auto_increment.test' --- a/mysql-test/suite/ndb/t/ndb_auto_increment.test 2009-09-03 07:49:50 +0000 +++ b/mysql-test/suite/ndb/t/ndb_auto_increment.test 2009-10-08 09:58:57 +0000 @@ -378,3 +378,15 @@ connection server2; --disable_warnings drop trigger if exists tr1; --enable_warnings + +# +# Bug #47865 SHOW CREATE TABLE does not show the current auto_increment number for ndb tables +# + +create table t1 (a int primary key auto_increment, b int) engine=ndb; + +insert into t1 values (null,1),(null,2),(null,3); + +show create table t1; + +drop table t1; \ No newline at end of file === modified file 'mysql-test/suite/ndb/t/ndb_insert.test' --- a/mysql-test/suite/ndb/t/ndb_insert.test 2008-10-16 11:44:22 +0000 +++ b/mysql-test/suite/ndb/t/ndb_insert.test 2009-10-14 14:12:28 +0000 @@ -655,3 +655,18 @@ insert ignore into t1 values (1,0), (2,0 select * from t1 order by a; drop table t1; # End of 4.1 tests + +# +# Bug #35990 Error code 1062 to 1296 (unknown) after setting sql_mode to STRICT_TRANS_TABLES +# + +create table t1(code varchar(64) not null, PRIMARY KEY (code)) ENGINE=NDBCluster; + +insert into t1 values ('code'); +--error ER_DUP_ENTRY +insert into t1 values ('code'); + +set sql_mode='STRICT_TRANS_TABLES'; +--error ER_DUP_ENTRY +insert into t1 values ('code'); +drop table t1; \ No newline at end of file === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2009-10-07 17:16:52 +0000 +++ b/sql/ha_ndbcluster.cc 2009-10-14 14:12:28 +0000 @@ -287,18 +287,25 @@ static int ndb_to_mysql_error(const NdbE } /* - Push the NDB error message as warning - - Used to be able to use SHOW WARNINGS toget more info on what the error is - - Used by replication to see if the error was temporary - */ - if (ndberr->status == NdbError::TemporaryError) - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_GET_TEMPORARY_ERRMSG, ER(ER_GET_TEMPORARY_ERRMSG), - ndberr->code, ndberr->message, "NDB"); - else - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_GET_ERRMSG, ER(ER_GET_ERRMSG), - ndberr->code, ndberr->message, "NDB"); + If we don't abort directly on warnings push a warning + with the internal error information + */ + if (!current_thd->abort_on_warning) + { + /* + Push the NDB error message as warning + - Used to be able to use SHOW WARNINGS toget more info on what the error is + - Used by replication to see if the error was temporary + */ + if (ndberr->status == NdbError::TemporaryError) + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_GET_TEMPORARY_ERRMSG, ER(ER_GET_TEMPORARY_ERRMSG), + ndberr->code, ndberr->message, "NDB"); + else + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_GET_ERRMSG, ER(ER_GET_ERRMSG), + ndberr->code, ndberr->message, "NDB"); + } return error; } @@ -6600,7 +6607,48 @@ static int create_ndb_column(THD *thd, void ha_ndbcluster::update_create_info(HA_CREATE_INFO *create_info) { DBUG_ENTER("update_create_info"); + THD *thd= current_thd; TABLE_SHARE *share= table->s; + const NDBTAB *ndbtab= m_table; + Ndb *ndb= check_ndb_in_thd(thd); + + /* + Find any initial auto_increment value + */ + for (uint i= 0; i < table->s->fields; i++) + { + Field *field= table->field[i]; + if (field->flags & AUTO_INCREMENT_FLAG) + { + ulonglong auto_value; + uint retries= NDB_AUTO_INCREMENT_RETRIES; + int retry_sleep= 30; /* 30 milliseconds, transaction */ + for (;;) + { + Ndb_tuple_id_range_guard g(m_share); + if (ndb->readAutoIncrementValue(ndbtab, g.range, auto_value)) + { + if (--retries && !thd->killed && + ndb->getNdbError().status == NdbError::TemporaryError) + { + do_retry_sleep(retry_sleep); + continue; + } + const NdbError err= ndb->getNdbError(); + sql_print_error("Error %lu in ::update_create_info(): %s", + (ulong) err.code, err.message); + DBUG_VOID_RETURN; + } + break; + } + if (auto_value > 1) + { + create_info->auto_increment_value= auto_value; + } + break; + } + } + if (share->mysql_version < MYSQL_VERSION_TABLESPACE_IN_FRM) { DBUG_PRINT("info", ("Restored an old table %s, pre-frm_version 7", @@ -6608,13 +6656,10 @@ void ha_ndbcluster::update_create_info(H if (!create_info->tablespace && !share->tablespace) { DBUG_PRINT("info", ("Checking for tablespace in ndb")); - THD *thd= current_thd; - Ndb *ndb= check_ndb_in_thd(thd); NDBDICT *ndbdict= ndb->getDictionary(); NdbError ndberr; Uint32 id; ndb->setDatabaseName(m_dbname); - const NDBTAB *ndbtab= m_table; DBUG_ASSERT(ndbtab != NULL); if (!ndbtab->getTablespace(&id)) {