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/xindex.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/xindex.cpp')
-rwxr-xr-x | storage/connect/xindex.cpp | 101 |
1 files changed, 92 insertions, 9 deletions
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index caa7c667419..e36d958f28a 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -61,6 +61,9 @@ /***********************************************************************/ extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */ extern "C" int trace; +#if defined(XMAP) +extern bool xmap; +#endif // XMAP /***********************************************************************/ /* Last two parameters are true to enable type checking, and last one */ @@ -810,12 +813,16 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp) return rc; } // end of SaveIndex -#if !defined(XMAP) /***********************************************************************/ /* Init: Open and Initialize a Key Index. */ /***********************************************************************/ bool XINDEX::Init(PGLOBAL g) { +#if defined(XMAP) + if (xmap) + return MapInit(g); +#endif // XMAP + /*********************************************************************/ /* Table will be accessed through an index table. */ /* If sorting is required, this will be done later. */ @@ -1051,11 +1058,11 @@ err: return true; } // end of Init -#else // XMAP +#if defined(XMAP) /***********************************************************************/ /* Init: Open and Initialize a Key Index. */ /***********************************************************************/ -bool XINDEX::Init(PGLOBAL g) +bool XINDEX::MapInit(PGLOBAL g) { /*********************************************************************/ /* Table will be accessed through an index table. */ @@ -1256,7 +1263,7 @@ bool XINDEX::Init(PGLOBAL g) err: Close(); return true; - } // end of Init + } // end of MapInit #endif // XMAP /***********************************************************************/ @@ -1564,6 +1571,46 @@ bool XINDEX::NextVal(bool eq) } // end of NextVal /***********************************************************************/ +/* XINDEX: Find Cur_K and Val_K's of previous index entry. */ +/* Returns false if Ok, true if there are no more values. */ +/***********************************************************************/ +bool XINDEX::PrevVal(void) + { + int n, neq = Nk + 1, curk; + PXCOL kcp; + + if (Cur_K == 0) + return true; + else + curk = --Cur_K; + + for (n = Nk, kcp = To_LastCol; kcp; n--, kcp = kcp->Previous) { + if (kcp->Kof) { + if (curk < kcp->Kof[kcp->Val_K]) + neq = n; + + } else { +#ifdef _DEBUG + assert(curk == kcp->Val_K -1); +#endif // _DEBUG + neq = n; + } // endif Kof + +#ifdef _DEBUG + assert(kcp->Val_K >= 0); +#endif // _DEBUG + + // If this is not a break... + if (neq > n) + break; // all previous columns have same value + + curk = --kcp->Val_K; // This is a break, get new column value + } // endfor kcp + + return false; + } // end of PrevVal + +/***********************************************************************/ /* XINDEX: Fetch a physical or logical record. */ /***********************************************************************/ int XINDEX::Fetch(PGLOBAL g) @@ -1615,6 +1662,12 @@ int XINDEX::Fetch(PGLOBAL g) Op = (Mul || Nval < Nk) ? OP_NXTDIF : OP_NEXT; break; + case OP_LAST: // Read last key + for (Cur_K = Num_K - 1, kp = To_KeyCol; kp; kp = kp->Next) + kp->Val_K = kp->Kblp->GetNval() - 1; + + Op = OP_NEXT; + break; default: // Should be OP_EQ // if (Tbxp->Key_Rank < 0) { /***************************************************************/ @@ -1852,6 +1905,25 @@ int XINDXS::GroupSize(void) } // end of GroupSize /***********************************************************************/ +/* XINDXS: Find Cur_K and Val_K of previous index value. */ +/* Returns false if Ok, true if there are no more values. */ +/***********************************************************************/ +bool XINDXS::PrevVal(void) + { + if (--Cur_K < 0) + return true; + + if (Mul) { + if (Cur_K < Pof[To_KeyCol->Val_K]) + To_KeyCol->Val_K--; + + } else + To_KeyCol->Val_K = Cur_K; + + return false; + } // end of PrevVal + +/***********************************************************************/ /* XINDXS: Find Cur_K and Val_K of next index value. */ /* If b is true next value must be equal to last one. */ /* Returns false if Ok, true if there are no more (equal) values. */ @@ -1895,12 +1967,12 @@ int XINDXS::Fetch(PGLOBAL g) /* Table read through a sorted index. */ /*********************************************************************/ switch (Op) { - case OP_NEXT: // Read next + case OP_NEXT: // Read next if (NextVal(false)) return -1; // End of indexed file break; - case OP_FIRST: // Read first + case OP_FIRST: // Read first To_KeyCol->Val_K = Cur_K = 0; Op = OP_NEXT; break; @@ -1914,7 +1986,7 @@ int XINDXS::Fetch(PGLOBAL g) } // endif Mul break; - case OP_NXTDIF: // Read next dif + case OP_NXTDIF: // Read next dif if (++To_KeyCol->Val_K == Ndif) return -1; // End of indexed file @@ -1924,7 +1996,17 @@ int XINDXS::Fetch(PGLOBAL g) To_KeyCol->Val_K = Cur_K = 0; Op = (Mul) ? OP_NXTDIF : OP_NEXT; break; - default: // Should OP_EQ + case OP_LAST: // Read first + Cur_K = Num_K - 1; + To_KeyCol->Val_K = Ndif - 1; + Op = OP_PREV; + break; + case OP_PREV: // Read previous + if (PrevVal()) + return -1; // End of indexed file + + break; + default: // Should be OP_EQ /*****************************************************************/ /* Look for the first key equal to the link column values */ /* and return its rank whithin the index table. */ @@ -2837,7 +2919,8 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m) } // endif n[1] Ndf = n[0]; - IsSorted = colp->GetOpt() < 0; +//IsSorted = colp->GetOpt() < 0; + IsSorted = false; return m + Bkeys.Size + Keys.Size + Koff.Size; } // end of MapInit #endif // XMAP |