Commit 2d573a6c authored by Olivier Bertrand's avatar Olivier Bertrand

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
parent bf6cadf9
......@@ -140,6 +140,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
char *fld, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16];
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0;
bool b;
PQRYRES qrp;
PCOLRES crp;
MYSQLC myc;
......@@ -158,7 +159,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
/* Do an evaluation of the result size. */
/********************************************************************/
STRING cmd(g, 64, "SHOW FULL COLUMNS FROM ");
bool b = cmd.Append((PSZ)table);
b = cmd.Append((PSZ)table);
b |= cmd.Append(" FROM ");
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,
fld = myc.GetCharField(1);
prec = 0;
len = 0;
v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
// v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
v = 0;
*uns = 0;
*zero = 0;
b = false;
if (!strnicmp(fld, "enum", 4)) {
char *p2, *p1 = fld + 6; // to skip enum('
......@@ -246,8 +249,15 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
if (*++p2 != ',') break;
p1 = p2 + 2;
} // endwhile
v = (len > 255) ? 'V' : 0;
strcpy(buf, "enum");
b = true;
} else if (!strnicmp(fld, "set", 3)) {
len = (int)strlen(fld) - 2;
v = 'V';
strcpy(buf, "set");
b = true;
} else switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) {
case 3:
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,
colname, len);
PushWarning(g, thd);
v = 'V';
} else if (v == 'N') {
len = (int)strlen(buf);
v = 0;
} else
len = MY_MIN(len, 4096);
......@@ -301,6 +308,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
default: crp->Nulls[i] = v; break;
} // endswitch nf
if (b) // enum or set
nf = sscanf(fld, "%s ", buf); // get values
crp = crp->Next; // Type_Name
crp->Kdata->SetValue(buf, i);
......
......@@ -96,7 +96,7 @@ Chiffre Lettre
ALTER TABLE t_all MULTIPLE=3;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
SELECT * FROM t_all;
SELECT * FROM t_all ORDER BY Chiffre;
Chiffre Lettre
1 One
2 Two
......@@ -104,30 +104,30 @@ Chiffre Lettre
4 Four
5 Five
6 Six
13 Thirteen
14 Fourteen
15 Fifteen
16 Sixteen
17 Seventeen
18 Eighteen
25 Twenty five
26 Twenty six
27 Twenty seven
28 Twenty eight
29 Tenty eight
30 Thirty
7 Seven
8 Eight
9 Nine
10 Ten
11 Eleven
12 Twelve
13 Thirteen
14 Fourteen
15 Fifteen
16 Sixteen
17 Seventeen
18 Eighteen
19 Nineteen
20 Twenty
21 Twenty one
22 Twenty two
23 Tenty three
24 Twenty four
25 Twenty five
26 Twenty six
27 Twenty seven
28 Twenty eight
29 Tenty eight
30 Thirty
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
......
......@@ -49,7 +49,7 @@ SELECT * FROM t_all;
--echo # Testing multiple 3
--echo #
ALTER TABLE t_all MULTIPLE=3;
SELECT * FROM t_all;
SELECT * FROM t_all ORDER BY Chiffre;
DROP TABLE t1;
DROP TABLE t2;
......
......@@ -42,8 +42,8 @@ int MYSQLtoPLG(char *typname, char *var)
type = TYPE_INT;
else if (!stricmp(typname, "smallint"))
type = TYPE_SHORT;
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar")
|| !stricmp(typname, "enum"))
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
!stricmp(typname, "enum") || !stricmp(typname, "set"))
type = TYPE_STRING;
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
!stricmp(typname, "real"))
......@@ -88,11 +88,12 @@ int MYSQLtoPLG(char *typname, char *var)
else if (!stricmp(typname, "year"))
*var = 'Y';
} else if (type == TYPE_STRING && stricmp(typname, "char"))
// This is to make the difference between CHAR and VARCHAR
// and translate ENUM to VARCHAR
*var = 'V';
else if (type == TYPE_ERROR && xconv == TPC_SKIP)
} else if (type == TYPE_STRING) {
if (!stricmp(typname, "varchar"))
// This is to make the difference between CHAR and VARCHAR
*var = 'V';
} else if (type == TYPE_ERROR && xconv == TPC_SKIP)
*var = 'K';
else
*var = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment