INTO CLIENT_ERRORS ARRAY
Analysis:
--------
The client may crash while executing a statement due to
the missing mapping of the server error to it's equivalent
client error.
When trying to reallocate memory for the packet buffer, if
the system is out of memory or the packet buffer is large,
the server errors 'ER_OUT_OF_RESOURCES' or 'ER_PACKET_TOO_LARGE'
is returned respectively. The client error number calculated is
negative and when trying to dereference the array of client
error messages with the calculated error number, the client
crashes.
Fix:
----
Map the server error returned to it's equivalent client error
prior to dereferencing the array of client error messages.
Note: Test case is not added since it is difficult to simulate
the error condition.
MDEV-5763 libmyodbc.so: undefined symbol: int2str
MDEV-5739 Symbol missing in libmysqlclient.so.18 (make_scrambled_password)
pam_mysql and especially myodbc need tons of internal symbols on Debian, argh!
An attempt to introduce libmysqlclient.so symbol versioning that is
compatible both with Debian and Fedora all versions: put all symbols into
libmysqlclient_18 version node (as on Debian), but also put aliases of
old symbols into libmysqlclient_16 version node (as on Fedora).
Also use a linker script to create aliases of exported symbols, not
rpm_support.cc source file.
Backported only the softlink part of the patch,
*not* the bumping of library version.
With this patch, the libmysql/ directory contains:
libmysqlclient.a
libmysqlclient_r.a -> libmysqlclient.a
libmysqlclient_r.so -> libmysqlclient.so*
libmysqlclient_r.so.18 -> libmysqlclient.so.18*
libmysqlclient_r.so.18.0.0 -> libmysqlclient.so.18.0.0*
libmysqlclient.so -> libmysqlclient.so.18*
libmysqlclient.so.18 -> libmysqlclient.so.18.0.0*
libmysqlclient.so.18.0.0*
Cleanup: remove TIME_FUZZY_DATE.
Introduce TIME_FUZZY_DATES which means "very fuzzy, the resulting
value is only used for comparison. It can be invalid date, fine, as long as it can be
compared".
Updated many tests results (they're better now).
The reason is the limitation of ReadConsole() API, it returns error if handle to redirected input is used.
The fix is to use a handle returned by CreateFile("CONIN$",...), rather than GetStdHandle(STD_HANDLE_INPUT) to get the true console handle.
Prior to this patch, _getch() was used to read password input from console. getch() has a property that it reads Ctrl-C as character with ASCII code 0x03, and disregards Ctrl-C handler for current process.
The fix is to use ReadConsole() API instead of getch() , after setting console mode to ENABLE_PROCESSED_INPUT - this mode allows current process to handle Ctrl-C events.
to enable both recompiling mysqli or odbc from sources in addition to drop-in replacement functionality.
The case in question is compiling mysqli from sources, that needs client_errors via ER() macro.
Previously, we exported it as mysql_client_errors (compatibly to Fedora's style symbol renaming, see MDEV-3842).
However, if MariaDB header files are used when compiling mysqli, client_errors needs to be exported with its original name.
Miscellaneous workarounds for drop-in compatibility problems with Linux distributions, arounf versioning of the
MySQL 5.5 client shared library. There seems to be 3 different ways major distributions handle versioning
1. Fedora (also Mageia, and likely other Redhat descendants) way
old, 5.1 API functions are given version libmysqlclient_16
new API functions (client plugins, mysql_stmt_next ) are given version libmysqlclient_18
some extra functions beyond API are exported.
some functions are renamed.
2.Debian Wheezy way
all functions are given libmysqlclient_18 version
3. Ubuntu way (or MySQL/MariaDB download packages)
no versioning
UIp to this fix, MariaDB distributions did not have any versioning in the libraries, this rendered client library incompatible to distributions
thus exchanging distribution's libmysqlclient.so.18.0.0 with MariaDB's did not work nicely (anywhere but on Ubuntu)
THE FIX
is to build libraries the same way as distributions do it
- when building RPMs, use same version script as Fedora does, Make sure to export extra-symbols, the same as Fedora exports.
- when building DEBs, use the same version script as Debian Wheezy
- do not use version scripts otherwise
Also, makes sure that extensions of MySQL APIs (asynchronous client functionality) is exported by the shared libraries.
Problem description: When client loses the connection to the MySQL server or
if the server gets shutdown after mysql_stmt_prepare() then the next
mysql_stmt_prepare() will return an error(as expected) but consecutive call
mysql_stmt_execute(), will crash the client program.
The expected behavior would be, it should through an error.
Analysis: The mysql_stmt_prepare() interns calls the function end_server()
and net->vio and net->buff are freed and set to NULL. Then the next call
mysql_stmt_execute() will interns call net_clear() where we are "net->vio"
with out validating it.
Fix: we are validating the net->vio, before calling net_clear().
Remove sql directory from the include path to workaround the problem. This removes the ambiguity , since then only one client_settings.h will be in the include paths
two tests still fail:
main.innodb_icp and main.range_vs_index_merge_innodb
call records_in_range() with both range ends being open
(which triggers an assert)
Several fixes :
* sql-common/client.c
Added a validity check of the fields metadata packet sent
by the server.
Now libmysql will check if the length of the data sent by
the server matches what's expected by the protocol before
using the data.
* client/mysqltest.cc
Fixed the error handling code in mysqltest to avoid sending
new commands when the reading the result set failed (and
there are unread data in the pipe).
* sql_common.h + libmysql/libmysql.c + sql-common/client.c
unpack_fields() now generates a proper error when it fails.
Added a new argument to this function to support the error
generation.
* sql/protocol.cc
Added a debug trigger to cause the server to send a NULL
insted of the packet expected by the client for testing
purposes.
mysql-test/suite/innodb/t/group_commit_crash.test:
remove autoincrement to avoid rbr being used for insert ... select
mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test:
remove autoincrement to avoid rbr being used for insert ... select
mysys/my_addr_resolve.c:
a pointer to a buffer is returned to the caller -> the buffer cannot be on the stack
mysys/stacktrace.c:
my_vsnprintf() is ok here, in 5.5
+get_tty_password this is the only external symbol in get_password.c,
which is explicitly listed in CLIENT_SOURCES
+handle_options this is in mysys/my_getopt.c
adding this sysmbol pulls in the other externals:
T getopt_compare_strings
T getopt_double_limit_value
T getopt_ll_limit_value
T getopt_ull_limit_value
T handle_options
T my_cleanup_options
T my_getopt_register_get_addr
T my_print_help
T my_print_variables
client/CMakeLists.txt:
1. -rdynamic is a linker flag.
2. it should be used in all builds, not debug only
libmysql/get_password.c:
prefer a standard function, when possible
(otherwise a plugin will need to load it from the client)
1. on windows: don't hang when there's no console, that is, _getch() returns -1.
2. on windows: _getch() returns an int, not char.
to distinguish between (char)255 and (int)-1
3. everywhere. isspace(pos[-1]) == ' ' never worked,
isspace() returns a boolean, not a char. the never-worked loop was
removed to preserve the existing behavior.