List:Commits« Previous MessageNext Message »
From:Marc Alff Date:January 19 2009 10:29pm
Subject:bzr push into mysql-6.0-wl2110-review branch (marc.alff:2730 to 2731)
View as plain text  
 2731 Marc Alff	2009-01-19
      Removed Fixed_string, UTF8String64 and UTF8String128.
removed:
  sql/sql_fixstring.cc
  sql/sql_fixstring.h
modified:
  libmysqld/CMakeLists.txt
  libmysqld/Makefile.am
  sql/CMakeLists.txt
  sql/Makefile.am
  sql/sql_error.cc
  sql/sql_error.h
  sql/sql_signal.cc

 2730 Marc Alff	2009-01-16 [merge]
      Merge mysql-6.0 --> mysql-6.0-wl2110-review
added:
  mysql-test/suite/ddl_lock/
  mysql-test/suite/ddl_lock/README
  mysql-test/suite/ddl_lock/include/
  mysql-test/suite/ddl_lock/include/stress_settings.inc
  mysql-test/suite/ddl_lock/include/sync_lock.inc
  mysql-test/suite/ddl_lock/r/
  mysql-test/suite/ddl_lock/r/concurrent_ddl.result
  mysql-test/suite/ddl_lock/r/create_stress_tables.result
  mysql-test/suite/ddl_lock/r/stress_ddl.result
  mysql-test/suite/ddl_lock/r/stress_dml.result
  mysql-test/suite/ddl_lock/stress_init.txt
  mysql-test/suite/ddl_lock/stress_tests.txt
  mysql-test/suite/ddl_lock/t/
  mysql-test/suite/ddl_lock/t/concurrent_ddl.test
  mysql-test/suite/ddl_lock/t/create_stress_tables.test
  mysql-test/suite/ddl_lock/t/stress_ddl.test
  mysql-test/suite/ddl_lock/t/stress_dml.test
  sql/debug_sync.h
modified:
  libmysqld/lib_sql.cc
  mysql-test/r/alter_table.result
  mysql-test/r/implicit_commit.result
  mysql-test/r/partition.result
  mysql-test/r/ps.result
  mysql-test/r/signal.result
  mysql-test/r/sp-dynamic.result
  mysql-test/r/sp-vars.result
  mysql-test/r/sp.result
  mysql-test/r/sp_notembedded.result
  mysql-test/r/trigger.result
  mysql-test/suite/binlog/r/binlog_unsafe.result
  mysql-test/suite/falcon/r/falcon_bug_28049.result
  mysql-test/suite/falcon/r/falcon_bug_32833.result
  mysql-test/suite/falcon/r/falcon_bugs.result
  mysql-test/suite/funcs_1/r/falcon_storedproc_02.result
  mysql-test/suite/funcs_1/r/innodb_storedproc_02.result
  mysql-test/suite/funcs_1/r/memory_storedproc_02.result
  mysql-test/suite/funcs_1/r/myisam_storedproc_02.result
  mysql-test/suite/funcs_1/r/ndb_storedproc_02.result
  mysql-test/suite/funcs_1/r/storedproc.result
  mysql-test/suite/rpl/r/rpl_row_sp007_innodb.result
  mysql-test/t/alter_table.test
  mysql-test/t/sp.test
  mysql-test/t/trigger.test
  sql/Makefile.am
  sql/backup/be_default.cc
  sql/backup/be_snapshot.cc
  sql/backup/kernel.cc
  sql/backup/logger.h
  sql/ddl_blocker.cc
  sql/debug_sync.cc
  sql/ha_ndbcluster_binlog.cc
  sql/handler.cc
  sql/item_func.cc
  sql/lock.cc
  sql/mdl.cc
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/protocol.cc
  sql/protocol.h
  sql/si_objects.cc
  sql/sp_head.cc
  sql/sql_base.cc
  sql/sql_class.cc
  sql/sql_class.h
  sql/sql_delete.cc
  sql/sql_error.cc
  sql/sql_error.h
  sql/sql_insert.cc
  sql/sql_parse.cc
  sql/sql_prepare.cc
  sql/sql_repl.cc
  sql/sql_signal.cc
  sql/sql_table.cc
  sql/sql_update.cc
  storage/maria/ha_maria.cc
  storage/myisam/myisam_backup_engine.cc
  storage/myisammrg/ha_myisammrg.cc

=== modified file 'libmysqld/CMakeLists.txt'
--- a/libmysqld/CMakeLists.txt	2008-12-19 14:59:10 +0000
+++ b/libmysqld/CMakeLists.txt	2009-01-19 22:28:20 +0000
@@ -195,7 +195,7 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libm
            ../sql/scheduler.cc ../sql/sql_audit.cc
            ../sql/ddl_blocker.cc ../sql/si_objects.cc
            ../sql/event_parse_data.cc ../sql/mdl.cc
-           ../sql/sql_signal.cc ../sql/sql_fixstring.cc
+           ../sql/sql_signal.cc
            ../sql/transaction.cc
 	   ../sql/rpl_handler.cc
            ${GEN_SOURCES}

=== modified file 'libmysqld/Makefile.am'
--- a/libmysqld/Makefile.am	2008-12-19 14:59:10 +0000
+++ b/libmysqld/Makefile.am	2009-01-19 22:28:20 +0000
@@ -82,7 +82,7 @@ sqlsources = derror.cc field.cc field_co
 	debug_sync.cc sql_tablespace.cc transaction.cc \
 	rpl_injector.cc my_user.c partition_info.cc \
 	sql_servers.cc ddl_blocker.cc si_objects.cc sql_audit.cc \
-	event_parse_data.cc mdl.cc sql_signal.cc sql_fixstring.cc \
+	event_parse_data.cc mdl.cc sql_signal.cc \
         rpl_handler.cc
 
 libmysqld_int_a_SOURCES= $(libmysqld_sources)

=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2008-12-19 14:59:10 +0000
+++ b/sql/CMakeLists.txt	2009-01-19 22:28:20 +0000
@@ -59,7 +59,7 @@ ADD_EXECUTABLE(mysqld
                sql_map.cc sql_parse.cc  sql_partition.cc sql_plugin.cc
                sql_prepare.cc sql_rename.cc 
                debug_sync.cc
-               sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc 
+               sql_repl.cc sql_select.cc sql_show.cc sql_state.c
                sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc
                sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc 
                time.cc tztime.cc uniques.cc unireg.cc item_xmlfunc.cc 
@@ -71,7 +71,7 @@ ADD_EXECUTABLE(mysqld
                sql_connect.cc scheduler.cc transaction.cc
                ddl_blocker.cc si_objects.cc si_logs.cc
                sql_profile.cc event_parse_data.cc mdl.cc
-               sql_signal.cc sql_fixstring.cc
+               sql_signal.cc
                rpl_handler.cc
                ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
                ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2009-01-17 02:29:30 +0000
+++ b/sql/Makefile.am	2009-01-19 22:28:20 +0000
@@ -102,7 +102,7 @@ noinst_HEADERS =	item.h item_func.h item
 			probes.h sql_audit.h transaction.h \
 			contributors.h sql_servers.h ddl_blocker.h \
 			si_objects.h si_logs.h sql_plist.h mdl.h records.h \
-			sql_signal.h sql_fixstring.h \
+			sql_signal.h \
 			rpl_handler.h replication.h sql_prepare.h debug_sync.h
 
 mysqld_SOURCES =	sql_lex.cc sql_handler.cc sql_partition.cc \
@@ -152,7 +152,7 @@ mysqld_SOURCES =	sql_lex.cc sql_handler.
 			sql_servers.cc sql_audit.cc sha2.cc \
 			ddl_blocker.cc si_objects.cc si_logs.cc \
 			event_parse_data.cc mdl.cc transaction.cc \
-			sql_signal.cc sql_fixstring.cc \
+			sql_signal.cc \
 			rpl_handler.cc
 
 if HAVE_DTRACE

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2009-01-17 02:29:30 +0000
+++ b/sql/sql_error.cc	2009-01-19 22:28:20 +0000
@@ -163,7 +163,7 @@ This file contains the implementation of
 
   - Change (#4 and #5) to store message text in UTF8 natively.
     In practice, this means changing the type of the message text to
-    'UTF8String128 MYSQL_ERROR::m_message_text', and is a direct
+    '<UTF8 String 128 class> MYSQL_ERROR::m_message_text', and is a direct
     consequence of WL#751.
 
   - Implement (#9) (GET DIAGNOSTICS).
@@ -172,16 +172,16 @@ This file contains the implementation of
 
 MYSQL_ERROR::MYSQL_ERROR()
  : Sql_alloc(),
-   m_class_origin(),
-   m_subclass_origin(),
-   m_constraint_catalog(),
-   m_constraint_schema(),
-   m_constraint_name(),
-   m_catalog_name(),
-   m_schema_name(),
-   m_table_name(),
-   m_column_name(),
-   m_cursor_name(),
+   m_class_origin((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_subclass_origin((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_constraint_catalog((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_constraint_schema((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_constraint_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_catalog_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_schema_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_table_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_column_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin),
    m_message_text(),
    m_sql_errno(0),
    m_level(MYSQL_ERROR::WARN_LEVEL_ERROR),
@@ -194,31 +194,21 @@ void MYSQL_ERROR::init(MEM_ROOT *mem_roo
 {
   DBUG_ASSERT(mem_root != NULL);
   DBUG_ASSERT(m_mem_root == NULL);
-  m_class_origin.init(mem_root);
-  m_subclass_origin.init(mem_root);
-  m_constraint_catalog.init(mem_root);
-  m_constraint_schema.init(mem_root);
-  m_constraint_name.init(mem_root);
-  m_catalog_name.init(mem_root);
-  m_schema_name.init(mem_root);
-  m_table_name.init(mem_root);
-  m_column_name.init(mem_root);
-  m_cursor_name.init(mem_root);
   m_mem_root= mem_root;
 }
 
 void MYSQL_ERROR::clear()
 {
-  m_class_origin.clear();
-  m_subclass_origin.clear();
-  m_constraint_catalog.clear();
-  m_constraint_schema.clear();
-  m_constraint_name.clear();
-  m_catalog_name.clear();
-  m_schema_name.clear();
-  m_table_name.clear();
-  m_column_name.clear();
-  m_cursor_name.clear();
+  m_class_origin.length(0);
+  m_subclass_origin.length(0);
+  m_constraint_catalog.length(0);
+  m_constraint_schema.length(0);
+  m_constraint_name.length(0);
+  m_catalog_name.length(0);
+  m_schema_name.length(0);
+  m_table_name.length(0);
+  m_column_name.length(0);
+  m_cursor_name.length(0);
   m_message_text.length(0);
   m_sql_errno= 0;
   m_level= MYSQL_ERROR::WARN_LEVEL_ERROR;
@@ -226,16 +216,16 @@ void MYSQL_ERROR::clear()
 
 MYSQL_ERROR::MYSQL_ERROR(MEM_ROOT *mem_root)
  : Sql_alloc(),
-   m_class_origin(mem_root),
-   m_subclass_origin(mem_root),
-   m_constraint_catalog(mem_root),
-   m_constraint_schema(mem_root),
-   m_constraint_name(mem_root),
-   m_catalog_name(mem_root),
-   m_schema_name(mem_root),
-   m_table_name(mem_root),
-   m_column_name(mem_root),
-   m_cursor_name(mem_root),
+   m_class_origin((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_subclass_origin((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_constraint_catalog((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_constraint_schema((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_constraint_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_catalog_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_schema_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_table_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_column_name((const char*) NULL, 0, & my_charset_utf8_bin),
+   m_cursor_name((const char*) NULL, 0, & my_charset_utf8_bin),
    m_message_text(),
    m_sql_errno(0),
    m_level(MYSQL_ERROR::WARN_LEVEL_ERROR),
@@ -245,20 +235,37 @@ MYSQL_ERROR::MYSQL_ERROR(MEM_ROOT *mem_r
   memset(m_returned_sqlstate, 0, sizeof(m_returned_sqlstate));
 }
 
+static void copy_string(MEM_ROOT *mem_root, String* dst, const String* src)
+{
+  size_t len= src->length();
+  if (len)
+  {
+    char* copy= (char*) alloc_root(mem_root, len + 1);
+    if (copy)
+    {
+      memcpy(copy, src->ptr(), len);
+      copy[len]= '\0';
+      dst->set(copy, len, src->charset());
+    }
+  }
+  else
+    dst->length(0);
+}
+
 void
 MYSQL_ERROR::copy_opt_attributes(const MYSQL_ERROR *cond)
 {
   DBUG_ASSERT(this != cond);
-  m_class_origin.copy(& cond->m_class_origin);
-  m_subclass_origin.copy(& cond->m_subclass_origin);
-  m_constraint_catalog.copy(& cond->m_constraint_catalog);
-  m_constraint_schema.copy(& cond->m_constraint_schema);
-  m_constraint_name.copy(& cond->m_constraint_name);
-  m_catalog_name.copy(& cond->m_catalog_name);
-  m_schema_name.copy(& cond->m_schema_name);
-  m_table_name.copy(& cond->m_table_name);
-  m_column_name.copy(& cond->m_column_name);
-  m_cursor_name.copy(& cond->m_cursor_name);
+  copy_string(m_mem_root, & m_class_origin, & cond->m_class_origin);
+  copy_string(m_mem_root, & m_subclass_origin, & cond->m_subclass_origin);
+  copy_string(m_mem_root, & m_constraint_catalog, & cond->m_constraint_catalog);
+  copy_string(m_mem_root, & m_constraint_schema, & cond->m_constraint_schema);
+  copy_string(m_mem_root, & m_constraint_name, & cond->m_constraint_name);
+  copy_string(m_mem_root, & m_catalog_name, & cond->m_catalog_name);
+  copy_string(m_mem_root, & m_schema_name, & cond->m_schema_name);
+  copy_string(m_mem_root, & m_table_name, & cond->m_table_name);
+  copy_string(m_mem_root, & m_column_name, & cond->m_column_name);
+  copy_string(m_mem_root, & m_cursor_name, & cond->m_cursor_name);
 }
 
 void

=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h	2009-01-17 02:29:30 +0000
+++ b/sql/sql_error.h	2009-01-19 22:28:20 +0000
@@ -19,7 +19,6 @@
 #include "sql_list.h" /* Sql_alloc, MEM_ROOT */
 #include "m_string.h" /* LEX_STRING */
 #include "mysql_com.h" /* MYSQL_ERRMSG_SIZE */
-#include "sql_fixstring.h"
 
 class THD;
 
@@ -273,34 +272,34 @@ private:
 
 private:
   /** SQL CLASS_ORIGIN condition item. */
-  UTF8String64 m_class_origin;
+  String m_class_origin;
 
   /** SQL SUBCLASS_ORIGIN condition item. */
-  UTF8String64 m_subclass_origin;
+  String m_subclass_origin;
 
   /** SQL CONSTRAINT_CATALOG condition item. */
-  UTF8String64 m_constraint_catalog;
+  String m_constraint_catalog;
 
   /** SQL CONSTRAINT_SCHEMA condition item. */
-  UTF8String64 m_constraint_schema;
+  String m_constraint_schema;
 
   /** SQL CONSTRAINT_NAME condition item. */
-  UTF8String64 m_constraint_name;
+  String m_constraint_name;
 
   /** SQL CATALOG_NAME condition item. */
-  UTF8String64 m_catalog_name;
+  String m_catalog_name;
 
   /** SQL SCHEMA_NAME condition item. */
-  UTF8String64 m_schema_name;
+  String m_schema_name;
 
   /** SQL TABLE_NAME condition item. */
-  UTF8String64 m_table_name;
+  String m_table_name;
 
   /** SQL COLUMN_NAME condition item. */
-  UTF8String64 m_column_name;
+  String m_column_name;
 
   /** SQL CURSOR_NAME condition item. */
-  UTF8String64 m_cursor_name;
+  String m_cursor_name;
 
   /** Message text, expressed in the character set implied by --language. */
   String m_message_text;

=== removed file 'sql/sql_fixstring.cc'
--- a/sql/sql_fixstring.cc	2009-01-07 17:37:52 +0000
+++ b/sql/sql_fixstring.cc	1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
-/* Copyright (C) 2008 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#include "mysql_priv.h"
-
-Fixed_string::~Fixed_string()
-{}
-
-void Fixed_string::set(const String* str)
-{
-  set(str->ptr(), str->length(), (CHARSET_INFO*) str->charset());
-}
-
-void Fixed_string::set(const char* str, size_t len, const CHARSET_INFO *str_cs)
-{
-  uint32 dummy_offset;
-  size_t numchars;
-  size_t to_copy;
-  const char *end= str + len;
-
-  if (str == NULL)
-  {
-    clear();
-    return;
-  }
-
-  numchars= str_cs->cset->numchars((CHARSET_INFO*) str_cs, str, end);
-
-  if (numchars <= m_max_char)
-  {
-    to_copy= len;
-    m_truncated= FALSE;
-  }
-  else
-  {
-    numchars= m_max_char;
-    to_copy= m_cs->cset->charpos(m_cs, str, end, numchars);
-    m_truncated= TRUE;
-  }
-
-  if (String::needs_conversion(to_copy, (CHARSET_INFO*) str_cs,
-                               (CHARSET_INFO*) m_cs, & dummy_offset))
-  {
-    size_t dest_len= numchars * m_cs->mbmaxlen;
-    reserve(dest_len + m_cs->mbminlen);
-    if (m_ptr)
-    {
-      const char* well_formed_error_pos;
-      const char* cannot_convert_error_pos;
-      const char* from_end_pos;
-
-      m_byte_length= well_formed_copy_nchars((CHARSET_INFO *) m_cs,
-                                             m_ptr, dest_len,
-                                             (CHARSET_INFO*) str_cs, str, len,
-                                             numchars,
-                                             & well_formed_error_pos,
-                                             & cannot_convert_error_pos,
-                                             & from_end_pos);
-      add_nul(m_ptr + m_byte_length);
-    }
-  }
-  else
-  {
-    reserve(to_copy + m_cs->mbminlen);
-    if (m_ptr)
-    {
-      m_byte_length= to_copy;
-      memcpy(m_ptr, str, to_copy);
-      add_nul(m_ptr + to_copy);
-    }
-  }
-}
-
-void Fixed_string::add_nul(char *ptr)
-{
-  /*
-    Assume that the NUL character is always encoded using 0 bytes,
-    and is always using an encoding of the minimum length.
-    Verified for:
-    - UTF8 : NUL = 1 zero byte
-    - latin* : NUL = 1 zero byte
-    - UTF16 : NUL = 2 zero byte
-    - UTF32 : NUL = 4 zero byte
-  */
-  switch (m_cs->mbminlen)
-  {
-  case 4: *ptr++ = '\0'; /* fall through */
-  case 3: *ptr++ = '\0'; /* fall through */
-  case 2: *ptr++ = '\0'; /* fall through */
-  case 1: *ptr++ = '\0'; break;
-  default: DBUG_ASSERT(FALSE); break;
-  }
-}
-
-void Fixed_string::copy(const Fixed_string *str)
-{
-  DBUG_ASSERT(m_cs->number == str->m_cs->number);
-
-  set(str->m_ptr, str->m_byte_length, str->m_cs);
-}
-
-void Fixed_string::clear()
-{
-  m_ptr= NULL;
-  m_byte_length= 0;
-  m_allocated_length= 0;
-  m_truncated= FALSE;
-}
-
-void Fixed_string::reserve(size_t len)
-{
-  if ((m_ptr != NULL) && (m_allocated_length >= len))
-    return;
-
-  m_ptr= (char*) alloc_root(m_mem_root, len);
-  m_allocated_length= (m_ptr ? len : 0);
-}
-

=== removed file 'sql/sql_fixstring.h'
--- a/sql/sql_fixstring.h	2009-01-07 17:37:52 +0000
+++ b/sql/sql_fixstring.h	1970-01-01 00:00:00 +0000
@@ -1,202 +0,0 @@
-/* Copyright (C) 2008 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef SQL_FIXSTRING_H
-#define SQL_FIXSTRING_H
-
-class String;
-
-/**
-  This class represents a VARCHAR string or a given fixed maximum size,
-  and of a given fixed character set.
-  The size and character set are immutable.
-  Memory used to represent the string is allocated from a provided memory root.
-*/
-class Fixed_string
-{
-public:
-  /**
-    Constructor.
-    @param max_char Immutable max size
-    @param cs Immutable character set
-    @param mem_root Memory root to use to represent the string value
-  */
-  Fixed_string(size_t max_char, CHARSET_INFO *cs, MEM_ROOT *mem_root)
-    : m_max_char(max_char),
-    m_cs(cs),
-    m_mem_root(mem_root),
-    m_byte_length(0),
-    m_allocated_length(0),
-    m_truncated(FALSE),
-    m_ptr(NULL)
-  {}
-
-  void init(MEM_ROOT *mem_root)
-  { m_mem_root= mem_root; }
-
-  /** Destructor. */
-  ~Fixed_string();
-
-  /**
-    Set the string value, with character set conversion if necessary.
-    @param str the value to set, expressed in any character set
-  */
-  void set(const String* str);
-
-  /**
-    Set the string value, with character set conversion if necessary.
-    @param str the value to set, expressed in character set str_cs
-    @param len length, in bytes, of str
-    @param str_cs character set of str
-  */
-  void set(const char* str, size_t len, const CHARSET_INFO *str_cs);
-
-  /**
-    Predicate, indicates if the string is truncated to the maximum size.
-    @return true if the string is truncated
-  */
-  bool is_truncated() const
-  { return m_truncated; }
-
-  /**
-    Access to the C pointer representation of the string.
-    @return a NUL terminated C string, in the character set of m_cs
-  */
-  const char* ptr() const
-  { return m_ptr; }
-
-  /**
-    Length, in bytes, of the C string representation,
-    excluding the terminating NUL character.
-    @return The string length in bytes
-  */
-  size_t length() const
-  { return m_byte_length; }
-
-  /**
-    Character set of the string.
-    @return the string character set
-  */
-  const CHARSET_INFO *charset() const
-  { return m_cs; }
-
-  /**
-    Set the string value from another Fixed_string.
-    Note that the character set of this object and of str must be equal.
-    @param str the string to copy
-  */
-  void copy(const Fixed_string *str);
-
-  void clear();
-
-private:
-  /**
-    Allocate memory for the string representation.
-    @param len size in bytes to allocate
-  */
-  void reserve(size_t len);
-
-  /**
-    Add a NUL character at the end of the string.
-    @param ptr location of the NUL character
-  */
-  void add_nul(char *ptr);
-
-  /**
-    Immutable maximum length of a VARCHAR string (N), in VARCHAR(N)
-  */
-  const size_t m_max_char;
-
-  /**
-    Immutable character set of a VARCHAR string (C), in VARCHAR(N) CHARACTER SET C.
-  */
-  CHARSET_INFO * const m_cs;
-
-  /**
-    Memory root to use to allocate the string value.
-  */
-  MEM_ROOT *m_mem_root;
-
-  /**
-    Length of the C string representation, in bytes,
-    excluding the terminating NUL character.
-  */
-  size_t m_byte_length;
-
-  /**
-    Size, in bytes, of the memory allocated.
-  */
-  size_t m_allocated_length;
-
-  /**
-    True if the string was truncated.
-    Note that no warnings or errors are generated,
-    the string is truncated silently.
-  */
-  bool m_truncated;
-
-  /**
-    C representation of the string, NUL terminated.
-  */
-  char * m_ptr;
-};
-
-/**
-  This class represents a 'VARCHAR(64) CHARACTER SET UTF8' string value.
-*/
-class UTF8String64 : public Fixed_string
-{
-public:
-  /**
-    Constructor.
-    @param root The memory root to use to represent the string value.
-  */
-  UTF8String64(MEM_ROOT *root)
-    : Fixed_string(64, & my_charset_utf8_bin, root)
-  {}
-
-  UTF8String64()
-    : Fixed_string(64, & my_charset_utf8_bin, NULL)
-  {}
-
-  ~UTF8String64()
-  {}
-};
-
-/**
-  This class represents a 'VARCHAR(128) CHARACTER SET UTF8' string value.
-*/
-class UTF8String128 : public Fixed_string
-{
-public:
-  /**
-    Constructor.
-    @param root The memory root to use to represent the string value.
-  */
-  UTF8String128(MEM_ROOT *root)
-    : Fixed_string(128, & my_charset_utf8_bin, root)
-  {}
-
-  UTF8String128()
-    : Fixed_string(128, & my_charset_utf8_bin, NULL)
-  {}
-
-  ~UTF8String128()
-  {}
-};
-
-#endif
-
-

=== modified file 'sql/sql_signal.cc'
--- a/sql/sql_signal.cc	2009-01-17 02:29:30 +0000
+++ b/sql/sql_signal.cc	2009-01-19 22:28:20 +0000
@@ -148,12 +148,89 @@ void Abstract_signal::eval_defaults(THD
   }
 }
 
-static int assign_condition_item(const char* name, THD *thd, Item *set,
-                                 UTF8String64 *ci)
+static bool assign_fixed_string(MEM_ROOT *mem_root,
+                                CHARSET_INFO *dst_cs,
+                                size_t max_char,
+                                String *dst,
+                                const String* src)
 {
-  char str_buff[(64+1)*4]; /* Room for a null terminated UFT8String64 */
+  bool truncated;
+  size_t numchars;
+  CHARSET_INFO *src_cs;
+  const char* src_str;
+  const char* src_end;
+  size_t src_len;
+  size_t to_copy;
+  char* dst_str;
+  size_t dst_len;
+  size_t dst_copied;
+  uint32 dummy_offset;
+
+  src_str= src->ptr();
+  if (src_str == NULL)
+  {
+    dst->set((const char*) NULL, 0, dst_cs);
+    return false;
+  }
+
+  src_cs= src->charset();
+  src_len= src->length();
+  src_end= src_str + src_len;
+  numchars= src_cs->cset->numchars(src_cs, src_str, src_end);
+
+  if (numchars <= max_char)
+  {
+    to_copy= src->length();
+    truncated= false;
+  }
+  else
+  {
+    numchars= max_char;
+    to_copy= dst_cs->cset->charpos(dst_cs, src_str, src_end, numchars);
+    truncated= true;
+  }
+
+  if (String::needs_conversion(to_copy, src_cs, dst_cs, & dummy_offset))
+  {
+    dst_len= numchars * dst_cs->mbmaxlen;
+    dst_str= (char*) alloc_root(mem_root, dst_len + 1);
+    if (dst_str)
+    {
+      const char* well_formed_error_pos;
+      const char* cannot_convert_error_pos;
+      const char* from_end_pos;
+
+      dst_copied= well_formed_copy_nchars(dst_cs, dst_str, dst_len,
+                                          src_cs, src_str, src_len,
+                                          numchars,
+                                          & well_formed_error_pos,
+                                          & cannot_convert_error_pos,
+                                          & from_end_pos);
+      dst_str[dst_copied]= '\0';
+    }
+  }
+  else
+  {
+    dst_len= to_copy;
+    dst_str= (char*) alloc_root(mem_root, dst_len + 1);
+    if (dst_str)
+    {
+      memcpy(dst_str, src_str, to_copy);
+      dst_str[to_copy]= '\0';
+    }
+  }
+  dst->set(dst_str, dst_len, dst_cs);
+
+  return truncated;
+}
+
+static int assign_condition_item(MEM_ROOT *mem_root, const char* name, THD *thd,
+                                 Item *set, String *ci)
+{
+  char str_buff[(64+1)*4]; /* Room for a null terminated UTF8 String 64 */
   String str_value(str_buff, sizeof(str_buff), & my_charset_utf8_bin);
   String *str;
+  bool truncated;
 
   DBUG_ENTER("assign_condition_item");
 
@@ -164,8 +241,8 @@ static int assign_condition_item(const c
   }
 
   str= set->val_str(& str_value);
-  ci->set(str);
-  if (ci->is_truncated())
+  truncated= assign_fixed_string(mem_root, & my_charset_utf8_bin, 64, ci, str);
+  if (truncated)
   {
     if (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
                                    MODE_STRICT_ALL_TABLES))
@@ -186,7 +263,7 @@ int Abstract_signal::eval_signal_informa
   struct cond_item_map
   {
     enum enum_diag_condition_item_name m_item;
-    UTF8String64 MYSQL_ERROR::*m_member;
+    String MYSQL_ERROR::*m_member;
   };
 
   static cond_item_map map[]=
@@ -210,7 +287,7 @@ int Abstract_signal::eval_signal_informa
   uint j;
   int result= 1;
   enum enum_diag_condition_item_name item_enum;
-  UTF8String64 *member;
+  String *member;
   const LEX_STRING *name;
 
   DBUG_ENTER("Abstract_signal::eval_signal_informations");
@@ -232,10 +309,10 @@ int Abstract_signal::eval_signal_informa
   }
 
   /*
-    Generically assign all the UTF8String64 condition items
+    Generically assign all the UTF8 String 64 condition items
     described in the map.
   */
-  for (j= 0; j < sizeof(map)/sizeof(map[0]); j++)
+  for (j= 0; j < array_elements(map); j++)
   {
     item_enum= map[j].m_item;
     set= m_set_signal_information.m_item[item_enum];
@@ -243,7 +320,7 @@ int Abstract_signal::eval_signal_informa
     {
       member= & (cond->* map[j].m_member);
       name= & Diag_condition_item_names[item_enum];
-      if (assign_condition_item(name->str, thd, set, member))
+      if (assign_condition_item(cond->m_mem_root, name->str, thd, set, member))
         goto end;
     }
   }
@@ -265,11 +342,12 @@ int Abstract_signal::eval_signal_informa
       Enforce that SET MESSAGE_TEXT = <value> evaluates the value
       as VARCHAR(128) CHARACTER SET UTF8.
     */
-    UTF8String128 utf8_text(thd->mem_root);
+    bool truncated;
+    String utf8_text;
     str= set->val_str(& str_value);
-    utf8_text.set(str->ptr(), (size_t) str->length(), str->charset());
-
-    if (utf8_text.is_truncated())
+    truncated= assign_fixed_string(thd->mem_root, & my_charset_utf8_bin, 128,
+                                   & utf8_text, str);
+    if (truncated)
     {
       if (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
                                      MODE_STRICT_ALL_TABLES))
@@ -291,7 +369,7 @@ int Abstract_signal::eval_signal_informa
     String converted_text;
     converted_text.set_charset(error_message_charset_info);
     converted_text.append(utf8_text.ptr(), utf8_text.length(),
-                          (CHARSET_INFO *) utf8_text.charset());
+                          utf8_text.charset());
     cond->set_builtin_message_text(converted_text.c_ptr_safe());
   }
 

Thread
bzr push into mysql-6.0-wl2110-review branch (marc.alff:2730 to 2731) Marc Alff19 Jan