Hi,

> Hello.
> 
> This should be fixed in 5.0.18. See:
>   http://bugs.mysql.com/bug.php?id=13909

17.2.1. CREATE PROCEDURE and CREATE FUNCTION
http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

says ...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 As of MySQL 5.0.18, the server uses the data type of a routine
 parameter or function return value as follows. These rules also apply
 to local routine variables created with the DECLARE statement
 (Section 17.2.9.1, “DECLARE Local Variables”).

    *

      Assignments are checked for data type mismatches and
      overflow. Conversion and overflow problems result in warnings,
      or errors in strict mode.
    *

      For character data types, if there is a CHARACTER SET clause in
      the declaration, the specified character set and its default
      collation are used. If there is no such clause, the database
      character set and collation are used. (These are given by the
      values of the character_set_database and collation_database
      system variables.)
    *

      Only scalar values can be assigned to parameters or
      variables. For example, a statement such as SET x = (SELECT 1,
      2) is invalid.

Before MySQL 5.0.18, parameters, return values, and local variables
are treated as items in expressions, and are subject to automatic
(silent) conversion and truncation. Stored functions ignore the
sql_mode setting. 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I thought that this explanation means function controls CHARACTER SET
clause properly from 5.0.18.

So, I checked on version 5.0.18, but situation is same....


mysql> SELECT VERSION();
+---------------------+
| VERSION()           |
+---------------------+
| 5.0.18-standard-log |
+---------------------+
1 row in set (0.01 sec)
 
mysql> SET NAMES utf8;
Query OK, 0 rows affected (0.00 sec)
 
## I tried to make function tokyo() which returns string 'Tokyo' in
## Japanase. _utf8 X'E69DB1E4BAAC' means Tokyo in Japanese.

mysql> DELIMITER //
mysql> CREATE FUNCTION tokyo() RETURNS VARCHAR(20) CHARACTER SET utf8
    -> DETERMINISTIC RETURN _utf8 X'E69DB1E4BAAC';
    -> //
Query OK, 0 rows affected (0.00 sec)
 
mysql> DELIMITER ;
mysql> SELECT tokyo();
+---------+
| tokyo() |
+---------+
| ??      |
+---------+
1 row in set, 1 warning (0.00 sec)
 
mysql> SELECT HEX(tokyo());
+--------------+
| HEX(tokyo()) |
+--------------+
| 3F3F         |
+--------------+
1 row in set, 1 warning (0.00 sec)
 
mysql> SELECT CHARSET(tokyo());
+------------------+
| CHARSET(tokyo()) |
+------------------+
| binary           |
+------------------+
1 row in set (0.00 sec)
 
mysql> SHOW CREATE FUNCTION tokyo\G
*************************** 1. row ***************************
       Function: tokyo
       sql_mode:
Create Function: CREATE FUNCTION `tokyo`() RETURNS varchar(20)
    DETERMINISTIC
RETURN _utf8 X'E69DB1E4BAAC'
1 row in set (0.00 sec)
 
mysql>


Returned charater type of function is binary.

And, SHOW CREATE FUNCTION removed "CHARACTER SET utf8" part. Why?

------------------------------------------------------------
Hirofumi Fujiwara        [EMAIL PROTECTED], [EMAIL PROTECTED]
Time Intermedia Corporation        http://www.timedia.co.jp/
Corporate Strategy Department & Knowledge Engineering Center
          26-27 Saka-machi Shinjuku-ku, Tokyo 160-0002 Japan
------------------------------------------------------------

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to