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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
ec838d56
Commit
ec838d56
authored
Feb 08, 2013
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tests for TABLE_TYPE=CSV
parent
dd9ee7d1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
0 deletions
+126
-0
mysql-test/suite/connect/r/csv.result
mysql-test/suite/connect/r/csv.result
+67
-0
mysql-test/suite/connect/std_data/people.csv
mysql-test/suite/connect/std_data/people.csv
+3
-0
mysql-test/suite/connect/t/csv.test
mysql-test/suite/connect/t/csv.test
+56
-0
No files found.
mysql-test/suite/connect/r/csv.result
0 → 100644
View file @
ec838d56
#
# Testing errors
#
CREATE TABLE t1
(
ID INT
) Engine=CONNECT TABLE_TYPE=CSV FILE_NAME='nonexistent.txt';
SELECT * FROM t1;
ID
Warnings:
Warning 1105 Open(rb) error 2 on DATADIR/test/nonexistent.txt: No such file or directory
DROP TABLE t1;
#
# Testing examples from the manual
#
CREATE TABLE t1
(
name CHAR(12),
birth DATE DATE_FORMAT='DD/MM/YY',
children SMALLINT(2)
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='people.csv'
HEADER=1 SEP_CHAR=';' QUOTED=1;
SELECT * FROM t1;
name birth children
Archibald 2001-05-17 3
Nabucho 2003-08-12 2
INSERT INTO t1 VALUES ('RONALD','1980-02-26',4);
SELECT * FROM t1;
name birth children
Archibald 2001-05-17 3
Nabucho 2003-08-12 2
RONALD 1980-02-26 4
DROP TABLE t1;
SELECT REPLACE(LOAD_FILE('DATADIR/test/people.csv'),'\r\n','\n');;
REPLACE(LOAD_FILE('DATADIR/test/people.csv'),'\r\n','\n')
Name;birth;children
"Archibald";17/05/01;3
"Nabucho";12/08/03;2
"RONALD";26/02/80;4
#
# Testing that the underlying file is created
#
CREATE TABLE t1
(
c1 CHAR(12) NOT NULL,
c2 CHAR(12) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='tmp.csv'
HEADER=1 SEP_CHAR=',' QUOTED=1;
INSERT INTO t1 VALUES (10,10),(20,20),(300,300),(4000,4000), ('a b','c d');
SELECT * FROM t1;
c1 c2
10 10
20 20
300 300
4000 4000
a b c d
DROP TABLE t1;
SELECT REPLACE(LOAD_FILE('DATADIR/test/tmp.csv'),'\r\n','\n');;
REPLACE(LOAD_FILE('DATADIR/test/tmp.csv'),'\r\n','\n')
"c1","c2"
"10","10"
"20","20"
"300","300"
"4000","4000"
"a b","c d"
mysql-test/suite/connect/std_data/people.csv
0 → 100644
View file @
ec838d56
Name;birth;children
"Archibald";17/05/01;3
"Nabucho";12/08/03;2
mysql-test/suite/connect/t/csv.test
0 → 100644
View file @
ec838d56
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
--
copy_file
$MYSQL_TEST_DIR
/
suite
/
connect
/
std_data
/
people
.
csv
$MYSQLD_DATADIR
/
test
/
people
.
csv
--
echo
#
--
echo
# Testing errors
--
echo
#
CREATE
TABLE
t1
(
ID
INT
)
Engine
=
CONNECT
TABLE_TYPE
=
CSV
FILE_NAME
=
'nonexistent.txt'
;
--
replace_regex
/
on
.*
test
.
nonexistent
.
txt
/
on
DATADIR
\
/
test
\
/
nonexistent
.
txt
/
# TODO: check why this is needed for Windows
--
replace_result
Open
(
rt
)
Open
(
rb
)
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Testing examples from the manual
--
echo
#
CREATE
TABLE
t1
(
name
CHAR
(
12
),
birth
DATE
DATE_FORMAT
=
'DD/MM/YY'
,
children
SMALLINT
(
2
)
)
ENGINE
=
CONNECT
TABLE_TYPE
=
CSV
FILE_NAME
=
'people.csv'
HEADER
=
1
SEP_CHAR
=
';'
QUOTED
=
1
;
SELECT
*
FROM
t1
;
INSERT
INTO
t1
VALUES
(
'RONALD'
,
'1980-02-26'
,
4
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
chmod
0777
$MYSQLD_DATADIR
/
test
/
people
.
csv
--
replace_result
$MYSQLD_DATADIR
DATADIR
--
eval
SELECT
REPLACE
(
LOAD_FILE
(
'$MYSQLD_DATADIR/test/people.csv'
),
'\r\n'
,
'\n'
);
--
echo
#
--
echo
# Testing that the underlying file is created
--
echo
#
CREATE
TABLE
t1
(
c1
CHAR
(
12
)
NOT
NULL
,
c2
CHAR
(
12
)
NOT
NULL
)
ENGINE
=
CONNECT
TABLE_TYPE
=
CSV
FILE_NAME
=
'tmp.csv'
HEADER
=
1
SEP_CHAR
=
','
QUOTED
=
1
;
INSERT
INTO
t1
VALUES
(
10
,
10
),(
20
,
20
),(
300
,
300
),(
4000
,
4000
),
(
'a b'
,
'c d'
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
chmod
0777
$MYSQLD_DATADIR
/
test
/
tmp
.
csv
--
replace_result
$MYSQLD_DATADIR
DATADIR
--
eval
SELECT
REPLACE
(
LOAD_FILE
(
'$MYSQLD_DATADIR/test/tmp.csv'
),
'\r\n'
,
'\n'
);
#
# Clean up
#
--
remove_file
$MYSQLD_DATADIR
/
test
/
people
.
csv
--
remove_file
$MYSQLD_DATADIR
/
test
/
tmp
.
csv
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