1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
unknown
2005-06-23 18:29:56 -07:00
parent d34e2ccb3e
commit 86d8abdb26
7 changed files with 117 additions and 1 deletions

View File

@ -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 }
};