List:Commits« Previous MessageNext Message »
From:Pekka Nousiainen Date:June 12 2011 4:54pm
Subject:bzr commit into mysql-5.1-telco-7.0-wl4124-new0 branch
(pekka.nousiainen:4396) WL#4124
View as plain text  
#At file:///export/space/pekka/ms/ms-wl4124-70/ based on revid:pekka.nousiainen@stripped

 4396 Pekka Nousiainen	2011-06-12
      wl#4124 d05_systab.diff
      change to mysql names and add FRM

    added:
      storage/ndb/src/ndbapi/NdbIndexStatFrmData.cpp
      storage/ndb/tools/ndb_dump_frm_data.cpp
    modified:
      storage/ndb/include/kernel/ndb_limits.h
      storage/ndb/include/ndb_constants.h
      storage/ndb/src/kernel/blocks/trix/Trix.cpp
      storage/ndb/src/ndbapi/Makefile.am
      storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp
      storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp
      storage/ndb/tools/Makefile.am
      storage/ndb/tools/ndb_index_stat.cpp
=== modified file 'storage/ndb/include/kernel/ndb_limits.h'
--- a/storage/ndb/include/kernel/ndb_limits.h	2011-05-29 10:55:32 +0000
+++ b/storage/ndb/include/kernel/ndb_limits.h	2011-06-12 16:54:32 +0000
@@ -226,9 +226,13 @@
  * counted as 1 word.  Values currently contain RIR (one word) and RPK
  * (one word for each key level).  The SAMPLEs table STAT_VALUE column
  * is longer to allow future changes.
+ *
+ * Stats tables are "lifted" to mysql level so for max key size use
+ * MAX_KEY_LENGTH/4 instead of the bigger MAX_KEY_SIZE_IN_WORDS.  The
+ * definition is not available by default, use 3072 directly now.
  */
 #define MAX_INDEX_STAT_KEY_COUNT    MAX_ATTRIBUTES_IN_INDEX
-#define MAX_INDEX_STAT_KEY_SIZE     (MAX_KEY_SIZE_IN_WORDS - 3 - 1)
+#define MAX_INDEX_STAT_KEY_SIZE     ((3072/4) - 3 - 1)
 #define MAX_INDEX_STAT_VALUE_COUNT  (1 + MAX_INDEX_STAT_KEY_COUNT)
 #define MAX_INDEX_STAT_VALUE_SIZE   MAX_INDEX_STAT_VALUE_COUNT
 #define MAX_INDEX_STAT_VALUE_CSIZE  512 /* Longvarbinary(2048) */

=== modified file 'storage/ndb/include/ndb_constants.h'
--- a/storage/ndb/include/ndb_constants.h	2011-05-31 08:28:58 +0000
+++ b/storage/ndb/include/ndb_constants.h	2011-06-12 16:54:32 +0000
@@ -118,10 +118,10 @@
 #define NDB_INDEX_STAT_DB     "mysql"
 #define NDB_INDEX_STAT_SCHEMA "def"
 
-#define NDB_INDEX_STAT_HEAD_TABLE    "NDB$IS_HEAD"
-#define NDB_INDEX_STAT_SAMPLE_TABLE  "NDB$IS_SAMPLE"
-#define NDB_INDEX_STAT_SAMPLE_INDEX1 "NDB$IS_SAMPLE_X1"
+#define NDB_INDEX_STAT_HEAD_TABLE    "ndb_index_stat_head"
+#define NDB_INDEX_STAT_SAMPLE_TABLE  "ndb_index_stat_sample"
+#define NDB_INDEX_STAT_SAMPLE_INDEX1 "ndb_index_stat_sample_x1"
 
-#define NDB_INDEX_STAT_PREFIX        "NDB$IS"
+#define NDB_INDEX_STAT_PREFIX        "ndb_index_stat"
 
 #endif

=== modified file 'storage/ndb/src/kernel/blocks/trix/Trix.cpp'
--- a/storage/ndb/src/kernel/blocks/trix/Trix.cpp	2011-06-06 12:18:27 +0000
+++ b/storage/ndb/src/kernel/blocks/trix/Trix.cpp	2011-06-12 16:54:32 +0000
@@ -1694,50 +1694,50 @@ Trix::execINDEX_STAT_IMPL_REQ(Signal* si
 
 const Trix::SysColumn
 Trix::g_statMetaHead_column[] = {
-  { 0, "INDEX_ID",
+  { 0, "index_id",
     true
   },
-  { 1, "INDEX_VERSION",
+  { 1, "index_version",
     true
   },
-  { 2, "TABLE_ID",
+  { 2, "table_id",
     false
   },
-  { 3, "FRAG_COUNT",
+  { 3, "frag_count",
     false
   },
-  { 4, "VALUE_FORMAT",
+  { 4, "value_format",
     false
   },
-  { 5, "SAMPLE_VERSION",
+  { 5, "sample_version",
     false
   },
-  { 6, "LOAD_TIME",
+  { 6, "load_time",
     false
   },
-  { 7, "SAMPLE_COUNT",
+  { 7, "sample_count",
     false
   },
-  { 8, "KEY_BYTES",
+  { 8, "key_bytes",
     false
   }
 };
 
 const Trix::SysColumn
 Trix::g_statMetaSample_column[] = {
-  { 0, "INDEX_ID",
+  { 0, "index_id",
     true
   },
-  { 1, "INDEX_VERSION",
+  { 1, "index_version",
     true
   },
-  { 2, "SAMPLE_VERSION",
+  { 2, "sample_version",
     true
   },
-  { 3, "STAT_KEY",
+  { 3, "stat_key",
     true
   },
-  { 4, "STAT_VALUE",
+  { 4, "stat_value",
     false
   }
 };

=== modified file 'storage/ndb/src/ndbapi/Makefile.am'
--- a/storage/ndb/src/ndbapi/Makefile.am	2011-06-06 12:18:27 +0000
+++ b/storage/ndb/src/ndbapi/Makefile.am	2011-06-12 16:54:32 +0000
@@ -59,6 +59,7 @@ libndbapi_la_SOURCES = \
 	NdbBlob.cpp \
 	NdbIndexStat.cpp \
 	NdbIndexStatImpl.cpp \
+	NdbIndexStatFrmData.cpp \
         SignalSender.cpp \
         ObjectMap.cpp \
 	NdbInterpretedCode.cpp \

=== added file 'storage/ndb/src/ndbapi/NdbIndexStatFrmData.cpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStatFrmData.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStatFrmData.cpp	2011-06-12 16:54:32 +0000
@@ -0,0 +1,175 @@
+/*
+   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include <ndb_global.h>
+#include "NdbIndexStatImpl.hpp"
+
+#if ndb_index_stat_systables_sql
+
+use mysql;
+
+create table ndb_index_stat_head (
+  index_id int unsigned not null,
+  index_version int unsigned not null,
+  table_id int unsigned not null,
+  frag_count int unsigned not null,
+  value_format int unsigned not null,
+  sample_version int unsigned not null,
+  load_time int unsigned not null,
+  sample_count int unsigned not null,
+  key_bytes int unsigned not null,
+  primary key using hash (
+    index_id, index_version)
+) engine=ndb;
+
+create table ndb_index_stat_sample (
+  index_id int unsigned not null,
+  index_version int unsigned not null,
+  sample_version int unsigned not null,
+  stat_key varbinary(3056) not null, -- ((3072/4) - 3 - 1) * 4
+  stat_value varbinary(2048) not null, -- 512 * 4
+  primary key using hash (
+    index_id, index_version, sample_version, stat_key),
+  index ndb_index_stat_sample_x1 (
+    index_id, index_version, sample_version)
+) engine=ndb;
+
+#endif
+
+// rest dumped from *.frm by tools/ndb_dump_frm_data
+
+/*
+  name: ndb_index_stat_head
+  orig: 8918
+  pack: 402
+*/
+
+const uint g_ndb_index_stat_head_frm_len = 402;
+
+const uint8 g_ndb_index_stat_head_frm_data[402] =
+{
+  0x01,0x00,0x00,0x00,0xd6,0x22,0x00,0x00,
+  0x86,0x01,0x00,0x00,0x78,0x9c,0xed,0xda,
+  0xbf,0x4e,0xc2,0x40,0x1c,0x07,0xf0,0x6f,
+  0xcb,0xdf,0x1e,0x50,0x08,0x21,0x0c,0x0c,
+  0xa6,0x31,0x21,0x11,0x17,0x9d,0x9d,0xc4,
+  0xc4,0x81,0x18,0x95,0x10,0x16,0x5c,0x9a,
+  0x02,0x87,0xa9,0x02,0x35,0xb4,0x10,0xd9,
+  0x78,0x27,0x1e,0xc1,0x77,0xf0,0x29,0x7c,
+  0x06,0xcf,0x2b,0x50,0x3c,0x36,0x16,0x83,
+  0x9a,0xdf,0x67,0xba,0xfb,0xf6,0x2e,0xf9,
+  0xe5,0xbb,0xb5,0xe9,0xa7,0x66,0x98,0x31,
+  0xa0,0xa0,0x01,0xe7,0x80,0xab,0x55,0xb1,
+  0xa5,0x9f,0x22,0x0d,0x24,0xc2,0x65,0x3a,
+  0xca,0x5c,0x79,0xee,0xe3,0x0d,0xb8,0x58,
+  0xed,0x4c,0xe0,0xec,0x0c,0xb0,0x40,0x08,
+  0x21,0x84,0x10,0x42,0x08,0x21,0x84,0x90,
+  0xdf,0x4c,0xd3,0x01,0x86,0xf0,0x0d,0x5f,
+  0x8f,0xc9,0xdd,0x42,0x6e,0x2b,0x97,0x71,
+  0xe8,0x8b,0xe4,0x7a,0x21,0x9a,0xad,0xc6,
+  0x6d,0xbd,0xd5,0x11,0x87,0x1e,0xf4,0xaf,
+  0xdb,0xb3,0x40,0x86,0x71,0xbf,0xdb,0x1b,
+  0x4e,0xfd,0x80,0x4f,0x4a,0x72,0x6f,0x35,
+  0xeb,0xad,0x76,0xa3,0xdd,0xb8,0xbf,0xb3,
+  0xae,0x3a,0xd6,0xcd,0x75,0xc7,0x3a,0xa9,
+  0x41,0x2b,0xfe,0xe8,0xa8,0x84,0x10,0x42,
+  0x08,0x21,0x84,0x10,0x42,0xfe,0x9f,0x77,
+  0x1d,0x85,0x43,0xcf,0x70,0x48,0x1a,0x0c,
+  0x2c,0xf1,0x20,0x57,0x55,0x3c,0x6d,0xd3,
+  0x26,0xca,0x9b,0xd5,0x12,0xcc,0xd0,0x4b,
+  0x35,0x6b,0x4f,0x88,0xc3,0x70,0xc7,0x7d,
+  0xfe,0x6a,0xbb,0x7d,0x24,0x60,0xae,0xd7,
+  0x33,0x3e,0xf1,0x5d,0x6f,0x8c,0x24,0x8c,
+  0xc0,0xe9,0x0e,0x79,0xf8,0x30,0x85,0xcc,
+  0x60,0xe2,0x3c,0xda,0x3d,0x6f,0x3a,0x0e,
+  0x90,0x46,0x6e,0xe6,0x0c,0xa7,0xdc,0x1e,
+  0x78,0x93,0x91,0x13,0xc8,0xa1,0xf2,0xbe,
+  0x33,0x7a,0x91,0x47,0xa3,0xbb,0x0c,0x6c,
+  0xe8,0x39,0x7d,0x3b,0x70,0x47,0x1c,0x19,
+  0xe4,0x36,0x8f,0xd7,0xd7,0xb3,0x60,0xcf,
+  0x7c,0x6e,0x77,0xe7,0x01,0xf7,0x11,0x37,
+  0x18,0xc3,0xea,0x3b,0x8e,0x9c,0x3f,0x16,
+  0xfe,0xc2,0x61,0xca,0x20,0xa9,0x04,0xc9,
+  0xf0,0x04,0x53,0x82,0x54,0x46,0x06,0xa6,
+  0x12,0xa4,0x73,0x32,0x28,0x2a,0x81,0x91,
+  0x97,0x41,0x59,0x09,0x98,0x84,0x8a,0x12,
+  0x64,0xc2,0x2b,0x47,0x4a,0x90,0x0d,0x4f,
+  0x1c,0x2b,0x81,0x88,0x9a,0x11,0x3b,0xb5,
+  0x88,0xa8,0x13,0xf1,0x5d,0x88,0x50,0xdb,
+  0x10,0xbb,0x55,0x88,0x6d,0x0f,0x42,0x2d,
+  0x41,0x6c,0x1b,0x10,0xf8,0x02,0xe7,0x16,
+  0x7d,0xd4
+};
+
+/*
+  name: ndb_index_stat_sample
+  orig: 12842
+  pack: 371
+*/
+
+const uint g_ndb_index_stat_sample_frm_len = 371;
+
+const uint8 g_ndb_index_stat_sample_frm_data[371] =
+{
+  0x01,0x00,0x00,0x00,0x2a,0x32,0x00,0x00,
+  0x67,0x01,0x00,0x00,0x78,0x9c,0xed,0xda,
+  0x3b,0x4f,0xc2,0x60,0x18,0x05,0xe0,0xd3,
+  0x1b,0xf4,0xa2,0x85,0x81,0x38,0x38,0x35,
+  0x71,0x01,0x17,0x74,0x71,0x32,0x11,0x8c,
+  0x9a,0x10,0xa3,0x12,0xc2,0xc2,0xd4,0x80,
+  0xed,0x40,0xc4,0x6a,0xb8,0x05,0xb6,0xfe,
+  0x36,0xfd,0x3b,0x0e,0xfc,0x00,0xe3,0x67,
+  0x69,0xa9,0xc0,0x62,0xdc,0x8a,0xc9,0x79,
+  0xa6,0xb7,0xa7,0x5f,0x9a,0xf3,0x6d,0x1d,
+  0xde,0x2f,0xc9,0xb4,0x15,0xa0,0x28,0x01,
+  0x35,0xe0,0x4d,0x46,0x09,0x29,0x79,0x06,
+  0x03,0xd0,0x96,0xa3,0x9e,0x66,0xd1,0x01,
+  0x7c,0xbc,0x03,0x67,0xf1,0x93,0x0d,0x54,
+  0xab,0xc0,0x09,0x88,0x88,0x88,0x88,0x88,
+  0x88,0x88,0x68,0x97,0xc9,0x79,0xe0,0x08,
+  0x65,0x7c,0x5a,0xaa,0x02,0x48,0xa1,0x04,
+  0x1c,0xd6,0x54,0xc8,0xa1,0x96,0x0c,0x4a,
+  0x68,0x24,0x83,0x1a,0xee,0x47,0xef,0x6b,
+  0x0b,0x4b,0xc2,0x1e,0xa2,0xa3,0xbf,0x9d,
+  0x15,0xcd,0x56,0xe3,0xae,0xde,0xea,0x88,
+  0xc0,0xeb,0xb9,0xfd,0xc0,0xf3,0x67,0xee,
+  0x68,0xdc,0x1d,0xbb,0xa3,0xee,0xf3,0xeb,
+  0xc0,0x77,0x67,0xa7,0x22,0xeb,0x6b,0x13,
+  0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+  0x11,0xd1,0x3f,0x60,0x22,0xf0,0x7a,0x8f,
+  0x83,0xc9,0x68,0xec,0x0f,0x97,0xeb,0x6b,
+  0x4e,0xb3,0xde,0x6a,0x37,0xda,0x8d,0x87,
+  0x7b,0xe7,0xb2,0xe3,0xdc,0x5e,0x77,0x9c,
+  0x72,0x05,0x92,0x9d,0x75,0x4d,0x22,0x22,
+  0x22,0xa2,0x9d,0x70,0x2c,0xa3,0x98,0x75,
+  0x87,0x2c,0x49,0xd0,0x30,0x87,0xbd,0xfc,
+  0x6d,0x2c,0x9d,0xff,0xa4,0x4d,0x1c,0xac,
+  0xa6,0x39,0x72,0x9a,0x5c,0xaa,0x38,0x7f,
+  0x04,0x15,0x46,0xb2,0xf0,0xd0,0xf7,0xa2,
+  0x2f,0xdb,0xc9,0x3c,0xf5,0x87,0xa3,0xfe,
+  0x4b,0x80,0x1c,0x0a,0xab,0x15,0x88,0x34,
+  0xc9,0xc3,0x88,0x37,0x23,0x9e,0xfc,0x39,
+  0x74,0x58,0xf1,0x3c,0xed,0x0e,0x26,0x3e,
+  0x54,0xc3,0x34,0x11,0x6f,0x58,0x44,0x2d,
+  0x14,0x1d,0xd0,0xec,0x28,0xd0,0x36,0x82,
+  0x5c,0x21,0x0a,0x8c,0x8d,0x20,0x6f,0xdc,
+  0x2c,0xac,0x78,0x4b,0x23,0x0a,0x0a,0x17,
+  0x80,0x6e,0x5d,0x41,0x17,0xd6,0x3a,0x10,
+  0x69,0x37,0xb1,0x55,0x4c,0x6c,0xb7,0x12,
+  0x69,0x25,0xb1,0xee,0x23,0xf0,0x0d,0x53,
+  0x4c,0x66,0xbc
+};

=== modified file 'storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp	2011-06-12 16:51:59 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp	2011-06-12 16:54:32 +0000
@@ -127,59 +127,67 @@ NdbIndexStatImpl::make_headtable(NdbDict
 {
   tab.setName(g_headtable_name);
   tab.setLogging(true);
+  int ret;
+  ret = tab.setFrm(g_ndb_index_stat_head_frm_data,
+                   g_ndb_index_stat_head_frm_len);
+  if (ret != 0)
+  {
+    setError(ret, __LINE__);
+    return -1;
+  }
   // key must be first
   {
-    NdbDictionary::Column col("INDEX_ID");
+    NdbDictionary::Column col("index_id");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setPrimaryKey(true);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("INDEX_VERSION");
+    NdbDictionary::Column col("index_version");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setPrimaryKey(true);
     tab.addColumn(col);
   }
   // table
   {
-    NdbDictionary::Column col("TABLE_ID");
+    NdbDictionary::Column col("table_id");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("FRAG_COUNT");
+    NdbDictionary::Column col("frag_count");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
   }
   // current sample
   {
-    NdbDictionary::Column col("VALUE_FORMAT");
+    NdbDictionary::Column col("value_format");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("SAMPLE_VERSION");
+    NdbDictionary::Column col("sample_version");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("LOAD_TIME");
+    NdbDictionary::Column col("load_time");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("SAMPLE_COUNT");
+    NdbDictionary::Column col("sample_count");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("KEY_BYTES");
+    NdbDictionary::Column col("key_bytes");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setNullable(false);
     tab.addColumn(col);
@@ -197,27 +205,35 @@ NdbIndexStatImpl::make_sampletable(NdbDi
 {
   tab.setName(g_sampletable_name);
   tab.setLogging(true);
+  int ret;
+  ret = tab.setFrm(g_ndb_index_stat_sample_frm_data,
+                   g_ndb_index_stat_sample_frm_len);
+  if (ret != 0)
+  {
+    setError(ret, __LINE__);
+    return -1;
+  }
   // key must be first
   {
-    NdbDictionary::Column col("INDEX_ID");
+    NdbDictionary::Column col("index_id");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setPrimaryKey(true);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("INDEX_VERSION");
+    NdbDictionary::Column col("index_version");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setPrimaryKey(true);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("SAMPLE_VERSION");
+    NdbDictionary::Column col("sample_version");
     col.setType(NdbDictionary::Column::Unsigned);
     col.setPrimaryKey(true);
     tab.addColumn(col);
   }
   {
-    NdbDictionary::Column col("STAT_KEY");
+    NdbDictionary::Column col("stat_key");
     col.setType(NdbDictionary::Column::Longvarbinary);
     col.setPrimaryKey(true);
     col.setLength(MaxKeyBytes);
@@ -225,7 +241,7 @@ NdbIndexStatImpl::make_sampletable(NdbDi
   }
   // value
   {
-    NdbDictionary::Column col("STAT_VALUE");
+    NdbDictionary::Column col("stat_value");
     col.setType(NdbDictionary::Column::Longvarbinary);
     col.setNullable(false);
     col.setLength(MaxValueCBytes);
@@ -246,9 +262,9 @@ NdbIndexStatImpl::make_sampleindex1(NdbD
   ind.setName(g_sampleindex1_name);
   ind.setType(NdbDictionary::Index::OrderedIndex);
   ind.setLogging(false);
-  ind.addColumnName("INDEX_ID");
-  ind.addColumnName("INDEX_VERSION");
-  ind.addColumnName("SAMPLE_VERSION");
+  ind.addColumnName("index_id");
+  ind.addColumnName("index_version");
+  ind.addColumnName("sample_version");
   return 0;
 }
 
@@ -870,12 +886,12 @@ NdbIndexStatImpl::sys_head_setkey(Con& c
 {
   Head& head = con.m_head;
   NdbOperation* op = con.m_op;
-  if (op->equal("INDEX_ID", (char*)&head.m_indexId) == -1)
+  if (op->equal("index_id", (char*)&head.m_indexId) == -1)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->equal("INDEX_VERSION", (char*)&head.m_indexVersion) == -1)
+  if (op->equal("index_version", (char*)&head.m_indexVersion) == -1)
   {
     setError(con, __LINE__);
     return -1;
@@ -888,37 +904,37 @@ NdbIndexStatImpl::sys_head_getvalue(Con&
 {
   Head& head = con.m_head;
   NdbOperation* op = con.m_op;
-  if (op->getValue("TABLE_ID", (char*)&head.m_tableId) == 0)
+  if (op->getValue("table_id", (char*)&head.m_tableId) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("FRAG_COUNT", (char*)&head.m_fragCount) == 0)
+  if (op->getValue("frag_count", (char*)&head.m_fragCount) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("VALUE_FORMAT", (char*)&head.m_valueFormat) == 0)
+  if (op->getValue("value_format", (char*)&head.m_valueFormat) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("SAMPLE_VERSION", (char*)&head.m_sampleVersion) == 0)
+  if (op->getValue("sample_version", (char*)&head.m_sampleVersion) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("LOAD_TIME", (char*)&head.m_loadTime) == 0)
+  if (op->getValue("load_time", (char*)&head.m_loadTime) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("SAMPLE_COUNT", (char*)&head.m_sampleCount) == 0)
+  if (op->getValue("sample_count", (char*)&head.m_sampleCount) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("KEY_BYTES", (char*)&head.m_keyBytes) == 0)
+  if (op->getValue("key_bytes", (char*)&head.m_keyBytes) == 0)
   {
     setError(con, __LINE__);
     return -1;
@@ -931,22 +947,22 @@ NdbIndexStatImpl::sys_sample_setkey(Con&
 {
   Head& head = con.m_head;
   NdbIndexScanOperation* op = con.m_scanop;
-  if (op->equal("INDEX_ID", (char*)&head.m_indexId) == -1)
+  if (op->equal("index_id", (char*)&head.m_indexId) == -1)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->equal("INDEX_VERSION", (char*)&head.m_indexVersion) == -1)
+  if (op->equal("index_version", (char*)&head.m_indexVersion) == -1)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->equal("SAMPLE_VERSION", (char*)&head.m_sampleVersion) == -1)
+  if (op->equal("sample_version", (char*)&head.m_sampleVersion) == -1)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->equal("STAT_KEY", (char*)m_keyData.get_full_buf()) == -1)
+  if (op->equal("stat_key", (char*)m_keyData.get_full_buf()) == -1)
   {
     setError(con, __LINE__);
     return -1;
@@ -958,12 +974,12 @@ int
 NdbIndexStatImpl::sys_sample_getvalue(Con& con)
 {
   NdbIndexScanOperation* op = con.m_scanop;
-  if (op->getValue("STAT_KEY", (char*)m_keyData.get_full_buf()) == 0)
+  if (op->getValue("stat_key", (char*)m_keyData.get_full_buf()) == 0)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->getValue("STAT_VALUE", (char*)m_valueData.get_full_buf()) == 0)
+  if (op->getValue("stat_value", (char*)m_valueData.get_full_buf()) == 0)
   {
     setError(con, __LINE__);
     return -1;
@@ -979,19 +995,19 @@ NdbIndexStatImpl::sys_sample_setbound(Co
   const NdbIndexScanOperation::BoundType eq_bound =
     NdbIndexScanOperation::BoundEQ;
 
-  if (op->setBound("INDEX_ID", eq_bound, &head.m_indexId) == -1)
+  if (op->setBound("index_id", eq_bound, &head.m_indexId) == -1)
   {
     setError(con, __LINE__);
     return -1;
   }
-  if (op->setBound("INDEX_VERSION", eq_bound, &head.m_indexVersion) == -1)
+  if (op->setBound("index_version", eq_bound, &head.m_indexVersion) == -1)
   {
     setError(con, __LINE__);
     return -1;
   }
   if (sv_bound != -1)
   {
-    if (op->setBound("SAMPLE_VERSION", sv_bound, &head.m_sampleVersion) == -1)
+    if (op->setBound("sample_version", sv_bound, &head.m_sampleVersion) == -1)
     {
       setError(con, __LINE__);
       return -1;

=== modified file 'storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp	2011-06-07 10:03:02 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp	2011-06-12 16:54:32 +0000
@@ -30,6 +30,11 @@ class NdbIndexScanOperation;
 class NdbRecAttr;
 class NdbOperation;
 
+extern const uint g_ndb_index_stat_head_frm_len;
+extern const uint8 g_ndb_index_stat_head_frm_data[];
+extern const uint g_ndb_index_stat_sample_frm_len;
+extern const uint8 g_ndb_index_stat_sample_frm_data[];
+
 class NdbIndexStatImpl : public NdbIndexStat {
 public:
   friend class NdbIndexStat;

=== modified file 'storage/ndb/tools/Makefile.am'
--- a/storage/ndb/tools/Makefile.am	2011-06-06 12:18:27 +0000
+++ b/storage/ndb/tools/Makefile.am	2011-06-12 16:54:32 +0000
@@ -17,7 +17,7 @@ EXTRA_DIST = CMakeLists.txt ndbinfo.sql
 
 BUILT_SOURCES = ndbinfo.sql
 
-noinst_PROGRAMS = 	ndbinfo_sql
+noinst_PROGRAMS = 	ndbinfo_sql ndb_dump_frm_data
 dist_bin_SCRIPTS =	ndb_size.pl ndb_error_reporter
 dist_pkgdata_DATA = ndbinfo.sql
 
@@ -78,6 +78,7 @@ ndbinfo.sql: $(ndbinfo_sql_SOURCES)
 	$(MV) $@-t $@
 
 ndb_index_stat_SOURCES = ndb_index_stat.cpp $(tools_common_sources)
+ndb_dump_frm_data_SOURCES = ndb_dump_frm_data.cpp
 
 include $(top_srcdir)/storage/ndb/config/common.mk.am
 include $(top_srcdir)/storage/ndb/config/type_ndbapitools.mk.am
@@ -95,4 +96,5 @@ ndb_restore_LDFLAGS = @ndb_bin_am_ldflag
 ndb_config_LDFLAGS = @ndb_bin_am_ldflags@
 ndbinfo_sql_LDFLAGS = @ndb_bin_am_ldflags@
 ndb_index_stat_LDFLAGS = @ndb_bin_am_ldflags@
+ndb_dump_frm_data_LDFLAGS = @ndb_bin_am_ldflags@
 

=== added file 'storage/ndb/tools/ndb_dump_frm_data.cpp'
--- a/storage/ndb/tools/ndb_dump_frm_data.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/tools/ndb_dump_frm_data.cpp	2011-06-12 16:54:32 +0000
@@ -0,0 +1,176 @@
+/* Copyright (C) 2003 MySQL AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include <ndb_global.h>
+#include <ndb_opts.h>
+
+#include <NdbOut.hpp>
+#include <NdbApi.hpp>
+#include <NDBT.hpp>
+
+static int oi = 1000;
+static struct my_option
+my_long_options[] =
+{
+  { "help", '?',
+    "Display this help and exit.",
+    0, 0, 0,
+    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
+  { 0, 0,
+    0,
+    0, 0, 0,
+    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }
+};
+
+const char*
+load_default_groups[]= { 0 };
+
+static void
+short_usage_sub(void)
+{
+  ndb_short_usage_sub("*.frm ...");
+}
+
+static void
+usage()
+{
+  printf("%s: pack and dump *.frm as C arrays\n", my_progname);
+  ndb_usage(short_usage_sub, load_default_groups, my_long_options);
+}
+
+static void
+dodump(const char* name, const uchar* frm_data, uint frm_len)
+{
+  printf("const uint g_%s_frm_len = %u;\n\n", name, frm_len);
+  printf("const uint8 g_%s_frm_data[%u] =\n{\n", name, frm_len);
+  uint n = 0;
+  while (n < frm_len) {
+    if (n % 8 == 0) {
+      if (n != 0) {
+        printf("\n");
+      }
+      printf("  ");
+    }
+    printf("0x%02x", frm_data[n]);
+    if (n + 1 < frm_len) {
+            printf(",");
+    }
+    n++;
+  }
+  if (n % 8 != 0) {
+    printf("\n");
+  }
+  printf("};\n");
+}
+
+static int
+dofile(const char* file)
+{
+  struct stat st;
+  size_t size = 0;
+  uchar* data = 0;
+  int fd = -1;
+  uchar* pack_data = 0;
+  size_t pack_len = 0;
+  char* namebuf = 0;
+  int ret = -1;
+  do
+  {
+    if (stat(file, &st) == -1)
+    {
+      fprintf(stderr, "%s: stat: %s\n", file, strerror(errno));
+      break;
+    }
+    size = st.st_size;
+    if ((data = (uchar*)malloc(size)) == 0)
+    {
+      fprintf(stderr, "%s: malloc %u: %s\n", file, (uint)size, strerror(errno));
+      break;
+    }
+    if ((fd = open(file, O_RDONLY)) == -1)
+    {
+      fprintf(stderr, "%s: open: %s\n", file, strerror(errno));
+      break;
+    }
+    ssize_t size2;
+    if ((size2 = read(fd, data, size)) == -1)
+    {
+      fprintf(stderr, "%s: read: %s\n", file, strerror(errno));
+      break;
+    }
+    if ((size_t)size2 != size)
+    {
+      fprintf(stderr, "%s: short read: %u != %u\n", file, (uint)size2, (uint)size);
+      break;
+    }
+    int error;
+    if ((error = packfrm(data, size, &pack_data, &pack_len)) != 0)
+    {
+      fprintf(stderr, "%s: packfrm: error %d\n", file, error);
+      break;
+    }
+    namebuf = strdup(file);
+    if (namebuf == 0)
+    {
+      fprintf(stderr, "%s: strdup: %s\n", file, strerror(errno));
+      break;
+    }
+    char* name = namebuf;
+    if (strchr(name, '/') != 0)
+      name = strrchr(name, '/') + 1;
+    char* dot;
+    if ((dot = strchr(name, '.')) != 0)
+      *dot = 0;
+    printf("\n/*\n");
+    printf("  name: %s\n", name);
+    printf("  orig: %u\n", (uint)size);
+    printf("  pack: %u\n", (uint)pack_len);
+    printf("*/\n\n");
+    dodump(name, pack_data, pack_len);
+    ret = 0;
+  }
+  while (0);
+  if (namebuf != 0)
+    free(namebuf);
+  if (pack_data != 0)
+    my_free(pack_data, MYF(0));
+  if (fd != -1)
+    (void)close(fd);
+  if (data != 0)
+    free(data);
+  return ret;
+}
+
+int
+main(int argc, char** argv)
+{
+  my_progname = "ndb_pack_frm";
+  int ret;
+
+  ndb_init();
+  ndb_opt_set_usage_funcs(short_usage_sub, usage);
+  ret = handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option);
+ if (ret != 0)
+    return NDBT_WRONGARGS;
+
+  for (int i = 0; i < argc; i++)
+  {
+    ret = dofile(argv[i]);
+    if (ret != 0)
+      return NDBT_FAILED;
+  }
+
+  return NDBT_OK;
+}

=== modified file 'storage/ndb/tools/ndb_index_stat.cpp'
--- a/storage/ndb/tools/ndb_index_stat.cpp	2011-06-06 12:18:47 +0000
+++ b/storage/ndb/tools/ndb_index_stat.cpp	2011-06-12 16:54:32 +0000
@@ -93,7 +93,7 @@ doconnect()
 
     g_dic = g_ndb->getDictionary();
 
-    g_ndb_sys = new Ndb(g_ncc, "mysql");
+    g_ndb_sys = new Ndb(g_ncc, NDB_INDEX_STAT_DB);
     CHK2(g_ndb_sys->init() == 0, g_ndb_sys->getNdbError());
     CHK2(g_ndb_sys->waitUntilReady(30) == 0, g_ndb_sys->getNdbError());
 


Attachment: [text/bzr-bundle] bzr/pekka.nousiainen@oracle.com-20110612165432-zmsj0oqru7pskjmm.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-wl4124-new0 branch(pekka.nousiainen:4396) WL#4124Pekka Nousiainen13 Jun