Skip to content

Commit

Permalink
feat(tianmu): support select into outfile with enclosed char. (stonea…
Browse files Browse the repository at this point in the history
…tom#850,stoneatom#1006)

[summary]
1 support select into out-file can output enclose char(optionally or not);
2 support load with enclose char(optionally or not);
  • Loading branch information
lujiashun authored and mergify[bot] committed Dec 15, 2022
1 parent 1a81c64 commit ad960cb
Show file tree
Hide file tree
Showing 15 changed files with 32,281 additions and 24 deletions.
19 changes: 19 additions & 0 deletions mysql-test/suite/tianmu/r/issue1006.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DROP DATABASE IF EXISTS issue1006_test;
CREATE DATABASE issue1006_test;
USE issue1006_test;
CREATE TABLE `orders` (
`o_orderkey` int(11) NOT NULL,
`o_custkey` int(11) NOT NULL,
`o_orderstatus` char(1) NOT NULL,
`o_totalprice` decimal(15,2) NOT NULL,
`o_orderdate` date NOT NULL,
`o_orderpriority` char(15) NOT NULL,
`o_clerk` char(15) NOT NULL,
`o_shippriority` int(11) NOT NULL,
`o_comment` varchar(79) NOT NULL,
PRIMARY KEY (`o_orderkey`)
) ENGINE=tianmu DEFAULT CHARSET=utf8mb4;
load data local infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue1006.txt' into table orders FIELDS TERMINATED BY ' ' ENCLOSED BY '"' LINES TERMINATED BY '\n';
select * from orders limit 10 into outfile 'MYSQLTEST_VARDIR/tmp/issue1006_out.txt' FIELDS TERMINATED BY ' ' ENCLOSED BY '"' LINES TERMINATED BY '\n';
drop table orders;
DROP DATABASE issue1006_test;
62 changes: 62 additions & 0 deletions mysql-test/suite/tianmu/r/issue850.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
DROP DATABASE IF EXISTS issue850_test;
CREATE DATABASE issue850_test;
USE issue850_test;
CREATE TABLE IF NOT EXISTS `lineorder` (
`lo_orderkey` int NOT NULL COMMENT "",
`lo_linenumber` int NOT NULL COMMENT "",
`lo_custkey` int NOT NULL COMMENT "",
`lo_partkey` int NOT NULL COMMENT "",
`lo_suppkey` int NOT NULL COMMENT "",
`lo_orderdate` int NOT NULL COMMENT "",
`lo_orderpriority` varchar(16) NOT NULL COMMENT "",
`lo_shippriority` int NOT NULL COMMENT "",
`lo_quantity` int NOT NULL COMMENT "",
`lo_extendedprice` int NOT NULL COMMENT "",
`lo_ordtotalprice` int NOT NULL COMMENT "",
`lo_discount` int NOT NULL COMMENT "",
`lo_revenue` int NOT NULL COMMENT "",
`lo_supplycost` int NOT NULL COMMENT "",
`lo_tax` int NOT NULL COMMENT "",
`lo_commitdate` int NOT NULL COMMENT "",
`lo_shipmode` varchar(11) NOT NULL COMMENT ""
)engine = tianmu;
CREATE TABLE IF NOT EXISTS `customer` (
`c_custkey` int(11) NOT NULL COMMENT "",
`c_name` varchar(26) NOT NULL COMMENT "",
`c_address` varchar(41) NOT NULL COMMENT "",
`c_city` varchar(11) NOT NULL COMMENT "",
`c_nation` varchar(16) NOT NULL COMMENT "",
`c_region` varchar(13) NOT NULL COMMENT "",
`c_phone` varchar(16) NOT NULL COMMENT "",
`c_mktsegment` varchar(11) NOT NULL COMMENT ""
)engine = tianmu;
CREATE TABLE IF NOT EXISTS `supplier` (
`s_suppkey` int(11) NOT NULL COMMENT "",
`s_name` varchar(26) NOT NULL COMMENT "",
`s_address` varchar(26) NOT NULL COMMENT "",
`s_city` varchar(11) NOT NULL COMMENT "",
`s_nation` varchar(16) NOT NULL COMMENT "",
`s_region` varchar(13) NOT NULL COMMENT "",
`s_phone` varchar(16) NOT NULL COMMENT ""
)engine = tianmu;
CREATE TABLE IF NOT EXISTS `part` (
`p_partkey` int(11) NOT NULL COMMENT "",
`p_name` varchar(23) NOT NULL COMMENT "",
`p_mfgr` varchar(7) NOT NULL COMMENT "",
`p_category` varchar(8) NOT NULL COMMENT "",
`p_brand` varchar(10) NOT NULL COMMENT "",
`p_color` varchar(12) NOT NULL COMMENT "",
`p_type` varchar(26) NOT NULL COMMENT "",
`p_size` int(11) NOT NULL COMMENT "",
`p_container` varchar(11) NOT NULL COMMENT ""
) engine = tianmu;
load data local infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue850_customer.txt' into table customer fields terminated by '|';
load data local infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue850_lineorder.txt' into table lineorder fields terminated by '|';
load data local infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue850_part.txt' into table part fields terminated by '|';
load data local infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue850_supplier.txt' into table supplier fields terminated by '|';
select `LO_ORDERDATE` , `LO_ORDERKEY` , `LO_LINENUMBER` , `LO_CUSTKEY` , `LO_PARTKEY` , `LO_SUPPKEY` , `LO_ORDERPRIORITY` , `LO_SHIPPRIORITY` , `LO_QUANTITY` , `LO_EXTENDEDPRICE` , `LO_ORDTOTALPRICE` , `LO_DISCOUNT` , `LO_REVENUE` , `LO_SUPPLYCOST` , `LO_TAX` , `LO_COMMITDATE` , `LO_SHIPMODE` , `C_NAME` , `C_ADDRESS` , `C_CITY` , `C_NATION` , `C_REGION` , `C_PHONE` , `C_MKTSEGMENT` , `S_NAME` , `S_ADDRESS` , `S_CITY` , `S_NATION` , `S_REGION` , `S_PHONE` , `P_NAME` , `P_MFGR` , `P_CATEGORY` , `P_BRAND` , `P_COLOR` , `P_TYPE` , `P_SIZE` , `P_CONTAINER` from lineorder l INNER JOIN customer c ON (c.C_CUSTKEY = l.LO_CUSTKEY) INNER JOIN supplier s ON (s.S_SUPPKEY = l.LO_SUPPKEY) INNER JOIN part p ON (p.P_PARTKEY = l.LO_PARTKEY) where lo_orderdate >=19980101 and lo_orderdate <19990101 INTO OUTFILE "MYSQLTEST_VARDIR/tmp/issue850_out.txt" fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';
drop table customer;
drop table lineorder;
drop table part;
drop table supplier;
DROP DATABASE issue850_test;
10 changes: 10 additions & 0 deletions mysql-test/suite/tianmu/std_data/issue1006.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"1" "369001" "O" "186600.18" "1996-01-02" "5-LOW" "Clerk#000009506" "0" "nstructions sleep ;furiously among"
"2" "780017" "O" "66219.63" "1996-12-01" "1-URGENT" "Clerk#000008792" "0" " foxes. pending accounts at the pending, silent asymptot"
"3" "1233140" "F" "270741.97" "1993-10-14" "5-LOW" "Clerk#000009543" "0" "sly final accounts boost. carefully regular ideas cajole carefully. depos"
"4" "1367761" "O" "41714.38" "1995-10-11" "5-LOW" "Clerk#000001234" "0" "sits. slyly regular warthogs cajole. regular, regular theodolites a cro"
"5" "444848" "F" "122444.33" "1994-07-30" "5-LOW" "Clerk#000009248" "0" "quickly. bold deposits sleep slyly. packages use slyly"
"6" "556222" "F" "50883.96" "1992-02-21" "4-NOT SPECIFIED" "Clerk#000000580" "0" "ggle. special, final requests are against the furiously specia"
"7" "391343" "O" "287534.80" "1996-01-10" "2-HIGH" "Clerk#000004697" "0" "ly special requests "
"32" "1300570" "O" "129634.85" "1995-07-16" "2-HIGH" "Clerk#000006157" "0" "ise blithely bold, regular requests. quickly unusual dep"
"33" "669580" "F" "126998.88" "1993-10-27" "3-MEDIUM" "Clerk#000004086" "0" "uriously. furiously final request"
"34" "610001" "O" "55314.82" "1998-07-21" "3-MEDIUM" "Clerk#000002228" "0" "ly final packages. fluffily final deposits wake blithely ideas.spe"
Loading

0 comments on commit ad960cb

Please sign in to comment.