Commit 5884aa15 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-11234. Escape quoting character. Should be doubled.

  Now it is also possible to escape it by a backslash.
  modified:   storage/connect/tabfmt.cpp

- Prepare making VEC table type support conditional.
  VEC tables might be unsupported in future versions
  modified:   storage/connect/CMakeLists.txt
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/xindex.cpp

- MDEV-11067 suggested to add configuration support to the Apache wrapper.
  Was added but commented out until prooved it is really useful.
  modified:   storage/connect/ApacheInterface.java
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jdbccat.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h
  modified:   storage/connect/tabjdbc.cpp
  modified:   storage/connect/tabjdbc.h

- Remove useless members.
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h

- New UDF countin.
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h
parent b7aee7db
......@@ -35,7 +35,10 @@ public class ApacheInterface extends JdbcInterface {
ds.setPassword(parms[3]);
pool.put(url, ds);
} // endif ds
// if (parms.length > 4 && parms[4] != null)
// ds.setConnectionProperties(parms[4]);
// Get a connection from the data source
conn = ds.getConnection();
......
......@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
# Definitions that are shared for all OSes
#
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT )
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT -DVCT_SUPPORT )
#
......
......@@ -171,7 +171,7 @@
#define JSONMAX 10 // JSON Default max grp size
extern "C" {
char version[]= "Version 1.04.0008 August 10, 2016";
char version[]= "Version 1.04.0008 October 20, 2016";
#if defined(__WIN__)
char compver[]= "Version 1.04.0008 " __DATE__ " " __TIME__;
char slash= '\\';
......@@ -5190,7 +5190,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
PJPARM sjp= NULL;
char *driver= NULL;
char *url= NULL;
char *tabtyp = NULL;
//char *prop= NULL;
char *tabtyp= NULL;
#endif // JDBC_SUPPORT
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
bool bif, ok= false, dbf= false;
......@@ -5256,6 +5257,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#if defined(JDBC_SUPPORT)
driver= GetListOption(g, "Driver", topt->oplist, NULL);
// url= GetListOption(g, "URL", topt->oplist, NULL);
// prop = GetListOption(g, "Properties", topt->oplist, NULL);
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
#endif // JDBC_SUPPORT
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
......@@ -5366,6 +5368,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
jdef->SetName(create_info->alias);
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
sjp->Driver= driver;
// sjp->Properties = prop;
sjp->Fsize= 0;
sjp->Scrollable= false;
......
......@@ -8,6 +8,7 @@ typedef struct jdbc_parms {
char *Url; // Driver URL
char *User; // User connect info
char *Pwd; // Password connect info
//char *Properties; // Connection property list
//int Cto; // Connect timeout
//int Qto; // Query timeout
int Fsize; // Fetch size
......
......@@ -525,10 +525,10 @@ JDBConn::JDBConn(PGLOBAL g, TDBJDBC *tdbp)
m_Wrap = strcat(strcpy(wn, "wrappers/"), m_Wrap);
} // endif m_Wrap
m_Driver = NULL;
m_Url = NULL;
m_User = NULL;
m_Pwd = NULL;
//m_Driver = NULL;
//m_Url = NULL;
//m_User = NULL;
//m_Pwd = NULL;
m_Ncol = 0;
m_Aff = 0;
m_Rows = 0;
......@@ -772,7 +772,7 @@ bool JDBConn::GetJVM(PGLOBAL g)
/***********************************************************************/
int JDBConn::Open(PJPARM sop)
{
int irc = RC_FX;
bool err = false;
jboolean jt = (trace > 0);
PGLOBAL& g = m_G;
......@@ -865,30 +865,37 @@ int JDBConn::Open(PJPARM sop)
switch (rc) {
case JNI_OK:
strcpy(g->Message, "VM successfully created");
irc = RC_OK;
break;
case JNI_ERR:
strcpy(g->Message, "Initialising JVM failed: unknown error");
return RC_FX;
break;
case JNI_EDETACHED:
strcpy(g->Message, "Thread detached from the VM");
return RC_FX;
break;
case JNI_EVERSION:
strcpy(g->Message, "JNI version error");
return RC_FX;
break;
case JNI_ENOMEM:
strcpy(g->Message, "Not enough memory");
return RC_FX;
break;
case JNI_EEXIST:
strcpy(g->Message, "VM already created");
return RC_FX;
break;
case JNI_EINVAL:
strcpy(g->Message, "Invalid arguments");
return RC_FX;
break;
default:
sprintf(g->Message, "Unknown return code %d", rc);
return RC_FX;
sprintf(g->Message, "Unknown return code %d", (int)rc);
break;
} // endswitch rc
if (trace)
htrc("%s\n", g->Message);
if (irc != RC_OK)
return irc;
//=============== Display JVM version ===============
jint ver = env->GetVersion();
printf("JVM Version %d.%d\n", ((ver>>16)&0x0f), (ver&0x0f));
......@@ -978,10 +985,10 @@ int JDBConn::Open(PJPARM sop)
jobjectArray parms = env->NewObjectArray(4, // constructs java array of 4
env->FindClass("java/lang/String"), NULL); // Strings
m_Driver = sop->Driver;
m_Url = sop->Url;
m_User = sop->User;
m_Pwd = sop->Pwd;
//m_Driver = sop->Driver;
//m_Url = sop->Url;
//m_User = sop->User;
//m_Pwd = sop->Pwd;
m_Scrollable = sop->Scrollable;
m_RowsetSize = sop->Fsize;
//m_LoginTimeout = sop->Cto;
......@@ -989,17 +996,20 @@ int JDBConn::Open(PJPARM sop)
//m_UseCnc = sop->UseCnc;
// change some elements
if (m_Driver)
env->SetObjectArrayElement(parms, 0, env->NewStringUTF(m_Driver));
if (sop->Driver)
env->SetObjectArrayElement(parms, 0, env->NewStringUTF(sop->Driver));
if (sop->Url)
env->SetObjectArrayElement(parms, 1, env->NewStringUTF(sop->Url));
if (m_Url)
env->SetObjectArrayElement(parms, 1, env->NewStringUTF(m_Url));
if (sop->User)
env->SetObjectArrayElement(parms, 2, env->NewStringUTF(sop->User));
if (m_User)
env->SetObjectArrayElement(parms, 2, env->NewStringUTF(m_User));
if (sop->Pwd)
env->SetObjectArrayElement(parms, 3, env->NewStringUTF(sop->Pwd));
if (m_Pwd)
env->SetObjectArrayElement(parms, 3, env->NewStringUTF(m_Pwd));
//if (sop->Properties)
// env->SetObjectArrayElement(parms, 4, env->NewStringUTF(sop->Properties));
// call method
rc = env->CallIntMethod(job, cid, parms, m_RowsetSize, m_Scrollable);
......
......@@ -180,9 +180,9 @@ class JDBConn : public BLOCK {
char *Msg;
char *m_Wrap;
char m_IDQuoteChar[2];
PSZ m_Driver;
PSZ m_Url;
PSZ m_User;
//PSZ m_Driver;
//PSZ m_Url;
//PSZ m_User;
PSZ m_Pwd;
int m_Ncol;
int m_Aff;
......
......@@ -5264,3 +5264,50 @@ char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result,
return str;
} // end of envar
/*********************************************************************************/
/* Returns the distinct number of B occurences in A. */
/*********************************************************************************/
my_bool countin_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count != 2) {
strcpy(message, "This function must have 2 arguments");
return true;
} else if (args->arg_type[0] != STRING_RESULT) {
strcpy(message, "First argument must be string");
return true;
} else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument is not a string");
return true;
} // endif args
return false;
} // end of countin_init
long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *)
{
PSZ str1, str2;
char *s;
long long n = 0;
size_t lg;
lg = (size_t)args->lengths[0];
s = str1 = (PSZ)malloc(lg + 1);
memcpy(str1, args->args[0], lg);
str1[lg] = 0;
lg = (size_t)args->lengths[1];
str2 = (PSZ)malloc(lg + 1);
memcpy(str2, args->args[1], lg);
str2[lg] = 0;
while (s = strstr(s, str2)) {
n++;
s += lg;
} // endwhile
free(str1);
free(str2);
return n;
} // end of countin
......@@ -221,6 +221,9 @@ extern "C" {
DllExport my_bool envar_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *envar(UDF_EXEC_ARGS);
DllExport my_bool countin_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long countin(UDF_EXEC_ARGS);
} // extern "C"
......
......@@ -64,7 +64,9 @@
#include "filamtxt.h"
#include "tabdos.h"
#include "tabfmt.h"
#if defined(VCT_SUPPORT)
#include "tabvct.h"
#endif // VCT_SUPPORT
#include "tabsys.h"
#if defined(__WIN__)
#include "tabmac.h"
......@@ -549,7 +551,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
#if defined(XML_SUPPORT)
case TAB_XML: tdp= new(g) XMLDEF; break;
#endif // XML_SUPPORT
case TAB_VEC: tdp= new(g) VCTDEF; break;
#if defined(VCT_SUPPORT)
case TAB_VEC: tdp = new(g)VCTDEF; break;
#endif // VCT_SUPPORT
#if defined(ODBC_SUPPORT)
case TAB_ODBC: tdp= new(g) ODBCDEF; break;
#endif // ODBC_SUPPORT
......
......@@ -40,7 +40,9 @@
#include "tabcol.h"
#include "filamap.h"
#include "filamfix.h"
#if defined(VCT_SUPPORT)
#include "filamvct.h"
#endif // VCT_SUPPORT
#if defined(ZIP_SUPPORT)
#include "filamzip.h"
#endif // ZIP_SUPPORT
......@@ -683,16 +685,19 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) MPXFAM(defp);
else
txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_VCT) {
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
#if defined(VCT_SUPPORT)
assert(Pxdef->GetDefType() == TYPE_AM_VCT);
if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp);
else
txfp = new(g) VCTFAM((PVCTDEF)defp);
} // endif's
#else // !VCT_SUPPORT
strcpy(g->Message, "VCT no more supported");
return NULL;
#endif // !VCT_SUPPORT
} // endif's
((PTDBDOS)tdbp)->SetTxfp(txfp);
} // endif Txfp
......
......@@ -830,8 +830,9 @@ bool TDBCSV::SkipHeader(PGLOBAL g)
/***********************************************************************/
int TDBCSV::ReadBuffer(PGLOBAL g)
{
char *p1, *p2, *p = NULL;
int i, n, len, rc = Txfp->ReadBuffer(g);
//char *p1, *p2, *p = NULL;
char *p2, *p = NULL;
int i, n, len, rc = Txfp->ReadBuffer(g);
bool bad = false;
if (trace > 1)
......@@ -846,14 +847,23 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
for (i = 0; i < Fields; i++) {
if (!bad) {
if (Qot && *p2 == Qot) { // Quoted field
for (n = 0, p1 = ++p2; (p = strchr(p1, Qot)); p1 = p + 2)
if (*(p + 1) == Qot)
n++; // Doubled internal quotes
else
break; // Final quote
//for (n = 0, p1 = ++p2; (p = strchr(p1, Qot)); p1 = p + 2)
// if (*(p + 1) == Qot)
// n++; // Doubled internal quotes
// else
// break; // Final quote
for (n = 0, p = ++p2; p; p++)
if (*p == Qot || *p == '\\') {
if (*(++p) == Qot)
n++; // Escaped internal quotes
else if (*(p - 1) == Qot)
break; // Final quote
} // endif *p
if (p) {
len = p++ - p2;
//len = p++ - p2;
len = p - p2 - 1;;
// if (Sep != ' ')
// for (; *p == ' '; p++) ; // Skip blanks
......@@ -873,10 +883,12 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
if (n) {
int j, k;
// Suppress the double of internal quotes
// Suppress the escape of internal quotes
for (j = k = 0; j < len; j++, k++) {
if (p2[j] == Qot)
j++; // skip first one
if (p2[j] == Qot || (p2[j] == '\\' && p2[j + 1] == Qot))
j++; // skip escape char
else if (p2[j] == '\\')
p2[k++] = p2[j++]; // avoid \\Qot
p2[k] = p2[j];
} // endfor i, j
......
......@@ -110,6 +110,7 @@ bool JDBCDEF::SetParms(PJPARM sjp)
sjp->Url= Url;
sjp->User= Username;
sjp->Pwd= Password;
//sjp->Properties = Prop;
return true;
} // end of SetParms
......@@ -234,6 +235,7 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Read_Only = true;
Wrapname = GetStringCatInfo(g, "Wrapper", NULL);
//Prop = GetStringCatInfo(g, "Properties", NULL);
Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
Tabschema = GetStringCatInfo(g, "Dbname", NULL);
......@@ -337,6 +339,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
Schema = tdp->Tabschema;
Ops.User = tdp->Username;
Ops.Pwd = tdp->Password;
// Ops.Properties = tdp->Prop;
Catalog = tdp->Tabcat;
Srcdef = tdp->Srcdef;
Qrystr = tdp->Qrystr;
......@@ -356,6 +359,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
Ops.Url = NULL;
Ops.User = NULL;
Ops.Pwd = NULL;
// Ops.Properties = NULL;
Catalog = NULL;
Srcdef = NULL;
Qrystr = NULL;
......
......@@ -58,6 +58,7 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */
PSZ Tabschema; /* External table schema */
PSZ Username; /* User connect name */
PSZ Password; /* Password connect info */
//PSZ Prop; /* Connection Properties */
PSZ Tabcat; /* External table catalog */
PSZ Tabtype; /* External table type */
PSZ Colpat; /* Catalog column pattern */
......
......@@ -45,7 +45,9 @@
//nclude "array.h"
#include "filamtxt.h"
#include "tabdos.h"
#if defined(VCT_SUPPORT)
#include "tabvct.h"
#endif // VCT_SUPPORT
/***********************************************************************/
/* Macro or external routine definition */
......@@ -293,9 +295,11 @@ bool XINDEX::AddColumns(void)
return false; // Not applying to static index
else if (IsMul())
return false; // Not done yet for multiple index
else if (Tbxp->GetAmType() == TYPE_AM_VCT && ((PTDBVCT)Tbxp)->IsSplit())
#if defined(VCT_SUPPORT)
else if (Tbxp->GetAmType() == TYPE_AM_VCT && ((PTDBVCT)Tbxp)->IsSplit())
return false; // This would require to read additional files
else
#endif // VCT_SUPPORT
else
return true;
} // end of AddColumns
......
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