Skip to content

Commit a2b0c32

Browse files
liuxulifacebook-github-bot
authored andcommitted
output symbolic errno for 'SHOW SLAVE STATUS'
Summary: Instead of just showing the errno when running SHOW SLAVE STATUS command, also printing the error name so that user won't have misunderstanding Reviewed By: gunnarku Differential Revision: D4445585 fbshipit-source-id: 36baa9e
1 parent 922933b commit a2b0c32

File tree

6 files changed

+101
-2
lines changed

6 files changed

+101
-2
lines changed

include/my_sys.h

+1
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ extern void my_osmaperr(unsigned long last_error);
652652
#endif
653653

654654
extern void init_glob_errs(void);
655+
extern void init_glob_err_names(void);
655656
extern const char** get_global_errmsgs();
656657
extern void wait_for_free_space(const char *filename, int errors);
657658
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);

include/mysys_err.h

+2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ extern "C" {
2222

2323
#define GLOBERRS (EE_ERROR_LAST - EE_ERROR_FIRST + 1) /* Nr of global errors */
2424
#define EE(X) (globerrs[(X) - EE_ERROR_FIRST])
25+
#define EE_NAME(X) (globerrnames[(X) - EE_ERROR_FIRST])
2526

2627
extern const char *globerrs[]; /* my_error_messages is here */
28+
extern const char *globerrnames[]; /* symbolic_errno is here */
2729

2830
/* Error message numbers in global map */
2931
/*

mysql-test/include/check-testcase.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ if ($tmp)
4343
--echo Replicate_Wild_Do_Table #
4444
--echo Replicate_Wild_Ignore_Table #
4545
--echo Last_Errno 0
46+
--echo Last_Symbolic_Errno
4647
--echo Last_Error
4748
--echo Skip_Counter 0
4849
--echo Exec_Master_Log_Pos #
@@ -85,11 +86,10 @@ if ($tmp)
8586
}
8687
if (!$tmp) {
8788
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
88-
--replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 41 # 42 # 43 # 47 # 53 # 54 # 56 # 57 # 58 #
89+
--replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 23 # 24 # 25 # 26 # 27 # 42 # 43 # 44 # 48 # 54 # 55 # 57 # 58 # 59 #
8990
query_vertical
9091
SHOW SLAVE STATUS;
9192
}
9293

9394
call mtr.check_testcase();
9495
--enable_query_log
95-

mysys/errors.c

+79
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,54 @@ const char *globerrs[GLOBERRS]=
5656
"Memory capacity exceeded (capacity %llu bytes)"
5757
};
5858

59+
const char *globerrnames[GLOBERRS]=
60+
{
61+
"EE_CANTCREATEFILE",
62+
"EE_READ",
63+
"EE_WRITE",
64+
"EE_BADCLOSE",
65+
"EE_OUTOFMEMORY",
66+
"EE_DELETE",
67+
"EE_LINK",
68+
"",
69+
"EE_EOFERR",
70+
"EE_CANTLOCK",
71+
"EE_CANTUNLOCK",
72+
"EE_DIR",
73+
"EE_STAT",
74+
"EE_CANT_CHSIZE",
75+
"EE_CANT_OPEN_STREAM",
76+
"EE_GETWD",
77+
"EE_SETWD",
78+
"EE_LINK_WARNING",
79+
"EE_OPEN_WARNING",
80+
"EE_DISK_FULL",
81+
"EE_CANT_MKDIR",
82+
"EE_UNKNOWN_CHARSET",
83+
"EE_OUT_OF_FILERESOURCES",
84+
"EE_CANT_READLINK",
85+
"EE_CANT_SYMLINK",
86+
"EE_REALPATH",
87+
"EE_SYNC",
88+
"EE_UNKNOWN_COLLATION",
89+
"EE_FILENOTFOUND",
90+
"EE_FILE_NOT_CLOSED",
91+
"EE_CHANGE_OWNERSHIP",
92+
"EE_CHANGE_PERMISSIONS",
93+
"EE_CANT_SEEK",
94+
"EE_CAPACITY_EXCEEDED"
95+
};
96+
5997
void init_glob_errs(void)
6098
{
6199
/* This is now done statically. */
62100
}
63101

102+
void init_glob_err_names(void)
103+
{
104+
/* This is now done statically. */
105+
}
106+
64107
#else
65108

66109
void init_glob_errs()
@@ -98,6 +141,42 @@ void init_glob_errs()
98141
EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d - %s)";
99142
EE(EE_CANT_SEEK) = "Can't seek in file '%s' (Errcode: %d - %s)";
100143
}
144+
145+
void init_glob_err_names()
146+
{
147+
EE_NAME(EE_CANTCREATEFILE) = "EE_CANTCREATEFILE";
148+
EE_NAME(EE_READ) = "EE_READ";
149+
EE_NAME(EE_WRITE) = "EE_WRITE";
150+
EE_NAME(EE_BADCLOSE) = "EE_BADCLOSE";
151+
EE_NAME(EE_OUTOFMEMORY) = "EE_OUTOFMEMORY";
152+
EE_NAME(EE_DELETE) = "EE_DELETE";
153+
EE_NAME(EE_LINK) = "EE_LINK";
154+
EE_NAME(EE_EOFERR) = "EE_EOFERR";
155+
EE_NAME(EE_CANTLOCK) = "EE_CANTLOCK";
156+
EE_NAME(EE_CANTUNLOCK) = "EE_CANTUNLOCK";
157+
EE_NAME(EE_DIR) = "EE_DIR";
158+
EE_NAME(EE_STAT) = "EE_STAT";
159+
EE_NAME(EE_CANT_CHSIZE) = "EE_CANT_CHSIZE";
160+
EE_NAME(EE_CANT_OPEN_STREAM)= "EE_CANT_OPEN_STREAM";
161+
EE_NAME(EE_GETWD) = "EE_GETWD";
162+
EE_NAME(EE_SETWD) = "EE_SETWD";
163+
EE_NAME(EE_LINK_WARNING) = "EE_LINK_WARNING";
164+
EE_NAME(EE_OPEN_WARNING) = "EE_OPEN_WARNING";
165+
EE_NAME(EE_DISK_FULL) = "EE_DISK_FULL";
166+
EE_NAME(EE_CANT_MKDIR) ="EE_CANT_MKDIR";
167+
EE_NAME(EE_UNKNOWN_CHARSET)= "EE_UNKNOWN_CHARSET";
168+
EE_NAME(EE_OUT_OF_FILERESOURCES)="EE_OUT_OF_FILERESOURCES";
169+
EE_NAME(EE_CANT_READLINK)= "EE_CANT_READLINK";
170+
EE_NAME(EE_CANT_SYMLINK)= "EE_CANT_SYMLINK";
171+
EE_NAME(EE_REALPATH)= "EE_REALPATH";
172+
EE_NAME(EE_SYNC)= "EE_SYNC";
173+
EE_NAME(EE_UNKNOWN_COLLATION)= "EE_UNKNOWN_COLLATION";
174+
EE_NAME(EE_FILENOTFOUND) = "EE_FILENOTFOUND";
175+
EE_NAME(EE_FILE_NOT_CLOSED) = "EE_FILE_NOT_CLOSED";
176+
EE_NAME(EE_CHANGE_OWNERSHIP) = "EE_CHANGE_OWNERSHIP";
177+
EE_NAME(EE_CHANGE_PERMISSIONS) = "EE_CHANGE_PERMISSIONS";
178+
EE_NAME(EE_CANT_SEEK) = "EE_CANT_SEEK";
179+
}
101180
#endif
102181

103182
/*

mysys/my_init.c

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ my_bool my_init(void)
8282
my_umask_dir= (int) (atoi_octal(str) | 0700);
8383

8484
init_glob_errs();
85+
init_glob_err_names();
8586

8687
instrumented_stdin.m_file= stdin;
8788
instrumented_stdin.m_psi= NULL; /* not yet instrumented */

sql/rpl_slave.cc

+16
Original file line numberDiff line numberDiff line change
@@ -2975,6 +2975,7 @@ bool show_slave_status(THD* thd, Master_info* mi)
29752975
field_list.push_back(new Item_empty_string("Replicate_Wild_Ignore_Table",
29762976
28));
29772977
field_list.push_back(new Item_return_int("Last_Errno", 4, MYSQL_TYPE_LONG));
2978+
field_list.push_back(new Item_empty_string("Last_Symbolic_Errno", 20));
29782979
field_list.push_back(new Item_empty_string("Last_Error", 20));
29792980
field_list.push_back(new Item_return_int("Skip_Counter", 10,
29802981
MYSQL_TYPE_LONG));
@@ -3107,6 +3108,21 @@ bool show_slave_status(THD* thd, Master_info* mi)
31073108
protocol->store(&tmp);
31083109

31093110
protocol->store(mi->rli->last_error().number);
3111+
3112+
if (mi->rli->last_error().number == 0)
3113+
{
3114+
protocol->store("", &my_charset_bin);
3115+
}
3116+
else if (mi->rli->last_error().number >= EE_ERROR_FIRST &&
3117+
mi->rli->last_error().number <= EE_ERROR_LAST)
3118+
{
3119+
protocol->store(EE_NAME(mi->rli->last_error().number), &my_charset_bin);
3120+
}
3121+
else
3122+
{
3123+
protocol->store("regular sql errno", &my_charset_bin);
3124+
}
3125+
31103126
protocol->store(mi->rli->last_error().message, &my_charset_bin);
31113127
protocol->store((uint32) mi->rli->slave_skip_counter);
31123128
protocol->store((ulonglong) mi->rli->get_group_master_log_pos());

0 commit comments

Comments
 (0)