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