Permalink
Browse files

Only 4.1 and later supports setting sql_mode on a per session basis

  • Loading branch information...
1 parent 7936d3a commit f9d03a63d57337db752f1b88f3d99122f7c5dc11 @xertres xertres committed Jan 20, 2013
Showing with 5 additions and 5 deletions.
  1. +5 −5 do_mysql/ext/do_mysql/do_mysql.c
@@ -341,13 +341,13 @@ void do_mysql_full_connect(VALUE self, MYSQL *db) {
// For really anscient MySQL versions we don't attempt any strictness
#ifdef HAVE_MYSQL_GET_SERVER_VERSION
- //4.x versions do not support certain session parameters
- if (mysql_get_server_version(db) < 50000) {
- do_mysql_cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_DIR_IN_CREATE,NO_UNSIGNED_SUBTRACTION'"));
- }
- else {
+ //4.0 does not support sql_mode at all, while later 4.x versions do not support certain session parameters
+ if (mysql_get_server_version(db) >= 50000) {
do_mysql_cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'"));
}
+ else if (mysql_get_server_version(db) >= 40100) {
+ do_mysql_cCommand_execute(Qnil, self, db, rb_str_new2("SET SESSION sql_mode = 'ANSI,NO_DIR_IN_CREATE,NO_UNSIGNED_SUBTRACTION'"));
+ }
#endif
rb_iv_set(self, "@connection", Data_Wrap_Struct(rb_cObject, 0, 0, db));

0 comments on commit f9d03a6

Please sign in to comment.