Commit 38c3fd20 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-6802 in a clean way.

  Add an union in the PARM structure to contain int values
  Use a cast to ptrdiff_t in MAPFAM/MXPFAM::InitDelete required by some compilers
modified:
  storage/connect/array.cpp
  storage/connect/filamap.cpp
  storage/connect/filamtxt.cpp
  storage/connect/global.h
  
- Suppress some GCC warnings
modified:
  storage/connect/array.cpp
  storage/connect/filter.cpp
  storage/connect/tabdos.cpp
  storage/connect/tabmysql.cpp
  storage/connect/value.cpp
parent dd5eb7ae
......@@ -130,7 +130,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
break;
case TYPE_VOID:
// Integer stored inside pp->Value
par->AddValue(g, (int)(uintptr_t)parmp->Value);
par->AddValue(g, parmp->Intval);
break;
} // endswitch valtyp
......@@ -609,13 +609,13 @@ int ARRAY::Convert(PGLOBAL g, int k, PVAL vp)
Size = Nval;
Nval = 0;
Vblp = Valblk->Allocate(g, Type, Len, 0, Size);
Vblp = Valblk->Allocate(g, Type, Len, prec, Size);
if (!Valblk->GetMemp())
// The error message was built by PlgDBalloc
return TYPE_ERROR;
else
Value = AllocateValue(g, Type, Len, 0, NULL);
Value = AllocateValue(g, Type, Len, prec, NULL);
/*********************************************************************/
/* Converting STRING to DATE can be done according to date format. */
......
......@@ -30,7 +30,6 @@
#include <io.h>
#endif // !UNIX
#include <fcntl.h>
#include <stdint.h> // for uintprt_h
#endif // !WIN32
/***********************************************************************/
......@@ -291,8 +290,8 @@ bool MAPFAM::RecordPos(PGLOBAL g)
/***********************************************************************/
int MAPFAM::InitDelete(PGLOBAL g, int fpos, int spos)
{
Fpos = Memory + (uintptr_t)fpos;
Mempos = Memory + (uintptr_t)spos;
Fpos = Memory + (ptrdiff_t)fpos;
Mempos = Memory + (ptrdiff_t)spos;
return RC_OK;
} // end of InitDelete
......@@ -686,7 +685,7 @@ bool MPXFAM::SetPos(PGLOBAL g, int pos)
/***********************************************************************/
int MPXFAM::InitDelete(PGLOBAL g, int fpos, int spos)
{
Fpos = Memory + Headlen + (uintptr_t)fpos * Lrecl;
Fpos = Memory + Headlen + (ptrdiff_t)fpos * Lrecl;
Mempos = Fpos + Lrecl;
return RC_OK;
} // end of InitDelete
......
......@@ -287,7 +287,7 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
// *((int*)pp->Value) = *((int*)val);
// break;
case TYPE_VOID:
pp->Value = (void*)*(int*)val;
pp->Intval = *(int*)val;
break;
// case TYPE_STRING:
// pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1);
......
......@@ -63,7 +63,7 @@ static PPARM MakeParm(PGLOBAL g, PXOB xp)
} // end of MakeParm
/***********************************************************************/
/* Routines called externally by FILTER function. */
/* Routines called internally/externally by FILTER functions. */
/***********************************************************************/
bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
//bool ReadSubQuery(PGLOBAL, PSUBQ);
......@@ -72,6 +72,32 @@ bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
BYTE OpBmp(PGLOBAL g, OPVAL opc);
PARRAY MakeValueArray(PGLOBAL g, PPARM pp);
/***********************************************************************/
/* Returns the bitmap representing the conditions that must not be */
/* met when returning from TestValue for a given operator. */
/* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */
/***********************************************************************/
BYTE OpBmp(PGLOBAL g, OPVAL opc)
{
BYTE bt;
switch (opc) {
case OP_IN:
case OP_EQ: bt = 0x06; break;
case OP_NE: bt = 0x01; break;
case OP_GT: bt = 0x03; break;
case OP_GE: bt = 0x02; break;
case OP_LT: bt = 0x05; break;
case OP_LE: bt = 0x04; break;
case OP_EXIST: bt = 0x00; break;
default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
} // endswitch opc
return bt;
} // end of OpBmp
/***********************************************************************/
/* Routines called externally by CondFilter. */
/***********************************************************************/
......
......@@ -205,7 +205,10 @@ typedef struct _activity { /* Describes activity and language */
/*---------------- UNIT ?????????? VERSION ? ----------------------*/
typedef struct _parm {
void *Value;
union {
void *Value;
int Intval;
}; // end union
short Type, Domain;
PPARM Next;
} PARM;
......
......@@ -322,7 +322,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
&& mode == MODE_UPDATE) &&
!(tmp == TMP_FORCE &&
(mode == MODE_UPDATE || mode == MODE_DELETE));
PTXF txfp;
PTXF txfp = NULL;
PTDBASE tdbp;
/*********************************************************************/
......@@ -574,7 +574,7 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
int TDBDOS::MakeBlockValues(PGLOBAL g)
{
int i, lg, nrec, rc, n = 0;
int curnum, curblk, block, last, savndv, savnbm;
int curnum, curblk, block, savndv, savnbm;
void *savmin, *savmax;
bool blocked, xdb2 = false;
//POOLHEADER save;
......@@ -611,7 +611,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
// to Rows+1 by unblocked variable length table access methods.
curblk = -1;
curnum = nrec - 1;
last = 0;
//last = 0;
Txfp->Block = block; // This is useful mainly for
Txfp->CurBlk = curblk; // blocked tables (ZLBFAM), for
Txfp->CurNum = curnum; // others it is just to be clean.
......@@ -742,7 +742,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
Txfp->BlkPos[curblk] = Txfp->GetPos();
} // endif CurNum
last = curnum + 1; // curnum is zero based
// last = curnum + 1; // curnum is zero based
Txfp->CurBlk = curblk; // Used in COLDOS::SetMinMax
Txfp->CurNum = curnum; // Used in COLDOS::SetMinMax
} // endif blocked
......@@ -1351,7 +1351,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
//int i, n1, n2, ctype = TYPE_ERROR, n = 0, type[2] = {0,0};
//bool conv = false, xdb2 = false, ok = false, b[2];
//PXOB *xarg1, *xarg2 = NULL, xp[2];
int i, ctype = TYPE_ERROR, n = 0, type[2] = {0,0};
int i, n = 0, type[2] = {0,0};
bool conv = false, xdb2 = false, ok = false;
PXOB *xarg2 = NULL, xp[2];
PCOL colp;
......@@ -1363,7 +1363,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
switch (arg[i]->GetType()) {
case TYPE_CONST:
type[i] = 1;
ctype = arg[i]->GetResultType();
// ctype = arg[i]->GetResultType();
break;
case TYPE_COLBLK:
conv = cnv[i];
......@@ -1388,7 +1388,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
// correlated subquery, it has a constant value during
// each execution of the subquery.
type[i] = 1;
ctype = arg[i]->GetResultType();
// ctype = arg[i]->GetResultType();
} // endif this
break;
......
......@@ -888,6 +888,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g)
} else if (Mode == MODE_INSERT) {
if (Srcdef) {
strcpy(g->Message, "No insert into anonym views");
Myc.Close();
return true;
} // endif Srcdef
......@@ -906,12 +907,12 @@ bool TDBMYSQL::OpenDB(PGLOBAL g)
} // endif MakeInsert
if (m_Rc != RC_FX) {
int rc;
char cmd[64];
int w;
sprintf(cmd, "ALTER TABLE `%s` DISABLE KEYS", Tabname);
rc = Myc.ExecSQL(g, cmd, &w); // may fail for some engines
m_Rc = Myc.ExecSQL(g, cmd, &w); // may fail for some engines
} // endif m_Rc
} else
......
......@@ -91,32 +91,6 @@ PSZ strlwr(PSZ s);
}
#endif // !WIN32
/***********************************************************************/
/* Returns the bitmap representing the conditions that must not be */
/* met when returning from TestValue for a given operator. */
/* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */
/***********************************************************************/
BYTE OpBmp(PGLOBAL g, OPVAL opc)
{
BYTE bt;
switch (opc) {
case OP_IN:
case OP_EQ: bt = 0x06; break;
case OP_NE: bt = 0x01; break;
case OP_GT: bt = 0x03; break;
case OP_GE: bt = 0x02; break;
case OP_LT: bt = 0x05; break;
case OP_LE: bt = 0x04; break;
case OP_EXIST: bt = 0x00; break;
default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
} // endswitch opc
return bt;
} // end of OpBmp
/***********************************************************************/
/* Get a long long number from its character representation. */
/* IN p: Pointer to the numeric string */
......
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