1drop function if exists bug17615|
2create table t3 (a varchar(256) unicode)|
3create function bug17615() returns varchar(256) unicode
4begin
5declare tmp_res varchar(256) unicode;
6set tmp_res= 'foo string';
7return tmp_res;
8end|
9insert into t3 values(bug17615())|
10select * from t3|
11a
12foo string
13drop function bug17615|
14drop table t3|
15CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci)
16RETURNS VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_danish_ci
17BEGIN
18DECLARE f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_swedish_ci;
19DECLARE f3 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_bin;
20SET f1= concat(collation(f1), ' ', collation(f2), ' ', collation(f3));
21RETURN f1;
22END|
23SELECT f('a')|
24f('a')
25ucs2_unicode_ci ucs2_swedish_ci ucs2_bin
26SELECT collation(f('a'))|
27collation(f('a'))
28ucs2_danish_ci
29DROP FUNCTION f|
30CREATE FUNCTION f()
31RETURNS VARCHAR(64) UNICODE BINARY
32BEGIN
33RETURN '';
34END|
35SHOW CREATE FUNCTION f;
36DROP FUNCTION f;
37CREATE FUNCTION f()
38RETURNS VARCHAR(64) BINARY UNICODE
39BEGIN
40RETURN '';
41END|
42Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
43f	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION	CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin
44BEGIN
45RETURN '';
46END	latin1	latin1_swedish_ci	latin1_swedish_ci
47SHOW CREATE FUNCTION f;
48DROP FUNCTION f;
49#
50# Testing keywords ASCII + BINARY
51#
52CREATE FUNCTION f()
53RETURNS VARCHAR(64) ASCII BINARY
54BEGIN
55RETURN '';
56END|
57Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
58f	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION	CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin
59BEGIN
60RETURN '';
61END	latin1	latin1_swedish_ci	latin1_swedish_ci
62SHOW CREATE FUNCTION f;
63DROP FUNCTION f;
64CREATE FUNCTION f()
65RETURNS VARCHAR(64) BINARY ASCII
66BEGIN
67RETURN '';
68END|
69Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
70f	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION	CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin
71BEGIN
72RETURN '';
73END	latin1	latin1_swedish_ci	latin1_swedish_ci
74SHOW CREATE FUNCTION f;
75DROP FUNCTION f;
76#
77# Testing COLLATE in OUT parameter
78#
79CREATE PROCEDURE p1(IN  f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci,
80OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci)
81BEGIN
82SET f2= f1;
83SET f2= concat(collation(f1), ' ', collation(f2));
84END|
85Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
86f	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION	CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin
87BEGIN
88RETURN '';
89END	latin1	latin1_swedish_ci	latin1_swedish_ci
90CREATE FUNCTION f1()
91RETURNS VARCHAR(64) CHARACTER SET ucs2
92BEGIN
93DECLARE f1 VARCHAR(64) CHARACTER SET ucs2;
94DECLARE f2 VARCHAR(64) CHARACTER SET ucs2;
95SET f1='str';
96CALL p1(f1, f2);
97RETURN f2;
98END|
99SELECT f1()|
100f1()
101ucs2_czech_ci ucs2_polish_ci
102DROP PROCEDURE p1|
103DROP FUNCTION f1|
104CREATE FUNCTION f(f1 VARCHAR(64) COLLATE ucs2_unicode_ci)
105RETURNS VARCHAR(64) CHARACTER SET ucs2
106BEGIN
107RETURN 'str';
108END|
109ERROR 42000: This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'
110CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2)
111RETURNS VARCHAR(64) COLLATE ucs2_unicode_ci
112BEGIN
113RETURN 'str';
114END|
115ERROR 42000: This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'
116CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2)
117RETURNS VARCHAR(64) CHARACTER SET ucs2
118BEGIN
119DECLARE f2 VARCHAR(64) COLLATE ucs2_unicode_ci;
120RETURN 'str';
121END|
122ERROR 42000: This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'
123SET NAMES utf8;
124DROP FUNCTION IF EXISTS bug48766;
125CREATE FUNCTION bug48766 ()
126RETURNS ENUM( 'w' ) CHARACTER SET ucs2
127RETURN 0;
128SHOW CREATE FUNCTION bug48766;
129Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
130bug48766	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION	CREATE DEFINER=`root`@`localhost` FUNCTION `bug48766`() RETURNS enum('w') CHARSET ucs2
131RETURN 0	utf8	utf8_general_ci	latin1_swedish_ci
132SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES
133WHERE ROUTINE_NAME='bug48766';
134DTD_IDENTIFIER
135enum('w')
136DROP FUNCTION bug48766;
137CREATE FUNCTION bug48766 ()
138RETURNS ENUM('а','б','в','г') CHARACTER SET ucs2
139RETURN 0;
140SHOW CREATE FUNCTION bug48766;
141Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
142bug48766	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION	CREATE DEFINER=`root`@`localhost` FUNCTION `bug48766`() RETURNS enum('а','б','в','г') CHARSET ucs2
143RETURN 0	utf8	utf8_general_ci	latin1_swedish_ci
144SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES
145WHERE ROUTINE_NAME='bug48766';
146DTD_IDENTIFIER
147enum('а','б','в','г')
148DROP FUNCTION bug48766;
149