diff options
Diffstat (limited to 'storage/connect/myconn.cpp')
-rw-r--r-- | storage/connect/myconn.cpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 3d0a3d86136..e8b72cd3643 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -47,9 +47,12 @@ #include "myconn.h" extern "C" int trace; +extern "C" int zconv; extern MYSQL_PLUGIN_IMPORT uint mysqld_port; extern MYSQL_PLUGIN_IMPORT char *mysqld_unix_port; +DllExport void PushWarning(PGLOBAL, THD*, int level = 1); + // Returns the current used port uint GetDefaultPort(void) { @@ -61,7 +64,7 @@ uint GetDefaultPort(void) /* of a MySQL table or view. */ /* info = TRUE to get catalog column informations. */ /************************************************************************/ -PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, +PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, const char *user, const char *pwd, const char *table, const char *colpat, int port, bool info) @@ -75,7 +78,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, 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, *fmt, v, cmd[128], uns[16], zero[16]; + char *fld, *colname, *chset, *fmt, v, cmd[128], uns[16], zero[16]; int i, n, nf, ncol = sizeof(buftyp) / sizeof(int); int len, type, prec, rc, k = 0; PQRYRES qrp; @@ -144,23 +147,24 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, /**********************************************************************/ /* Now get the results into blocks. */ /**********************************************************************/ - for (i = 0; i < n; i++) { - if ((rc = myc.Fetch(g, -1) == RC_FX)) { + for (i = 0; i < n; /*i++*/) { + if ((rc = myc.Fetch(g, -1)) == RC_FX) { myc.Close(); return NULL; - } else if (rc == RC_NF) + } else if (rc == RC_EF) break; // Get column name - fld = myc.GetCharField(0); + colname = myc.GetCharField(0); crp = qrp->Colresp; // Column_Name - crp->Kdata->SetValue(fld, i); + crp->Kdata->SetValue(colname, i); // Get type, type name, precision, unsigned and zerofill + chset = myc.GetCharField(2); fld = myc.GetCharField(1); prec = 0; len = 0; - v = 0; + v = (chset && !strcmp(chset, "binary")) ? 'B' : 0; *uns = 0; *zero = 0; @@ -181,11 +185,28 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, } // endswitch nf if ((type = MYSQLtoPLG(cmd, &v)) == TYPE_ERROR) { - sprintf(g->Message, "Unsupported column type %s", cmd); + if (v == 'K') { + // Skip this column + sprintf(g->Message, "Column %s skipped (unsupported type %s)", + colname, cmd); + PushWarning(g, thd); + continue; + } // endif v + + sprintf(g->Message, "Column %s unsupported type %s", colname, cmd); myc.Close(); return NULL; - } else if (type == TYPE_STRING) - len = min(len, 4096); + } else if (type == TYPE_STRING) { + if (v == 'X') { + len = zconv; + sprintf(g->Message, "Column %s converted to varchar(%d)", + colname, len); + PushWarning(g, thd); + v = 'V'; + } else + len = min(len, 4096); + + } // endif type qrp->Nblin++; crp = crp->Next; // Data_Type @@ -241,8 +262,10 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, crp->Kdata->SetValue(fld, i); crp = crp->Next; // New (charset) - fld = myc.GetCharField(2); + fld = chset; crp->Kdata->SetValue(fld, i); + + i++; // Can be skipped } // endfor i #if 0 |