Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c92f2606
Commit
c92f2606
authored
May 21, 2016
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit changes made from 10.1
parent
4a1ffc38
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
453 additions
and
332 deletions
+453
-332
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+23
-11
storage/connect/jdbconn.cpp
storage/connect/jdbconn.cpp
+285
-304
storage/connect/jdbconn.h
storage/connect/jdbconn.h
+25
-3
storage/connect/tabjdbc.cpp
storage/connect/tabjdbc.cpp
+117
-14
storage/connect/tabjdbc.h
storage/connect/tabjdbc.h
+3
-0
No files found.
storage/connect/ha_connect.cc
View file @
c92f2606
...
...
@@ -119,6 +119,7 @@
#undef OFFSET
#define NOPARSE
#define NJDBC
#if defined(UNIX)
#include "osutil.h"
#endif // UNIX
...
...
@@ -128,7 +129,7 @@
#include "odbccat.h"
#endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT)
#include "
jdbccat
.h"
#include "
tabjdbc
.h"
#include "jdbconn.h"
#endif // JDBC_SUPPORT
#include "xtable.h"
...
...
@@ -5224,7 +5225,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#endif
#if defined(JDBC_SUPPORT)
driver
=
GetListOption
(
g
,
"Driver"
,
topt
->
oplist
,
NULL
);
url
=
GetListOption
(
g
,
"URL"
,
topt
->
oplist
,
NULL
);
//
url= GetListOption(g, "URL", topt->oplist, NULL);
tabtyp
=
GetListOption
(
g
,
"Tabtype"
,
topt
->
oplist
,
NULL
);
#endif // JDBC_SUPPORT
mxe
=
atoi
(
GetListOption
(
g
,
"maxerr"
,
topt
->
oplist
,
"0"
));
...
...
@@ -5325,18 +5326,31 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case
TAB_JDBC
:
if
(
fnc
&
FNC_DRIVER
)
{
ok
=
true
;
}
else
if
(
!
url
&&
!
(
url
=
strz
(
g
,
create_info
->
connect_string
)))
{
}
else
if
(
!
(
url
=
strz
(
g
,
create_info
->
connect_string
)))
{
strcpy
(
g
->
Message
,
"Missing URL"
);
}
else
{
// Store ODBC additional parameters
// Store JDBC additional parameters
int
rc
;
PJDBCDEF
jdef
=
new
(
g
)
JDBCDEF
();
jdef
->
SetName
(
create_info
->
alias
);
sjp
=
(
PJPARM
)
PlugSubAlloc
(
g
,
NULL
,
sizeof
(
JDBCPARM
));
sjp
->
Driver
=
driver
;
sjp
->
Url
=
url
;
sjp
->
User
=
(
char
*
)
user
;
sjp
->
Pwd
=
(
char
*
)
pwd
;
sjp
->
Fsize
=
0
;
sjp
->
Scrollable
=
false
;
ok
=
true
;
if
((
rc
=
jdef
->
ParseURL
(
g
,
url
,
false
))
==
RC_OK
)
{
sjp
->
Url
=
url
;
sjp
->
User
=
(
char
*
)
user
;
sjp
->
Pwd
=
(
char
*
)
pwd
;
ok
=
true
;
}
else
if
(
rc
==
RC_NF
)
{
if
(
jdef
->
GetTabname
())
tab
=
jdef
->
GetTabname
();
ok
=
jdef
->
SetParms
(
sjp
);
}
// endif rc
}
// endif's
supfnc
|=
(
FNC_DRIVER
|
FNC_TABLE
);
...
...
@@ -5775,12 +5789,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
switch
(
typ
)
{
case
TYPE_DOUBLE
:
case
TYPE_DECIM
:
// Some data sources do not count dec in length (prec)
prec
+=
(
dec
+
2
);
// To be safe
break
;
case
TYPE_DECIM
:
prec
=
len
;
break
;
default:
dec
=
0
;
}
// endswitch typ
...
...
storage/connect/jdbconn.cpp
View file @
c92f2606
This diff is collapsed.
Click to expand it.
storage/connect/jdbconn.h
View file @
c92f2606
...
...
@@ -53,6 +53,9 @@ typedef struct tagJCATPARM {
typedef
jint
(
JNICALL
*
CRTJVM
)
(
JavaVM
**
,
void
**
,
void
*
);
typedef
jint
(
JNICALL
*
GETJVM
)
(
JavaVM
**
,
jsize
,
jsize
*
);
#if defined(_DEBUG)
typedef
jint
(
JNICALL
*
GETDEF
)
(
void
*
);
#endif // _DEBUG
// JDBC connection to a data source
class
TDBJDBC
;
...
...
@@ -109,8 +112,15 @@ class JDBConn : public BLOCK {
public:
// Set static variables
static
void
SetJVM
(
void
)
{
LibJvm
=
NULL
;
CreateJavaVM
=
NULL
;
GetCreatedJavaVMs
=
NULL
;
}
static
void
SetJVM
(
void
)
{
LibJvm
=
NULL
;
CreateJavaVM
=
NULL
;
GetCreatedJavaVMs
=
NULL
;
#if defined(_DEBUG)
GetDefaultJavaVMInitArgs
=
NULL
;
#endif // _DEBUG
}
// end of SetJVM
static
void
ResetJVM
(
void
);
static
bool
GetJVM
(
PGLOBAL
g
);
...
...
@@ -120,7 +130,8 @@ class JDBConn : public BLOCK {
// JDBC operations
protected:
char
*
Check
(
void
);
bool
gmID
(
PGLOBAL
g
,
jmethodID
&
mid
,
const
char
*
name
,
const
char
*
sig
);
bool
Check
(
jint
rc
=
0
);
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
//void ThrowDJX(PSZ msg);
//void Free(void);
...
...
@@ -134,6 +145,9 @@ class JDBConn : public BLOCK {
#endif // !__WIN__
static
CRTJVM
CreateJavaVM
;
static
GETJVM
GetCreatedJavaVMs
;
#if defined(_DEBUG)
static
GETDEF
GetDefaultJavaVMInitArgs
;
#endif // _DEBUG
PGLOBAL
m_G
;
TDBJDBC
*
m_Tdb
;
JavaVM
*
jvm
;
// Pointer to the JVM (Java Virtual Machine)
...
...
@@ -150,9 +164,17 @@ class JDBConn : public BLOCK {
jmethodID
prepid
;
// The CreatePrepStmt method ID
jmethodID
xpid
;
// The ExecutePrep method ID
jmethodID
pcid
;
// The ClosePrepStmt method ID
jmethodID
errid
;
// The GetErrmsg method ID
jmethodID
chrfldid
;
// The StringField method ID
jmethodID
intfldid
;
// The IntField method ID
jmethodID
dblfldid
;
// The DoubleField method ID
jmethodID
fltfldid
;
// The FloatField method ID
jmethodID
datfldid
;
// The TimestampField method ID
jmethodID
bigfldid
;
// The BigintField method ID
//DWORD m_LoginTimeout;
//DWORD m_QueryTimeout;
//DWORD m_UpdateOptions;
char
*
Msg
;
char
m_IDQuoteChar
[
2
];
PSZ
m_Driver
;
PSZ
m_Url
;
...
...
storage/connect/tabjdbc.cpp
View file @
c92f2606
/************* TabJDBC C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: TABJDBC */
/* ------------- */
/* Version 1.
0
*/
/* Version 1.
1
*/
/* */
/* COPYRIGHT: */
/* ---------- */
...
...
@@ -34,8 +34,10 @@
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#define MYSQL_SERVER 1
#include "my_global.h"
#include "sql_class.h"
#include "sql_servers.h"
#if defined(__WIN__)
#include <io.h>
#include <fcntl.h>
...
...
@@ -67,7 +69,6 @@
#include "plgdbsem.h"
#include "mycat.h"
#include "xtable.h"
#include "jdbccat.h"
#include "tabjdbc.h"
#include "tabmul.h"
#include "reldef.h"
...
...
@@ -101,11 +102,107 @@ JDBCDEF::JDBCDEF(void)
Scrollable
=
Xsrc
=
false
;
}
// end of JDBCDEF constructor
/***********************************************************************/
/* Called on table construction. */
/***********************************************************************/
bool
JDBCDEF
::
SetParms
(
PJPARM
sjp
)
{
sjp
->
Url
=
Url
;
sjp
->
User
=
Username
;
sjp
->
Pwd
=
Password
;
return
true
;
}
// end of SetParms
/***********************************************************************/
/* Parse connection string */
/* */
/* SYNOPSIS */
/* ParseURL() */
/* Url The connection string to parse */
/* */
/* DESCRIPTION */
/* This is used to set the Url in case a wrapper server as been */
/* specified. This is rather experimental yet. */
/* */
/* RETURN VALUE */
/* RC_OK Url was a true URL */
/* RC_NF Url was a server name/table */
/* RC_FX Error */
/* */
/***********************************************************************/
int
JDBCDEF
::
ParseURL
(
PGLOBAL
g
,
char
*
url
,
bool
b
)
{
if
(
strncmp
(
url
,
"jdbc:"
,
5
))
{
// No "jdbc:" in connection string. Must be a straight
// "server" or "server/table"
// ok, so we do a little parsing, but not completely!
if
((
Tabname
=
strchr
(
url
,
'/'
)))
{
// If there is a single '/' in the connection string,
// this means the user is specifying a table name
*
Tabname
++=
'\0'
;
// there better not be any more '/'s !
if
(
strchr
(
Tabname
,
'/'
))
return
RC_FX
;
}
else
if
(
b
)
{
// Otherwise, straight server name,
Tabname
=
GetStringCatInfo
(
g
,
"Name"
,
NULL
);
Tabname
=
GetStringCatInfo
(
g
,
"Tabname"
,
Tabname
);
}
// endelse
if
(
trace
)
htrc
(
"server: %s Tabname: %s"
,
url
,
Tabname
);
// Now make the required URL
FOREIGN_SERVER
*
server
,
server_buffer
;
// get_server_by_name() clones the server if exists
if
(
!
(
server
=
get_server_by_name
(
current_thd
->
mem_root
,
url
,
&
server_buffer
)))
{
sprintf
(
g
->
Message
,
"Server %s does not exist!"
,
url
);
return
RC_FX
;
}
// endif server
if
(
strncmp
(
server
->
host
,
"jdbc:"
,
5
))
{
// Now make the required URL
Url
=
(
PSZ
)
PlugSubAlloc
(
g
,
NULL
,
0
);
strcat
(
strcpy
(
Url
,
"jdbc:"
),
server
->
scheme
);
strcat
(
strcat
(
Url
,
"://"
),
server
->
host
);
if
(
server
->
port
)
{
char
buf
[
16
];
sprintf
(
buf
,
"%d"
,
server
->
port
);
strcat
(
strcat
(
Url
,
":"
),
buf
);
}
// endif port
if
(
server
->
db
)
strcat
(
strcat
(
Url
,
"/"
),
server
->
db
);
PlugSubAlloc
(
g
,
NULL
,
strlen
(
Url
)
+
1
);
}
else
// host is a URL
Url
=
PlugDup
(
g
,
server
->
host
);
if
(
server
->
username
)
Username
=
PlugDup
(
g
,
server
->
username
);
if
(
server
->
password
)
Password
=
PlugDup
(
g
,
server
->
password
);
return
RC_NF
;
}
// endif
// Url was a JDBC URL, nothing to do
return
RC_OK
;
}
// end of ParseURL
/***********************************************************************/
/* DefineAM: define specific AM block values from JDBC file. */
/***********************************************************************/
bool
JDBCDEF
::
DefineAM
(
PGLOBAL
g
,
LPCSTR
am
,
int
poff
)
{
int
rc
=
RC_OK
;
Driver
=
GetStringCatInfo
(
g
,
"Driver"
,
NULL
);
Desc
=
Url
=
GetStringCatInfo
(
g
,
"Connect"
,
NULL
);
...
...
@@ -120,28 +217,33 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
}
// endif Connect
Tabname
=
GetStringCatInfo
(
g
,
"Name"
,
(
Catfunc
&
(
FNC_TABLE
|
FNC_COL
))
?
NULL
:
Name
);
Tabname
=
GetStringCatInfo
(
g
,
"Tabname"
,
Tabname
);
Tabschema
=
GetStringCatInfo
(
g
,
"Dbname"
,
NULL
);
Tabschema
=
GetStringCatInfo
(
g
,
"Schema"
,
Tabschema
);
Tabcat
=
GetStringCatInfo
(
g
,
"Qualifier"
,
NULL
);
Tabcat
=
GetStringCatInfo
(
g
,
"Catalog"
,
Tabcat
);
Tabtype
=
GetStringCatInfo
(
g
,
"Tabtype"
,
NULL
);
Username
=
GetStringCatInfo
(
g
,
"User"
,
NULL
);
Password
=
GetStringCatInfo
(
g
,
"Password"
,
NULL
);
if
(
Url
)
rc
=
ParseURL
(
g
,
Url
);
if
(
rc
==
RC_FX
)
// Error
return
true
;
else
if
(
rc
==
RC_OK
)
{
// Url was not a server name
Tabname
=
GetStringCatInfo
(
g
,
"Name"
,
(
Catfunc
&
(
FNC_TABLE
|
FNC_COL
))
?
NULL
:
Name
);
Tabname
=
GetStringCatInfo
(
g
,
"Tabname"
,
Tabname
);
Username
=
GetStringCatInfo
(
g
,
"User"
,
NULL
);
Password
=
GetStringCatInfo
(
g
,
"Password"
,
NULL
);
}
// endif rc
if
((
Srcdef
=
GetStringCatInfo
(
g
,
"Srcdef"
,
NULL
)))
Read_Only
=
true
;
Tabcat
=
GetStringCatInfo
(
g
,
"Qualifier"
,
NULL
);
Tabcat
=
GetStringCatInfo
(
g
,
"Catalog"
,
Tabcat
);
Tabschema
=
GetStringCatInfo
(
g
,
"Dbname"
,
NULL
);
Tabschema
=
GetStringCatInfo
(
g
,
"Schema"
,
Tabschema
);
Tabtype
=
GetStringCatInfo
(
g
,
"Tabtype"
,
NULL
);
Qrystr
=
GetStringCatInfo
(
g
,
"Query_String"
,
"?"
);
Sep
=
GetStringCatInfo
(
g
,
"Separator"
,
NULL
);
Xsrc
=
GetBoolCatInfo
(
"Execsrc"
,
FALSE
);
Maxerr
=
GetIntCatInfo
(
"Maxerr"
,
0
);
Maxres
=
GetIntCatInfo
(
"Maxres"
,
0
);
Quoted
=
GetIntCatInfo
(
"Quoted"
,
0
);
//Options = JDBConn::noJDBCDialog;
//Options = JDBConn::noJDBCDialog | JDBConn::useCursorLib;
//Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
//Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
Scrollable
=
GetBoolCatInfo
(
"Scrollable"
,
false
);
...
...
@@ -274,6 +376,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
Ncol
=
0
;
Nparm
=
0
;
Placed
=
false
;
Prepared
=
false
;
Werr
=
false
;
Rerr
=
false
;
Ops
.
Fsize
=
Ops
.
CheckSize
(
Rows
);
...
...
storage/connect/tabjdbc.h
View file @
c92f2606
...
...
@@ -7,6 +7,7 @@
/***********************************************************************/
#include "colblk.h"
#include "resource.h"
#include "jdbccat.h"
typedef
class
JDBCDEF
*
PJDBCDEF
;
typedef
class
TDBJDBC
*
PTDBJDBC
;
...
...
@@ -44,6 +45,8 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */
virtual
int
Indexable
(
void
)
{
return
2
;
}
virtual
bool
DefineAM
(
PGLOBAL
g
,
LPCSTR
am
,
int
poff
);
virtual
PTDB
GetTable
(
PGLOBAL
g
,
MODE
m
);
int
ParseURL
(
PGLOBAL
g
,
char
*
url
,
bool
b
=
true
);
bool
SetParms
(
PJPARM
sjp
);
protected:
// Members
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment