@@ -119,6 +119,7 @@ static my_bool opt_mark_progress= 0;
119119static my_bool ps_protocol= 0 , ps_protocol_enabled= 0 ;
120120static my_bool sp_protocol= 0 , sp_protocol_enabled= 0 ;
121121static my_bool view_protocol= 0 , view_protocol_enabled= 0 ;
122+ static my_bool service_connection_enabled= 1 ;
122123static my_bool cursor_protocol= 0 , cursor_protocol_enabled= 0 ;
123124static my_bool parsing_disabled= 0 ;
124125static my_bool display_result_vertically= FALSE , display_result_lower= FALSE ,
@@ -157,6 +158,7 @@ static struct property prop_list[] = {
157158 { &display_metadata, 0 , 0 , 0 , " $ENABLED_METADATA" },
158159 { &ps_protocol_enabled, 0 , 0 , 0 , " $ENABLED_PS_PROTOCOL" },
159160 { &view_protocol_enabled, 0 , 0 , 0 , " $ENABLED_VIEW_PROTOCOL" },
161+ { &service_connection_enabled, 0 , 1 , 0 , " $ENABLED_SERVICE_CONNECTION" },
160162 { &disable_query_log, 0 , 0 , 1 , " $ENABLED_QUERY_LOG" },
161163 { &disable_result_log, 0 , 0 , 1 , " $ENABLED_RESULT_LOG" },
162164 { &disable_warnings, 0 , 0 , 1 , " $ENABLED_WARNINGS" }
@@ -172,6 +174,7 @@ enum enum_prop {
172174 P_META,
173175 P_PS,
174176 P_VIEW,
177+ P_CONN,
175178 P_QUERY,
176179 P_RESULT,
177180 P_WARN,
@@ -379,6 +382,7 @@ enum enum_commands {
379382 Q_START_TIMER, Q_END_TIMER,
380383 Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
381384 Q_DISABLE_VIEW_PROTOCOL, Q_ENABLE_VIEW_PROTOCOL,
385+ Q_DISABLE_SERVICE_CONNECTION, Q_ENABLE_SERVICE_CONNECTION,
382386 Q_ENABLE_NON_BLOCKING_API, Q_DISABLE_NON_BLOCKING_API,
383387 Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
384388 Q_IF,
@@ -472,6 +476,8 @@ const char *command_names[]=
472476 " enable_ps_protocol" ,
473477 " disable_view_protocol" ,
474478 " enable_view_protocol" ,
479+ " disable_service_connection" ,
480+ " enable_service_connection" ,
475481 " enable_non_blocking_api" ,
476482 " disable_non_blocking_api" ,
477483 " disable_reconnect" ,
@@ -8978,25 +8984,30 @@ int util_query(MYSQL* org_mysql, const char* query){
89788984 MYSQL* mysql;
89798985 DBUG_ENTER (" util_query" );
89808986
8981- if (!(mysql= cur_con-> util_mysql ) )
8987+ if (service_connection_enabled )
89828988 {
8983- DBUG_PRINT (" info" , (" Creating util_mysql" ));
8984- if (!(mysql= mysql_init (mysql)))
8985- die (" Failed in mysql_init()" );
8989+ if (!(mysql= cur_con->util_mysql ))
8990+ {
8991+ DBUG_PRINT (" info" , (" Creating util_mysql" ));
8992+ if (!(mysql= mysql_init (mysql)))
8993+ die (" Failed in mysql_init()" );
89868994
8987- if (opt_connect_timeout)
8988- mysql_options (mysql, MYSQL_OPT_CONNECT_TIMEOUT,
8989- (void *) &opt_connect_timeout);
8995+ if (opt_connect_timeout)
8996+ mysql_options (mysql, MYSQL_OPT_CONNECT_TIMEOUT,
8997+ (void *) &opt_connect_timeout);
89908998
8991- /* enable local infile, in non-binary builds often disabled by default */
8992- mysql_options (mysql, MYSQL_OPT_LOCAL_INFILE, 0 );
8993- mysql_options (mysql, MYSQL_OPT_NONBLOCK, 0 );
8994- safe_connect (mysql, " util" , org_mysql->host , org_mysql->user ,
8995- org_mysql->passwd , org_mysql->db , org_mysql->port ,
8996- org_mysql->unix_socket );
8999+ /* enable local infile, in non-binary builds often disabled by default */
9000+ mysql_options (mysql, MYSQL_OPT_LOCAL_INFILE, 0 );
9001+ mysql_options (mysql, MYSQL_OPT_NONBLOCK, 0 );
9002+ safe_connect (mysql, " util" , org_mysql->host , org_mysql->user ,
9003+ org_mysql->passwd , org_mysql->db , org_mysql->port ,
9004+ org_mysql->unix_socket );
89979005
8998- cur_con->util_mysql = mysql;
9006+ cur_con->util_mysql = mysql;
9007+ }
89999008 }
9009+ else
9010+ mysql= org_mysql;
90009011
90019012 int ret= mysql_query (mysql, query);
90029013 DBUG_RETURN (ret);
@@ -9145,7 +9156,10 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
91459156 Collect warnings from create of the view that should otherwise
91469157 have been produced when the SELECT was executed
91479158 */
9148- append_warnings (&ds_warnings, cur_con->util_mysql );
9159+ append_warnings (&ds_warnings,
9160+ service_connection_enabled ?
9161+ cur_con->util_mysql :
9162+ mysql);
91499163 }
91509164
91519165 dynstr_free (&query_str);
@@ -10199,6 +10213,14 @@ int main(int argc, char **argv)
1019910213 case Q_ENABLE_VIEW_PROTOCOL:
1020010214 set_property (command, P_VIEW, view_protocol);
1020110215 break ;
10216+ case Q_DISABLE_SERVICE_CONNECTION:
10217+ set_property (command, P_CONN, 0 );
10218+ /* Close only util connections */
10219+ close_util_connections ();
10220+ break ;
10221+ case Q_ENABLE_SERVICE_CONNECTION:
10222+ set_property (command, P_CONN, view_protocol);
10223+ break ;
1020210224 case Q_DISABLE_NON_BLOCKING_API:
1020310225 non_blocking_api_enabled= 0 ;
1020410226 break ;
0 commit comments