Skip to content

Commit 2d573a6

Browse files
committed
CONNECT Storage Engine: Support of ENUM and SET column types
for MYSQL tables. modified: storage/connect/myconn.cpp modified: storage/connect/myutil.cpp Order the result of multiple=3 table, otherwise being different on Linux and Windows causing the test to fail. modified: storage/connect/mysql-test/connect/r/mul_new.result modified: storage/connect/mysql-test/connect/t/mul_new.test
1 parent bf6cadf commit 2d573a6

File tree

4 files changed

+38
-27
lines changed

4 files changed

+38
-27
lines changed

storage/connect/myconn.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
140140
char *fld, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16];
141141
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
142142
int len, type, prec, rc, k = 0;
143+
bool b;
143144
PQRYRES qrp;
144145
PCOLRES crp;
145146
MYSQLC myc;
@@ -158,7 +159,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
158159
/* Do an evaluation of the result size. */
159160
/********************************************************************/
160161
STRING cmd(g, 64, "SHOW FULL COLUMNS FROM ");
161-
bool b = cmd.Append((PSZ)table);
162+
b = cmd.Append((PSZ)table);
162163

163164
b |= cmd.Append(" FROM ");
164165
b |= cmd.Append((PSZ)(db ? db : PlgGetUser(g)->DBName));
@@ -233,9 +234,11 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
233234
fld = myc.GetCharField(1);
234235
prec = 0;
235236
len = 0;
236-
v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
237+
// v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
238+
v = 0;
237239
*uns = 0;
238240
*zero = 0;
241+
b = false;
239242

240243
if (!strnicmp(fld, "enum", 4)) {
241244
char *p2, *p1 = fld + 6; // to skip enum('
@@ -246,8 +249,15 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
246249
if (*++p2 != ',') break;
247250
p1 = p2 + 2;
248251
} // endwhile
249-
252+
253+
v = (len > 255) ? 'V' : 0;
250254
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;
251261
} else switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) {
252262
case 3:
253263
nf = sscanf(fld, "%[^(](%d,%d) %s %s", buf, &len, &prec, uns, zero);
@@ -283,9 +293,6 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
283293
colname, len);
284294
PushWarning(g, thd);
285295
v = 'V';
286-
} else if (v == 'N') {
287-
len = (int)strlen(buf);
288-
v = 0;
289296
} else
290297
len = MY_MIN(len, 4096);
291298

@@ -301,6 +308,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
301308
default: crp->Nulls[i] = v; break;
302309
} // endswitch nf
303310

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

storage/connect/mysql-test/connect/r/mul_new.result

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,38 @@ Chiffre Lettre
9696
ALTER TABLE t_all MULTIPLE=3;
9797
Warnings:
9898
Warning 1105 This is an outward table, table data were not modified.
99-
SELECT * FROM t_all;
99+
SELECT * FROM t_all ORDER BY Chiffre;
100100
Chiffre Lettre
101101
1 One
102102
2 Two
103103
3 Three
104104
4 Four
105105
5 Five
106106
6 Six
107-
13 Thirteen
108-
14 Fourteen
109-
15 Fifteen
110-
16 Sixteen
111-
17 Seventeen
112-
18 Eighteen
113-
25 Twenty five
114-
26 Twenty six
115-
27 Twenty seven
116-
28 Twenty eight
117-
29 Tenty eight
118-
30 Thirty
119107
7 Seven
120108
8 Eight
121109
9 Nine
122110
10 Ten
123111
11 Eleven
124112
12 Twelve
113+
13 Thirteen
114+
14 Fourteen
115+
15 Fifteen
116+
16 Sixteen
117+
17 Seventeen
118+
18 Eighteen
125119
19 Nineteen
126120
20 Twenty
127121
21 Twenty one
128122
22 Twenty two
129123
23 Tenty three
130124
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
131131
DROP TABLE t1;
132132
DROP TABLE t2;
133133
DROP TABLE t3;

storage/connect/mysql-test/connect/t/mul_new.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ SELECT * FROM t_all;
4949
--echo # Testing multiple 3
5050
--echo #
5151
ALTER TABLE t_all MULTIPLE=3;
52-
SELECT * FROM t_all;
52+
SELECT * FROM t_all ORDER BY Chiffre;
5353

5454
DROP TABLE t1;
5555
DROP TABLE t2;

storage/connect/myutil.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +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")
46-
|| !stricmp(typname, "enum"))
45+
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
46+
!stricmp(typname, "enum") || !stricmp(typname, "set"))
4747
type = TYPE_STRING;
4848
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
4949
!stricmp(typname, "real"))
@@ -88,11 +88,12 @@ int MYSQLtoPLG(char *typname, char *var)
8888
else if (!stricmp(typname, "year"))
8989
*var = 'Y';
9090

91-
} else if (type == TYPE_STRING && stricmp(typname, "char"))
92-
// This is to make the difference between CHAR and VARCHAR
93-
// and translate ENUM to VARCHAR
94-
*var = 'V';
95-
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)
9697
*var = 'K';
9798
else
9899
*var = 0;

0 commit comments

Comments
 (0)