Skip to content

Commit 55fb72d

Browse files
committed
- JdbcInterface: change return type of ...Field function
modified: storage/connect/JdbcInterface.java - Change Version number and date modified: storage/connect/ha_connect.cc - Implement the test on connect_type_conv YES/NO modified: storage/connect/jdbconn.cpp modified: storage/connect/odbconn.cpp - Fix MDEV-10520. Local schema was confused with remote schema modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabodbc.cpp - Fix crash when using mapped indices. Was trying to write in a mapped file declared as read only. modified: storage/connect/xindex.cpp
1 parent e4b1846 commit 55fb72d

File tree

7 files changed

+54
-33
lines changed

7 files changed

+54
-33
lines changed

storage/connect/JdbcInterface.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -641,40 +641,43 @@ public boolean BooleanField(int n, String name) {
641641
return false;
642642
} // end of BooleanField
643643

644-
public Date DateField(int n, String name) {
644+
public int DateField(int n, String name) {
645645
if (rs == null) {
646646
System.out.println("No result set");
647647
} else try {
648-
return (n > 0) ? rs.getDate(n) : rs.getDate(name);
648+
Date d = (n > 0) ? rs.getDate(n) : rs.getDate(name);
649+
return (d != null) ? (int)(d.getTime() / 1000) : 0;
649650
} catch (SQLException se) {
650651
SetErrmsg(se);
651652
} //end try/catch
652653

653-
return null;
654+
return 0;
654655
} // end of DateField
655656

656-
public Time TimeField(int n, String name) {
657+
public int TimeField(int n, String name) {
657658
if (rs == null) {
658659
System.out.println("No result set");
659660
} else try {
660-
return (n > 0) ? rs.getTime(n) : rs.getTime(name);
661+
Time t = (n > 0) ? rs.getTime(n) : rs.getTime(name);
662+
return (t != null) ? (int)(t.getTime() / 1000) : 0;
661663
} catch (SQLException se) {
662664
SetErrmsg(se);
663665
} //end try/catch
664666

665-
return null;
667+
return 0;
666668
} // end of TimeField
667669

668-
public Timestamp TimestampField(int n, String name) {
670+
public int TimestampField(int n, String name) {
669671
if (rs == null) {
670672
System.out.println("No result set");
671673
} else try {
672-
return (n > 0) ? rs.getTimestamp(n) : rs.getTimestamp(name);
674+
Timestamp ts = (n > 0) ? rs.getTimestamp(n) : rs.getTimestamp(name);
675+
return (ts != null) ? (int)(ts.getTime() / 1000) : 0;
673676
} catch (SQLException se) {
674677
SetErrmsg(se);
675678
} //end try/catch
676679

677-
return null;
680+
return 0;
678681
} // end of TimestampField
679682

680683
public String ObjectField(int n, String name) {

storage/connect/ha_connect.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@
171171
#define JSONMAX 10 // JSON Default max grp size
172172

173173
extern "C" {
174-
char version[]= "Version 1.04.0006 May 08, 2016";
174+
char version[]= "Version 1.04.0008 August 10, 2016";
175175
#if defined(__WIN__)
176-
char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__;
176+
char compver[]= "Version 1.04.0008 " __DATE__ " " __TIME__;
177177
char slash= '\\';
178178
#else // !__WIN__
179179
char slash= '/';
@@ -6935,7 +6935,7 @@ maria_declare_plugin(connect)
69356935
0x0104, /* version number (1.04) */
69366936
NULL, /* status variables */
69376937
connect_system_variables, /* system variables */
6938-
"1.04.0006", /* string version */
6938+
"1.04.0008", /* string version */
69396939
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
69406940
}
69416941
maria_declare_plugin_end;

storage/connect/jdbconn.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern "C" HINSTANCE s_hModule; // Saved module handle
5959
#define nullptr 0
6060
#endif // !__WIN__
6161

62+
TYPCONV GetTypeConv();
6263
int GetConvSize();
6364
extern char *JvmPath; // The connect_jvm_path global variable value
6465
extern char *ClassPath; // The connect_class_path global variable value
@@ -121,7 +122,10 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
121122

122123
switch (stp) {
123124
case -1: // LONGVARCHAR
124-
len = MY_MIN(abs(len), GetConvSize());
125+
if (GetTypeConv() != TPC_YES)
126+
return TYPE_ERROR;
127+
else
128+
len = MY_MIN(abs(len), GetConvSize());
125129
case 12: // VARCHAR
126130
v = 'V';
127131
case 1: // CHAR

storage/connect/odbconn.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
extern "C" HINSTANCE s_hModule; // Saved module handle
5454
#endif // __WIN__
5555

56+
TYPCONV GetTypeConv();
5657
int GetConvSize();
5758

5859
/***********************************************************************/
@@ -135,9 +136,13 @@ int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w)
135136
case SQL_WLONGVARCHAR: // (-10)
136137
w = true;
137138
case SQL_LONGVARCHAR: // (-1)
138-
v = 'V';
139-
type = TYPE_STRING;
140-
len = MY_MIN(abs(len), GetConvSize());
139+
if (GetTypeConv() == TPC_YES) {
140+
v = 'V';
141+
type = TYPE_STRING;
142+
len = MY_MIN(abs(len), GetConvSize());
143+
} else
144+
type = TYPE_ERROR;
145+
141146
break;
142147
case SQL_NUMERIC: // 2
143148
case SQL_DECIMAL: // 3

storage/connect/tabjdbc.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,10 @@ bool TDBJDBC::MakeSQL(PGLOBAL g, bool cnt)
522522
if (Catalog && *Catalog)
523523
catp = Catalog;
524524

525-
if (tablep->GetSchema())
526-
schmp = (char*)tablep->GetSchema();
527-
else if (Schema && *Schema)
525+
//if (tablep->GetSchema())
526+
// schmp = (char*)tablep->GetSchema();
527+
//else
528+
if (Schema && *Schema)
528529
schmp = Schema;
529530

530531
if (catp) {
@@ -606,9 +607,10 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
606607
if (catp)
607608
len += strlen(catp) + 1;
608609

609-
if (tablep->GetSchema())
610-
schmp = (char*)tablep->GetSchema();
611-
else if (Schema && *Schema)
610+
//if (tablep->GetSchema())
611+
// schmp = (char*)tablep->GetSchema();
612+
//else
613+
if (Schema && *Schema)
612614
schmp = Schema;
613615

614616
if (schmp)

storage/connect/tabodbc.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,14 @@ bool TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
458458
if (Catalog && *Catalog)
459459
catp = Catalog;
460460

461-
if (tablep->GetSchema())
462-
schmp = (char*)tablep->GetSchema();
463-
else if (Schema && *Schema)
461+
// Following lines are commented because of MSDEV-10520
462+
// Indeed the schema in the tablep is the local table database and
463+
// is normally not related to the remote table database.
464+
// TODO: Try to remember why this was done and if it was useful in some case.
465+
//if (tablep->GetSchema())
466+
// schmp = (char*)tablep->GetSchema();
467+
//else
468+
if (Schema && *Schema)
464469
schmp = Schema;
465470

466471
if (catp) {
@@ -541,9 +546,10 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
541546
if (catp)
542547
len += strlen(catp) + 1;
543548

544-
if (tablep->GetSchema())
545-
schmp = (char*)tablep->GetSchema();
546-
else if (Schema && *Schema)
549+
//if (tablep->GetSchema())
550+
// schmp = (char*)tablep->GetSchema();
551+
//else
552+
if (Schema && *Schema)
547553
schmp = Schema;
548554

549555
if (schmp)

storage/connect/xindex.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ bool XINDEX::MapInit(PGLOBAL g)
11981198
const char *ftype;
11991199
BYTE *mbase;
12001200
char fn[_MAX_PATH];
1201-
int *nv, k, n, id = -1;
1201+
int *nv, nv0, k, n, id = -1;
12021202
bool estim;
12031203
PCOL colp;
12041204
PXCOL prev = NULL, kcp = NULL;
@@ -1288,25 +1288,26 @@ bool XINDEX::MapInit(PGLOBAL g)
12881288
if (nv[0] >= MAX_INDX) {
12891289
// New index format
12901290
Srtd = nv[7] != 0;
1291-
nv[0] -= MAX_INDX;
1291+
nv0 = nv[0] - MAX_INDX;
12921292
mbase += NZ * sizeof(int);
12931293
} else {
12941294
Srtd = false;
12951295
mbase += (NZ - 1) * sizeof(int);
1296+
nv0 = nv[0];
12961297
} // endif nv
12971298

12981299
if (trace)
12991300
htrc("nv=%d %d %d %d %d %d %d %d\n",
1300-
nv[0], nv[1], nv[2], nv[3], nv[4], nv[5], nv[6], Srtd);
1301+
nv0, nv[1], nv[2], nv[3], nv[4], nv[5], nv[6], Srtd);
13011302

13021303
// The test on ID was suppressed because MariaDB can change an index ID
13031304
// when other indexes are added or deleted
1304-
if (/*nv[0] != ID ||*/ nv[1] != Nk) {
1305+
if (/*nv0 != ID ||*/ nv[1] != Nk) {
13051306
// Not this index
13061307
sprintf(g->Message, MSG(BAD_INDEX_FILE), fn);
13071308

13081309
if (trace)
1309-
htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk);
1310+
htrc("nv0=%d ID=%d nv[1]=%d Nk=%d\n", nv0, ID, nv[1], Nk);
13101311

13111312
goto err;
13121313
} // endif nv

0 commit comments

Comments
 (0)