diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2005-01-13 18:24:19 +0100 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2005-01-13 18:24:19 +0100 |
commit | 2f77a22a01988f9f23f483225281e8ca636d9a70 (patch) | |
tree | fa529e2373a3877d0150bec89f3e96bb190bc954 /sql/ha_ndbcluster.cc | |
parent | 12040a9deaf8fc47f448123ab2e24c8f10f39e03 (diff) | |
download | mariadb-git-2f77a22a01988f9f23f483225281e8ca636d9a70.tar.gz |
To get correct values in SHOW TABLE STATUS
Added pseudo column fragment memory
changed ndb_get_table_statistics to take struct
and read row_size and fragment_memory
ndb/include/kernel/AttributeHeader.hpp:
Added pseudo column fragment memory
ndb/include/ndbapi/NdbDictionary.hpp:
Added pseudo column fragment memory
ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp:
Added pseudo column fragment memory
ndb/src/ndbapi/NdbDictionary.cpp:
Added pseudo column fragment memory
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
Added pseudo column fragment memory
sql/ha_ndbcluster.cc:
changed ndb_get_table_statistics to take struct
and read row_size and fragment_memory
sql/ha_ndbcluster.h:
partially implemented update_table_comment
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 90 |
1 files changed, 74 insertions, 16 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a1b1099135b..d5892d59c52 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -85,7 +85,7 @@ static int unpackfrm(const void **data, uint *len, const void* pack_data); static int ndb_get_table_statistics(Ndb*, const char *, - Uint64* rows, Uint64* commits); + struct Ndb_statistics *); /* @@ -95,6 +95,17 @@ static int ndb_get_table_statistics(Ndb*, const char *, static uint32 dummy_buf; /* + Stats that can be retrieved from ndb +*/ + +struct Ndb_statistics { + Uint64 row_count; + Uint64 commit_count; + Uint64 row_size; + Uint64 fragment_memory; +}; + +/* Error handling functions */ @@ -262,9 +273,11 @@ void ha_ndbcluster::records_update() // if (info->records == ~(ha_rows)0) { Ndb *ndb= get_ndb(); - Uint64 rows; - if(ndb_get_table_statistics(ndb, m_tabname, &rows, 0) == 0){ - info->records= rows; + struct Ndb_statistics stat; + if(ndb_get_table_statistics(ndb, m_tabname, &stat) == 0){ + mean_rec_length= stat.row_size; + data_file_length= stat.fragment_memory; + info->records= stat.row_count; } } { @@ -2724,10 +2737,19 @@ void ha_ndbcluster::info(uint flag) if ((my_errno= check_ndb_connection())) DBUG_VOID_RETURN; Ndb *ndb= get_ndb(); - Uint64 rows= 100; - if (current_thd->variables.ndb_use_exact_count) - ndb_get_table_statistics(ndb, m_tabname, &rows, 0); - records= rows; + struct Ndb_statistics stat; + if (current_thd->variables.ndb_use_exact_count && + ndb_get_table_statistics(ndb, m_tabname, &stat) == 0) + { + mean_rec_length= stat.row_size; + data_file_length= stat.fragment_memory; + records= stat.row_count; + } + else + { + mean_rec_length= 0; + records= 100; + } } } if (flag & HA_STATUS_CONST) @@ -4813,8 +4835,8 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len, static int -ndb_get_table_statistics(Ndb* ndb, const char * table, - Uint64* row_count, Uint64* commit_count) +ndb_get_table_statistics(Ndb* ndb, const char * table, + struct Ndb_statistics * ndbstat) { DBUG_ENTER("ndb_get_table_statistics"); DBUG_PRINT("enter", ("table: %s", table)); @@ -4835,9 +4857,11 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, if (check == -1) break; - Uint64 rows, commits; + Uint64 rows, commits, size, mem; pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&rows); pOp->getValue(NdbDictionary::Column::COMMIT_COUNT, (char*)&commits); + pOp->getValue(NdbDictionary::Column::ROW_SIZE, (char*)&size); + pOp->getValue(NdbDictionary::Column::FRAGMENT_MEMORY, (char*)&mem); check= pTrans->execute(NdbTransaction::NoCommit, NdbTransaction::AbortOnError, @@ -4847,10 +4871,15 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, Uint64 sum_rows= 0; Uint64 sum_commits= 0; + Uint64 sum_row_size= 0; + Uint64 sum_mem= 0; while((check= pOp->nextResult(TRUE, TRUE)) == 0) { sum_rows+= rows; sum_commits+= commits; + if (sum_row_size < size) + sum_row_size= size; + sum_mem+= mem; } if (check == -1) @@ -4859,11 +4888,14 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, pOp->close(TRUE); ndb->closeTransaction(pTrans); - if(row_count) - * row_count= sum_rows; - if(commit_count) - * commit_count= sum_commits; - DBUG_PRINT("exit", ("records: %u commits: %u", sum_rows, sum_commits)); + + ndbstat->row_count= sum_rows; + ndbstat->commit_count= sum_commits; + ndbstat->row_size= sum_row_size; + ndbstat->fragment_memory= sum_mem; + + DBUG_PRINT("exit", ("records: %u commits: %u row_size: %d mem: %d", + sum_rows, sum_commits, sum_row_size, sum_mem)); DBUG_RETURN(0); } while(0); @@ -5248,4 +5280,30 @@ ha_ndbcluster::setup_recattr(const NdbRecAttr* curr) DBUG_RETURN(0); } +char* +ha_ndbcluster::update_table_comment( + /* out: table comment + additional */ + const char* comment)/* in: table comment defined by user */ +{ + return (char*)comment; +#if 0 // for the future + uint length= strlen(comment); + if(length > 64000 - 3) + { + return((char*)comment); /* string too long */ + } + + char *str; + const char *fmt="%s%sRow size: %d"; + const unsigned fmt_len_plus_extra= length + strlen(fmt) + 3; + if ((str= my_malloc(fmt_len_plus_extra, MYF(0))) == NULL) + { + return (char*)comment; + } + + snprintf(str,fmt_len_plus_extra,fmt,comment,10); + return str; +#endif +} + #endif /* HAVE_NDBCLUSTER_DB */ |