Skip to content

Commit fe71854

Browse files
committed
Merge branch 'ob-10.1' into 10.1
2 parents 6b0fc1e + 6b1e133 commit fe71854

15 files changed

+212
-165
lines changed

storage/connect/CMakeLists.txt

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ IF(CONNECT_WITH_LIBXML2)
109109
FIND_PACKAGE(LibXml2)
110110
IF (LIBXML2_FOUND)
111111
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
112+
SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below
112113
SET(XML_LIBRARY ${LIBXML2_LIBRARIES})
113114
SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h)
114115
add_definitions(-DLIBXML2_SUPPORT)
@@ -124,7 +125,6 @@ IF(WIN32)
124125
OPTION(CONNECT_WITH_MSXML "Compile CONNECT storage engine with MSXML support" ON)
125126
IF(CONNECT_WITH_MSXML)
126127
add_definitions(-DMSX6 -DDOMDOC_SUPPORT)
127-
message(STATUS "MSXML library version: msxml6")
128128
SET(MSXML_FOUND 1)
129129
SET(CONNECT_SOURCES ${CONNECT_SOURCES} domdoc.cpp domdoc.h)
130130
ENDIF(CONNECT_WITH_MSXML)
@@ -326,6 +326,14 @@ IF(NOT TARGET connect)
326326
RETURN()
327327
ENDIF()
328328

329+
# Don't link with bundled zlib and systel libxml2 at the same time.
330+
# System libxml2 uses system zlib, might conflict with the bundled one.
331+
IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB)
332+
GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES)
333+
LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR})
334+
SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS})
335+
ENDIF()
336+
329337
IF(WIN32)
330338
IF (libmongoc-1.0_FOUND)
331339
SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS
@@ -346,23 +354,6 @@ IF(WIN32)
346354
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
347355
ENDIF(WIN32)
348356

349-
IF(NOT TARGET connect)
350-
RETURN()
351-
ENDIF()
352-
353-
# Install some extra files that belong to connect engine
354-
IF(WIN32)
355-
# install ha_connect.lib
356-
GET_TARGET_PROPERTY(CONNECT_LOCATION connect LOCATION)
357-
STRING(REPLACE "dll" "lib" CONNECT_LIB ${CONNECT_LOCATION})
358-
IF(CMAKE_CONFIGURATION_TYPES)
359-
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}"
360-
CONNECT_LIB ${CONNECT_LIB})
361-
ENDIF()
362-
INSTALL(FILES ${CONNECT_LIB}
363-
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
364-
ENDIF(WIN32)
365-
366357
IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
367358
# TODO: Find how to compile and install the java wrapper classes
368359
# Find required libraries and include directories

storage/connect/filamdbf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ int DBFFAM::Cardinality(PGLOBAL g)
447447

448448
if (rln && Lrecl != rln) {
449449
// This happens always on some Linux platforms
450-
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, rln);
450+
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, (ushort)rln);
451451

452452
if (Accept) {
453453
Lrecl = rln;
@@ -967,7 +967,7 @@ int DBMFAM::Cardinality(PGLOBAL g)
967967

968968
if (rln && Lrecl != rln) {
969969
// This happens always on some Linux platforms
970-
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, rln);
970+
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, (ushort)rln);
971971

972972
if (Accept) {
973973
Lrecl = rln;

storage/connect/filamvct.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@
6565
extern int num_read, num_there; // Statistics
6666
static int num_write;
6767

68-
#if defined(UNIX)
69-
// Add dummy strerror (NGC)
70-
char *strerror(int num);
71-
#endif // UNIX
72-
7368
/***********************************************************************/
7469
/* Header containing block info for not split VEC tables. */
7570
/* Block and last values can be calculated from NumRec and Nrec. */

storage/connect/ha_connect.cc

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ pthread_mutex_t parmut;
204204
pthread_mutex_t usrmut;
205205
pthread_mutex_t tblmut;
206206

207+
#if defined(DEVELOPMENT)
208+
char *GetUserVariable(PGLOBAL g, const uchar *varname);
209+
210+
char *GetUserVariable(PGLOBAL g, const uchar *varname)
211+
{
212+
char buf[1024];
213+
bool b;
214+
THD *thd = current_thd;
215+
CHARSET_INFO *cs = system_charset_info;
216+
String *str = NULL, tmp(buf, sizeof(buf), cs);
217+
HASH uvars = thd->user_vars;
218+
user_var_entry *uvar = (user_var_entry*)my_hash_search(&uvars, varname, 0);
219+
220+
if (uvar)
221+
str = uvar->val_str(&b, &tmp, NOT_FIXED_DEC);
222+
223+
return str ? PlugDup(g, str->ptr()) : NULL;
224+
}; // end of GetUserVariable
225+
#endif // DEVELOPMENT
226+
207227
/***********************************************************************/
208228
/* Utility functions. */
209229
/***********************************************************************/
@@ -1795,7 +1815,9 @@ PCSZ ha_connect::GetDBName(PCSZ name)
17951815

17961816
const char *ha_connect::GetTableName(void)
17971817
{
1798-
return tshp ? tshp->table_name.str : table_share->table_name.str;
1818+
const char *path= tshp ? tshp->path.str : table_share->path.str;
1819+
const char *name= strrchr(path, slash);
1820+
return name ? name+1 : path;
17991821
} // end of GetTableName
18001822

18011823
char *ha_connect::GetPartName(void)
@@ -4678,9 +4700,6 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
46784700
PGLOBAL g= GetPlug(thd, xp);
46794701
DBUG_ENTER("ha_connect::start_stmt");
46804702

4681-
if (table->triggers)
4682-
g->More= 1; // We don't know which columns are used by the trigger
4683-
46844703
if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true))
46854704
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
46864705

@@ -4708,8 +4727,24 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
47084727
break;
47094728
} // endswitch mode
47104729

4711-
xmod= CheckMode(g, thd, newmode, &chk, &cras);
4712-
DBUG_RETURN((xmod == MODE_ERROR) ? HA_ERR_INTERNAL_ERROR : 0);
4730+
if (newmode == MODE_ANY) {
4731+
if (CloseTable(g)) {
4732+
// Make error a warning to avoid crash
4733+
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
4734+
rc = 0;
4735+
} // endif Close
4736+
4737+
locked = 0;
4738+
xmod = MODE_ANY; // For info commands
4739+
DBUG_RETURN(rc);
4740+
} // endif MODE_ANY
4741+
4742+
newmode = CheckMode(g, thd, newmode, &chk, &cras);
4743+
4744+
if (newmode == MODE_ERROR)
4745+
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
4746+
4747+
DBUG_RETURN(check_stmt(g, newmode, cras));
47134748
} // end of start_stmt
47144749

47154750
/**
@@ -4891,21 +4926,16 @@ int ha_connect::external_lock(THD *thd, int lock_type)
48914926
// Make it a warning to avoid crash
48924927
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
48934928
rc= 0;
4894-
//my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
4895-
//rc = HA_ERR_INTERNAL_ERROR;
48964929
} // endif Close
48974930

48984931
locked= 0;
4899-
// m_lock_type= lock_type;
49004932
xmod= MODE_ANY; // For info commands
49014933
DBUG_RETURN(rc);
4902-
} // endif MODE_ANY
4903-
else
4904-
if (check_privileges(thd, options, table->s->db.str)) {
4905-
strcpy(g->Message, "This operation requires the FILE privilege");
4906-
htrc("%s\n", g->Message);
4907-
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
4908-
} // endif check_privileges
4934+
} else if (check_privileges(thd, options, table->s->db.str)) {
4935+
strcpy(g->Message, "This operation requires the FILE privilege");
4936+
htrc("%s\n", g->Message);
4937+
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
4938+
} // endif check_privileges
49094939

49104940

49114941
DBUG_ASSERT(table && table->s);
@@ -4916,43 +4946,31 @@ int ha_connect::external_lock(THD *thd, int lock_type)
49164946
if (newmode == MODE_ERROR)
49174947
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
49184948

4919-
// If this is the start of a new query, cleanup the previous one
4949+
DBUG_RETURN(check_stmt(g, newmode, cras));
4950+
} // end of external_lock
4951+
4952+
4953+
int ha_connect::check_stmt(PGLOBAL g, MODE newmode, bool cras)
4954+
{
4955+
int rc = 0;
4956+
DBUG_ENTER("ha_connect::check_stmt");
4957+
4958+
// If this is the start of a new query, cleanup the previous one
49204959
if (xp->CheckCleanup()) {
49214960
tdbp= NULL;
49224961
valid_info= false;
4923-
} // endif CheckCleanup
4924-
4925-
#if 0
4926-
if (xcheck) {
4927-
// This must occur after CheckCleanup
4928-
if (!g->Xchk) {
4929-
g->Xchk= new(g) XCHK;
4930-
((PCHK)g->Xchk)->oldsep= GetBooleanOption("Sepindex", false);
4931-
((PCHK)g->Xchk)->oldpix= GetIndexInfo();
4932-
} // endif Xchk
4933-
4934-
} else
4935-
g->Xchk= NULL;
4936-
#endif // 0
4962+
} // endif CheckCleanup
49374963

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

4941-
if (trace(1)) {
4942-
#if 0
4943-
htrc("xcheck=%d cras=%d\n", xcheck, cras);
4944-
4945-
if (xcheck)
4946-
htrc("oldsep=%d oldpix=%p\n",
4947-
((PCHK)g->Xchk)->oldsep, ((PCHK)g->Xchk)->oldpix);
4948-
#endif // 0
4949-
htrc("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
4950-
} // endif trace
4967+
if (trace(1))
4968+
htrc("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
49514969

49524970
// Set or reset the good database environment
49534971
if (CntCheckDB(g, this, GetDBName(NULL))) {
4954-
htrc("%p external_lock: %s\n", this, g->Message);
4955-
rc= HA_ERR_INTERNAL_ERROR;
4972+
htrc("%p check_stmt: %s\n", this, g->Message);
4973+
rc= HA_ERR_INTERNAL_ERROR;
49564974
// This can NOT be called without open called first, but
49574975
// the table can have been closed since then
49584976
} else if (!tdbp || xp->CheckQuery(valid_query_id) || xmod != newmode) {
@@ -4972,10 +4990,10 @@ int ha_connect::external_lock(THD *thd, int lock_type)
49724990
} // endif tdbp
49734991

49744992
if (trace(1))
4975-
htrc("external_lock: rc=%d\n", rc);
4993+
htrc("check_stmt: rc=%d\n", rc);
49764994

49774995
DBUG_RETURN(rc);
4978-
} // end of external_lock
4996+
} // end of check_stmt
49794997

49804998

49814999
/**
@@ -6257,7 +6275,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
62576275
TABLE *st= table; // Probably unuseful
62586276
THD *thd= ha_thd();
62596277
LEX_STRING cnc = table_arg->s->connect_string;
6260-
#if defined(WITH_PARTITION_STORAGE_ENGINE)
6278+
#ifdef WITH_PARTITION_STORAGE_ENGINE
62616279
partition_info *part_info= table_arg->part_info;
62626280
#else // !WITH_PARTITION_STORAGE_ENGINE
62636281
#define part_info 0

storage/connect/ha_connect.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ int index_prev(uchar *buf);
507507
protected:
508508
bool check_privileges(THD *thd, PTOS options, char *dbn, bool quick=false);
509509
MODE CheckMode(PGLOBAL g, THD *thd, MODE newmode, bool *chk, bool *cras);
510-
char *GetDBfromName(const char *name);
510+
int check_stmt(PGLOBAL g, MODE newmode, bool cras);
511+
char *GetDBfromName(const char *name);
511512

512513
// Members
513514
static ulong num; // Tracable handler number

storage/connect/inihandl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
194194
}
195195

196196
for (key = section->key; key; key = key->next)
197-
if (key->name && key->name[0]) {
197+
if (key->name[0]) {
198198
fprintf(file, "%s", SVP(key->name));
199199

200200
if (key->value)

storage/connect/javaconn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ bool JAVAConn::Open(PGLOBAL g)
441441

442442
//=============== load and initialize Java VM and JNI interface =============
443443
rc = CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !!
444-
delete options; // we then no longer need the initialisation options.
444+
delete[] options; // we then no longer need the initialisation options.
445445

446446
switch (rc) {
447447
case JNI_OK:

storage/connect/json.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,3 @@ class JVALUE : public JSON {
299299
PJVAL Next; // Next value in array
300300
bool Del; // True when deleted
301301
}; // end of class JVALUE
302-

storage/connect/jsonudf.cpp

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,8 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
16661666
if (args->arg_count > (unsigned)i) {
16671667
int j = 0, n = args->attribute_lengths[i];
16681668
my_bool b; // true if attribute is zero terminated
1669-
PSZ p, s = args->attributes[i];
1669+
PSZ p;
1670+
PCSZ s = args->attributes[i];
16701671

16711672
if (s && *s && (n || *s == '\'')) {
16721673
if ((b = (!n || !s[n])))
@@ -5805,6 +5806,52 @@ char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result,
58055806
return str;
58065807
} // end of envar
58075808

5809+
#if defined(DEVELOPMENT)
5810+
extern char *GetUserVariable(PGLOBAL g, const uchar *varname);
5811+
5812+
/*********************************************************************************/
5813+
/* Utility function returning a user variable value. */
5814+
/*********************************************************************************/
5815+
my_bool uvar_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
5816+
{
5817+
unsigned long reslen, memlen;
5818+
5819+
if (args->arg_count != 1) {
5820+
strcpy(message, "Unique argument must be a user variable name");
5821+
return true;
5822+
} else
5823+
CalcLen(args, false, reslen, memlen, true);
5824+
5825+
initid->maybe_null = true;
5826+
return JsonInit(initid, args, message, true, reslen, memlen, 2048);
5827+
} // end of uvar_init
5828+
5829+
char *uvar(UDF_INIT *initid, UDF_ARGS *args, char *result,
5830+
unsigned long *res_length, char *is_null, char *)
5831+
{
5832+
char *str, varname[256];
5833+
PGLOBAL g = (PGLOBAL)initid->ptr;
5834+
int n = MY_MIN(args->lengths[0], sizeof(varname) - 1);
5835+
5836+
PlugSubSet(g->Sarea, g->Sarea_Size);
5837+
memcpy(varname, args->args[0], n);
5838+
varname[n] = 0;
5839+
5840+
if (!(str = GetUserVariable(g, (const uchar*)&varname))) {
5841+
*res_length = 0;
5842+
*is_null = 1;
5843+
} else
5844+
*res_length = strlen(str);
5845+
5846+
return str;
5847+
} // end of uvar
5848+
5849+
void uvar_deinit(UDF_INIT* initid)
5850+
{
5851+
JsonFreeMem((PGLOBAL)initid->ptr);
5852+
} // end of uvar_deinit
5853+
#endif // DEVELOPMENT
5854+
58085855
/*********************************************************************************/
58095856
/* Returns the distinct number of B occurences in A. */
58105857
/*********************************************************************************/
@@ -5851,4 +5898,3 @@ long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result,
58515898
free(str2);
58525899
return n;
58535900
} // end of countin
5854-

storage/connect/plugutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ BOOL PlugSubSet(void *memp, uint size)
526526
/***********************************************************************/
527527
/* Use it to export a function that do throwing. */
528528
/***********************************************************************/
529-
void *DoThrow(int n)
529+
static void *DoThrow(int n)
530530
{
531531
throw n;
532532
} /* end of DoThrow */

0 commit comments

Comments
 (0)