add a new mgmapi ndb_mgm_get_db_parameter_info, which retrieve parameter's name

This commit is contained in:
Justin.He/justin.he@qa3-104.qa.cn.tlan 2006-10-18 11:06:35 +08:00
parent 01c02f34a9
commit 0192e8ab20
5 changed files with 2204 additions and 1 deletions

View file

@ -1133,6 +1133,14 @@ extern "C" {
int ndb_mgm_check_connection(NdbMgmHandle handle);
int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length);
struct ndb_mgm_param_info
{
Uint32 m_id;
const char * m_name;
};
int ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info,
size_t * size);
#endif
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED

View file

@ -1,7 +1,7 @@
noinst_LTLIBRARIES = libmgmapi.la
libmgmapi_la_SOURCES = mgmapi.cpp ndb_logevent.cpp mgmapi_configuration.cpp LocalConfig.cpp ../kernel/error/ndbd_exit_codes.c
libmgmapi_la_SOURCES = mgmapi.cpp ndb_logevent.cpp mgmapi_configuration.cpp LocalConfig.cpp ../kernel/error/ndbd_exit_codes.c ../mgmsrv/ParamInfo.cpp
INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/include/mgmapi

View file

@ -1,6 +1,10 @@
#include <ndb_types.h>
#include <mgmapi.h>
#include "mgmapi_configuration.hpp"
#include "../mgmsrv/ParamInfo.hpp"
extern const ParamInfo ParamInfoArray[];
extern const int ParamInfoNum;
ndb_mgm_configuration_iterator::ndb_mgm_configuration_iterator
(const ndb_mgm_configuration & conf, unsigned type_of_section)
@ -155,3 +159,37 @@ ndb_mgm_find(ndb_mgm_configuration_iterator* iter,
int param, unsigned search){
return iter->find(param, search);
}
/**
* Retrieve information about parameter
* @param info : in - pointer to structure allocated by caller
* @param size : in/out : pointer to int initialized to sizeof(ndb_mgm_param_info)...will be set to bytes set by function on return
*/
extern "C"
int
ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info, size_t * size) {
if ( paramId == 0 ) {
return -1;
}
for (int i = 0; i < ParamInfoNum; i++) {
if (paramId == ParamInfoArray[i]._paramId && strcmp(DB_TOKEN, ParamInfoArray[i]._section) == 0) {
size_t tmp = 0;
if (tmp + sizeof(info->m_id) <= *size)
{
info->m_id = ParamInfoArray[i]._paramId;
tmp += sizeof(info->m_id);
}
if (tmp + sizeof(info->m_name) <= *size)
{
info->m_name = ParamInfoArray[i]._fname;
tmp += sizeof(info->m_name);
}
*size = tmp;
return 0;
}
}
return -1;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,44 @@
#ifndef PARAMINFO_H
#define PARAMINFO_H
#define DB_TOKEN "DB"
#define MGM_TOKEN "MGM"
#define API_TOKEN "API"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* The Configuration parameter type and status
*/
enum ParameterType { CI_BOOL, CI_INT, CI_INT64, CI_STRING, CI_SECTION };
enum ParameterStatus { CI_USED, ///< Active
CI_DEPRICATED, ///< Can be, but shouldn't
CI_NOTIMPLEMENTED, ///< Is ignored.
CI_INTERNAL ///< Not configurable by the user
};
/**
* Entry for one configuration parameter
*/
typedef struct m_ParamInfo {
Uint32 _paramId;
const char* _fname;
const char* _section;
const char* _description;
ParameterStatus _status;
bool _updateable;
ParameterType _type;
const char* _default;
const char* _min;
const char* _max;
}ParamInfo;
#ifdef __cplusplus
}
#endif
#endif