Skip to content

Commit b845ba2

Browse files
author
Tor Didriksen
committed
WL#14467: Isolate character set and collation library
The patch is intended to make libstrings, the character set and collation library, an independent self-contained library suitable for use in separate projects where the whole mysys is not needed or is not welcome. API changes =========== - include/m_ctype.h + m_ctype.h is a C++ source file for a long time, so, C-specific code has been removed/converted. + Error message data has been extracted from MY_CHARSET_LOADER into MY_CHARSET_ERRMSG + MY_CHARSET_LOADER has been converted into a C++ abstract interface structure. - include/my_sys.h + all_charsets[] has made an array of constant pointers (was not constant). + The variadic type my_error_reporter of the my_charset_error_reporter callback has been replaced with my_error_vreporter (the latest expects va_list instead of ellipsis). + my_charset_loader_init_mysys() has been removed. + my_collation_get_by_name() and my_charset_get_by_name() have been changed to return error messages via MY_CHARSET_ERRMSG instead of MY_CHARSET_LOADER. Behavior changes ================ - On-demand initialization of lexer tables (former lex_init() and hint_lex_init_maps()). Locks ===== - Global mutex THR_LOCK_charset has been replaced with a local std::mutex. Use cases of new API in server sources ====================================== - Lexer: new API call instead of get_charset_by_csname(). Added to public API =================== - include/mysql/strings/collations.h: new public API of libstring - include/mysql/attribute.h: public version of MY_ATTRIBUTE - include/mysql/declspec.h: public version of MYSQL_PLUGIN_IMPORT Moved to public API =================== - include/mysql/strings/m_ctype.h - include/mysql/my_loglevel.h New important files =================== - strings/collations.cc: hides interactions with implementation internals (i.e. with strings/collations_internal.{h,cc}) Change-Id: I95ab120ab32f8f1225cda9b5837c8b53c9b9c4a4
1 parent 6aac738 commit b845ba2

File tree

914 files changed

+9432
-6648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

914 files changed

+9432
-6648
lines changed

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,17 @@ ADD_DEFINITIONS(-D__STDC_FORMAT_MACROS) # Enable C99 printf format macros
15761576
ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # Get access to M_PI, M_E, etc. in math.h
15771577
ADD_DEFINITIONS(-DLZ4_DISABLE_DEPRECATE_WARNINGS) # C++14 deprecation warnings in LZ4.
15781578

1579+
# Force the same macro definition MYSQL_PROJECT for all source files being
1580+
# compiled as a part of the MySQL server, client tools, libraries etc.
1581+
# The MYSQL_PROJECT macro helps to distinguish when e.g. some C++ header file
1582+
# is included by the MySQL project source file or by the external project
1583+
# source file.
1584+
# For example, MYSQL_PROJECT helps to detect when include/mysql/strings/api.h
1585+
# is used to a) build a static library, or b) build a Windows DLL, or
1586+
# c) reference the server strings API from plugins (DLLs) loaded by the
1587+
# MySQL server, or d) reference the libstrings DLL from external executables.
1588+
ADD_DEFINITIONS(-DMYSQL_PROJECT)
1589+
15791590
OPTION(ENABLE_EXPERIMENT_SYSVARS "Expose ussually hidden system variables to allow experiments" OFF)
15801591
IF(ENABLE_EXPERIMENT_SYSVARS)
15811592
ADD_DEFINITIONS(-DENABLE_EXPERIMENT_SYSVARS)
@@ -2222,6 +2233,13 @@ IF(NOT WITHOUT_SERVER AND WITH_UNIT_TESTS)
22222233
# If some symbols are still missing, they will be picked up from
22232234
# dependent libraries, since we LINK_PUBLIC.
22242235
# To see what symbols we need to import, remove LINK_PUBLIC above.
2236+
#
2237+
# The strings library uses visibility=hidden for all symbols,
2238+
# except those explicitly tagged with MYSQL_STRINGS_EXPORT.
2239+
# If we get ODR violations for executables using server_unittest_library,
2240+
# it means the symbol has been found in strings and
2241+
# server_unittest_library, which means the unit test is using
2242+
# some non-exported symbol from strings.
22252243
EXPORTS
22262244
builtin_perfschema_plugin # Pulls in the whole server.
22272245
mysql_service_mysql_rwlock_v1 # Pulls in minchassis

client/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ MERGE_CONVENIENCE_LIBRARIES(json_binlog_static
176176
MYSQL_ADD_EXECUTABLE(json_client_library_main
177177
json_client_library_main.cc
178178
INCLUDE_DIRECTORIES ../sql
179-
LINK_LIBRARIES json_client_library strings
179+
LINK_LIBRARIES json_client_library strings mysys
180180
SKIP_INSTALL
181181
)
182182

client/base/abstract_connection_program.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "client/base/abstract_connection_program.h"
2626

27+
struct CHARSET_INFO;
28+
2729
using namespace Mysql::Tools::Base;
2830

2931
Abstract_connection_program::Abstract_connection_program()
@@ -41,4 +43,4 @@ CHARSET_INFO *Abstract_connection_program::get_current_charset() const {
4143

4244
void Abstract_connection_program::set_current_charset(CHARSET_INFO *charset) {
4345
m_connection_options.set_current_charset(charset);
44-
}
46+
}

client/base/abstract_connection_program.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "client/base/mysql_connection_options.h"
3535
#include "client/client_priv.h"
3636

37+
struct CHARSET_INFO;
38+
3739
namespace Mysql {
3840
namespace Tools {
3941
namespace Base {

client/base/message_data.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#include "client/base/message_data.h"
2626
#include "errmsg.h"
2727

28-
#include "m_ctype.h"
28+
#include "mysql/strings/m_ctype.h"
2929
#include "sql_string.h"
30+
#include "template_utils.h"
3031

3132
using namespace Mysql::Tools::Base;
3233

client/base/mysql_connection_options.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
#include "client/base/abstract_options_provider.h"
3535
#include "client/base/abstract_program.h"
3636
#include "compression.h"
37-
#include "m_ctype.h"
37+
#include "m_string.h"
3838
#include "multi_factor_passwordopt-vars.h"
39+
#include "mysql/strings/m_ctype.h"
3940
#include "mysys_err.h"
41+
#include "nulls.h"
4042
#include "typelib.h"
4143

4244
using Mysql::Tools::Base::Abstract_program;

client/base/mysql_connection_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "my_compiler.h"
3636
#include "my_inttypes.h"
3737

38+
struct CHARSET_INFO;
39+
3840
namespace Mysql {
3941
namespace Tools {
4042
namespace Base {

client/base/mysql_query_runner.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <atomic>
3030
#include <functional>
3131

32-
#include "m_ctype.h"
32+
#include "mysql/strings/m_ctype.h"
3333
#include "sql_string.h"
3434
#include "template_utils.h"
3535

client/check/mysqlcheck.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
#include "caching_sha2_passwordopt-vars.h"
3232
#include "client/client_priv.h"
3333
#include "compression.h"
34-
#include "m_ctype.h"
3534
#include "my_alloc.h"
3635
#include "my_dbug.h"
3736
#include "my_default.h"
3837
#include "my_inttypes.h"
3938
#include "my_macros.h"
4039
#include "mysql/service_mysql_alloc.h"
40+
#include "mysql/strings/m_ctype.h"
41+
#include "nulls.h"
4142
#include "print_version.h"
4243
#include "sslopt-vars.h"
4344
#include "typelib.h"

client/check/mysqlcheck_core.cc

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030

3131
#include "client/check/mysqlcheck.h"
3232
#include "client/client_priv.h"
33-
#include "m_ctype.h"
33+
#include "m_string.h"
3434
#include "my_default.h"
3535
#include "my_inttypes.h"
36+
#include "mysql/strings/m_ctype.h"
3637

3738
using namespace Mysql::Tools::Check;
3839

@@ -354,15 +355,18 @@ static void print_result() {
354355
mysql_free_result(res);
355356
}
356357

357-
void Mysql::Tools::Check::mysql_check(
358-
MYSQL *connection, int what_to_do, bool opt_alldbs,
359-
bool opt_check_only_changed, bool opt_extended, bool opt_databases,
360-
bool opt_fast, bool opt_medium_check, bool opt_quick, bool opt_all_in_1,
361-
bool opt_silent, bool opt_auto_repair, bool ignore_errors, bool opt_frm,
362-
bool opt_fix_table_names, bool opt_fix_db_names, bool opt_upgrade,
363-
bool opt_write_binlog, uint verbose, std::string opt_skip_database,
364-
std::vector<std::string> arguments,
365-
void (*dberror)(MYSQL *mysql, const std::string &when)) {
358+
namespace Mysql::Tools::Check {
359+
360+
void mysql_check(MYSQL *connection, int what_to_do, bool opt_alldbs,
361+
bool opt_check_only_changed, bool opt_extended,
362+
bool opt_databases, bool opt_fast, bool opt_medium_check,
363+
bool opt_quick, bool opt_all_in_1, bool opt_silent,
364+
bool opt_auto_repair, bool ignore_errors, bool opt_frm,
365+
bool opt_fix_table_names, bool opt_fix_db_names,
366+
bool opt_upgrade, bool opt_write_binlog, uint verbose,
367+
std::string opt_skip_database,
368+
std::vector<std::string> arguments,
369+
void (*dberror)(MYSQL *mysql, const std::string &when)) {
366370
::sock = connection;
367371
::what_to_do = what_to_do;
368372
::opt_alldbs = opt_alldbs;
@@ -419,6 +423,8 @@ void Mysql::Tools::Check::mysql_check(
419423
}
420424
}
421425

426+
} // namespace Mysql::Tools::Check
427+
422428
Program::Program()
423429
: m_what_to_do(0),
424430
m_auto_repair(false),

0 commit comments

Comments
 (0)