List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:November 29 2010 4:31pm
Subject:bzr push into mysql-trunk-bugfixing branch (jon.hauglid:3392 to 3393)
Bug#57035
View as plain text  
 3393 Jon Olav Hauglid	2010-11-29
      Bug #57035 'ulonglong sql_mode' stored into ulong, is risky
                 and causes compiler warning
      
      In 5.5 THD::variables::sql_mode was changed from ulong to
      ulonglong. The problem was that several variables used to
      store sql_mode were still declared as ulong. This patch
      updates these declarations to sql_mode_t which is typedef'ed
      to ulonglong.
      
      The patch also adds a test case designed to break once
      someone adds a new SQL mode. This is done to serve as an
      indication that current tests which use
      "SET @@sql_mode= cast(pow(2,32)-1" to activate all SQL modes
      will then have to be updated.

    modified:
      mysql-test/r/variables.result
      mysql-test/t/variables.test
      sql/event_data_objects.cc
      sql/event_data_objects.h
      sql/event_db_repository.cc
      sql/ha_partition.cc
      sql/item.cc
      sql/item_cmpfunc.cc
      sql/item_timefunc.h
      sql/log_event.cc
      sql/log_event.h
      sql/opt_range.cc
      sql/partition_info.cc
      sql/set_var.h
      sql/sp.cc
      sql/sp.h
      sql/sp_head.cc
      sql/sp_head.h
      sql/sql_acl.cc
      sql/sql_cache.cc
      sql/sql_cache.h
      sql/sql_class.h
      sql/sql_insert.cc
      sql/sql_select.h
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_trigger.cc
      sql/sql_trigger.h
      sql/sql_view.cc
      sql/sys_vars.cc
 3392 Georgi Kodinov	2010-11-29 [merge]
      merge

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2010-11-25 04:41:58 +0000
+++ b/mysql-test/r/variables.result	2010-11-29 16:27:58 +0000
@@ -1722,3 +1722,9 @@ set @@session.autocommit=t1_min(), @@ses
 drop table t1;
 drop function t1_min;
 drop function t1_max;
+#
+# Bug#57035 'ulonglong sql_mode' stored into ulong, is risky and causes
+#           compiler warning
+#
+SET @@sql_mode= 4294967296;
+ERROR 42000: Variable 'sql_mode' can't be set to the value of '4294967296'

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2010-11-25 04:41:58 +0000
+++ b/mysql-test/t/variables.test	2010-11-29 16:27:58 +0000
@@ -1464,3 +1464,23 @@ drop function t1_max;
 
 
 ###########################################################################
+
+
+--echo #
+--echo # Bug#57035 'ulonglong sql_mode' stored into ulong, is risky and causes
+--echo #           compiler warning
+--echo #
+
+# Several tests currently use "@@sql_mode= cast(pow(2,32)-1"
+# to activate all SQL modes. This will stop working once
+# someone adds a new flag. The test below is designed to break
+# once this happens to indicate that other tests will have to
+# be updated.
+#
+# The test does this by trying to set sql_mode to the next 
+# currently unused flag value and check that this currently fails.
+# Once a new flag is added, this value will become valid and
+# the statement below will succeed.
+
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@sql_mode= 4294967296;

=== modified file 'sql/event_data_objects.cc'
--- a/sql/event_data_objects.cc	2010-11-18 16:34:56 +0000
+++ b/sql/event_data_objects.cc	2010-11-29 16:27:58 +0000
@@ -430,7 +430,7 @@ Event_job_data::load_from_row(THD *thd,
   definer_host.str= strmake_root(&mem_root, ptr + 1, len);
   definer_host.length= len;
 
-  sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int();
+  sql_mode= (sql_mode_t) table->field[ET_FIELD_SQL_MODE]->val_int();
 
   DBUG_RETURN(FALSE);
 }
@@ -636,7 +636,7 @@ Event_timed::load_from_row(THD *thd, TAB
   else
     comment.length= 0;
 
-  sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int();
+  sql_mode= (sql_mode_t) table->field[ET_FIELD_SQL_MODE]->val_int();
 
   DBUG_RETURN(FALSE);
 }

=== modified file 'sql/event_data_objects.h'
--- a/sql/event_data_objects.h	2010-11-18 16:34:56 +0000
+++ b/sql/event_data_objects.h	2010-11-29 16:27:58 +0000
@@ -132,7 +132,7 @@ public:
   ulonglong created;
   ulonglong modified;
 
-  ulong sql_mode;
+  sql_mode_t sql_mode;
 
   class Stored_program_creation_ctx *creation_ctx;
   LEX_STRING body_utf8;
@@ -158,7 +158,7 @@ public:
   LEX_STRING definer_user;
   LEX_STRING definer_host;
 
-  ulong sql_mode;
+  sql_mode_t sql_mode;
 
   class Stored_program_creation_ctx *creation_ctx;
 

=== modified file 'sql/event_db_repository.cc'
--- a/sql/event_db_repository.cc	2010-11-18 16:34:56 +0000
+++ b/sql/event_db_repository.cc	2010-11-29 16:27:58 +0000
@@ -199,7 +199,7 @@ mysql_event_fill_row(THD *thd,
                      TABLE *table,
                      Event_parse_data *et,
                      sp_head *sp,
-                     ulong sql_mode,
+                     sql_mode_t sql_mode,
                      my_bool is_update)
 {
   CHARSET_INFO *scs= system_charset_info;
@@ -622,7 +622,7 @@ Event_db_repository::create_event(THD *t
   int ret= 1;
   TABLE *table= NULL;
   sp_head *sp= thd->lex->sphead;
-  ulong saved_mode= thd->variables.sql_mode;
+  sql_mode_t saved_mode= thd->variables.sql_mode;
   /*
     Take a savepoint to release only the lock on mysql.event
     table at the end but keep the global read lock and
@@ -740,7 +740,7 @@ Event_db_repository::update_event(THD *t
   CHARSET_INFO *scs= system_charset_info;
   TABLE *table= NULL;
   sp_head *sp= thd->lex->sphead;
-  ulong saved_mode= thd->variables.sql_mode;
+  sql_mode_t saved_mode= thd->variables.sql_mode;
   /*
     Take a savepoint to release only the lock on mysql.event
     table at the end but keep the global read lock and
@@ -1015,7 +1015,7 @@ Event_db_repository::load_named_event(TH
                                       LEX_STRING name, Event_basic *etn)
 {
   bool ret;
-  ulong saved_mode= thd->variables.sql_mode;
+  sql_mode_t saved_mode= thd->variables.sql_mode;
   Open_tables_backup open_tables_backup;
   TABLE_LIST event_table;
 

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-11-26 15:20:05 +0000
+++ b/sql/ha_partition.cc	2010-11-29 16:27:58 +0000
@@ -3095,7 +3095,7 @@ int ha_partition::write_row(uchar * buf)
   my_bitmap_map *old_map;
   THD *thd= ha_thd();
   timestamp_auto_set_type saved_timestamp_type= table->timestamp_field_type;
-  ulong saved_sql_mode= thd->variables.sql_mode;
+  sql_mode_t saved_sql_mode= thd->variables.sql_mode;
   bool saved_auto_inc_field_not_null= table->auto_increment_field_not_null;
 #ifdef NOT_NEEDED
   uchar *rec0= m_rec0;

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-11-19 15:49:46 +0000
+++ b/sql/item.cc	2010-11-29 16:27:58 +0000
@@ -1068,7 +1068,7 @@ int Item::save_in_field_no_warnings(Fiel
   THD *thd= table->in_use;
   enum_check_fields tmp= thd->count_cuted_fields;
   my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
-  ulonglong sql_mode= thd->variables.sql_mode;
+  sql_mode_t sql_mode= thd->variables.sql_mode;
   thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;
   res= save_in_field(field, no_conversions);

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2010-11-05 16:23:32 +0000
+++ b/sql/item_cmpfunc.cc	2010-11-29 16:27:58 +0000
@@ -406,7 +406,7 @@ static bool convert_constant_item(THD *t
   if (!(*item)->with_subselect && (*item)->const_item())
   {
     TABLE *table= field->table;
-    ulonglong orig_sql_mode= thd->variables.sql_mode;
+    sql_mode_t orig_sql_mode= thd->variables.sql_mode;
     enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
     my_bitmap_map *old_maps[2];
     ulonglong UNINIT_VAR(orig_field_val); /* original field value if valid */

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2010-10-31 23:37:14 +0000
+++ b/sql/item_timefunc.h	2010-11-29 16:27:58 +0000
@@ -1041,7 +1041,7 @@ class Item_func_str_to_date :public Item
   date_time_format_types cached_format_type;
   timestamp_type cached_timestamp_type;
   bool const_item;
-  ulonglong sql_mode;
+  sql_mode_t sql_mode;
 public:
   Item_func_str_to_date(Item *a, Item *b)
     :Item_str_func(a, b), const_item(false)

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-11-29 11:28:55 +0000
+++ b/sql/log_event.cc	2010-11-29 16:27:58 +0000
@@ -2498,7 +2498,7 @@ bool Query_log_event::write(IO_CACHE* fi
   if (sql_mode_inited)
   {
     *start++= Q_SQL_MODE_CODE;
-    int8store(start, (ulonglong)sql_mode);
+    int8store(start, sql_mode);
     start+= 8;
   }
   if (catalog_len) // i.e. this var is inited (false for 4.0 events)
@@ -2827,7 +2827,7 @@ Query_log_event::Query_log_event(THD* th
   else
     cache_type= Log_event::EVENT_STMT_CACHE;
   DBUG_ASSERT(cache_type != Log_event::EVENT_INVALID_CACHE);
-  DBUG_PRINT("info",("Query_log_event has flags2: %lu  sql_mode: %lu",
+  DBUG_PRINT("info",("Query_log_event has flags2: %lu  sql_mode: %llu",
                      (ulong) flags2, sql_mode));
 }
 #endif /* MYSQL_CLIENT */
@@ -3042,7 +3042,7 @@ Query_log_event::Query_log_event(const c
 #endif
       CHECK_SPACE(pos, end, 8);
       sql_mode_inited= 1;
-      sql_mode= (ulong) uint8korr(pos); // QQ: Fix when sql_mode is ulonglong
+      sql_mode= uint8korr(pos);
       DBUG_PRINT("info",("In Query_log_event, read sql_mode: %s",
 			 llstr(sql_mode, buff)));
       pos+= 8;
@@ -3515,8 +3515,8 @@ int Query_log_event::do_apply_event(Rela
       */
       if (sql_mode_inited)
         thd->variables.sql_mode=
-          (ulong) ((thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) |
-                   (sql_mode & ~(ulong) MODE_NO_DIR_IN_CREATE));
+          (sql_mode_t) ((thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) |
+                       (sql_mode & ~(ulonglong) MODE_NO_DIR_IN_CREATE));
       if (charset_inited)
       {
         if (rli->cached_charset_compare(charset))

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-11-16 12:14:06 +0000
+++ b/sql/log_event.h	2010-11-29 16:27:58 +0000
@@ -51,6 +51,7 @@
 
 /* Forward declarations */
 class String;
+typedef ulonglong sql_mode_t;
 
 #define PREFIX_SQL_LOAD "SQL_LOAD-"
 
@@ -695,7 +696,7 @@ typedef struct st_print_event_info
   bool flags2_inited;
   uint32 flags2;
   bool sql_mode_inited;
-  ulong sql_mode;		/* must be same as THD.variables.sql_mode */
+  sql_mode_t sql_mode;		/* must be same as THD.variables.sql_mode */
   ulong auto_increment_increment, auto_increment_offset;
   bool charset_inited;
   char charset[6]; // 3 variables, each of them storable in 2 bytes
@@ -1740,7 +1741,7 @@ public:
 
   uint32 flags2;
   /* In connections sql_mode is 32 bits now but will be 64 bits soon */
-  ulong sql_mode;
+  sql_mode_t sql_mode;
   ulong auto_increment_increment, auto_increment_offset;
   char charset[6];
   uint time_zone_len; /* 0 means uninited */

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-11-26 13:46:21 +0000
+++ b/sql/opt_range.cc	2010-11-29 16:27:58 +0000
@@ -5721,7 +5721,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, Item
   SEL_ARG *tree= 0;
   MEM_ROOT *alloc= param->mem_root;
   uchar *str;
-  ulonglong orig_sql_mode;
+  sql_mode_t orig_sql_mode;
   int err;
   DBUG_ENTER("get_mm_leaf");
 

=== modified file 'sql/partition_info.cc'
--- a/sql/partition_info.cc	2010-10-01 16:11:50 +0000
+++ b/sql/partition_info.cc	2010-11-29 16:27:58 +0000
@@ -2156,7 +2156,7 @@ bool partition_info::fix_column_value_fu
       {
         uchar *val_ptr;
         uint len= field->pack_length();
-        ulong save_sql_mode;
+        sql_mode_t save_sql_mode;
         bool save_got_warning;
 
         if (!(column_item= get_column_item(column_item,

=== modified file 'sql/set_var.h'
--- a/sql/set_var.h	2010-11-29 11:28:55 +0000
+++ b/sql/set_var.h	2010-11-29 16:27:58 +0000
@@ -309,8 +309,8 @@ int sql_set_variables(THD *thd, List<set
 
 bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type);
 
-ulong expand_sql_mode(ulonglong sql_mode);
-bool sql_mode_string_representation(THD *thd, ulong sql_mode, LEX_STRING *ls);
+ulong expand_sql_mode(sql_mode_t sql_mode);
+bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls);
 
 extern sys_var *Sys_autocommit_ptr;
 

=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2010-11-18 16:34:56 +0000
+++ b/sql/sp.cc	2010-11-29 16:27:58 +0000
@@ -42,11 +42,11 @@ create_string(THD *thd, String *buf,
 	      st_sp_chistics *chistics,
               const LEX_STRING *definer_user,
               const LEX_STRING *definer_host,
-              ulong sql_mode);
+              sql_mode_t sql_mode);
 
 static int
 db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
-                ulong sql_mode, const char *params, const char *returns,
+                sql_mode_t sql_mode, const char *params, const char *returns,
                 const char *body, st_sp_chistics &chistics,
                 const char *definer, longlong created, longlong modified,
                 Stored_program_creation_ctx *creation_ctx);
@@ -539,7 +539,7 @@ db_find_routine(THD *thd, int type, sp_n
   char buff[65];
   String str(buff, sizeof(buff), &my_charset_bin);
   bool saved_time_zone_used= thd->time_zone_used;
-  ulong sql_mode, saved_mode= thd->variables.sql_mode;
+  sql_mode_t sql_mode, saved_mode= thd->variables.sql_mode;
   Open_tables_backup open_tables_state_backup;
   Stored_program_creation_ctx *creation_ctx;
 
@@ -636,7 +636,7 @@ db_find_routine(THD *thd, int type, sp_n
   modified= table->field[MYSQL_PROC_FIELD_MODIFIED]->val_int();
   created= table->field[MYSQL_PROC_FIELD_CREATED]->val_int();
 
-  sql_mode= (ulong) table->field[MYSQL_PROC_FIELD_SQL_MODE]->val_int();
+  sql_mode= (sql_mode_t) table->field[MYSQL_PROC_FIELD_SQL_MODE]->val_int();
 
   table->field[MYSQL_PROC_FIELD_COMMENT]->val_str(&str, &str);
 
@@ -713,11 +713,11 @@ Silence_deprecated_warning::handle_condi
     @retval   0                     error
 */
 
-static sp_head *sp_compile(THD *thd, String *defstr, ulong sql_mode,
+static sp_head *sp_compile(THD *thd, String *defstr, sql_mode_t sql_mode,
                            Stored_program_creation_ctx *creation_ctx)
 {
   sp_head *sp;
-  ulong old_sql_mode= thd->variables.sql_mode;
+  sql_mode_t old_sql_mode= thd->variables.sql_mode;
   ha_rows old_select_limit= thd->variables.select_limit;
   sp_rcontext *old_spcont= thd->spcont;
   Silence_deprecated_warning warning_handler;
@@ -758,7 +758,7 @@ static sp_head *sp_compile(THD *thd, Str
 
 static int
 db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
-                ulong sql_mode, const char *params, const char *returns,
+                sql_mode_t sql_mode, const char *params, const char *returns,
                 const char *body, st_sp_chistics &chistics,
                 const char *definer, longlong created, longlong modified,
                 Stored_program_creation_ctx *creation_ctx)
@@ -924,7 +924,7 @@ sp_create_routine(THD *thd, int type, sp
   int ret;
   TABLE *table;
   char definer[USER_HOST_BUFF_SIZE];
-  ulong saved_mode= thd->variables.sql_mode;
+  sql_mode_t saved_mode= thd->variables.sql_mode;
   MDL_key::enum_mdl_namespace mdl_type= type == TYPE_ENUM_FUNCTION ?
                                         MDL_key::FUNCTION : MDL_key::PROCEDURE;
 
@@ -2093,9 +2093,9 @@ create_string(THD *thd, String *buf,
               st_sp_chistics *chistics,
               const LEX_STRING *definer_user,
               const LEX_STRING *definer_host,
-              ulong sql_mode)
+              sql_mode_t sql_mode)
 {
-  ulong old_sql_mode= thd->variables.sql_mode;
+  sql_mode_t old_sql_mode= thd->variables.sql_mode;
   /* Make some room to begin with */
   if (buf->alloc(100 + dblen + 1 + namelen + paramslen + returnslen + bodylen +
 		 chistics->comment.length + 10 /* length of " DEFINER= "*/ +
@@ -2177,7 +2177,7 @@ create_string(THD *thd, String *buf,
 
 sp_head *
 sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
-                               String *name, ulong sql_mode, int type,
+                               String *name, sql_mode_t sql_mode, int type,
                                const char *returns, const char *params,
                                bool *free_sp_head)
 {

=== modified file 'sql/sp.h'
--- a/sql/sp.h	2010-11-18 16:34:56 +0000
+++ b/sql/sp.h	2010-11-29 16:27:58 +0000
@@ -188,7 +188,7 @@ TABLE *open_proc_table_for_read(THD *thd
 
 sp_head *
 sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
-                               String *name, ulong sql_mode, int type,
+                               String *name, sql_mode_t sql_mode, int type,
                                const char *returns, const char *params,
                                bool *free_sp_head);
 

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2010-11-29 11:28:55 +0000
+++ b/sql/sp_head.cc	2010-11-29 16:27:58 +0000
@@ -1204,7 +1204,7 @@ sp_head::execute(THD *thd, bool merge_da
   sp_rcontext *ctx= thd->spcont;
   bool err_status= FALSE;
   uint ip= 0;
-  ulong save_sql_mode;
+  sql_mode_t save_sql_mode;
   bool save_abort_on_warning;
   Query_arena *old_arena;
   /* per-instruction arena */
@@ -2479,7 +2479,7 @@ sp_head::do_cont_backpatch()
 
 void
 sp_head::set_info(longlong created, longlong modified,
-                  st_sp_chistics *chistics, ulong sql_mode)
+                  st_sp_chistics *chistics, sql_mode_t sql_mode)
 {
   m_created= created;
   m_modified= modified;

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2010-11-16 12:14:06 +0000
+++ b/sql/sp_head.h	2010-11-29 16:27:58 +0000
@@ -172,7 +172,7 @@ public:
 
   const char *m_tmp_query;	///< Temporary pointer to sub query string
   st_sp_chistics *m_chistics;
-  ulong m_sql_mode;		///< For SHOW CREATE and execution
+  sql_mode_t m_sql_mode;        ///< For SHOW CREATE and execution
   LEX_STRING m_qname;		///< db.name
   bool m_explicit_name;         ///< Prepend the db name? */
   LEX_STRING m_db;
@@ -394,7 +394,7 @@ public:
                              Create_field *field_def);
 
   void set_info(longlong created, longlong modified,
-		st_sp_chistics *chistics, ulong sql_mode);
+		st_sp_chistics *chistics, sql_mode_t sql_mode);
 
   void set_definer(const char *definer, uint definerlen);
   void set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name);

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2010-11-26 15:45:26 +0000
+++ b/sql/sql_acl.cc	2010-11-29 16:27:58 +0000
@@ -703,7 +703,7 @@ static my_bool acl_load(THD *thd, TABLE_
   bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
   char tmp_name[NAME_LEN+1];
   int password_length;
-  ulong old_sql_mode= thd->variables.sql_mode;
+  sql_mode_t old_sql_mode= thd->variables.sql_mode;
   DBUG_ENTER("acl_load");
 
   thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
@@ -4290,7 +4290,7 @@ static my_bool grant_load(THD *thd, TABL
   bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
   MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,
                                                            THR_MALLOC);
-  ulong old_sql_mode= thd->variables.sql_mode;
+  sql_mode_t old_sql_mode= thd->variables.sql_mode;
   DBUG_ENTER("grant_load");
 
   thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
@@ -6497,7 +6497,7 @@ bool mysql_drop_user(THD *thd, List <LEX
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   bool some_users_deleted= FALSE;
-  ulong old_sql_mode= thd->variables.sql_mode;
+  sql_mode_t old_sql_mode= thd->variables.sql_mode;
   bool save_binlog_row_based;
   DBUG_ENTER("mysql_drop_user");
 

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2010-10-12 10:15:42 +0000
+++ b/sql/sql_cache.cc	2010-11-29 16:27:58 +0000
@@ -1222,7 +1222,7 @@ void Query_cache::store_query(THD *thd,
     DBUG_PRINT("qcache", ("\
 long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
 CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
-sql mode: 0x%lx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
+sql mode: 0x%llx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
 def_week_frmt: %lu, in_trans: %d, autocommit: %d",
                           (int)flags.client_long_flag,
                           (int)flags.client_protocol_41,
@@ -1564,7 +1564,7 @@ Query_cache::send_result_to_client(THD *
   DBUG_PRINT("qcache", ("\
 long %d, 4.1: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
 CS client: %u, CS result: %u, CS conn: %u, limit: %lu, TZ: 0x%lx, \
-sql mode: 0x%lx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
+sql mode: 0x%llx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
 def_week_frmt: %lu, in_trans: %d, autocommit: %d",
                           (int)flags.client_long_flag,
                           (int)flags.client_protocol_41,

=== modified file 'sql/sql_cache.h'
--- a/sql/sql_cache.h	2010-07-02 02:58:51 +0000
+++ b/sql/sql_cache.h	2010-11-29 16:27:58 +0000
@@ -25,6 +25,7 @@ class Time_zone;
 struct LEX;
 struct TABLE;
 typedef struct st_changed_table_list CHANGED_TABLE_LIST;
+typedef ulonglong sql_mode_t;
 
 /* Query cache */
 
@@ -532,7 +533,7 @@ struct Query_cache_query_flags
   uint collation_connection_num;
   ha_rows limit;
   Time_zone *time_zone;
-  ulong sql_mode;
+  sql_mode_t sql_mode;
   ulong max_sort_length;
   ulong group_concat_max_len;
   ulong default_week_format;

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-11-29 11:28:55 +0000
+++ b/sql/sql_class.h	2010-11-29 16:27:58 +0000
@@ -399,6 +399,8 @@ class Time_zone;
 
 #define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC)
 
+typedef ulonglong sql_mode_t;
+
 typedef struct system_variables
 {
   /*
@@ -420,7 +422,7 @@ typedef struct system_variables
   ulonglong long_query_time;
   /* A bitmap for switching optimizations on/off */
   ulonglong optimizer_switch;
-  ulonglong sql_mode; ///< which non-standard SQL behaviour should be enabled
+  sql_mode_t sql_mode; ///< which non-standard SQL behaviour should be enabled
   ulonglong option_bits; ///< OPTION_xxx constants, e.g. OPTION_PROFILING
   ha_rows select_limit;
   ha_rows max_join_size;

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2010-11-29 03:17:40 +0000
+++ b/sql/sql_insert.cc	2010-11-29 16:27:58 +0000
@@ -1825,7 +1825,7 @@ public:
   char *record;
   enum_duplicates dup;
   time_t start_time;
-  ulong sql_mode;
+  sql_mode_t sql_mode;
   bool auto_increment_field_not_null;
   bool query_start_used, ignore, log_query, binlog_rows_query_log_events;
   bool stmt_depends_on_first_successful_insert_id_in_prev_stmt;

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2010-11-05 22:19:41 +0000
+++ b/sql/sql_select.h	2010-11-29 16:27:58 +0000
@@ -2070,7 +2070,7 @@ public:
     enum store_key_result result;
     THD *thd= to_field->table->in_use;
     enum_check_fields saved_count_cuted_fields= thd->count_cuted_fields;
-    ulonglong sql_mode= thd->variables.sql_mode;
+    sql_mode_t sql_mode= thd->variables.sql_mode;
     thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
 
     thd->count_cuted_fields= CHECK_FIELD_IGNORE;

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-11-29 11:28:55 +0000
+++ b/sql/sql_show.cc	2010-11-29 16:27:58 +0000
@@ -4478,7 +4478,7 @@ bool store_schema_params(THD *thd, TABLE
               &returns);
 
   sp= sp_load_for_information_schema(thd, proc_table, &sp_db, &sp_name,
-                                     (ulong) proc_table->
+                                     (sql_mode_t) proc_table->
                                      field[MYSQL_PROC_FIELD_SQL_MODE]->val_int(),
                                      routine_type,
                                      returns.c_ptr_safe(),
@@ -4634,7 +4634,7 @@ bool store_schema_proc(THD *thd, TABLE *
         bool free_sp_head;
         proc_table->field[MYSQL_PROC_FIELD_RETURNS]->val_str(&returns);
         sp= sp_load_for_information_schema(thd, proc_table, &sp_db, &sp_name,
-                                           (ulong) proc_table->
+                                           (sql_mode_t) proc_table->
                                            field[MYSQL_PROC_FIELD_SQL_MODE]->
                                            val_int(),
                                            TYPE_ENUM_FUNCTION,
@@ -5095,7 +5095,7 @@ static bool store_trigger(THD *thd, TABL
                           enum trg_event_type event,
                           enum trg_action_time_type timing,
                           LEX_STRING *trigger_stmt,
-                          ulong sql_mode,
+                          sql_mode_t sql_mode,
                           LEX_STRING *definer_buffer,
                           LEX_STRING *client_cs_name,
                           LEX_STRING *connection_cl_name,
@@ -5164,7 +5164,7 @@ static int get_schema_triggers_record(TH
       {
         LEX_STRING trigger_name;
         LEX_STRING trigger_stmt;
-        ulong sql_mode;
+        sql_mode_t sql_mode;
         char definer_holder[USER_HOST_BUFF_SIZE];
         LEX_STRING definer_buffer;
         LEX_STRING client_cs_name;
@@ -7543,7 +7543,7 @@ static bool show_create_trigger_impl(THD
   List<Item> fields;
 
   LEX_STRING trg_name;
-  ulonglong trg_sql_mode;
+  sql_mode_t trg_sql_mode;
   LEX_STRING trg_sql_mode_str;
   LEX_STRING trg_sql_original_stmt;
   LEX_STRING trg_client_cs_name;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-11-29 11:28:55 +0000
+++ b/sql/sql_table.cc	2010-11-29 16:27:58 +0000
@@ -7075,7 +7075,7 @@ copy_data_between_tables(TABLE *from,TAB
   List<Item>   all_fields;
   ha_rows examined_rows;
   bool auto_increment_field_copied= 0;
-  ulong save_sql_mode;
+  sql_mode_t save_sql_mode;
   ulonglong prev_insert_id;
   DBUG_ENTER("copy_data_between_tables");
 

=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc	2010-11-18 16:34:56 +0000
+++ b/sql/sql_trigger.cc	2010-11-29 16:27:58 +0000
@@ -576,7 +576,7 @@ bool Table_triggers_list::create_trigger
   LEX_STRING *trg_def;
   LEX_STRING definer_user;
   LEX_STRING definer_host;
-  ulonglong *trg_sql_mode;
+  sql_mode_t *trg_sql_mode;
   char trg_definer_holder[USER_HOST_BUFF_SIZE];
   LEX_STRING *trg_definer;
   Item_trigger_field *trg_field;
@@ -717,7 +717,7 @@ bool Table_triggers_list::create_trigger
   if (!(trg_def= alloc_lex_string(&table->mem_root)) ||
       definitions_list.push_back(trg_def, &table->mem_root) ||
 
-      !(trg_sql_mode= alloc_type<ulonglong>(&table->mem_root)) ||
+      !(trg_sql_mode= alloc_type<sql_mode_t>(&table->mem_root)) ||
       definition_modes_list.push_back(trg_sql_mode, &table->mem_root) ||
 
       !(trg_definer= alloc_lex_string(&table->mem_root)) ||
@@ -932,7 +932,7 @@ bool Table_triggers_list::drop_trigger(T
 
   List_iterator_fast<LEX_STRING> it_name(names_list);
 
-  List_iterator<ulonglong> it_mod(definition_modes_list);
+  List_iterator<sql_mode_t> it_mod(definition_modes_list);
   List_iterator<LEX_STRING> it_def(definitions_list);
   List_iterator<LEX_STRING> it_definer(definers_list);
   List_iterator<LEX_STRING> it_client_cs_name(client_cs_names);
@@ -1138,7 +1138,7 @@ bool Table_triggers_list::check_n_load(T
 
       List_iterator_fast<LEX_STRING> it(triggers->definitions_list);
       LEX_STRING *trg_create_str;
-      ulonglong *trg_sql_mode;
+      sql_mode_t *trg_sql_mode;
 
       if (triggers->definition_modes_list.is_empty() &&
           !triggers->definitions_list.is_empty())
@@ -1149,7 +1149,7 @@ bool Table_triggers_list::check_n_load(T
           We use one mode (current) for all triggers, because we have not
           information about mode in old format.
         */
-        if (!(trg_sql_mode= alloc_type<ulonglong>(&table->mem_root)))
+        if (!(trg_sql_mode= alloc_type<sql_mode_t>(&table->mem_root)))
         {
           DBUG_RETURN(1); // EOM
         }
@@ -1286,14 +1286,14 @@ bool Table_triggers_list::check_n_load(T
       if (!names_only && triggers->prepare_record1_accessors(table))
         DBUG_RETURN(1);
 
-      List_iterator_fast<ulonglong> itm(triggers->definition_modes_list);
+      List_iterator_fast<sql_mode_t> itm(triggers->definition_modes_list);
       List_iterator_fast<LEX_STRING> it_definer(triggers->definers_list);
       List_iterator_fast<LEX_STRING> it_client_cs_name(triggers->client_cs_names);
       List_iterator_fast<LEX_STRING> it_connection_cl_name(triggers->connection_cl_names);
       List_iterator_fast<LEX_STRING> it_db_cl_name(triggers->db_cl_names);
       LEX *old_lex= thd->lex, lex;
       sp_rcontext *save_spcont= thd->spcont;
-      ulong save_sql_mode= thd->variables.sql_mode;
+      sql_mode_t save_sql_mode= thd->variables.sql_mode;
       LEX_STRING *on_table_name;
 
       thd->lex= &lex;
@@ -1307,7 +1307,7 @@ bool Table_triggers_list::check_n_load(T
         trg_sql_mode= itm++;
         LEX_STRING *trg_definer= it_definer++;
 
-        thd->variables.sql_mode= (ulong)*trg_sql_mode;
+        thd->variables.sql_mode= *trg_sql_mode;
 
         Parser_state parser_state;
         if (parser_state.init(thd, trg_create_str->str, trg_create_str->length))
@@ -1346,7 +1346,7 @@ bool Table_triggers_list::check_n_load(T
         sp= triggers->bodies[event][action_time]= lex.sphead;
         lex.sphead= NULL; /* Prevent double cleanup. */
 
-        sp->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
+        sp->set_info(0, 0, &lex.sp_chistics, *trg_sql_mode);
         sp->set_creation_ctx(creation_ctx);
 
         if (!trg_definer->length)
@@ -1499,7 +1499,7 @@ bool Table_triggers_list::get_trigger_in
                                            trg_action_time_type time_type,
                                            LEX_STRING *trigger_name,
                                            LEX_STRING *trigger_stmt,
-                                           ulong *sql_mode,
+                                           sql_mode_t *sql_mode,
                                            LEX_STRING *definer,
                                            LEX_STRING *client_cs_name,
                                            LEX_STRING *connection_cl_name,
@@ -1545,14 +1545,14 @@ bool Table_triggers_list::get_trigger_in
 void Table_triggers_list::get_trigger_info(THD *thd,
                                            int trigger_idx,
                                            LEX_STRING *trigger_name,
-                                           ulonglong *sql_mode,
+                                           sql_mode_t *sql_mode,
                                            LEX_STRING *sql_original_stmt,
                                            LEX_STRING *client_cs_name,
                                            LEX_STRING *connection_cl_name,
                                            LEX_STRING *db_cl_name)
 {
   List_iterator_fast<LEX_STRING> it_trigger_name(names_list);
-  List_iterator_fast<ulonglong> it_sql_mode(definition_modes_list);
+  List_iterator_fast<sql_mode_t> it_sql_mode(definition_modes_list);
   List_iterator_fast<LEX_STRING> it_sql_orig_stmt(definitions_list);
   List_iterator_fast<LEX_STRING> it_client_cs_name(client_cs_names);
   List_iterator_fast<LEX_STRING> it_connection_cl_name(connection_cl_names);
@@ -1740,7 +1740,7 @@ Table_triggers_list::change_table_name_i
 {
   char path_buff[FN_REFLEN];
   LEX_STRING *def, *on_table_name, new_def;
-  ulong save_sql_mode= thd->variables.sql_mode;
+  sql_mode_t save_sql_mode= thd->variables.sql_mode;
   List_iterator_fast<LEX_STRING> it_def(definitions_list);
   List_iterator_fast<LEX_STRING> it_on_table_name(on_table_names_list);
   List_iterator_fast<ulonglong> it_mode(definition_modes_list);
@@ -1753,7 +1753,7 @@ Table_triggers_list::change_table_name_i
   while ((def= it_def++))
   {
     on_table_name= it_on_table_name++;
-    thd->variables.sql_mode= (ulong) *(it_mode++);
+    thd->variables.sql_mode= *(it_mode++);
 
     /* Construct CREATE TRIGGER statement with new table name. */
     buff.length(0);

=== modified file 'sql/sql_trigger.h'
--- a/sql/sql_trigger.h	2010-10-01 10:23:16 +0000
+++ b/sql/sql_trigger.h	2010-11-29 16:27:58 +0000
@@ -136,7 +136,7 @@ public:
   bool get_trigger_info(THD *thd, trg_event_type event,
                         trg_action_time_type time_type,
                         LEX_STRING *trigger_name, LEX_STRING *trigger_stmt,
-                        ulong *sql_mode,
+                        sql_mode_t *sql_mode,
                         LEX_STRING *definer,
                         LEX_STRING *client_cs_name,
                         LEX_STRING *connection_cl_name,
@@ -145,7 +145,7 @@ public:
   void get_trigger_info(THD *thd,
                         int trigger_idx,
                         LEX_STRING *trigger_name,
-                        ulonglong *sql_mode,
+                        sql_mode_t *sql_mode,
                         LEX_STRING *sql_original_stmt,
                         LEX_STRING *client_cs_name,
                         LEX_STRING *connection_cl_name,

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	2010-11-18 16:34:56 +0000
+++ b/sql/sql_view.cc	2010-11-29 16:27:58 +0000
@@ -836,7 +836,7 @@ static int mysql_register_view(THD *thd,
   view_query.length(0);
   is_query.length(0);
   {
-    ulong sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
+    sql_mode_t sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
     thd->variables.sql_mode&= ~MODE_ANSI_QUOTES;
 
     lex->unit.print(&view_query, QT_ORDINARY);
@@ -1221,7 +1221,7 @@ bool mysql_make_view(THD *thd, File_pars
     view_select= &lex->select_lex;
     view_select->select_number= ++thd->select_number;
 
-    ulong saved_mode= thd->variables.sql_mode;
+    sql_mode_t saved_mode= thd->variables.sql_mode;
     /* switch off modes which can prevent normal parsing of VIEW
       - MODE_REAL_AS_FLOAT            affect only CREATE TABLE parsing
       + MODE_PIPES_AS_CONCAT          affect expression parsing

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-11-29 11:28:55 +0000
+++ b/sql/sys_vars.cc	2010-11-29 16:27:58 +0000
@@ -1939,7 +1939,7 @@ static Sys_var_ulong Sys_sort_buffer(
        VALID_RANGE(MIN_SORT_MEMORY, ULONG_MAX), DEFAULT(MAX_SORT_MEMORY),
        BLOCK_SIZE(1));
 
-export ulong expand_sql_mode(ulonglong sql_mode)
+export sql_mode_t expand_sql_mode(sql_mode_t sql_mode)
 {
   if (sql_mode & MODE_ANSI)
   {
@@ -2025,7 +2025,7 @@ static const char *sql_mode_names[]=
   "PAD_CHAR_TO_FULL_LENGTH",
   0
 };
-export bool sql_mode_string_representation(THD *thd, ulong sql_mode,
+export bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
                                            LEX_STRING *ls)
 {
   set_to_string(thd, ls, sql_mode, sql_mode_names);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-bugfixing branch (jon.hauglid:3392 to 3393)Bug#57035Jon Olav Hauglid29 Nov