List:Commits« Previous MessageNext Message »
From:Martin Skold Date:October 15 2009 2:03pm
Subject:bzr commit into mysql-5.1-telco-7.1 branch (Martin.Skold:3080) Bug#35990
Bug#47865 Bug#47955 Bug#48036
View as plain text  
#At file:///home/marty/MySQL/mysql-5.1-telco-7.1/

 3080 Martin Skold	2009-10-15 [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/r/ndb_update.result
        mysql-test/suite/ndb/t/ndb_auto_increment.test
        mysql-test/suite/ndb/t/ndb_insert.test
        mysql-test/suite/ndb/t/ndb_update.test
        sql/ha_ndbcluster.cc
        sql/sql_update.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/r/ndb_update.result'
--- a/mysql-test/suite/ndb/r/ndb_update.result	2008-12-05 10:59:32 +0000
+++ b/mysql-test/suite/ndb/r/ndb_update.result	2009-10-15 08:28:50 +0000
@@ -27,6 +27,12 @@ pk1	b	c
 0	0	0
 2	2	2
 4	1	1
+UPDATE t1 set pk1 = 2 where pk1 = 2;
+affected rows: 0
+info: Rows matched: 1  Changed: 0  Warnings: 0
+UPDATE t1 set c = 1 WHERE b IN(0,1,2,3,4);
+ERROR 23000: Duplicate entry '1' for key 'c'
+UPDATE IGNORE t1 set c = 1 WHERE b IN(0,1,2,3,4);
 UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
 ERROR 23000: Duplicate entry '2' for key 'c'
 UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4;

=== 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 'mysql-test/suite/ndb/t/ndb_update.test'
--- a/mysql-test/suite/ndb/t/ndb_update.test	2008-12-05 10:59:32 +0000
+++ b/mysql-test/suite/ndb/t/ndb_update.test	2009-10-15 08:28:50 +0000
@@ -28,6 +28,12 @@ select * from t1 order by pk1;
 UPDATE t1 set pk1 = 4 where pk1 = 2;
 UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2;
 select * from t1 order by pk1;
+--enable_info
+UPDATE t1 set pk1 = 2 where pk1 = 2;
+--disable_info
+--error ER_DUP_ENTRY
+UPDATE t1 set c = 1 WHERE b IN(0,1,2,3,4);
+UPDATE IGNORE t1 set c = 1 WHERE b IN(0,1,2,3,4);
 --error ER_DUP_ENTRY
 UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
 UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4;

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2009-10-07 17:57:00 +0000
+++ b/sql/ha_ndbcluster.cc	2009-10-15 14:03:24 +0000
@@ -435,18 +435,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;
 }
 
@@ -4208,6 +4215,12 @@ ha_ndbcluster::delete_row_conflict_fn(en
 bool ha_ndbcluster::start_bulk_update()
 {
   DBUG_ENTER("ha_ndbcluster::start_bulk_update");
+  if (!m_use_write && m_ignore_dup_key)
+  {
+    DBUG_PRINT("info", ("Batching turned off as duplicate key is "
+                        "ignored by using peek_row"));
+    DBUG_RETURN(TRUE);
+  }
   DBUG_RETURN(FALSE);
 }
 
@@ -7081,7 +7094,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", 
@@ -7089,13 +7143,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))
        {

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2009-10-01 05:56:05 +0000
+++ b/sql/sql_update.cc	2009-10-15 12:37:53 +0000
@@ -857,13 +857,22 @@ int mysql_update(THD *thd,
       also when using BEFORE UPDATE triggers on table and also quite
       hard checks on UPDATE statement. Still it is used very often with
       all those limitations.
-
-      Moreover, since there is no read before update, found == updated,
-      as there is no optimization to remove the update if the new data
-      should equal the old.
     */
     table->file->info(HA_STATUS_WRITTEN_ROWS);
-    found= updated= table->file->stats.rows_updated;
+    updated= table->file->stats.rows_updated;
+    /*
+      If we could compare the records then the records were
+      either found by reading the table or they were
+      constructed from the WHERE clause. In this case the
+      handler might not have been called to perform the update.
+      If we could not compare the records then the read was skipped
+      and we could not create a record to compare with from the
+      WHERE clause. In this case we cannot use the calculated value
+      of found, instead the number if found records must equal to number
+      of updated records.
+     */
+    if (!can_compare_record)
+      found= updated;
   }
 
   /* If LAST_INSERT_ID(X) was used, report X */

Thread
bzr commit into mysql-5.1-telco-7.1 branch (Martin.Skold:3080) Bug#35990Bug#47865 Bug#47955 Bug#48036Martin Skold15 Oct