Commit bf6cadf9 authored by Olivier Bertrand's avatar Olivier Bertrand

CONNECT Storage Engine:

The last commited changes have brought important additions to CONNECT.
1 - Replacement of setjmp/longjump's by try/catch/throw
2 - Support of multiple tables in subdirectories
3 - Support translating ENUM to VARCHAR for MYSQL tables.
4 - Tables based on ZIP files

Support ENUM data type for MYSQL tables.
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/myutil.cpp

Fix typo causing the test to fail on Linux.
  modified:   storage/connect/mysql-test/connect/r/mul_new.result
  modified:   storage/connect/mysql-test/connect/t/mul_new.test
parent cdc7a69e
...@@ -135,8 +135,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, ...@@ -135,8 +135,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL, FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL,
FLD_REM, FLD_NO, FLD_DEFAULT, FLD_EXTRA, FLD_REM, FLD_NO, FLD_DEFAULT, FLD_EXTRA,
FLD_CHARSET}; FLD_CHARSET};
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0}; //unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
char *fld, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16]; unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
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;
PQRYRES qrp; PQRYRES qrp;
...@@ -236,7 +237,18 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, ...@@ -236,7 +237,18 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
*uns = 0; *uns = 0;
*zero = 0; *zero = 0;
switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) { if (!strnicmp(fld, "enum", 4)) {
char *p2, *p1 = fld + 6; // to skip enum('
while (true) {
p2 = strchr(p1, '\'');
len = MY_MAX(len, p2 - p1);
if (*++p2 != ',') break;
p1 = p2 + 2;
} // endwhile
strcpy(buf, "enum");
} 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);
break; break;
...@@ -271,7 +283,10 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, ...@@ -271,7 +283,10 @@ 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 } else if (v == 'N') {
len = (int)strlen(buf);
v = 0;
} else
len = MY_MIN(len, 4096); len = MY_MIN(len, 4096);
} // endif type } // endif type
......
...@@ -43,7 +43,7 @@ Chiffre Lettre ...@@ -43,7 +43,7 @@ Chiffre Lettre
CREATE TABLE t4 ( CREATE TABLE t4 (
Chiffre int(3) NOT NULL, Chiffre int(3) NOT NULL,
Lettre char(16) NOT NULL) Lettre char(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='Subdir/num4.csv' LRECL=20 HEADER=1; ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='subdir/num4.csv' LRECL=20 HEADER=1;
INSERT INTO t4 VALUES(19,'Nineteen'),(20,'Twenty'),(21,'Twenty one'),(22,'Twenty two'),(23,'Tenty three'),(24,'Twenty four'); INSERT INTO t4 VALUES(19,'Nineteen'),(20,'Twenty'),(21,'Twenty one'),(22,'Twenty two'),(23,'Tenty three'),(24,'Twenty four');
SELECT * FROM t4; SELECT * FROM t4;
Chiffre Lettre Chiffre Lettre
......
...@@ -28,7 +28,7 @@ SELECT * FROM t3; ...@@ -28,7 +28,7 @@ SELECT * FROM t3;
CREATE TABLE t4 ( CREATE TABLE t4 (
Chiffre int(3) NOT NULL, Chiffre int(3) NOT NULL,
Lettre char(16) NOT NULL) Lettre char(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='Subdir/num4.csv' LRECL=20 HEADER=1; ENGINE=CONNECT TABLE_TYPE='CSV' FILE_NAME='subdir/num4.csv' LRECL=20 HEADER=1;
INSERT INTO t4 VALUES(19,'Nineteen'),(20,'Twenty'),(21,'Twenty one'),(22,'Twenty two'),(23,'Tenty three'),(24,'Twenty four'); INSERT INTO t4 VALUES(19,'Nineteen'),(20,'Twenty'),(21,'Twenty one'),(22,'Twenty two'),(23,'Tenty three'),(24,'Twenty four');
SELECT * FROM t4; SELECT * FROM t4;
......
...@@ -42,7 +42,8 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -42,7 +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"))
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"))
...@@ -87,9 +88,10 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -87,9 +88,10 @@ 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, "varchar")) } else if (type == TYPE_STRING && stricmp(typname, "char"))
// This is to make the difference between CHAR and VARCHAR // This is to make the difference between CHAR and VARCHAR
*var = 'V'; // and translate ENUM to VARCHAR
*var = 'V';
else if (type == TYPE_ERROR && xconv == TPC_SKIP) else if (type == TYPE_ERROR && xconv == TPC_SKIP)
*var = 'K'; *var = 'K';
else else
......
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