mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-13 12:07:03 +02:00
switch from utf8 to utf8mb4 on the database level
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
@ -88,6 +88,7 @@ struct _parse_rule config_parse_rules[] =
|
||||
{ "min_message_size", "integer", (void*) int_parser, offsetof(struct __config, min_message_size), "100", sizeof(int)},
|
||||
{ "min_word_len", "integer", (void*) int_parser, offsetof(struct __config, min_word_len), "1", sizeof(int)},
|
||||
{ "mmap_dedup_test", "integer", (void*) int_parser, offsetof(struct __config, mmap_dedup_test), "0", sizeof(int)},
|
||||
{ "mysqlcharset", "string", (void*) string_parser, offsetof(struct __config, mysqlcharset), "utf8mb4", MAXVAL-1},
|
||||
{ "mysqlhost", "string", (void*) string_parser, offsetof(struct __config, mysqlhost), "", MAXVAL-1},
|
||||
{ "mysqlport", "integer", (void*) int_parser, offsetof(struct __config, mysqlport), "", sizeof(int)},
|
||||
{ "mysqlsocket", "string", (void*) string_parser, offsetof(struct __config, mysqlsocket), "/tmp/mysql.sock", MAXVAL-1},
|
||||
|
@ -65,6 +65,7 @@ struct __config {
|
||||
|
||||
// mysql stuff
|
||||
|
||||
char mysqlcharset[MAXVAL];
|
||||
char mysqlhost[MAXVAL];
|
||||
int mysqlport;
|
||||
char mysqlsocket[MAXVAL];
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
int open_database(struct session_data *sdata, struct __config *cfg){
|
||||
int rc=1;
|
||||
char buf[BUFLEN];
|
||||
|
||||
mysql_init(&(sdata->mysql));
|
||||
|
||||
@ -22,8 +23,11 @@ int open_database(struct session_data *sdata, struct __config *cfg){
|
||||
return ERR;
|
||||
}
|
||||
|
||||
mysql_real_query(&(sdata->mysql), "SET NAMES utf8", strlen("SET NAMES utf8"));
|
||||
mysql_real_query(&(sdata->mysql), "SET CHARACTER SET utf8", strlen("SET CHARACTER SET utf8"));
|
||||
snprintf(buf, sizeof(buf)-2, "SET NAMES %s", cfg->mysqlcharset);
|
||||
mysql_real_query(&(sdata->mysql), buf, strlen(buf));
|
||||
|
||||
snprintf(buf, sizeof(buf)-2, "SET CHARACTER SET %s", cfg->mysqlcharset);
|
||||
mysql_real_query(&(sdata->mysql), buf, strlen(buf));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user