diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-05-30 10:59:34 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-05-30 10:59:34 +0200 |
commit | 514a7d8462aa4aa0a2acac54355b1d0cfb35695f (patch) | |
tree | 84ae797a06a8e9fd5d8bf5e22ce2f2d43cbe793f | |
parent | b6a56370d6e833f8033169ebb4e91cdce4d911aa (diff) | |
download | mariadb-git-514a7d8462aa4aa0a2acac54355b1d0cfb35695f.tar.gz |
Add unicode ODBC types to the types recognized by CONNECT.
Was added in function TranslateSQLType.
modified: storage/connect/ha_connect.cc
modified: storage/connect/odbconn.cpp
modified: storage/connect/value.h
Add some trace in particular in indexing routines.
modified: storage/connect/block.h
modified: storage/connect/ha_connect.cc
modified: storage/connect/plugutil.c
modified: storage/connect/xindex.cpp
modified: storage/connect/xindex.h
-rw-r--r-- | storage/connect/block.h | 2 | ||||
-rw-r--r-- | storage/connect/ha_connect.cc | 15 | ||||
-rw-r--r-- | storage/connect/odbconn.cpp | 14 | ||||
-rw-r--r-- | storage/connect/plugutil.c | 4 | ||||
-rw-r--r-- | storage/connect/value.h | 5 | ||||
-rwxr-xr-x | storage/connect/xindex.cpp | 62 | ||||
-rw-r--r-- | storage/connect/xindex.h | 2 |
7 files changed, 80 insertions, 24 deletions
diff --git a/storage/connect/block.h b/storage/connect/block.h index 69cec39e8a5..aa4edde5ec9 100644 --- a/storage/connect/block.h +++ b/storage/connect/block.h @@ -38,7 +38,7 @@ typedef class BLOCK *PBLOCK; class DllExport BLOCK { public: void * operator new(size_t size, PGLOBAL g, void *p = NULL) { -// if (trace > 2) +// if (trace > 3) // htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); return (PlugSubAlloc(g, p, size)); diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index da357faa171..6769760c5fa 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -4755,6 +4755,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, else rows= HA_POS_ERROR; + if (trace) + htrc("records_in_range: rows=%llu\n", rows); + DBUG_RETURN(rows); } // end of records_in_range @@ -5523,10 +5526,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd, #if defined(ODBC_SUPPORT) if (ttp == TAB_ODBC) { - int plgtyp; + int plgtyp; + bool w= false; // Wide character type // typ must be PLG type, not SQL type - if (!(plgtyp= TranslateSQLType(typ, dec, prec, v))) { + if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) { if (GetTypeConv() == TPC_SKIP) { // Skip this column sprintf(g->Message, "Column %s skipped (unsupported type %d)", @@ -5543,6 +5547,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd, typ= plgtyp; switch (typ) { + case TYPE_STRING: + if (w) { + sprintf(g->Message, "Column %s is wide characters", cnm); + push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message); + } // endif w + + break; case TYPE_DOUBLE: // Some data sources do not count dec in length (prec) prec += (dec + 2); // To be safe diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 0c89f8404f6..6aaa048de81 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -116,16 +116,24 @@ static int GetSQLCType(int type) /***********************************************************************/ /* TranslateSQLType: translate a SQL Type to a PLG type. */ /***********************************************************************/ -int TranslateSQLType(int stp, int prec, int& len, char& v) +int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w) { int type; switch (stp) { + case SQL_WVARCHAR: // (-9) + w = true; case SQL_VARCHAR: // 12 v = 'V'; + type = TYPE_STRING; + break; + case SQL_WCHAR: // (-8) + w = true; case SQL_CHAR: // 1 type = TYPE_STRING; break; + case SQL_WLONGVARCHAR: // (-10) + w = true; case SQL_LONGVARCHAR: // (-1) v = 'V'; type = TYPE_STRING; @@ -180,7 +188,6 @@ int TranslateSQLType(int stp, int prec, int& len, char& v) case SQL_BINARY: // (-2) case SQL_VARBINARY: // (-3) case SQL_LONGVARBINARY: // (-4) -// case SQL_BIT: // (-7) case SQL_GUID: // (-11) default: type = TYPE_ERROR; @@ -410,6 +417,7 @@ PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop) PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) { // int i, type, len, prec; + bool w = false; // PCOLRES crp, crpt, crpl, crpp; PQRYRES qrp; ODBConn *ocp; @@ -455,7 +463,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) type = crpt->Kdata->GetIntValue(i); len = crpl->Kdata->GetIntValue(i); prec = crpp->Kdata->GetIntValue(i); - type = TranslateSQLType(type, prec, len); + type = TranslateSQLType(type, prec, len, w); crpt->Kdata->SetValue(type, i); // Some data sources do not count prec in length diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c index 63526f5fc48..c0e249adf12 100644 --- a/storage/connect/plugutil.c +++ b/storage/connect/plugutil.c @@ -502,7 +502,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ pph = (PPOOLHEADER)memp; - if (trace > 2) + if (trace > 3) htrc("SubAlloc in %p size=%d used=%d free=%d\n", memp, size, pph->To_Free, pph->FreeBlk); @@ -526,7 +526,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) pph->To_Free += size; /* New offset of pool free block */ pph->FreeBlk -= size; /* New size of pool free block */ - if (trace > 2) + if (trace > 3) htrc("Done memp=%p used=%d free=%d\n", memp, pph->To_Free, pph->FreeBlk); diff --git a/storage/connect/value.h b/storage/connect/value.h index 207944594f1..f8cd1ba65a7 100644 --- a/storage/connect/value.h +++ b/storage/connect/value.h @@ -36,8 +36,9 @@ typedef struct _datpar *PDTP; // For DTVAL DllExport PSZ GetTypeName(int); DllExport int GetTypeSize(int, int); #ifdef ODBC_SUPPORT -/* This function is exported for use in EOM table type DLLs */ -DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); +/* This function is exported for use in OEM table type DLLs */ +DllExport int TranslateSQLType(int stp, int prec, + int& len, char& v, bool& w); #endif DllExport char *GetFormatType(int); DllExport int GetFormatType(char); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 85b3fc9751c..a2d75cec8ab 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -340,6 +340,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } // endif n + if (trace) + htrc("XINDEX Make: n=%d\n", n); + // File position must be stored Record.Size = n * sizeof(int); @@ -477,6 +480,9 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) } else To_Rec[nkey] = Tdbp->GetRecpos(); + if (trace > 1) + htrc("Make: To_Rec[%d]=%d\n", nkey, To_Rec[nkey]); + /*******************************************************************/ /* Get the keys and place them in the key blocks. */ /*******************************************************************/ @@ -1759,6 +1765,9 @@ int XINDEX::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file + if (trace > 1) + htrc("XINDEX Fetch: Op=%d\n", Op); + /*********************************************************************/ /* Table read through a sorted index. */ /*********************************************************************/ @@ -1776,9 +1785,6 @@ int XINDEX::Fetch(PGLOBAL g) break; case OP_SAME: // Read next same // Logically the key values should be the same as before - if (trace > 1) - htrc("looking for next same value\n"); - if (NextVal(true)) { Op = OP_EQ; return -2; // no more equal values @@ -1824,7 +1830,7 @@ int XINDEX::Fetch(PGLOBAL g) Nth++; if (trace > 1) - htrc("Fetch: Looking for new value\n"); + htrc("Fetch: Looking for new value Nth=%d\n", Nth); Cur_K = FastFind(); @@ -1896,6 +1902,10 @@ int XINDEX::FastFind(void) sup = To_KeyCol->Ndf; } // endif Nblk + if (trace > 2) + htrc("XINDEX FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", + Nblk, Op, inf, sup); + for (k = 0, kcp = To_KeyCol; kcp; kcp = kcp->Next) { while (sup - inf > 1) { i = (inf + sup) >> 1; @@ -1970,6 +1980,9 @@ int XINDEX::FastFind(void) curk = (kcp->Kof) ? kcp->Kof[kcp->Val_K] : kcp->Val_K; } // endfor kcp + if (trace > 2) + htrc("XINDEX FastFind: curk=%d\n", curk); + return curk; } // end of FastFind @@ -2043,8 +2056,7 @@ int XINDXS::GroupSize(void) #if defined(_DEBUG) assert(To_KeyCol->Val_K >= 0 && To_KeyCol->Val_K < Ndif); #endif // _DEBUG - return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] - : 1; + return (Pof) ? Pof[To_KeyCol->Val_K + 1] - Pof[To_KeyCol->Val_K] : 1; } // end of GroupSize /***********************************************************************/ @@ -2106,6 +2118,9 @@ int XINDXS::Fetch(PGLOBAL g) if (Num_K == 0) return -1; // means end of file + if (trace > 1) + htrc("XINDXS Fetch: Op=%d\n", Op); + /*********************************************************************/ /* Table read through a sorted index. */ /*********************************************************************/ @@ -2120,9 +2135,6 @@ int XINDXS::Fetch(PGLOBAL g) Op = OP_NEXT; break; case OP_SAME: // Read next same - if (trace > 1) - htrc("looking for next same value\n"); - if (!Mul || NextVal(true)) { Op = OP_EQ; return -2; // No more equal values @@ -2160,7 +2172,7 @@ int XINDXS::Fetch(PGLOBAL g) Nth++; if (trace > 1) - htrc("Fetch: Looking for new value\n"); + htrc("Fetch: Looking for new value Nth=%d\n", Nth); Cur_K = FastFind(); @@ -2192,7 +2204,7 @@ int XINDXS::Fetch(PGLOBAL g) /***********************************************************************/ int XINDXS::FastFind(void) { - register int sup, inf, i= 0, n = 2; + register int sup, inf, i= 0, n = 2; register PXCOL kcp = To_KeyCol; if (Nblk && Op == OP_EQ) { @@ -2215,7 +2227,6 @@ int XINDXS::FastFind(void) if (inf < 0) return Num_K; -// i = inf; inf *= Sblk; if ((sup = inf + Sblk) > Ndif) @@ -2227,6 +2238,10 @@ int XINDXS::FastFind(void) sup = Ndif; } // endif Nblk + if (trace > 2) + htrc("XINDXS FastFind: Nblk=%d Op=%d inf=%d sup=%d\n", + Nblk, Op, inf, sup); + while (sup - inf > 1) { i = (inf + sup) >> 1; @@ -2249,6 +2264,9 @@ int XINDXS::FastFind(void) n = 0; } // endif sup + if (trace > 2) + htrc("XINDXS FastFind: n=%d i=%d\n", n, i); + // Loop on kcp because of dynamic indexing for (; kcp; kcp = kcp->Next) kcp->Val_K = i; // Used by FillValue @@ -2330,6 +2348,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) } // endif NewOff.Low = (int)ftell(Xfile); + + if (trace) + htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + } else if (mode == MODE_WRITE) { if (id >= 0) { // New not sep index file. Write the header. @@ -2337,6 +2359,10 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) Write(g, noff, sizeof(IOFF), MAX_INDX, rc); fseek(Xfile, 0, SEEK_END); NewOff.Low = (int)ftell(Xfile); + + if (trace) + htrc("XFILE Open: NewOff.Low=%d\n", NewOff.Low); + } // endif id } else if (mode == MODE_READ && id >= 0) { @@ -2346,6 +2372,9 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode) return true; } // endif MAX_INDX + if (trace) + htrc("XFILE Open: noff[%d].Low=%d\n", id, noff[id].Low); + // Position the cursor at the offset of this index if (fseek(Xfile, noff[id].Low, SEEK_SET)) { sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek"); @@ -3158,12 +3187,18 @@ bool KXYCOL::InitFind(PGLOBAL g, PXOB xp) xp->Reset(); xp->Eval(g); Valp->SetValue_pval(xp->GetValue(), false); -// Valp->SetValue_pval(xp->GetValue(), !Prefix); } // endif Type + if (trace > 1) { + char buf[32]; + + htrc("KCOL InitFind: value=%s\n", Valp->GetCharString(buf)); + } // endif trace + return false; } // end of InitFind +#if 0 /***********************************************************************/ /* InitBinFind: initialize Value to the value pointed by vp. */ /***********************************************************************/ @@ -3171,6 +3206,7 @@ void KXYCOL::InitBinFind(void *vp) { Valp->SetBinValue(vp); } // end of InitBinFind +#endif // 0 /***********************************************************************/ /* KXYCOL FillValue: called by COLBLK::Eval when a column value is */ diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h index ad34259501f..a4e98075222 100644 --- a/storage/connect/xindex.h +++ b/storage/connect/xindex.h @@ -462,7 +462,7 @@ class KXYCOL: public BLOCK { virtual void FreeData(void); virtual void FillValue(PVAL valp); virtual int CompVal(int i); - void InitBinFind(void *vp); +// void InitBinFind(void *vp); bool MakeBlockArray(PGLOBAL g, int nb, int size); int Compare(int i1, int i2); int CompBval(int i); |