Commit a36f97cd authored by unknown's avatar unknown

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/bk/work-sub-4.1
parents 5de829a2 124696cf
...@@ -943,3 +943,5 @@ ac_available_languages_fragment ...@@ -943,3 +943,5 @@ ac_available_languages_fragment
libmysqld/ha_archive.cc libmysqld/ha_archive.cc
libmysqld/ha_example.cc libmysqld/ha_example.cc
libmysqld/ha_tina.cc libmysqld/ha_tina.cc
analyse.test
client/mysqladmin.c
...@@ -4413,6 +4413,12 @@ mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong row) ...@@ -4413,6 +4413,12 @@ mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong row)
for (; tmp && row; --row, tmp= tmp->next) for (; tmp && row; --row, tmp= tmp->next)
; ;
stmt->data_cursor= tmp; stmt->data_cursor= tmp;
if (!row && tmp)
{
/* Rewind the counter */
stmt->read_row_func= stmt_read_row_buffered;
stmt->state= MYSQL_STMT_EXECUTE_DONE;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -478,3 +478,7 @@ t1 CREATE TABLE `t1` ( ...@@ -478,3 +478,7 @@ t1 CREATE TABLE `t1` (
`c3` longtext `c3` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value
myisam_data_pointer_size 8
...@@ -355,3 +355,10 @@ create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3; ...@@ -355,3 +355,10 @@ create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3;
show create table t1; show create table t1;
drop table t1; drop table t1;
#
# Bug #6993: myisam_data_pointer_size
#
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
/** The log levels. NOTE: Could not use the name LogLevel since /** The log levels. NOTE: Could not use the name LogLevel since
* it caused conflicts with another class. * it caused conflicts with another class.
*/ */
enum LoggerLevel {LL_OFF, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, enum LoggerLevel {LL_ON, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR,
LL_CRITICAL, LL_ALERT, LL_ALL}; LL_CRITICAL, LL_ALERT, LL_ALL};
/** /**
......
...@@ -244,7 +244,9 @@ extern "C" { ...@@ -244,7 +244,9 @@ extern "C" {
* Log severities (used to filter the cluster log) * Log severities (used to filter the cluster log)
*/ */
enum ndb_mgm_clusterlog_level { enum ndb_mgm_clusterlog_level {
NDB_MGM_CLUSTERLOG_OFF = 0, /*< Cluster log off*/ NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1,
/* must range from 0 and up, indexes into an array */
NDB_MGM_CLUSTERLOG_ON = 0, /*< Cluster log on*/
NDB_MGM_CLUSTERLOG_DEBUG = 1, /*< Used in NDB Cluster NDB_MGM_CLUSTERLOG_DEBUG = 1, /*< Used in NDB Cluster
*< developement *< developement
*/ */
...@@ -264,7 +266,8 @@ extern "C" { ...@@ -264,7 +266,8 @@ extern "C" {
*< corrected immediately, *< corrected immediately,
*< such as a corrupted system *< such as a corrupted system
*/ */
NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities on*/ /* must be next number, works as bound in loop */
NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities */
}; };
/** /**
...@@ -580,11 +583,13 @@ extern "C" { ...@@ -580,11 +583,13 @@ extern "C" {
* *
* @param handle NDB management handle. * @param handle NDB management handle.
* @param level A cluster log level to filter. * @param level A cluster log level to filter.
* @param enable set 1=enable 0=disable
* @param reply Reply message. * @param reply Reply message.
* @return -1 on error. * @return -1 on error.
*/ */
int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, int ndb_mgm_filter_clusterlog(NdbMgmHandle handle,
enum ndb_mgm_clusterlog_level level, enum ndb_mgm_clusterlog_level level,
int enable,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
/** /**
...@@ -620,6 +625,11 @@ extern "C" { ...@@ -620,6 +625,11 @@ extern "C" {
int level, int level,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
ndb_mgm_clusterlog_level
ndb_mgm_match_clusterlog_level(const char * name);
const char *
ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level);
/** /**
* Set log category and levels for the Node * Set log category and levels for the Node
* *
......
...@@ -48,10 +48,10 @@ public: ...@@ -48,10 +48,10 @@ public:
bool empty() const; bool empty() const;
/** @brief Convert to uppercase */ /** @brief Convert to uppercase */
void ndb_toupper(); BaseString& ndb_toupper();
/** @brief Convert to lowercase */ /** @brief Convert to lowercase */
void ndb_tolower(); BaseString& ndb_tolower();
/** @brief Assigns from a char * */ /** @brief Assigns from a char * */
BaseString& assign(const char* s); BaseString& assign(const char* s);
...@@ -206,16 +206,18 @@ BaseString::empty() const ...@@ -206,16 +206,18 @@ BaseString::empty() const
return m_len == 0; return m_len == 0;
} }
inline void inline BaseString&
BaseString::ndb_toupper() { BaseString::ndb_toupper() {
for(unsigned i = 0; i < length(); i++) for(unsigned i = 0; i < length(); i++)
m_chr[i] = toupper(m_chr[i]); m_chr[i] = toupper(m_chr[i]);
return *this;
} }
inline void inline BaseString&
BaseString::ndb_tolower() { BaseString::ndb_tolower() {
for(unsigned i = 0; i < length(); i++) for(unsigned i = 0; i < length(); i++)
m_chr[i] = tolower(m_chr[i]); m_chr[i] = tolower(m_chr[i]);
return *this;
} }
inline bool inline bool
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
// //
// PUBLIC // PUBLIC
// //
const char* Logger::LoggerLevelNames[] = { "OFF ", const char* Logger::LoggerLevelNames[] = { "ON ",
"DEBUG ", "DEBUG ",
"INFO ", "INFO ",
"WARNING ", "WARNING ",
...@@ -46,7 +46,9 @@ Logger::Logger() : ...@@ -46,7 +46,9 @@ Logger::Logger() :
m_pSyslogHandler(NULL) m_pSyslogHandler(NULL)
{ {
m_pHandlerList = new LogHandlerList(); m_pHandlerList = new LogHandlerList();
m_logLevels[LL_INFO] = true; disable(LL_ALL);
enable(LL_ON);
enable(LL_INFO);
} }
Logger::~Logger() Logger::~Logger()
...@@ -227,6 +229,13 @@ Logger::removeAllHandlers() ...@@ -227,6 +229,13 @@ Logger::removeAllHandlers()
bool bool
Logger::isEnable(LoggerLevel logLevel) const Logger::isEnable(LoggerLevel logLevel) const
{ {
if (logLevel == LL_ALL)
{
for (unsigned i = 1; i < MAX_LOG_LEVELS; i++)
if (!m_logLevels[i])
return false;
return true;
}
return m_logLevels[logLevel]; return m_logLevels[logLevel];
} }
...@@ -235,7 +244,7 @@ Logger::enable(LoggerLevel logLevel) ...@@ -235,7 +244,7 @@ Logger::enable(LoggerLevel logLevel)
{ {
if (logLevel == LL_ALL) if (logLevel == LL_ALL)
{ {
for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) for (unsigned i = 0; i < MAX_LOG_LEVELS; i++)
{ {
m_logLevels[i] = true; m_logLevels[i] = true;
} }
...@@ -337,7 +346,7 @@ Logger::debug(const char* pMsg, ...) const ...@@ -337,7 +346,7 @@ Logger::debug(const char* pMsg, ...) const
void void
Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const
{ {
if (m_logLevels[LL_OFF] == false && m_logLevels[logLevel]) if (m_logLevels[LL_ON] && m_logLevels[logLevel])
{ {
LogHandler* pHandler = NULL; LogHandler* pHandler = NULL;
while ( (pHandler = m_pHandlerList->next()) != NULL) while ( (pHandler = m_pHandlerList->next()) != NULL)
......
...@@ -914,21 +914,67 @@ ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, const int *node_list) ...@@ -914,21 +914,67 @@ ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, const int *node_list)
return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0); return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0);
} }
static const char *clusterlog_level_names[]=
{ "enabled", "debug", "info", "warning", "error", "critical", "alert" };
struct ndb_mgm_clusterlog_levels
{
const char* name;
enum ndb_mgm_clusterlog_level level;
} clusterlog_levels[] = {
{ clusterlog_level_names[0], NDB_MGM_CLUSTERLOG_ON },
{ clusterlog_level_names[1], NDB_MGM_CLUSTERLOG_DEBUG },
{ clusterlog_level_names[2], NDB_MGM_CLUSTERLOG_INFO },
{ clusterlog_level_names[3], NDB_MGM_CLUSTERLOG_WARNING },
{ clusterlog_level_names[4], NDB_MGM_CLUSTERLOG_ERROR },
{ clusterlog_level_names[5], NDB_MGM_CLUSTERLOG_CRITICAL },
{ clusterlog_level_names[6], NDB_MGM_CLUSTERLOG_ALERT },
{ "all", NDB_MGM_CLUSTERLOG_ALL },
{ 0, NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL },
};
extern "C"
ndb_mgm_clusterlog_level
ndb_mgm_match_clusterlog_level(const char * name)
{
if(name == 0)
return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL;
for(int i = 0; clusterlog_levels[i].name !=0 ; i++)
if(strcasecmp(name, clusterlog_levels[i].name) == 0)
return clusterlog_levels[i].level;
return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL;
}
extern "C"
const char *
ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level)
{
int i= (int)level;
if (i >= 0 && i < (int)NDB_MGM_CLUSTERLOG_ALL)
return clusterlog_level_names[i];
for(i = (int)NDB_MGM_CLUSTERLOG_ALL; clusterlog_levels[i].name != 0; i++)
if(clusterlog_levels[i].level == level)
return clusterlog_levels[i].name;
return 0;
}
extern "C" extern "C"
unsigned int * unsigned int *
ndb_mgm_get_logfilter(NdbMgmHandle handle) ndb_mgm_get_logfilter(NdbMgmHandle handle)
{ {
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_logfilter"); SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_logfilter");
static Uint32 enabled[7] = {0,0,0,0,0,0,0}; static Uint32 enabled[(int)NDB_MGM_CLUSTERLOG_ALL] = {0,0,0,0,0,0,0};
const ParserRow<ParserDummy> getinfo_reply[] = { const ParserRow<ParserDummy> getinfo_reply[] = {
MGM_CMD("clusterlog", NULL, ""), MGM_CMD("clusterlog", NULL, ""),
MGM_ARG("enabled", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[0], Int, Mandatory, ""),
MGM_ARG("debug", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[1], Int, Mandatory, ""),
MGM_ARG("info", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[2], Int, Mandatory, ""),
MGM_ARG("warning", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[3], Int, Mandatory, ""),
MGM_ARG("error", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[4], Int, Mandatory, ""),
MGM_ARG("critical", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[5], Int, Mandatory, ""),
MGM_ARG("alert", Int, Mandatory, ""), MGM_ARG(clusterlog_level_names[6], Int, Mandatory, ""),
}; };
CHECK_HANDLE(handle, NULL); CHECK_HANDLE(handle, NULL);
CHECK_CONNECTED(handle, NULL); CHECK_CONNECTED(handle, NULL);
...@@ -938,10 +984,8 @@ ndb_mgm_get_logfilter(NdbMgmHandle handle) ...@@ -938,10 +984,8 @@ ndb_mgm_get_logfilter(NdbMgmHandle handle)
reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args); reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args);
CHECK_REPLY(reply, NULL); CHECK_REPLY(reply, NULL);
const char *names[] = { "enabled", "debug", "info", "warning", "error", for(int i=0; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) {
"critical", "alert" }; reply->get(clusterlog_level_names[i], &enabled[i]);
for(int i=0; i < 7; i++) {
reply->get(names[i], &enabled[i]);
} }
return enabled; return enabled;
} }
...@@ -950,6 +994,7 @@ extern "C" ...@@ -950,6 +994,7 @@ extern "C"
int int
ndb_mgm_filter_clusterlog(NdbMgmHandle handle, ndb_mgm_filter_clusterlog(NdbMgmHandle handle,
enum ndb_mgm_clusterlog_level level, enum ndb_mgm_clusterlog_level level,
int enable,
struct ndb_mgm_reply* /*reply*/) struct ndb_mgm_reply* /*reply*/)
{ {
SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_filter_clusterlog"); SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_filter_clusterlog");
...@@ -964,6 +1009,7 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, ...@@ -964,6 +1009,7 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle,
Properties args; Properties args;
args.put("level", level); args.put("level", level);
args.put("enable", enable);
const Properties *reply; const Properties *reply;
reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args); reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args);
...@@ -971,11 +1017,14 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, ...@@ -971,11 +1017,14 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle,
BaseString result; BaseString result;
reply->get("result", result); reply->get("result", result);
if(strcmp(result.c_str(), "1") == 0) {
if (strcmp(result.c_str(), "1") == 0)
retval = 1;
else if (strcmp(result.c_str(), "0") == 0)
retval = 0; retval = 0;
} else { else
{
SET_ERROR(handle, EINVAL, result.c_str()); SET_ERROR(handle, EINVAL, result.c_str());
retval = -1;
} }
delete reply; delete reply;
return retval; return retval;
......
...@@ -264,9 +264,9 @@ static const char* helpText = ...@@ -264,9 +264,9 @@ static const char* helpText =
"START BACKUP Start backup\n" "START BACKUP Start backup\n"
"ABORT BACKUP <backup id> Abort backup\n" "ABORT BACKUP <backup id> Abort backup\n"
"SHUTDOWN Shutdown all processes in cluster and quit\n" "SHUTDOWN Shutdown all processes in cluster and quit\n"
"CLUSTERLOG ON Enable Cluster logging\n" "CLUSTERLOG ON [<severity>] ... Enable Cluster logging\n"
"CLUSTERLOG OFF Disable Cluster logging\n" "CLUSTERLOG OFF [<severity>] ... Disable Cluster logging\n"
"CLUSTERLOG FILTER <severity> Toggle severity filter on/off\n" "CLUSTERLOG TOGGLE [<severity>] ... Toggle severity filter on/off\n"
"CLUSTERLOG INFO Print cluster log information\n" "CLUSTERLOG INFO Print cluster log information\n"
"<id> START Start DB node (started with -n)\n" "<id> START Start DB node (started with -n)\n"
"<id> RESTART [-n] [-i] Restart DB node\n" "<id> RESTART [-n] [-i] Restart DB node\n"
...@@ -666,11 +666,9 @@ CommandInterpreter::analyseAfterFirstToken(int processId, ...@@ -666,11 +666,9 @@ CommandInterpreter::analyseAfterFirstToken(int processId,
if(processId == -1){ if(processId == -1){
executeForAll(command, fun, allAfterSecondToken); executeForAll(command, fun, allAfterSecondToken);
} else { } else {
if(strcasecmp(command, "STATUS") != 0)
ndbout_c("Executing %s on node %d.", command, processId);
(this->*fun)(processId, allAfterSecondToken, false); (this->*fun)(processId, allAfterSecondToken, false);
ndbout << endl;
} }
ndbout << endl;
} }
/** /**
...@@ -733,12 +731,8 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, ...@@ -733,12 +731,8 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun,
return; return;
} }
NdbAutoPtr<char> ap1((char*)cl); NdbAutoPtr<char> ap1((char*)cl);
while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) { while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB))
if(strcasecmp(cmd, "STATUS") != 0)
ndbout_c("Executing %s on node %d.", cmd, nodeId);
(this->*fun)(nodeId, allAfterSecondToken, true); (this->*fun)(nodeId, allAfterSecondToken, true);
ndbout << endl;
} // while
} }
} }
...@@ -1137,30 +1131,93 @@ CommandInterpreter::executeConnect(char* parameters) ...@@ -1137,30 +1131,93 @@ CommandInterpreter::executeConnect(char* parameters)
void void
CommandInterpreter::executeClusterLog(char* parameters) CommandInterpreter::executeClusterLog(char* parameters)
{ {
DBUG_ENTER("CommandInterpreter::executeClusterLog");
int i; int i;
if (parameters != 0 && strlen(parameters) != 0) { if (emptyString(parameters))
{
ndbout << "Missing argument." << endl;
DBUG_VOID_RETURN;
}
enum ndb_mgm_clusterlog_level severity = NDB_MGM_CLUSTERLOG_ALL; enum ndb_mgm_clusterlog_level severity = NDB_MGM_CLUSTERLOG_ALL;
int isOk = true;
char name[12];
bool noArgs = false;
char * tmpString = my_strdup(parameters,MYF(MY_WME)); char * tmpString = my_strdup(parameters,MYF(MY_WME));
My_auto_ptr<char> ap1(tmpString); My_auto_ptr<char> ap1(tmpString);
char * tmpPtr = 0; char * tmpPtr = 0;
char * item = strtok_r(tmpString, " ", &tmpPtr); char * item = strtok_r(tmpString, " ", &tmpPtr);
int enable;
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) {
ndbout << "Couldn't get status" << endl;
printError();
DBUG_VOID_RETURN;
}
/******************** /********************
* CLUSTERLOG FILTER * CLUSTERLOG INFO
********************/ ********************/
if (strcasecmp(item, "FILTER") == 0) { if (strcasecmp(item, "INFO") == 0) {
DBUG_PRINT("info",("INFO"));
if(enabled[0] == 0)
{
ndbout << "Cluster logging is disabled." << endl;
DBUG_VOID_RETURN;
}
#if 0
for(i = 0; i<7;i++)
printf("enabled[%d] = %d\n", i, enabled[i]);
#endif
ndbout << "Severities enabled: ";
for(i = 1; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) {
const char *str= ndb_mgm_get_clusterlog_level_string((ndb_mgm_clusterlog_level)i);
if (str == 0)
{
DBUG_ASSERT(false);
continue;
}
if(enabled[i])
ndbout << BaseString(str).ndb_toupper() << " ";
}
ndbout << endl;
DBUG_VOID_RETURN;
}
else if (strcasecmp(item, "FILTER") == 0 ||
strcasecmp(item, "TOGGLE") == 0)
{
DBUG_PRINT("info",("TOGGLE"));
enable= -1;
}
else if (strcasecmp(item, "OFF") == 0)
{
DBUG_PRINT("info",("OFF"));
enable= 0;
} else if (strcasecmp(item, "ON") == 0) {
DBUG_PRINT("info",("ON"));
enable= 1;
} else {
ndbout << "Invalid argument." << endl;
DBUG_VOID_RETURN;
}
int res_enable;
item = strtok_r(NULL, " ", &tmpPtr); item = strtok_r(NULL, " ", &tmpPtr);
if (item == NULL) { if (item == NULL) {
noArgs = true; res_enable= ndb_mgm_filter_clusterlog(m_mgmsrv,
NDB_MGM_CLUSTERLOG_ON, enable, NULL);
if (res_enable < 0)
{
ndbout << "Couldn't set filter" << endl;
printError();
DBUG_VOID_RETURN;
}
ndbout << "Cluster logging is " << (res_enable ? "enabled.":"disabled") << endl;
DBUG_VOID_RETURN;
} }
while (item != NULL) {
snprintf(name, sizeof(name), item);
do {
severity= NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL;
if (strcasecmp(item, "ALL") == 0) { if (strcasecmp(item, "ALL") == 0) {
severity = NDB_MGM_CLUSTERLOG_ALL; severity = NDB_MGM_CLUSTERLOG_ALL;
} else if (strcasecmp(item, "ALERT") == 0) { } else if (strcasecmp(item, "ALERT") == 0) {
...@@ -1175,106 +1232,29 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1175,106 +1232,29 @@ CommandInterpreter::executeClusterLog(char* parameters)
severity = NDB_MGM_CLUSTERLOG_INFO; severity = NDB_MGM_CLUSTERLOG_INFO;
} else if (strcasecmp(item, "DEBUG") == 0) { } else if (strcasecmp(item, "DEBUG") == 0) {
severity = NDB_MGM_CLUSTERLOG_DEBUG; severity = NDB_MGM_CLUSTERLOG_DEBUG;
} else if (strcasecmp(item, "OFF") == 0) { } else if (strcasecmp(item, "OFF") == 0 ||
severity = NDB_MGM_CLUSTERLOG_OFF; strcasecmp(item, "ON") == 0) {
} else { if (enable < 0) // only makes sense with toggle
isOk = false; severity = NDB_MGM_CLUSTERLOG_ON;
}
item = strtok_r(NULL, " ", &tmpPtr);
} // while(item != NULL){
if (noArgs) {
ndbout << "Missing argument(s)." << endl;
} else if (isOk) {
if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) {
if(strcasecmp(name, "ALL") == 0) {
ndbout << "All severities levels enabled." << endl;
} else if(strcasecmp(name, "OFF") == 0) {
ndbout << "Cluster logging enabled." << endl;
} else {
ndbout << name << " events disabled." << endl;
}
} else {
if(strcasecmp(name, "ALL") == 0) {
ndbout << "All severities levels disabled." << endl;
} else if(strcasecmp(name, "OFF") == 0) {
ndbout << "Cluster logging disabled." << endl;
} else {
ndbout << name << " events enabled." << endl;
} }
} if (severity == NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL) {
} else { ndbout << "Invalid severity level: " << item << endl;
ndbout << "Invalid severity level." << endl; DBUG_VOID_RETURN;
} }
/******************** res_enable = ndb_mgm_filter_clusterlog(m_mgmsrv, severity, enable, NULL);
* CLUSTERLOG INFO if (res_enable < 0)
********************/ {
} else if (strcasecmp(item, "INFO") == 0) { ndbout << "Couldn't set filter" << endl;
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) {
ndbout << "Couldn't get status" << endl;
printError();
return;
}
const char* names[] = {"ENABLED", "DEBUG", "INFO", "WARNING", "ERROR",
"CRITICAL", "ALERT"};
if(enabled[0])
ndbout << "Cluster logging is disabled." << endl;
for(i = 0; i<7;i++)
printf("enabled[%d] = %d\n", i, enabled[i]);
ndbout << "Severities enabled: ";
for(i = 1; i < 7; i++) {
if(enabled[i])
ndbout << names[i] << " ";
}
ndbout << endl;
/********************
* CLUSTERLOG OFF
********************/
} else if (strcasecmp(item, "OFF") == 0) {
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) {
ndbout << "Couldn't get status" << endl;
printError(); printError();
return; DBUG_VOID_RETURN;
}
if(!enabled[0]) {
ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL);
ndbout << "Cluster logging is disabled." << endl;
} else {
ndbout << "Cluster logging is already disabled." << endl;
} }
ndbout << BaseString(item).ndb_toupper().c_str() << " " << (res_enable ? "enabled":"disabled") << endl;
/******************** item = strtok_r(NULL, " ", &tmpPtr);
* CLUSTERLOG ON } while(item != NULL);
********************/
} else if (strcasecmp(item, "ON") == 0) {
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) {
ndbout << "Could not get status" << endl;
printError();
return;
}
if(enabled[0]) {
ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL);
ndbout << "Cluster logging is enabled." << endl;
} else {
ndbout << "Cluster logging is already enabled." << endl;
}
} else {
ndbout << "Invalid argument." << endl;
}
} else { DBUG_VOID_RETURN;
ndbout << "Missing argument." << endl;
}
} }
//***************************************************************************** //*****************************************************************************
...@@ -1404,7 +1384,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, ...@@ -1404,7 +1384,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters,
if(all) if(all)
ndbout << "NDB Cluster is being restarted." << endl; ndbout << "NDB Cluster is being restarted." << endl;
else else
ndbout_c("Database node %d is being restarted.", processId); ndbout_c("Node %d is being restarted.", processId);
} }
} }
...@@ -1451,7 +1431,7 @@ CommandInterpreter::executeStatus(int processId, ...@@ -1451,7 +1431,7 @@ CommandInterpreter::executeStatus(int processId,
const char* parameters, bool all) const char* parameters, bool all)
{ {
if (! emptyString(parameters)) { if (! emptyString(parameters)) {
ndbout << "No parameters expected to this command." << endl; ndbout_c("No parameters expected to this command.");
return; return;
} }
...@@ -1482,7 +1462,7 @@ CommandInterpreter::executeStatus(int processId, ...@@ -1482,7 +1462,7 @@ CommandInterpreter::executeStatus(int processId,
ndbout << "Node " << processId << ": " << status_string(status); ndbout << "Node " << processId << ": " << status_string(status);
switch(status){ switch(status){
case NDB_MGM_NODE_STATUS_STARTING: case NDB_MGM_NODE_STATUS_STARTING:
ndbout << " (Phase " << startPhase << ")" ; ndbout << " (Phase " << startPhase << ")";
break; break;
case NDB_MGM_NODE_STATUS_SHUTTING_DOWN: case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
ndbout << " (Phase " << startPhase << ")"; ndbout << " (Phase " << startPhase << ")";
...@@ -1495,6 +1475,8 @@ CommandInterpreter::executeStatus(int processId, ...@@ -1495,6 +1475,8 @@ CommandInterpreter::executeStatus(int processId,
getMajor(version) , getMajor(version) ,
getMinor(version), getMinor(version),
getBuild(version)); getBuild(version));
else
ndbout << endl;
} }
...@@ -1506,7 +1488,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, ...@@ -1506,7 +1488,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters,
bool all) bool all)
{ {
(void) all; (void) all;
if (emptyString(parameters)) {
ndbout << "Expected argument" << endl;
return;
}
BaseString tmp(parameters); BaseString tmp(parameters);
Vector<BaseString> spec; Vector<BaseString> spec;
tmp.split(spec, "="); tmp.split(spec, "=");
...@@ -1532,6 +1517,8 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, ...@@ -1532,6 +1517,8 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters,
return; return;
} }
ndbout << "Executing LOGLEVEL on node " << processId << flush;
struct ndb_mgm_reply reply; struct ndb_mgm_reply reply;
int result; int result;
result = ndb_mgm_set_loglevel_node(m_mgmsrv, result = ndb_mgm_set_loglevel_node(m_mgmsrv,
...@@ -1541,11 +1528,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, ...@@ -1541,11 +1528,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters,
&reply); &reply);
if (result < 0) { if (result < 0) {
ndbout_c("Executing LOGLEVEL on node %d failed.", processId); ndbout_c(" failed.");
printError(); printError();
} else { } else {
ndbout << "Executing LOGLEVEL on node " << processId << " OK!" ndbout_c(" OK!");
<< endl;
} }
} }
...@@ -1840,36 +1826,36 @@ CommandInterpreter::executeEventReporting(int processId, ...@@ -1840,36 +1826,36 @@ CommandInterpreter::executeEventReporting(int processId,
spec[0].trim().ndb_toupper(); spec[0].trim().ndb_toupper();
int category = ndb_mgm_match_event_category(spec[0].c_str()); int category = ndb_mgm_match_event_category(spec[0].c_str());
if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){ if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){
category = atoi(spec[0].c_str()); if(!convert(spec[0].c_str(), category) ||
if(category < NDB_MGM_MIN_EVENT_CATEGORY || category < NDB_MGM_MIN_EVENT_CATEGORY ||
category > NDB_MGM_MAX_EVENT_CATEGORY){ category > NDB_MGM_MAX_EVENT_CATEGORY){
ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl; ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl;
return; return;
} }
} }
int level = atoi(spec[1].c_str()); int level;
if(level < 0 || level > 15){ if (!convert(spec[1].c_str(),level))
{
ndbout << "Invalid level: " << spec[1].c_str() << endl; ndbout << "Invalid level: " << spec[1].c_str() << endl;
return; return;
} }
ndbout << "Executing CLUSTERLOG on node " << processId << flush;
struct ndb_mgm_reply reply; struct ndb_mgm_reply reply;
int result; int result;
result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv, result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv,
processId, // fast fix - pekka processId,
(ndb_mgm_event_category)category, (ndb_mgm_event_category)category,
level, level,
&reply); &reply);
if (result != 0) { if (result != 0) {
ndbout_c("Executing CLUSTERLOG on node %d failed", processId); ndbout_c(" failed.");
printError(); printError();
} else { } else {
ndbout << "Executing CLUSTERLOG on node " << processId << " OK!" ndbout_c(" OK!");
<< endl;
} }
} }
......
...@@ -157,10 +157,6 @@ int CommandInterpreter::readAndExecute() { ...@@ -157,10 +157,6 @@ int CommandInterpreter::readAndExecute() {
executeShow(allAfterFirstToken); executeShow(allAfterFirstToken);
return true; return true;
} }
else if (strcmp(firstToken, "CLUSTERLOG") == 0) {
executeClusterLog(allAfterFirstToken);
return true;
}
else if(strcmp(firstToken, "START") == 0 && else if(strcmp(firstToken, "START") == 0 &&
allAfterFirstToken != 0 && allAfterFirstToken != 0 &&
strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
...@@ -472,130 +468,6 @@ void CommandInterpreter::executeShow(char* parameters) { ...@@ -472,130 +468,6 @@ void CommandInterpreter::executeShow(char* parameters) {
} }
} }
//*****************************************************************************
//*****************************************************************************
void CommandInterpreter::executeClusterLog(char* parameters) {
if (parameters != 0 && strlen(parameters) != 0) {
int severity = 7;
int isOk = true;
char name[12];
bool noArgs = false;
char * tmpString = strdup(parameters);
char * tmpPtr = 0;
char * item = strtok_r(tmpString, " ", &tmpPtr);
/********************
* CLUSTERLOG FILTER
********************/
if (strcmp(item, "FILTER") == 0) {
item = strtok_r(NULL, " ", &tmpPtr);
if (item == NULL) {
noArgs = true;
}
while (item != NULL) {
snprintf(name, 12, item);
if (strcmp(item, "ALL") == 0) {
severity = 7;
} else if (strcmp(item, "ALERT") == 0) {
severity = 6;
} else if (strcmp(item, "CRITICAL") == 0) {
severity = 5;
} else if (strcmp(item, "ERROR") == 0) {
severity = 4;
} else if (strcmp(item, "WARNING") == 0) {
severity = 3;
} else if (strcmp(item, "INFO") == 0) {
severity = 2;
} else if (strcmp(item, "DEBUG") == 0) {
severity = 1;
} else if (strcmp(item, "OFF") == 0) {
severity = 0;
} else {
isOk = false;
}
item = strtok_r(NULL, " ", &tmpPtr);
} // while(item != NULL){
free(tmpString);
if (noArgs) {
ndbout << "Missing argument(s)." << endl;
} else if (isOk) {
if (_mgmtSrvr.setEventLogFilter(severity)) {
if(strcmp(name, "ALL") == 0 || strcmp(name, "all") == 0) {
ndbout << "All severities levels enabled." << endl;
} else if(strcmp(name, "OFF") == 0 || strcmp(name, "off") == 0) {
ndbout << "Cluster logging disabled." << endl;
} else {
ndbout << name << " events enabled." << endl;
}
} else {
if(strcmp(name, "ALL") == 0) {
ndbout << "All severities levels disabled." << endl;
} else if(strcmp(name, "OFF") == 0) {
ndbout << "Cluster logging enabled." << endl;
} else {
ndbout << name << " events disabled." << endl;
}
}
} else {
ndbout << "Invalid severity level." << endl;
}
/********************
* CLUSTERLOG INFO
********************/
} else if (strcmp(item, "INFO") == 0) {
const char* names[] = {"DEBUG", "INFO", "WARNING", "ERROR",
"CRITICAL", "ALERT"};
if (_mgmtSrvr.isEventLogFilterEnabled(0)) { // OFF
ndbout << "Cluster logging is disabled." << endl;
}
ndbout << "Severities enabled: ";
for (int i = 0; i < 6; i++) {
if (_mgmtSrvr.isEventLogFilterEnabled(i + 1)) {
ndbout << names[i] << " ";
}
}
ndbout << endl;
/********************
* CLUSTERLOG OFF
********************/
} else if (strcmp(item, "OFF") == 0) {
if (!_mgmtSrvr.isEventLogFilterEnabled(0)) { // ON
if (_mgmtSrvr.setEventLogFilter(0));
ndbout << "Cluster logging is disabled." << endl;
} else {
ndbout << "Cluster logging is already disabled." << endl;
}
/********************
* CLUSTERLOG ON
********************/
} else if (strcmp(item, "ON") == 0) {
if (_mgmtSrvr.isEventLogFilterEnabled(0)) { // OFF
if (_mgmtSrvr.setEventLogFilter(0));
ndbout << "Cluster logging is enabled." << endl;
} else {
ndbout << "Cluster logging is already enabled." << endl;
}
} else {
ndbout << "Invalid argument." << endl;
}
} else {
ndbout << "Missing argument." << endl;
}
}
void void
stopCallback(int nodeId, void * anyData, int errCode){ stopCallback(int nodeId, void * anyData, int errCode){
if(errCode == 0){ if(errCode == 0){
......
...@@ -125,7 +125,6 @@ private: ...@@ -125,7 +125,6 @@ private:
void executeShow(char* parameters); void executeShow(char* parameters);
void executeRun(char* parameters); void executeRun(char* parameters);
void executeInfo(char* parameters); void executeInfo(char* parameters);
void executeClusterLog(char* parameters);
public: public:
void executeStop(int processId, const char* parameters, bool all); void executeStop(int processId, const char* parameters, bool all);
......
...@@ -226,7 +226,8 @@ MgmtSrvr::startEventLog() ...@@ -226,7 +226,8 @@ MgmtSrvr::startEventLog()
clusterLog); clusterLog);
} }
if(!g_EventLogger.addHandler(logdest)) { if(!g_EventLogger.addHandler(logdest)) {
ndbout << "Warning: could not add log destination \"" << logdest.c_str() << "\"" << endl; ndbout << "Warning: could not add log destination \""
<< logdest.c_str() << "\"" << endl;
} }
} }
...@@ -244,18 +245,19 @@ class ErrorItem ...@@ -244,18 +245,19 @@ class ErrorItem
}; };
bool bool
MgmtSrvr::setEventLogFilter(int severity) MgmtSrvr::setEventLogFilter(int severity, int enable)
{ {
bool enabled = true;
Logger::LoggerLevel level = (Logger::LoggerLevel)severity; Logger::LoggerLevel level = (Logger::LoggerLevel)severity;
if (g_EventLogger.isEnable(level)) { if (enable > 0) {
g_EventLogger.enable(level);
} else if (enable == 0) {
g_EventLogger.disable(level);
} else if (g_EventLogger.isEnable(level)) {
g_EventLogger.disable(level); g_EventLogger.disable(level);
enabled = false;
} else { } else {
g_EventLogger.enable(level); g_EventLogger.enable(level);
} }
return g_EventLogger.isEnable(level);
return enabled;
} }
bool bool
......
...@@ -122,7 +122,7 @@ public: ...@@ -122,7 +122,7 @@ public:
* @param serverity the log level/serverity. * @param serverity the log level/serverity.
* @return true if the severity was enabled. * @return true if the severity was enabled.
*/ */
bool setEventLogFilter(int severity); bool setEventLogFilter(int severity, int enable);
/** /**
* Returns true if the log level/severity is enabled. * Returns true if the log level/severity is enabled.
......
...@@ -218,6 +218,7 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -218,6 +218,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_CMD("set logfilter", &MgmApiSession::setLogFilter, ""), MGM_CMD("set logfilter", &MgmApiSession::setLogFilter, ""),
MGM_ARG("level", Int, Mandatory, "Severety level"), MGM_ARG("level", Int, Mandatory, "Severety level"),
MGM_ARG("enable", Int, Mandatory, "1=disable, 0=enable, -1=toggle"),
MGM_CMD("config lock", &MgmApiSession::configLock, ""), MGM_CMD("config lock", &MgmApiSession::configLock, ""),
...@@ -1203,10 +1204,12 @@ void ...@@ -1203,10 +1204,12 @@ void
MgmApiSession::setLogFilter(Parser_t::Context &ctx, MgmApiSession::setLogFilter(Parser_t::Context &ctx,
const class Properties &args) { const class Properties &args) {
Uint32 level; Uint32 level;
Uint32 enable;
args.get("level", &level); args.get("level", &level);
args.get("enable", &enable);
int result = m_mgmsrv.setEventLogFilter(level); int result = m_mgmsrv.setEventLogFilter(level, enable);
m_output->println("set logfilter reply"); m_output->println("set logfilter reply");
m_output->println("result: %d", result); m_output->println("result: %d", result);
......
...@@ -1432,7 +1432,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) ...@@ -1432,7 +1432,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl)
m_globalHash->unlock(); m_globalHash->unlock();
} }
} }
DBUG_RETURN(ret) DBUG_RETURN(ret);
} }
int int
......
...@@ -5004,7 +5004,7 @@ The minimum value for this variable is 4096.", ...@@ -5004,7 +5004,7 @@ The minimum value for this variable is 4096.",
"Default pointer size to be used for MyISAM tables.", "Default pointer size to be used for MyISAM tables.",
(gptr*) &myisam_data_pointer_size, (gptr*) &myisam_data_pointer_size,
(gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
4, 2, 7, 0, 1, 0}, 4, 2, 8, 0, 1, 0},
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
"Used to help MySQL to decide when to use the slow but safe key cache index create method.", "Used to help MySQL to decide when to use the slow but safe key cache index create method.",
(gptr*) &global_system_variables.myisam_max_extra_sort_file_size, (gptr*) &global_system_variables.myisam_max_extra_sort_file_size,
......
...@@ -495,8 +495,17 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -495,8 +495,17 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
char *from, *to; char *from, *to;
for (from= to= (char*) interval->type_names[pos]; *from; ) for (from= to= (char*) interval->type_names[pos]; *from; )
{ {
*to++= (char) (hexchar_to_int(*from++) << 4) + /*
hexchar_to_int(*from++); Note, hexchar_to_int(*from++) doesn't work
one some compilers, e.g. IRIX. Looks like a compiler
bug in inline functions in combination with arguments
that have a side effect. So, let's use from[0] and from[1]
and increment 'from' by two later.
*/
*to++= (char) (hexchar_to_int(from[0]) << 4) +
hexchar_to_int(from[1]);
from+= 2;
} }
interval->type_lengths[pos] /= 2; interval->type_lengths[pos] /= 2;
} }
......
...@@ -11389,6 +11389,67 @@ static void test_conversion() ...@@ -11389,6 +11389,67 @@ static void test_conversion()
myquery(rc); myquery(rc);
} }
static void test_rewind(void)
{
MYSQL_STMT *stmt;
MYSQL_BIND bind;
int rc = 0;
const char *stmt_text;
long unsigned int length=4, Data=0;
my_bool isnull=0;
myheader("test_rewind");
stmt_text= "CREATE TABLE t1 (a int)";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt_text= "INSERT INTO t1 VALUES(2),(3),(4)";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
stmt= mysql_stmt_init(mysql);
stmt_text= "SELECT * FROM t1";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
bzero(&bind,sizeof(MYSQL_BIND));
bind.buffer_type= MYSQL_TYPE_LONG;
bind.buffer= (void *)&Data; /* this buffer won't be altered */
bind.length= &length;
bind.is_null= &isnull;
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
rc= mysql_stmt_store_result(stmt);
DIE_UNLESS(rc == 0);
rc= mysql_stmt_bind_result(stmt, &bind);
DIE_UNLESS(rc == 0);
/* retreive all result sets till we are at the end */
while(!mysql_stmt_fetch(stmt))
printf("fetched result:%ld\n", Data);
DIE_UNLESS(rc != MYSQL_NO_DATA);
/* seek to the first row */
mysql_stmt_data_seek(stmt, 0);
/* now we should be able to fetch the results again */
/* but mysql_stmt_fetch returns MYSQL_NO_DATA */
while(!(rc= mysql_stmt_fetch(stmt)))
printf("fetched result after seek:%ld\n", Data);
DIE_UNLESS(rc == MYSQL_NO_DATA);
stmt_text= "DROP TABLE t1";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
rc= mysql_stmt_free_result(stmt);
rc= mysql_stmt_close(stmt);
}
/* /*
Read and parse arguments and MySQL options from my.cnf Read and parse arguments and MySQL options from my.cnf
...@@ -11594,6 +11655,7 @@ static struct my_tests_st my_tests[]= { ...@@ -11594,6 +11655,7 @@ static struct my_tests_st my_tests[]= {
{ "test_datetime_ranges", test_datetime_ranges }, { "test_datetime_ranges", test_datetime_ranges },
{ "test_bug4172", test_bug4172 }, { "test_bug4172", test_bug4172 },
{ "test_conversion", test_conversion }, { "test_conversion", test_conversion },
{ "test_rewind", test_rewind },
{ 0, 0 } { 0, 0 }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment