Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce1652d

Browse files
committed
bugfix:修复命令行不支持中文的问题 (issue Meituan-Dianping#10)
1 parent f547d11 commit ce1652d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sqladvisor/main.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <algorithm>
44
#include <limits>
5+
#include <locale.h>
56
#include "sql/mysqld.h"
67
#include "sql/sql_class.h"
78
#include "sql/sql_lex.h"
@@ -1339,14 +1340,21 @@ int main(int argc, char **argv) {
13391340
char *query = NULL;
13401341
char *sqlparse_path = strdup("/usr/local/sqlparser");
13411342
int i = 0;
1342-
1343+
char *lc = NULL;
13431344
if (mysqld_init(sqlparse_path)) {
13441345
sql_print_error("加载sqlparser模块有错 \n");
13451346
if(sqlparse_path) free(sqlparse_path);
13461347
return -1;
13471348
}
13481349
if(sqlparse_path) free(sqlparse_path);
13491350

1351+
lc = setlocale(LC_ALL, "");
1352+
if (NULL == lc) {
1353+
sql_print_error("setlocale 有错 \n");
1354+
if(sqlparse_path) free(sqlparse_path);
1355+
return -1;
1356+
}
1357+
13501358
ConnectionOptionsInit(&options);
13511359
context = g_option_context_new("sqladvisor");
13521360
g_option_context_add_main_entries(context, entries, NULL);

0 commit comments

Comments
 (0)