Commit f71f471e authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-27595 Backport SQL service, introduced by MDEV-19275.

  Fixes to make SQL SERVICE working.

Conflicts:
	storage/spider/spd_table.cc
parent 1fa196a5
...@@ -5402,6 +5402,7 @@ class Protocol_local : public Protocol_text ...@@ -5402,6 +5402,7 @@ class Protocol_local : public Protocol_text
MEM_ROOT *alloc; MEM_ROOT *alloc;
THD *new_thd; THD *new_thd;
Security_context empty_ctx; Security_context empty_ctx;
ulonglong client_capabilities;
Protocol_local(THD *thd_arg, THD *new_thd_arg, ulong prealloc) : Protocol_local(THD *thd_arg, THD *new_thd_arg, ulong prealloc) :
Protocol_text(thd_arg, prealloc), Protocol_text(thd_arg, prealloc),
...@@ -6023,12 +6024,15 @@ loc_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -6023,12 +6024,15 @@ loc_advanced_command(MYSQL *mysql, enum enum_server_command command,
{ {
Ed_connection con(p->thd); Ed_connection con(p->thd);
Security_context *ctx_orig= p->thd->security_ctx; Security_context *ctx_orig= p->thd->security_ctx;
ulonglong cap_orig= p->thd->client_capabilities;
MYSQL_LEX_STRING sql_text; MYSQL_LEX_STRING sql_text;
DBUG_ASSERT(current_thd == p->thd); DBUG_ASSERT(current_thd == p->thd);
sql_text.str= (char *) arg; sql_text.str= (char *) arg;
sql_text.length= arg_length; sql_text.length= arg_length;
p->thd->security_ctx= &p->empty_ctx; p->thd->security_ctx= &p->empty_ctx;
p->thd->client_capabilities= p->client_capabilities;
result= con.execute_direct(p, sql_text); result= con.execute_direct(p, sql_text);
p->thd->client_capabilities= cap_orig;
p->thd->security_ctx= ctx_orig; p->thd->security_ctx= ctx_orig;
} }
if (skip_check) if (skip_check)
...@@ -6153,6 +6157,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql) ...@@ -6153,6 +6157,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql)
THD *thd_orig= current_thd; THD *thd_orig= current_thd;
THD *new_thd; THD *new_thd;
Protocol_local *p; Protocol_local *p;
ulonglong client_flag;
DBUG_ENTER("mysql_real_connect_local"); DBUG_ENTER("mysql_real_connect_local");
/* Test whether we're already connected */ /* Test whether we're already connected */
...@@ -6164,6 +6169,9 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql) ...@@ -6164,6 +6169,9 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql)
mysql->methods= &local_methods; mysql->methods= &local_methods;
mysql->user= NULL; mysql->user= NULL;
client_flag= mysql->options.client_flag;
client_flag|= CLIENT_MULTI_RESULTS;;
client_flag&= ~(CLIENT_COMPRESS | CLIENT_PLUGIN_AUTH);
mysql->info_buffer= (char *) my_malloc(MYSQL_ERRMSG_SIZE, MYF(0)); mysql->info_buffer= (char *) my_malloc(MYSQL_ERRMSG_SIZE, MYF(0));
if (!thd_orig || thd_orig->lock) if (!thd_orig || thd_orig->lock)
...@@ -6184,6 +6192,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql) ...@@ -6184,6 +6192,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql)
new_thd->security_ctx->skip_grants(); new_thd->security_ctx->skip_grants();
new_thd->query_cache_is_applicable= 0; new_thd->query_cache_is_applicable= 0;
new_thd->variables.wsrep_on= 0; new_thd->variables.wsrep_on= 0;
new_thd->client_capabilities= client_flag;
/* /*
TOSO: decide if we should turn the auditing off TOSO: decide if we should turn the auditing off
for such threads. for such threads.
...@@ -6204,6 +6213,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql) ...@@ -6204,6 +6213,7 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql)
{ {
p->empty_ctx.init(); p->empty_ctx.init();
p->empty_ctx.skip_grants(); p->empty_ctx.skip_grants();
p->client_capabilities= client_flag;
} }
mysql->thd= p; mysql->thd= p;
......
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