List:Commits« Previous MessageNext Message »
From:monty Date:April 26 2007 10:12pm
Subject:bk commit into 5.1 tree (monty:1.2572)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of monty. When monty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-04-27 01:12:09+03:00, monty@stripped +11 -0
  Added sql_mode PAD_CHAR_TO_FULL_LENGTH (WL#921)
  This pads the value of CHAR columns with spaces up to full column length (according to ANSI)
  It's not makde part of oracle or ansi mode yet, as this would cause a notable behaviour change.
  Added uuid_short(), a generator for increasing 'unique' longlong integers (8 bytes)   

  mysql-test/r/func_misc.result@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +3 -0
    Update results

  mysql-test/r/sql_mode.result@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +17 -2
    Update results

  mysql-test/t/func_misc.test@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +4 -0
    Added test for uuid_short()

  mysql-test/t/sql_mode.test@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +12 -1
    Added test for sql_mode=PAD_CHAR_TO_FULL_LENGTH (#WL921)

  sql/field.cc@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +6 -1
    Added sql_mode PAD_CHAR_TO_FULL_LENGTH

  sql/item.cc@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +1 -0
    Initialize uuid_short()

  sql/item_create.cc@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +24 -0
    Added creation of uuid_short()

  sql/item_func.cc@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +37 -0
    Added uuid_short()

  sql/item_func.h@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +15 -0
    Added uuid_short()

  sql/mysql_priv.h@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +2 -0
    Added sql_mode PAD_CHAR_TO_FULL_LENGTH

  sql/mysqld.cc@stripped, 2007-04-27 01:12:06+03:00, monty@stripped +5 -1
    Added sql_mode PAD_CHAR_TO_FULL_LENGTH

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	monty
# Host:	nosik.monty.fi
# Root:	/home/my/mysql-5.1

--- 1.385/sql/field.cc	2007-04-10 16:00:29 +03:00
+++ 1.386/sql/field.cc	2007-04-27 01:12:06 +03:00
@@ -6187,9 +6187,14 @@
 			      String *val_ptr)
 {
   ASSERT_COLUMN_MARKED_FOR_READ;
-  uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length);
   /* See the comment for Field_long::store(long long) */
   DBUG_ASSERT(table->in_use == current_thd);
+  uint length;
+  if (table->in_use->variables.sql_mode &
+      MODE_PAD_CHAR_TO_FULL_LENGTH)
+    length= my_charpos(field_charset, ptr, ptr + field_length, field_length);
+  else
+    length= field_charset->cset->lengthsp(field_charset, ptr, field_length);
   val_ptr->set((const char*) ptr, length, field_charset);
   return val_ptr;
 }

--- 1.264/sql/item.cc	2007-04-20 11:50:45 +03:00
+++ 1.265/sql/item.cc	2007-04-27 01:12:06 +03:00
@@ -161,6 +161,7 @@
 void item_init(void)
 {
   item_user_lock_init();
+  uuid_short_init();
 }
 
 

--- 1.76/sql/item_create.cc	2007-03-29 19:12:47 +03:00
+++ 1.77/sql/item_create.cc	2007-04-27 01:12:06 +03:00
@@ -2141,6 +2141,19 @@
 };
 
 
+class Create_func_uuid_short : public Create_func_arg0
+{
+public:
+  virtual Item *create(THD *thd);
+
+  static Create_func_uuid_short s_singleton;
+
+protected:
+  Create_func_uuid_short() {}
+  virtual ~Create_func_uuid_short() {}
+};
+
+
 class Create_func_version : public Create_func_arg0
 {
 public:
@@ -4532,6 +4545,16 @@
 }
 
 
+Create_func_uuid_short Create_func_uuid_short::s_singleton;
+
+Item*
+Create_func_uuid_short::create(THD *thd)
+{
+  thd->lex->binlog_row_based_if_mixed= TRUE;
+  return new (thd->mem_root) Item_func_uuid_short();
+}
+
+
 Create_func_version Create_func_version::s_singleton;
 
 Item*
@@ -4871,6 +4894,7 @@
   { C_STRING_WITH_LEN("UPDATEXML"), BUILDER(Create_func_xml_update)},
   { C_STRING_WITH_LEN("UPPER"), BUILDER(Create_func_ucase)},
   { C_STRING_WITH_LEN("UUID"), BUILDER(Create_func_uuid)},
+  { C_STRING_WITH_LEN("UUID_SHORT"), BUILDER(Create_func_uuid_short)},
   { C_STRING_WITH_LEN("VERSION"), BUILDER(Create_func_version)},
   { C_STRING_WITH_LEN("WEEKDAY"), BUILDER(Create_func_weekday)},
   { C_STRING_WITH_LEN("WEEKOFYEAR"), BUILDER(Create_func_weekofyear)},

--- 1.378/sql/item_func.cc	2007-04-12 10:10:34 +03:00
+++ 1.379/sql/item_func.cc	2007-04-27 01:12:06 +03:00
@@ -5358,3 +5358,40 @@
   }
   DBUG_RETURN(res);
 }
+
+
+/*
+  uuid_short handling.
+
+  The short uuid is defined as a longlong that contains the following bytes:
+
+  Bytes  Comment
+  1      Server_id & 255
+  4      Startup time of server in seconds
+  3      Incrementor
+
+  This means that an uuid is guaranteed to be unique
+  even in a replication environment if the following holds:
+
+  - The last byte of the server id is unique
+  - If you between two shutdown of the server don't get more than
+    an average of 2^24 = 16M calls to uuid_short() per second.
+*/
+
+ulonglong uuid_value;
+
+void uuid_short_init()
+{
+  uuid_value= (((ulonglong) server_id << 56) + 
+               (ulonglong) server_start_time << 24);
+}
+
+
+longlong Item_func_uuid_short::val_int()
+{
+  ulonglong val;
+  pthread_mutex_lock(&LOCK_uuid_generator);
+  val= uuid_value++;
+  pthread_mutex_unlock(&LOCK_uuid_generator);
+  return (longlong) val;
+}

--- 1.165/sql/item_func.h	2007-04-13 09:25:37 +03:00
+++ 1.166/sql/item_func.h	2007-04-27 01:12:06 +03:00
@@ -1528,3 +1528,18 @@
   const char *func_name() const { return "found_rows"; }
   void fix_length_and_dec() { decimals= 0; maybe_null=0; }
 };
+
+
+void uuid_short_init();
+
+class Item_func_uuid_short :public Item_int_func
+{
+public:
+  Item_func_uuid_short() :Item_int_func() {}
+  const char *func_name() const { return "uuid_short"; }
+  longlong val_int();
+  void fix_length_and_dec()
+  { max_length= 21; unsigned_flag=1; }
+  bool check_partition_func_processor(byte *int_arg) {return FALSE;}
+};
+

--- 1.499/sql/mysql_priv.h	2007-04-20 11:50:45 +03:00
+++ 1.500/sql/mysql_priv.h	2007-04-27 01:12:06 +03:00
@@ -401,6 +401,8 @@
 #define MODE_NO_AUTO_CREATE_USER	(MODE_TRADITIONAL*2)
 #define MODE_HIGH_NOT_PRECEDENCE	(MODE_NO_AUTO_CREATE_USER*2)
 #define MODE_NO_ENGINE_SUBSTITUTION     (MODE_HIGH_NOT_PRECEDENCE*2)
+#define MODE_PAD_CHAR_TO_FULL_LENGTH    (MODE_NO_ENGINE_SUBSTITUTION*2)
+
 /*
   Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
   use strictly more than 64 bits by adding one more define above, you should

--- 1.633/sql/mysqld.cc	2007-04-20 11:50:45 +03:00
+++ 1.634/sql/mysqld.cc	2007-04-27 01:12:06 +03:00
@@ -225,8 +225,10 @@
   "ERROR_FOR_DIVISION_BY_ZERO",
   "TRADITIONAL", "NO_AUTO_CREATE_USER", "HIGH_NOT_PRECEDENCE",
   "NO_ENGINE_SUBSTITUTION",
+  "PAD_CHAR_TO_FULL_LENGTH",
   NullS
 };
+
 static const unsigned int sql_mode_names_len[]=
 {
   /*REAL_AS_FLOAT*/               13,
@@ -259,8 +261,10 @@
   /*TRADITIONAL*/                 11,
   /*NO_AUTO_CREATE_USER*/         19,
   /*HIGH_NOT_PRECEDENCE*/         19,
-  /*NO_ENGINE_SUBSTITUTION*/      22
+  /*NO_ENGINE_SUBSTITUTION*/      22,
+  /*PAD_CHAR_TO_FULL_LENGTH*/     23
 };
+
 TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
 			    sql_mode_names,
                             (unsigned int *)sql_mode_names_len };

--- 1.39/mysql-test/r/sql_mode.result	2006-06-21 15:07:08 +03:00
+++ 1.40/mysql-test/r/sql_mode.result	2007-04-27 01:12:06 +03:00
@@ -475,9 +475,24 @@
 select @@sql_mode;
 @@sql_mode
 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI
-set sql_mode=2147483648;
-ERROR 42000: Variable 'sql_mode' can't be set to the value of '2147483648'
+set sql_mode=2147483648*2;
+ERROR 42000: Variable 'sql_mode' can't be set to the value of '4294967296'
 select @@sql_mode;
 @@sql_mode
 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI
+set sql_mode=PAD_CHAR_TO_FULL_LENGTH;
+create table t1 (a int auto_increment primary key, b char(5));
+insert into t1 (b) values('a'),('b\t'),('c ');
+select concat('x',b,'x') from t1;
+concat('x',b,'x')
+xa    x
+xb	   x
+xc    x
+set sql_mode=0;
+select concat('x',b,'x') from t1;
+concat('x',b,'x')
+xax
+xb	x
+xcx
+drop table t1;
 SET @@SQL_MODE=@OLD_SQL_MODE;

--- 1.19/mysql-test/t/sql_mode.test	2006-06-21 15:07:09 +03:00
+++ 1.20/mysql-test/t/sql_mode.test	2007-04-27 01:12:06 +03:00
@@ -264,7 +264,18 @@
 set sql_mode=16384+(65536*4);
 select @@sql_mode;
 --error 1231
-set sql_mode=2147483648; # that mode does not exist
+set sql_mode=2147483648*2; # that mode does not exist
 select @@sql_mode;
+
+#
+# Test WL921: Retain spaces when retrieving CHAR column values
+
+set sql_mode=PAD_CHAR_TO_FULL_LENGTH;
+create table t1 (a int auto_increment primary key, b char(5));
+insert into t1 (b) values('a'),('b\t'),('c ');
+select concat('x',b,'x') from t1;
+set sql_mode=0;
+select concat('x',b,'x') from t1;
+drop table t1;
 
 SET @@SQL_MODE=@OLD_SQL_MODE;

--- 1.31/mysql-test/r/func_misc.result	2007-03-02 04:21:51 +02:00
+++ 1.32/mysql-test/r/func_misc.result	2007-04-27 01:12:06 +03:00
@@ -22,6 +22,9 @@
 select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
 length(uuid())	charset(uuid())	length(unhex(replace(uuid(),_utf8'-',_utf8'')))
 36	utf8	16
+select cast(uuid_short()-uuid_short() as signed);
+cast(uuid_short()-uuid_short() as signed)
+-1
 select length(format('nan', 2)) > 0;
 length(format('nan', 2)) > 0
 1

--- 1.21/mysql-test/t/func_misc.test	2007-03-02 04:20:46 +02:00
+++ 1.22/mysql-test/t/func_misc.test	2007-04-27 01:12:06 +03:00
@@ -14,6 +14,10 @@
 
 select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
 
+# As we can assume we are the only user for the mysqld server, the difference
+# between two calls should be -1
+select cast(uuid_short()-uuid_short() as signed);
+
 #
 # Test for core dump with nan
 #
Thread
bk commit into 5.1 tree (monty:1.2572)monty27 Apr