@brief Initialize a new THD for a connection in the embedded server @param client_flag Client capabilities which this thread supports @return pointer to the created THD object @todo This function copies code from several places in the server, including create_new_thread(), and prepare_new_connection_state(). This should be refactored to avoid code duplication. */
| 703 | be refactored to avoid code duplication. |
| 704 | */ |
| 705 | void *create_embedded_thd(ulong client_flag) |
| 706 | { |
| 707 | THD * thd= new THD(next_thread_id()); |
| 708 | |
| 709 | thd->thread_stack= (char*) &thd; |
| 710 | thd->store_globals(); |
| 711 | lex_start(thd); |
| 712 | |
| 713 | /* TODO - add init_connect command execution */ |
| 714 | |
| 715 | if (thd->variables.max_join_size == HA_POS_ERROR) |
| 716 | thd->variables.option_bits |= OPTION_BIG_SELECTS; |
| 717 | thd->mark_connection_idle(); |
| 718 | thd->set_time(); |
| 719 | thd->init_for_queries(); |
| 720 | thd->client_capabilities= client_flag | MARIADB_CLIENT_EXTENDED_METADATA; |
| 721 | thd->real_id= pthread_self(); |
| 722 | |
| 723 | thd->db= null_clex_str; |
| 724 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
| 725 | thd->security_ctx->db_access= DB_ACLS; |
| 726 | thd->security_ctx->master_access= ALL_KNOWN_ACL; |
| 727 | #endif |
| 728 | thd->cur_data= 0; |
| 729 | thd->first_data= 0; |
| 730 | thd->data_tail= &thd->first_data; |
| 731 | bzero((char*) &thd->net, sizeof(thd->net)); |
| 732 | server_threads.insert(thd); |
| 733 | thd->mysys_var= 0; |
| 734 | thd->reset_globals(); |
| 735 | return thd; |
| 736 | } |
| 737 | |
| 738 | |
| 739 | THD *embedded_get_current_thd() |
no test coverage detected