mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix MDEV-7890
This commit is contained in:
@@ -2173,12 +2173,12 @@ int ha_connect::CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Return the where clause for remote indexed read. */
|
/* Return the where clause for remote indexed read. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
|
bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL op, char q,
|
||||||
const void *key, int klen)
|
const void *key, int klen)
|
||||||
{
|
{
|
||||||
const uchar *ptr;
|
const uchar *ptr;
|
||||||
uint rem, len, stlen; //, prtlen;
|
uint rem, len, stlen; //, prtlen;
|
||||||
bool nq, b= false;
|
bool nq, oom, b= false;
|
||||||
Field *fp;
|
Field *fp;
|
||||||
KEY *kfp;
|
KEY *kfp;
|
||||||
KEY_PART_INFO *kpart;
|
KEY_PART_INFO *kpart;
|
||||||
@@ -2190,7 +2190,7 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
|
|||||||
return true;
|
return true;
|
||||||
} // endif key
|
} // endif key
|
||||||
|
|
||||||
strcat(qry, " WHERE (");
|
oom= qry->Append(" WHERE (");
|
||||||
kfp= &table->key_info[active_index];
|
kfp= &table->key_info[active_index];
|
||||||
rem= kfp->user_defined_key_parts,
|
rem= kfp->user_defined_key_parts,
|
||||||
len= klen,
|
len= klen,
|
||||||
@@ -2203,24 +2203,26 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
|
|||||||
nq= fp->str_needs_quotes();
|
nq= fp->str_needs_quotes();
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
strcat(qry, " AND ");
|
oom|= qry->Append(" AND ");
|
||||||
else
|
else
|
||||||
b= true;
|
b= true;
|
||||||
|
|
||||||
strcat(strncat(strcat(qry, q), fp->field_name, strlen(fp->field_name)), q);
|
oom|= qry->Append(q);
|
||||||
|
oom|= qry->Append((PSZ)fp->field_name);
|
||||||
|
oom|= qry->Append(q);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OP_EQ:
|
case OP_EQ:
|
||||||
case OP_GT:
|
case OP_GT:
|
||||||
case OP_GE:
|
case OP_GE:
|
||||||
strcat(qry, GetValStr(op, false));
|
oom|= qry->Append((PSZ)GetValStr(op, false));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcat(qry, " ??? ");
|
oom|= qry->Append(" ??? ");
|
||||||
} // endwitch op
|
} // endwitch op
|
||||||
|
|
||||||
if (nq)
|
if (nq)
|
||||||
strcat(qry, "'");
|
oom|= qry->Append('\'');
|
||||||
|
|
||||||
if (kpart->key_part_flag & HA_VAR_LENGTH_PART) {
|
if (kpart->key_part_flag & HA_VAR_LENGTH_PART) {
|
||||||
String varchar;
|
String varchar;
|
||||||
@@ -2228,17 +2230,17 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
|
|||||||
|
|
||||||
varchar.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
|
varchar.set_quick((char*) ptr+HA_KEY_BLOB_LENGTH,
|
||||||
var_length, &my_charset_bin);
|
var_length, &my_charset_bin);
|
||||||
strncat(qry, varchar.ptr(), varchar.length());
|
oom|= qry->Append(varchar.ptr(), varchar.length());
|
||||||
} else {
|
} else {
|
||||||
char strbuff[MAX_FIELD_WIDTH];
|
char strbuff[MAX_FIELD_WIDTH];
|
||||||
String str(strbuff, sizeof(strbuff), kpart->field->charset()), *res;
|
String str(strbuff, sizeof(strbuff), kpart->field->charset()), *res;
|
||||||
|
|
||||||
res= fp->val_str(&str, ptr);
|
res= fp->val_str(&str, ptr);
|
||||||
strncat(qry, res->ptr(), res->length());
|
oom|= qry->Append(res->ptr(), res->length());
|
||||||
} // endif flag
|
} // endif flag
|
||||||
|
|
||||||
if (nq)
|
if (nq)
|
||||||
strcat(qry, "'");
|
oom|= qry->Append('\'');
|
||||||
|
|
||||||
if (stlen >= len)
|
if (stlen >= len)
|
||||||
break;
|
break;
|
||||||
@@ -2251,8 +2253,10 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
|
|||||||
ptr+= stlen - MY_TEST(kpart->null_bit);
|
ptr+= stlen - MY_TEST(kpart->null_bit);
|
||||||
} // endfor kpart
|
} // endfor kpart
|
||||||
|
|
||||||
strcat(qry, ")");
|
if ((oom|= qry->Append(")")))
|
||||||
return false;
|
strcpy(g->Message, "Out of memory");
|
||||||
|
|
||||||
|
return oom;
|
||||||
} // end of MakeKeyWhere
|
} // end of MakeKeyWhere
|
||||||
|
|
||||||
|
|
||||||
|
@@ -235,7 +235,7 @@ public:
|
|||||||
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
|
int CheckRecord(PGLOBAL g, const uchar *oldbuf, uchar *newbuf);
|
||||||
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
|
int ReadIndexed(uchar *buf, OPVAL op, const uchar* key= NULL,
|
||||||
uint key_len= 0);
|
uint key_len= 0);
|
||||||
bool MakeKeyWhere(PGLOBAL g, char *qry, OPVAL op, char *q,
|
bool MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL op, char q,
|
||||||
const void *key, int klen);
|
const void *key, int klen);
|
||||||
inline char *Strz(LEX_STRING &ls);
|
inline char *Strz(LEX_STRING &ls);
|
||||||
|
|
||||||
|
@@ -1078,8 +1078,7 @@ bool TDBMYSQL::ReadKey(PGLOBAL g, OPVAL op, const void *key, int len)
|
|||||||
if (Myc.m_Res)
|
if (Myc.m_Res)
|
||||||
Myc.FreeResult();
|
Myc.FreeResult();
|
||||||
|
|
||||||
To_Def->GetHandler()->MakeKeyWhere(g, Query->GetStr(),
|
To_Def->GetHandler()->MakeKeyWhere(g, Query, op, '`', key, len);
|
||||||
op, "`", key, len);
|
|
||||||
|
|
||||||
if (To_CondFil) {
|
if (To_CondFil) {
|
||||||
oom = Query->Append(" AND (");
|
oom = Query->Append(" AND (");
|
||||||
|
@@ -289,6 +289,34 @@ bool STRING::Set(char *s, uint n)
|
|||||||
return false;
|
return false;
|
||||||
} // end of Set
|
} // end of Set
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Append a char* to a STRING. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool STRING::Append(const char *s, uint ln)
|
||||||
|
{
|
||||||
|
if (!s)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint len = Length + ln + 1;
|
||||||
|
|
||||||
|
if (len > Size) {
|
||||||
|
char *p = Realloc(len);
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
return true;
|
||||||
|
else if (p != Strp) {
|
||||||
|
strcpy(p, Strp);
|
||||||
|
Strp = p;
|
||||||
|
} // endif p
|
||||||
|
|
||||||
|
} // endif n
|
||||||
|
|
||||||
|
strncpy(Strp + Length, s, ln);
|
||||||
|
Length = len - 1;
|
||||||
|
Strp[Length] = 0;
|
||||||
|
return false;
|
||||||
|
} // end of Append
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Append a PSZ to a STRING. */
|
/* Append a PSZ to a STRING. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@@ -134,6 +134,7 @@ class DllExport STRING : public BLOCK {
|
|||||||
inline void Reset(void) {*Strp = 0;}
|
inline void Reset(void) {*Strp = 0;}
|
||||||
bool Set(PSZ s);
|
bool Set(PSZ s);
|
||||||
bool Set(char *s, uint n);
|
bool Set(char *s, uint n);
|
||||||
|
bool Append(const char *s, uint ln);
|
||||||
bool Append(PSZ s);
|
bool Append(PSZ s);
|
||||||
bool Append(STRING &str);
|
bool Append(STRING &str);
|
||||||
bool Append(char c);
|
bool Append(char c);
|
||||||
|
Reference in New Issue
Block a user