Skip to content

Commit

Permalink
Merge branch 'ob-10.1' into 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Buggynours committed Mar 14, 2018
2 parents c195e05 + 46defc4 commit a0f47c3
Show file tree
Hide file tree
Showing 15 changed files with 383 additions and 171 deletions.
27 changes: 22 additions & 5 deletions storage/connect/Client.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

package wrappers;

import java.io.BufferedReader;
import java.io.Console;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

public class Client {
static boolean DEBUG = true;
Expand Down Expand Up @@ -58,6 +62,9 @@ public static void main(String[] args) {
String query;
System.out.println("Successfully connected to " + parms[1]);

s = jdi.GetQuoteString();
System.out.println("Qstr = '" + s + "'");

while ((query = getLine("Query: ", false)) != null) {
n = jdi.Execute(query);
System.out.println("Returned n = " + n);
Expand All @@ -79,7 +86,11 @@ public static void main(String[] args) {
private static void PrintResult(int ncol) {
// Get result set meta data
int i;
Date date = new Date(0);
Time time = new Time(0);
Timestamp tsp = new Timestamp(0);
String columnName;
Object job;

// Get the column names; column indices start from 1
for (i = 1; i <= ncol; i++) {
Expand Down Expand Up @@ -112,6 +123,7 @@ private static void PrintResult(int ncol) {
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
case java.sql.Types.CHAR:
case 1111:
System.out.print(jdi.StringField(i, null));
break;
case java.sql.Types.INTEGER:
Expand All @@ -120,14 +132,17 @@ private static void PrintResult(int ncol) {
case java.sql.Types.BIGINT:
System.out.print(jdi.BigintField(i, null));
break;
case java.sql.Types.TIMESTAMP:
System.out.print(jdi.TimestampField(i, null));
break;
case java.sql.Types.TIME:
System.out.print(jdi.TimeField(i, null));
time.setTime((long)jdi.TimeField(i, null) * 1000);
System.out.print(time);
break;
case java.sql.Types.DATE:
System.out.print(jdi.DateField(i, null));
date.setTime((long)jdi.DateField(i, null) * 1000);
System.out.print(date);
break;
case java.sql.Types.TIMESTAMP:
tsp.setTime((long)jdi.TimestampField(i, null) * 1000);
System.out.print(tsp);
break;
case java.sql.Types.SMALLINT:
System.out.print(jdi.IntField(i, null));
Expand All @@ -141,6 +156,8 @@ private static void PrintResult(int ncol) {
case java.sql.Types.BOOLEAN:
System.out.print(jdi.BooleanField(i, null));
default:
job = jdi.ObjectField(i, null);
System.out.print(job.toString());
break;
} // endswitch Type

Expand Down
Binary file modified storage/connect/JavaWrappers.jar
Binary file not shown.
54 changes: 51 additions & 3 deletions storage/connect/JdbcInterface.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package wrappers;

import java.math.*;
import java.sql.*;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Date;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.UUID;

import javax.sql.DataSource;

Expand Down Expand Up @@ -223,6 +235,24 @@ public void SetTimestampParm(int i, Timestamp t) {

} // end of SetTimestampParm

public void SetUuidParm(int i, String s) {
try {
UUID uuid;

if (s == null)
uuid = null;
else if (s.isEmpty())
uuid = UUID.randomUUID();
else
uuid = UUID.fromString(s);

pstmt.setObject(i, uuid);
} catch (Exception e) {
SetErrmsg(e);
} // end try/catch

} // end of SetUuidParm

public int SetNullParm(int i, int typ) {
int rc = 0;

Expand Down Expand Up @@ -481,6 +511,8 @@ public int ExecuteQuery(String query) {
System.out.println("Executing query '" + query + "'");

try {
if (rs != null)
rs.close();
rs = stmt.executeQuery(query);
rsmd = rs.getMetaData();
ncol = rsmd.getColumnCount();
Expand Down Expand Up @@ -708,7 +740,7 @@ public int TimestampField(int n, String name) {
return 0;
} // end of TimestampField

public Object ObjectField(int n, String name) {
public Object ObjectField(int n, String name) {
if (rs == null) {
System.out.println("No result set");
} else try {
Expand All @@ -720,6 +752,22 @@ public Object ObjectField(int n, String name) {
return null;
} // end of ObjectField

public String UuidField(int n, String name) {
Object job;

if (rs == null) {
System.out.println("No result set");
} else
try {
job = (n > 0) ? rs.getObject(n) : rs.getObject(name);
return job.toString();
} catch (SQLException se) {
SetErrmsg(se);
} // end try/catch

return null;
} // end of UuidField

public int GetDrivers(String[] s, int mxs) {
int n = 0;
List<Driver> drivers = Collections.list(DriverManager.getDrivers());
Expand Down
5 changes: 3 additions & 2 deletions storage/connect/PostgresqlInterface.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package wrappers;

import java.sql.*;
import java.sql.SQLException;
import java.util.Hashtable;

import javax.sql.DataSource;

import org.postgresql.jdbc2.optional.PoolingDataSource;

public class PostgresqlInterface extends JdbcInterface {
Expand All @@ -19,7 +20,7 @@ public PostgresqlInterface(boolean b) {

} // end of constructor

@Override
@Override
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
String url = parms[1];
Expand Down
6 changes: 5 additions & 1 deletion storage/connect/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
DllExport bool AllocSarea(PGLOBAL, uint);
DllExport void FreeSarea(PGLOBAL);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
DllExport char *PlugDup(PGLOBAL g, const char *str);
DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...);
Expand All @@ -231,4 +230,9 @@ DllExport uint GetTraceValue(void);
} // extern "C"
#endif

/***********************************************************************/
/* Non exported routine declarations. */
/***********************************************************************/
void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw

/*-------------------------- End of Global.H --------------------------*/
21 changes: 14 additions & 7 deletions storage/connect/ha_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@
#define JSONMAX 10 // JSON Default max grp size

extern "C" {
char version[]= "Version 1.06.0006 February 02, 2018";
char version[]= "Version 1.06.0007 March 11, 2018";
#if defined(__WIN__)
char compver[]= "Version 1.06.0006 " __DATE__ " " __TIME__;
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
char slash= '\\';
#else // !__WIN__
char slash= '/';
Expand Down Expand Up @@ -288,11 +288,16 @@ static MYSQL_THDVAR_SET(
0, // def (NO)
&xtrace_typelib); // typelib

// Getting exact info values
// Getting exact info values
static MYSQL_THDVAR_BOOL(exact_info, PLUGIN_VAR_RQCMDARG,
"Getting exact info values",
NULL, NULL, 0);

// Enabling cond_push
static MYSQL_THDVAR_BOOL(cond_push, PLUGIN_VAR_RQCMDARG,
"Enabling cond_push",
NULL, NULL, 1); // YES by default

/**
Temporary file usage:
no: Not using temporary file
Expand Down Expand Up @@ -427,6 +432,7 @@ handlerton *connect_hton= NULL;
uint GetTraceValue(void)
{return (uint)(connect_hton ? THDVAR(current_thd, xtrace) : 0);}
bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
bool CondPushEnabled(void) {return THDVAR(current_thd, cond_push);}
USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);}
int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);}
Expand Down Expand Up @@ -3196,7 +3202,7 @@ const COND *ha_connect::cond_push(const COND *cond)
{
DBUG_ENTER("ha_connect::cond_push");

if (tdbp) {
if (tdbp && CondPushEnabled()) {
PGLOBAL& g= xp->g;
AMT tty= tdbp->GetAmType();
bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
Expand Down Expand Up @@ -7243,7 +7249,8 @@ static struct st_mysql_sys_var* connect_system_variables[]= {
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
MYSQL_SYSVAR(enable_mongo),
#endif // JAVA_SUPPORT || CMGO_SUPPORT
NULL
MYSQL_SYSVAR(cond_push),
NULL
};

maria_declare_plugin(connect)
Expand All @@ -7256,10 +7263,10 @@ maria_declare_plugin(connect)
PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */
0x0106, /* version number (1.05) */
0x0107, /* version number (1.05) */
NULL, /* status variables */
connect_system_variables, /* system variables */
"1.06.0006", /* string version */
"1.06.0007", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
}
maria_declare_plugin_end;
Loading

0 comments on commit a0f47c3

Please sign in to comment.