diff options
author | unknown <jimw@mysql.com> | 2005-06-23 18:29:56 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-06-23 18:29:56 -0700 |
commit | 86d8abdb26e35a5920eea0e55fadd89295f05df6 (patch) | |
tree | b5f6e8ddaa771fd03ce4b741cc2723ea99b358ca /tests | |
parent | d34e2ccb3ea51811552f3e87ad68ee8673804da1 (diff) | |
download | mariadb-git-86d8abdb26e35a5920eea0e55fadd89295f05df6.tar.gz |
Make status of NO_BACKSLASH_ESCAPES mode known to the client so
it can use it to switch to only quoting apostrophes by doubling
them when it is in effect. (Bug #10214)
include/my_sys.h:
Add new escape_quotes_for_mysql() function
include/mysql_com.h:
Add SERVER_STATUS_NO_BACKSLASH_ESCAPES
libmysql/libmysql.c:
Use SERVER_STATUS_NO_BACKSLASH_ESCAPES in server_status to determine
how mysql_real_escape_string() should do quoting.
mysys/charset.c:
Add new escape_quotes_for_mysql() function that only quotes
apostrophes by doubling them up.
sql/set_var.cc:
Set SERVER_STATUS_NO_BACKSLASH_ESCAPES when MODE_NO_BACKSLASH_ESCAPES
changes.
sql/sql_class.cc:
Set SERVER_STATUS_NO_BACKSLASH_ESCAPES when necessary on thread creation.
tests/mysql_client_test.c:
Add new test for sending NO_BACKSLASH_ESCAPES as part of server_status.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 8debf7614a3..bb9e693b8ec 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13332,6 +13332,35 @@ static void test_bug9992() mysql_close(mysql1); } + +/* + Check that the server signals when NO_BACKSLASH_ESCAPES mode is in effect, + and mysql_real_escape_string() does the right thing as a result. +*/ + +static void test_bug10214() +{ + MYSQL_RES* res ; + int len; + char out[8]; + + myheader("test_bug10214"); + + DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)); + + len= mysql_real_escape_string(mysql, out, "a'b\\c", 5); + DIE_UNLESS(memcmp(out, "a\\'b\\\\c", len) == 0); + + mysql_query(mysql, "set sql_mode='NO_BACKSLASH_ESCAPES'"); + DIE_UNLESS(mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES); + + len= mysql_real_escape_string(mysql, out, "a'b\\c", 5); + DIE_UNLESS(memcmp(out, "a''b\\c", len) == 0); + + mysql_query(mysql, "set sql_mode=''"); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -13567,6 +13596,7 @@ static struct my_tests_st my_tests[]= { { "test_bug10729", test_bug10729 }, { "test_bug11111", test_bug11111 }, { "test_bug9992", test_bug9992 }, + { "test_bug10214", test_bug10214 }, { 0, 0 } }; |