Commit e0c147c2 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-18192: CONNECT Engine JDBC not able to issue

  simple UPDATE statement from trigger or stored procedure
  modified:   storage/connect/tabext.cpp
  modified:   storage/connect/tabext.h
  modified:   storage/connect/tabjdbc.cpp

- Enable CONNECT tables to have triggers
  Update version number
  modified:   storage/connect/ha_connect.cc

- Make user and password defined in CREATE TABLE have precedence on
  the ones specified in a Federated Server.
  modified:   storage/connect/tabjdbc.cpp

- JSONColumns: Copy locally constant strings to fix error in OEM modules
  modified:   storage/connect/tabjson.cpp
parent 261e9a8a
...@@ -170,9 +170,9 @@ ...@@ -170,9 +170,9 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.06.0008 October 06, 2018"; char version[]= "Version 1.06.0009 January 27, 2019";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.06.0008 " __DATE__ " " __TIME__; char compver[]= "Version 1.06.0009 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
...@@ -1914,9 +1914,11 @@ int ha_connect::OpenTable(PGLOBAL g, bool del) ...@@ -1914,9 +1914,11 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
break; break;
} // endswitch xmode } // endswitch xmode
if (xmod != MODE_INSERT || tdbp->GetAmType() == TYPE_AM_MYSQL // g->More is 1 when executing commands from triggers
if (!g->More && (xmod != MODE_INSERT
|| tdbp->GetAmType() == TYPE_AM_MYSQL
|| tdbp->GetAmType() == TYPE_AM_ODBC || tdbp->GetAmType() == TYPE_AM_ODBC
|| tdbp->GetAmType() == TYPE_AM_JDBC) { || tdbp->GetAmType() == TYPE_AM_JDBC)) {
// Get the list of used fields (columns) // Get the list of used fields (columns)
char *p; char *p;
unsigned int k1, k2, n1, n2; unsigned int k1, k2, n1, n2;
...@@ -4631,6 +4633,8 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, ...@@ -4631,6 +4633,8 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
break; break;
case SQLCOM_CREATE_VIEW: case SQLCOM_CREATE_VIEW:
case SQLCOM_DROP_VIEW: case SQLCOM_DROP_VIEW:
case SQLCOM_CREATE_TRIGGER:
case SQLCOM_DROP_TRIGGER:
newmode= MODE_ANY; newmode= MODE_ANY;
break; break;
case SQLCOM_ALTER_TABLE: case SQLCOM_ALTER_TABLE:
...@@ -4674,6 +4678,9 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type) ...@@ -4674,6 +4678,9 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
PGLOBAL g= GetPlug(thd, xp); PGLOBAL g= GetPlug(thd, xp);
DBUG_ENTER("ha_connect::start_stmt"); 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)) if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
...@@ -7310,7 +7317,7 @@ maria_declare_plugin(connect) ...@@ -7310,7 +7317,7 @@ maria_declare_plugin(connect)
0x0106, /* version number (1.06) */ 0x0106, /* version number (1.06) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.06.0008", /* string version */ "1.06.0009", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
/************* Tabext C++ Functions Source Code File (.CPP) ************/ /************* Tabext C++ Functions Source Code File (.CPP) ************/
/* Name: TABEXT.CPP Version 1.0 */ /* Name: TABEXT.CPP Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2017 */ /* (C) Copyright to the author Olivier BERTRAND 2017 - 2019 */
/* */ /* */
/* This file contains the TBX, TDB and OPJOIN classes functions. */ /* This file contains the TBX, TDB and OPJOIN classes functions. */
/***********************************************************************/ /***********************************************************************/
...@@ -445,6 +445,43 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt) ...@@ -445,6 +445,43 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
return false; return false;
} // end of MakeSQL } // end of MakeSQL
/***********************************************************************/
/* Remove the NAME_CONST functions that are added by procedures. */
/***********************************************************************/
void TDBEXT::RemoveConst(PGLOBAL g, char *stmt)
{
char *p, *p2;
char val[1025], nval[1025];
int n, nc;
while ((p = strstr(stmt, "NAME_CONST")))
if ((n = sscanf(p, "%*[^,],%1024[^)])%n", val, &nc))) {
if (trace(33))
htrc("p=%s\nn=%d val=%s nc=%d\n", p, n, val, nc);
*p = 0;
if ((p2 = strstr(val, "'"))) {
if ((n = sscanf(p2, "%*['\\]%1024[^'\\]", nval))) {
if (trace(33))
htrc("p2=%s\nn=%d nval=%s\n", p2, n, nval);
strcat(strcat(strcat(strcat(stmt, "'"), nval), "'"), p + nc);
} else
break;
} else
strcat(strcat(strcat(strcat(stmt, "("), val), ")"), p + nc);
if (trace(33))
htrc("stmt=%s\n", stmt);
} else
break;
return;
} // end of RemoveConst
/***********************************************************************/ /***********************************************************************/
/* MakeCommand: make the Update or Delete statement to send to the */ /* MakeCommand: make the Update or Delete statement to send to the */
/* MySQL server. Limited to remote values and filtering. */ /* MySQL server. Limited to remote values and filtering. */
...@@ -524,6 +561,8 @@ bool TDBEXT::MakeCommand(PGLOBAL g) ...@@ -524,6 +561,8 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
stmt[i++] = (Qrystr[k] == '`') ? q : Qrystr[k]; stmt[i++] = (Qrystr[k] == '`') ? q : Qrystr[k];
} while (Qrystr[k++]); } while (Qrystr[k++]);
RemoveConst(g, stmt);
if (body) if (body)
strcat(stmt, body); strcat(stmt, body);
......
/*************** Tabext H Declares Source Code File (.H) ***************/ /*************** Tabext H Declares Source Code File (.H) ***************/
/* Name: TABEXT.H Version 1.0 */ /* Name: TABEXT.H Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2017 */ /* (C) Copyright to the author Olivier BERTRAND 2017 - 2019 */
/* */ /* */
/* This is the EXTDEF, TABEXT and EXTCOL classes definitions. */ /* This is the EXTDEF, TABEXT and EXTCOL classes definitions. */
/***********************************************************************/ /***********************************************************************/
...@@ -130,6 +130,7 @@ class DllExport TDBEXT : public TDB { ...@@ -130,6 +130,7 @@ class DllExport TDBEXT : public TDB {
virtual bool MakeSQL(PGLOBAL g, bool cnt); virtual bool MakeSQL(PGLOBAL g, bool cnt);
//virtual bool MakeInsert(PGLOBAL g); //virtual bool MakeInsert(PGLOBAL g);
virtual bool MakeCommand(PGLOBAL g); virtual bool MakeCommand(PGLOBAL g);
void RemoveConst(PGLOBAL g, char *stmt);
int Decode(PCSZ utf, char *buf, size_t n); int Decode(PCSZ utf, char *buf, size_t n);
// Members // Members
......
/************* TabJDBC C++ Program Source Code File (.CPP) *************/ /************* TabJDBC C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: TABJDBC */ /* PROGRAM NAME: TABJDBC */
/* ------------- */ /* ------------- */
/* Version 1.2 */ /* Version 1.3 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2016-2019 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -185,10 +185,10 @@ int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b) ...@@ -185,10 +185,10 @@ int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b)
} else // host is a URL } else // host is a URL
Url = PlugDup(g, server->host); Url = PlugDup(g, server->host);
if (server->username) if (!Username && server->username)
Username = PlugDup(g, server->username); Username = PlugDup(g, server->username);
if (server->password) if (!Password && server->password)
Password = PlugDup(g, server->password); Password = PlugDup(g, server->password);
return RC_NF; return RC_NF;
...@@ -558,9 +558,10 @@ bool TDBJDBC::OpenDB(PGLOBAL g) ...@@ -558,9 +558,10 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
this, Tdb_No, Use, Mode); this, Tdb_No, Use, Mode);
if (Use == USE_OPEN) { if (Use == USE_OPEN) {
/*******************************************************************/ if (Mode == MODE_READ || Mode == MODE_READX) {
/*****************************************************************/
/* Table already open, just replace it at its beginning. */ /* Table already open, just replace it at its beginning. */
/*******************************************************************/ /*****************************************************************/
if (Memory == 1) { if (Memory == 1) {
if ((Qrp = Jcp->AllocateResult(g, this))) if ((Qrp = Jcp->AllocateResult(g, this)))
Memory = 2; // Must be filled Memory = 2; // Must be filled
...@@ -585,6 +586,14 @@ bool TDBJDBC::OpenDB(PGLOBAL g) ...@@ -585,6 +586,14 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
CurNum = 0; CurNum = 0;
Fpos = 0; Fpos = 0;
Curpos = 1; Curpos = 1;
} else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) {
// new update coming from a trigger or procedure
Query = NULL;
SetCondFil(NULL);
Qrystr = To_Def->GetStringCatInfo(g, "Query_String", "?");
} else { //if (Mode == MODE_INSERT)
} // endif Mode
return false; return false;
} // endif use } // endif use
......
/************* tabjson C++ Program Source Code File (.CPP) *************/ /************* tabjson C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: tabjson Version 1.6 */ /* PROGRAM NAME: tabjson Version 1.7 */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2018 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2019 */
/* This program are the JSON class DB execution routines. */ /* This program are the JSON class DB execution routines. */
/***********************************************************************/ /***********************************************************************/
...@@ -110,8 +110,8 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) ...@@ -110,8 +110,8 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
buftyp, fldtyp, length, false, false); buftyp, fldtyp, length, false, false);
crp = qrp->Colresp->Next->Next->Next->Next->Next->Next; crp = qrp->Colresp->Next->Next->Next->Next->Next->Next;
crp->Name = "Nullable"; crp->Name = PlugDup(g, "Nullable");
crp->Next->Name = "Jpath"; crp->Next->Name = PlugDup(g, "Jpath");
if (info || !qrp) if (info || !qrp)
return qrp; return qrp;
......
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