-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-27612 Connect : check buffer sizes, fix string format errors
- Loading branch information
Showing
13 changed files
with
280 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
execute immediate concat('create table t engine=CONNECT table_type=JSON',REPEAT('1',5000), | ||
' FILE_NAME=''users.json'' HTTP=''http://localhost:4142'' URI=''/users'''); | ||
ERROR HY000: Unsupported table type JSON1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
execute immediate concat('create table t engine=CONNECT table_type=OEM module=''libname'' | ||
Option_list=''Myopt=foo'' subtype=''MYTYPE',REPEAT('1', 10000), ''''); | ||
ERROR HY000: Subtype string too long | ||
execute immediate concat('create table t engine=CONNECT table_type=DBF file_name=''', | ||
REPLACE(@@secure_file_priv,'\\','/'),'cust.dbf', REPEAT('1', 10000), ''''); | ||
ERROR HY000: Cannot open | ||
create table t engine=connect table_type=mysql | ||
CONNECTION='mysql://root@localhost:MASTER_MYPORT/test/foobar' | ||
SRCDEF='SELECT 1,''%n'' FROM DUAL WHERE %s'; | ||
select *from t; | ||
ERROR HY000: Got error 174 'MakeSQL: Wrong place holders specification' from CONNECT | ||
drop table t; | ||
create table t engine=connect table_type=mysql | ||
CONNECTION='mysql://root@localhost:MASTER_MYPORT/test/foobar' | ||
SRCDEF='SELECT 1,%n FROM DUAL WHERE %s'; | ||
ERROR HY000: (1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%n FROM DUAL WHERE 1=1 LIMIT 0' at line 1 [SELECT 1,%n FROM DUAL WHERE 1=1 LIMIT 0] | ||
create table t engine=connect table_type=mysql | ||
CONNECTION='mysql://root@localhost:MASTER_MYPORT/test/foobar' | ||
SRCDEF='SELECT 1 FROM DUAL WHERE %s'; | ||
select *from t; | ||
1 | ||
1 | ||
drop table t; | ||
create table beers ( | ||
`Name` char(16) xpath='brandName', | ||
`Origin` char(16) xpath='origin', | ||
`Description` char(32) xpath='details') | ||
engine=CONNECT table_type=XML file_name='MYSQLTEST_VARDIR/tmp/beer.xml' | ||
tabname='table' option_list='rownode=tr,colnode=td%n'; | ||
select * from beers; | ||
Name Origin Description | ||
NULL NULL NULL | ||
NULL NULL NULL | ||
drop table beers; | ||
create table beers ( | ||
`Name` char(16) xpath='brandName', | ||
`Origin` char(16) xpath='origin', | ||
`Description` char(32) xpath='details') | ||
engine=CONNECT table_type=XML file_name='MYSQLTEST_VARDIR/tmp/beer.xml' | ||
tabname='table' option_list='rownode=tr,colnode=td'; | ||
insert into beers values('11','22','33'); | ||
drop table beers; | ||
execute immediate CONCAT('create table jsampall | ||
(Author char(128) jpath=''$.AUTHOR["', REPEAT('a',10000),'"]'') | ||
engine=CONNECT table_type=JSON | ||
file_name=''',REPLACE(@@secure_file_priv,'\\','/'),'tmp/test.json'''); | ||
select author from jsampall; | ||
author | ||
Jean-Christophe Bernadacaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
William J. Pardi | ||
drop table jsampall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
|
||
# Overlong table type | ||
--error ER_UNKNOWN_ERROR | ||
execute immediate concat('create table t engine=CONNECT table_type=JSON',REPEAT('1',5000), | ||
' FILE_NAME=''users.json'' HTTP=''http://localhost:4142'' URI=''/users'''); | ||
|
||
# Overlong subtype | ||
--error ER_UNKNOWN_ERROR | ||
execute immediate concat('create table t engine=CONNECT table_type=OEM module=''libname'' | ||
Option_list=''Myopt=foo'' subtype=''MYTYPE',REPEAT('1', 10000), ''''); | ||
|
||
|
||
# Overlong filename | ||
--error ER_UNKNOWN_ERROR | ||
execute immediate concat('create table t engine=CONNECT table_type=DBF file_name=''', | ||
REPLACE(@@secure_file_priv,'\\','/'),'cust.dbf', REPEAT('1', 10000), ''''); | ||
|
||
|
||
# Format string in SRCDEF | ||
--replace_result $MASTER_MYPORT MASTER_MYPORT | ||
eval create table t engine=connect table_type=mysql | ||
CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/foobar' | ||
SRCDEF='SELECT 1,''%n'' FROM DUAL WHERE %s'; | ||
--error ER_GET_ERRMSG | ||
select *from t; | ||
drop table t; | ||
|
||
--replace_result $MASTER_MYPORT MASTER_MYPORT | ||
--error ER_UNKNOWN_ERROR | ||
eval create table t engine=connect table_type=mysql | ||
CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/foobar' | ||
SRCDEF='SELECT 1,%n FROM DUAL WHERE %s'; | ||
|
||
--replace_result $MASTER_MYPORT MASTER_MYPORT | ||
eval create table t engine=connect table_type=mysql | ||
CONNECTION='mysql://root@localhost:$MASTER_MYPORT/test/foobar' | ||
SRCDEF='SELECT 1 FROM DUAL WHERE %s'; | ||
select *from t; | ||
drop table t; | ||
|
||
write_file $MYSQLTEST_VARDIR/tmp/beer.xml; | ||
<?xml version="1.0"?> | ||
<Beers> | ||
<table> | ||
<th><td>Name</td><td>Origin</td><td>Description</td></th> | ||
<tr> | ||
<td><brandName>Huntsman</brandName></td> | ||
<td><origin>Bath, UK</origin></td> | ||
<td><details>Wonderful hop, light alcohol</details></td> | ||
</tr> | ||
<tr> | ||
<td><brandName>Tuborg</brandName></td> | ||
<td><origin>Danmark</origin></td> | ||
<td><details>In small bottles</details></td> | ||
</tr> | ||
</table> | ||
</Beers> | ||
EOF | ||
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
# Format string in colnode | ||
eval create table beers ( | ||
`Name` char(16) xpath='brandName', | ||
`Origin` char(16) xpath='origin', | ||
`Description` char(32) xpath='details') | ||
engine=CONNECT table_type=XML file_name='$MYSQLTEST_VARDIR/tmp/beer.xml' | ||
tabname='table' option_list='rownode=tr,colnode=td%n'; | ||
select * from beers; | ||
drop table beers; | ||
|
||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
eval create table beers ( | ||
`Name` char(16) xpath='brandName', | ||
`Origin` char(16) xpath='origin', | ||
`Description` char(32) xpath='details') | ||
engine=CONNECT table_type=XML file_name='$MYSQLTEST_VARDIR/tmp/beer.xml' | ||
tabname='table' option_list='rownode=tr,colnode=td'; | ||
insert into beers values('11','22','33'); | ||
drop table beers; | ||
|
||
remove_file $MYSQLTEST_VARDIR/tmp/beer.xml; | ||
|
||
write_file $MYSQLTEST_VARDIR/tmp/test.json; | ||
[ | ||
{ | ||
"ISBN": "9782212090819", | ||
"LANG": "fr", | ||
"SUBJECT": "applications", | ||
"AUTHOR": [ | ||
{ | ||
"FIRSTNAME": "Jean-Christophe", | ||
"LASTNAME": "Bernadac" | ||
}, | ||
{ | ||
"FIRSTNAME": "François", | ||
"LASTNAME": "Knab" | ||
} | ||
], | ||
"TITLE": "Construire une application XML", | ||
"PUBLISHER": { | ||
"NAME": "Eyrolles", | ||
"PLACE": "Paris" | ||
}, | ||
"DATEPUB": 1999 | ||
}, | ||
{ | ||
"ISBN": "9782840825685", | ||
"LANG": "fr", | ||
"SUBJECT": "applications", | ||
"AUTHOR": [ | ||
{ | ||
"FIRSTNAME": "William J.", | ||
"LASTNAME": "Pardi" | ||
} | ||
], | ||
"TITLE": "XML en Action", | ||
"TRANSLATED": { | ||
"PREFIX": "adapté de l'anglais par", | ||
"TRANSLATOR": { | ||
"FIRSTNAME": "James", | ||
"LASTNAME": "Guerin" | ||
} | ||
}, | ||
"PUBLISHER": { | ||
"NAME": "Microsoft Press", | ||
"PLACE": "Paris" | ||
}, | ||
"DATEPUB": 1999 | ||
} | ||
] | ||
EOF | ||
|
||
execute immediate CONCAT('create table jsampall | ||
(Author char(128) jpath=''$.AUTHOR["', REPEAT('a',10000),'"]'') | ||
engine=CONNECT table_type=JSON | ||
file_name=''',REPLACE(@@secure_file_priv,'\\','/'),'tmp/test.json'''); | ||
|
||
select author from jsampall; | ||
drop table jsampall; | ||
remove_file $MYSQLTEST_VARDIR/tmp/test.json; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters