Commit fd1b7d0f authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-9058: protocol: COM_MULTI command (part 2)

simple COM_MULTI support (no prepared statements chain yet).
parent e5377457
...@@ -235,6 +235,8 @@ enum enum_server_command ...@@ -235,6 +235,8 @@ enum enum_server_command
#define MARIADB_CLIENT_FLAGS_MASK 0xffffffff00000000ULL #define MARIADB_CLIENT_FLAGS_MASK 0xffffffff00000000ULL
/* Client support progress indicator */ /* Client support progress indicator */
#define MARIADB_CLIENT_PROGRESS (1ULL << 32) #define MARIADB_CLIENT_PROGRESS (1ULL << 32)
/* support COM_MULTI */
#define MARIADB_CLIENT_COM_MULTI (1ULL << 33)
#ifdef HAVE_COMPRESS #ifdef HAVE_COMPRESS
#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
...@@ -271,7 +273,8 @@ enum enum_server_command ...@@ -271,7 +273,8 @@ enum enum_server_command
MARIADB_CLIENT_PROGRESS | \ MARIADB_CLIENT_PROGRESS | \
CLIENT_PLUGIN_AUTH | \ CLIENT_PLUGIN_AUTH | \
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \ CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
CLIENT_CONNECT_ATTRS) CLIENT_CONNECT_ATTRS |\
MARIADB_CLIENT_COM_MULTI)
/* /*
To be added later: To be added later:
......
...@@ -165,7 +165,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -165,7 +165,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
arg_length= header_length; arg_length= header_length;
} }
result= dispatch_command(command, thd, (char *) arg, arg_length); result= dispatch_command(command, thd, (char *) arg, arg_length, FALSE);
thd->cur_data= 0; thd->cur_data= 0;
thd->mysys_var= NULL; thd->mysys_var= NULL;
......
...@@ -4429,7 +4429,8 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, ...@@ -4429,7 +4429,8 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
thd->m_digest->reset(thd->m_token_array, max_digest_length); thd->m_digest->reset(thd->m_token_array, max_digest_length);
thd->enable_slow_log= thd->variables.sql_log_slow; thd->enable_slow_log= thd->variables.sql_log_slow;
mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); mysql_parse(thd, thd->query(), thd->query_length(), &parser_state,
FALSE);
/* Finalize server status flags after executing a statement. */ /* Finalize server status flags after executing a statement. */
thd->update_server_status(); thd->update_server_status();
log_slow_statement(thd); log_slow_statement(thd);
......
...@@ -121,6 +121,8 @@ extern my_bool thd_net_is_killed(); ...@@ -121,6 +121,8 @@ extern my_bool thd_net_is_killed();
static my_bool net_write_buff(NET *, const uchar *, ulong); static my_bool net_write_buff(NET *, const uchar *, ulong);
my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags);
/** Init with packet info. */ /** Init with packet info. */
my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags)
...@@ -129,14 +131,12 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) ...@@ -129,14 +131,12 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags)
DBUG_PRINT("enter", ("my_flags: %u", my_flags)); DBUG_PRINT("enter", ("my_flags: %u", my_flags));
net->vio = vio; net->vio = vio;
my_net_local_init(net); /* Set some limits */ my_net_local_init(net); /* Set some limits */
if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+
NET_HEADER_SIZE + COMP_HEADER_SIZE +1, if (net_allocate_new_packet(net, thd, my_flags))
MYF(MY_WME | my_flags))))
DBUG_RETURN(1); DBUG_RETURN(1);
net->buff_end=net->buff+net->max_packet;
net->error=0; net->return_status=0; net->error=0; net->return_status=0;
net->pkt_nr=net->compress_pkt_nr=0; net->pkt_nr=net->compress_pkt_nr=0;
net->write_pos=net->read_pos = net->buff;
net->last_error[0]=0; net->last_error[0]=0;
net->compress=0; net->reading_or_writing=0; net->compress=0; net->reading_or_writing=0;
net->where_b = net->remain_in_buf=0; net->where_b = net->remain_in_buf=0;
...@@ -165,6 +165,18 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) ...@@ -165,6 +165,18 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags)
{
DBUG_ENTER("net_allocate_new_packet");
if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+
NET_HEADER_SIZE + COMP_HEADER_SIZE +1,
MYF(MY_WME | my_flags))))
DBUG_RETURN(1);
net->buff_end=net->buff+net->max_packet;
net->write_pos=net->read_pos = net->buff;
DBUG_RETURN(0);
}
void net_end(NET *net) void net_end(NET *net)
{ {
......
...@@ -7139,3 +7139,10 @@ ER_KILL_QUERY_DENIED_ERROR ...@@ -7139,3 +7139,10 @@ ER_KILL_QUERY_DENIED_ERROR
ER_NO_EIS_FOR_FIELD ER_NO_EIS_FOR_FIELD
eng "Engine-independent statistics are not collected for column '%s'" eng "Engine-independent statistics are not collected for column '%s'"
ukr "Незалежна від типу таблиці статистика не збирається для стовбця '%s'" ukr "Незалежна від типу таблиці статистика не збирається для стовбця '%s'"
ER_COMMULTI_BADCONTEXT 0A000
eng "COM_MULTI can't return a result set in the given context"
ger "COM_MULTI kann im gegebenen Kontext keine Ergebnismenge zurückgeben"
ukr "COM_MULTI не може повернути результати у цьому контексті"
ER_BAD_COMMAND_IN_MULTI
eng "Command '%s' is not allowed for COM_MULTI"
ukr "Команда '%s' не дозволена для COM_MULTI"
...@@ -5365,6 +5365,10 @@ class select_dumpvar :public select_result_interceptor { ...@@ -5365,6 +5365,10 @@ class select_dumpvar :public select_result_interceptor {
Do not check that wsrep snapshot is ready before allowing this command Do not check that wsrep snapshot is ready before allowing this command
*/ */
#define CF_SKIP_WSREP_CHECK (1U << 2) #define CF_SKIP_WSREP_CHECK (1U << 2)
/**
Do not allow it for COM_MULTI batch
*/
#define CF_NO_COM_MULTI (1U << 3)
/* Inline functions */ /* Inline functions */
......
This diff is collapsed.
...@@ -35,6 +35,7 @@ enum enum_mysql_completiontype { ...@@ -35,6 +35,7 @@ enum enum_mysql_completiontype {
extern "C" int test_if_data_home_dir(const char *dir); extern "C" int test_if_data_home_dir(const char *dir);
int error_if_data_home_dir(const char *path, const char *what); int error_if_data_home_dir(const char *path, const char *what);
my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags);
bool multi_update_precheck(THD *thd, TABLE_LIST *tables); bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
bool multi_delete_precheck(THD *thd, TABLE_LIST *tables); bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
...@@ -87,7 +88,7 @@ bool is_log_table_write_query(enum enum_sql_command command); ...@@ -87,7 +88,7 @@ bool is_log_table_write_query(enum enum_sql_command command);
bool alloc_query(THD *thd, const char *packet, uint packet_length); bool alloc_query(THD *thd, const char *packet, uint packet_length);
void mysql_init_select(LEX *lex); void mysql_init_select(LEX *lex);
void mysql_parse(THD *thd, char *rawbuf, uint length, void mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state); Parser_state *parser_state, bool is_com_multi);
bool mysql_new_select(LEX *lex, bool move_down); bool mysql_new_select(LEX *lex, bool move_down);
void create_select_for_variable(const char *var_name); void create_select_for_variable(const char *var_name);
void create_table_set_open_action_and_adjust_tables(LEX *lex); void create_table_set_open_action_and_adjust_tables(LEX *lex);
...@@ -99,7 +100,8 @@ int mysql_execute_command(THD *thd); ...@@ -99,7 +100,8 @@ int mysql_execute_command(THD *thd);
bool do_command(THD *thd); bool do_command(THD *thd);
void do_handle_bootstrap(THD *thd); void do_handle_bootstrap(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length); char* packet, uint packet_length,
bool is_com_multi, bool is_next_command);
void log_slow_statement(THD *thd); void log_slow_statement(THD *thd);
bool append_file_to_dir(THD *thd, const char **filename_ptr, bool append_file_to_dir(THD *thd, const char **filename_ptr,
const char *table_name); const char *table_name);
......
...@@ -907,7 +907,7 @@ static int run_sql_command(THD *thd, const char *query) ...@@ -907,7 +907,7 @@ static int run_sql_command(THD *thd, const char *query)
return -1; return -1;
} }
mysql_parse(thd, thd->query(), thd->query_length(), &ps); mysql_parse(thd, thd->query(), thd->query_length(), &ps, FALSE);
if (thd->is_error()) if (thd->is_error())
{ {
int const err= thd->get_stmt_da()->sql_errno(); int const err= thd->get_stmt_da()->sql_errno();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment