The world's most popular open source database
#include <mysql/plugin.h>Include dependency graph for sql_plugin.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
| #define MYSQL_ANY_PLUGIN -1 |
Definition at line 32 of file sql_plugin.h.
Referenced by fill_plugins(), mysql_install_plugin(), mysql_uninstall_plugin(), plugin_add(), plugin_del(), plugin_find_internal(), and plugin_foreach().
| #define SHOW_FUNC |
Value:
SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \ SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \ SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH
Definition at line 24 of file sql_plugin.h.
Referenced by show_status_array().
| typedef my_bool( plugin_foreach_func)(THD *thd, st_plugin_int *plugin, void *arg) |
Definition at line 81 of file sql_plugin.h.
| typedef int(*) plugin_type_init(struct st_plugin_int *) |
Definition at line 65 of file sql_plugin.h.
| typedef enum enum_mysql_show_type SHOW_TYPE |
Definition at line 29 of file sql_plugin.h.
| typedef struct st_mysql_show_var SHOW_VAR |
Definition at line 30 of file sql_plugin.h.
| enum enum_plugin_state |
Definition at line 34 of file sql_plugin.h.
00035 { 00036 PLUGIN_IS_FREED= 0, 00037 PLUGIN_IS_DELETED, 00038 PLUGIN_IS_UNINITIALIZED, 00039 PLUGIN_IS_READY 00040 };
| my_bool mysql_install_plugin | ( | THD * | thd, | |
| const LEX_STRING * | name, | |||
| const LEX_STRING * | dl | |||
| ) |
Definition at line 814 of file sql_plugin.cc.
References bzero, check_table_access(), DBUG_ENTER, DBUG_RETURN, st_mysql_plugin::deinit, ER_CANT_INITIALIZE_UDF, err, error, FALSE, st_table::field, st_table::file, files_charset_info, handler::ha_write_row(), INSERT_ACL, LEX_STRING::length, my_error(), MYF, MYSQL_ANY_PLUGIN, name, open_ltable(), st_plugin_int::plugin, plugin_add(), plugin_del(), plugin_find_internal(), plugin_initialize(), PLUGIN_IS_READY, handler::print_error(), st_table::record, REPORT_TO_USER, restore_record, rw_unlock, rw_wrlock, st_plugin_int::state, Field::store(), LEX_STRING::str, system_charset_info, THR_LOCK_plugin, TL_WRITE, TRUE, and st_table::use_all_columns().
Referenced by mysql_execute_command().
00815 { 00816 TABLE_LIST tables; 00817 TABLE *table; 00818 int error; 00819 struct st_plugin_int *tmp; 00820 DBUG_ENTER("mysql_install_plugin"); 00821 00822 bzero(&tables, sizeof(tables)); 00823 tables.db= (char *)"mysql"; 00824 tables.table_name= tables.alias= (char *)"plugin"; 00825 if (check_table_access(thd, INSERT_ACL, &tables, 0)) 00826 DBUG_RETURN(TRUE); 00827 00828 /* need to open before acquiring THR_LOCK_plugin or it will deadlock */ 00829 if (! (table = open_ltable(thd, &tables, TL_WRITE))) 00830 DBUG_RETURN(TRUE); 00831 00832 rw_wrlock(&THR_LOCK_plugin); 00833 if (plugin_add(name, dl, REPORT_TO_USER)) 00834 goto err; 00835 tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN); 00836 00837 if (plugin_initialize(tmp)) 00838 { 00839 my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, 00840 "Plugin initialization function failed."); 00841 goto err; 00842 } 00843 00844 tmp->state= PLUGIN_IS_READY; 00845 00846 table->use_all_columns(); 00847 restore_record(table, s->default_values); 00848 table->field[0]->store(name->str, name->length, system_charset_info); 00849 table->field[1]->store(dl->str, dl->length, files_charset_info); 00850 error= table->file->ha_write_row(table->record[0]); 00851 if (error) 00852 { 00853 table->file->print_error(error, MYF(0)); 00854 goto deinit; 00855 } 00856 00857 rw_unlock(&THR_LOCK_plugin); 00858 DBUG_RETURN(FALSE); 00859 deinit: 00860 if (tmp->plugin->deinit) 00861 tmp->plugin->deinit(); 00862 err: 00863 plugin_del(name); 00864 rw_unlock(&THR_LOCK_plugin); 00865 DBUG_RETURN(TRUE); 00866 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool mysql_uninstall_plugin | ( | THD * | thd, | |
| const LEX_STRING * | name | |||
| ) |
Definition at line 869 of file sql_plugin.cc.
References bzero, DBUG_ENTER, DBUG_RETURN, ER_SP_DOES_NOT_EXIST, err, error, FALSE, st_table::field, st_table::file, handler::ha_delete_row(), HA_READ_KEY_EXACT, handler::index_read_idx(), st_table::key_info, st_key::key_length, my_error(), MYF, MYSQL_ANY_PLUGIN, name, open_ltable(), st_plugin_int::plugin, plugin_del(), plugin_finalize(), plugin_find_internal(), PLUGIN_IS_DELETED, handler::print_error(), Field::ptr, push_warning(), st_table::record, rw_unlock, rw_wrlock, Field::store(), system_charset_info, THR_LOCK_plugin, TL_WRITE, TRUE, st_table::use_all_columns(), and MYSQL_ERROR::WARN_LEVEL_WARN.
Referenced by mysql_execute_command().
00870 { 00871 TABLE *table; 00872 TABLE_LIST tables; 00873 struct st_plugin_int *plugin; 00874 DBUG_ENTER("mysql_uninstall_plugin"); 00875 00876 bzero(&tables, sizeof(tables)); 00877 tables.db= (char *)"mysql"; 00878 tables.table_name= tables.alias= (char *)"plugin"; 00879 00880 /* need to open before acquiring THR_LOCK_plugin or it will deadlock */ 00881 if (! (table= open_ltable(thd, &tables, TL_WRITE))) 00882 DBUG_RETURN(TRUE); 00883 00884 rw_wrlock(&THR_LOCK_plugin); 00885 if (!(plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) 00886 { 00887 my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str); 00888 goto err; 00889 } 00890 if (!plugin->plugin_dl) 00891 { 00892 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, 00893 "Built-in plugins cannot be deleted,."); 00894 my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str); 00895 goto err; 00896 } 00897 00898 if (!plugin_finalize(thd, plugin)) 00899 plugin_del(name); 00900 else 00901 plugin->state= PLUGIN_IS_DELETED; 00902 00903 table->use_all_columns(); 00904 table->field[0]->store(name->str, name->length, system_charset_info); 00905 if (! table->file->index_read_idx(table->record[0], 0, 00906 (byte *)table->field[0]->ptr, 00907 table->key_info[0].key_length, 00908 HA_READ_KEY_EXACT)) 00909 { 00910 int error; 00911 if ((error= table->file->ha_delete_row(table->record[0]))) 00912 { 00913 table->file->print_error(error, MYF(0)); 00914 goto err; 00915 } 00916 } 00917 rw_unlock(&THR_LOCK_plugin); 00918 DBUG_RETURN(FALSE); 00919 err: 00920 rw_unlock(&THR_LOCK_plugin); 00921 DBUG_RETURN(TRUE); 00922 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool plugin_foreach | ( | THD * | thd, | |
| plugin_foreach_func * | func, | |||
| int | type, | |||
| void * | arg | |||
| ) |
Definition at line 925 of file sql_plugin.cc.
References DBUG_ENTER, DBUG_RETURN, dynamic_element, st_dynamic_array::elements, err, FALSE, hash(), hash_element(), MYSQL_ANY_PLUGIN, st_plugin_int::plugin, plugin_array, plugin_hash, PLUGIN_IS_DELETED, PLUGIN_IS_FREED, rw_rdlock, rw_unlock, THR_LOCK_plugin, and TRUE.
Referenced by fill_plugins(), fill_schema_engines(), fill_schema_files(), ha_close_connection(), ha_commit_or_rollback_by_xid(), ha_drop_database(), ha_flush_logs(), ha_known_exts(), ha_panic(), ha_recover(), ha_release_temporary_latches(), ha_show_status(), ha_start_consistent_snapshot(), and mysqld_show_storage_engines().
00927 { 00928 uint idx; 00929 struct st_plugin_int *plugin; 00930 DBUG_ENTER("mysql_uninstall_plugin"); 00931 rw_rdlock(&THR_LOCK_plugin); 00932 00933 if (type == MYSQL_ANY_PLUGIN) 00934 { 00935 for (idx= 0; idx < plugin_array.elements; idx++) 00936 { 00937 plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); 00938 00939 /* FREED records may have garbage pointers */ 00940 if ((plugin->state != PLUGIN_IS_FREED) && 00941 func(thd, plugin, arg)) 00942 goto err; 00943 } 00944 } 00945 else 00946 { 00947 HASH *hash= &plugin_hash[type]; 00948 for (idx= 0; idx < hash->records; idx++) 00949 { 00950 plugin= (struct st_plugin_int *) hash_element(hash, idx); 00951 if ((plugin->state != PLUGIN_IS_FREED) && 00952 (plugin->state != PLUGIN_IS_DELETED) && 00953 func(thd, plugin, arg)) 00954 goto err; 00955 } 00956 } 00957 00958 rw_unlock(&THR_LOCK_plugin); 00959 DBUG_RETURN(FALSE); 00960 err: 00961 rw_unlock(&THR_LOCK_plugin); 00962 DBUG_RETURN(TRUE); 00963 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void plugin_free | ( | void | ) |
Definition at line 790 of file sql_plugin.cc.
References DBUG_ENTER, DBUG_VOID_RETURN, delete_dynamic(), dynamic_element, st_dynamic_array::elements, free_plugin_mem(), hash_free(), initialized, MYSQL_MAX_PLUGIN_TYPE_NUM, plugin_array, plugin_call_deinitializer(), plugin_dl_array, plugin_hash, rwlock_destroy, and THR_LOCK_plugin.
Referenced by clean_up().
00791 { 00792 uint i; 00793 DBUG_ENTER("plugin_free"); 00794 plugin_call_deinitializer(); 00795 for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) 00796 hash_free(&plugin_hash[i]); 00797 delete_dynamic(&plugin_array); 00798 for (i= 0; i < plugin_dl_array.elements; i++) 00799 { 00800 struct st_plugin_dl *tmp= dynamic_element(&plugin_dl_array, i, 00801 struct st_plugin_dl *); 00802 free_plugin_mem(tmp); 00803 } 00804 delete_dynamic(&plugin_dl_array); 00805 if (initialized) 00806 { 00807 initialized= 0; 00808 rwlock_destroy(&THR_LOCK_plugin); 00809 } 00810 DBUG_VOID_RETURN; 00811 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int plugin_init | ( | void | ) |
Definition at line 650 of file sql_plugin.cc.
References DBUG_ENTER, DBUG_RETURN, dynamic_element, st_dynamic_array::elements, err, get_hash_key(), hash_init, st_mysql_plugin::info, initialized, my_init_dynamic_array, my_rwlock_init, MYSQL_MAX_PLUGIN_TYPE_NUM, mysqld_builtins, NULL, plugin_array, plugin_dl_array, plugin_hash, plugin_initialize(), PLUGIN_IS_READY, plugin_register_builtin(), st_plugin_int::state, system_charset_info, and THR_LOCK_plugin.
Referenced by init_server_components().
00651 { 00652 int i; 00653 struct st_mysql_plugin **builtins; 00654 struct st_mysql_plugin *plugin; 00655 DBUG_ENTER("plugin_init"); 00656 00657 if (initialized) 00658 DBUG_RETURN(0); 00659 00660 my_rwlock_init(&THR_LOCK_plugin, NULL); 00661 00662 if (my_init_dynamic_array(&plugin_dl_array, 00663 sizeof(struct st_plugin_dl),16,16) || 00664 my_init_dynamic_array(&plugin_array, 00665 sizeof(struct st_plugin_int),16,16)) 00666 goto err; 00667 00668 for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) 00669 { 00670 if (hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0, 00671 get_hash_key, NULL, 0)) 00672 goto err; 00673 } 00674 00675 /* Register all the built-in plugins */ 00676 for (builtins= mysqld_builtins; *builtins; builtins++) 00677 { 00678 for (plugin= *builtins; plugin->info; plugin++) 00679 { 00680 if (plugin_register_builtin(plugin)) 00681 goto err; 00682 struct st_plugin_int *tmp=dynamic_element(&plugin_array, 00683 plugin_array.elements-1, 00684 struct st_plugin_int *); 00685 if (plugin_initialize(tmp)) 00686 goto err; 00687 tmp->state= PLUGIN_IS_READY; 00688 } 00689 } 00690 00691 initialized= 1; 00692 00693 DBUG_RETURN(0); 00694 00695 err: 00696 DBUG_RETURN(1); 00697 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool plugin_is_ready | ( | const LEX_STRING * | name, | |
| int | type | |||
| ) |
Definition at line 348 of file sql_plugin.cc.
References DBUG_ENTER, DBUG_RETURN, FALSE, name, st_plugin_int::plugin, plugin_find_internal(), PLUGIN_IS_READY, rw_rdlock, rw_unlock, THR_LOCK_plugin, and TRUE.
00349 { 00350 my_bool rc= FALSE; 00351 struct st_plugin_int *plugin; 00352 DBUG_ENTER("plugin_is_ready"); 00353 rw_rdlock(&THR_LOCK_plugin); 00354 if ((plugin= plugin_find_internal(name, type)) && 00355 plugin->state == PLUGIN_IS_READY) 00356 rc= TRUE; 00357 rw_unlock(&THR_LOCK_plugin); 00358 DBUG_RETURN(rc); 00359 }
Here is the call graph for this function:

| void plugin_load | ( | void | ) |
Definition at line 727 of file sql_plugin.cc.
References bzero, close_thread_tables(), st_table_list::db, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, end_read_record(), ER, ER_GET_ERRNO, error, st_table::field, free_root(), get_field(), init_read_record(), init_sql_alloc(), initialized, LEX_STRING::length, mem, my_errno, my_pthread_setspecific_ptr, my_strdup(), MYF, name, NULL, plugin_add(), plugin_call_initializer(), st_read_record::read_record, REPORT_TO_LOG, simple_open_n_lock_tables(), sql_print_error(), LEX_STRING::str, strlen(), TL_READ, and st_table::use_all_columns().
Referenced by main().
00728 { 00729 TABLE_LIST tables; 00730 TABLE *table; 00731 READ_RECORD read_record_info; 00732 int error, i; 00733 MEM_ROOT mem; 00734 THD *new_thd; 00735 DBUG_ENTER("plugin_load"); 00736 00737 DBUG_ASSERT(initialized); 00738 00739 if (!(new_thd= new THD)) 00740 { 00741 sql_print_error("Can't allocate memory for plugin structures"); 00742 delete new_thd; 00743 DBUG_VOID_RETURN; 00744 } 00745 init_sql_alloc(&mem, 1024, 0); 00746 new_thd->thread_stack= (char*) &tables; 00747 new_thd->store_globals(); 00748 new_thd->db= my_strdup("mysql", MYF(0)); 00749 new_thd->db_length= 5; 00750 bzero((gptr)&tables, sizeof(tables)); 00751 tables.alias= tables.table_name= (char*)"plugin"; 00752 tables.lock_type= TL_READ; 00753 tables.db= new_thd->db; 00754 if (simple_open_n_lock_tables(new_thd, &tables)) 00755 { 00756 DBUG_PRINT("error",("Can't open plugin table")); 00757 sql_print_error("Can't open the mysql.plugin table. Please run the mysql_upgrade script to create it."); 00758 goto end; 00759 } 00760 table= tables.table; 00761 init_read_record(&read_record_info, new_thd, table, NULL, 1, 0); 00762 table->use_all_columns(); 00763 while (!(error= read_record_info.read_record(&read_record_info))) 00764 { 00765 DBUG_PRINT("info", ("init plugin record")); 00766 LEX_STRING name, dl; 00767 name.str= get_field(&mem, table->field[0]); 00768 name.length= strlen(name.str); 00769 dl.str= get_field(&mem, table->field[1]); 00770 dl.length= strlen(dl.str); 00771 if (plugin_add(&name, &dl, REPORT_TO_LOG)) 00772 DBUG_PRINT("warning", ("Couldn't load plugin named '%s' with soname '%s'.", 00773 name.str, dl.str)); 00774 } 00775 plugin_call_initializer(); 00776 if (error > 0) 00777 sql_print_error(ER(ER_GET_ERRNO), my_errno); 00778 end_read_record(&read_record_info); 00779 new_thd->version--; // Force close to free memory 00780 end: 00781 free_root(&mem, MYF(0)); 00782 close_thread_tables(new_thd); 00783 delete new_thd; 00784 /* Remember that we don't have a THD */ 00785 my_pthread_setspecific_ptr(THR_THD, 0); 00786 DBUG_VOID_RETURN; 00787 }
Here is the call graph for this function:

Here is the caller graph for this function:

| st_plugin_int* plugin_lock | ( | const LEX_STRING * | name, | |
| int | type | |||
| ) |
Definition at line 362 of file sql_plugin.cc.
References DBUG_ENTER, DBUG_RETURN, name, plugin_find_internal(), PLUGIN_IS_READY, PLUGIN_IS_UNINITIALIZED, st_plugin_int::ref_count, rw_unlock, rw_wrlock, st_plugin_int::state, and THR_LOCK_plugin.
Referenced by ha_resolve_by_name(), and open_binary_frm().
00363 { 00364 struct st_plugin_int *rc; 00365 DBUG_ENTER("plugin_lock"); 00366 rw_wrlock(&THR_LOCK_plugin); 00367 if ((rc= plugin_find_internal(name, type))) 00368 { 00369 if (rc->state == PLUGIN_IS_READY || rc->state == PLUGIN_IS_UNINITIALIZED) 00370 rc->ref_count++; 00371 else 00372 rc= 0; 00373 } 00374 rw_unlock(&THR_LOCK_plugin); 00375 DBUG_RETURN(rc); 00376 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool plugin_register_builtin | ( | struct st_mysql_plugin * | plugin | ) |
Definition at line 700 of file sql_plugin.cc.
References DBUG_ENTER, DBUG_RETURN, dynamic_element, st_dynamic_array::elements, insert_dynamic(), LEX_STRING::length, my_hash_insert(), st_mysql_plugin::name, st_plugin_int::name, st_plugin_int::plugin, plugin_array, st_plugin_int::plugin_dl, plugin_hash, PLUGIN_IS_UNINITIALIZED, st_plugin_int::ref_count, st_plugin_int::state, LEX_STRING::str, strlen(), and st_mysql_plugin::type.
Referenced by plugin_init().
00701 { 00702 struct st_plugin_int tmp; 00703 DBUG_ENTER("plugin_register_builtin"); 00704 00705 tmp.plugin= plugin; 00706 tmp.name.str= (char *)plugin->name; 00707 tmp.name.length= strlen(plugin->name); 00708 tmp.state= PLUGIN_IS_UNINITIALIZED; 00709 00710 /* Cannot be unloaded */ 00711 tmp.ref_count= 1; 00712 tmp.plugin_dl= 0; 00713 00714 if (insert_dynamic(&plugin_array, (gptr)&tmp)) 00715 DBUG_RETURN(1); 00716 00717 if (my_hash_insert(&plugin_hash[plugin->type], 00718 (byte*)dynamic_element(&plugin_array, 00719 plugin_array.elements - 1, 00720 struct st_plugin_int *))) 00721 DBUG_RETURN(1); 00722 00723 DBUG_RETURN(0); 00724 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void plugin_unlock | ( | struct st_plugin_int * | plugin | ) |
Definition at line 505 of file sql_plugin.cc.
References DBUG_ASSERT, DBUG_ENTER, DBUG_VOID_RETURN, st_mysql_plugin::deinit, st_mysql_plugin::name, st_plugin_int::plugin, plugin_del(), PLUGIN_IS_DELETED, rw_unlock, rw_wrlock, and THR_LOCK_plugin.
Referenced by closefrm(), and ha_resolve_by_name().
00506 { 00507 DBUG_ENTER("plugin_unlock"); 00508 rw_wrlock(&THR_LOCK_plugin); 00509 DBUG_ASSERT(plugin && plugin->ref_count); 00510 plugin->ref_count--; 00511 if (plugin->state == PLUGIN_IS_DELETED && ! plugin->ref_count) 00512 { 00513 if (plugin->plugin->deinit) 00514 plugin->plugin->deinit(); 00515 plugin_del(&plugin->name); 00516 } 00517 rw_unlock(&THR_LOCK_plugin); 00518 DBUG_VOID_RETURN; 00519 }
Here is the call graph for this function:


