Commit 514a7d84 authored by Olivier Bertrand's avatar Olivier Bertrand

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