mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
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
This commit is contained in:
@@ -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_REM, FLD_NO, FLD_DEFAULT, FLD_EXTRA,
|
||||
FLD_CHARSET};
|
||||
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, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
|
||||
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 len, type, prec, rc, k = 0;
|
||||
PQRYRES qrp;
|
||||
@@ -236,7 +237,18 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
*uns = 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:
|
||||
nf = sscanf(fld, "%[^(](%d,%d) %s %s", buf, &len, &prec, uns, zero);
|
||||
break;
|
||||
@@ -271,7 +283,10 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
colname, len);
|
||||
PushWarning(g, thd);
|
||||
v = 'V';
|
||||
} else
|
||||
} else if (v == 'N') {
|
||||
len = (int)strlen(buf);
|
||||
v = 0;
|
||||
} else
|
||||
len = MY_MIN(len, 4096);
|
||||
|
||||
} // endif type
|
||||
|
||||
@@ -43,7 +43,7 @@ Chiffre Lettre
|
||||
CREATE TABLE t4 (
|
||||
Chiffre int(3) 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');
|
||||
SELECT * FROM t4;
|
||||
Chiffre Lettre
|
||||
|
||||
@@ -28,7 +28,7 @@ SELECT * FROM t3;
|
||||
CREATE TABLE t4 (
|
||||
Chiffre int(3) 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');
|
||||
SELECT * FROM t4;
|
||||
|
||||
|
||||
@@ -42,7 +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"))
|
||||
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar")
|
||||
|| !stricmp(typname, "enum"))
|
||||
type = TYPE_STRING;
|
||||
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
|
||||
!stricmp(typname, "real"))
|
||||
@@ -87,9 +88,10 @@ int MYSQLtoPLG(char *typname, char *var)
|
||||
else if (!stricmp(typname, "year"))
|
||||
*var = 'Y';
|
||||
|
||||
} else if (type == TYPE_STRING && !stricmp(typname, "varchar"))
|
||||
// This is to make the difference between CHAR and VARCHAR
|
||||
*var = 'V';
|
||||
} 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)
|
||||
*var = 'K';
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user