Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d3cc15eb
Commit
d3cc15eb
authored
Jun 30, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '10.0' into 10.1
parents
b503b1c0
92928bcd
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
7 deletions
+126
-7
client/mysql.cc
client/mysql.cc
+4
-2
client/mysqltest.cc
client/mysqltest.cc
+13
-3
include/mysql_com.h
include/mysql_com.h
+2
-0
mysql-test/r/mysql.result
mysql-test/r/mysql.result
+58
-0
mysql-test/r/mysqltest.result
mysql-test/r/mysqltest.result
+5
-0
mysql-test/t/mysql.test
mysql-test/t/mysql.test
+30
-0
mysql-test/t/mysqltest.test
mysql-test/t/mysqltest.test
+7
-1
sql/item_strfunc.cc
sql/item_strfunc.cc
+1
-1
sql/sql_class.cc
sql/sql_class.cc
+2
-0
sql/sys_vars.cc
sql/sys_vars.cc
+4
-0
No files found.
client/mysql.cc
View file @
d3cc15eb
...
...
@@ -2319,8 +2319,10 @@ static bool add_line(String &buffer, char *line, ulong line_length,
continue
;
}
#endif
if
(
!*
ml_comment
&&
inchar
==
'\\'
&&
!
(
*
in_string
&&
if
(
!*
ml_comment
&&
inchar
==
'\\'
&&
*
in_string
!=
'`'
&&
!
(
*
in_string
==
'"'
&&
(
mysql
.
server_status
&
SERVER_STATUS_ANSI_QUOTES
))
&&
!
(
*
in_string
&&
(
mysql
.
server_status
&
SERVER_STATUS_NO_BACKSLASH_ESCAPES
)))
{
// Found possbile one character command like \c
...
...
client/mysqltest.cc
View file @
d3cc15eb
...
...
@@ -6520,6 +6520,16 @@ my_bool end_of_query(int c)
}
static
inline
bool
is_escape_char
(
char
c
,
char
in_string
)
{
if
(
c
!=
'\\'
||
in_string
==
'`'
)
return
false
;
if
(
!
cur_con
)
return
true
;
uint
server_status
=
cur_con
->
mysql
->
server_status
;
if
(
server_status
&
SERVER_STATUS_NO_BACKSLASH_ESCAPES
)
return
false
;
return
!
(
server_status
&
SERVER_STATUS_ANSI_QUOTES
&&
in_string
==
'"'
);
}
/*
Read one "line" from the file
...
...
@@ -6546,7 +6556,7 @@ my_bool end_of_query(int c)
int
read_line
(
char
*
buf
,
int
size
)
{
char
c
,
UNINIT_VAR
(
last_quote
)
,
last_char
=
0
;
char
c
,
last_quote
=
0
,
last_char
=
0
;
char
*
p
=
buf
,
*
buf_end
=
buf
+
size
-
1
;
int
skip_char
=
0
;
my_bool
have_slash
=
FALSE
;
...
...
@@ -6628,7 +6638,7 @@ int read_line(char *buf, int size)
state
=
R_Q
;
}
}
have_slash
=
(
c
==
'\\'
);
have_slash
=
is_escape_char
(
c
,
last_quote
);
break
;
case
R_COMMENT
:
...
...
@@ -6698,7 +6708,7 @@ int read_line(char *buf, int size)
case
R_Q
:
if
(
c
==
last_quote
)
state
=
R_NORMAL
;
else
if
(
c
==
'\\'
)
else
if
(
is_escape_char
(
c
,
last_quote
)
)
state
=
R_SLASH_IN_Q
;
break
;
...
...
include/mysql_com.h
View file @
d3cc15eb
...
...
@@ -323,6 +323,8 @@ enum enum_server_command
*/
#define SERVER_STATUS_IN_TRANS_READONLY 8192
#define SERVER_STATUS_ANSI_QUOTES 32768
/**
Server status flags that must be cleared when starting
...
...
mysql-test/r/mysql.result
View file @
d3cc15eb
...
...
@@ -544,3 +544,61 @@ ERROR 1300 (HY000) at line 2: Invalid utf8 character string: 'test\xF0\x9F\x98\x
set GLOBAL sql_mode=default;
End of tests
create table `a1\``b1` (a int);
show tables;
Tables_in_test
a1\`b1
insert `a1\``b1` values (1),(2);
show create table `a1\``b1`;
Table Create Table
a1\`b1 CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `a1\``b1` VALUES (1),(2);
insert `a1\``b1` values (4),(5);
show create table `a1\``b1`;
Table Create Table
a1\`b1 CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from `a1\``b1`;
a
1
2
drop table `a1\``b1`;
set sql_mode=ansi_quotes;
create table "a1\""b1" (a int);
show tables;
Tables_in_test
a1\"b1
insert "a1\""b1" values (1),(2);
show create table "a1\""b1";
Table Create Table
a1\"b1 CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
);
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO "a1\""b1" VALUES (1),(2);
insert "a1\""b1" values (4),(5);
show create table "a1\""b1";
Table Create Table
a1\"b1 CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from "a1\""b1";
a
1
2
drop table "a1\""b1";
set sql_mode=default;
mysql-test/r/mysqltest.result
View file @
d3cc15eb
...
...
@@ -962,4 +962,9 @@ con1
con2
con2
-closed_connection-
set sql_mode=no_backslash_escapes;
select "foo\""bar";
foo\"bar
foo\"bar
set sql_mode=default;
End of tests
mysql-test/t/mysql.test
View file @
d3cc15eb
...
...
@@ -645,3 +645,33 @@ EOF
set
GLOBAL
sql_mode
=
default
;
--
echo
--
echo
End
of
tests
#
# MDEV-13187 incorrect backslash parsing in clients
#
create
table
`a1\``
b1
` (a int);
show tables;
insert `
a1
\
``
b1
` values (1),(2);
show create table `
a1
\
``
b1
`;
--exec $MYSQL_DUMP --compact test
--exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug.sql
insert `
a1
\
``
b1
` values (4),(5);
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug.sql
show create table `
a1
\
``
b1
`;
select * from `
a1
\
``
b1
`;
drop table `
a1
\
``
b1
`
;
# same with ansi_quotes
set
sql_mode
=
ansi_quotes
;
create
table
"a1
\"
"
b1
" (a int);
show tables;
insert "
a1
\
""
b1
" values (1),(2);
show create table "
a1
\
""
b1
";
--exec
$MYSQL_DUMP
--compact --compatible=postgres test
--exec
$MYSQL_DUMP
--compatible=postgres test >
$MYSQLTEST_VARDIR
/tmp/bug.sql
insert "
a1
\
""
b1
" values (4),(5);
--exec
$MYSQL
test <
$MYSQLTEST_VARDIR
/tmp/bug.sql
show create table "
a1
\
""
b1
";
select * from "
a1
\
""
b1
";
drop table "
a1
\
""
b1
";
set sql_mode=default;
mysql-test/t/mysqltest.test
View file @
d3cc15eb
...
...
@@ -2946,11 +2946,17 @@ disconnect $x;
# Disconnect the selected connection
disconnect
$y
;
--
echo
$CURRENT_CONNECTION
connection
default
;
#
# MDEV-13187 incorrect backslash parsing in clients
#
set
sql_mode
=
no_backslash_escapes
;
select
"foo
\"
"
bar
";
set sql_mode=default;
--echo End of tests
connection
default
;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
...
...
sql/item_strfunc.cc
View file @
d3cc15eb
...
...
@@ -1100,7 +1100,7 @@ String *Item_func_reverse::val_str(String *str)
if
((
l
=
my_ismbchar
(
res
->
charset
(),
ptr
,
end
)))
{
tmp
-=
l
;
DBUG_ASSERT
(
tmp
>=
tmp_value
.
ptr
());
DBUG_ASSERT
(
tmp
>=
str
->
ptr
());
memcpy
(
tmp
,
ptr
,
l
);
ptr
+=
l
;
}
...
...
sql/sql_class.cc
View file @
d3cc15eb
...
...
@@ -1400,6 +1400,8 @@ void THD::init(void)
server_status
=
SERVER_STATUS_AUTOCOMMIT
;
if
(
variables
.
sql_mode
&
MODE_NO_BACKSLASH_ESCAPES
)
server_status
|=
SERVER_STATUS_NO_BACKSLASH_ESCAPES
;
if
(
variables
.
sql_mode
&
MODE_ANSI_QUOTES
)
server_status
|=
SERVER_STATUS_ANSI_QUOTES
;
transaction
.
all
.
modified_non_trans_table
=
transaction
.
stmt
.
modified_non_trans_table
=
FALSE
;
...
...
sql/sys_vars.cc
View file @
d3cc15eb
...
...
@@ -3030,6 +3030,10 @@ static bool fix_sql_mode(sys_var *self, THD *thd, enum_var_type type)
thd
->
server_status
|=
SERVER_STATUS_NO_BACKSLASH_ESCAPES
;
else
thd
->
server_status
&=
~
SERVER_STATUS_NO_BACKSLASH_ESCAPES
;
if
(
thd
->
variables
.
sql_mode
&
MODE_ANSI_QUOTES
)
thd
->
server_status
|=
SERVER_STATUS_ANSI_QUOTES
;
else
thd
->
server_status
&=
~
SERVER_STATUS_ANSI_QUOTES
;
}
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment