Skip to content

Commit fd1b7d0

Browse files
committed
MDEV-9058: protocol: COM_MULTI command (part 2)
simple COM_MULTI support (no prepared statements chain yet).
1 parent e537745 commit fd1b7d0

File tree

9 files changed

+217
-40
lines changed

9 files changed

+217
-40
lines changed

include/mysql_com.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ enum enum_server_command
235235
#define MARIADB_CLIENT_FLAGS_MASK 0xffffffff00000000ULL
236236
/* Client support progress indicator */
237237
#define MARIADB_CLIENT_PROGRESS (1ULL << 32)
238+
/* support COM_MULTI */
239+
#define MARIADB_CLIENT_COM_MULTI (1ULL << 33)
238240

239241
#ifdef HAVE_COMPRESS
240242
#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
@@ -271,7 +273,8 @@ enum enum_server_command
271273
MARIADB_CLIENT_PROGRESS | \
272274
CLIENT_PLUGIN_AUTH | \
273275
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
274-
CLIENT_CONNECT_ATTRS)
276+
CLIENT_CONNECT_ATTRS |\
277+
MARIADB_CLIENT_COM_MULTI)
275278

276279
/*
277280
To be added later:

libmysqld/lib_sql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
165165
arg_length= header_length;
166166
}
167167

168-
result= dispatch_command(command, thd, (char *) arg, arg_length);
168+
result= dispatch_command(command, thd, (char *) arg, arg_length, FALSE);
169169
thd->cur_data= 0;
170170
thd->mysys_var= NULL;
171171

sql/log_event.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4429,7 +4429,8 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
44294429
thd->m_digest->reset(thd->m_token_array, max_digest_length);
44304430

44314431
thd->enable_slow_log= thd->variables.sql_log_slow;
4432-
mysql_parse(thd, thd->query(), thd->query_length(), &parser_state);
4432+
mysql_parse(thd, thd->query(), thd->query_length(), &parser_state,
4433+
FALSE);
44334434
/* Finalize server status flags after executing a statement. */
44344435
thd->update_server_status();
44354436
log_slow_statement(thd);

sql/net_serv.cc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ extern my_bool thd_net_is_killed();
121121

122122
static my_bool net_write_buff(NET *, const uchar *, ulong);
123123

124+
my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags);
125+
124126
/** Init with packet info. */
125127

126128
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)
129131
DBUG_PRINT("enter", ("my_flags: %u", my_flags));
130132
net->vio = vio;
131133
my_net_local_init(net); /* Set some limits */
132-
if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+
133-
NET_HEADER_SIZE + COMP_HEADER_SIZE +1,
134-
MYF(MY_WME | my_flags))))
134+
135+
if (net_allocate_new_packet(net, thd, my_flags))
135136
DBUG_RETURN(1);
136-
net->buff_end=net->buff+net->max_packet;
137+
137138
net->error=0; net->return_status=0;
138139
net->pkt_nr=net->compress_pkt_nr=0;
139-
net->write_pos=net->read_pos = net->buff;
140140
net->last_error[0]=0;
141141
net->compress=0; net->reading_or_writing=0;
142142
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)
165165
DBUG_RETURN(0);
166166
}
167167

168+
my_bool net_allocate_new_packet(NET *net, void *thd, uint my_flags)
169+
{
170+
DBUG_ENTER("net_allocate_new_packet");
171+
if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+
172+
NET_HEADER_SIZE + COMP_HEADER_SIZE +1,
173+
MYF(MY_WME | my_flags))))
174+
DBUG_RETURN(1);
175+
net->buff_end=net->buff+net->max_packet;
176+
net->write_pos=net->read_pos = net->buff;
177+
DBUG_RETURN(0);
178+
}
179+
168180

169181
void net_end(NET *net)
170182
{

sql/share/errmsg-utf8.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7139,3 +7139,10 @@ ER_KILL_QUERY_DENIED_ERROR
71397139
ER_NO_EIS_FOR_FIELD
71407140
eng "Engine-independent statistics are not collected for column '%s'"
71417141
ukr "Незалежна від типу таблиці статистика не збирається для стовбця '%s'"
7142+
ER_COMMULTI_BADCONTEXT 0A000
7143+
eng "COM_MULTI can't return a result set in the given context"
7144+
ger "COM_MULTI kann im gegebenen Kontext keine Ergebnismenge zurückgeben"
7145+
ukr "COM_MULTI не може повернути результати у цьому контексті"
7146+
ER_BAD_COMMAND_IN_MULTI
7147+
eng "Command '%s' is not allowed for COM_MULTI"
7148+
ukr "Команда '%s' не дозволена для COM_MULTI"

sql/sql_class.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5365,6 +5365,10 @@ class select_dumpvar :public select_result_interceptor {
53655365
Do not check that wsrep snapshot is ready before allowing this command
53665366
*/
53675367
#define CF_SKIP_WSREP_CHECK (1U << 2)
5368+
/**
5369+
Do not allow it for COM_MULTI batch
5370+
*/
5371+
#define CF_NO_COM_MULTI (1U << 3)
53685372

53695373
/* Inline functions */
53705374

0 commit comments

Comments
 (0)