Skip to content
Permalink
Browse files
- Fix MDEV-18292: CONNECT Engine JDBC not able to issue
  simple UPDATE statement from trigger or stored procedure
  Was not fixed when the same table was called several times
  with different modes. Fixed by checking if a new statement
  is compatible in the start_stmt function. It nows do the
  same checks than external_lock.
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/ha_connect.h

- typo
  modified:   storage/connect/user_connect.cc
  • Loading branch information
Buggynours committed Mar 4, 2019
1 parent 990f8e8 commit 0a43be3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 43 deletions.
@@ -3663,7 +3663,7 @@ int ha_connect::update_row(const uchar *old_data, const uchar *new_data)

// Check values for possible change in indexed column
if ((rc= CheckRecord(g, old_data, new_data)))
DBUG_RETURN(rc);
DBUG_RETURN(rc);

if (CntUpdateRow(g, tdbp)) {
DBUG_PRINT("update_row", ("%s", g->Message));
@@ -4698,9 +4698,6 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
PGLOBAL g= GetPlug(thd, xp);
DBUG_ENTER("ha_connect::start_stmt");

if (table->triggers)
g->More = 1; // We don't know which columns are used by the trigger

if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);

@@ -4714,7 +4711,7 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
case TL_WRITE:
case TL_WRITE_ONLY:
newmode= MODE_WRITE;
break;
break;
case TL_READ:
case TL_READ_WITH_SHARED_LOCKS:
case TL_READ_HIGH_PRIORITY:
@@ -4728,8 +4725,24 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
break;
} // endswitch mode

xmod= CheckMode(g, thd, newmode, &chk, &cras);
DBUG_RETURN((xmod == MODE_ERROR) ? HA_ERR_INTERNAL_ERROR : 0);
if (newmode == MODE_ANY) {
if (CloseTable(g)) {
// Make error a warning to avoid crash
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc= 0;
} // endif Close

locked= 0;
xmod= MODE_ANY; // For info commands
DBUG_RETURN(rc);
} // endif MODE_ANY

newmode= CheckMode(g, thd, newmode, &chk, &cras);

if (newmode == MODE_ERROR)
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);

DBUG_RETURN(check_stmt(g, newmode, cras));
} // end of start_stmt

/**
@@ -4911,22 +4924,16 @@ int ha_connect::external_lock(THD *thd, int lock_type)
// Make it a warning to avoid crash
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc= 0;
//my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
//rc = HA_ERR_INTERNAL_ERROR;
} // endif Close

locked= 0;
// m_lock_type= lock_type;
xmod= MODE_ANY; // For info commands
DBUG_RETURN(rc);
} // endif MODE_ANY
else
if (check_privileges(thd, options, table->s->db.str)) {
} else if (check_privileges(thd, options, table->s->db.str)) {
strcpy(g->Message, "This operation requires the FILE privilege");
htrc("%s\n", g->Message);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif check_privileges

} // endif check_privileges

DBUG_ASSERT(table && table->s);

@@ -4936,42 +4943,30 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (newmode == MODE_ERROR)
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);

// If this is the start of a new query, cleanup the previous one
DBUG_RETURN(check_stmt(g, newmode, cras));
} // end of external_lock


int ha_connect::check_stmt(PGLOBAL g, MODE newmode, bool cras)
{
int rc= 0;
DBUG_ENTER("ha_connect::check_lock");

// If this is the start of a new query, cleanup the previous one
if (xp->CheckCleanup()) {
tdbp= NULL;
valid_info= false;
} // endif CheckCleanup

#if 0
if (xcheck) {
// This must occur after CheckCleanup
if (!g->Xchk) {
g->Xchk= new(g) XCHK;
((PCHK)g->Xchk)->oldsep= GetBooleanOption("Sepindex", false);
((PCHK)g->Xchk)->oldpix= GetIndexInfo();
} // endif Xchk

} else
g->Xchk= NULL;
#endif // 0
} // endif CheckCleanup

if (cras)
g->Createas= 1; // To tell external tables of a multi-table command

if (trace(1)) {
#if 0
htrc("xcheck=%d cras=%d\n", xcheck, cras);

if (xcheck)
htrc("oldsep=%d oldpix=%p\n",
((PCHK)g->Xchk)->oldsep, ((PCHK)g->Xchk)->oldpix);
#endif // 0
if (trace(1))
htrc("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
} // endif trace

// Set or reset the good database environment
if (CntCheckDB(g, this, GetDBName(NULL))) {
htrc("%p external_lock: %s\n", this, g->Message);
htrc("%p check_lock: %s\n", this, g->Message);
rc= HA_ERR_INTERNAL_ERROR;
// This can NOT be called without open called first, but
// the table can have been closed since then
@@ -4984,18 +4979,18 @@ int ha_connect::external_lock(THD *thd, int lock_type)
else
tdbp= NULL;

} // endif tdbp
} // endif tdbp

xmod= newmode;

// Delay open until used fields are known
} // endif tdbp

if (trace(1))
htrc("external_lock: rc=%d\n", rc);
htrc("check_lock: rc=%d\n", rc);

DBUG_RETURN(rc);
} // end of external_lock
} // end of check_stmt


/**
@@ -507,6 +507,7 @@ int index_prev(uchar *buf);
protected:
bool check_privileges(THD *thd, PTOS options, const char *dbn, bool quick=false);
MODE CheckMode(PGLOBAL g, THD *thd, MODE newmode, bool *chk, bool *cras);
int check_stmt(PGLOBAL g, MODE newmode, bool cras);
char *GetDBfromName(const char *name);

// Members
@@ -177,6 +177,7 @@ bool user_connect::CheckCleanup(bool force)
g->Createas = 0;
g->Alchecked = 0;
g->Mrr = 0;
g->More = 0;
last_query_id= thdp->query_id;

if (trace(65) && !force)

0 comments on commit 0a43be3

Please sign in to comment.