Commit 3f361af7 authored by Olivier Bertrand's avatar Olivier Bertrand

- FIX MDEV-5989 (max(indexed) doesn't work)

  By implementing index_last
modified:
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/xindex.cpp

- Adding the TYPE_BIN Connect internal type
  (not tested and not used yet)
modified:
  storage/connect/global.h
  storage/connect/value.cpp
  storage/connect/value.h
parent b1ae8341
......@@ -84,6 +84,7 @@
#define TYPE_LIST 6
#define TYPE_INT 7
#define TYPE_DECIM 9
#define TYPE_BIN 10
#if defined(OS32)
#define SYS_STAMP "OS32"
......
......@@ -2482,7 +2482,6 @@ int ha_connect::index_first(uchar *buf)
} // end of index_first
#ifdef NOT_USED
/**
@brief
index_last() asks for the last key in the index.
......@@ -2496,9 +2495,15 @@ int ha_connect::index_first(uchar *buf)
int ha_connect::index_last(uchar *buf)
{
DBUG_ENTER("ha_connect::index_last");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
#endif // NOT_USED
int rc;
if (indexing <= 0) {
rc= HA_ERR_INTERNAL_ERROR;
} else
rc= ReadIndexed(buf, OP_LAST);
DBUG_RETURN(rc);
} // end of index_last
/****************************************************************************/
......
......@@ -241,7 +241,8 @@ public:
*/
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return HA_READ_NEXT | HA_READ_RANGE | HA_READ_ORDER | HA_KEYREAD_ONLY;
return HA_READ_NEXT | HA_READ_RANGE | HA_READ_ORDER
| HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR;
} // end of index_flags
/** @brief
......@@ -416,7 +417,7 @@ const char *GetValStr(OPVAL vop, bool neg);
We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented.
*/
//int index_last(uchar *buf);
int index_last(uchar *buf);
/* Index condition pushdown implementation */
//Item *idx_cond_push(uint keyno, Item* idx_cond);
......
This diff is collapsed.
/**************** Value H Declares Source Code File (.H) ***************/
/* Name: VALUE.H Version 2.0 */
/* Name: VALUE.H Version 2.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
/* (C) Copyright to the author Olivier BERTRAND 2001-2014 */
/* */
/* This file contains the VALUE and derived classes declares. */
/***********************************************************************/
......@@ -276,6 +276,62 @@ class DllExport DECVAL: public TYPVAL<PSZ> {
// Members
}; // end of class DECVAL
/***********************************************************************/
/* Specific BINARY class. */
/***********************************************************************/
class DllExport BINVAL: public VALUE {
public:
// Constructors
//BINVAL(void *p);
BINVAL(PGLOBAL g, void *p, int cl, int n);
// Implementation
virtual bool IsTypeNum(void) {return false;}
virtual bool IsZero(void);
virtual void Reset(void);
virtual int GetValLen(void) {return Clen;};
virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return Len;}
virtual PSZ GetCharValue(void) {return (PSZ)Binp;}
virtual char GetTinyValue(void);
virtual uchar GetUTinyValue(void);
virtual short GetShortValue(void);
virtual ushort GetUShortValue(void);
virtual int GetIntValue(void);
virtual uint GetUIntValue(void);
virtual longlong GetBigintValue(void);
virtual ulonglong GetUBigintValue(void);
virtual double GetFloatValue(void);
virtual void *GetTo_Val(void) {return Binp;}
// Methods
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(char c);
virtual void SetValue(uchar c);
virtual void SetValue(short i);
virtual void SetValue(ushort i);
virtual void SetValue(int n);
virtual void SetValue(uint n);
virtual void SetValue(longlong n);
virtual void SetValue(ulonglong n);
virtual void SetValue(double f);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
// Members
void *Binp;
char *Chrp;
int Len;
}; // end of class BINVAL
/***********************************************************************/
/* Class DTVAL: represents a time stamp value. */
/***********************************************************************/
......
......@@ -1627,6 +1627,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) {
/***************************************************************/
......@@ -1938,6 +1944,11 @@ int XINDXS::Fetch(PGLOBAL g)
To_KeyCol->Val_K = Cur_K = 0;
Op = (Mul) ? OP_NXTDIF : OP_NEXT;
break;
case OP_LAST: // Read first
Cur_K = Num_K - 1;
To_KeyCol->Val_K = To_KeyCol->Kblp->GetNval() - 1;
Op = OP_NEXT;
break;
default: // Should OP_EQ
/*****************************************************************/
/* Look for the first key equal to the link column values */
......
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