List:Commits« Previous MessageNext Message »
From:Maitrayi Sabaratnam Date:December 10 2010 12:35pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (msabaratnam:4052)
View as plain text  
#At file:///export/home2/tmp/maitrayi/mysql-repo/repo-7.0/mysql-5.1-telco-7.0-part-info/ based on revid:jonas@stripped

 4052 Maitrayi Sabaratnam	2010-12-10
      WORKLOG#5568 Show space usage by a table in INFORMATION_SCHEMA.TABLES/PARTITIONS

    modified:
      mysql-test/suite/ndb/r/ndb_dd_alter.result
      mysql-test/suite/ndb/r/ndb_partition_range.result
      mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/ha_ndbinfo.cc
      sql/ha_ndbinfo.h
      sql/ha_partition.cc
      sql/ha_partition.h
      sql/handler.h
=== modified file 'mysql-test/suite/ndb/r/ndb_dd_alter.result'
--- a/mysql-test/suite/ndb/r/ndb_dd_alter.result	2010-11-30 10:35:37 +0000
+++ b/mysql-test/suite/ndb/r/ndb_dd_alter.result	2010-12-10 12:35:21 +0000
@@ -317,11 +317,11 @@ a1
 20
 SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t1	p0	NULL	1	NULL	KEY	NULL		NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	ts
+NULL	test	t1	p0	NULL	1	NULL	KEY	NULL		NULL	NULL	11	28	32768	NULL	0	0	NULL	NULL	NULL	NULL		default	ts
 ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE;
 SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t1	p0	NULL	1	NULL	KEY	NULL		NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	ts
+NULL	test	t1	p0	NULL	1	NULL	KEY	NULL		NULL	NULL	11	36	32768	1048576	0	1043532	NULL	NULL	NULL	NULL		default	ts
 SELECT * FROM test.t1 ORDER BY a1;
 a1	a2	a3
 1	2.2345	20000001

=== modified file 'mysql-test/suite/ndb/r/ndb_partition_range.result'
--- a/mysql-test/suite/ndb/r/ndb_partition_range.result	2010-10-01 10:08:29 +0000
+++ b/mysql-test/suite/ndb/r/ndb_partition_range.result	2010-12-10 12:35:21 +0000
@@ -17,9 +17,9 @@ INSERT into t1 values (10, 1, 1);
 INSERT into t1 values (15, 1, 1);
 select * from information_schema.partitions where table_name= 't1';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t1	x1	NULL	1	NULL	RANGE	NULL	a	NULL	5	0	0	0	#	0	0	#	#	NULL	NULL		default	NULL
-NULL	test	t1	x2	NULL	2	NULL	RANGE	NULL	a	NULL	10	0	0	0	#	0	0	#	#	NULL	NULL		default	NULL
-NULL	test	t1	x3	NULL	3	NULL	RANGE	NULL	a	NULL	20	0	0	0	#	0	0	#	#	NULL	NULL		default	NULL
+NULL	test	t1	x1	NULL	1	NULL	RANGE	NULL	a	NULL	5	1	40	32768	#	0	0	#	#	NULL	NULL		default	NULL
+NULL	test	t1	x2	NULL	2	NULL	RANGE	NULL	a	NULL	10	1	40	32768	#	0	0	#	#	NULL	NULL		default	NULL
+NULL	test	t1	x3	NULL	3	NULL	RANGE	NULL	a	NULL	20	2	40	32768	#	0	0	#	#	NULL	NULL		default	NULL
 select * from t1 order by a;
 a	b	c
 1	1	1

=== modified file 'mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result'
--- a/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result	2009-10-15 17:48:45 +0000
+++ b/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result	2010-12-10 12:35:21 +0000
@@ -402,30 +402,30 @@ t6	CREATE TABLE `t6` (
  PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) */
 SELECT * FROM information_schema.partitions WHERE table_name= 't1';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t1	p0	NULL	1	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space1
-NULL	test	t1	p1	NULL	2	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space1
-NULL	test	t1	p2	NULL	3	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space1
-NULL	test	t1	p3	NULL	4	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space1
+NULL	test	t1	p0	NULL	1	NULL	HASH	NULL	c3	NULL	NULL	125	44	32768	1048576	0	1021944	NULL	NULL	NULL	NULL		default	table_space1
+NULL	test	t1	p1	NULL	2	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	1048576	0	0	NULL	NULL	NULL	NULL		default	table_space1
+NULL	test	t1	p2	NULL	3	NULL	HASH	NULL	c3	NULL	NULL	125	44	32768	1048576	0	1021944	NULL	NULL	NULL	NULL		default	table_space1
+NULL	test	t1	p3	NULL	4	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	1048576	0	0	NULL	NULL	NULL	NULL		default	table_space1
 SELECT * FROM information_schema.partitions WHERE table_name= 't2';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t2	p0	NULL	1	NULL	KEY	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space2
-NULL	test	t2	p1	NULL	2	NULL	KEY	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space2
+NULL	test	t2	p0	NULL	1	NULL	KEY	NULL	c3	NULL	NULL	139	40	65536	1048576	0	1042256	NULL	NULL	NULL	NULL		default	table_space2
+NULL	test	t2	p1	NULL	2	NULL	KEY	NULL	c3	NULL	NULL	111	40	65536	1048576	0	1042704	NULL	NULL	NULL	NULL		default	table_space2
 SELECT * FROM information_schema.partitions WHERE table_name= 't3';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t3	x1	NULL	1	NULL	RANGE	NULL	c3	NULL	105	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space2
-NULL	test	t3	x2	NULL	2	NULL	RANGE	NULL	c3	NULL	333	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space2
-NULL	test	t3	x3	NULL	3	NULL	RANGE	NULL	c3	NULL	720	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	table_space2
+NULL	test	t3	x1	NULL	1	NULL	RANGE	NULL	c3	NULL	105	53	44	32768	1048576	0	1030260	NULL	NULL	NULL	NULL		default	table_space2
+NULL	test	t3	x2	NULL	2	NULL	RANGE	NULL	c3	NULL	333	114	44	32768	1048576	0	1016840	NULL	NULL	NULL	NULL		default	table_space2
+NULL	test	t3	x3	NULL	3	NULL	RANGE	NULL	c3	NULL	720	83	44	32768	1048576	0	1023660	NULL	NULL	NULL	NULL		default	table_space2
 SELECT * FROM information_schema.partitions WHERE table_name= 't4';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t4	p0	NULL	1	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
+NULL	test	t4	p0	NULL	1	NULL	HASH	NULL	c3	NULL	NULL	250	40	65536	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
 NULL	test	t4	p1	NULL	2	NULL	HASH	NULL	c3	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
 SELECT * FROM information_schema.partitions WHERE table_name= 't5';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t5	p0	NULL	1	NULL	KEY	NULL	pk1	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
-NULL	test	t5	p1	NULL	2	NULL	KEY	NULL	pk1	NULL	NULL	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
+NULL	test	t5	p0	NULL	1	NULL	KEY	NULL	pk1	NULL	NULL	128	36	65536	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
+NULL	test	t5	p1	NULL	2	NULL	KEY	NULL	pk1	NULL	NULL	122	36	65536	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
 SELECT * FROM information_schema.partitions WHERE table_name= 't6';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t6	x1	NULL	1	NULL	RANGE	NULL	pk1	NULL	333	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
+NULL	test	t6	x1	NULL	1	NULL	RANGE	NULL	pk1	NULL	333	250	40	65536	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
 NULL	test	t6	x2	NULL	2	NULL	RANGE	NULL	pk1	NULL	720	0	0	0	NULL	0	0	NULL	NULL	NULL	NULL		default	NULL
 SELECT COUNT(*) FROM test.t1;
 COUNT(*)

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-12-01 12:06:43 +0000
+++ b/sql/ha_ndbcluster.cc	2010-12-10 12:35:21 +0000
@@ -344,7 +344,8 @@ static uchar *ndbcluster_get_key(NDB_SHA
 
 static int ndb_get_table_statistics(THD *thd, ha_ndbcluster*, bool, Ndb*,
                                     const NdbRecord *, struct Ndb_statistics *,
-                                    bool have_lock= FALSE);
+                                    bool have_lock= FALSE,
+                                    bool part_stats= FALSE);
 
 THD *injector_thd= 0;
 
@@ -5777,7 +5778,7 @@ ha_ndbcluster::cmp_ref(const uchar * ref
   }
 }
 
-int ha_ndbcluster::info(uint flag)
+int ha_ndbcluster::info(uint flag, bool part_stats)
 {
   THD *thd= table->in_use;
   int result= 0;
@@ -5813,7 +5814,7 @@ int ha_ndbcluster::info(uint flag)
       if ((my_errno= check_ndb_connection(thd)))
         DBUG_RETURN(my_errno);
     }
-    result= update_stats(thd, 1);
+    result= update_stats(thd, 1, false, part_stats);
     break;
   }
   if (flag & HA_STATUS_CONST)
@@ -5862,12 +5863,19 @@ int ha_ndbcluster::info(uint flag)
 void ha_ndbcluster::get_dynamic_partition_info(PARTITION_STATS *stat_info,
                                                uint part_id)
 {
-  /* 
-     This functions should be fixed. Suggested fix: to
-     implement ndb function which retrives the statistics
-     about ndb partitions.
-  */
   bzero((char*) stat_info, sizeof(PARTITION_STATS));
+
+  set_part_id(part_id);
+
+  int res= info(HA_STATUS_VARIABLE, true);
+  if (!res)
+  {
+    stat_info->records = stats.records;
+    stat_info->mean_rec_length = stats.mean_rec_length;
+    stat_info->data_file_length = stats.data_file_length;
+    stat_info->delete_length = stats.delete_length;
+    stat_info->max_data_file_length = stats.max_data_file_length;
+  }
   return;
 }
 
@@ -11430,7 +11438,8 @@ struct ndb_table_statistics_row {
 
 int ha_ndbcluster::update_stats(THD *thd,
                                 bool do_read_stat,
-                                bool have_lock)
+                                bool have_lock,
+                                bool part_stats)
 {
   struct Ndb_statistics stat;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -11444,7 +11453,7 @@ int ha_ndbcluster::update_stats(THD *thd
     }
     if (int err= ndb_get_table_statistics(thd, this, TRUE, ndb,
                                           m_ndb_record, &stat,
-                                          have_lock))
+                                          have_lock, part_stats))
     {
       DBUG_RETURN(err);
     }
@@ -11470,21 +11479,36 @@ int ha_ndbcluster::update_stats(THD *thd
   stats.mean_rec_length= stat.row_size;
   stats.data_file_length= stat.fragment_memory;
   stats.records= stat.row_count + no_uncommitted_rows_count;
+
+  stats.max_data_file_length= stat.fragment_extent_space;
+  stats.delete_length= stat.fragment_extent_free_space;
+
   DBUG_PRINT("exit", ("stats.records: %d  "
                       "stat->row_count: %d  "
-                      "no_uncommitted_rows_count: %d",
+                      "no_uncommitted_rows_count: %d  "
+                      "stat->fragment_extent_space: %u  "
+                      "stat->fragment_extent_free_space: %u",
                       (int)stats.records,
                       (int)stat.row_count,
-                      (int)no_uncommitted_rows_count));
+                      (int)no_uncommitted_rows_count,
+                      (uint)stat.fragment_extent_space,
+		      (uint)stat.fragment_extent_free_space));
   DBUG_RETURN(0);
 }
 
+/* If part_stats is true, ndbstat returns only the 
+   partition-statistics of the partition or fragment
+   specified in handler::m_part_id (given by file->get_part_id()). 
+   Else (i.e. part_stats is false), it returns the table-statistics,
+   which is an aggregate statistics over all partitions of this table.
+ */
+
 static 
 int
 ndb_get_table_statistics(THD *thd, ha_ndbcluster* file, bool report_error, Ndb* ndb,
                          const NdbRecord *record,
                          struct Ndb_statistics * ndbstat,
-                         bool have_lock)
+                         bool have_lock, bool part_stats)
 {
   Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   NdbTransaction* pTrans;
@@ -11493,12 +11517,12 @@ ndb_get_table_statistics(THD *thd, ha_nd
   int reterr= 0;
   int retry_sleep= 30; /* 30 milliseconds */
   const char *dummyRowPtr;
-  const Uint32 extraCols= 5;
+  const Uint32 extraCols= 8;
   NdbOperation::GetValueSpec extraGets[extraCols];
-  Uint64 rows, commits, fixed_mem, var_mem;
-  Uint32 size;
+  Uint64 rows, commits, fixed_mem, var_mem, ext_space, free_ext_space;
+  Uint32 size, fragid;
 #ifndef DBUG_OFF
-  char buff[22], buff2[22], buff3[22], buff4[22];
+  char buff[22], buff2[22], buff3[22], buff4[22], buff5[22], buff6[22];
 #endif
   DBUG_ENTER("ndb_get_table_statistics");
 
@@ -11519,6 +11543,12 @@ ndb_get_table_statistics(THD *thd, ha_nd
   extraGets[3].appStorage= &fixed_mem;
   extraGets[4].column= NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY;
   extraGets[4].appStorage= &var_mem;
+  extraGets[5].column= NdbDictionary::Column::FRAGMENT_EXTENT_SPACE;
+  extraGets[5].appStorage= &ext_space;
+  extraGets[6].column= NdbDictionary::Column::FRAGMENT_FREE_EXTENT_SPACE;
+  extraGets[6].appStorage= &free_ext_space;
+  extraGets[7].column= NdbDictionary::Column::FRAGMENT;
+  extraGets[7].appStorage= &fragid;
 
   const Uint32 codeWords= 1;
   Uint32 codeSpace[ codeWords ];
@@ -11541,6 +11571,8 @@ ndb_get_table_statistics(THD *thd, ha_nd
     Uint64 sum_commits= 0;
     Uint64 sum_row_size= 0;
     Uint64 sum_mem= 0;
+    Uint64 sum_ext_space= 0;
+    Uint64 sum_free_ext_space= 0;
     NdbScanOperation*pOp;
     int check;
 
@@ -11583,14 +11615,31 @@ ndb_get_table_statistics(THD *thd, ha_nd
     
     while ((check= pOp->nextResult(&dummyRowPtr, TRUE, TRUE)) == 0)
     {
-      DBUG_PRINT("info", ("nextResult rows: %d  commits: %d",
-                          (int)rows, (int)commits));
+      DBUG_PRINT("info", ("nextResult rows: %d  commits: %d "
+                          "fixed_mem_size %d var_mem_size %d "
+                          "fragmentid %d extent_space %d free_extent_space %d",
+                          (int)rows, (int)commits, (int)fixed_mem,
+                          (int)fixed_mem, (int)fragid, (int)ext_space,
+                          (int)free_ext_space));
+
+      if (part_stats && fragid != file->get_part_id())
+      {
+        continue;
+      }
+
       sum_rows+= rows;
       sum_commits+= commits;
       if (sum_row_size < size)
         sum_row_size= size;
       sum_mem+= fixed_mem + var_mem;
       count++;
+      sum_ext_space += ext_space;
+      sum_free_ext_space += free_ext_space;
+
+      if (part_stats && fragid == file->get_part_id())
+      {
+        break;
+      }
     }
     
     if (check == -1)
@@ -11607,13 +11656,19 @@ ndb_get_table_statistics(THD *thd, ha_nd
     ndbstat->commit_count= sum_commits;
     ndbstat->row_size= (ulong)sum_row_size;
     ndbstat->fragment_memory= sum_mem;
+    ndbstat->fragment_extent_space= sum_ext_space;
+    ndbstat->fragment_extent_free_space= sum_free_ext_space;
 
     DBUG_PRINT("exit", ("records: %s  commits: %s "
-                        "row_size: %s  mem: %s count: %u",
+                        "row_size: %s  mem: %s "
+                        "allocated: %s  free: %s "
+                        "count: %u",
 			llstr(sum_rows, buff),
                         llstr(sum_commits, buff2),
                         llstr(sum_row_size, buff3),
                         llstr(sum_mem, buff4),
+                        llstr(sum_ext_space, buff5),
+                        llstr(sum_free_ext_space, buff6),
                         count));
 
     DBUG_RETURN(0);

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2010-11-24 17:45:27 +0000
+++ b/sql/ha_ndbcluster.h	2010-12-10 12:35:21 +0000
@@ -164,6 +164,8 @@ struct Ndb_statistics {
   Uint64 commit_count;
   ulong row_size;
   Uint64 fragment_memory;
+  Uint64 fragment_extent_space; 
+  Uint64 fragment_extent_free_space;
 };
 
 typedef struct st_ndbcluster_share {
@@ -431,7 +433,7 @@ class ha_ndbcluster: public handler
   ha_rows records();
   ha_rows estimate_rows_upper_bound()
     { return HA_POS_ERROR; }
-  int info(uint);
+  int info(uint, bool part_stats= FALSE);
 #if MYSQL_VERSION_ID < 50501
   typedef PARTITION_INFO PARTITION_STATS;
 #endif
@@ -468,6 +470,8 @@ class ha_ndbcluster: public handler
   int create(const char *name, TABLE *form, HA_CREATE_INFO *info);
   int get_default_no_partitions(HA_CREATE_INFO *info);
   bool get_no_parts(const char *name, uint *no_parts);
+  Uint32 get_part_id() {return m_part_id;}
+  void set_part_id(Uint32 part_id) {m_part_id = part_id;}
   void set_auto_partitions(partition_info *part_info);
   virtual bool is_fatal_error(int error, uint flags)
   {
@@ -881,7 +885,8 @@ private:
   NdbIndexScanOperation *m_multi_cursor;
   Ndb *get_ndb(THD *thd);
 
-  int update_stats(THD *thd, bool do_read_stat, bool have_lock= FALSE);
+  int update_stats(THD *thd, bool do_read_stat, bool have_lock= FALSE,
+                   bool part_stats= FALSE);
 };
 
 int ndbcluster_discover(THD* thd, const char* dbname, const char* name,

=== modified file 'sql/ha_ndbinfo.cc'
--- a/sql/ha_ndbinfo.cc	2010-11-10 14:17:13 +0000
+++ b/sql/ha_ndbinfo.cc	2010-12-10 12:35:21 +0000
@@ -529,7 +529,7 @@ void ha_ndbinfo::position(const uchar *r
   DBUG_VOID_RETURN;
 }
 
-int ha_ndbinfo::info(uint flag)
+int ha_ndbinfo::info(uint flag, bool part_stats)
 {
   DBUG_ENTER("ha_ndbinfo::info");
   DBUG_PRINT("enter", ("flag: %d", flag));

=== modified file 'sql/ha_ndbinfo.h'
--- a/sql/ha_ndbinfo.h	2010-01-25 10:04:59 +0000
+++ b/sql/ha_ndbinfo.h	2010-12-10 12:35:21 +0000
@@ -54,7 +54,7 @@ public:
   int rnd_next(uchar *buf);
   int rnd_pos(uchar *buf, uchar *pos);
   void position(const uchar *record);
-  int info(uint);
+  int info(uint, bool part_stats= FALSE);
 
   THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
                              enum thr_lock_type lock_type) {

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-11-05 09:22:28 +0000
+++ b/sql/ha_partition.cc	2010-12-10 12:35:21 +0000
@@ -4985,7 +4985,7 @@ int ha_partition::handle_ordered_prev(uc
       retrieving statistics data.
 */
 
-int ha_partition::info(uint flag)
+int ha_partition::info(uint flag, bool part_stats)
 {
   DBUG_ENTER("ha_partition::info");
 
@@ -5218,6 +5218,7 @@ void ha_partition::get_dynamic_partition
   stat_info->max_data_file_length= file->stats.max_data_file_length;
   stat_info->index_file_length=    file->stats.index_file_length;
   stat_info->delete_length=        file->stats.delete_length;
+  stat_info->max_data_file_length= file->stats.max_data_file_length;
   stat_info->create_time=          file->stats.create_time;
   stat_info->update_time=          file->stats.update_time;
   stat_info->check_time=           file->stats.check_time;

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2010-11-02 12:50:55 +0000
+++ b/sql/ha_partition.h	2010-12-10 12:35:21 +0000
@@ -526,7 +526,7 @@ public:
     purposes.
     -------------------------------------------------------------------------
   */
-  virtual int info(uint);
+  virtual int info(uint, bool part_stats= FALSE);
   void get_dynamic_partition_info(PARTITION_INFO *stat_info,
                                   uint part_id);
   virtual int extra(enum ha_extra_function operation);

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2010-11-02 12:50:55 +0000
+++ b/sql/handler.h	2010-12-10 12:35:21 +0000
@@ -1563,7 +1563,7 @@ public:
     Otherwise it set ref to the current row.
   */
   virtual void position(const uchar *record)=0;
-  virtual int info(uint)=0; // see my_base.h for full description
+  virtual int info(uint, bool part_stats= FALSE)=0; // see my_base.h for full description
   virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info,
                                           uint part_id);
 #ifndef MCP_BUG56438


Attachment: [text/bzr-bundle] bzr/msabaratnam@mysql.com-20101210123521-x6b0k22ytv70uuel.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (msabaratnam:4052) Maitrayi Sabaratnam10 Dec