summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2017-07-10 19:31:05 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2017-07-10 19:31:05 (GMT)
commit70a86be6c01f123cb166715ee03c21a5a5ded34b (patch) (side-by-side diff)
tree7478a7759d547106ca7b49515ee840bb5d106907
parent2e876f3eba3b02ef2e51cb00c9e65a55b59d3019 (diff)
downloadmysqlstat-master.tar.gz
mysqlstat-master.tar.bz2
Provide default values for NULL columnsHEADmaster
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/mysqlstat.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/mysqlstat.c b/src/mysqlstat.c
index 4eb5a18..7db2649 100644
--- a/src/mysqlstat.c
+++ b/src/mysqlstat.c
@@ -20,2 +20,3 @@
#include <assert.h>
+#include <errno.h>
#include "mysqlstat_mib.h"
@@ -184,8 +185,10 @@ val_Slave_IO_Running(char const *val)
{
- if (strcmp(val, "Yes") == 0)
- return 1;
- else if (strcmp(val, "No") == 0)
- return 2;
- else if (strcmp(val, "Connected") == 0)
- return 3;
+ if (val) {
+ if (strcmp(val, "Yes") == 0)
+ return 1;
+ else if (strcmp(val, "No") == 0)
+ return 2;
+ else if (strcmp(val, "Connected") == 0)
+ return 3;
+ }
return 4;
@@ -196,3 +199,3 @@ val_bool(char const *val)
{
- if (strcmp(val, "Yes") == 0)
+ if (val && strcmp(val, "Yes") == 0)
return 1;
@@ -201,2 +204,11 @@ val_bool(char const *val)
+static u_long
+var_num(char const *val, u_long dfl)
+{
+ if (!val)
+ return dfl;
+ return strtoul(val, NULL, 10);
+}
+
+
static void
@@ -212,5 +224,5 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Master_Port, name)) {
- ent->replMasterPort = strtoul(value, NULL, 10);
+ ent->replMasterPort = var_num(value, 65536);
} else if (STREQ(Connect_Retry, name)) {
- ent->replConnectRetry = strtoul(value, NULL, 10);
+ ent->replConnectRetry = var_num(value, 0);
} else if (STREQ(Master_Log_File, name)) {
@@ -218,3 +230,3 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Read_Master_Log_Pos, name)) {
- ent->replReadMasterLogPos = strtoul(value, NULL, 10);
+ ent->replReadMasterLogPos = var_num(value, 0);
} else if (STREQ(Relay_Log_File, name)) {
@@ -222,3 +234,3 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Relay_Log_Pos, name)) {
- ent->replRelayLogPos = strtoul(value, NULL, 10);
+ ent->replRelayLogPos = var_num(value, 0);
} else if (STREQ(Relay_Master_Log_File, name)) {
@@ -242,3 +254,3 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Last_IO_Errno, name)) {
- ent->replLastIOErrno = strtoul(value, NULL, 10);
+ ent->replLastIOErrno = var_num(value, EINVAL);
} else if (STREQ(Last_IO_Error, name)) {
@@ -246,3 +258,3 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Last_SQL_Errno, name)) {
- ent->replLastSQLErrno = strtoul(value, NULL, 10);
+ ent->replLastSQLErrno = var_num(value, 0);
} else if (STREQ(Last_SQL_Error, name)) {
@@ -250,7 +262,7 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Skip_Counter, name)) {
- ent->replSkipCounter = strtoul(value, NULL, 10);
+ ent->replSkipCounter = var_num(value, 0);
} else if (STREQ(Exec_Master_Log_Pos, name)) {
- ent->replExecMasterLogPos = strtoul(value, NULL, 10);
+ ent->replExecMasterLogPos = var_num(value, 0);
} else if (STREQ(Relay_Log_Space, name)) {
- ent->replRelayLogSpace = strtoul(value, NULL, 10);
+ ent->replRelayLogSpace = var_num(value, 0);
} else if (STREQ(Until_Condition, name)) {
@@ -274,3 +286,4 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Seconds_Behind_Master, name)) {
- ent->replSecondsBehindMaster = strtoul(value, NULL, 10) * 100;
+ /* FIXME: default? */
+ ent->replSecondsBehindMaster = var_num(value, 0) * 100;
} else if (STREQ(Master_SSL_Verify_Server_Cert, name)) {
@@ -377,3 +390,3 @@ store_master_status_row(struct replMasterStatusTable_entry *ent,
} else if (STREQ(Position, name)) {
- ent->replMasterCurrentLogPos = strtoul(value, NULL, 10);
+ ent->replMasterCurrentLogPos = var_num(value, 0);
} else if (STREQ(Binlog_Do_DB, name)) {

Return to:

Send suggestions and report system problems to the System administrator.