Skip to content

Commit 9e233c1

Browse files
committed
Merge branch 'ob-10.1' into 10.1
2 parents e1c2710 + e5f5457 commit 9e233c1

File tree

7 files changed

+658
-291
lines changed

7 files changed

+658
-291
lines changed

storage/connect/ha_connect.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
#define JSONMAX 10 // JSON Default max grp size
173173

174174
extern "C" {
175-
char version[]= "Version 1.05.0003 February 27, 2017";
175+
char version[]= "Version 1.05.0003 March 7, 2017";
176176
#if defined(__WIN__)
177177
char compver[]= "Version 1.05.0003 " __DATE__ " " __TIME__;
178178
char slash= '\\';
@@ -509,7 +509,7 @@ ha_create_table_option connect_table_option_list[]=
509509
HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1),
510510
HA_TOPTION_NUMBER("BLOCK_SIZE", elements, 0, 0, INT_MAX32, 1),
511511
//HA_TOPTION_NUMBER("ESTIMATE", estimate, 0, 0, INT_MAX32, 1),
512-
HA_TOPTION_NUMBER("MULTIPLE", multiple, 0, 0, 2, 1),
512+
HA_TOPTION_NUMBER("MULTIPLE", multiple, 0, 0, 3, 1),
513513
HA_TOPTION_NUMBER("HEADER", header, 0, 0, 3, 1),
514514
HA_TOPTION_NUMBER("QUOTED", quoted, (ulonglong) -1, 0, 3, 1),
515515
HA_TOPTION_NUMBER("ENDING", ending, (ulonglong) -1, 0, INT_MAX32, 1),

storage/connect/myconn.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
135135
FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL,
136136
FLD_REM, FLD_NO, FLD_DEFAULT, FLD_EXTRA,
137137
FLD_CHARSET};
138-
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
139-
char *fld, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16];
138+
//unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
139+
unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
140+
char *fld, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16];
140141
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
141142
int len, type, prec, rc, k = 0;
143+
bool b;
142144
PQRYRES qrp;
143145
PCOLRES crp;
144146
MYSQLC myc;
@@ -157,7 +159,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
157159
/* Do an evaluation of the result size. */
158160
/********************************************************************/
159161
STRING cmd(g, 64, "SHOW FULL COLUMNS FROM ");
160-
bool b = cmd.Append((PSZ)table);
162+
b = cmd.Append((PSZ)table);
161163

162164
b |= cmd.Append(" FROM ");
163165
b |= cmd.Append((PSZ)(db ? db : PlgGetUser(g)->DBName));
@@ -232,11 +234,31 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
232234
fld = myc.GetCharField(1);
233235
prec = 0;
234236
len = 0;
235-
v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
237+
// v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
238+
v = 0;
236239
*uns = 0;
237240
*zero = 0;
238-
239-
switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) {
241+
b = false;
242+
243+
if (!strnicmp(fld, "enum", 4)) {
244+
char *p2, *p1 = fld + 6; // to skip enum('
245+
246+
while (true) {
247+
p2 = strchr(p1, '\'');
248+
len = MY_MAX(len, p2 - p1);
249+
if (*++p2 != ',') break;
250+
p1 = p2 + 2;
251+
} // endwhile
252+
253+
v = (len > 255) ? 'V' : 0;
254+
strcpy(buf, "enum");
255+
b = true;
256+
} else if (!strnicmp(fld, "set", 3)) {
257+
len = (int)strlen(fld) - 2;
258+
v = 'V';
259+
strcpy(buf, "set");
260+
b = true;
261+
} else switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) {
240262
case 3:
241263
nf = sscanf(fld, "%[^(](%d,%d) %s %s", buf, &len, &prec, uns, zero);
242264
break;
@@ -271,7 +293,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
271293
colname, len);
272294
PushWarning(g, thd);
273295
v = 'V';
274-
} else
296+
} else
275297
len = MY_MIN(len, 4096);
276298

277299
} // endif type
@@ -286,6 +308,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
286308
default: crp->Nulls[i] = v; break;
287309
} // endswitch nf
288310

311+
if (b) // enum or set
312+
nf = sscanf(fld, "%s ", buf); // get values
313+
289314
crp = crp->Next; // Type_Name
290315
crp->Kdata->SetValue(buf, i);
291316

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#
2+
# Testing multiple 1
3+
#
4+
CREATE TABLE t1 (
5+
Chiffre int(3) NOT NULL,
6+
Lettre char(16) NOT NULL)
7+
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='num1.csv' LRECL=20 HEADER=1;
8+
INSERT INTO t1 VALUES(1,'One'),(2,'Two'),(3,'Three'),(4,'Four'),(5,'Five'),(6,'Six');
9+
SELECT * FROM t1;
10+
Chiffre Lettre
11+
1 One
12+
2 Two
13+
3 Three
14+
4 Four
15+
5 Five
16+
6 Six
17+
CREATE TABLE t2 (
18+
Chiffre int(3) NOT NULL,
19+
Lettre char(16) NOT NULL)
20+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='subdir/num2.csv' LRECL=20 HEADER=1;
21+
INSERT INTO t2 VALUES(7,'Seven'),(8,'Eight'),(9,'Nine'),(10,'Ten'),(11,'Eleven'),(12,'Twelve');
22+
SELECT * FROM t2;
23+
Chiffre Lettre
24+
7 Seven
25+
8 Eight
26+
9 Nine
27+
10 Ten
28+
11 Eleven
29+
12 Twelve
30+
CREATE TABLE t3 (
31+
Chiffre int(3) NOT NULL,
32+
Lettre char(16) NOT NULL)
33+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='num3.csv' LRECL=20 HEADER=1;
34+
INSERT INTO t3 VALUES(13,'Thirteen'),(14,'Fourteen'),(15,'Fifteen'),(16,'Sixteen'),(17,'Seventeen'),(18,'Eighteen');
35+
SELECT * FROM t3;
36+
Chiffre Lettre
37+
13 Thirteen
38+
14 Fourteen
39+
15 Fifteen
40+
16 Sixteen
41+
17 Seventeen
42+
18 Eighteen
43+
CREATE TABLE t4 (
44+
Chiffre int(3) NOT NULL,
45+
Lettre char(16) NOT NULL)
46+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='subdir/num4.csv' LRECL=20 HEADER=1;
47+
INSERT INTO t4 VALUES(19,'Nineteen'),(20,'Twenty'),(21,'Twenty one'),(22,'Twenty two'),(23,'Tenty three'),(24,'Twenty four');
48+
SELECT * FROM t4;
49+
Chiffre Lettre
50+
19 Nineteen
51+
20 Twenty
52+
21 Twenty one
53+
22 Twenty two
54+
23 Tenty three
55+
24 Twenty four
56+
CREATE TABLE t5 (
57+
Chiffre int(3) NOT NULL,
58+
Lettre char(16) NOT NULL)
59+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='num5.csv' LRECL=20 HEADER=1;
60+
INSERT INTO t5 VALUES(25,'Twenty five'),(26,'Twenty six'),(27,'Twenty seven'),(28,'Twenty eight'),(29,'Tenty eight'),(30,'Thirty');
61+
SELECT * FROM t5;
62+
Chiffre Lettre
63+
25 Twenty five
64+
26 Twenty six
65+
27 Twenty seven
66+
28 Twenty eight
67+
29 Tenty eight
68+
30 Thirty
69+
CREATE TABLE t_all (
70+
Chiffre int(3) not null,
71+
Lettre char(16) not null)
72+
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='num?.csv' HEADER=1 LRECL=20 MULTIPLE=1;
73+
SELECT * FROM t_all ORDER BY Chiffre;
74+
Chiffre Lettre
75+
1 One
76+
2 Two
77+
3 Three
78+
4 Four
79+
5 Five
80+
6 Six
81+
13 Thirteen
82+
14 Fourteen
83+
15 Fifteen
84+
16 Sixteen
85+
17 Seventeen
86+
18 Eighteen
87+
25 Twenty five
88+
26 Twenty six
89+
27 Twenty seven
90+
28 Twenty eight
91+
29 Tenty eight
92+
30 Thirty
93+
#
94+
# Testing multiple 3
95+
#
96+
ALTER TABLE t_all MULTIPLE=3;
97+
Warnings:
98+
Warning 1105 This is an outward table, table data were not modified.
99+
SELECT * FROM t_all ORDER BY Chiffre;
100+
Chiffre Lettre
101+
1 One
102+
2 Two
103+
3 Three
104+
4 Four
105+
5 Five
106+
6 Six
107+
7 Seven
108+
8 Eight
109+
9 Nine
110+
10 Ten
111+
11 Eleven
112+
12 Twelve
113+
13 Thirteen
114+
14 Fourteen
115+
15 Fifteen
116+
16 Sixteen
117+
17 Seventeen
118+
18 Eighteen
119+
19 Nineteen
120+
20 Twenty
121+
21 Twenty one
122+
22 Twenty two
123+
23 Tenty three
124+
24 Twenty four
125+
25 Twenty five
126+
26 Twenty six
127+
27 Twenty seven
128+
28 Twenty eight
129+
29 Tenty eight
130+
30 Thirty
131+
DROP TABLE t1;
132+
DROP TABLE t2;
133+
DROP TABLE t3;
134+
DROP TABLE t4;
135+
DROP TABLE t5;
136+
DROP TABLE t_all;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
let $MYSQLD_DATADIR= `select @@datadir`;
2+
--mkdir $MYSQLD_DATADIR/test/subdir/
3+
4+
--echo #
5+
--echo # Testing multiple 1
6+
--echo #
7+
CREATE TABLE t1 (
8+
Chiffre int(3) NOT NULL,
9+
Lettre char(16) NOT NULL)
10+
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='num1.csv' LRECL=20 HEADER=1;
11+
INSERT INTO t1 VALUES(1,'One'),(2,'Two'),(3,'Three'),(4,'Four'),(5,'Five'),(6,'Six');
12+
SELECT * FROM t1;
13+
14+
CREATE TABLE t2 (
15+
Chiffre int(3) NOT NULL,
16+
Lettre char(16) NOT NULL)
17+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='subdir/num2.csv' LRECL=20 HEADER=1;
18+
INSERT INTO t2 VALUES(7,'Seven'),(8,'Eight'),(9,'Nine'),(10,'Ten'),(11,'Eleven'),(12,'Twelve');
19+
SELECT * FROM t2;
20+
21+
CREATE TABLE t3 (
22+
Chiffre int(3) NOT NULL,
23+
Lettre char(16) NOT NULL)
24+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='num3.csv' LRECL=20 HEADER=1;
25+
INSERT INTO t3 VALUES(13,'Thirteen'),(14,'Fourteen'),(15,'Fifteen'),(16,'Sixteen'),(17,'Seventeen'),(18,'Eighteen');
26+
SELECT * FROM t3;
27+
28+
CREATE TABLE t4 (
29+
Chiffre int(3) NOT NULL,
30+
Lettre char(16) NOT NULL)
31+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='subdir/num4.csv' LRECL=20 HEADER=1;
32+
INSERT INTO t4 VALUES(19,'Nineteen'),(20,'Twenty'),(21,'Twenty one'),(22,'Twenty two'),(23,'Tenty three'),(24,'Twenty four');
33+
SELECT * FROM t4;
34+
35+
CREATE TABLE t5 (
36+
Chiffre int(3) NOT NULL,
37+
Lettre char(16) NOT NULL)
38+
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='num5.csv' LRECL=20 HEADER=1;
39+
INSERT INTO t5 VALUES(25,'Twenty five'),(26,'Twenty six'),(27,'Twenty seven'),(28,'Twenty eight'),(29,'Tenty eight'),(30,'Thirty');
40+
SELECT * FROM t5;
41+
42+
CREATE TABLE t_all (
43+
Chiffre int(3) not null,
44+
Lettre char(16) not null)
45+
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='num?.csv' HEADER=1 LRECL=20 MULTIPLE=1;
46+
SELECT * FROM t_all ORDER BY Chiffre;
47+
48+
--echo #
49+
--echo # Testing multiple 3
50+
--echo #
51+
ALTER TABLE t_all MULTIPLE=3;
52+
SELECT * FROM t_all ORDER BY Chiffre;
53+
54+
DROP TABLE t1;
55+
DROP TABLE t2;
56+
DROP TABLE t3;
57+
DROP TABLE t4;
58+
DROP TABLE t5;
59+
DROP TABLE t_all;
60+
61+
--remove_file $MYSQLD_DATADIR/test/subdir/num2.csv
62+
--remove_file $MYSQLD_DATADIR/test/subdir/num4.csv
63+
--rmdir $MYSQLD_DATADIR/test/subdir/
64+
--remove_file $MYSQLD_DATADIR/test/num1.csv
65+
--remove_file $MYSQLD_DATADIR/test/num3.csv
66+
--remove_file $MYSQLD_DATADIR/test/num5.csv
67+

storage/connect/myutil.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ int MYSQLtoPLG(char *typname, char *var)
4242
type = TYPE_INT;
4343
else if (!stricmp(typname, "smallint"))
4444
type = TYPE_SHORT;
45-
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar"))
45+
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
46+
!stricmp(typname, "enum") || !stricmp(typname, "set"))
4647
type = TYPE_STRING;
4748
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
4849
!stricmp(typname, "real"))
@@ -87,10 +88,12 @@ int MYSQLtoPLG(char *typname, char *var)
8788
else if (!stricmp(typname, "year"))
8889
*var = 'Y';
8990

90-
} else if (type == TYPE_STRING && !stricmp(typname, "varchar"))
91-
// This is to make the difference between CHAR and VARCHAR
92-
*var = 'V';
93-
else if (type == TYPE_ERROR && xconv == TPC_SKIP)
91+
} else if (type == TYPE_STRING) {
92+
if (!stricmp(typname, "varchar"))
93+
// This is to make the difference between CHAR and VARCHAR
94+
*var = 'V';
95+
96+
} else if (type == TYPE_ERROR && xconv == TPC_SKIP)
9497
*var = 'K';
9598
else
9699
*var = 0;

0 commit comments

Comments
 (0)