Commit 5af076e5 authored by Olivier Bertrand's avatar Olivier Bertrand

Add all changes made on 10.1

parent 26adbb2d
...@@ -257,6 +257,32 @@ int main() { ...@@ -257,6 +257,32 @@ int main() {
ENDIF(UNIX) ENDIF(UNIX)
ENDIF(CONNECT_WITH_ODBC) ENDIF(CONNECT_WITH_ODBC)
#
# JDBC
#
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)
IF(CONNECT_WITH_JDBC)
# TODO: detect Java SDK and the presence of JDBC connectors
# TODO: Find how to compile and install the JdbcInterface.java class
# Find required libraries and include directories
FIND_PACKAGE(Java)
FIND_PACKAGE(JNI)
IF (JAVA_FOUND AND JNI_FOUND)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY})
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
JdbcInterface.java JdbcInterface.class
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h)
add_definitions(-DJDBC_SUPPORT)
ELSE()
SET(JDBC_LIBRARY "")
ENDIF()
ENDIF(CONNECT_WITH_JDBC)
# #
# XMAP # XMAP
...@@ -277,5 +303,5 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} ...@@ -277,5 +303,5 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
COMPONENT connect-engine COMPONENT connect-engine
RECOMPILE_FOR_EMBEDDED RECOMPILE_FOR_EMBEDDED
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${IPHLPAPI_LIBRARY}) ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY})
This diff was suppressed by a .gitattributes entry.
This diff is collapsed.
This diff is collapsed.
...@@ -622,13 +622,16 @@ void PROFILE_End(void) ...@@ -622,13 +622,16 @@ void PROFILE_End(void)
if (trace) if (trace)
htrc("PROFILE_End: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES); htrc("PROFILE_End: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES);
if (!CurProfile) // Sergey Vojtovich
return;
/* Close all opened files and free the cache structure */ /* Close all opened files and free the cache structure */
for (i = 0; i < N_CACHED_PROFILES; i++) { for (i = 0; i < N_CACHED_PROFILES; i++) {
if (trace) if (trace)
htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i); htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i);
CurProfile = MRUProfile[i]; // CurProfile = MRUProfile[i]; Sergey Vojtovich
PROFILE_ReleaseFile(); // PROFILE_ReleaseFile(); see MDEV-9997
free(MRUProfile[i]); free(MRUProfile[i]);
} // endfor i } // endfor i
......
// Timeout and net wait defaults
#define DEFAULT_LOGIN_TIMEOUT -1 // means do not set
#define DEFAULT_QUERY_TIMEOUT -1 // means do not set
typedef struct jdbc_parms {
int CheckSize(int rows);
char *Driver; // JDBC driver
char *Url; // Driver URL
char *User; // User connect info
char *Pwd; // Password connect info
//int Cto; // Connect timeout
//int Qto; // Query timeout
int Fsize; // Fetch size
bool Scrollable; // Scrollable cursor
} JDBCPARM, *PJPARM;
/***********************************************************************/
/* JDBC catalog function prototypes. */
/***********************************************************************/
#if defined(PROMPT_OK)
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
#endif // PROMPT_OK
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table,
char *colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat,
char *tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
This diff is collapsed.
/***********************************************************************/
/* JDBConn.h : header file for the JDBC connection classes. */
/***********************************************************************/
//nclude <windows.h> /* Windows include file */
//nclude <windowsx.h> /* Message crackers */
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include "block.h"
/***********************************************************************/
/* JDBC interface. */
/***********************************************************************/
#include <jni.h>
/***********************************************************************/
/* Constants and defines. */
/***********************************************************************/
// Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names
//efine MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE 0 // TYPE_NULL
#if !defined(__WIN__)
typedef unsigned char *PUCHAR;
#endif // !__WIN__
enum JCATINFO {
CAT_TAB = 1, // JDBC Tables
CAT_COL = 2, // JDBC Columns
CAT_KEY = 3, // JDBC PrimaryKeys
//CAT_STAT = 4, // SQLStatistics
//CAT_SPC = 5 // SQLSpecialColumns
};
/***********************************************************************/
/* This structure is used to control the catalog functions. */
/***********************************************************************/
typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PUCHAR DB; // Database (Schema)
PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern
} JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
typedef jint(JNICALL *GETJVM) (JavaVM **, jsize, jsize *);
// JDBC connection to a data source
class TDBJDBC;
class JDBCCOL;
class JDBConn;
class TDBXJDC;
/***********************************************************************/
/* JDBConn class. */
/***********************************************************************/
class JDBConn : public BLOCK {
friend class TDBJDBC;
friend class TDBXJDC;
//friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private:
JDBConn(); // Standard (unused) constructor
public:
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
int Open(PJPARM sop);
int Rewind(char *sql);
void Close(void);
PQRYRES AllocateResult(PGLOBAL g);
// Attributes
public:
char *GetQuoteChar(void) { return m_IDQuoteChar; }
// Database successfully opened?
bool IsOpen(void) { return m_Opened; }
//PSZ GetStringInfo(ushort infotype);
int GetMaxValue(int infotype);
//PSZ GetConnect(void) { return m_Connect; }
public:
// Operations
//void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(char *sql, JDBCCOL *colp);
int ExecuteQuery(char *sql);
int ExecuteUpdate(char *sql);
int Fetch(int pos = 0);
bool PrepareSQL(char *sql);
int ExecuteSQL(void);
bool SetParam(JDBCCOL *colp);
int ExecSQLcommand(char *sql);
void SetColumnValue(int rank, PSZ name, PVAL val);
int GetCatInfo(JCATPARM *cap);
//bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *src);
public:
// Set static variables
static void SetJVM(void)
{ LibJvm = NULL; CreateJavaVM = NULL; GetCreatedJavaVMs = NULL; }
static void ResetJVM(void);
static bool GetJVM(PGLOBAL g);
// Implementation
public:
//virtual ~JDBConn();
// JDBC operations
protected:
char *Check(void);
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
//void ThrowDJX(PSZ msg);
//void Free(void);
protected:
// Members
#if defined(__WIN__)
static HANDLE LibJvm; // Handle to the jvm DLL
#else // !__WIN__
static void *LibJvm; // Handle for the jvm shared library
#endif // !__WIN__
static CRTJVM CreateJavaVM;
static GETJVM GetCreatedJavaVMs;
PGLOBAL m_G;
TDBJDBC *m_Tdb;
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
JNIEnv *env; // Pointer to native interface
jclass jdi; // Pointer to the JdbcInterface class
jobject job; // The JdbcInterface class object
jmethodID xqid; // The ExecuteQuery method ID
jmethodID xuid; // The ExecuteUpdate method ID
jmethodID xid; // The Execute method ID
jmethodID grs; // The GetResult method ID
jmethodID readid; // The ReadNext method ID
jmethodID fetchid; // The Fetch method ID
jmethodID typid; // The ColumnType method ID
jmethodID prepid; // The CreatePrepStmt method ID
jmethodID xpid; // The ExecutePrep method ID
jmethodID pcid; // The ClosePrepStmt method ID
//DWORD m_LoginTimeout;
//DWORD m_QueryTimeout;
//DWORD m_UpdateOptions;
char m_IDQuoteChar[2];
PSZ m_Driver;
PSZ m_Url;
PSZ m_User;
PSZ m_Pwd;
int m_Ncol;
int m_Aff;
int m_Rows;
int m_Fetch;
int m_RowsetSize;
jboolean m_Updatable;
jboolean m_Transact;
jboolean m_Scrollable;
bool m_Opened;
bool m_Full;
}; // end of JDBConn class definition
...@@ -3538,37 +3538,9 @@ void jsoncontains_path_deinit(UDF_INIT* initid) ...@@ -3538,37 +3538,9 @@ void jsoncontains_path_deinit(UDF_INIT* initid)
} // end of jsoncontains_path_deinit } // end of jsoncontains_path_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Set Json items of a Json document according to path. */ /* This function is used by the json_set/insert/update_item functions. */
/*********************************************************************************/ /*********************************************************************************/
my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
{
unsigned long reslen, memlen;
int n = IsJson(args, 0);
if (!(args->arg_count % 2)) {
strcpy(message, "This function must have an odd number of arguments");
return true;
} else if (!n && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "First argument must be a json item");
return true;
} else
CalcLen(args, false, reslen, memlen);
if (n == 2 && args->args[0]) {
char fn[_MAX_PATH];
long fl;
memcpy(fn, args->args[0], args->lengths[0]);
fn[args->lengths[0]] = 0;
fl = GetFileLength(fn);
memlen += fl * 3;
} else if (n != 3)
memlen += args->lengths[0] * 3;
return JsonInit(initid, args, message, true, reslen, memlen);
} // end of json_set_item_init
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *p, *path, *str = NULL; char *p, *path, *str = NULL;
...@@ -3586,12 +3558,16 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3586,12 +3558,16 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item) } else if (initid->const_item)
g->N = 1; g->N = 1;
if (!strcmp(result, "$insert")) if (!strcmp(result, "$set"))
w = 0;
else if (!strcmp(result, "$insert"))
w = 1; w = 1;
else if (!strcmp(result, "$update")) else if (!strcmp(result, "$update"))
w = 2; w = 2;
else else {
w = 0; PUSH_WARNING("Logical error, please contact CONNECT developer");
goto err;
} // endelse
// Save stack and allocation environment and prepare error return // Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) { if (g->jump_level == MAX_JUMP) {
...@@ -3660,10 +3636,10 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3660,10 +3636,10 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Activityp = (PACTIVITY)str; g->Activityp = (PACTIVITY)str;
err: err:
g->jump_level--; g->jump_level--;
fin: fin:
if (!str) { if (!str) {
*is_null = 1; *is_null = 1;
*res_length = 0; *res_length = 0;
...@@ -3671,6 +3647,44 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3671,6 +3647,44 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of handle_item
/*********************************************************************************/
/* Set Json items of a Json document according to path. */
/*********************************************************************************/
my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
unsigned long reslen, memlen;
int n = IsJson(args, 0);
if (!(args->arg_count % 2)) {
strcpy(message, "This function must have an odd number of arguments");
return true;
} else if (!n && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "First argument must be a json item");
return true;
} else
CalcLen(args, false, reslen, memlen);
if (n == 2 && args->args[0]) {
char fn[_MAX_PATH];
long fl;
memcpy(fn, args->args[0], args->lengths[0]);
fn[args->lengths[0]] = 0;
fl = GetFileLength(fn);
memlen += fl * 3;
} else if (n != 3)
memlen += args->lengths[0] * 3;
return JsonInit(initid, args, message, true, reslen, memlen);
} // end of json_set_item_init
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p)
{
strcpy(result, "$set");
return handle_item(initid, args, result, res_length, is_null, p);
} // end of json_set_item } // end of json_set_item
void json_set_item_deinit(UDF_INIT* initid) void json_set_item_deinit(UDF_INIT* initid)
...@@ -3690,7 +3704,7 @@ char *json_insert_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3690,7 +3704,7 @@ char *json_insert_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p) unsigned long *res_length, char *is_null, char *p)
{ {
strcpy(result, "$insert"); strcpy(result, "$insert");
return json_set_item(initid, args, result, res_length, is_null, p); return handle_item(initid, args, result, res_length, is_null, p);
} // end of json_insert_item } // end of json_insert_item
void json_insert_item_deinit(UDF_INIT* initid) void json_insert_item_deinit(UDF_INIT* initid)
...@@ -3710,7 +3724,7 @@ char *json_update_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3710,7 +3724,7 @@ char *json_update_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p) unsigned long *res_length, char *is_null, char *p)
{ {
strcpy(result, "$update"); strcpy(result, "$update");
return json_set_item(initid, args, result, res_length, is_null, p); return handle_item(initid, args, result, res_length, is_null, p);
} // end of json_update_item } // end of json_update_item
void json_update_item_deinit(UDF_INIT* initid) void json_update_item_deinit(UDF_INIT* initid)
...@@ -4706,14 +4720,9 @@ void jbin_item_merge_deinit(UDF_INIT* initid) ...@@ -4706,14 +4720,9 @@ void jbin_item_merge_deinit(UDF_INIT* initid)
} // end of jbin_item_merge_deinit } // end of jbin_item_merge_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Set Json items of a Json document according to path. */ /* This function is used by the jbin_set/insert/update functions. */
/*********************************************************************************/ /*********************************************************************************/
my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
{
return json_set_item_init(initid, args, message);
} // end of jbin_set_item_init
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *p, *path; char *p, *path;
...@@ -4732,12 +4741,16 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4732,12 +4741,16 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item) } else if (initid->const_item)
g->N = 1; g->N = 1;
if (!strcmp(result, "$insert")) if (!strcmp(result, "$set"))
w = 0;
else if (!strcmp(result, "$insert"))
w = 1; w = 1;
else if (!strcmp(result, "$update")) else if (!strcmp(result, "$update"))
w = 2; w = 2;
else else {
w = 0; PUSH_WARNING("Logical error, please contact CONNECT developer");
goto fin;
} // endelse
if (!g->Xchk) { if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true, false, true)) { if (CheckMemory(g, initid, args, 1, true, false, true)) {
...@@ -4791,7 +4804,7 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4791,7 +4804,7 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Activityp = (PACTIVITY)bsp; g->Activityp = (PACTIVITY)bsp;
fin: fin:
if (!bsp) { if (!bsp) {
*is_null = 1; *is_null = 1;
*res_length = 0; *res_length = 0;
...@@ -4799,6 +4812,21 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4799,6 +4812,21 @@ char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of bin_handle_item
/*********************************************************************************/
/* Set Json items of a Json document according to path. */
/*********************************************************************************/
my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
return json_set_item_init(initid, args, message);
} // end of jbin_set_item_init
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p)
{
strcpy(result, "$set");
return bin_handle_item(initid, args, result, res_length, is_null, p);
} // end of jbin_set_item } // end of jbin_set_item
void jbin_set_item_deinit(UDF_INIT* initid) void jbin_set_item_deinit(UDF_INIT* initid)
...@@ -4818,7 +4846,7 @@ char *jbin_insert_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4818,7 +4846,7 @@ char *jbin_insert_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p) unsigned long *res_length, char *is_null, char *p)
{ {
strcpy(result, "$insert"); strcpy(result, "$insert");
return jbin_set_item(initid, args, result, res_length, is_null, p); return bin_handle_item(initid, args, result, res_length, is_null, p);
} // end of jbin_insert_item } // end of jbin_insert_item
void jbin_insert_item_deinit(UDF_INIT* initid) void jbin_insert_item_deinit(UDF_INIT* initid)
...@@ -4838,7 +4866,7 @@ char *jbin_update_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4838,7 +4866,7 @@ char *jbin_update_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p) unsigned long *res_length, char *is_null, char *p)
{ {
strcpy(result, "$update"); strcpy(result, "$update");
return jbin_set_item(initid, args, result, res_length, is_null, p); return bin_handle_item(initid, args, result, res_length, is_null, p);
} // end of jbin_update_item } // end of jbin_update_item
void jbin_update_item_deinit(UDF_INIT* initid) void jbin_update_item_deinit(UDF_INIT* initid)
...@@ -4999,3 +5027,30 @@ void json_serialize_deinit(UDF_INIT* initid) ...@@ -4999,3 +5027,30 @@ void json_serialize_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of json_serialize_deinit } // end of json_serialize_deinit
/*********************************************************************************/
/* Utility function returning an environment variable value. */
/*********************************************************************************/
my_bool envar_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count != 1) {
strcpy(message, "Unique argument must be an environment variable name");
return true;
} else
return false;
} // end of envar_init
char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *)
{
char *str, name[256];
int n = MY_MIN(args->lengths[0], sizeof(name) - 1);
memcpy(name, args->args[0], n);
name[n] = 0;
str = getenv(name);
*res_length = (str) ? strlen(str) : 0;
return str;
} // end of envar
...@@ -218,8 +218,12 @@ extern "C" { ...@@ -218,8 +218,12 @@ extern "C" {
DllExport my_bool json_serialize_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_serialize_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_serialize(UDF_EXEC_ARGS); DllExport char *json_serialize(UDF_EXEC_ARGS);
DllExport void json_serialize_deinit(UDF_INIT*); DllExport void json_serialize_deinit(UDF_INIT*);
DllExport my_bool envar_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *envar(UDF_EXEC_ARGS);
} // extern "C" } // extern "C"
/*********************************************************************************/ /*********************************************************************************/
/* Structure JPN. Used to make the locate path. */ /* Structure JPN. Used to make the locate path. */
/*********************************************************************************/ /*********************************************************************************/
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
#else // !__WIN__ #else // !__WIN__
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#if defined(THREAD) //#if defined(THREAD)
#include <pthread.h> #include <pthread.h>
#endif // THREAD //#endif // THREAD
#include <stdarg.h> #include <stdarg.h>
#define BIGMEM 2147483647 // Max int value #define BIGMEM 2147483647 // Max int value
#endif // !__WIN__ #endif // !__WIN__
...@@ -69,17 +69,6 @@ ...@@ -69,17 +69,6 @@
#include "valblk.h" #include "valblk.h"
#include "rcmsg.h" #include "rcmsg.h"
/***********************************************************************/
/* Macro or external routine definition */
/***********************************************************************/
#if defined(THREAD)
#if defined(__WIN__)
extern CRITICAL_SECTION parsec; // Used calling the Flex parser
#else // !__WIN__
extern pthread_mutex_t parmut;
#endif // !__WIN__
#endif // THREAD
/***********************************************************************/ /***********************************************************************/
/* DB static variables. */ /* DB static variables. */
/***********************************************************************/ /***********************************************************************/
...@@ -90,6 +79,12 @@ extern "C" { ...@@ -90,6 +79,12 @@ extern "C" {
extern char version[]; extern char version[];
} // extern "C" } // extern "C"
#if defined(__WIN__)
extern CRITICAL_SECTION parsec; // Used calling the Flex parser
#else // !__WIN__
extern pthread_mutex_t parmut;
#endif // !__WIN__
// The debug trace used by the main thread // The debug trace used by the main thread
FILE *pfile = NULL; FILE *pfile = NULL;
...@@ -702,21 +697,21 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) ...@@ -702,21 +697,21 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
/* Call the FLEX generated parser. In multi-threading mode the next */ /* Call the FLEX generated parser. In multi-threading mode the next */
/* instruction is included in an Enter/LeaveCriticalSection bracket. */ /* instruction is included in an Enter/LeaveCriticalSection bracket. */
/*********************************************************************/ /*********************************************************************/
#if defined(THREAD) //#if defined(THREAD)
#if defined(__WIN__) #if defined(__WIN__)
EnterCriticalSection((LPCRITICAL_SECTION)&parsec); EnterCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__ #else // !__WIN__
pthread_mutex_lock(&parmut); pthread_mutex_lock(&parmut);
#endif // !__WIN__ #endif // !__WIN__
#endif // THREAD //#endif // THREAD
rc = fmdflex(pdp); rc = fmdflex(pdp);
#if defined(THREAD) //#if defined(THREAD)
#if defined(__WIN__) #if defined(__WIN__)
LeaveCriticalSection((LPCRITICAL_SECTION)&parsec); LeaveCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__ #else // !__WIN__
pthread_mutex_unlock(&parmut); pthread_mutex_unlock(&parmut);
#endif // !__WIN__ #endif // !__WIN__
#endif // THREAD //#endif // THREAD
if (trace) if (trace)
htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc); htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc);
...@@ -1102,6 +1097,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp) ...@@ -1102,6 +1097,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
case TYPE_AM_DOM: strcpy(amn, "DOM"); break; case TYPE_AM_DOM: strcpy(amn, "DOM"); break;
case TYPE_AM_DIR: strcpy(amn, "DIR"); break; case TYPE_AM_DIR: strcpy(amn, "DIR"); break;
case TYPE_AM_ODBC: strcpy(amn, "ODBC"); break; case TYPE_AM_ODBC: strcpy(amn, "ODBC"); break;
case TYPE_AM_JDBC: strcpy(amn, "JDBC"); break;
case TYPE_AM_MAC: strcpy(amn, "MAC"); break; case TYPE_AM_MAC: strcpy(amn, "MAC"); break;
case TYPE_AM_OEM: strcpy(amn, "OEM"); break; case TYPE_AM_OEM: strcpy(amn, "OEM"); break;
case TYPE_AM_OUT: strcpy(amn, "OUT"); break; case TYPE_AM_OUT: strcpy(amn, "OUT"); break;
......
...@@ -305,7 +305,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g) ...@@ -305,7 +305,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
case TAB_OEM: case TAB_OEM:
poff = 0; // Offset represents an independant flag poff = 0; // Offset represents an independant flag
break; break;
default: // VCT PLG ODBC MYSQL WMI... default: // VCT PLG ODBC JDBC MYSQL WMI...
poff = 0; // NA poff = 0; // NA
break; break;
} // endswitch tc } // endswitch tc
...@@ -514,9 +514,10 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) ...@@ -514,9 +514,10 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
} // endif getdef } // endif getdef
#else // !__WIN__ #else // !__WIN__
const char *error = NULL; const char *error = NULL;
Dl_info dl_info;
#if 0 // Don't know what all this stuff does #if 0 // Don't know what all this stuff does
Dl_info dl_info;
// The OEM lib must retrieve exported CONNECT variables // The OEM lib must retrieve exported CONNECT variables
if (dladdr(&connect_hton, &dl_info)) { if (dladdr(&connect_hton, &dl_info)) {
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) {
......
This diff is collapsed.
This diff is collapsed.
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