Skip to content

Commit dddd0ec

Browse files
ivo-roylevdahlerlend
authored andcommitted
WL#16824 Binary Libraries Server support.
Have the SQL Parser accept hex literals. SHOW CREATE LIBRARY with hex literals. Component Services. Change-Id: I3107bd07e21ea3955fe19945127e32c4a7f221d6
1 parent 8e01805 commit dddd0ec

19 files changed

+427
-45
lines changed

include/mysql/components/services/language_service.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,33 @@ DECLARE_BOOL_METHOD(parse, (mysql_cstring_with_length name,
181181

182182
END_SERVICE_DEFINITION(external_library)
183183

184+
/**
185+
@ingroup group_components_services_inventory
186+
187+
A service to parse library code in either UTF8 or BINARY character set.
188+
*/
189+
BEGIN_SERVICE_DEFINITION(external_library_ext)
190+
191+
/**
192+
Parses library code.
193+
194+
@param [in] name Name of the library.
195+
@param [in] language Language of the library source code.
196+
@param [in] body Library's source code in provided charset.
197+
@param [in] is_binary Is the library body stored with a binary character
198+
set?
199+
@param [out] result True if the parse succeeds.
200+
False if the library cannot be parsed.
201+
202+
@return Status of the performed operation.
203+
@retval false success.
204+
@retval true failure.
205+
*/
206+
DECLARE_BOOL_METHOD(parse, (mysql_cstring_with_length name,
207+
mysql_cstring_with_length language,
208+
mysql_cstring_with_length body, bool is_binary,
209+
bool *result));
210+
211+
END_SERVICE_DEFINITION(external_library_ext)
212+
184213
#endif /* LANGUAGE_SERVICE_GUARD */
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* Copyright (c) 2025, Oracle and/or its affiliates.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License, version 2.0,
5+
as published by the Free Software Foundation.
6+
7+
This program is designed to work with certain software (including
8+
but not limited to OpenSSL) that is licensed under separate terms,
9+
as designated in a particular file or component or in included license
10+
documentation. The authors of MySQL hereby grant you an additional
11+
permission to link the program and your derivative works with the
12+
separately licensed software that they have either included with
13+
the program or referenced in the documentation.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License, version 2.0, for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23+
24+
#ifndef MYSQL_LIBRARY_EXT_H
25+
#define MYSQL_LIBRARY_EXT_H
26+
27+
#include <mysql/components/service.h>
28+
#include "defs/mysql_string_defs.h"
29+
30+
DEFINE_SERVICE_HANDLE(my_h_library);
31+
32+
/**
33+
Services for reading the properties of the Libraries that are imported
34+
by the routines.
35+
36+
How to use:
37+
my_h_library library_handle;
38+
library->init(nullptr, schema, name, version, &library_handle);
39+
mysql_cstring_with_length body;
40+
bool is_binary;
41+
library_ext->get_body(library_handle, &is_binary);
42+
// ... use the body throughout the caller.
43+
library->deinit(library_handle);
44+
*/
45+
BEGIN_SERVICE_DEFINITION(mysql_library_ext)
46+
47+
/**
48+
Get library's body.
49+
50+
@param [in] library_handle Handle to library.
51+
@param [out] body Library's body.
52+
@param [out] is_binary Is the library body stored with a binary
53+
character set?
54+
55+
@note: The returned Library's body is valid only while the library_handle
56+
is valid.
57+
58+
@returns Status of get operation:
59+
@retval false Success.
60+
@retval true Failure.
61+
*/
62+
DECLARE_BOOL_METHOD(get_body,
63+
(my_h_library library_handle,
64+
mysql_cstring_with_length *body, bool *is_binary));
65+
66+
END_SERVICE_DEFINITION(mysql_library_ext)
67+
68+
#endif /* MYSQL_LIBRARY_EXT_H */

mysql-test/r/mysqldump-library.result

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ USING (mysqldump_test_db.sp1)
1010
as " return sp1.f(n) ";
1111
set sql_mode=ansi_quotes;
1212
create library mysqldump_test_db.`ansi"_"quoted"` LANGUAGE JAVASCRIPT AS $$ export function f(n) { return n+1 } $$;
13+
create library mysqldump_test_db.binary_library_hex LANGUAGE WASM
14+
COMMENT 'A binary library stored in binary encoding'
15+
AS X'7072696E7466282754686973206973205741534D27293B';
1316
create function mysqldump_test_db.`ansi"_"quoted"`(n INTEGER) RETURNS INTEGER LANGUAGE JAVASCRIPT
1417
USING (mysqldump_test_db.`ansi"_"quoted"` as lib, mysqldump_test_db.sp1)
1518
as $$ return lib.f(n) $$;
@@ -46,6 +49,16 @@ CREATE LIBRARY "ansi""_""quoted"""
4649
AS $$ export function f(n) { return n+1 } $$ ;;
4750
DELIMITER ;
4851
/*!50003 SET sql_mode = @saved_sql_mode */ ;
52+
DROP LIBRARY IF EXISTS `binary_library_hex`;
53+
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
54+
/*!50003 SET sql_mode = 'ANSI_QUOTES' */ ;
55+
DELIMITER ;;
56+
CREATE LIBRARY "binary_library_hex"
57+
COMMENT 'A binary library stored in binary encoding'
58+
LANGUAGE WASM
59+
AS 0x7072696E7466282754686973206973205741534D27293B ;;
60+
DELIMITER ;
61+
/*!50003 SET sql_mode = @saved_sql_mode */ ;
4962
DROP LIBRARY IF EXISTS `sp1`;
5063
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
5164
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
@@ -131,6 +144,14 @@ DELIMITER ;
131144
CREATE LIBRARY "ansi""_""quoted"""
132145
LANGUAGE JAVASCRIPT
133146
AS $$ export function f(n) { return n+1 } $$
147+
]]>
148+
</library>
149+
<library Library="binary_library_hex" sql_mode="ANSI_QUOTES">
150+
<![CDATA[
151+
CREATE LIBRARY "binary_library_hex"
152+
COMMENT 'A binary library stored in binary encoding'
153+
LANGUAGE WASM
154+
AS 0x7072696E7466282754686973206973205741534D27293B
134155
]]>
135156
</library>
136157
<library Library="sp1" sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION">
@@ -172,6 +193,7 @@ drop function mysqldump_test_db.sp1;
172193
drop function mysqldump_test_db.`ansi"_"quoted"`;
173194
drop library mysqldump_test_db.`ansi"_"quoted"`;
174195
drop library mysqldump_test_db.sp1;
196+
drop library mysqldump_test_db.binary_library_hex;
175197
SELECT * FROM INFORMATION_SCHEMA.ROUTINE_LIBRARIES
176198
WHERE ROUTINE_SCHEMA = 'mysqldump_test_db'
177199
ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, LIBRARY_CATALOG, LIBRARY_SCHEMA, LIBRARY_NAME, LIBRARY_VERSION;
@@ -200,6 +222,12 @@ Library sql_mode Create Library
200222
ansi"_"quoted" ANSI_QUOTES CREATE LIBRARY "ansi""_""quoted"""
201223
LANGUAGE JAVASCRIPT
202224
AS $$ export function f(n) { return n+1 } $$
225+
show create library mysqldump_test_db.binary_library_hex;
226+
Library sql_mode Create Library
227+
binary_library_hex ANSI_QUOTES CREATE LIBRARY "binary_library_hex"
228+
COMMENT 'A binary library stored in binary encoding'
229+
LANGUAGE WASM
230+
AS 0x7072696E7466282754686973206973205741534D27293B
203231
SELECT * FROM INFORMATION_SCHEMA.ROUTINE_LIBRARIES
204232
WHERE ROUTINE_SCHEMA = 'mysqldump_test_db'
205233
ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, LIBRARY_CATALOG, LIBRARY_SCHEMA, LIBRARY_NAME, LIBRARY_VERSION;

mysql-test/r/sp-library-binary.result

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# WL#16824: WASM library server support.
3+
#
4+
CREATE LIBRARY binary_library_utf8 LANGUAGE WASM
5+
AS $$cHJpbnRmKCdUaGlzIGlzIFdBU00nKTs=$$;
6+
Warnings:
7+
Warning 6001 Language component: Not available.
8+
SHOW CREATE LIBRARY binary_library_utf8;
9+
Library sql_mode Create Library
10+
binary_library_utf8 ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE LIBRARY `binary_library_utf8`
11+
LANGUAGE WASM
12+
AS $$cHJpbnRmKCdUaGlzIGlzIFdBU00nKTs=$$
13+
ALTER LIBRARY binary_library_utf8 COMMENT 'A binary library stored in UTF8 encoding.';
14+
CREATE LIBRARY binary_library_hex LANGUAGE WASM
15+
COMMENT 'A binary library stored in binary encoding'
16+
AS 0x7072696E7466282754686973206973205741534D27293B;
17+
Warnings:
18+
Warning 6001 Language component: Not available.
19+
SHOW CREATE LIBRARY binary_library_hex;
20+
Library sql_mode Create Library
21+
binary_library_hex ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE LIBRARY `binary_library_hex`
22+
COMMENT 'A binary library stored in binary encoding'
23+
LANGUAGE WASM
24+
AS 0x7072696E7466282754686973206973205741534D27293B
25+
ALTER LIBRARY binary_library_hex COMMENT 'A binary library stored in BINARY encoding.';
26+
CREATE LIBRARY binary_library_quotes LANGUAGE WASM
27+
COMMENT 'A binary library stored in binary encoding'
28+
AS _binary X'7072696E7466282754686973206973205741534D20776974682071756F74657327293B';
29+
Warnings:
30+
Warning 6001 Language component: Not available.
31+
SHOW CREATE LIBRARY binary_library_quotes;
32+
Library sql_mode Create Library
33+
binary_library_quotes ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE LIBRARY `binary_library_quotes`
34+
COMMENT 'A binary library stored in binary encoding'
35+
LANGUAGE WASM
36+
AS 0x7072696E7466282754686973206973205741534D20776974682071756F74657327293B
37+
CREATE LIBRARY binary_library_binary LANGUAGE WASM
38+
COMMENT 'A binary library stored in binary encoding'
39+
AS _binary b'111000011100101101001110111011101001100110101000100111101010011010001101001111001110000011010011110011100000101011110000011010011100110110000011010011101110100000110001011010011101110110000111100101111001100111101001111011';
40+
Warnings:
41+
Warning 6001 Language component: Not available.
42+
SHOW CREATE LIBRARY binary_library_binary;
43+
Library sql_mode Create Library
44+
binary_library_binary ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION CREATE LIBRARY `binary_library_binary`
45+
COMMENT 'A binary library stored in binary encoding'
46+
LANGUAGE WASM
47+
AS 0x3872FFFFFFD3FFFFFFBBFFFFFFA66A27FFFFFFA9FFFFFFA34F3834FFFFFFF3FFFFFF82FFFFFFBC1A7360FFFFFFD3FFFFFFBA0C5A7761FFFFFFE5FFFFFFE67A7B
48+
# Negative tests:
49+
CREATE LIBRARY binary_library_binary_neg LANGUAGE WASM
50+
AS _binary b'01210';
51+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b'01210'' at line 2
52+
CREATE LIBRARY binary_library_hex_neg LANGUAGE WASM
53+
AS _binary X'ABCDEFGH';
54+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'X'ABCDEFGH'' at line 2
55+
CREATE LIBRARY binary_library_null LANGUAGE WASM
56+
AS _binary NULL;
57+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 2
58+
CREATE LIBRARY binary_library_null LANGUAGE WASM
59+
AS NULL;
60+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 2
61+
CREATE LIBRARY binary_library_neg LANGUAGE WASM
62+
AS 0xABCDEFGH;
63+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0xABCDEFGH' at line 2
64+
CREATE LIBRARY binary_library_neg LANGUAGE WASM
65+
AS 'This is not Base64 encoded text';
66+
Warnings:
67+
Warning 6001 Language component: Not available.
68+
SELECT * FROM INFORMATION_SCHEMA.LIBRARIES
69+
WHERE LIBRARY_SCHEMA = 'test'
70+
ORDER BY LIBRARY_NAME;
71+
LIBRARY_CATALOG LIBRARY_SCHEMA LIBRARY_NAME LIBRARY_DEFINITION LANGUAGE CREATED LAST_ALTERED SQL_MODE LIBRARY_COMMENT CREATOR
72+
def test binary_library_binary WASM <created> <modified> ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION A binary library stored in binary encoding root@localhost
73+
def test binary_library_hex WASM <created> <modified> ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION A binary library stored in BINARY encoding. root@localhost
74+
def test binary_library_neg This is not Base64 encoded text WASM <created> <modified> ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION root@localhost
75+
def test binary_library_quotes WASM <created> <modified> ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION A binary library stored in binary encoding root@localhost
76+
def test binary_library_utf8 cHJpbnRmKCdUaGlzIGlzIFdBU00nKTs= WASM <created> <modified> ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION A binary library stored in UTF8 encoding. root@localhost
77+
SHOW LIBRARY STATUS like 'binary_library_%';
78+
Db Name Language Creator Modified Created Comment
79+
test binary_library_binary WASM root@localhost <modified> <created> A binary library stored in binary encoding
80+
test binary_library_hex WASM root@localhost <modified> <created> A binary library stored in BINARY encoding.
81+
test binary_library_neg WASM root@localhost <modified> <created>
82+
test binary_library_quotes WASM root@localhost <modified> <created> A binary library stored in binary encoding
83+
test binary_library_utf8 WASM root@localhost <modified> <created> A binary library stored in UTF8 encoding.
84+
# Cleanup.
85+
DROP LIBRARY binary_library_neg;
86+
DROP LIBRARY binary_library_binary;
87+
DROP LIBRARY binary_library_quotes;
88+
DROP LIBRARY binary_library_hex;
89+
DROP LIBRARY binary_library_utf8;
90+
SELECT * FROM INFORMATION_SCHEMA.LIBRARIES
91+
WHERE LIBRARY_SCHEMA = 'test';
92+
LIBRARY_CATALOG LIBRARY_SCHEMA LIBRARY_NAME LIBRARY_DEFINITION LANGUAGE CREATED LAST_ALTERED SQL_MODE LIBRARY_COMMENT CREATOR

mysql-test/t/mysqldump-library.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ USING (mysqldump_test_db.sp1)
2424
as " return sp1.f(n) ";
2525
set sql_mode=ansi_quotes;
2626
create library mysqldump_test_db.`ansi"_"quoted"` LANGUAGE JAVASCRIPT AS $$ export function f(n) { return n+1 } $$;
27+
create library mysqldump_test_db.binary_library_hex LANGUAGE WASM
28+
COMMENT 'A binary library stored in binary encoding'
29+
AS X'7072696E7466282754686973206973205741534D27293B';
2730
create function mysqldump_test_db.`ansi"_"quoted"`(n INTEGER) RETURNS INTEGER LANGUAGE JAVASCRIPT
2831
USING (mysqldump_test_db.`ansi"_"quoted"` as lib, mysqldump_test_db.sp1)
2932
as $$ return lib.f(n) $$;
@@ -45,6 +48,7 @@ drop function mysqldump_test_db.sp1;
4548
drop function mysqldump_test_db.`ansi"_"quoted"`;
4649
drop library mysqldump_test_db.`ansi"_"quoted"`;
4750
drop library mysqldump_test_db.sp1;
51+
drop library mysqldump_test_db.binary_library_hex;
4852
SELECT * FROM INFORMATION_SCHEMA.ROUTINE_LIBRARIES
4953
WHERE ROUTINE_SCHEMA = 'mysqldump_test_db'
5054
ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, LIBRARY_CATALOG, LIBRARY_SCHEMA, LIBRARY_NAME, LIBRARY_VERSION;
@@ -55,6 +59,7 @@ show create function mysqldump_test_db.sp1;
5559
show create library mysqldump_test_db.sp1;
5660
show create function mysqldump_test_db.`ansi"_"quoted"`;
5761
show create library mysqldump_test_db.`ansi"_"quoted"`;
62+
show create library mysqldump_test_db.binary_library_hex;
5863
SELECT * FROM INFORMATION_SCHEMA.ROUTINE_LIBRARIES
5964
WHERE ROUTINE_SCHEMA = 'mysqldump_test_db'
6065
ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, LIBRARY_CATALOG, LIBRARY_SCHEMA, LIBRARY_NAME, LIBRARY_VERSION;

mysql-test/t/sp-library-binary.test

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--echo #
2+
--echo # WL#16824: WASM library server support.
3+
--echo #
4+
5+
CREATE LIBRARY binary_library_utf8 LANGUAGE WASM
6+
AS $$cHJpbnRmKCdUaGlzIGlzIFdBU00nKTs=$$;
7+
SHOW CREATE LIBRARY binary_library_utf8;
8+
ALTER LIBRARY binary_library_utf8 COMMENT 'A binary library stored in UTF8 encoding.';
9+
10+
CREATE LIBRARY binary_library_hex LANGUAGE WASM
11+
COMMENT 'A binary library stored in binary encoding'
12+
AS 0x7072696E7466282754686973206973205741534D27293B;
13+
SHOW CREATE LIBRARY binary_library_hex;
14+
ALTER LIBRARY binary_library_hex COMMENT 'A binary library stored in BINARY encoding.';
15+
16+
CREATE LIBRARY binary_library_quotes LANGUAGE WASM
17+
COMMENT 'A binary library stored in binary encoding'
18+
AS _binary X'7072696E7466282754686973206973205741534D20776974682071756F74657327293B';
19+
SHOW CREATE LIBRARY binary_library_quotes;
20+
21+
CREATE LIBRARY binary_library_binary LANGUAGE WASM
22+
COMMENT 'A binary library stored in binary encoding'
23+
AS _binary b'111000011100101101001110111011101001100110101000100111101010011010001101001111001110000011010011110011100000101011110000011010011100110110000011010011101110100000110001011010011101110110000111100101111001100111101001111011';
24+
SHOW CREATE LIBRARY binary_library_binary;
25+
26+
--echo # Negative tests:
27+
--error ER_PARSE_ERROR
28+
CREATE LIBRARY binary_library_binary_neg LANGUAGE WASM
29+
AS _binary b'01210';
30+
--error ER_PARSE_ERROR
31+
CREATE LIBRARY binary_library_hex_neg LANGUAGE WASM
32+
AS _binary X'ABCDEFGH';
33+
--error ER_PARSE_ERROR
34+
CREATE LIBRARY binary_library_null LANGUAGE WASM
35+
AS _binary NULL;
36+
--error ER_PARSE_ERROR
37+
CREATE LIBRARY binary_library_null LANGUAGE WASM
38+
AS NULL;
39+
--error ER_PARSE_ERROR
40+
CREATE LIBRARY binary_library_neg LANGUAGE WASM
41+
AS 0xABCDEFGH;
42+
CREATE LIBRARY binary_library_neg LANGUAGE WASM
43+
AS 'This is not Base64 encoded text';
44+
45+
--replace_column 6 <created> 7 <modified>
46+
SELECT * FROM INFORMATION_SCHEMA.LIBRARIES
47+
WHERE LIBRARY_SCHEMA = 'test'
48+
ORDER BY LIBRARY_NAME;
49+
50+
--sorted_result
51+
--replace_column 5 <modified> 6 <created>
52+
SHOW LIBRARY STATUS like 'binary_library_%';
53+
54+
--echo # Cleanup.
55+
56+
DROP LIBRARY binary_library_neg;
57+
DROP LIBRARY binary_library_binary;
58+
DROP LIBRARY binary_library_quotes;
59+
DROP LIBRARY binary_library_hex;
60+
DROP LIBRARY binary_library_utf8;
61+
62+
SELECT * FROM INFORMATION_SCHEMA.LIBRARIES
63+
WHERE LIBRARY_SCHEMA = 'test';
64+

sql/dd/dd_routine.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,11 @@ static bool fill_dd_library_info(sp_head *sp, const LEX_USER *definer,
539539
// Set comment.
540540
library->set_comment(sp->m_chistics->comment.str ? sp->m_chistics->comment.str
541541
: "");
542+
// Set the binary character set.
543+
if (sp->m_chistics->is_binary)
544+
library->set_client_collation_id(my_charset_bin.number);
545+
else
546+
library->set_client_collation_id(my_charset_utf8mb4_0900_ai_ci.number);
542547

543548
return false;
544549
}

sql/dd/impl/types/library_impl.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Library_impl::Library_impl() {
3939
Routine_impl::set_deterministic(false);
4040
Routine_impl::set_sql_data_access(SDA_CONTAINS_SQL);
4141
Routine_impl::set_security_type(View::ST_INVOKER);
42-
Routine_impl::set_client_collation_id(my_charset_utf8mb4_0900_ai_ci.number);
4342
Routine_impl::set_connection_collation_id(
4443
my_charset_utf8mb4_0900_ai_ci.number);
4544
Routine_impl::set_schema_collation_id(my_charset_utf8mb4_0900_ai_ci.number);

sql/dd/impl/types/library_impl.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class Library_impl : public Routine_impl, public Library {
159159
bool set_options(const String_type &options_raw) override {
160160
return Routine_impl::set_options(options_raw);
161161
}
162+
void set_client_collation_id(Object_id client_collation_id) override {
163+
Routine_impl::set_client_collation_id(client_collation_id);
164+
}
162165

163166
// Disabled functions that do not make sense for a library.
164167

@@ -194,12 +197,6 @@ class Library_impl : public Routine_impl, public Library {
194197
// collation.
195198
/////////////////////////////////////////////////////////////////////////
196199

197-
void set_client_collation_id(Object_id client_collation_id
198-
[[maybe_unused]]) override {
199-
// Setting this attribute is not allowed for the Library.
200-
assert(false);
201-
}
202-
203200
void set_connection_collation_id(Object_id connection_collation_id
204201
[[maybe_unused]]) override {
205202
// Setting this attribute is not allowed for the Library.

0 commit comments

Comments
 (0)