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
b3e06ce3
Commit
b3e06ce3
authored
Sep 26, 2022
by
Anel
Committed by
GitHub
Sep 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-28533: CONNECT engine does not quote columns involved in WHERE clause (#2263)
parent
66cd1c33
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
4 deletions
+56
-4
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+14
-4
storage/connect/mysql-test/connect/r/mysql.result
storage/connect/mysql-test/connect/r/mysql.result
+22
-0
storage/connect/mysql-test/connect/t/mysql.test
storage/connect/mysql-test/connect/t/mysql.test
+20
-0
No files found.
storage/connect/ha_connect.cc
View file @
b3e06ce3
...
...
@@ -3073,6 +3073,8 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
if
((
iscol
=
args
[
i
]
->
type
()
==
COND
::
FIELD_ITEM
))
{
const
char
*
fnm
;
char
buf
[
MAX_FIELD_WIDTH
];
String
strColumn
(
buf
,
sizeof
(
buf
),
system_charset_info
);
ha_field_option_struct
*
fop
;
Item_field
*
pField
=
(
Item_field
*
)
args
[
i
];
...
...
@@ -3098,8 +3100,14 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
return
NULL
;
}
else
{
bool
h
;
fnm
=
filp
->
Chk
(
pField
->
field
->
field_name
.
str
,
&
h
);
if
(
tty
==
TYPE_AM_MYSQL
&&
!
(
x
||
ismul
))
{
strColumn
.
length
(
0
);
strColumn
.
qs_append
(
STRING_WITH_LEN
(
"`"
));
strColumn
.
qs_append
(
fnm
);
strColumn
.
append
(
STRING_WITH_LEN
(
"`"
));
}
if
(
h
&&
i
&&
!
ishav
)
return
NULL
;
// Having should be col VOP arg
...
...
@@ -3113,9 +3121,11 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
htrc
(
"Field name=%s
\n
"
,
pField
->
field
->
field_name
.
str
);
htrc
(
"Field type=%d
\n
"
,
pField
->
field
->
type
());
htrc
(
"Field_type=%d
\n
"
,
args
[
i
]
->
field_type
());
}
// endif trace
strcat
((
ishav
?
havg
:
body
),
fnm
);
}
// endif trace
if
(
tty
==
TYPE_AM_MYSQL
&&
!
(
x
||
ismul
))
strcat
((
ishav
?
havg
:
body
),
strColumn
.
ptr
());
else
strcat
((
ishav
?
havg
:
body
),
fnm
);
}
else
if
(
args
[
i
]
->
type
()
==
COND
::
FUNC_ITEM
)
{
if
(
tty
==
TYPE_AM_MYSQL
)
{
if
(
!
CheckCond
(
g
,
filp
,
args
[
i
]))
...
...
storage/connect/mysql-test/connect/r/mysql.result
View file @
b3e06ce3
...
...
@@ -304,5 +304,27 @@ INSERT INTO t2 VALUES (10),(20),(30),(40);
DROP TABLE t2;
DROP TABLE t1;
#
# MDEV-28533 CONNECT engine does not quote columns involved in WHERE clause
#
CREATE TABLE t1 (id int, `spaced col` varchar(10),`nospace` varchar(10));
insert into t1 values (1,1,'x1'),(2,'C-003','x2');
SELECT * from t1;
id spaced col nospace
1 1 x1
2 C-003 x2
CREATE TABLE t2 (id int, `spaced col` varchar(10), `nospace` varchar(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=PORT';
SELECT * from t2;
id spaced col nospace
1 1 x1
2 C-003 x2
SELECT `id` FROM t2 WHERE t2.`nospace` = 'x1';
id
1
SELECT `id` FROM t2 WHERE t2.`spaced col` = 'C-003';
id
2
DROP TABLE t1;
DROP TABLE t2;
#
# End of 10.3 tests
#
storage/connect/mysql-test/connect/t/mysql.test
View file @
b3e06ce3
...
...
@@ -483,6 +483,26 @@ INSERT INTO t2 VALUES (10),(20),(30),(40);
DROP
TABLE
t2
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-28533 CONNECT engine does not quote columns involved in WHERE clause
--
echo
#
CREATE
TABLE
t1
(
id
int
,
`spaced col`
varchar
(
10
),
`nospace`
varchar
(
10
));
insert
into
t1
values
(
1
,
1
,
'x1'
),(
2
,
'C-003'
,
'x2'
);
SELECT
*
from
t1
;
--
replace_result
$PORT
PORT
--
eval
CREATE
TABLE
t2
(
id
int
,
`spaced col`
varchar
(
10
),
`nospace`
varchar
(
10
))
ENGINE
=
CONNECT
TABLE_TYPE
=
MYSQL
DBNAME
=
'test'
TABNAME
=
't1'
OPTION_LIST
=
'host=localhost,user=root,port=$PORT'
SELECT
*
from
t2
;
SELECT
`id`
FROM
t2
WHERE
t2
.
`nospace`
=
'x1'
;
SELECT
`id`
FROM
t2
WHERE
t2
.
`spaced col`
=
'C-003'
;
DROP
TABLE
t1
;
DROP
TABLE
t2
;
--
echo
#
--
echo
# End of 10.3 tests
--
echo
#
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