| 144 | */ |
| 145 | |
| 146 | void udf_init() |
| 147 | { |
| 148 | udf_func *tmp; |
| 149 | TABLE_LIST tables; |
| 150 | READ_RECORD read_record_info; |
| 151 | TABLE *table; |
| 152 | int error; |
| 153 | DBUG_ENTER("ufd_init"); |
| 154 | |
| 155 | if (initialized || opt_noacl) |
| 156 | DBUG_VOID_RETURN; |
| 157 | |
| 158 | #ifdef HAVE_PSI_INTERFACE |
| 159 | init_udf_psi_keys(); |
| 160 | #endif |
| 161 | |
| 162 | mysql_rwlock_init(key_rwlock_THR_LOCK_udf, &THR_LOCK_udf); |
| 163 | |
| 164 | init_sql_alloc(key_memory_udf_mem, &mem, UDF_ALLOC_BLOCK_SIZE, 0, MYF(0)); |
| 165 | THD *new_thd = new THD(0); |
| 166 | if (!new_thd || |
| 167 | my_hash_init(key_memory_udf_mem, &udf_hash, |
| 168 | Lex_ident_routine::charset_info(), |
| 169 | 32,0,0,get_hash_key, NULL, 0)) |
| 170 | { |
| 171 | sql_print_error("Can't allocate memory for udf structures"); |
| 172 | my_hash_free(&udf_hash); |
| 173 | free_root(&mem,MYF(0)); |
| 174 | delete new_thd; |
| 175 | DBUG_VOID_RETURN; |
| 176 | } |
| 177 | initialized = 1; |
| 178 | new_thd->thread_stack= (void*) &new_thd; // Big stack |
| 179 | new_thd->store_globals(); |
| 180 | new_thd->set_query_inner((char*) STRING_WITH_LEN("intern:udf_init"), |
| 181 | default_charset_info); |
| 182 | new_thd->set_db(&MYSQL_SCHEMA_NAME); |
| 183 | |
| 184 | tables.init_one_table(&new_thd->db, &MYSQL_FUNC_NAME, 0, TL_READ); |
| 185 | |
| 186 | if (open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) |
| 187 | { |
| 188 | DBUG_PRINT("error",("Can't open udf table")); |
| 189 | sql_print_error("Can't open the mysql.func table. Please " |
| 190 | "run mysql_upgrade to create it."); |
| 191 | goto end; |
| 192 | } |
| 193 | |
| 194 | table= tables.table; |
| 195 | if (init_read_record(&read_record_info, new_thd, table, NULL, NULL, 1, 0, |
| 196 | FALSE)) |
| 197 | { |
| 198 | sql_print_error("Could not initialize init_read_record; udf's not " |
| 199 | "loaded"); |
| 200 | goto end; |
| 201 | } |
| 202 | |
| 203 | table->use_all_columns(); |
nothing calls this directly
no test coverage detected