diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2014-04-19 11:11:30 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2014-04-19 11:11:30 +0200 |
commit | 812520315318e358d2d9daf9ca709578af1efe40 (patch) | |
tree | d5dff4f4c06aa4554707a6ad717dc73a576313d0 /storage/connect/myconn.cpp | |
parent | cc7a08c9410335237e6c19f84d9c5d08938b8e8a (diff) | |
parent | b43e82dce63c07abe8de740b3bf18a33600ccac0 (diff) | |
download | mariadb-git-812520315318e358d2d9daf9ca709578af1efe40.tar.gz |
- Commit merged files
modified:
storage/connect/CMakeLists.txt
storage/connect/connect.h
storage/connect/global.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/myconn.cpp
storage/connect/myconn.h
storage/connect/mysql-test/connect/r/pivot.result
storage/connect/mysql-test/connect/suite.pm
storage/connect/mysql-test/connect/t/pivot.test
storage/connect/myutil.cpp
storage/connect/osutil.c
storage/connect/plgdbsem.h
storage/connect/plugutil.c
storage/connect/tabmysql.cpp
storage/connect/tabpivot.cpp
storage/connect/tabutil.cpp
storage/connect/user_connect.cc
storage/connect/valblk.cpp
storage/connect/valblk.h
storage/connect/value.cpp
storage/connect/value.h
storage/connect/xindex.cpp
storage/connect/xindex.h
Diffstat (limited to 'storage/connect/myconn.cpp')
-rw-r--r-- | storage/connect/myconn.cpp | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 3d0a3d86136..18c80f2b24e 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 @@ -284,7 +307,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, if (!port) port = mysqld_port; - if (!strnicmp(srcdef, "select ", 7)) { + if (!strnicmp(srcdef, "select ", 7)) { query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9); strcat(strcpy(query, srcdef), " LIMIT 0"); } else @@ -608,7 +631,7 @@ if (w) /***********************************************************************/ void MYSQLC::DataSeek(my_ulonglong row) { - MYSQL_ROWS *tmp=0; + MYSQL_ROWS *tmp=0; //DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row)); if (m_Res->data) @@ -783,7 +806,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) else { if (!*row && crp->Nulls) crp->Nulls[n] = '*'; // Null value - + crp->Kdata->Reset(n); } // endelse *row } @@ -880,7 +903,7 @@ void MYSQLC::DiscardResults(void) while (!mysql_next_result(m_DB)) { res = mysql_store_result(m_DB); mysql_free_result(res); - } // endwhile next result + } // endwhile next result } // end of DiscardResults #endif // 0 |