4147 Maitrayi Sabaratnam 2011-01-27 [merge]
Merge
modified:
mysql-test/suite/ndb/r/ndb_dd_basic.result
mysql-test/suite/ndb/r/ndb_partition_range.result
mysql-test/suite/ndb/t/ndb_dd_basic.test
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.h
4146 Jonas Oreland 2011-01-27
ndb - (bug#59756) latest patch revealed the setTemporary does not work...which it doesnt...but was previously silently ignored..but now is brought to light
modified:
sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_dd_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_dd_basic.result 2010-02-09 05:24:15 +0000
+++ b/mysql-test/suite/ndb/r/ndb_dd_basic.result 2011-01-27 17:57:43 +0000
@@ -167,6 +167,13 @@ INSERT INTO t1 VALUES
SELECT COUNT(*) FROM t1;
COUNT(*)
501
+select TABLE_NAME, PARTITION_NAME, TABLE_ROWS, DATA_LENGTH, MAX_DATA_LENGTH, DATA_FREE from INFORMATION_SCHEMA.partitions where table_name='t1';
+TABLE_NAME PARTITION_NAME TABLE_ROWS DATA_LENGTH MAX_DATA_LENGTH DATA_FREE
+t1 p0 259 32768 1048576 1039300
+t1 p1 242 32768 1048576 1039640
+select TABLE_NAME, TABLE_ROWS, DATA_LENGTH, MAX_DATA_LENGTH, DATA_FREE from INFORMATION_SCHEMA.tables where table_name='t1';
+TABLE_NAME TABLE_ROWS DATA_LENGTH MAX_DATA_LENGTH DATA_FREE
+t1 501 65536 2097152 2078940
CREATE LOGFILE GROUP lg2
ADD UNDOFILE 'x.dat'
INITIAL_SIZE 10y
=== 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 2011-01-27 17:57:43 +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/t/ndb_dd_basic.test'
--- a/mysql-test/suite/ndb/t/ndb_dd_basic.test 2010-02-09 05:24:15 +0000
+++ b/mysql-test/suite/ndb/t/ndb_dd_basic.test 2011-01-27 17:57:43 +0000
@@ -199,6 +199,14 @@ INSERT INTO t1 VALUES
SELECT COUNT(*) FROM t1;
+########################################
+# WL#5568: Check disk space usage.
+########################################
+
+select TABLE_NAME, PARTITION_NAME, TABLE_ROWS, DATA_LENGTH, MAX_DATA_LENGTH, DATA_FREE from INFORMATION_SCHEMA.partitions where table_name='t1';
+
+select TABLE_NAME, TABLE_ROWS, DATA_LENGTH, MAX_DATA_LENGTH, DATA_FREE from INFORMATION_SCHEMA.tables where table_name='t1';
+
####################################
# Test error cases with size numbers
####################################
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2011-01-27 14:08:39 +0000
+++ b/sql/ha_ndbcluster.cc 2011-01-27 17:57:43 +0000
@@ -369,7 +369,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,
+ uint part_id= ~(uint)0);
THD *injector_thd= 0;
@@ -5943,13 +5944,36 @@ 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.
- */
+ DBUG_PRINT("info", ("ha_ndbcluster::get_dynamic_partition_info"));
+
bzero((char*) stat_info, sizeof(PARTITION_STATS));
- return;
+ int error = 0;
+ THD *thd = table->in_use;
+
+ if (!thd)
+ thd = current_thd;
+ if (!m_table_info)
+ {
+ if ((error = check_ndb_connection(thd)))
+ goto err;
+ }
+ error = update_stats(thd, 1, false, part_id);
+
+ if (error == 0)
+ {
+ 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;
+ }
+
+err:
+
+ DBUG_PRINT("warning",
+ ("ha_ndbcluster::get_dynamic_partition_info failed with error code %u",
+ error));
}
@@ -11560,7 +11584,8 @@ struct ndb_table_statistics_row {
int ha_ndbcluster::update_stats(THD *thd,
bool do_read_stat,
- bool have_lock)
+ bool have_lock,
+ uint part_id)
{
struct Ndb_statistics stat;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -11574,7 +11599,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_id))
{
DBUG_RETURN(err);
}
@@ -11600,21 +11625,34 @@ 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_id contains a legal partition id, ndbstat returns the
+ partition-statistics pertaining to that partition only.
+ Otherwise, it returns the table-statistics,
+ which is an aggregate over all partitions of that 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,
+ uint part_id)
{
Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
NdbTransaction* pTrans;
@@ -11623,12 +11661,11 @@ ndb_get_table_statistics(THD *thd, ha_nd
int reterr= 0;
int retry_sleep= 30; /* 30 milliseconds */
const char *dummyRowPtr;
- const Uint32 extraCols= 5;
- NdbOperation::GetValueSpec extraGets[extraCols];
- Uint64 rows, commits, fixed_mem, var_mem;
- Uint32 size;
+ NdbOperation::GetValueSpec extraGets[8];
+ 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");
@@ -11649,6 +11686,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 ];
@@ -11671,6 +11714,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;
@@ -11687,7 +11732,7 @@ ndb_get_table_statistics(THD *thd, ha_nd
/* Set batch_size=1, as we need only one row per fragment. */
options.batch= 1;
options.extraGetValues= &extraGets[0];
- options.numExtraGetValues= extraCols;
+ options.numExtraGetValues= sizeof(extraGets)/sizeof(extraGets[0]);
options.interpretedCode= &code;
if ((pOp= pTrans->scanTable(record, NdbOperation::LM_CommittedRead,
@@ -11714,13 +11759,30 @@ 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));
+ "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)var_mem, (int)fragid, (int)ext_space,
+ (int)free_ext_space));
+
+ if ((part_id != ~(uint)0) && fragid != 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_id != ~(uint)0) && fragid == part_id)
+ {
+ break;
+ }
}
if (check == -1)
@@ -11737,13 +11799,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 2011-01-14 15:12:39 +0000
+++ b/sql/ha_ndbcluster.h 2011-01-27 17:57:43 +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 {
@@ -883,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,
+ uint part_id= ~(uint)0);
};
int ndbcluster_discover(THD* thd, const char* dbname, const char* name,
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.1-telco-7.0 branch (msabaratnam:4146 to 4147) | Maitrayi Sabaratnam | 27 Jan |