# HG changeset patch # User Adam Chlipala # Date 1389745373 18000 # Node ID ef9fdbb05c737039b4f76fcc82781c3294c4210a # Parent ac1be85e91ada45cc40f65a86b9ea5bb1722ef48 MySQL: set character set when opening a new connection diff -r ac1be85e91ad -r ef9fdbb05c73 src/mysql.sml --- a/src/mysql.sml Thu Jan 09 17:27:24 2014 -0500 +++ b/src/mysql.sml Tue Jan 14 19:22:53 2014 -0500 @@ -551,6 +551,23 @@ newline, string "}", newline, + newline, + string "if (mysql_set_character_set(mysql, \"utf8\")) {", + newline, + box [string "char msg[1024];", + newline, + string "strncpy(msg, mysql_error(mysql), 1024);", + newline, + string "msg[1023] = 0;", + newline, + string "mysql_close(mysql);", + newline, + string "uw_error(ctx, FATAL, ", + string "\"Error setting UTF-8 character set for MySQL connection: %s\", msg);"], + newline, + string "}", + newline, + newline, string "conn = calloc(1, sizeof(uw_conn));", newline, string "conn->conn = mysql;",