List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:August 17 2010 1:37pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3692)
View as plain text  
#At file:///home/msvensson/mysql/tmp/MR5OGRS4d3/7.0/ based on revid:magnus.blaudd@strippedx88y4vi

 3692 Magnus Blåudd	2010-08-17 [merge]
      Merge 7.0-bug54316 -> 7.0

    modified:
      client/mysqldump.c
      mysql-test/suite/ndb/r/ndbinfo.result
      mysql-test/suite/ndb/t/ndbinfo.test
      scripts/mysql_system_tables.sql
      storage/ndb/tools/ndbinfo_sql.cpp
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2010-06-16 12:04:53 +0000
+++ b/client/mysqldump.c	2010-08-13 09:22:44 +0000
@@ -3850,6 +3850,45 @@ static int dump_tablespaces(char* ts_whe
   DBUG_RETURN(0);
 }
 
+static int
+is_ndbinfo(MYSQL* mysql, const char* dbname)
+{
+  static int checked_ndbinfo = 0;
+  static int have_ndbinfo = 0;
+
+  if (!checked_ndbinfo)
+  {
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+
+    checked_ndbinfo = 1;
+
+    if (mysql_query_with_error_report(mysql,
+                                      &res,
+                                      "SHOW VARIABLES LIKE "
+                                      "\"ndbinfo_version\""))
+      return 0;
+
+    if (!(row= mysql_fetch_row(res)))
+    {
+      verbose_msg("-- Doesn't have ndbinfo engine\n");
+      mysql_free_result(res);
+      return 0;
+    }
+
+    have_ndbinfo = 1;
+    mysql_free_result(res);
+  }
+
+  if (!have_ndbinfo)
+    return 0;
+
+  if (my_strcasecmp(&my_charset_latin1, dbname, "ndbinfo") == 0)
+    return 1;
+
+  return 0;
+}
+
 static int dump_all_databases()
 {
   MYSQL_ROW row;
@@ -3864,6 +3903,9 @@ static int dump_all_databases()
         !my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
       continue;
 
+    if (is_ndbinfo(mysql, row[0]))
+      continue;
+
     if (dump_all_tables_in_db(row[0]))
       result=1;
   }
@@ -3882,6 +3924,9 @@ static int dump_all_databases()
           !my_strcasecmp(&my_charset_latin1, row[0], "information_schema"))
         continue;
 
+    if (is_ndbinfo(mysql, row[0]))
+      continue;
+
       if (dump_all_views_in_db(row[0]))
         result=1;
     }
@@ -3988,6 +4033,12 @@ int init_dumping_tables(char *qdatabase)
 
 static int init_dumping(char *database, int init_func(char*))
 {
+  if (is_ndbinfo(mysql, database))
+  {
+    verbose_msg("-- Skipping dump of ndbinfo database\n");
+    return 0;
+  }
+
   if (mysql_select_db(mysql, database))
   {
     DB_error(mysql, "when selecting the database");

=== modified file 'mysql-test/suite/ndb/r/ndbinfo.result'
--- a/mysql-test/suite/ndb/r/ndbinfo.result	2010-03-18 10:21:02 +0000
+++ b/mysql-test/suite/ndb/r/ndbinfo.result	2010-08-13 09:22:44 +0000
@@ -229,3 +229,10 @@ ERROR 42000: The used table type doesn't
 CREATE TABLE ndb$test (node_id int AUTO_INCREMENT) ENGINE = ndbinfo;
 ERROR 42000: The used table type doesn't support AUTO_INCREMENT columns
 
+select count(*) from blocks;
+count(*)
+20
+select count(*) from blocks;
+count(*)
+20
+

=== modified file 'mysql-test/suite/ndb/t/ndbinfo.test'
--- a/mysql-test/suite/ndb/t/ndbinfo.test	2010-03-18 10:21:02 +0000
+++ b/mysql-test/suite/ndb/t/ndbinfo.test	2010-08-13 09:22:44 +0000
@@ -153,6 +153,20 @@ CREATE TABLE ndb$test (node_id int, bloc
 --error ER_TABLE_CANT_HANDLE_AUTO_INCREMENT
 CREATE TABLE ndb$test (node_id int AUTO_INCREMENT) ENGINE = ndbinfo;
 
+
+#
+# Bug#54316 mysqldump and restore ndbinfo fails
+# - caused by "blocks" and "config_params" table being truncated
+#   when restoriung a dump without any data. Hack mysqldump
+#   to not include ndbinfo database in --all-databases or
+#   when explicitly given on command line
+#
+let $dump_file = $MYSQLTEST_VARDIR/tmp/ndbinfo_dump.sql;
+select count(*) from blocks;
+--exec $MYSQL_DUMP --no-data --databases test ndbinfo > $dump_file
+--exec $MYSQL test < $dump_file
+select count(*) from blocks;
+
 if (`select @@ndbinfo_version < ((7<<16) | (1 << 8))`)
 {
   --disable_query_log

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-03-05 15:03:09 +0000
+++ b/scripts/mysql_system_tables.sql	2010-08-13 09:22:44 +0000
@@ -283,7 +283,7 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 # ndbinfo.blocks
-SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`blocks` (block_number INT UNSIGNED, block_name VARCHAR(512))','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`blocks` (block_number INT UNSIGNED PRIMARY KEY, block_name VARCHAR(512))','SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
@@ -294,18 +294,18 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 # ndbinfo.config_params
-SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`config_params` (param_number INT UNSIGNED, param_name VARCHAR(512))','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`config_params` (param_number INT UNSIGNED PRIMARY KEY, param_name VARCHAR(512))','SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
 
-SET @str=IF(@have_ndbinfo,'INSERT INTO `ndbinfo`.`config_params` VALUES (179, "MaxNoOfSubscriptions"), (180, "MaxNoOfSubscribers"), (181, "MaxNoOfConcurrentSubOperations"), (5, "HostName"), (3, "NodeId"), (101, "NoOfReplicas"), (103, "MaxNoOfAttributes"), (102, "MaxNoOfTables"), (149, "MaxNoOfOrderedIndexes"), (150, "MaxNoOfUniqueHashIndexes"), (110, "MaxNoOfConcurrentIndexOperations"), (105, "MaxNoOfTriggers"), (109, "MaxNoOfFiredTriggers"), (100, "MaxNoOfSavedMessages"), (177, "LockExecuteThreadToCPU"), (178, "LockMaintThreadsToCPU"), (176, "RealtimeScheduler"), (114, "LockPagesInMainMemory"), (123, "TimeBetweenWatchDogCheck"), (174, "SchedulerExecutionTimer"), (175, "SchedulerSpinTimer"), (141, "TimeBetweenWatchDogCheckInitial"), (124, "StopOnError"), (107, "MaxNoOfConcurrentOperations"), (151, "MaxNoOfLocalOperations"), (152, "MaxNoOfLocalScans"), (153, "BatchSizePerLocalScan"), (106, "MaxNoOfConcurrentTransactions"), (108, "MaxNoOfConcurrentScans"), (111, "TransactionBufferMemory"), (113, "IndexMemory"), (112, "DataMemory"), (154, "UndoIndexBuffer"), (155, "UndoDataBuffer"), (156, "RedoBuffer"), (157, "LongMessageBuffer"), (160, "DiskPageBufferMemory"), (198, "SharedGlobalMemory"), (115, "StartPartialTimeout"), (116, "StartPartitionedTimeout"), (117, "StartFailureTimeout"), (118, "HeartbeatIntervalDbDb"), (119, "HeartbeatIntervalDbApi"), (120, "TimeBetweenLocalCheckpoints"), (121, "TimeBetweenGlobalCheckpoints"), (170, "TimeBetweenEpochs"), (171, "TimeBetweenEpochsTimeout"), (182, "MaxBufferedEpochs"), (126, "NoOfFragmentLogFiles"), (140, "FragmentLogFileSize"), (189, "InitFragmentLogFiles"), (190, "DiskIOThreadPool"), (159, "MaxNoOfOpenFiles"), (162, "InitialNoOfOpenFiles"), (129, "TimeBetweenInactiveTransactionAbortCheck"), (130, "TransactionInactiveTimeout"), (131, "TransactionDeadlockDetectionTimeout"), (148, "Diskless"), (122, "ArbitrationTimeout"), (142, "Arbitration"), (7, "DataDir"), (125, "FileSystemPath"), (250, "LogLevelStartup"), (251, "LogLevelShutdown"), (252, "LogLevelStatistic"), (253, "LogLevelCheckpoint"), (254, "LogLevelNodeRestart"), (255, "LogLevelConnection"), (259, "LogLevelCongestion"), (258, "LogLevelError"), (256, "LogLevelInfo"), (158, "BackupDataDir"), (163, "DiskSyncSize"), (164, "DiskCheckpointSpeed"), (165, "DiskCheckpointSpeedInRestart"), (133, "BackupMemory"), (134, "BackupDataBufferSize"), (135, "BackupLogBufferSize"), (136, "BackupWriteSize"), (139, "BackupMaxWriteSize"), (161, "StringMemory"), (169, "MaxAllocate"), (166, "MemReportFrequency"), (167, "BackupReportFrequency"), (184, "StartupStatusReportFrequency"), (168, "ODirect"), (172, "CompressedBackup"), (173, "CompressedLCP"), (9, "TotalSendBufferMemory"), (202, "ReservedSendBufferMemory"), (185, "Nodegroup"), (186, "MaxNoOfExecutionThreads"), (188, "__ndbmt_lqh_workers"), (187, "__ndbmt_lqh_threads"), (191, "__ndbmt_classic"), (193, "FileSystemPathDD"), (194, "FileSystemPathDataFiles"), (195, "FileSystemPathUndoFiles"), (196, "InitialLogfileGroup"), (197, "InitialTablespace"), (605, "MaxLCPStartDelay"), (606, "BuildIndexThreads")','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'INSERT INTO `ndbinfo`.`config_params` VALUES (179, "MaxNoOfSubscriptions"), (180, "MaxNoOfSubscribers"), (181, "MaxNoOfConcurrentSubOperations"), (5, "HostName"), (3, "NodeId"), (101, "NoOfReplicas"), (103, "MaxNoOfAttributes"), (102, "MaxNoOfTables"), (149, "MaxNoOfOrderedIndexes"), (150, "MaxNoOfUniqueHashIndexes"), (110, "MaxNoOfConcurrentIndexOperations"), (105, "MaxNoOfTriggers"), (109, "MaxNoOfFiredTriggers"), (100, "MaxNoOfSavedMessages"), (177, "LockExecuteThreadToCPU"), (178, "LockMaintThreadsToCPU"), (176, "RealtimeScheduler"), (114, "LockPagesInMainMemory"), (123, "TimeBetweenWatchDogCheck"), (174, "SchedulerExecutionTimer"), (175, "SchedulerSpinTimer"), (141, "TimeBetweenWatchDogCheckInitial"), (124, "StopOnError"), (107, "MaxNoOfConcurrentOperations"), (151, "MaxNoOfLocalOperations"), (152, "MaxNoOfLocalScans"), (153, "BatchSizePerLocalScan"), (106, "MaxNoOfConcurrentTransactions"), (108, "MaxNoOfConcurrentScans"), (111, "TransactionBufferMemory"), (113, "IndexMemory"), (112, "DataMemory"), (154, "UndoIndexBuffer"), (155, "UndoDataBuffer"), (156, "RedoBuffer"), (157, "LongMessageBuffer"), (160, "DiskPageBufferMemory"), (198, "SharedGlobalMemory"), (115, "StartPartialTimeout"), (116, "StartPartitionedTimeout"), (117, "StartFailureTimeout"), (118, "HeartbeatIntervalDbDb"), (119, "HeartbeatIntervalDbApi"), (120, "TimeBetweenLocalCheckpoints"), (121, "TimeBetweenGlobalCheckpoints"), (170, "TimeBetweenEpochs"), (171, "TimeBetweenEpochsTimeout"), (182, "MaxBufferedEpochs"), (126, "NoOfFragmentLogFiles"), (140, "FragmentLogFileSize"), (189, "InitFragmentLogFiles"), (190, "DiskIOThreadPool"), (159, "MaxNoOfOpenFiles"), (162, "InitialNoOfOpenFiles"), (129, "TimeBetweenInactiveTransactionAbortCheck"), (130, "TransactionInactiveTimeout"), (131, "TransactionDeadlockDetectionTimeout"), (148, "Diskless"), (122, "ArbitrationTimeout"), (142, "Arbitration"), (7, "DataDir"), (125, "FileSystemPath"), (250, "LogLevelStartup"), (251, "LogLevelShutdown"), (252, "LogLevelStatistic"), (253, "LogLevelCheckpoint"), (254, "LogLevelNodeRestart"), (255, "LogLevelConnection"), (259, "LogLevelCongestion"), (258, "LogLevelError"), (256, "LogLevelInfo"), (158, "BackupDataDir"), (163, "DiskSyncSize"), (164, "DiskCheckpointSpeed"), (165, "DiskCheckpointSpeedInRestart"), (133, "BackupMemory"), (134, "BackupDataBufferSize"), (135, "BackupLogBufferSize"), (136, "BackupWriteSize"), (139, "BackupMaxWriteSize"), (161, "StringMemory"), (169, "MaxAllocate"), (166, "MemReportFrequency"), (167, "BackupReportFrequency"), (184, "StartupStatusReportFrequency"), (168, "ODirect"), (172, "CompressedBackup"), (173, "CompressedLCP"), (9, "TotalSendBufferMemory"), (202, "ReservedSendBufferMemory"), (185, "Nodegroup"), (186, "MaxNoOfExecutionThreads"), (188, "__ndbmt_lqh_workers"), (187, "__ndbmt_lqh_threads"), (191, "__ndbmt_classic"), (193, "FileSystemPathDD"), (194, "FileSystemPathDataFiles"), (195, "FileSystemPathUndoFiles"), (196, "InitialLogfileGroup"), (197, "InitialTablespace"), (605, "MaxLCPStartDelay"), (606, "BuildIndexThreads"), (607, "HeartbeatOrder")','SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
 
 # ndbinfo.pools
-SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`pools` AS SELECT node_id, b.block_name, block_instance, pool_name, used, total, high, entry_size, cp1.param_name AS param_name1, cp2.param_name AS param_name2, cp3.param_name AS param_name3, cp4.param_name AS param_name4 FROM ndbinfo.ndb$pools p JOIN ndbinfo.blocks b ON p.block_number = b.block_number LEFT JOIN ndbinfo.config_params cp1 ON p.config_param1 = cp1.param_number LEFT JOIN ndbinfo.config_params cp2 ON p.config_param2 = cp2.param_number LEFT JOIN ndbinfo.config_params cp3 ON p.config_param3 = cp3.param_number LEFT JOIN ndbinfo.config_params cp4 ON p.config_param4 = cp4.param_number','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`pools` AS SELECT node_id, b.block_name, block_instance, pool_name, used, total, high, entry_size, cp1.param_name AS param_name1, cp2.param_name AS param_name2, cp3.param_name AS param_name3, cp4.param_name AS param_name4 FROM ndbinfo.ndb$pools p LEFT JOIN ndbinfo.blocks b ON p.block_number = b.block_number LEFT JOIN ndbinfo.config_params cp1 ON p.config_param1 = cp1.param_number LEFT JOIN ndbinfo.config_params cp2 ON p.config_param2 = cp2.param_number LEFT JOIN ndbinfo.config_params cp3 ON p.config_param3 = cp3.param_number LEFT JOIN ndbinfo.config_params cp4 ON p.config_param4 = cp4.param_number','SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
@@ -335,7 +335,7 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 # ndbinfo.counters
-SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`counters` AS SELECT node_id, b.block_name, block_instance, counter_id, CASE counter_id  WHEN 1 THEN "ATTRINFO"  WHEN 2 THEN "TRANSACTIONS"  WHEN 3 THEN "COMMITS"  WHEN 4 THEN "READS"  WHEN 5 THEN "SIMPLE_READS"  WHEN 6 THEN "WRITES"  WHEN 7 THEN "ABORTS"  WHEN 8 THEN "TABLE_SCANS"  WHEN 9 THEN "RANGE_SCANS"  WHEN 10 THEN "OPERATIONS"  ELSE "<unknown>"  END AS counter_name, val FROM ndbinfo.ndb$counters c, ndbinfo.blocks b WHERE c.block_number = b.block_number','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`counters` AS SELECT node_id, b.block_name, block_instance, counter_id, CASE counter_id  WHEN 1 THEN "ATTRINFO"  WHEN 2 THEN "TRANSACTIONS"  WHEN 3 THEN "COMMITS"  WHEN 4 THEN "READS"  WHEN 5 THEN "SIMPLE_READS"  WHEN 6 THEN "WRITES"  WHEN 7 THEN "ABORTS"  WHEN 8 THEN "TABLE_SCANS"  WHEN 9 THEN "RANGE_SCANS"  WHEN 10 THEN "OPERATIONS"  ELSE "<unknown>"  END AS counter_name, val FROM ndbinfo.ndb$counters c LEFT JOIN ndbinfo.blocks b ON c.block_number = b.block_number','SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;
@@ -347,7 +347,7 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 # ndbinfo.memoryusage
-SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE SQL SECURITY INVOKER VIEW `ndbinfo`.`memoryusage` AS SELECT node_id,  pool_name AS memory_type,  SUM(used*entry_size) AS used,  SUM(used) AS used_pages,  SUM(total*entry_size) AS total,  SUM(total) AS total_pages FROM ndbinfo.ndb$pools WHERE block_number IN (248, 254) AND   (pool_name = "Index memory" OR pool_name = "Data memory") GROUP BY node_id, memory_type','SET @dummy = 0');
+SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root@localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`memoryusage` AS SELECT node_id,  pool_name AS memory_type,  SUM(used*entry_size) AS used,  SUM(used) AS used_pages,  SUM(total*entry_size) AS total,  SUM(total) AS total_pages FROM ndbinfo.ndb$pools WHERE block_number IN (248, 254) AND   (pool_name = "Index memory" OR pool_name = "Data memory") GROUP BY node_id, memory_type','SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;

=== modified file 'storage/ndb/tools/ndbinfo_sql.cpp'
--- a/storage/ndb/tools/ndbinfo_sql.cpp	2010-03-05 15:03:09 +0000
+++ b/storage/ndb/tools/ndbinfo_sql.cpp	2010-08-13 09:22:44 +0000
@@ -50,7 +50,7 @@ struct view {
     "cp2.param_name AS param_name2, cp3.param_name AS param_name3, "
     "cp4.param_name AS param_name4 "
     "FROM <NDBINFO_DB>.<TABLE_PREFIX>pools p "
-    "JOIN <NDBINFO_DB>.blocks b ON p.block_number = b.block_number "
+    "LEFT JOIN <NDBINFO_DB>.blocks b ON p.block_number = b.block_number "
     "LEFT JOIN <NDBINFO_DB>.config_params cp1 ON p.config_param1 = cp1.param_number "
     "LEFT JOIN <NDBINFO_DB>.config_params cp2 ON p.config_param2 = cp2.param_number "
     "LEFT JOIN <NDBINFO_DB>.config_params cp3 ON p.config_param3 = cp3.param_number "
@@ -119,9 +119,9 @@ struct view {
     "  ELSE \"<unknown>\" "
     " END AS counter_name, "
     "val "
-    "FROM <NDBINFO_DB>.<TABLE_PREFIX>counters c, "
-    "<NDBINFO_DB>.blocks b "
-    "WHERE c.block_number = b.block_number"
+    "FROM <NDBINFO_DB>.<TABLE_PREFIX>counters c "
+    "LEFT JOIN <NDBINFO_DB>.blocks b "
+    "ON c.block_number = b.block_number"
    },
    { "nodes",
     "SELECT node_id, "
@@ -196,12 +196,12 @@ struct lookup {
 } lookups[] =
 {
   { "blocks",
-    "block_number INT UNSIGNED, "
+    "block_number INT UNSIGNED PRIMARY KEY, "
     "block_name VARCHAR(512)",
     &fill_blocks
    },
   { "config_params",
-    "param_number INT UNSIGNED, "
+    "param_number INT UNSIGNED PRIMARY KEY, "
     "param_name VARCHAR(512)",
     &fill_config_params
    }
@@ -402,7 +402,7 @@ int main(int argc, char** argv){
 
     /* Create or replace the view */
     BaseString sql;
-    sql.assfmt("CREATE OR REPLACE "
+    sql.assfmt("CREATE OR REPLACE DEFINER=`root@localhost` "
                "SQL SECURITY INVOKER VIEW `%s`.`%s` AS %s",
                opt_ndbinfo_db, v.name, view_sql.c_str());
     print_conditional_sql(sql);

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20100817133712-jig7md9pt0802chp.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3692) Magnus Blåudd17 Aug