Skip to content

Commit 2f2797e

Browse files
committed
- JDBC tables can be connected via foreign server wrapper
Redesign the handling of errors and exceptions modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/jdbconn.h modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h
1 parent 7972a45 commit 2f2797e

File tree

5 files changed

+373
-297
lines changed

5 files changed

+373
-297
lines changed

storage/connect/ha_connect.cc

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
#undef OFFSET
120120

121121
#define NOPARSE
122+
#define NJDBC
122123
#if defined(UNIX)
123124
#include "osutil.h"
124125
#endif // UNIX
@@ -128,7 +129,7 @@
128129
#include "odbccat.h"
129130
#endif // ODBC_SUPPORT
130131
#if defined(JDBC_SUPPORT)
131-
#include "jdbccat.h"
132+
#include "tabjdbc.h"
132133
#include "jdbconn.h"
133134
#endif // JDBC_SUPPORT
134135
#include "xtable.h"
@@ -5224,7 +5225,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
52245225
#endif
52255226
#if defined(JDBC_SUPPORT)
52265227
driver= GetListOption(g, "Driver", topt->oplist, NULL);
5227-
url= GetListOption(g, "URL", topt->oplist, NULL);
5228+
// url= GetListOption(g, "URL", topt->oplist, NULL);
52285229
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
52295230
#endif // JDBC_SUPPORT
52305231
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
@@ -5325,18 +5326,31 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
53255326
case TAB_JDBC:
53265327
if (fnc & FNC_DRIVER) {
53275328
ok= true;
5328-
} else if (!url && !(url= strz(g, create_info->connect_string))) {
5329+
} else if (!(url= strz(g, create_info->connect_string))) {
53295330
strcpy(g->Message, "Missing URL");
53305331
} else {
5331-
// Store ODBC additional parameters
5332+
// Store JDBC additional parameters
5333+
int rc;
5334+
PJDBCDEF jdef= new(g) JDBCDEF();
5335+
5336+
jdef->SetName(create_info->alias);
53325337
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
53335338
sjp->Driver= driver;
5334-
sjp->Url= url;
5335-
sjp->User= (char*)user;
5336-
sjp->Pwd= (char*)pwd;
53375339
sjp->Fsize= 0;
53385340
sjp->Scrollable= false;
5339-
ok= true;
5341+
5342+
if ((rc = jdef->ParseURL(g, url, false)) == RC_OK) {
5343+
sjp->Url= url;
5344+
sjp->User= (char*)user;
5345+
sjp->Pwd= (char*)pwd;
5346+
ok= true;
5347+
} else if (rc == RC_NF) {
5348+
if (jdef->GetTabname())
5349+
tab= jdef->GetTabname();
5350+
5351+
ok= jdef->SetParms(sjp);
5352+
} // endif rc
5353+
53405354
} // endif's
53415355

53425356
supfnc |= (FNC_DRIVER | FNC_TABLE);
@@ -5775,12 +5789,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
57755789

57765790
switch (typ) {
57775791
case TYPE_DOUBLE:
5792+
case TYPE_DECIM:
57785793
// Some data sources do not count dec in length (prec)
57795794
prec += (dec + 2); // To be safe
57805795
break;
5781-
case TYPE_DECIM:
5782-
prec= len;
5783-
break;
57845796
default:
57855797
dec= 0;
57865798
} // endswitch typ

0 commit comments

Comments
 (0)