List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:May 16 2011 2:24pm
Subject:bzr commit into mysql-trunk branch (tor.didriksen:3092)
View as plain text  
#At file:///export/home/didrik/repo/trunk-mats-min-max/ based on revid:tor.didriksen@stripped

 3092 Tor Didriksen	2011-05-16
      Comments on min/max patch.
      
      Some changes due to 64-bit architecture (I presume).
      Some style comments:
       - don't say 'using <foo>'; in a header file
       - always include <algorithm> before using max/min.

    modified:
      client/mysql.cc
      client/mysqltest.cc
      sql/field.cc
      sql/item.cc
      sql/item_timefunc.cc
      sql/opt_range.h
      sql/sp_head.cc
      sql/sql_join_cache.cc
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_plugin.cc
      sql/sql_prepare.cc
      sql/sql_select.cc
      sql/sql_show.cc
      sql/sql_table.cc
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-05-16 13:32:40 +0000
+++ b/client/mysql.cc	2011-05-16 14:24:24 +0000
@@ -3381,8 +3381,9 @@ print_table_data(MYSQL_RES *result)
                                                   field->name,
                                                   field->name + name_length);
       uint display_length= field->max_length + name_length - numcells;
+      // Note that "%*" takes an int!!
       tee_fprintf(PAGER, " %-*s |",
-                  min<size_t>(display_length, MAX_COLUMN_LENGTH),
+                  min<int>(display_length, MAX_COLUMN_LENGTH),
                   field->name);
       num_flag[off]= IS_NUM(field->type);
     }

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2011-05-16 13:32:40 +0000
+++ b/client/mysqltest.cc	2011-05-16 14:24:24 +0000
@@ -5925,9 +5925,9 @@ int read_line(char *buf, int size)
       }
       else if ((c == '{' &&
                 (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-                                      (uchar*) buf, min(5, p - buf), 0) ||
+                                      (uchar*) buf, min<my_ptrdiff_t>(5, p - buf), 0) ||
                  !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-                                      (uchar*) buf, min(2, p - buf), 0))))
+                                      (uchar*) buf, min<my_ptrdiff_t>(2, p - buf), 0))))
       {
         /* Only if and while commands can be terminated by { */
         *p++= c;

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-05-16 13:32:40 +0000
+++ b/sql/field.cc	2011-05-16 14:24:24 +0000
@@ -8721,7 +8721,7 @@ String *Field_bit::val_str(String *val_b
 {
   ASSERT_COLUMN_MARKED_FOR_READ;
   char buff[sizeof(longlong)];
-  uint length= min(pack_length(), sizeof(longlong));
+  uint length= min<uint>(pack_length(), sizeof(longlong));
   ulonglong bits= val_int();
   mi_int8store(buff,bits);
 

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-05-16 13:32:40 +0000
+++ b/sql/item.cc	2011-05-16 14:24:24 +0000
@@ -5865,7 +5865,7 @@ longlong Item_hex_string::val_int()
   // following assert is redundant, because fixed=1 assigned in constructor
   DBUG_ASSERT(fixed == 1);
   char *end=(char*) str_value.ptr()+str_value.length(),
-       *ptr= end - min(str_value.length(), sizeof(longlong));
+       *ptr= end - min<size_t>(str_value.length(), sizeof(longlong));
 
   ulonglong value=0;
   for (; ptr != end ; ptr++)
@@ -5920,7 +5920,7 @@ warn:
 void Item_hex_string::print(String *str, enum_query_type query_type)
 {
   char *end= (char*) str_value.ptr() + str_value.length(),
-       *ptr= end - min(str_value.length(), sizeof(longlong));
+       *ptr= end - min<size_t>(str_value.length(), sizeof(longlong));
   str->append("0x");
   for (; ptr != end ; ptr++)
   {

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2011-05-16 13:32:40 +0000
+++ b/sql/item_timefunc.cc	2011-05-16 14:24:24 +0000
@@ -616,7 +616,7 @@ static bool extract_date_time(DATE_TIME_
 err:
   {
     char buff[128];
-    strmake(buff, val_begin, min(length, sizeof(buff)-1));
+    strmake(buff, val_begin, min<size_t>(length, sizeof(buff)-1));
     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                         ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
                         date_time_type, buff, "str_to_date");
@@ -3492,7 +3492,7 @@ null_date:
   if (val && (fuzzy_date & TIME_NO_ZERO_DATE))
   {
     char buff[128];
-    strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1));
+    strmake(buff, val->ptr(), min<size_t>(val->length(), sizeof(buff)-1));
     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                         ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
                         "datetime", buff, "str_to_date");

=== modified file 'sql/opt_range.h'
--- a/sql/opt_range.h	2011-05-12 12:35:00 +0000
+++ b/sql/opt_range.h	2011-05-16 14:24:24 +0000
@@ -30,8 +30,11 @@
 #include "sql_class.h"                          // set_var.h: THD
 #include "set_var.h"                            /* Item */
 
-using std::min;
-using std::max;
+// Always include what you need:
+#include <algorithm>
+
+// using std::min; Avoid doing this in headers
+// using std::max;
 
 class JOIN;
 class Item_sum;
@@ -96,7 +99,7 @@ class QUICK_RANGE :public Sql_alloc {
   void make_min_endpoint(key_range *kr, uint prefix_length, 
                          key_part_map keypart_map) {
     make_min_endpoint(kr);
-    kr->length= min(kr->length, prefix_length);
+    kr->length= std::min(kr->length, prefix_length);
     kr->keypart_map&= keypart_map;
   }
   
@@ -134,7 +137,7 @@ class QUICK_RANGE :public Sql_alloc {
   void make_max_endpoint(key_range *kr, uint prefix_length, 
                          key_part_map keypart_map) {
     make_max_endpoint(kr);
-    kr->length= min(kr->length, prefix_length);
+    kr->length= std::min(kr->length, prefix_length);
     kr->keypart_map&= keypart_map;
   }
 

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-05-16 13:32:40 +0000
+++ b/sql/sp_head.cc	2011-05-16 14:24:24 +0000
@@ -2643,7 +2643,7 @@ sp_head::show_create_routine(THD *thd, i
     */
 
     Item_empty_string *stmt_fld=
-      new Item_empty_string(col3_caption, max(m_defstr.length, 1024U));
+      new Item_empty_string(col3_caption, max<size_t>(m_defstr.length, 1024U));
 
     stmt_fld->maybe_null= TRUE;
 

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2011-05-12 12:35:00 +0000
+++ b/sql/sql_join_cache.cc	2011-05-16 14:24:24 +0000
@@ -27,6 +27,10 @@
 #include "sql_select.h"
 #include "key.h"
 
+#include <algorithm>
+using std::max;
+using std::min;
+
 
 /*****************************************************************************
  *  Join cache module

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-05-12 17:29:19 +0000
+++ b/sql/sql_parse.cc	2011-05-16 14:24:24 +0000
@@ -96,6 +96,10 @@
 #include "mysql/psi/mysql_statement.h"
 #include "sql_bootstrap.h"
 
+#include <algorithm>
+using std::max;
+using std::min;
+
 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
 
 /**
@@ -6607,7 +6611,7 @@ bool check_simple_select()
     char command[80];
     Lex_input_stream *lip= & thd->m_parser_state->m_lip;
     strmake(command, lip->yylval->symbol.str,
-	    min(lip->yylval->symbol.length, sizeof(command)-1));
+	    min<size_t>(lip->yylval->symbol.length, sizeof(command)-1));
     my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
     return 1;
   }

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2011-05-06 13:21:38 +0000
+++ b/sql/sql_partition.cc	2011-05-16 14:24:24 +0000
@@ -68,6 +68,10 @@
 #include "opt_range.h"                  // store_key_image_to_rec
 #include "sql_analyse.h"                // append_escaped
 
+#include <algorithm>
+using std::max;
+using std::min;
+
 #ifdef WITH_PARTITION_STORAGE_ENGINE
 #include "ha_partition.h"
 

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2011-05-12 12:35:00 +0000
+++ b/sql/sql_plugin.cc	2011-05-16 14:24:24 +0000
@@ -565,7 +565,7 @@ static st_plugin_dl *plugin_dl_add(const
     for (i=0;
          (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
          i++)
-      memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
+      memcpy(cur+i, old, min<size_t>(sizeof(cur[i]), sizeof_st_plugin));
 
     sym= cur;
   }

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-05-16 13:32:40 +0000
+++ b/sql/sql_prepare.cc	2011-05-16 14:24:24 +0000
@@ -115,6 +115,10 @@ When one supplies long data for a placeh
 #endif
 #include "lock.h"                               // MYSQL_OPEN_FORCE_SHARED_MDL
 
+#include <algorithm>
+using std::max;
+using std::min;
+
 /**
   A result class used to send cursor rows using the binary protocol.
 */

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-05-16 13:32:40 +0000
+++ b/sql/sql_select.cc	2011-05-16 14:24:24 +0000
@@ -51,6 +51,11 @@
 
 #define PREV_BITS(type,A)	((type) (((type) 1 << (A)) -1))
 
+#include <algorithm>
+using std::max;
+using std::min;
+
+
 const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
 			      "MAYBE_REF","ALL","range","index","fulltext",
 			      "ref_or_null","unique_subquery","index_subquery",

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-05-16 13:32:40 +0000
+++ b/sql/sql_show.cc	2011-05-16 14:24:24 +0000
@@ -54,6 +54,10 @@
 #include "debug_sync.h"
 #include "datadict.h"   // dd_frm_type()
 
+#include <algorithm>
+using std::max;
+using std::min;
+
 #define STR_OR_NIL(S) ((S) ? (S) : "<nil>")
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-05-12 17:29:19 +0000
+++ b/sql/sql_table.cc	2011-05-16 14:24:24 +0000
@@ -56,6 +56,10 @@
 #include <io.h>
 #endif
 
+#include <algorithm>
+using std::max;
+using std::min;
+
 const char *primary_key_name="PRIMARY";
 
 static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);


Attachment: [text/bzr-bundle] bzr/tor.didriksen@oracle.com-20110516142424-4w19iq1q76zhasjw.bundle
Thread
bzr commit into mysql-trunk branch (tor.didriksen:3092) Tor Didriksen16 May