Commit e2567fb6 authored by Alexander Barkov's avatar Alexander Barkov

Tests connect.odbc_postgresql and connect.odbc_oracle failed

after revision 4363 (fixes for MDEV-6661 and MDEV-6666).

Fixing a wrong assumption in ha_connect.cc that strings
returned from val_str() are always 0-terminated.
parent 213a4a93
...@@ -2188,8 +2188,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond) ...@@ -2188,8 +2188,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
switch (args[i]->real_type()) { switch (args[i]->real_type()) {
case COND::STRING_ITEM: case COND::STRING_ITEM:
pp->Type= TYPE_STRING; pp->Type= TYPE_STRING;
pp->Value= PlugSubAlloc(g, NULL, res->length() + 1); pp->Value= PlugSubAllocStr(g, NULL, res->ptr(), res->length());
strncpy((char*)pp->Value, res->ptr(), res->length() + 1);
break; break;
case COND::INT_ITEM: case COND::INT_ITEM:
pp->Type= TYPE_INT; pp->Type= TYPE_INT;
...@@ -2437,7 +2436,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond) ...@@ -2437,7 +2436,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
} else { } else {
if (args[i]->field_type() == MYSQL_TYPE_VARCHAR) { if (args[i]->field_type() == MYSQL_TYPE_VARCHAR) {
// Add the command to the list // Add the command to the list
PCMD *ncp, cmdp= new(g) CMD(g, (char*)res->ptr()); PCMD *ncp, cmdp= new(g) CMD(g, (char*)res->c_ptr());
for (ncp= &filp->Cmds; *ncp; ncp= &(*ncp)->Next) ; for (ncp= &filp->Cmds; *ncp; ncp= &(*ncp)->Next) ;
......
...@@ -174,6 +174,16 @@ class ha_connect: public handler ...@@ -174,6 +174,16 @@ class ha_connect: public handler
CONNECT_SHARE *share; ///< Shared lock info CONNECT_SHARE *share; ///< Shared lock info
CONNECT_SHARE *get_share(); CONNECT_SHARE *get_share();
protected:
char *PlugSubAllocStr(PGLOBAL g, void *memp, const char *str, size_t length)
{
char *ptr;
if (!(ptr= (char*) PlugSubAlloc(g, memp, length + 1)))
return NULL;
memcpy(ptr, str, length);
ptr[length]= '\0';
return ptr;
}
public: public:
ha_connect(handlerton *hton, TABLE_SHARE *table_arg); ha_connect(handlerton *hton, TABLE_SHARE *table_arg);
~ha_connect(); ~ha_connect();
......
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