List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:July 18 2006 6:37pm
Subject:bk commit into 5.0 tree (anozdrin:1.2237) BUG#16211
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of alik. When alik 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, 2006-07-18 20:37:41+04:00, anozdrin@booka. +5 -0
  Fix for BUG#16211: Stored function return type for strings is ignored.
  This is the first part of fix for this bug.
  
  The problem is that CHARSET-clause of the return type for stored functions
  is just ignored.
  
  The current fix is to remember CHARSET-clause if it is explicitly specified.

  mysql-test/r/sp.result@stripped, 2006-07-18 20:37:37+04:00, anozdrin@booka. +58 -0
    Updated result file.

  mysql-test/t/sp.test@stripped, 2006-07-18 20:37:38+04:00, anozdrin@booka. +68 -0
    Provided a test case for BUG#16211.

  sql/field.h@stripped, 2006-07-18 20:37:38+04:00, anozdrin@booka. +11 -0
    Added a new flag to understand whether CHARSET-clause has been specified or not.

  sql/sp.cc@stripped, 2006-07-18 20:37:38+04:00, anozdrin@booka. +12 -0
    1. Add CHARSET-clause to CREATE-statement if it has been explicitly specified.
    2. Polishing -- provided some comments.

  sql/sp_head.cc@stripped, 2006-07-18 20:37:38+04:00, anozdrin@booka. +2 -0
    Added a new flag to understand whether CHARSET-clause has been specified or not.

# 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:	anozdrin
# Host:	booka.
# Root:	/home/alik/MySQL/devel/5.0-rt-bug16211

--- 1.183/sql/field.h	2006-07-18 20:37:45 +04:00
+++ 1.184/sql/field.h	2006-07-18 20:37:45 +04:00
@@ -1413,6 +1413,17 @@ public:
   TYPELIB *interval;			// Which interval to use
   List<String> interval_list;
   CHARSET_INFO *charset;
+
+  /*
+    charset_clause_specified -- specifies whether CHARSET clause has been
+    specified for the field or not.
+
+    NOTE: this attribute has been introduced only for backward compatibility
+    in handling RETURNS-clause of stored functions. The attribute is supposed
+    to be removed while finalizing character set support in RETURNS-clause.
+  */
+  bool charset_clause_specified;
+
   Field::geometry_type geom_type;
   Field *field;				// For alter table
 

--- 1.203/mysql-test/r/sp.result	2006-07-18 20:37:45 +04:00
+++ 1.204/mysql-test/r/sp.result	2006-07-18 20:37:45 +04:00
@@ -5069,4 +5069,62 @@ END |
 SET @a = _latin2"aaaaaaaaaa" |
 CALL bug21013(10) |
 DROP PROCEDURE bug21013 |
+DROP DATABASE IF EXISTS bug16211_db1|
+CREATE DATABASE bug16211_db1 DEFAULT CHARACTER SET utf8|
+use bug16211_db1|
+CREATE FUNCTION bug16211_f1() RETURNS CHAR(10)
+RETURN ""|
+CREATE FUNCTION bug16211_f2() RETURNS CHAR(10) CHARSET koi8r
+RETURN ""|
+SHOW CREATE FUNCTION bug16211_f1|
+Function	sql_mode	Create Function
+bug16211_f1		CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10)
+RETURN ""
+SHOW CREATE FUNCTION bug16211_f2|
+Function	sql_mode	Create Function
+bug16211_f2		CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10)
CHARSET koi8r
+RETURN ""
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f1"|
+dtd_identifier
+char(10)
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f2"|
+dtd_identifier
+char(10) CHARSET koi8r
+SELECT CHARSET(bug16211_f1())|
+CHARSET(bug16211_f1())
+latin1
+SELECT CHARSET(bug16211_f2())|
+CHARSET(bug16211_f2())
+koi8r
+ALTER DATABASE bug16211_db1 CHARACTER SET cp1251|
+SHOW CREATE FUNCTION bug16211_f1|
+Function	sql_mode	Create Function
+bug16211_f1		CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10)
+RETURN ""
+SHOW CREATE FUNCTION bug16211_f2|
+Function	sql_mode	Create Function
+bug16211_f2		CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10)
CHARSET koi8r
+RETURN ""
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f1"|
+dtd_identifier
+char(10)
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f2"|
+dtd_identifier
+char(10) CHARSET koi8r
+SELECT CHARSET(bug16211_f1())|
+CHARSET(bug16211_f1())
+latin1
+SELECT CHARSET(bug16211_f2())|
+CHARSET(bug16211_f2())
+koi8r
+use test|
+DROP DATABASE bug16211_db1|
 drop table t1,t2;

--- 1.191/mysql-test/t/sp.test	2006-07-18 20:37:45 +04:00
+++ 1.192/mysql-test/t/sp.test	2006-07-18 20:37:45 +04:00
@@ -5990,6 +5990,74 @@ DROP PROCEDURE bug21013 |
 
 
 #
+# BUG#16211: Stored function return type for strings is ignored
+#
+
+# Prepare: create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS bug16211_db1|
+--enable_warnings
+
+CREATE DATABASE bug16211_db1 DEFAULT CHARACTER SET utf8|
+
+use bug16211_db1|
+
+# Test case:
+
+#   - Create two stored functions -- with and without explicit CHARSET-clause
+#     for return value;
+
+CREATE FUNCTION bug16211_f1() RETURNS CHAR(10)
+  RETURN ""|
+
+CREATE FUNCTION bug16211_f2() RETURNS CHAR(10) CHARSET koi8r
+  RETURN ""|
+
+#   - Check that CHARSET-clause is specified for the second function;
+
+SHOW CREATE FUNCTION bug16211_f1|
+SHOW CREATE FUNCTION bug16211_f2|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f1"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f2"|
+
+SELECT CHARSET(bug16211_f1())|
+SELECT CHARSET(bug16211_f2())|
+
+#   - Alter database character set.
+
+ALTER DATABASE bug16211_db1 CHARACTER SET cp1251|
+
+#   - Check that CHARSET-clause has not changed.
+
+SHOW CREATE FUNCTION bug16211_f1|
+SHOW CREATE FUNCTION bug16211_f2|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f1"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "bug16211_db1" AND ROUTINE_NAME = "bug16211_f2"|
+
+SELECT CHARSET(bug16211_f1())|
+SELECT CHARSET(bug16211_f2())|
+
+# Cleanup.
+
+use test|
+
+DROP DATABASE bug16211_db1|
+
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings

--- 1.113/sql/sp.cc	2006-07-18 20:37:45 +04:00
+++ 1.114/sql/sp.cc	2006-07-18 20:37:45 +04:00
@@ -495,6 +495,13 @@ sp_returns_type(THD *thd, String &result
   table.s = &table.share_not_to_be_used;
   field= sp->create_result_field(0, 0, &table);
   field->sql_type(result);
+
+  if (field->has_charset() &&
sp->m_return_field_def.charset_clause_specified)
+  {
+    result.append(STRING_WITH_LEN(" CHARSET "));
+    result.append(field->charset()->csname);
+  }
+
   delete field;
 }
 
@@ -974,6 +981,11 @@ sp_find_routine(THD *thd, int type, sp_n
     sp_head *new_sp;
     const char *returns= "";
     char definer[USER_HOST_BUFF_SIZE];
+
+    /*
+      String buffer for RETURNS data type must have system charset;
+      64 -- size of "returns" column of mysql.proc.
+    */
     String retstr(64);
 
     DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp));

--- 1.219/sql/sp_head.cc	2006-07-18 20:37:45 +04:00
+++ 1.220/sql/sp_head.cc	2006-07-18 20:37:45 +04:00
@@ -1867,6 +1867,8 @@ sp_head::fill_field_definition(THD *thd,
                       lex->uint_geom_type))
     return TRUE;
 
+  field_def->charset_clause_specified= lex->charset != NULL;
+
   if (field_def->interval_list.elements)
     field_def->interval= create_typelib(mem_root, field_def,
                                         &field_def->interval_list);
Thread
bk commit into 5.0 tree (anozdrin:1.2237) BUG#16211Alexander Nozdrin18 Jul