Commit 91ae1258 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-12471: BULK Command

BULK execution moved to a new command.
parent e813fe86
......@@ -12,7 +12,8 @@ enum enum_server_command
COM_UNIMPLEMENTED,
COM_RESET_CONNECTION,
COM_MDB_GAP_BEG,
COM_MDB_GAP_END=250,
COM_MDB_GAP_END=249,
COM_STMT_BULK_EXECUTE=250,
COM_SLAVE_WORKER=251,
COM_SLAVE_IO=252,
COM_SLAVE_SQL=253,
......
......@@ -115,7 +115,8 @@ enum enum_server_command
COM_RESET_CONNECTION,
/* don't forget to update const char *command_name[] in sql_parse.cc */
COM_MDB_GAP_BEG,
COM_MDB_GAP_END=250,
COM_MDB_GAP_END=249,
COM_STMT_BULK_EXECUTE=250,
COM_SLAVE_WORKER=251,
COM_SLAVE_IO=252,
COM_SLAVE_SQL=253,
......@@ -136,6 +137,13 @@ enum enum_indicator_type
STMT_INDICATOR_IGNORE
};
/*
bulk PS flags
*/
#define STMT_BULK_FLAG_CLIENT_SEND_TYPES 128
#define STMT_BULK_FLAG_INSERT_ID_REQUEST 64
/* sql type stored in .frm files for virtual fields */
#define MYSQL_TYPE_VIRTUAL 245
/*
......@@ -311,7 +319,8 @@ enum enum_indicator_type
CLIENT_SESSION_TRACK |\
CLIENT_DEPRECATE_EOF |\
CLIENT_CONNECT_ATTRS |\
MARIADB_CLIENT_COM_MULTI)
MARIADB_CLIENT_COM_MULTI |\
MARIADB_CLIENT_STMT_BULK_OPERATIONS)
/*
To be added later:
......
......@@ -1396,7 +1396,7 @@ performance-schema-max-rwlock-instances -1
performance-schema-max-socket-classes 10
performance-schema-max-socket-instances -1
performance-schema-max-stage-classes 150
performance-schema-max-statement-classes 187
performance-schema-max-statement-classes 188
performance-schema-max-table-handles -1
performance-schema-max-table-instances -1
performance-schema-max-thread-classes 50
......
......@@ -2867,9 +2867,9 @@ READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES
SESSION_VALUE NULL
GLOBAL_VALUE 187
GLOBAL_VALUE 188
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 187
DEFAULT_VALUE 188
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Maximum number of statement instruments.
......
......@@ -3063,9 +3063,9 @@ READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES
SESSION_VALUE NULL
GLOBAL_VALUE 187
GLOBAL_VALUE 188
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 187
DEFAULT_VALUE 188
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Maximum number of statement instruments.
......
......@@ -3347,7 +3347,7 @@ Item_param::Item_param(THD *thd, uint pos_in_query_arg):
state(NO_VALUE),
/* Don't pretend to be a literal unless value for this item is set. */
item_type(PARAM_ITEM),
indicators(0), indicator(STMT_INDICATOR_NONE),
indicator(STMT_INDICATOR_NONE),
set_param_func(default_set_param_func),
m_out_param_info(NULL),
/*
......
......@@ -2873,10 +2873,8 @@ class Item_param :public Item_basic_value,
};
/*
Used for bulk protocol. Indicates if we should expect
indicators byte before value of the parameter
Used for bulk protocol only.
*/
my_bool indicators;
enum enum_indicator_type indicator;
/*
......
......@@ -697,9 +697,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
bool using_bulk_insert= 0;
uint value_count;
ulong counter = 1;
ulong iteration= 0;
/* counter of iteration in bulk PS operation*/
ulonglong iteration= 0;
ulonglong id;
ulong bulk_iterations= bulk_parameters_iterations(thd);
COPY_INFO info;
TABLE *table= 0;
List_iterator_fast<List_item> its(values_list);
......@@ -767,7 +767,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
value_count= values->elements;
DBUG_ASSERT(bulk_iterations > 0);
if (mysql_prepare_insert(thd, table_list, table, fields, values,
update_fields, update_values, duplic, &unused_conds,
FALSE))
......@@ -939,6 +938,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
do
{
DBUG_PRINT("info", ("iteration %llu", iteration));
if (iteration && bulk_parameters_set(thd))
goto abort;
......@@ -1059,7 +1059,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
its.rewind();
iteration++;
} while (iteration < bulk_iterations);
} while (bulk_parameters_iterations(thd));
values_loop_end:
free_underlaid_joins(thd, &thd->lex->select_lex);
......@@ -1206,7 +1206,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
retval= thd->lex->explain->send_explain(thd);
goto abort;
}
if ((bulk_iterations * values_list.elements) == 1 && (!(thd->variables.option_bits & OPTION_WARNINGS) ||
if ((iteration * values_list.elements) == 1 && (!(thd->variables.option_bits & OPTION_WARNINGS) ||
!thd->cuted_fields))
{
my_ok(thd, info.copied + info.deleted +
......
......@@ -391,7 +391,7 @@ const LEX_STRING command_name[257]={
{ 0, 0 }, //247
{ 0, 0 }, //248
{ 0, 0 }, //249
{ 0, 0 }, //250
{ C_STRING_WITH_LEN("Bulk_execute") }, //250
{ C_STRING_WITH_LEN("Slave_worker") }, //251
{ C_STRING_WITH_LEN("Slave_IO") }, //252
{ C_STRING_WITH_LEN("Slave_SQL") }, //253
......@@ -1749,6 +1749,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
break;
}
case COM_STMT_BULK_EXECUTE:
{
mysqld_stmt_bulk_execute(thd, packet, packet_length);
break;
}
case COM_STMT_EXECUTE:
{
mysqld_stmt_execute(thd, packet, packet_length);
......
This diff is collapsed.
......@@ -72,6 +72,7 @@ class Reprepare_observer
void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length);
void mysqld_stmt_execute(THD *thd, char *packet, uint packet_length);
void mysqld_stmt_execute_bulk(THD *thd, char *packet, uint packet_length);
void mysqld_stmt_bulk_execute(THD *thd, char *packet, uint packet_length);
void mysqld_stmt_close(THD *thd, char *packet);
void mysql_sql_stmt_prepare(THD *thd);
......@@ -83,7 +84,7 @@ void mysqld_stmt_reset(THD *thd, char *packet);
void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length);
void reinit_stmt_before_use(THD *thd, LEX *lex);
ulong bulk_parameters_iterations(THD *thd);
my_bool bulk_parameters_iterations(THD *thd);
my_bool bulk_parameters_set(THD *thd);
/**
Execute a fragment of server code in an isolated context, so that
......
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