summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Ackerman <isaac.ackerman@mariadb.com>2020-02-20 22:04:07 +0000
committerSergei Petrunia <psergey@askmonty.org>2020-03-10 11:22:33 +0300
commit01f3976243931273a3bceb8cc87900f63f91f1a6 (patch)
tree05b9ea83107a51612e7b84604e56640085a007f6
parent2e76114cf911c3a36052da73f94d9c6e6cb4d820 (diff)
downloadmariadb-git-01f3976243931273a3bceb8cc87900f63f91f1a6.tar.gz
Track sysvars that change pushdown execution
-rw-r--r--storage/xpand/ha_xpand.cc6
-rw-r--r--storage/xpand/xpand_connection.cc59
-rw-r--r--storage/xpand/xpand_connection.h4
3 files changed, 61 insertions, 8 deletions
diff --git a/storage/xpand/ha_xpand.cc b/storage/xpand/ha_xpand.cc
index 3852bae1933..341f10acd18 100644
--- a/storage/xpand/ha_xpand.cc
+++ b/storage/xpand/ha_xpand.cc
@@ -253,7 +253,7 @@ xpand_connection *get_trx(THD *thd, int *error_code)
xpand_connection *trx;
if (!(trx = (xpand_connection *)thd_get_ha_data(thd, xpand_hton)))
{
- if (!(trx = new xpand_connection())) {
+ if (!(trx = new xpand_connection(thd))) {
*error_code = HA_ERR_OUT_OF_MEM;
return NULL;
}
@@ -1264,7 +1264,7 @@ static int xpand_discover_table_names(handlerton *hton, LEX_CSTRING *db,
MY_DIR *dir,
handlerton::discovered_list *result)
{
- xpand_connection *xpand_net = new xpand_connection();
+ xpand_connection *xpand_net = new xpand_connection(NULL);
int error_code = xpand_net->connect();
if (error_code)
goto err;
@@ -1278,7 +1278,7 @@ err:
int xpand_discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
{
- xpand_connection *xpand_net = new xpand_connection();
+ xpand_connection *xpand_net = new xpand_connection(NULL);
int error_code = xpand_net->connect();
if (error_code)
goto err;
diff --git a/storage/xpand/xpand_connection.cc b/storage/xpand/xpand_connection.cc
index 48c43237199..9e730042a7f 100644
--- a/storage/xpand/xpand_connection.cc
+++ b/storage/xpand/xpand_connection.cc
@@ -6,9 +6,15 @@ Copyright (c) 2019, MariaDB Corporation.
#include "xpand_connection.h"
#include <string>
-#include "errmsg.h"
#include "handler.h"
#include "table.h"
+#include "sql_class.h"
+#include "tztime.h"
+
+//#include "errmsg.h"
+//name conflicts on macro ER with sql_class.h
+#define CR_CONNECTION_ERROR 2002
+#define CR_CONN_HOST_ERROR 2003
extern int xpand_connect_timeout;
extern int xpand_read_timeout;
@@ -82,8 +88,8 @@ enum xpand_commands {
/****************************************************************************
** Class xpand_connection
****************************************************************************/
-xpand_connection::xpand_connection()
- : command_buffer(NULL), command_buffer_length(0), command_length(0),
+xpand_connection::xpand_connection(THD *parent_thd)
+ : session(parent_thd), command_buffer(NULL), command_buffer_length(0), command_length(0),
trans_state(XPAND_TRANS_NONE), trans_flags(XPAND_TRANS_NO_POST_FLAGS)
{
DBUG_ENTER("xpand_connection::xpand_connection");
@@ -198,6 +204,43 @@ int xpand_connection::connect()
DBUG_RETURN(0);
}
+int xpand_connection::add_status_vars()
+{
+ DBUG_ENTER("xpand_connection::add_status_vars");
+ assert(session);
+
+ int error_code = 0;
+ system_variables vars = session->variables;
+ if ((error_code = add_command_operand_uchar(1)))
+ DBUG_RETURN(error_code);
+ //sql mode
+ if ((error_code = add_command_operand_ulonglong(vars.sql_mode)))
+ DBUG_RETURN(error_code);
+ //auto increment state
+ if ((error_code = add_command_operand_ushort(vars.auto_increment_increment)))
+ DBUG_RETURN(error_code);
+ if ((error_code = add_command_operand_ushort(vars.auto_increment_offset)))
+ DBUG_RETURN(error_code);
+ //character set and collation
+ if ((error_code = add_command_operand_ushort(vars.character_set_client->number)))
+ DBUG_RETURN(error_code);
+ if ((error_code = add_command_operand_ushort(vars.collation_connection->number)))
+ DBUG_RETURN(error_code);
+ if ((error_code = add_command_operand_ushort(vars.collation_server->number)))
+ DBUG_RETURN(error_code);
+ //timezone and time names
+ String tzone; //convert to utf8
+ vars.time_zone->get_name()->print(&tzone, get_charset(33,0));
+ if ((error_code = add_command_operand_str((const uchar*)tzone.ptr(),tzone.length())))
+ DBUG_RETURN(error_code);
+ if ((error_code = add_command_operand_ushort(vars.lc_time_names->number)))
+ DBUG_RETURN(error_code);
+ //transaction isolation
+ if ((error_code = add_command_operand_uchar(vars.tx_isolation)))
+ DBUG_RETURN(error_code);
+ DBUG_RETURN(0);
+}
+
int xpand_connection::begin_command(uchar command)
{
if (trans_state == XPAND_TRANS_NONE)
@@ -211,6 +254,11 @@ int xpand_connection::begin_command(uchar command)
if ((error_code = add_command_operand_uchar(trans_state | trans_flags)))
return error_code;
+ if (trans_state & XPAND_TRANS_NEW_STMT ||
+ trans_state & XPAND_TRANS_REQUESTED)
+ if ((error_code = add_status_vars()))
+ return error_code;
+
return error_code;
}
@@ -620,7 +668,10 @@ public:
ulong packet_length = cli_safe_read(xpand_net);
if (packet_length == packet_error) {
*stmt_completed = TRUE;
- DBUG_RETURN(mysql_errno(xpand_net));
+ int error_code = mysql_errno(xpand_net);
+ my_printf_error(error_code, "Xpand error: %s", MYF(0),
+ mysql_error(xpand_net));
+ DBUG_RETURN(error_code);
}
unsigned char *pos = xpand_net->net.read_pos;
diff --git a/storage/xpand/xpand_connection.h b/storage/xpand/xpand_connection.h
index c07d8da5f5b..41b4ddec713 100644
--- a/storage/xpand/xpand_connection.h
+++ b/storage/xpand/xpand_connection.h
@@ -31,6 +31,7 @@ class xpand_connection_cursor;
class xpand_connection
{
private:
+ THD *session;
MYSQL xpand_net;
uchar *command_buffer;
size_t command_buffer_length;
@@ -41,7 +42,7 @@ private:
int allocate_cursor(MYSQL *xpand_net, ulong buffer_size,
xpand_connection_cursor **scan);
public:
- xpand_connection();
+ xpand_connection(THD *parent_thd);
~xpand_connection();
inline bool is_connected()
@@ -116,6 +117,7 @@ private:
int add_command_operand_vlstr(const uchar *str, size_t length);
int add_command_operand_lex_string(LEX_CSTRING str);
int add_command_operand_bitmap(MY_BITMAP *bitmap);
+ int add_status_vars();
int begin_command(uchar command);
int send_command();
int read_query_response();