MCPcopy Create free account
hub / github.com/MariaDB/server / delayed_get_table

Function delayed_get_table

sql/sql_insert.cc:2832–2977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2830*/
2831
2832static
2833bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
2834 TABLE_LIST *table_list)
2835{
2836 int error;
2837 Delayed_insert *di;
2838 DBUG_ENTER("delayed_get_table");
2839
2840 /* Must be set in the parser */
2841 DBUG_ASSERT(table_list->db.str);
2842
2843 /* Find the thread which handles this table. */
2844 if (!(di= find_handler(thd, table_list)))
2845 {
2846 /*
2847 No match. Create a new thread to handle the table, but
2848 no more than max_insert_delayed_threads.
2849 */
2850 if (delayed_insert_threads >= thd->variables.max_insert_delayed_threads)
2851 DBUG_RETURN(0);
2852 THD_STAGE_INFO(thd, stage_creating_delayed_handler);
2853 mysql_mutex_lock(&LOCK_delayed_create);
2854 /*
2855 The first search above was done without LOCK_delayed_create.
2856 Another thread might have created the handler in between. Search again.
2857 */
2858 if (! (di= find_handler(thd, table_list)))
2859 {
2860 if (!(di= new Delayed_insert(thd->lex)))
2861 goto end_create;
2862
2863 /*
2864 Annotating delayed inserts is not supported.
2865 */
2866 di->thd.variables.binlog_annotate_row_events= 0;
2867
2868 di->thd.set_db(&table_list->db);
2869 di->thd.set_query(my_strndup(PSI_INSTRUMENT_ME,
2870 table_list->table_name.str,
2871 table_list->table_name.length,
2872 MYF(MY_WME | ME_FATAL)),
2873 table_list->table_name.length, system_charset_info);
2874 if (di->thd.db.str == NULL || di->thd.query() == NULL)
2875 {
2876 /* The error is reported */
2877 delete di;
2878 goto end_create;
2879 }
2880 di->table_list= *table_list; // Needed to open table
2881 /* Replace volatile strings with local copies */
2882 di->table_list.alias.str= di->table_list.table_name.str= di->thd.query();
2883 di->table_list.alias.length= di->table_list.table_name.length= di->thd.query_length();
2884 di->table_list.db= Lex_ident_db(di->thd.db);
2885 /*
2886 Nulify select_lex because, if the thread that spawned the current one
2887 disconnects, the select_lex will point to freed memory.
2888 */
2889 di->table_list.select_lex= NULL;

Callers 1

Calls 15

find_handlerFunction · 0.85
my_strndupFunction · 0.85
Lex_ident_dbClass · 0.85
init_mdl_requestsFunction · 0.85
my_errorFunction · 0.85
my_messageFunction · 0.85
query_lengthMethod · 0.80
sql_errnoMethod · 0.80
get_stmt_daMethod · 0.80
get_local_tableMethod · 0.80
set_dbMethod · 0.45
set_queryMethod · 0.45

Tested by

no test coverage detected