2011-07-04 01:25:49 +02:00
|
|
|
/*
|
2018-04-19 22:27:02 +02:00
|
|
|
Copyright (c) 2005, 2018, Oracle and/or its affiliates.
|
2020-07-31 17:09:08 +02:00
|
|
|
Copyright (c) 2010, 2020, MariaDB Corporation.
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2005-11-05 12:20:35 +01:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
2005-11-05 12:20:35 +01:00
|
|
|
|
2017-06-18 05:42:16 +02:00
|
|
|
#include "sql_plugin.h" // SHOW_MY_BOOL
|
|
|
|
#include "sql_priv.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "unireg.h"
|
|
|
|
#include "sql_class.h" // set_var.h: THD
|
2009-12-22 10:35:56 +01:00
|
|
|
#include "sys_vars_shared.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_locale.h"
|
|
|
|
#include "sql_plugin.h"
|
|
|
|
#include "sql_parse.h" // check_table_access
|
A pre-requisite patch for the fix for Bug#52044.
This patch also fixes Bug#55452 "SET PASSWORD is
replicated twice in RBR mode".
The goal of this patch is to remove the release of
metadata locks from close_thread_tables().
This is necessary to not mistakenly release
the locks in the course of a multi-step
operation that involves multiple close_thread_tables()
or close_tables_for_reopen().
On the same token, move statement commit outside
close_thread_tables().
Other cleanups:
Cleanup COM_FIELD_LIST.
Don't call close_thread_tables() in COM_SHUTDOWN -- there
are no open tables there that can be closed (we leave
the locked tables mode in THD destructor, and this
close_thread_tables() won't leave it anyway).
Make open_and_lock_tables() and open_and_lock_tables_derived()
call close_thread_tables() upon failure.
Remove the calls to close_thread_tables() that are now
unnecessary.
Simplify the back off condition in Open_table_context.
Streamline metadata lock handling in LOCK TABLES
implementation.
Add asserts to ensure correct life cycle of
statement transaction in a session.
Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
mysql-test/r/variables.result:
Update results: set @@autocommit and statement transaction/
prelocked mode.
mysql-test/r/view.result:
A harmless change in CHECK TABLE <view> status for a broken view.
If previously a failure to prelock all functions used in a view
would leave the connection in LTM_PRELOCKED mode, now we call
close_thread_tables() from open_and_lock_tables()
and leave prelocked mode, thus some check in mysql_admin_table() that
works only in prelocked/locked tables mode is no longer activated.
mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result:
Fixed Bug#55452 "SET PASSWORD is replicated twice in
RBR mode": extra binlog events are gone from the
binary log.
mysql-test/t/variables.test:
Add a test case: set autocommit and statement transaction/prelocked
mode.
sql/event_data_objects.cc:
Simplify code in Event_job_data::execute().
Move sp_head memory management to lex_end().
sql/event_db_repository.cc:
Move the release of metadata locks outside
close_thread_tables().
Make sure we call close_thread_tables() when
open_and_lock_tables() fails and remove extra
code from the events data dictionary.
Use close_mysql_tables(), a new internal
function to properly close mysql.* tables
in the data dictionary.
Contract Event_db_repository::drop_events_by_field,
drop_schema_events into one function.
When dropping all events in a schema,
make sure we don't mistakenly release all
locks acquired by DROP DATABASE. These
include locks on the database name
and the global intention exclusive
metadata lock.
sql/event_db_repository.h:
Function open_event_table() does not require an instance
of Event_db_repository.
sql/events.cc:
Use close_mysql_tables() instead of close_thread_tables()
to bootstrap events, since the latter no longer
releases metadata locks.
sql/ha_ndbcluster.cc:
- mysql_rm_table_part2 no longer releases
acquired metadata locks. Do it in the caller.
sql/ha_ndbcluster_binlog.cc:
Deploy the new protocol for closing thread
tables in run_query() and ndb_binlog_index
code.
sql/handler.cc:
Assert that we never call ha_commit_trans/
ha_rollback_trans in sub-statement, which
is now the case.
sql/handler.h:
Add an accessor to check whether THD_TRANS object
is empty (has no transaction started).
sql/log.cc:
Update a comment.
sql/log_event.cc:
Since now we commit/rollback statement transaction in
mysql_execute_command(), we need a mechanism to communicate
from Query_log_event::do_apply_event() to mysql_execute_command()
that the statement transaction should be rolled back, not committed.
Ideally it would be a virtual method of THD. I hesitate
to make THD a virtual base class in this already large patch.
Use a thd->variables.option_bits for now.
Remove a call to close_thread_tables() from the slave IO
thread. It doesn't open any tables, and the protocol
for closing thread tables is more complicated now.
Make sure we properly close thread tables, however,
in Load_data_log_event, which doesn't
follow the standard server execution procedure
with mysql_execute_command().
@todo: this piece should use Server_runnable
framework instead.
Remove an unnecessary call to mysql_unlock_tables().
sql/rpl_rli.cc:
Update Relay_log_info::slave_close_thread_tables()
to follow the new close protocol.
sql/set_var.cc:
Remove an unused header.
sql/slave.cc:
Remove an unnecessary call to
close_thread_tables().
sql/sp.cc:
Remove unnecessary calls to close_thread_tables()
from SP DDL implementation. The tables will
be closed by the caller, in mysql_execute_command().
When dropping all routines in a database, make sure
to not mistakenly drop all metadata locks acquired
so far, they include the scoped lock on the schema.
sql/sp_head.cc:
Correct the protocol that closes thread tables
in an SP instruction.
Clear lex->sphead before cleaning up lex
with lex_end to make sure that we don't
delete the sphead twice. It's considered
to be "cleaner" and more in line with
future changes than calling delete lex->sphead
in other places that cleanup the lex.
sql/sp_head.h:
When destroying m_lex_keeper of an instruction,
don't delete the sphead that all lex objects
share.
@todo: don't store a reference to routine's sp_head
instance in instruction's lex.
sql/sql_acl.cc:
Don't call close_thread_tables() where the caller will
do that for us.
Fix Bug#55452 "SET PASSWORD is replicated twice in RBR
mode" by disabling RBR replication in change_password()
function.
Use close_mysql_tables() in bootstrap and ACL reload
code to make sure we release all metadata locks.
sql/sql_base.cc:
This is the main part of the patch:
- remove manipulation with thd->transaction
and thd->mdl_context from close_thread_tables().
Now this function is only responsible for closing
tables, nothing else.
This is necessary to be able to easily use
close_thread_tables() in procedures, that
involve multiple open/close tables, which all
need to be protected continuously by metadata
locks.
Add asserts ensuring that TABLE object
is only used when is protected by a metadata lock.
Simplify the back off condition of Open_table_context,
we no longer need to look at the autocommit mode.
Make open_and_lock_tables() and open_normal_and_derived_tables()
close thread tables and release metadata locks acquired so-far
upon failure. This simplifies their usage.
Implement close_mysql_tables().
sql/sql_base.h:
Add declaration for close_mysql_tables().
sql/sql_class.cc:
Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
The code became dead when my_eof() was made a non-protocol method,
but a method that merely modifies the diagnostics area.
The code became redundant with the fix for Bug#37521, when
we started to cal close_thread_tables() before
Protocol::end_statement().
sql/sql_do.cc:
Do nothing in DO if inside a substatement
(the assert moved out of trans_rollback_stmt).
sql/sql_handler.cc:
Add comments.
sql/sql_insert.cc:
Remove dead code.
Release metadata locks explicitly at the
end of the delayed insert thread.
sql/sql_lex.cc:
Add destruction of lex->sphead to lex_end(),
lex "reset" method called at the end of each statement.
sql/sql_parse.cc:
Move close_thread_tables() and other related
cleanups to mysql_execute_command()
from dispatch_command(). This has become
possible after the fix for Bug#37521.
Mark federated SERVER statements as DDL.
Next step: make sure that we don't store
eof packet in the query cache, and move
the query cache code outside mysql_parse.
Brush up the code of COM_FIELD_LIST.
Remove unnecessary calls to close_thread_tables().
When killing a query, don't report "OK"
if it was a suicide.
sql/sql_parse.h:
Remove declaration of a function that is now static.
sql/sql_partition.cc:
Remove an unnecessary call to close_thread_tables().
sql/sql_plugin.cc:
open_and_lock_tables() will clean up
after itself after a failure.
Move close_thread_tables() above
end: label, and replace with close_mysql_tables(),
which will also release the metadata lock
on mysql.plugin.
sql/sql_prepare.cc:
Now that we no longer release locks in close_thread_tables()
statement prepare code has become more straightforward.
Remove the now redundant check for thd->killed() (used
only by the backup project) from Execute_server_runnable.
Reorder code to take into account that now mysql_execute_command()
performs lex->unit.cleanup() and close_thread_tables().
sql/sql_priv.h:
Add a new option to server options to interact
between the slave SQL thread and execution
framework (hack). @todo: use a virtual
method of class THD instead.
sql/sql_servers.cc:
Due to Bug 25705 replication of
DROP/CREATE/ALTER SERVER is broken.
Make sure at least we do not attempt to
replicate these statements using RBR,
as this violates the assert in close_mysql_tables().
sql/sql_table.cc:
Do not release metadata locks in mysql_rm_table_part2,
this is done by the caller.
Do not call close_thread_tables() in mysql_create_table(),
this is done by the caller.
Fix a bug in DROP TABLE under LOCK TABLES when,
upon error in wait_while_table_is_used() we would mistakenly
release the metadata lock on a non-dropped table.
Explicitly release metadata locks when doing an implicit
commit.
sql/sql_trigger.cc:
Now that we delete lex->sphead in lex_end(),
zero the trigger's sphead in lex after loading
the trigger, to avoid double deletion.
sql/sql_udf.cc:
Use close_mysql_tables() instead of close_thread_tables().
sql/sys_vars.cc:
Remove code added in scope of WL#4284 which would
break when we perform set @@session.autocommit along
with setting other variables and using tables or functions.
A test case added to variables.test.
sql/transaction.cc:
Add asserts.
sql/tztime.cc:
Use close_mysql_tables() rather than close_thread_tables().
2010-07-27 12:25:53 +02:00
|
|
|
#include "sql_base.h" // close_mysql_tables
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "key.h" // key_copy
|
2015-01-05 13:27:44 +01:00
|
|
|
#include "sql_table.h"
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "sql_show.h" // remove_status_vars, add_status_vars
|
|
|
|
#include "strfunc.h" // find_set
|
|
|
|
#include "records.h" // init_read_record, end_read_record
|
2005-11-05 12:20:35 +01:00
|
|
|
#include <my_pthread.h>
|
2007-03-02 17:43:45 +01:00
|
|
|
#include <my_getopt.h>
|
2010-08-20 11:58:28 +02:00
|
|
|
#include "sql_audit.h"
|
2010-08-09 10:32:50 +02:00
|
|
|
#include <mysql/plugin_auth.h>
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
|
2010-03-29 17:13:53 +02:00
|
|
|
#include <mysql/plugin_auth.h>
|
2014-11-25 21:58:14 +01:00
|
|
|
#include <mysql/plugin_password_validation.h>
|
2015-03-27 09:45:22 +01:00
|
|
|
#include <mysql/plugin_encryption.h>
|
2019-10-04 16:33:09 +02:00
|
|
|
#include <mysql/plugin_data_type.h>
|
2019-10-16 10:43:24 +02:00
|
|
|
#include <mysql/plugin_function.h>
|
2013-03-26 19:17:26 +01:00
|
|
|
#include "sql_plugin_compat.h"
|
2022-02-15 14:36:02 +01:00
|
|
|
#include "wsrep_mysqld.h"
|
2013-03-26 19:17:26 +01:00
|
|
|
|
2020-01-29 13:50:26 +01:00
|
|
|
static PSI_memory_key key_memory_plugin_mem_root;
|
|
|
|
static PSI_memory_key key_memory_plugin_int_mem_root;
|
|
|
|
static PSI_memory_key key_memory_mysql_plugin;
|
|
|
|
static PSI_memory_key key_memory_mysql_plugin_dl;
|
|
|
|
static PSI_memory_key key_memory_plugin_bookmark;
|
|
|
|
|
2015-03-30 14:16:34 +02:00
|
|
|
#ifdef HAVE_LINK_H
|
|
|
|
#include <link.h>
|
|
|
|
#endif
|
|
|
|
|
2011-04-25 17:22:25 +02:00
|
|
|
extern struct st_maria_plugin *mysql_optional_plugins[];
|
|
|
|
extern struct st_maria_plugin *mysql_mandatory_plugins[];
|
2006-04-13 22:49:29 +02:00
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
/**
|
|
|
|
@note The order of the enumeration is critical.
|
|
|
|
@see construct_options
|
|
|
|
*/
|
2010-09-27 14:55:09 +02:00
|
|
|
const char *global_plugin_typelib_names[]=
|
|
|
|
{ "OFF", "ON", "FORCE", "FORCE_PLUS_PERMANENT", NULL };
|
2009-05-14 14:03:33 +02:00
|
|
|
static TYPELIB global_plugin_typelib=
|
|
|
|
{ array_elements(global_plugin_typelib_names)-1,
|
|
|
|
"", global_plugin_typelib_names, NULL };
|
|
|
|
|
2012-12-15 18:24:11 +01:00
|
|
|
static I_List<i_string> opt_plugin_load_list;
|
|
|
|
I_List<i_string> *opt_plugin_load_list_ptr= &opt_plugin_load_list;
|
2005-11-05 12:20:35 +01:00
|
|
|
char *opt_plugin_dir_ptr;
|
|
|
|
char opt_plugin_dir[FN_REFLEN];
|
2011-04-25 17:22:25 +02:00
|
|
|
ulong plugin_maturity;
|
2010-06-16 19:01:22 +02:00
|
|
|
|
2018-01-07 17:03:44 +01:00
|
|
|
static LEX_CSTRING MYSQL_PLUGIN_NAME= {STRING_WITH_LEN("plugin") };
|
|
|
|
|
2010-06-16 19:01:22 +02:00
|
|
|
/*
|
|
|
|
not really needed now, this map will become essential when we add more
|
|
|
|
maturity levels. We cannot change existing maturity constants,
|
|
|
|
so the next value - even if it will be MariaDB_PLUGIN_MATURITY_VERY_BUGGY -
|
|
|
|
will inevitably be larger than MariaDB_PLUGIN_MATURITY_STABLE.
|
|
|
|
To be able to compare them we use this mapping array
|
|
|
|
*/
|
|
|
|
uint plugin_maturity_map[]=
|
|
|
|
{ 0, 1, 2, 3, 4, 5, 6 };
|
|
|
|
|
2006-11-11 02:21:59 +01:00
|
|
|
/*
|
2019-06-10 18:07:49 +02:00
|
|
|
When you add a new plugin type, add both a string and make sure that the
|
2006-11-11 02:21:59 +01:00
|
|
|
init and deinit array are correctly updated.
|
|
|
|
*/
|
2018-01-08 14:33:23 +01:00
|
|
|
const LEX_CSTRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
|
|
|
{
|
|
|
|
{ STRING_WITH_LEN("UDF") },
|
|
|
|
{ STRING_WITH_LEN("STORAGE ENGINE") },
|
|
|
|
{ STRING_WITH_LEN("FTPARSER") },
|
|
|
|
{ STRING_WITH_LEN("DAEMON") },
|
|
|
|
{ STRING_WITH_LEN("INFORMATION SCHEMA") },
|
|
|
|
{ STRING_WITH_LEN("AUDIT") },
|
|
|
|
{ STRING_WITH_LEN("REPLICATION") },
|
|
|
|
{ STRING_WITH_LEN("AUTHENTICATION") },
|
|
|
|
{ STRING_WITH_LEN("PASSWORD VALIDATION") },
|
2019-10-04 16:33:09 +02:00
|
|
|
{ STRING_WITH_LEN("ENCRYPTION") },
|
2019-10-07 08:46:25 +02:00
|
|
|
{ STRING_WITH_LEN("DATA TYPE") },
|
2019-10-16 14:22:04 +02:00
|
|
|
{ STRING_WITH_LEN("FUNCTION") }
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
};
|
handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support
run-time handlerton initialization (no compiler warnings), handler API
is now tied to MySQL version, handlerton->plugin mapping added
(slot-based), dummy default_hton removed, plugin-type-specific
initialization generalized, built-in plugins are now initialized too,
--default-storage-engine no longer needs a list of storage engines
in handle_options().
mysql-test-run.pl bugfixes
include/mysql/plugin.h:
added st_mysql_storage_engine
made handlerton tied to MySQL version
mysql-test/mysql-test-run.pl:
bugfixes (umask, --no-defaults)
mysql-test/r/ndb_dd_basic.result:
update error message
mysql-test/t/partition_mgm_err2.test:
fix typo
sql/ha_berkeley.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_berkeley.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_federated.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_heap.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisam.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisammrg.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster_binlog.cc:
no 'name' in the handlerton anymore
sql/ha_partition.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/handler.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
handlerton->plugin mapping
sql/handler.h:
handlerton cleanup: remove duplicate fields
sql/log.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/mysql_priv.h:
handler.h needs plugin.h
sql/mysqld.cc:
Convert --default-storage-engine to a handlerton* when
all storage engines are initialized and not in getopt
sql/set_var.cc:
no name in the handlerton anymore
sql/sql_parse.cc:
no default_hton anymore
sql/sql_partition.cc:
no name in the handlerton anymore
sql/sql_plugin.cc:
generalize plugin type-specific initialization.
initialize built-in plugins too
sql/sql_plugin.h:
generalize plugin type-specific initialization.
sql/sql_show.cc:
st_mysql_storage_engine structure
no name in the handlerton anymore
sql/sql_table.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_tablespace.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_yacc.yy:
no default_hton anymore
issue "unknown storage engine" warning where it is discovered
storage/archive/ha_archive.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/archive/ha_archive.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/blackhole/ha_blackhole.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/csv/ha_tina.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/example/ha_example.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
2006-05-28 14:51:01 +02:00
|
|
|
|
2007-01-27 00:36:39 +01:00
|
|
|
extern int initialize_schema_table(st_plugin_int *plugin);
|
|
|
|
extern int finalize_schema_table(st_plugin_int *plugin);
|
|
|
|
|
2009-12-15 20:52:47 +01:00
|
|
|
extern int initialize_audit_plugin(st_plugin_int *plugin);
|
|
|
|
extern int finalize_audit_plugin(st_plugin_int *plugin);
|
|
|
|
|
2015-03-27 09:45:22 +01:00
|
|
|
extern int initialize_encryption_plugin(st_plugin_int *plugin);
|
|
|
|
extern int finalize_encryption_plugin(st_plugin_int *plugin);
|
2015-01-05 13:36:14 +01:00
|
|
|
|
2019-10-11 14:12:38 +02:00
|
|
|
extern int initialize_data_type_plugin(st_plugin_int *plugin);
|
|
|
|
|
2007-01-27 00:36:39 +01:00
|
|
|
/*
|
2007-04-13 19:24:46 +02:00
|
|
|
The number of elements in both plugin_type_initialize and
|
2007-01-27 00:36:39 +01:00
|
|
|
plugin_type_deinitialize should equal to the number of plugins
|
|
|
|
defined.
|
2007-04-13 19:24:46 +02:00
|
|
|
*/
|
handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support
run-time handlerton initialization (no compiler warnings), handler API
is now tied to MySQL version, handlerton->plugin mapping added
(slot-based), dummy default_hton removed, plugin-type-specific
initialization generalized, built-in plugins are now initialized too,
--default-storage-engine no longer needs a list of storage engines
in handle_options().
mysql-test-run.pl bugfixes
include/mysql/plugin.h:
added st_mysql_storage_engine
made handlerton tied to MySQL version
mysql-test/mysql-test-run.pl:
bugfixes (umask, --no-defaults)
mysql-test/r/ndb_dd_basic.result:
update error message
mysql-test/t/partition_mgm_err2.test:
fix typo
sql/ha_berkeley.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_berkeley.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_federated.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_heap.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisam.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisammrg.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster_binlog.cc:
no 'name' in the handlerton anymore
sql/ha_partition.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/handler.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
handlerton->plugin mapping
sql/handler.h:
handlerton cleanup: remove duplicate fields
sql/log.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/mysql_priv.h:
handler.h needs plugin.h
sql/mysqld.cc:
Convert --default-storage-engine to a handlerton* when
all storage engines are initialized and not in getopt
sql/set_var.cc:
no name in the handlerton anymore
sql/sql_parse.cc:
no default_hton anymore
sql/sql_partition.cc:
no name in the handlerton anymore
sql/sql_plugin.cc:
generalize plugin type-specific initialization.
initialize built-in plugins too
sql/sql_plugin.h:
generalize plugin type-specific initialization.
sql/sql_show.cc:
st_mysql_storage_engine structure
no name in the handlerton anymore
sql/sql_table.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_tablespace.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_yacc.yy:
no default_hton anymore
issue "unknown storage engine" warning where it is discovered
storage/archive/ha_archive.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/archive/ha_archive.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/blackhole/ha_blackhole.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/csv/ha_tina.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/example/ha_example.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
2006-05-28 14:51:01 +02:00
|
|
|
plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
|
|
|
{
|
2014-11-25 21:58:14 +01:00
|
|
|
0, ha_initialize_handlerton, 0, 0,initialize_schema_table,
|
2019-10-11 14:12:38 +02:00
|
|
|
initialize_audit_plugin, 0, 0, 0, initialize_encryption_plugin,
|
|
|
|
initialize_data_type_plugin, 0
|
handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support
run-time handlerton initialization (no compiler warnings), handler API
is now tied to MySQL version, handlerton->plugin mapping added
(slot-based), dummy default_hton removed, plugin-type-specific
initialization generalized, built-in plugins are now initialized too,
--default-storage-engine no longer needs a list of storage engines
in handle_options().
mysql-test-run.pl bugfixes
include/mysql/plugin.h:
added st_mysql_storage_engine
made handlerton tied to MySQL version
mysql-test/mysql-test-run.pl:
bugfixes (umask, --no-defaults)
mysql-test/r/ndb_dd_basic.result:
update error message
mysql-test/t/partition_mgm_err2.test:
fix typo
sql/ha_berkeley.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_berkeley.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_federated.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_heap.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisam.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisammrg.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster_binlog.cc:
no 'name' in the handlerton anymore
sql/ha_partition.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/handler.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
handlerton->plugin mapping
sql/handler.h:
handlerton cleanup: remove duplicate fields
sql/log.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/mysql_priv.h:
handler.h needs plugin.h
sql/mysqld.cc:
Convert --default-storage-engine to a handlerton* when
all storage engines are initialized and not in getopt
sql/set_var.cc:
no name in the handlerton anymore
sql/sql_parse.cc:
no default_hton anymore
sql/sql_partition.cc:
no name in the handlerton anymore
sql/sql_plugin.cc:
generalize plugin type-specific initialization.
initialize built-in plugins too
sql/sql_plugin.h:
generalize plugin type-specific initialization.
sql/sql_show.cc:
st_mysql_storage_engine structure
no name in the handlerton anymore
sql/sql_table.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_tablespace.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_yacc.yy:
no default_hton anymore
issue "unknown storage engine" warning where it is discovered
storage/archive/ha_archive.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/archive/ha_archive.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/blackhole/ha_blackhole.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/csv/ha_tina.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/example/ha_example.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
2006-05-28 14:51:01 +02:00
|
|
|
};
|
|
|
|
|
2006-09-07 15:01:36 +02:00
|
|
|
plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
|
|
|
{
|
2014-11-25 21:58:14 +01:00
|
|
|
0, ha_finalize_handlerton, 0, 0, finalize_schema_table,
|
2019-10-07 08:46:25 +02:00
|
|
|
finalize_audit_plugin, 0, 0, 0, finalize_encryption_plugin, 0,
|
2019-10-16 14:22:04 +02:00
|
|
|
0 // FUNCTION
|
2006-09-07 15:01:36 +02:00
|
|
|
};
|
|
|
|
|
2015-01-05 13:27:44 +01:00
|
|
|
/*
|
|
|
|
Defines in which order plugin types have to be initialized.
|
|
|
|
Essentially, we want to initialize MYSQL_KEY_MANAGEMENT_PLUGIN before
|
|
|
|
MYSQL_STORAGE_ENGINE_PLUGIN, and that before MYSQL_INFORMATION_SCHEMA_PLUGIN
|
|
|
|
*/
|
|
|
|
static int plugin_type_initialization_order[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
|
|
|
{
|
|
|
|
MYSQL_DAEMON_PLUGIN,
|
2015-03-27 09:45:22 +01:00
|
|
|
MariaDB_ENCRYPTION_PLUGIN,
|
2019-10-04 16:33:09 +02:00
|
|
|
MariaDB_DATA_TYPE_PLUGIN,
|
2019-10-16 10:43:24 +02:00
|
|
|
MariaDB_FUNCTION_PLUGIN,
|
2015-01-05 13:27:44 +01:00
|
|
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
|
|
|
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
|
|
|
MYSQL_FTPARSER_PLUGIN,
|
|
|
|
MYSQL_AUTHENTICATION_PLUGIN,
|
|
|
|
MariaDB_PASSWORD_VALIDATION_PLUGIN,
|
|
|
|
MYSQL_AUDIT_PLUGIN,
|
|
|
|
MYSQL_REPLICATION_PLUGIN,
|
|
|
|
MYSQL_UDF_PLUGIN
|
|
|
|
};
|
|
|
|
|
2007-01-29 00:47:35 +01:00
|
|
|
#ifdef HAVE_DLOPEN
|
2005-11-05 12:20:35 +01:00
|
|
|
static const char *plugin_interface_version_sym=
|
|
|
|
"_mysql_plugin_interface_version_";
|
2006-01-01 16:43:34 +01:00
|
|
|
static const char *sizeof_st_plugin_sym=
|
|
|
|
"_mysql_sizeof_struct_st_plugin_";
|
2005-11-05 12:20:35 +01:00
|
|
|
static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";
|
2006-09-07 12:56:32 +02:00
|
|
|
static int min_plugin_interface_version= MYSQL_PLUGIN_INTERFACE_VERSION & ~0xFF;
|
2010-04-01 16:34:51 +02:00
|
|
|
static const char *maria_plugin_interface_version_sym=
|
|
|
|
"_maria_plugin_interface_version_";
|
|
|
|
static const char *maria_sizeof_st_plugin_sym=
|
|
|
|
"_maria_sizeof_struct_st_plugin_";
|
|
|
|
static const char *maria_plugin_declarations_sym=
|
|
|
|
"_maria_plugin_declarations_";
|
|
|
|
static int min_maria_plugin_interface_version=
|
|
|
|
MARIA_PLUGIN_INTERFACE_VERSION & ~0xFF;
|
2007-01-29 00:47:35 +01:00
|
|
|
#endif
|
|
|
|
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
/* Note that 'int version' must be the first field of every plugin
|
|
|
|
sub-structure (plugin->info).
|
|
|
|
*/
|
|
|
|
static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
|
|
|
{
|
|
|
|
0x0000,
|
2006-05-28 17:02:50 +02:00
|
|
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
2006-11-11 02:21:59 +01:00
|
|
|
MYSQL_FTPARSER_INTERFACE_VERSION,
|
2007-01-27 00:36:39 +01:00
|
|
|
MYSQL_DAEMON_INTERFACE_VERSION,
|
2009-09-26 06:49:49 +02:00
|
|
|
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
|
2009-12-15 20:52:47 +01:00
|
|
|
MYSQL_AUDIT_INTERFACE_VERSION,
|
2010-11-25 18:17:28 +01:00
|
|
|
MYSQL_REPLICATION_INTERFACE_VERSION,
|
2014-11-25 21:58:14 +01:00
|
|
|
MIN_AUTHENTICATION_INTERFACE_VERSION,
|
2015-01-05 13:36:14 +01:00
|
|
|
MariaDB_PASSWORD_VALIDATION_INTERFACE_VERSION,
|
2019-10-04 16:33:09 +02:00
|
|
|
MariaDB_ENCRYPTION_INTERFACE_VERSION,
|
2019-10-07 08:46:25 +02:00
|
|
|
MariaDB_DATA_TYPE_INTERFACE_VERSION,
|
2019-10-16 14:22:04 +02:00
|
|
|
MariaDB_FUNCTION_INTERFACE_VERSION
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
};
|
|
|
|
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
|
|
|
|
{
|
|
|
|
0x0000, /* UDF: not implemented */
|
2005-12-29 21:29:02 +01:00
|
|
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
2006-11-11 02:21:59 +01:00
|
|
|
MYSQL_FTPARSER_INTERFACE_VERSION,
|
2007-01-27 00:36:39 +01:00
|
|
|
MYSQL_DAEMON_INTERFACE_VERSION,
|
2009-09-26 06:49:49 +02:00
|
|
|
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
|
2009-12-15 20:52:47 +01:00
|
|
|
MYSQL_AUDIT_INTERFACE_VERSION,
|
2010-11-25 18:17:28 +01:00
|
|
|
MYSQL_REPLICATION_INTERFACE_VERSION,
|
2014-11-25 21:58:14 +01:00
|
|
|
MYSQL_AUTHENTICATION_INTERFACE_VERSION,
|
2015-01-05 13:36:14 +01:00
|
|
|
MariaDB_PASSWORD_VALIDATION_INTERFACE_VERSION,
|
2019-10-04 16:33:09 +02:00
|
|
|
MariaDB_ENCRYPTION_INTERFACE_VERSION,
|
2019-10-07 08:46:25 +02:00
|
|
|
MariaDB_DATA_TYPE_INTERFACE_VERSION,
|
2019-10-16 14:22:04 +02:00
|
|
|
MariaDB_FUNCTION_INTERFACE_VERSION
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
};
|
2006-05-28 17:02:50 +02:00
|
|
|
|
2011-11-28 18:20:51 +01:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
const char *plugin_name;
|
|
|
|
enum enum_plugin_load_option override;
|
|
|
|
} override_plugin_load_policy[]={
|
|
|
|
/*
|
|
|
|
If the performance schema is compiled in,
|
|
|
|
treat the storage engine plugin as 'mandatory',
|
|
|
|
to suppress any plugin-level options such as '--performance-schema'.
|
|
|
|
This is specific to the performance schema, and is done on purpose:
|
|
|
|
the server-level option '--performance-schema' controls the overall
|
|
|
|
performance schema initialization, which consists of much more that
|
|
|
|
the underlying storage engine initialization.
|
|
|
|
See mysqld.cc, set_vars.cc.
|
|
|
|
Suppressing ways to interfere directly with the storage engine alone
|
|
|
|
prevents awkward situations where:
|
|
|
|
- the user wants the performance schema functionality, by using
|
|
|
|
'--enable-performance-schema' (the server option),
|
|
|
|
- yet disable explicitly a component needed for the functionality
|
|
|
|
to work, by using '--skip-performance-schema' (the plugin)
|
|
|
|
*/
|
2014-12-04 17:59:07 +01:00
|
|
|
{ "performance_schema", PLUGIN_FORCE }
|
2011-11-28 18:20:51 +01:00
|
|
|
|
|
|
|
/* we disable few other plugins by default */
|
2015-02-24 16:26:18 +01:00
|
|
|
,{ "feedback", PLUGIN_OFF }
|
2011-11-28 18:20:51 +01:00
|
|
|
};
|
|
|
|
|
2009-11-02 21:05:42 +01:00
|
|
|
/* support for Services */
|
|
|
|
|
2022-01-13 17:27:28 +01:00
|
|
|
#include "sql_plugin_services.inl"
|
2007-04-18 20:46:26 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
A mutex LOCK_plugin must be acquired before accessing the
|
|
|
|
following variables/structures.
|
|
|
|
We are always manipulating ref count, so a rwlock here is unneccessary.
|
|
|
|
*/
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_t LOCK_plugin;
|
2005-11-05 12:20:35 +01:00
|
|
|
static DYNAMIC_ARRAY plugin_dl_array;
|
|
|
|
static DYNAMIC_ARRAY plugin_array;
|
|
|
|
static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
|
2014-01-28 08:12:43 +01:00
|
|
|
static MEM_ROOT plugin_mem_root;
|
2007-03-02 17:43:45 +01:00
|
|
|
static bool reap_needed= false;
|
2019-06-14 23:02:55 +02:00
|
|
|
volatile int global_plugin_version= 1;
|
2006-09-05 23:59:16 +02:00
|
|
|
|
2009-11-02 21:05:42 +01:00
|
|
|
static bool initialized= 0;
|
2013-04-09 23:27:29 +02:00
|
|
|
ulong dlopen_count;
|
|
|
|
|
2009-11-02 21:05:42 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
write-lock on LOCK_system_variables_hash is required before modifying
|
|
|
|
the following variables/structures
|
|
|
|
*/
|
2014-01-28 08:12:43 +01:00
|
|
|
static MEM_ROOT plugin_vars_mem_root;
|
2018-02-06 13:55:58 +01:00
|
|
|
static size_t global_variables_dynamic_size= 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
static HASH bookmark_hash;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
hidden part of opaque value passed to variable check functions.
|
|
|
|
Used to provide a object-like structure to non C++ consumers.
|
|
|
|
*/
|
|
|
|
struct st_item_value_holder : public st_mysql_value
|
|
|
|
{
|
|
|
|
Item *item;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
stored in bookmark_hash, this structure is never removed from the
|
2007-04-13 19:24:46 +02:00
|
|
|
hash and is used to mark a single offset for a thd local variable
|
2007-03-02 17:43:45 +01:00
|
|
|
even if plugins have been uninstalled and reinstalled, repeatedly.
|
|
|
|
This structure is allocated from plugin_mem_root.
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-04-02 20:38:58 +02:00
|
|
|
The key format is as follows:
|
|
|
|
1 byte - variable type code
|
|
|
|
name_len bytes - variable name
|
|
|
|
'\0' - end of key
|
2007-03-02 17:43:45 +01:00
|
|
|
*/
|
|
|
|
struct st_bookmark
|
|
|
|
{
|
|
|
|
uint name_len;
|
|
|
|
int offset;
|
|
|
|
uint version;
|
2016-04-15 20:47:45 +02:00
|
|
|
bool loaded;
|
2007-04-13 19:23:02 +02:00
|
|
|
char key[1];
|
2007-03-02 17:43:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
skeleton of a plugin variable - portion of structure common to all.
|
|
|
|
*/
|
|
|
|
struct st_mysql_sys_var
|
|
|
|
{
|
|
|
|
MYSQL_PLUGIN_VAR_HEADER;
|
|
|
|
};
|
|
|
|
|
2018-07-04 11:27:20 +02:00
|
|
|
enum install_status { INSTALL_GOOD, INSTALL_FAIL_WARN_OK, INSTALL_FAIL_NOT_OK };
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
sys_var class for access to all plugin variables visible to the user
|
|
|
|
*/
|
2014-08-27 23:28:59 +02:00
|
|
|
class sys_var_pluginvar: public sys_var, public Sql_alloc
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct st_plugin_int *plugin;
|
|
|
|
struct st_mysql_sys_var *plugin_var;
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
sys_var_pluginvar(sys_var_chain *chain, const char *name_arg,
|
2022-02-15 08:18:55 +01:00
|
|
|
st_plugin_int *p, st_mysql_sys_var *plugin_var_arg,
|
|
|
|
const char *substitute);
|
2007-03-02 17:43:45 +01:00
|
|
|
sys_var_pluginvar *cast_pluginvar() { return this; }
|
2019-07-17 19:15:55 +02:00
|
|
|
uchar* real_value_ptr(THD *thd, enum_var_type type) const;
|
|
|
|
TYPELIB* plugin_var_typelib(void) const;
|
|
|
|
const uchar* do_value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base) const;
|
|
|
|
const uchar* session_value_ptr(THD *thd, const LEX_CSTRING *base) const
|
2009-12-22 10:35:56 +01:00
|
|
|
{ return do_value_ptr(thd, OPT_SESSION, base); }
|
2019-07-17 19:15:55 +02:00
|
|
|
const uchar* global_value_ptr(THD *thd, const LEX_CSTRING *base) const
|
2009-12-22 10:35:56 +01:00
|
|
|
{ return do_value_ptr(thd, OPT_GLOBAL, base); }
|
2019-07-17 19:15:55 +02:00
|
|
|
const uchar *default_value_ptr(THD *thd) const
|
2014-09-03 20:16:51 +02:00
|
|
|
{ return do_value_ptr(thd, OPT_DEFAULT, 0); }
|
2009-12-22 10:35:56 +01:00
|
|
|
bool do_check(THD *thd, set_var *var);
|
|
|
|
virtual void session_save_default(THD *thd, set_var *var) {}
|
|
|
|
virtual void global_save_default(THD *thd, set_var *var) {}
|
|
|
|
bool session_update(THD *thd, set_var *var);
|
|
|
|
bool global_update(THD *thd, set_var *var);
|
2015-04-10 02:36:54 +02:00
|
|
|
bool session_is_default(THD *thd);
|
2007-03-02 17:43:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-08-29 20:58:12 +02:00
|
|
|
/* prototypes */
|
2014-01-28 08:12:43 +01:00
|
|
|
static void plugin_load(MEM_ROOT *tmp_root);
|
|
|
|
static bool plugin_load_list(MEM_ROOT *, const char *);
|
2007-04-13 19:23:02 +02:00
|
|
|
static int test_plugin_options(MEM_ROOT *, struct st_plugin_int *,
|
2009-05-14 14:03:33 +02:00
|
|
|
int *, char **);
|
2010-04-01 16:34:51 +02:00
|
|
|
static bool register_builtin(struct st_maria_plugin *, struct st_plugin_int *,
|
2007-04-13 19:23:02 +02:00
|
|
|
struct st_plugin_int **);
|
2007-04-02 20:38:58 +02:00
|
|
|
static void unlock_variables(THD *thd, struct system_variables *vars);
|
2014-10-23 21:01:52 +02:00
|
|
|
static void cleanup_variables(struct system_variables *vars);
|
2023-01-19 21:53:16 +01:00
|
|
|
static void plugin_vars_free_values(st_mysql_sys_var **vars);
|
2013-12-09 12:39:13 +01:00
|
|
|
static void restore_ptr_backup(uint n, st_ptr_backup *backup);
|
2007-03-02 17:43:45 +01:00
|
|
|
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin);
|
|
|
|
static void reap_plugins(void);
|
|
|
|
|
2017-06-14 11:27:36 +02:00
|
|
|
bool plugin_is_forced(struct st_plugin_int *p)
|
|
|
|
{
|
|
|
|
return p->load_option == PLUGIN_FORCE ||
|
|
|
|
p->load_option == PLUGIN_FORCE_PLUS_PERMANENT;
|
|
|
|
}
|
|
|
|
|
2010-12-01 13:54:50 +01:00
|
|
|
/**
|
|
|
|
Check if the provided path is valid in the sense that it does cause
|
|
|
|
a relative reference outside the directory.
|
|
|
|
|
|
|
|
@note Currently, this function only check if there are any
|
|
|
|
characters in FN_DIRSEP in the string, but it might change in the
|
|
|
|
future.
|
|
|
|
|
|
|
|
@code
|
|
|
|
check_valid_path("../foo.so") -> true
|
|
|
|
check_valid_path("foo.so") -> false
|
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
bool check_valid_path(const char *path, size_t len)
|
|
|
|
{
|
|
|
|
size_t prefix= my_strcspn(files_charset_info, path, path + len, FN_DIRSEP);
|
|
|
|
return prefix < len;
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
static void fix_dl_name(MEM_ROOT *root, LEX_CSTRING *dl)
|
2012-03-05 21:48:06 +01:00
|
|
|
{
|
|
|
|
const size_t so_ext_len= sizeof(SO_EXT) - 1;
|
2022-04-14 14:11:04 +02:00
|
|
|
if (dl->length < so_ext_len ||
|
|
|
|
my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len,
|
2012-03-05 21:48:06 +01:00
|
|
|
SO_EXT))
|
|
|
|
{
|
|
|
|
char *s= (char*)alloc_root(root, dl->length + so_ext_len + 1);
|
|
|
|
memcpy(s, dl->str, dl->length);
|
|
|
|
strcpy(s + dl->length, SO_EXT);
|
|
|
|
dl->str= s;
|
|
|
|
dl->length+= so_ext_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-01 13:54:50 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
Value type thunks, allows the C world to play in the C++ world
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int item_value_type(struct st_mysql_value *value)
|
|
|
|
{
|
|
|
|
switch (((st_item_value_holder*)value)->item->result_type()) {
|
|
|
|
case INT_RESULT:
|
|
|
|
return MYSQL_VALUE_TYPE_INT;
|
|
|
|
case REAL_RESULT:
|
|
|
|
return MYSQL_VALUE_TYPE_REAL;
|
|
|
|
default:
|
2007-04-13 19:24:46 +02:00
|
|
|
return MYSQL_VALUE_TYPE_STRING;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-13 19:24:46 +02:00
|
|
|
static const char *item_val_str(struct st_mysql_value *value,
|
2007-03-02 17:43:45 +01:00
|
|
|
char *buffer, int *length)
|
|
|
|
{
|
|
|
|
String str(buffer, *length, system_charset_info), *res;
|
|
|
|
if (!(res= ((st_item_value_holder*)value)->item->val_str(&str)))
|
|
|
|
return NULL;
|
|
|
|
*length= res->length();
|
|
|
|
if (res->c_ptr_quick() == buffer)
|
|
|
|
return buffer;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
2007-04-13 19:24:46 +02:00
|
|
|
Lets be nice and create a temporary string since the
|
2007-03-02 17:43:45 +01:00
|
|
|
buffer was too small
|
|
|
|
*/
|
2011-02-28 11:48:50 +01:00
|
|
|
return current_thd->strmake(res->ptr(), res->length());
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-13 19:23:02 +02:00
|
|
|
static int item_val_int(struct st_mysql_value *value, long long *buf)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
Item *item= ((st_item_value_holder*)value)->item;
|
2007-04-13 19:23:02 +02:00
|
|
|
*buf= item->val_int();
|
2007-03-02 17:43:45 +01:00
|
|
|
if (item->is_null())
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
static int item_is_unsigned(struct st_mysql_value *value)
|
|
|
|
{
|
|
|
|
Item *item= ((st_item_value_holder*)value)->item;
|
|
|
|
return item->unsigned_flag;
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-04-13 19:23:02 +02:00
|
|
|
static int item_val_real(struct st_mysql_value *value, double *buf)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
Item *item= ((st_item_value_holder*)value)->item;
|
2007-04-13 19:23:02 +02:00
|
|
|
*buf= item->val_real();
|
2007-03-02 17:43:45 +01:00
|
|
|
if (item->is_null())
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Plugin support code
|
|
|
|
****************************************************************************/
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2007-01-29 00:47:35 +01:00
|
|
|
#ifdef HAVE_DLOPEN
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
static struct st_plugin_dl *plugin_dl_find(const LEX_CSTRING *dl)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
uint i;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct st_plugin_dl *tmp;
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_ENTER("plugin_dl_find");
|
|
|
|
for (i= 0; i < plugin_dl_array.elements; i++)
|
|
|
|
{
|
2007-05-24 19:39:24 +02:00
|
|
|
tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);
|
2005-11-05 12:20:35 +01:00
|
|
|
if (tmp->ref_count &&
|
2020-01-26 17:27:13 +01:00
|
|
|
! files_charset_info->strnncoll(dl->str, dl->length,
|
|
|
|
tmp->dl.str, tmp->dl.length))
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(tmp);
|
|
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl)
|
|
|
|
{
|
|
|
|
uint i;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct st_plugin_dl *tmp;
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
DBUG_ENTER("plugin_dl_insert_or_reuse");
|
|
|
|
for (i= 0; i < plugin_dl_array.elements; i++)
|
|
|
|
{
|
2007-05-24 19:39:24 +02:00
|
|
|
tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
if (! tmp->ref_count)
|
|
|
|
{
|
|
|
|
memcpy(tmp, plugin_dl, sizeof(struct st_plugin_dl));
|
|
|
|
DBUG_RETURN(tmp);
|
|
|
|
}
|
|
|
|
}
|
2007-05-31 21:28:04 +02:00
|
|
|
if (insert_dynamic(&plugin_dl_array, (uchar*)&plugin_dl))
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
DBUG_RETURN(0);
|
2007-05-24 19:39:24 +02:00
|
|
|
tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1,
|
|
|
|
struct st_plugin_dl **)=
|
2007-05-31 22:07:44 +02:00
|
|
|
(struct st_plugin_dl *) memdup_root(&plugin_mem_root, (uchar*)plugin_dl,
|
2007-05-24 19:39:24 +02:00
|
|
|
sizeof(struct st_plugin_dl));
|
|
|
|
DBUG_RETURN(tmp);
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
}
|
2018-01-20 11:45:23 +01:00
|
|
|
#else
|
|
|
|
static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-01-29 00:47:35 +01:00
|
|
|
#endif /* HAVE_DLOPEN */
|
|
|
|
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
|
2013-12-09 12:39:13 +01:00
|
|
|
static void free_plugin_mem(struct st_plugin_dl *p)
|
2006-01-01 16:43:34 +01:00
|
|
|
{
|
2006-03-21 10:54:26 +01:00
|
|
|
#ifdef HAVE_DLOPEN
|
2013-12-09 12:39:13 +01:00
|
|
|
if (p->ptr_backup)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(p->nbackups);
|
|
|
|
DBUG_ASSERT(p->handle);
|
|
|
|
restore_ptr_backup(p->nbackups, p->ptr_backup);
|
|
|
|
my_free(p->ptr_backup);
|
|
|
|
}
|
2006-01-07 14:41:57 +01:00
|
|
|
if (p->handle)
|
|
|
|
dlclose(p->handle);
|
2006-03-21 10:54:26 +01:00
|
|
|
#endif
|
2017-04-23 18:39:57 +02:00
|
|
|
my_free(const_cast<char*>(p->dl.str));
|
2010-03-12 20:05:21 +01:00
|
|
|
if (p->allocated)
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(p->plugins);
|
2006-01-01 16:43:34 +01:00
|
|
|
}
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2010-04-01 16:34:51 +02:00
|
|
|
/**
|
|
|
|
Reads data from mysql plugin interface
|
|
|
|
|
|
|
|
@param plugin_dl Structure where the data should be put
|
|
|
|
@param sym Reverence on version info
|
|
|
|
@param dlpath Path to the module
|
2018-05-18 10:28:53 +02:00
|
|
|
@param MyFlags Where errors should be reported (0 or ME_ERROR_LOG)
|
2010-04-01 16:34:51 +02:00
|
|
|
|
|
|
|
@retval FALSE OK
|
|
|
|
@retval TRUE ERROR
|
|
|
|
*/
|
|
|
|
|
2010-04-01 22:05:09 +02:00
|
|
|
#ifdef HAVE_DLOPEN
|
2010-04-01 16:34:51 +02:00
|
|
|
static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl,
|
2018-05-18 10:28:53 +02:00
|
|
|
void *sym, char *dlpath, myf MyFlags)
|
2010-04-01 16:34:51 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("read_maria_plugin_info");
|
|
|
|
/* Determine interface version */
|
|
|
|
if (!sym)
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, plugin_interface_version_sym);
|
2010-04-01 16:34:51 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
plugin_dl->mariaversion= 0;
|
|
|
|
plugin_dl->mysqlversion= *(int *)sym;
|
|
|
|
/* Versioning */
|
|
|
|
if (plugin_dl->mysqlversion < min_plugin_interface_version ||
|
|
|
|
(plugin_dl->mysqlversion >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8))
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, ENOEXEC,
|
2010-04-01 16:34:51 +02:00
|
|
|
"plugin interface version mismatch");
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
/* Find plugin declarations */
|
|
|
|
if (!(sym= dlsym(plugin_dl->handle, plugin_declarations_sym)))
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, plugin_declarations_sym);
|
2010-04-01 16:34:51 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert mysql declaration to maria one */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
uint sizeof_st_plugin;
|
|
|
|
struct st_mysql_plugin *old;
|
|
|
|
struct st_maria_plugin *cur;
|
|
|
|
char *ptr= (char *)sym;
|
|
|
|
|
|
|
|
if ((sym= dlsym(plugin_dl->handle, sizeof_st_plugin_sym)))
|
|
|
|
sizeof_st_plugin= *(int *)sym;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(min_plugin_interface_version == 0);
|
|
|
|
sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i= 0;
|
|
|
|
((struct st_mysql_plugin *)(ptr + i * sizeof_st_plugin))->info;
|
|
|
|
i++)
|
|
|
|
/* no op */;
|
|
|
|
|
|
|
|
cur= (struct st_maria_plugin*)
|
2020-01-29 13:50:26 +01:00
|
|
|
my_malloc(key_memory_mysql_plugin, (i + 1) * sizeof(struct st_maria_plugin),
|
2010-04-01 16:34:51 +02:00
|
|
|
MYF(MY_ZEROFILL|MY_WME));
|
|
|
|
if (!cur)
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_OUTOFMEMORY, MyFlags,
|
2011-07-02 22:12:12 +02:00
|
|
|
static_cast<int>(plugin_dl->dl.length));
|
2010-04-01 16:34:51 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
All st_plugin fields not initialized in the plugin explicitly, are
|
|
|
|
set to 0. It matches C standard behaviour for struct initializers that
|
|
|
|
have less values than the struct definition.
|
|
|
|
*/
|
|
|
|
for (i=0;
|
|
|
|
(old= (struct st_mysql_plugin *)(ptr + i * sizeof_st_plugin))->info;
|
|
|
|
i++)
|
|
|
|
{
|
|
|
|
|
2010-06-16 09:52:12 +02:00
|
|
|
cur[i].type= old->type;
|
|
|
|
cur[i].info= old->info;
|
|
|
|
cur[i].name= old->name;
|
|
|
|
cur[i].author= old->author;
|
|
|
|
cur[i].descr= old->descr;
|
|
|
|
cur[i].license= old->license;
|
|
|
|
cur[i].init= old->init;
|
|
|
|
cur[i].deinit= old->deinit;
|
|
|
|
cur[i].version= old->version;
|
|
|
|
cur[i].status_vars= old->status_vars;
|
|
|
|
cur[i].system_vars= old->system_vars;
|
2010-04-01 16:34:51 +02:00
|
|
|
/*
|
|
|
|
Something like this should be added to process
|
|
|
|
new mysql plugin versions:
|
|
|
|
if (plugin_dl->mysqlversion > 0x0101)
|
|
|
|
{
|
2010-06-16 09:52:12 +02:00
|
|
|
cur[i].newfield= CONSTANT_MEANS_UNKNOWN;
|
2010-04-01 16:34:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-16 09:52:12 +02:00
|
|
|
cur[i].newfield= old->newfield;
|
2010-04-01 16:34:51 +02:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
/* Maria only fields */
|
2010-06-16 09:52:12 +02:00
|
|
|
cur[i].version_info= "Unknown";
|
|
|
|
cur[i].maturity= MariaDB_PLUGIN_MATURITY_UNKNOWN;
|
2010-04-01 16:34:51 +02:00
|
|
|
}
|
|
|
|
plugin_dl->allocated= true;
|
|
|
|
plugin_dl->plugins= (struct st_maria_plugin *)cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Reads data from maria plugin interface
|
|
|
|
|
|
|
|
@param plugin_dl Structure where the data should be put
|
|
|
|
@param sym Reverence on version info
|
|
|
|
@param dlpath Path to the module
|
2018-05-18 10:28:53 +02:00
|
|
|
@param MyFlags Where errors should be reported (0 or ME_ERROR_LOG)
|
2010-04-01 16:34:51 +02:00
|
|
|
|
|
|
|
@retval FALSE OK
|
|
|
|
@retval TRUE ERROR
|
|
|
|
*/
|
|
|
|
|
|
|
|
static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl,
|
2018-05-18 10:28:53 +02:00
|
|
|
void *sym, char *dlpath, myf MyFlags)
|
2010-04-01 16:34:51 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("read_maria_plugin_info");
|
|
|
|
|
|
|
|
/* Determine interface version */
|
|
|
|
if (!(sym))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Actually this branch impossible because in case of absence of maria
|
|
|
|
version we try mysql version.
|
|
|
|
*/
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags,
|
2010-04-01 16:34:51 +02:00
|
|
|
maria_plugin_interface_version_sym);
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
plugin_dl->mariaversion= *(int *)sym;
|
|
|
|
plugin_dl->mysqlversion= 0;
|
|
|
|
/* Versioning */
|
|
|
|
if (plugin_dl->mariaversion < min_maria_plugin_interface_version ||
|
|
|
|
(plugin_dl->mariaversion >> 8) > (MARIA_PLUGIN_INTERFACE_VERSION >> 8))
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, ENOEXEC,
|
2010-04-01 16:34:51 +02:00
|
|
|
"plugin interface version mismatch");
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
/* Find plugin declarations */
|
|
|
|
if (!(sym= dlsym(plugin_dl->handle, maria_plugin_declarations_sym)))
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, maria_plugin_declarations_sym);
|
2010-04-01 16:34:51 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
if (plugin_dl->mariaversion != MARIA_PLUGIN_INTERFACE_VERSION)
|
|
|
|
{
|
|
|
|
uint sizeof_st_plugin;
|
|
|
|
struct st_maria_plugin *old, *cur;
|
|
|
|
char *ptr= (char *)sym;
|
|
|
|
|
|
|
|
if ((sym= dlsym(plugin_dl->handle, maria_sizeof_st_plugin_sym)))
|
|
|
|
sizeof_st_plugin= *(int *)sym;
|
|
|
|
else
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, maria_sizeof_st_plugin_sym);
|
2010-04-01 16:34:51 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sizeof_st_plugin != sizeof(st_mysql_plugin))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i= 0;
|
|
|
|
((struct st_maria_plugin *)(ptr + i * sizeof_st_plugin))->info;
|
|
|
|
i++)
|
|
|
|
/* no op */;
|
|
|
|
|
|
|
|
cur= (struct st_maria_plugin*)
|
2020-01-29 13:50:26 +01:00
|
|
|
my_malloc(key_memory_mysql_plugin, (i + 1) * sizeof(struct st_maria_plugin),
|
2010-04-01 16:34:51 +02:00
|
|
|
MYF(MY_ZEROFILL|MY_WME));
|
|
|
|
if (!cur)
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_OUTOFMEMORY, MyFlags,
|
2011-07-02 22:12:12 +02:00
|
|
|
static_cast<int>(plugin_dl->dl.length));
|
2010-04-01 16:34:51 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
All st_plugin fields not initialized in the plugin explicitly, are
|
|
|
|
set to 0. It matches C standard behaviour for struct initializers that
|
|
|
|
have less values than the struct definition.
|
|
|
|
*/
|
|
|
|
for (i=0;
|
|
|
|
(old= (struct st_maria_plugin *)(ptr + i * sizeof_st_plugin))->info;
|
|
|
|
i++)
|
2013-03-25 23:03:13 +01:00
|
|
|
memcpy(cur + i, old, MY_MIN(sizeof(cur[i]), sizeof_st_plugin));
|
2010-04-01 16:34:51 +02:00
|
|
|
|
|
|
|
sym= cur;
|
|
|
|
plugin_dl->allocated= true;
|
|
|
|
}
|
2013-09-09 13:56:35 +02:00
|
|
|
else
|
|
|
|
sym= ptr;
|
2010-04-01 16:34:51 +02:00
|
|
|
}
|
|
|
|
plugin_dl->plugins= (struct st_maria_plugin *)sym;
|
|
|
|
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
2010-04-08 11:51:22 +02:00
|
|
|
#endif /* HAVE_DLOPEN */
|
2010-04-01 16:34:51 +02:00
|
|
|
|
2018-05-18 10:28:53 +02:00
|
|
|
static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, myf MyFlags)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
#ifdef HAVE_DLOPEN
|
|
|
|
char dlpath[FN_REFLEN];
|
2018-02-06 13:55:58 +01:00
|
|
|
size_t plugin_dir_len,i;
|
|
|
|
uint dummy_errors;
|
2013-04-07 14:41:05 +02:00
|
|
|
struct st_plugin_dl *tmp= 0, plugin_dl;
|
2005-11-05 12:20:35 +01:00
|
|
|
void *sym;
|
2013-12-09 12:39:13 +01:00
|
|
|
st_ptr_backup tmp_backup[array_elements(list_of_services)];
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_ENTER("plugin_dl_add");
|
2010-12-02 08:14:43 +01:00
|
|
|
DBUG_PRINT("enter", ("dl->str: '%s', dl->length: %d",
|
|
|
|
dl->str, (int) dl->length));
|
2013-04-07 14:41:05 +02:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
plugin_dir_len= strlen(opt_plugin_dir);
|
|
|
|
/*
|
|
|
|
Ensure that the dll doesn't have a path.
|
|
|
|
This is done to ensure that only approved libraries from the
|
|
|
|
plugin directory are used (to make this even remotely secure).
|
|
|
|
*/
|
2019-07-26 22:42:35 +02:00
|
|
|
if (check_string_char_length((LEX_CSTRING *) dl, 0, NAME_CHAR_LEN,
|
2007-04-03 13:13:27 +02:00
|
|
|
system_charset_info, 1) ||
|
2019-07-24 13:14:03 +02:00
|
|
|
check_valid_path(dl->str, dl->length) ||
|
2005-11-05 12:20:35 +01:00
|
|
|
plugin_dir_len + dl->length + 1 >= FN_REFLEN)
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_UDF_NO_PATHS, MyFlags);
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
/* If this dll is already loaded just increase ref_count. */
|
|
|
|
if ((tmp= plugin_dl_find(dl)))
|
|
|
|
{
|
|
|
|
tmp->ref_count++;
|
|
|
|
DBUG_RETURN(tmp);
|
|
|
|
}
|
2006-01-01 16:43:34 +01:00
|
|
|
bzero(&plugin_dl, sizeof(plugin_dl));
|
2005-11-05 12:20:35 +01:00
|
|
|
/* Compile dll path */
|
2012-05-18 15:40:16 +02:00
|
|
|
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NullS);
|
2012-01-16 11:04:28 +01:00
|
|
|
(void) unpack_filename(dlpath, dlpath);
|
2005-11-05 12:20:35 +01:00
|
|
|
plugin_dl.ref_count= 1;
|
|
|
|
/* Open new dll handle */
|
|
|
|
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_NOW)))
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, errno, my_dlerror(dlpath));
|
2013-04-07 14:41:05 +02:00
|
|
|
goto ret;
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2013-04-09 23:27:29 +02:00
|
|
|
dlopen_count++;
|
2010-04-01 16:34:51 +02:00
|
|
|
|
2015-03-30 14:16:34 +02:00
|
|
|
#ifdef HAVE_LINK_H
|
|
|
|
if (global_system_variables.log_warnings > 2)
|
|
|
|
{
|
|
|
|
struct link_map *lm = (struct link_map*) plugin_dl.handle;
|
2017-09-19 19:45:17 +02:00
|
|
|
sql_print_information("Loaded '%s' with offset 0x%zx", dl->str, (size_t)lm->l_addr);
|
2015-03-30 14:16:34 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-01 16:34:51 +02:00
|
|
|
/* Checks which plugin interface present and reads info */
|
|
|
|
if (!(sym= dlsym(plugin_dl.handle, maria_plugin_interface_version_sym)))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2010-04-01 16:34:51 +02:00
|
|
|
if (read_mysql_plugin_info(&plugin_dl,
|
|
|
|
dlsym(plugin_dl.handle,
|
|
|
|
plugin_interface_version_sym),
|
|
|
|
dlpath,
|
2018-05-18 10:28:53 +02:00
|
|
|
MyFlags))
|
2013-04-07 14:41:05 +02:00
|
|
|
goto ret;
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2010-04-01 16:34:51 +02:00
|
|
|
else
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
if (read_maria_plugin_info(&plugin_dl, sym, dlpath, MyFlags))
|
2013-04-07 14:41:05 +02:00
|
|
|
goto ret;
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2009-11-02 21:05:42 +01:00
|
|
|
|
|
|
|
/* link the services in */
|
|
|
|
for (i= 0; i < array_elements(list_of_services); i++)
|
|
|
|
{
|
|
|
|
if ((sym= dlsym(plugin_dl.handle, list_of_services[i].name)))
|
|
|
|
{
|
2013-12-09 12:39:13 +01:00
|
|
|
void **ptr= (void **)sym;
|
|
|
|
uint ver= (uint)(intptr)*ptr;
|
2009-11-02 21:05:42 +01:00
|
|
|
if (ver > list_of_services[i].version ||
|
|
|
|
(ver >> 8) < (list_of_services[i].version >> 8))
|
|
|
|
{
|
|
|
|
char buf[MYSQL_ERRMSG_SIZE];
|
|
|
|
my_snprintf(buf, sizeof(buf),
|
|
|
|
"service '%s' interface version mismatch",
|
|
|
|
list_of_services[i].name);
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, ENOEXEC, buf);
|
2013-04-07 14:41:05 +02:00
|
|
|
goto ret;
|
2009-11-02 21:05:42 +01:00
|
|
|
}
|
2013-12-09 12:39:13 +01:00
|
|
|
tmp_backup[plugin_dl.nbackups++].save(ptr);
|
|
|
|
*ptr= list_of_services[i].service;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin_dl.nbackups)
|
|
|
|
{
|
|
|
|
size_t bytes= plugin_dl.nbackups * sizeof(plugin_dl.ptr_backup[0]);
|
2020-01-29 13:50:26 +01:00
|
|
|
plugin_dl.ptr_backup= (st_ptr_backup *)my_malloc(key_memory_mysql_plugin_dl,
|
|
|
|
bytes, MYF(0));
|
2013-12-09 12:39:13 +01:00
|
|
|
if (!plugin_dl.ptr_backup)
|
|
|
|
{
|
|
|
|
restore_ptr_backup(plugin_dl.nbackups, tmp_backup);
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_OUTOFMEMORY, MyFlags, bytes);
|
2013-12-09 12:39:13 +01:00
|
|
|
goto ret;
|
2009-11-02 21:05:42 +01:00
|
|
|
}
|
2013-12-09 12:39:13 +01:00
|
|
|
memcpy(plugin_dl.ptr_backup, tmp_backup, bytes);
|
2009-11-02 21:05:42 +01:00
|
|
|
}
|
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
/* Duplicate and convert dll name */
|
|
|
|
plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1;
|
2020-01-29 13:50:26 +01:00
|
|
|
if (! (plugin_dl.dl.str= (char*) my_malloc(key_memory_mysql_plugin_dl,
|
|
|
|
plugin_dl.dl.length, MYF(0))))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_OUTOFMEMORY, MyFlags,
|
2011-05-21 10:21:08 +02:00
|
|
|
static_cast<int>(plugin_dl.dl.length));
|
2013-04-07 14:41:05 +02:00
|
|
|
goto ret;
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2017-04-23 18:39:57 +02:00
|
|
|
plugin_dl.dl.length= copy_and_convert((char*) plugin_dl.dl.str,
|
|
|
|
plugin_dl.dl.length,
|
|
|
|
files_charset_info, dl->str,
|
|
|
|
dl->length, system_charset_info,
|
|
|
|
&dummy_errors);
|
|
|
|
((char*) plugin_dl.dl.str)[plugin_dl.dl.length]= 0;
|
2005-11-05 12:20:35 +01:00
|
|
|
/* Add this dll to array */
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
if (! (tmp= plugin_dl_insert_or_reuse(&plugin_dl)))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_OUTOFMEMORY, MyFlags,
|
2011-05-21 10:21:08 +02:00
|
|
|
static_cast<int>(sizeof(struct st_plugin_dl)));
|
2013-04-07 14:41:05 +02:00
|
|
|
goto ret;
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2013-04-07 14:41:05 +02:00
|
|
|
|
|
|
|
ret:
|
|
|
|
if (!tmp)
|
|
|
|
free_plugin_mem(&plugin_dl);
|
|
|
|
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
DBUG_RETURN(tmp);
|
2013-04-07 14:41:05 +02:00
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
#else
|
|
|
|
DBUG_ENTER("plugin_dl_add");
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_FEATURE_DISABLED, MyFlags, "plugin", "HAVE_DLOPEN");
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 14:41:05 +02:00
|
|
|
static void plugin_dl_del(struct st_plugin_dl *plugin_dl)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
DBUG_ENTER("plugin_dl_del");
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2013-04-07 14:41:05 +02:00
|
|
|
if (!plugin_dl)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2013-04-07 14:41:05 +02:00
|
|
|
/* Do not remove this element, unless no other plugin uses this dll. */
|
|
|
|
if (! --plugin_dl->ref_count)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2013-04-07 14:41:05 +02:00
|
|
|
free_plugin_mem(plugin_dl);
|
|
|
|
bzero(plugin_dl, sizeof(struct st_plugin_dl));
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2013-04-07 14:41:05 +02:00
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
static struct st_plugin_int *plugin_find_internal(const LEX_CSTRING *name,
|
|
|
|
int type)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
DBUG_ENTER("plugin_find_internal");
|
|
|
|
if (! initialized)
|
|
|
|
DBUG_RETURN(0);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
if (type == MYSQL_ANY_PLUGIN)
|
|
|
|
{
|
|
|
|
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
|
|
|
{
|
|
|
|
struct st_plugin_int *plugin= (st_plugin_int *)
|
2009-10-14 18:37:38 +02:00
|
|
|
my_hash_search(&plugin_hash[i], (const uchar *)name->str, name->length);
|
2006-01-07 14:41:57 +01:00
|
|
|
if (plugin)
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBUG_RETURN((st_plugin_int *)
|
2009-10-14 18:37:38 +02:00
|
|
|
my_hash_search(&plugin_hash[type], (const uchar *)name->str,
|
|
|
|
name->length));
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
static SHOW_COMP_OPTION plugin_status(const LEX_CSTRING *name, int type)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
SHOW_COMP_OPTION rc= SHOW_OPTION_NO;
|
2005-11-05 12:20:35 +01:00
|
|
|
struct st_plugin_int *plugin;
|
|
|
|
DBUG_ENTER("plugin_is_ready");
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
if ((plugin= plugin_find_internal(name, type)))
|
|
|
|
{
|
|
|
|
rc= SHOW_OPTION_DISABLED;
|
|
|
|
if (plugin->state == PLUGIN_IS_READY)
|
|
|
|
rc= SHOW_OPTION_YES;
|
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
bool plugin_is_ready(const LEX_CSTRING *name, int type)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
bool rc= FALSE;
|
|
|
|
if (plugin_status(name, type) == SHOW_OPTION_YES)
|
|
|
|
rc= TRUE;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-29 13:36:01 +02:00
|
|
|
SHOW_COMP_OPTION plugin_status(const char *name, size_t len, int type)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING plugin_name= { name, len };
|
2009-12-22 10:35:56 +01:00
|
|
|
return plugin_status(&plugin_name, type);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-20 16:11:14 +02:00
|
|
|
/*
|
|
|
|
If LEX is passed non-NULL, an automatic unlock of the plugin will happen
|
|
|
|
in the LEX destructor.
|
|
|
|
*/
|
2017-10-12 11:30:02 +02:00
|
|
|
static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc,
|
|
|
|
uint state_mask= PLUGIN_IS_READY |
|
2017-10-18 15:14:39 +02:00
|
|
|
PLUGIN_IS_UNINITIALIZED |
|
|
|
|
PLUGIN_IS_DELETED)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
st_plugin_int *pi= plugin_ref_to_int(rc);
|
|
|
|
DBUG_ENTER("intern_plugin_lock");
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2017-10-12 11:30:02 +02:00
|
|
|
if (pi->state & state_mask)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref plugin;
|
|
|
|
#ifdef DBUG_OFF
|
2010-03-08 18:05:09 +01:00
|
|
|
/*
|
|
|
|
In optimized builds we don't do reference counting for built-in
|
|
|
|
(plugin->plugin_dl == 0) plugins.
|
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!pi->plugin_dl)
|
|
|
|
DBUG_RETURN(pi);
|
|
|
|
|
|
|
|
plugin= pi;
|
|
|
|
#else
|
2007-03-29 06:29:16 +02:00
|
|
|
/*
|
|
|
|
For debugging, we do an additional malloc which allows the
|
|
|
|
memory manager and/or valgrind to track locked references and
|
2009-11-02 21:05:42 +01:00
|
|
|
double unlocks to aid resolving reference counting problems.
|
2007-03-29 06:29:16 +02:00
|
|
|
*/
|
2020-01-29 13:50:26 +01:00
|
|
|
if (!(plugin= (plugin_ref) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(pi),
|
|
|
|
MYF(MY_WME))))
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
|
|
|
|
*plugin= pi;
|
|
|
|
#endif
|
|
|
|
pi->ref_count++;
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("lock",("thd: %p plugin: \"%s\" LOCK ref_count: %d",
|
|
|
|
current_thd, pi->name.str, pi->ref_count));
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
if (lex)
|
2007-05-24 18:47:58 +02:00
|
|
|
insert_dynamic(&lex->plugins, (uchar*)&plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-20 16:11:14 +02:00
|
|
|
/*
|
|
|
|
Notes on lifetime:
|
|
|
|
|
|
|
|
If THD is passed as non-NULL (and with a non-NULL thd->lex), an entry is made
|
|
|
|
in the thd->lex which will cause an automatic unlock of the plugin in the LEX
|
|
|
|
destructor. In this case, no manual unlock must be done.
|
|
|
|
|
|
|
|
Otherwise, when passing a NULL THD, the caller must arrange that plugin
|
|
|
|
unlock happens later.
|
|
|
|
*/
|
2011-04-25 17:22:25 +02:00
|
|
|
plugin_ref plugin_lock(THD *thd, plugin_ref ptr)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-04-16 18:16:17 +02:00
|
|
|
LEX *lex= thd ? thd->lex : 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref rc;
|
|
|
|
DBUG_ENTER("plugin_lock");
|
2010-03-08 18:05:09 +01:00
|
|
|
|
|
|
|
#ifdef DBUG_OFF
|
|
|
|
/*
|
|
|
|
In optimized builds we don't do reference counting for built-in
|
|
|
|
(plugin->plugin_dl == 0) plugins.
|
|
|
|
|
|
|
|
Note that we access plugin->plugin_dl outside of LOCK_plugin, and for
|
|
|
|
dynamic plugins a 'plugin' could correspond to plugin that was unloaded
|
|
|
|
meanwhile! But because st_plugin_int is always allocated on
|
|
|
|
plugin_mem_root, the pointer can never be invalid - the memory is never
|
|
|
|
freed.
|
|
|
|
Of course, the memory that 'plugin' points to can be overwritten by
|
|
|
|
another plugin being loaded, but plugin->plugin_dl can never change
|
|
|
|
from zero to non-zero or vice versa.
|
|
|
|
That is, it's always safe to check for plugin->plugin_dl==0 even
|
|
|
|
without a mutex.
|
|
|
|
*/
|
|
|
|
if (! plugin_dlib(ptr))
|
2012-04-18 04:00:08 +02:00
|
|
|
{
|
|
|
|
plugin_ref_to_int(ptr)->locks_total++;
|
2010-03-08 18:05:09 +01:00
|
|
|
DBUG_RETURN(ptr);
|
2012-04-18 04:00:08 +02:00
|
|
|
}
|
2010-03-08 18:05:09 +01:00
|
|
|
#endif
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2012-04-18 04:00:08 +02:00
|
|
|
plugin_ref_to_int(ptr)->locks_total++;
|
2013-04-07 15:40:59 +02:00
|
|
|
rc= intern_plugin_lock(lex, ptr);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-20 16:11:14 +02:00
|
|
|
/*
|
|
|
|
Notes on lifetime:
|
|
|
|
|
|
|
|
If THD is passed as non-NULL (and with a non-NULL thd->lex), an entry is made
|
|
|
|
in the thd->lex which will cause an automatic unlock of the plugin in the LEX
|
|
|
|
destructor. In this case, no manual unlock must be done.
|
|
|
|
|
|
|
|
Otherwise, when passing a NULL THD, the caller must arrange that plugin
|
|
|
|
unlock happens later.
|
|
|
|
*/
|
2017-04-23 18:39:57 +02:00
|
|
|
plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name, int type)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-04-16 18:16:17 +02:00
|
|
|
LEX *lex= thd ? thd->lex : 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_ref rc= NULL;
|
|
|
|
st_plugin_int *plugin;
|
2007-04-18 14:37:57 +02:00
|
|
|
DBUG_ENTER("plugin_lock_by_name");
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
if ((plugin= plugin_find_internal(name, type)))
|
2013-04-07 15:40:59 +02:00
|
|
|
rc= intern_plugin_lock(lex, plugin_int_to_ref(plugin));
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
|
|
|
|
{
|
|
|
|
uint i;
|
2007-05-24 19:39:24 +02:00
|
|
|
struct st_plugin_int *tmp;
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
DBUG_ENTER("plugin_insert_or_reuse");
|
|
|
|
for (i= 0; i < plugin_array.elements; i++)
|
|
|
|
{
|
2007-05-24 19:39:24 +02:00
|
|
|
tmp= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
if (tmp->state == PLUGIN_IS_FREED)
|
|
|
|
{
|
|
|
|
memcpy(tmp, plugin, sizeof(struct st_plugin_int));
|
|
|
|
DBUG_RETURN(tmp);
|
|
|
|
}
|
|
|
|
}
|
2007-05-31 21:28:04 +02:00
|
|
|
if (insert_dynamic(&plugin_array, (uchar*)&plugin))
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
DBUG_RETURN(0);
|
2007-05-24 19:39:24 +02:00
|
|
|
tmp= *dynamic_element(&plugin_array, plugin_array.elements - 1,
|
|
|
|
struct st_plugin_int **)=
|
2007-05-31 22:07:44 +02:00
|
|
|
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)plugin,
|
2007-05-24 19:39:24 +02:00
|
|
|
sizeof(struct st_plugin_int));
|
|
|
|
DBUG_RETURN(tmp);
|
WL#2575 - Fulltext: Parser plugin for FTS
Manual merge.
Makefile.am:
Added new 'plugin' subdir.
configure.in:
Added plugin related makefiles.
include/my_base.h:
Added HA_OPEN_FROM_SQL_LAYER flag - indicates that a table was openned from the sql layer.
Added HA_OPTION_RELIES_ON_SQL_LAYER flag - indicates that a table relies on the sql layer.
Added HA_CREATE_RELIES_ON_SQL_LAYER flag - indicates that a table must be created with
HA_OPTION_RELIES_ON_SQL_LAYER flag.
include/myisam.h:
Distinct fulltext parser number added.
include/plugin.h:
Revise comment.
sql/ha_myisam.cc:
Pass HA_OPEN_FROM_SQL_LAYER flag to mi_open().
Pass HA_CREATE_RELIES_ON_SQL_LAYER flag to mi_create().
sql/sql_plugin.cc:
Reuse "unused" dynamic array elements.
A check for plugin info interface version.
sql/sql_plugin.h:
Added plugin_type_names[] - string plugin type names.
sql/sql_show.cc:
Use plugin_type_names array instead of switch to find literal parser name representation.
sql/sql_table.cc:
Fixed that ALTER TABLE ... ADD INDEX loses WITH PARSER info.
storage/myisam/ft_boolean_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_nlq_search.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to parser->parse().
storage/myisam/ft_parser.c:
Added two functions:
ftparser_call_initializer() - calls parser->init() function if specified and parser is not yet
initialized. Returns MYSQL_FTPARSER_PARAM *.
ftparser_call_deinitializer() - calls parser->deinit() function if specified and parser was
initialized. Deinitializes all parsers.
ft_parse() accepts additional param now - MYSQL_FTPARSER_PARM and passes it to parser->parse().
storage/myisam/ft_update.c:
Call fulltext parser init() function, pass MYSQL_FTPARSER_PARAM, returned by
ftparser_call_initializer(), to _mi_ft_parse().
_mi_ft_parse() accepts additional param now - MYSQL_FTPARSER_PARAM and passes
it to parser->parse().
storage/myisam/ftdefs.h:
Prototypes for new functions were added. MYSQL_FTPARSER_PARAM was added
to ft_parse and _mi_ft_parse().
storage/myisam/mi_close.c:
Free ftparser_param allocated by ftparser_call_initializer().
storage/myisam/mi_create.c:
If a table relies on the sql layer, set HA_OPTION_RELIES_ON_SQL_LAYER.
storage/myisam/mi_locking.c:
Call deinitializer for each initialized parser.
storage/myisam/mi_open.c:
Set default values for share->ftparser and keydef->ftparser_nr.
If a table is openned from the non-sql layer and HA_OPTION_RELIES_ON_SQL_LAYER is set, raise
HA_ERR_UNSUPPORTED error.
storage/myisam/myisamdef.h:
Added number of distinct parsers to MYISAM_SHARE.
Added ftparser_param to MI_INFO.
plugin/Makefile.am:
New BitKeeper file ``plugin/Makefile.am''
plugin/fulltext/Makefile.am:
New BitKeeper file ``plugin/fulltext/Makefile.am''
plugin/fulltext/plugin_example.c:
New BitKeeper file ``plugin/fulltext/plugin_example.c''
2005-12-28 13:05:30 +01:00
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
NOTE
|
|
|
|
Requires that a write-lock is held on LOCK_system_variables_hash
|
|
|
|
*/
|
2018-07-04 11:27:20 +02:00
|
|
|
static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists,
|
2018-08-23 21:41:22 +02:00
|
|
|
const LEX_CSTRING *name, LEX_CSTRING *dl, myf MyFlags)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2014-08-06 14:02:05 +02:00
|
|
|
struct st_plugin_int tmp, *maybe_dupe;
|
2010-04-01 16:34:51 +02:00
|
|
|
struct st_maria_plugin *plugin;
|
2012-12-15 18:24:11 +01:00
|
|
|
uint oks= 0, errs= 0, dupes= 0;
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_ENTER("plugin_add");
|
2012-06-13 11:59:45 +02:00
|
|
|
DBUG_PRINT("enter", ("name: %s dl: %s", name->str, dl->str));
|
|
|
|
|
2012-03-05 21:48:06 +01:00
|
|
|
if (name->str && plugin_find_internal(name, MYSQL_ANY_PLUGIN))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2018-07-04 11:27:20 +02:00
|
|
|
if (if_not_exists)
|
2018-08-23 21:41:22 +02:00
|
|
|
MyFlags|= ME_NOTE;
|
|
|
|
my_error(ER_PLUGIN_INSTALLED, MyFlags, name->str);
|
|
|
|
DBUG_RETURN(if_not_exists ? INSTALL_FAIL_WARN_OK : INSTALL_FAIL_NOT_OK);
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2007-04-24 10:40:23 +02:00
|
|
|
/* Clear the whole struct to catch future extensions. */
|
|
|
|
bzero((char*) &tmp, sizeof(tmp));
|
2012-03-05 21:48:06 +01:00
|
|
|
fix_dl_name(tmp_root, dl);
|
2018-05-18 10:28:53 +02:00
|
|
|
if (! (tmp.plugin_dl= plugin_dl_add(dl, MyFlags)))
|
2018-07-04 11:27:20 +02:00
|
|
|
DBUG_RETURN(INSTALL_FAIL_NOT_OK);
|
2005-11-05 12:20:35 +01:00
|
|
|
/* Find plugin by name */
|
|
|
|
for (plugin= tmp.plugin_dl->plugins; plugin->info; plugin++)
|
|
|
|
{
|
2012-03-05 21:48:06 +01:00
|
|
|
tmp.name.str= (char *)plugin->name;
|
|
|
|
tmp.name.length= strlen(plugin->name);
|
|
|
|
|
|
|
|
if (plugin->type < 0 || plugin->type >= MYSQL_MAX_PLUGIN_TYPE_NUM)
|
2014-11-21 14:45:25 +01:00
|
|
|
continue; // invalid plugin type
|
|
|
|
|
|
|
|
if (plugin->type == MYSQL_UDF_PLUGIN ||
|
2014-11-25 21:58:14 +01:00
|
|
|
(plugin->type == MariaDB_PASSWORD_VALIDATION_PLUGIN &&
|
|
|
|
tmp.plugin_dl->mariaversion == 0))
|
2014-11-21 14:45:25 +01:00
|
|
|
continue; // unsupported plugin type
|
2012-03-05 21:48:06 +01:00
|
|
|
|
2020-01-26 17:27:13 +01:00
|
|
|
if (name->str && system_charset_info->strnncoll(name->str, name->length,
|
|
|
|
tmp.name.str, tmp.name.length))
|
2012-03-05 21:48:06 +01:00
|
|
|
continue; // plugin name doesn't match
|
|
|
|
|
2014-08-06 14:02:05 +02:00
|
|
|
if (!name->str &&
|
|
|
|
(maybe_dupe= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)))
|
2012-12-15 18:24:11 +01:00
|
|
|
{
|
2014-08-06 14:02:05 +02:00
|
|
|
if (plugin->name != maybe_dupe->plugin->name)
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_UDF_EXISTS, MyFlags, plugin->name);
|
2018-07-04 11:27:20 +02:00
|
|
|
DBUG_RETURN(INSTALL_FAIL_NOT_OK);
|
2014-08-06 14:02:05 +02:00
|
|
|
}
|
2012-12-15 18:24:11 +01:00
|
|
|
dupes++;
|
2012-03-05 21:48:06 +01:00
|
|
|
continue; // already installed
|
2012-12-15 18:24:11 +01:00
|
|
|
}
|
|
|
|
struct st_plugin_int *tmp_plugin_ptr;
|
|
|
|
if (*(int*)plugin->info <
|
|
|
|
min_plugin_info_interface_version[plugin->type] ||
|
|
|
|
((*(int*)plugin->info) >> 8) >
|
|
|
|
(cur_plugin_info_interface_version[plugin->type] >> 8))
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
strxnmov(buf, sizeof(buf) - 1, "API version for ",
|
|
|
|
plugin_type_names[plugin->type].str,
|
|
|
|
" plugin ", tmp.name.str,
|
|
|
|
" not supported by this version of the server", NullS);
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dl->str, ENOEXEC, buf);
|
2012-12-15 18:24:11 +01:00
|
|
|
goto err;
|
|
|
|
}
|
2017-11-24 22:56:13 +01:00
|
|
|
|
2012-12-15 18:24:11 +01:00
|
|
|
if (plugin_maturity_map[plugin->maturity] < plugin_maturity)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
strxnmov(buf, sizeof(buf) - 1, "Loading of ",
|
|
|
|
plugin_maturity_names[plugin->maturity],
|
|
|
|
" plugin ", tmp.name.str,
|
|
|
|
" is prohibited by --plugin-maturity=",
|
|
|
|
plugin_maturity_names[plugin_maturity],
|
|
|
|
NullS);
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dl->str, EPERM, buf);
|
2012-12-15 18:24:11 +01:00
|
|
|
goto err;
|
|
|
|
}
|
2017-11-24 22:56:13 +01:00
|
|
|
else if (plugin_maturity_map[plugin->maturity] < SERVER_MATURITY_LEVEL)
|
|
|
|
{
|
|
|
|
sql_print_warning("Plugin '%s' is of maturity level %s while the server is %s",
|
|
|
|
tmp.name.str,
|
|
|
|
plugin_maturity_names[plugin->maturity],
|
|
|
|
plugin_maturity_names[SERVER_MATURITY_LEVEL]);
|
|
|
|
}
|
|
|
|
|
2012-12-15 18:24:11 +01:00
|
|
|
tmp.plugin= plugin;
|
|
|
|
tmp.ref_count= 0;
|
|
|
|
tmp.state= PLUGIN_IS_UNINITIALIZED;
|
|
|
|
tmp.load_option= PLUGIN_ON;
|
|
|
|
|
|
|
|
if (!(tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))
|
|
|
|
goto err;
|
|
|
|
if (my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
|
|
|
|
tmp_plugin_ptr->state= PLUGIN_IS_FREED;
|
2020-01-29 13:50:26 +01:00
|
|
|
init_alloc_root(key_memory_plugin_int_mem_root, &tmp_plugin_ptr->mem_root,
|
|
|
|
4096, 4096, MYF(0));
|
2012-03-05 21:48:06 +01:00
|
|
|
|
|
|
|
if (name->str)
|
2018-07-04 11:27:20 +02:00
|
|
|
DBUG_RETURN(INSTALL_GOOD); // all done
|
2012-03-05 21:48:06 +01:00
|
|
|
|
|
|
|
oks++;
|
|
|
|
tmp.plugin_dl->ref_count++;
|
|
|
|
continue; // otherwise - go on
|
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
err:
|
2012-03-05 21:48:06 +01:00
|
|
|
errs++;
|
|
|
|
if (name->str)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-12-15 18:24:11 +01:00
|
|
|
DBUG_ASSERT(!name->str || !dupes); // dupes is ONLY for name->str == 0
|
|
|
|
|
|
|
|
if (errs == 0 && oks == 0 && !dupes) // no plugin was found
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, name->str);
|
2012-03-05 21:48:06 +01:00
|
|
|
|
2013-04-07 14:41:05 +02:00
|
|
|
plugin_dl_del(tmp.plugin_dl);
|
2018-07-04 11:27:20 +02:00
|
|
|
if (errs > 0 || oks + dupes == 0)
|
|
|
|
DBUG_RETURN(INSTALL_FAIL_NOT_OK);
|
|
|
|
DBUG_RETURN(INSTALL_GOOD);
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
|
|
|
|
2016-04-15 20:47:45 +02:00
|
|
|
static void plugin_variables_deinit(struct st_plugin_int *plugin)
|
|
|
|
{
|
|
|
|
|
|
|
|
for (sys_var *var= plugin->system_vars; var; var= var->next)
|
|
|
|
(*var->test_load)= FALSE;
|
|
|
|
mysql_del_sys_var_chain(plugin->system_vars);
|
|
|
|
}
|
2005-11-05 12:20:35 +01:00
|
|
|
|
2007-04-13 19:23:02 +02:00
|
|
|
static void plugin_deinitialize(struct st_plugin_int *plugin, bool ref_check)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
we don't want to hold the LOCK_plugin mutex as it may cause
|
|
|
|
deinitialization to deadlock if plugins have worker threads
|
|
|
|
with plugin locks
|
|
|
|
*/
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_not_owner(&LOCK_plugin);
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2006-09-07 15:01:36 +02:00
|
|
|
if (plugin->plugin->status_vars)
|
|
|
|
{
|
2013-04-09 23:27:33 +02:00
|
|
|
/*
|
|
|
|
historical ndb behavior caused MySQL plugins to specify
|
|
|
|
status var names in full, with the plugin name prefix.
|
|
|
|
this was never fixed in MySQL.
|
2014-08-21 18:11:46 +02:00
|
|
|
MariaDB fixes that but supports MySQL style too.
|
2006-09-07 15:01:36 +02:00
|
|
|
*/
|
2013-04-09 23:27:33 +02:00
|
|
|
SHOW_VAR *show_vars= plugin->plugin->status_vars;
|
|
|
|
SHOW_VAR tmp_array[2]= {
|
2006-09-07 15:01:36 +02:00
|
|
|
{plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},
|
|
|
|
{0, 0, SHOW_UNDEF}
|
|
|
|
};
|
2013-04-09 23:27:33 +02:00
|
|
|
if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length))
|
|
|
|
show_vars= tmp_array;
|
|
|
|
|
|
|
|
remove_status_vars(show_vars);
|
2006-09-07 15:01:36 +02:00
|
|
|
}
|
|
|
|
|
2006-09-15 19:28:00 +02:00
|
|
|
if (plugin_type_deinitialize[plugin->plugin->type])
|
|
|
|
{
|
|
|
|
if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin))
|
|
|
|
{
|
|
|
|
sql_print_error("Plugin '%s' of type %s failed deinitialization",
|
2006-11-01 18:41:09 +01:00
|
|
|
plugin->name.str, plugin_type_names[plugin->plugin->type].str);
|
2007-04-13 19:24:46 +02:00
|
|
|
}
|
2006-09-15 19:28:00 +02:00
|
|
|
}
|
|
|
|
else if (plugin->plugin->deinit)
|
2006-09-07 15:01:36 +02:00
|
|
|
{
|
|
|
|
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
|
2006-11-20 03:01:54 +01:00
|
|
|
if (plugin->plugin->deinit(plugin))
|
2006-08-29 20:58:12 +02:00
|
|
|
{
|
2006-09-07 15:01:36 +02:00
|
|
|
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
|
|
|
|
plugin->name.str));
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
2006-09-07 15:01:36 +02:00
|
|
|
}
|
|
|
|
plugin->state= PLUGIN_IS_UNINITIALIZED;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
if (ref_check && plugin->ref_count)
|
|
|
|
sql_print_error("Plugin '%s' has ref_count=%d after deinitialization.",
|
|
|
|
plugin->name.str, plugin->ref_count);
|
2016-04-15 20:47:45 +02:00
|
|
|
plugin_variables_deinit(plugin);
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
|
|
|
|
2006-09-07 15:01:36 +02:00
|
|
|
static void plugin_del(struct st_plugin_int *plugin)
|
|
|
|
{
|
2011-07-10 20:21:18 +02:00
|
|
|
DBUG_ENTER("plugin_del");
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2007-04-26 21:26:04 +02:00
|
|
|
/* Free allocated strings before deleting the plugin. */
|
2023-01-19 21:53:16 +01:00
|
|
|
plugin_vars_free_values(plugin->plugin->system_vars);
|
2014-02-03 15:22:39 +01:00
|
|
|
restore_ptr_backup(plugin->nbackups, plugin->ptr_backup);
|
2015-01-05 13:27:44 +01:00
|
|
|
if (plugin->plugin_dl)
|
|
|
|
{
|
|
|
|
my_hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin);
|
|
|
|
plugin_dl_del(plugin->plugin_dl);
|
|
|
|
plugin->state= PLUGIN_IS_FREED;
|
|
|
|
free_root(&plugin->mem_root, MYF(0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
plugin->state= PLUGIN_IS_UNINITIALIZED;
|
2006-09-07 15:01:36 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static void reap_plugins(void)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2015-06-22 17:17:03 +02:00
|
|
|
uint count;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct st_plugin_int *plugin, **reap, **list;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
if (!reap_needed)
|
|
|
|
return;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
reap_needed= false;
|
|
|
|
count= plugin_array.elements;
|
|
|
|
reap= (struct st_plugin_int **)my_alloca(sizeof(plugin)*(count+1));
|
|
|
|
*(reap++)= NULL;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2015-06-22 17:17:03 +02:00
|
|
|
for (uint i=0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2015-06-22 17:17:03 +02:00
|
|
|
HASH *hash= plugin_hash + plugin_type_initialization_order[i];
|
|
|
|
for (uint j= 0; j < hash->records; j++)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2015-06-22 17:17:03 +02:00
|
|
|
plugin= (struct st_plugin_int *) my_hash_element(hash, j);
|
|
|
|
if (plugin->state == PLUGIN_IS_DELETED && !plugin->ref_count)
|
|
|
|
{
|
|
|
|
/* change the status flag to prevent reaping by another thread */
|
|
|
|
plugin->state= PLUGIN_IS_DYING;
|
|
|
|
*(reap++)= plugin;
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2014-12-22 15:53:17 +01:00
|
|
|
list= reap;
|
|
|
|
while ((plugin= *(--list)))
|
|
|
|
plugin_deinitialize(plugin, true);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
while ((plugin= *(--reap)))
|
2006-09-07 15:01:36 +02:00
|
|
|
plugin_del(plugin);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
my_afree(reap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
st_plugin_int *pi;
|
|
|
|
DBUG_ENTER("intern_plugin_unlock");
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
if (!plugin)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
|
|
|
|
pi= plugin_ref_to_int(plugin);
|
|
|
|
|
|
|
|
#ifdef DBUG_OFF
|
|
|
|
if (!pi->plugin_dl)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
#else
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (lex)
|
|
|
|
{
|
2007-03-23 18:14:46 +01:00
|
|
|
/*
|
|
|
|
Remove one instance of this plugin from the use list.
|
|
|
|
We are searching backwards so that plugins locked last
|
|
|
|
could be unlocked faster - optimizing for LIFO semantics.
|
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
for (i= lex->plugins.elements - 1; i >= 0; i--)
|
|
|
|
if (plugin == *dynamic_element(&lex->plugins, i, plugin_ref*))
|
|
|
|
{
|
|
|
|
delete_dynamic_element(&lex->plugins, i);
|
|
|
|
break;
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
DBUG_ASSERT(i >= 0);
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
DBUG_ASSERT(pi->ref_count);
|
|
|
|
pi->ref_count--;
|
|
|
|
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("lock",("thd: %p plugin: \"%s\" UNLOCK ref_count: %d",
|
|
|
|
current_thd, pi->name.str, pi->ref_count));
|
2010-04-08 19:19:01 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (pi->state == PLUGIN_IS_DELETED && !pi->ref_count)
|
|
|
|
reap_needed= true;
|
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void plugin_unlock(THD *thd, plugin_ref plugin)
|
|
|
|
{
|
2007-04-16 18:16:17 +02:00
|
|
|
LEX *lex= thd ? thd->lex : 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ENTER("plugin_unlock");
|
|
|
|
if (!plugin)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
#ifdef DBUG_OFF
|
|
|
|
/* built-in plugins don't need ref counting */
|
|
|
|
if (!plugin_dlib(plugin))
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
#endif
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
intern_plugin_unlock(lex, plugin);
|
|
|
|
reap_plugins();
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void plugin_unlock_list(THD *thd, plugin_ref *list, uint count)
|
|
|
|
{
|
2007-04-16 18:16:17 +02:00
|
|
|
LEX *lex= thd ? thd->lex : 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ENTER("plugin_unlock_list");
|
2010-03-29 17:13:53 +02:00
|
|
|
if (count == 0)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ASSERT(list);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
while (count--)
|
|
|
|
intern_plugin_unlock(lex, *list++);
|
|
|
|
reap_plugins();
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2023-07-25 05:10:52 +02:00
|
|
|
static void print_init_failed_error(st_plugin_int *p)
|
|
|
|
{
|
|
|
|
sql_print_error("Plugin '%s' registration as a %s failed.",
|
|
|
|
p->name.str,
|
|
|
|
plugin_type_names[p->plugin->type].str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int plugin_do_initialize(struct st_plugin_int *plugin, uint &state)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("plugin_do_initialize");
|
|
|
|
mysql_mutex_assert_not_owner(&LOCK_plugin);
|
|
|
|
plugin_type_init init= plugin_type_initialize[plugin->plugin->type];
|
|
|
|
if (!init)
|
|
|
|
init= (plugin_type_init) plugin->plugin->init;
|
|
|
|
if (init)
|
|
|
|
if (int ret= init(plugin))
|
|
|
|
{
|
|
|
|
/* Plugin init failed and did not requested a retry */
|
|
|
|
if (ret != HA_ERR_RETRY_INIT)
|
|
|
|
print_init_failed_error(plugin);
|
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
state= PLUGIN_IS_READY; // plugin->init() succeeded
|
|
|
|
|
|
|
|
if (plugin->plugin->status_vars)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
historical ndb behavior caused MySQL plugins to specify
|
|
|
|
status var names in full, with the plugin name prefix.
|
|
|
|
this was never fixed in MySQL.
|
|
|
|
MariaDB fixes that but supports MySQL style too.
|
|
|
|
*/
|
|
|
|
SHOW_VAR *show_vars= plugin->plugin->status_vars;
|
|
|
|
SHOW_VAR tmp_array[2]= {{plugin->plugin->name,
|
|
|
|
(char *) plugin->plugin->status_vars, SHOW_ARRAY},
|
|
|
|
{0, 0, SHOW_UNDEF}};
|
|
|
|
if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length))
|
|
|
|
show_vars= tmp_array;
|
|
|
|
|
|
|
|
if (add_status_vars(show_vars))
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
2005-11-05 12:20:35 +01:00
|
|
|
|
2014-01-28 08:12:43 +01:00
|
|
|
static int plugin_initialize(MEM_ROOT *tmp_root, struct st_plugin_int *plugin,
|
|
|
|
int *argc, char **argv, bool options_only)
|
2005-12-21 19:18:40 +01:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
int ret= 1;
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_ENTER("plugin_initialize");
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2010-01-19 14:30:55 +01:00
|
|
|
uint state= plugin->state;
|
|
|
|
DBUG_ASSERT(state == PLUGIN_IS_UNINITIALIZED);
|
2009-12-16 12:56:36 +01:00
|
|
|
|
2010-01-19 14:30:55 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2014-01-28 08:12:43 +01:00
|
|
|
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_wrlock(&LOCK_system_variables_hash);
|
2014-01-28 08:12:43 +01:00
|
|
|
if (test_plugin_options(tmp_root, plugin, argc, argv))
|
|
|
|
state= PLUGIN_IS_DISABLED;
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
2014-01-28 08:12:43 +01:00
|
|
|
|
|
|
|
if (options_only || state == PLUGIN_IS_DISABLED)
|
|
|
|
{
|
2017-06-14 11:30:32 +02:00
|
|
|
ret= !options_only && plugin_is_forced(plugin);
|
2015-12-16 19:33:53 +01:00
|
|
|
state= PLUGIN_IS_DISABLED;
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
2023-07-25 05:10:52 +02:00
|
|
|
else
|
|
|
|
ret= plugin_do_initialize(plugin, state);
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2024-02-12 11:08:22 +01:00
|
|
|
if (ret && ret != HA_ERR_RETRY_INIT)
|
2016-04-15 20:47:45 +02:00
|
|
|
plugin_variables_deinit(plugin);
|
2014-01-28 08:12:43 +01:00
|
|
|
|
2010-01-19 14:30:55 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
plugin->state= state;
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_RETURN(ret);
|
2005-12-21 19:18:40 +01:00
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-08-13 15:11:25 +02:00
|
|
|
extern "C" uchar *get_plugin_hash_key(const uchar *, size_t *, my_bool);
|
|
|
|
extern "C" uchar *get_bookmark_hash_key(const uchar *, size_t *, my_bool);
|
|
|
|
|
|
|
|
|
|
|
|
uchar *get_plugin_hash_key(const uchar *buff, size_t *length,
|
|
|
|
my_bool not_used __attribute__((unused)))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
struct st_plugin_int *plugin= (st_plugin_int *)buff;
|
|
|
|
*length= (uint)plugin->name.length;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
return((uchar *)plugin->name.str);
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-13 15:11:25 +02:00
|
|
|
uchar *get_bookmark_hash_key(const uchar *buff, size_t *length,
|
|
|
|
my_bool not_used __attribute__((unused)))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
struct st_bookmark *var= (st_bookmark *)buff;
|
|
|
|
*length= var->name_len + 1;
|
2007-05-24 18:47:58 +02:00
|
|
|
return (uchar*) var->key;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2018-02-06 13:55:58 +01:00
|
|
|
static inline void convert_dash_to_underscore(char *str, size_t len)
|
2009-05-14 14:03:33 +02:00
|
|
|
{
|
|
|
|
for (char *p= str; p <= str+len; p++)
|
|
|
|
if (*p == '-')
|
|
|
|
*p= '_';
|
|
|
|
}
|
|
|
|
|
2018-02-06 13:55:58 +01:00
|
|
|
static inline void convert_underscore_to_dash(char *str, size_t len)
|
2009-05-14 14:03:33 +02:00
|
|
|
{
|
|
|
|
for (char *p= str; p <= str+len; p++)
|
|
|
|
if (*p == '_')
|
|
|
|
*p= '-';
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
#ifdef HAVE_PSI_INTERFACE
|
|
|
|
static PSI_mutex_key key_LOCK_plugin;
|
|
|
|
|
|
|
|
static PSI_mutex_info all_plugin_mutexes[]=
|
|
|
|
{
|
|
|
|
{ &key_LOCK_plugin, "LOCK_plugin", PSI_FLAG_GLOBAL}
|
|
|
|
};
|
|
|
|
|
2020-01-29 13:50:26 +01:00
|
|
|
static PSI_memory_info all_plugin_memory[]=
|
|
|
|
{
|
|
|
|
{ &key_memory_plugin_mem_root, "plugin_mem_root", PSI_FLAG_GLOBAL},
|
|
|
|
{ &key_memory_plugin_int_mem_root, "plugin_int_mem_root", 0},
|
|
|
|
{ &key_memory_mysql_plugin_dl, "mysql_plugin_dl", 0},
|
|
|
|
{ &key_memory_mysql_plugin, "mysql_plugin", 0},
|
|
|
|
{ &key_memory_plugin_bookmark, "plugin_bookmark", PSI_FLAG_GLOBAL}
|
|
|
|
};
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
static void init_plugin_psi_keys(void)
|
|
|
|
{
|
|
|
|
const char* category= "sql";
|
|
|
|
int count;
|
|
|
|
|
|
|
|
if (PSI_server == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
count= array_elements(all_plugin_mutexes);
|
|
|
|
PSI_server->register_mutex(category, all_plugin_mutexes, count);
|
2020-01-29 13:50:26 +01:00
|
|
|
|
|
|
|
count= array_elements(all_plugin_memory);
|
|
|
|
mysql_memory_register(category, all_plugin_memory, count);
|
2010-01-07 06:42:07 +01:00
|
|
|
}
|
2020-01-29 13:50:26 +01:00
|
|
|
#else
|
|
|
|
static void init_plugin_psi_keys(void) {}
|
2010-01-07 06:42:07 +01:00
|
|
|
#endif /* HAVE_PSI_INTERFACE */
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2006-08-29 20:58:12 +02:00
|
|
|
/*
|
|
|
|
The logic is that we first load and initialize all compiled in plugins.
|
|
|
|
From there we load up the dynamic types (assuming we have not been told to
|
2006-09-07 15:01:36 +02:00
|
|
|
skip this part).
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2007-03-29 06:29:16 +02:00
|
|
|
Finally we initialize everything, aka the dynamic that have yet to initialize.
|
2006-08-29 20:58:12 +02:00
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
int plugin_init(int *argc, char **argv, int flags)
|
2005-12-21 19:18:40 +01:00
|
|
|
{
|
2015-01-05 13:27:44 +01:00
|
|
|
uint i;
|
2010-04-01 16:34:51 +02:00
|
|
|
struct st_maria_plugin **builtins;
|
|
|
|
struct st_maria_plugin *plugin;
|
2023-07-25 05:10:52 +02:00
|
|
|
struct st_plugin_int tmp, *plugin_ptr, **reap, **retry_end, **retry_start;
|
2007-03-02 17:43:45 +01:00
|
|
|
MEM_ROOT tmp_root;
|
2009-12-22 10:35:56 +01:00
|
|
|
bool reaped_mandatory_plugin= false;
|
2020-03-21 20:09:50 +01:00
|
|
|
bool mandatory= true;
|
2020-03-21 20:21:58 +01:00
|
|
|
I_List_iterator<i_string> opt_plugin_load_list_iter(opt_plugin_load_list);
|
2020-03-21 20:09:50 +01:00
|
|
|
char plugin_table_engine_name_buf[NAME_CHAR_LEN + 1];
|
|
|
|
LEX_CSTRING plugin_table_engine_name= { plugin_table_engine_name_buf, 0 };
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING MyISAM= { STRING_WITH_LEN("MyISAM") };
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_ENTER("plugin_init");
|
|
|
|
|
|
|
|
if (initialized)
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
|
2013-04-09 23:27:29 +02:00
|
|
|
dlopen_count =0;
|
|
|
|
|
2020-01-29 13:50:26 +01:00
|
|
|
init_plugin_psi_keys();
|
|
|
|
|
|
|
|
init_alloc_root(key_memory_plugin_mem_root, &plugin_mem_root, 4096, 4096, MYF(0));
|
|
|
|
init_alloc_root(key_memory_plugin_mem_root, &plugin_vars_mem_root, 4096, 4096, MYF(0));
|
|
|
|
init_alloc_root(PSI_NOT_INSTRUMENTED, &tmp_root, 4096, 4096, MYF(0));
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2020-02-27 11:52:20 +01:00
|
|
|
if (my_hash_init(key_memory_plugin_bookmark, &bookmark_hash, &my_charset_bin, 32, 0, 0,
|
|
|
|
get_bookmark_hash_key, NULL, HASH_UNIQUE))
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2016-04-28 10:28:02 +02:00
|
|
|
/*
|
|
|
|
The 80 is from 2016-04-27 when we had 71 default plugins
|
|
|
|
Big enough to avoid many mallocs even in future
|
|
|
|
*/
|
2020-02-27 11:52:20 +01:00
|
|
|
if (my_init_dynamic_array(key_memory_mysql_plugin_dl, &plugin_dl_array,
|
2013-01-23 16:18:09 +01:00
|
|
|
sizeof(struct st_plugin_dl *), 16, 16, MYF(0)) ||
|
2020-02-27 11:52:20 +01:00
|
|
|
my_init_dynamic_array(key_memory_mysql_plugin, &plugin_array,
|
2016-04-28 10:28:02 +02:00
|
|
|
sizeof(struct st_plugin_int *), 80, 32, MYF(0)))
|
2005-12-21 19:18:40 +01:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
|
|
|
{
|
2020-02-27 11:52:20 +01:00
|
|
|
if (my_hash_init(key_memory_plugin_mem_root, &plugin_hash[i], system_charset_info, 32, 0, 0,
|
|
|
|
get_plugin_hash_key, NULL, HASH_UNIQUE))
|
2005-12-21 19:18:40 +01:00
|
|
|
goto err;
|
|
|
|
}
|
handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support
run-time handlerton initialization (no compiler warnings), handler API
is now tied to MySQL version, handlerton->plugin mapping added
(slot-based), dummy default_hton removed, plugin-type-specific
initialization generalized, built-in plugins are now initialized too,
--default-storage-engine no longer needs a list of storage engines
in handle_options().
mysql-test-run.pl bugfixes
include/mysql/plugin.h:
added st_mysql_storage_engine
made handlerton tied to MySQL version
mysql-test/mysql-test-run.pl:
bugfixes (umask, --no-defaults)
mysql-test/r/ndb_dd_basic.result:
update error message
mysql-test/t/partition_mgm_err2.test:
fix typo
sql/ha_berkeley.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_berkeley.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_federated.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_heap.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_innodb.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisam.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_myisammrg.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/ha_ndbcluster_binlog.cc:
no 'name' in the handlerton anymore
sql/ha_partition.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/handler.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
handlerton->plugin mapping
sql/handler.h:
handlerton cleanup: remove duplicate fields
sql/log.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
sql/mysql_priv.h:
handler.h needs plugin.h
sql/mysqld.cc:
Convert --default-storage-engine to a handlerton* when
all storage engines are initialized and not in getopt
sql/set_var.cc:
no name in the handlerton anymore
sql/sql_parse.cc:
no default_hton anymore
sql/sql_partition.cc:
no name in the handlerton anymore
sql/sql_plugin.cc:
generalize plugin type-specific initialization.
initialize built-in plugins too
sql/sql_plugin.h:
generalize plugin type-specific initialization.
sql/sql_show.cc:
st_mysql_storage_engine structure
no name in the handlerton anymore
sql/sql_table.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_tablespace.cc:
no name in the handlerton anymore
no default_hton anymore
sql/sql_yacc.yy:
no default_hton anymore
issue "unknown storage engine" warning where it is discovered
storage/archive/ha_archive.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/archive/ha_archive.h:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/blackhole/ha_blackhole.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/csv/ha_tina.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
storage/example/ha_example.cc:
handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine,
initialize handlerton run-time to avoid compiler warnings
2006-05-28 14:51:01 +02:00
|
|
|
|
2012-03-28 19:26:00 +02:00
|
|
|
/* prepare debug_sync service */
|
2017-03-06 19:37:48 +01:00
|
|
|
DBUG_ASSERT(strcmp(list_of_services[1].name, "debug_sync_service") == 0);
|
|
|
|
list_of_services[1].service= *(void**)&debug_sync_C_callback_ptr;
|
2012-03-28 19:26:00 +02:00
|
|
|
|
2015-04-01 18:26:19 +02:00
|
|
|
/* prepare encryption_keys service */
|
|
|
|
finalize_encryption_plugin(0);
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
initialized= 1;
|
|
|
|
|
2006-09-07 15:01:36 +02:00
|
|
|
/*
|
2006-08-29 20:58:12 +02:00
|
|
|
First we register builtin plugins
|
|
|
|
*/
|
2015-07-28 08:18:55 +02:00
|
|
|
if (global_system_variables.log_warnings >= 9)
|
|
|
|
sql_print_information("Initializing built-in plugins");
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
for (builtins= mysql_mandatory_plugins; *builtins || mandatory; builtins++)
|
2006-04-13 22:49:29 +02:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
if (!*builtins)
|
|
|
|
{
|
|
|
|
builtins= mysql_optional_plugins;
|
|
|
|
mandatory= false;
|
|
|
|
if (!*builtins)
|
|
|
|
break;
|
|
|
|
}
|
2006-04-13 22:49:29 +02:00
|
|
|
for (plugin= *builtins; plugin->info; plugin++)
|
|
|
|
{
|
2009-02-09 16:03:52 +01:00
|
|
|
if (opt_ignore_builtin_innodb &&
|
2020-01-26 17:27:13 +01:00
|
|
|
!my_charset_latin1.strnncoll(plugin->name, 6, "InnoDB", 6))
|
2009-03-13 09:51:25 +01:00
|
|
|
continue;
|
2009-10-01 23:27:39 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
bzero(&tmp, sizeof(tmp));
|
|
|
|
tmp.plugin= plugin;
|
2007-04-13 19:23:02 +02:00
|
|
|
tmp.name.str= (char *)plugin->name;
|
|
|
|
tmp.name.length= strlen(plugin->name);
|
2008-12-17 16:45:34 +01:00
|
|
|
tmp.state= 0;
|
2010-09-27 14:55:09 +02:00
|
|
|
tmp.load_option= mandatory ? PLUGIN_FORCE : PLUGIN_ON;
|
2010-01-07 06:42:07 +01:00
|
|
|
|
2011-11-28 18:20:51 +01:00
|
|
|
for (i=0; i < array_elements(override_plugin_load_policy); i++)
|
|
|
|
{
|
|
|
|
if (!my_strcasecmp(&my_charset_latin1, plugin->name,
|
|
|
|
override_plugin_load_policy[i].plugin_name))
|
|
|
|
{
|
|
|
|
tmp.load_option= override_plugin_load_policy[i].override;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
|
2014-01-28 08:12:43 +01:00
|
|
|
tmp.state= PLUGIN_IS_UNINITIALIZED;
|
2007-03-02 17:43:45 +01:00
|
|
|
if (register_builtin(plugin, &tmp, &plugin_ptr))
|
|
|
|
goto err_unlock;
|
2006-04-13 22:49:29 +02:00
|
|
|
}
|
|
|
|
}
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2017-04-18 19:20:55 +02:00
|
|
|
/*
|
|
|
|
First, we initialize only MyISAM - that should almost always succeed
|
|
|
|
(almost always, because plugins can be loaded outside of the server, too).
|
|
|
|
*/
|
2015-01-05 13:27:44 +01:00
|
|
|
plugin_ptr= plugin_find_internal(&MyISAM, MYSQL_STORAGE_ENGINE_PLUGIN);
|
2017-04-18 19:20:55 +02:00
|
|
|
DBUG_ASSERT(plugin_ptr || !mysql_mandatory_plugins[0]);
|
|
|
|
if (plugin_ptr)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(plugin_ptr->load_option == PLUGIN_FORCE);
|
2015-01-05 13:27:44 +01:00
|
|
|
|
2017-04-18 19:20:55 +02:00
|
|
|
if (plugin_initialize(&tmp_root, plugin_ptr, argc, argv, false))
|
|
|
|
goto err_unlock;
|
2015-01-05 13:27:44 +01:00
|
|
|
|
2017-04-18 19:20:55 +02:00
|
|
|
/*
|
|
|
|
set the global default storage engine variable so that it will
|
|
|
|
not be null in any child thread.
|
|
|
|
*/
|
|
|
|
global_system_variables.table_plugin =
|
|
|
|
intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr));
|
2017-07-03 10:35:44 +02:00
|
|
|
DBUG_SLOW_ASSERT(plugin_ptr->ref_count == 1);
|
2020-02-24 16:38:14 +01:00
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2015-01-05 13:27:44 +01:00
|
|
|
/* Register (not initialize!) all dynamic plugins */
|
2020-03-21 20:21:58 +01:00
|
|
|
if (global_system_variables.log_warnings >= 9)
|
|
|
|
sql_print_information("Initializing plugins specified on the command line");
|
|
|
|
while (i_string *item= opt_plugin_load_list_iter++)
|
|
|
|
plugin_load_list(&tmp_root, item->ptr);
|
|
|
|
|
|
|
|
if (!(flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2020-03-21 20:21:58 +01:00
|
|
|
char path[FN_REFLEN + 1];
|
|
|
|
build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0);
|
2020-06-15 14:06:08 +02:00
|
|
|
Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name);
|
2020-03-21 20:21:58 +01:00
|
|
|
if (ttype != TABLE_TYPE_NORMAL)
|
|
|
|
plugin_table_engine_name=empty_clex_str;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2006-08-29 20:58:12 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Now we initialize all remaining plugins
|
|
|
|
*/
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2023-07-25 05:10:52 +02:00
|
|
|
/* List of plugins to reap */
|
2007-03-02 17:43:45 +01:00
|
|
|
reap= (st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*));
|
|
|
|
*(reap++)= NULL;
|
2023-07-25 05:10:52 +02:00
|
|
|
/* List of plugins to retry */
|
|
|
|
retry_start= retry_end=
|
|
|
|
(st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*));
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2015-01-05 13:27:44 +01:00
|
|
|
for(;;)
|
2006-08-29 20:58:12 +02:00
|
|
|
{
|
2023-07-25 05:10:52 +02:00
|
|
|
int error;
|
2015-01-05 13:27:44 +01:00
|
|
|
for (i=0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
2006-08-29 20:58:12 +02:00
|
|
|
{
|
2015-01-05 13:27:44 +01:00
|
|
|
HASH *hash= plugin_hash + plugin_type_initialization_order[i];
|
|
|
|
for (uint idx= 0; idx < hash->records; idx++)
|
2006-09-07 15:01:36 +02:00
|
|
|
{
|
2015-01-05 13:27:44 +01:00
|
|
|
plugin_ptr= (struct st_plugin_int *) my_hash_element(hash, idx);
|
|
|
|
if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED)
|
2014-12-22 15:53:17 +01:00
|
|
|
{
|
2020-03-21 20:09:50 +01:00
|
|
|
bool plugin_table_engine= lex_string_eq(&plugin_table_engine_name,
|
|
|
|
&plugin_ptr->name);
|
|
|
|
bool opts_only= flags & PLUGIN_INIT_SKIP_INITIALIZATION &&
|
|
|
|
(flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE ||
|
|
|
|
!plugin_table_engine);
|
2023-07-25 05:10:52 +02:00
|
|
|
error= plugin_initialize(&tmp_root, plugin_ptr, argc, argv,
|
2023-07-26 13:54:59 +02:00
|
|
|
opts_only);
|
2023-07-25 05:10:52 +02:00
|
|
|
if (error)
|
2015-01-05 13:27:44 +01:00
|
|
|
{
|
|
|
|
plugin_ptr->state= PLUGIN_IS_DYING;
|
2023-07-25 05:10:52 +02:00
|
|
|
/* The plugin wants a retry of the initialisation,
|
|
|
|
possibly due to dependency on other plugins */
|
|
|
|
if (unlikely(error == HA_ERR_RETRY_INIT))
|
|
|
|
*(retry_end++)= plugin_ptr;
|
|
|
|
else
|
|
|
|
*(reap++)= plugin_ptr;
|
2015-01-05 13:27:44 +01:00
|
|
|
}
|
2014-12-22 15:53:17 +01:00
|
|
|
}
|
2006-09-07 15:01:36 +02:00
|
|
|
}
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
2023-07-25 05:10:52 +02:00
|
|
|
/* Retry plugins that asked for it */
|
|
|
|
while (retry_start < retry_end)
|
|
|
|
{
|
|
|
|
st_plugin_int **to_re_retry, **retrying;
|
|
|
|
for (to_re_retry= retrying= retry_start; retrying < retry_end; retrying++)
|
|
|
|
{
|
|
|
|
plugin_ptr= *retrying;
|
|
|
|
uint state= plugin_ptr->state;
|
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
|
|
|
error= plugin_do_initialize(plugin_ptr, state);
|
2024-02-12 11:08:22 +01:00
|
|
|
DBUG_EXECUTE_IF("fail_spider_init_retry", error= 1;);
|
2023-07-25 05:10:52 +02:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
plugin_ptr->state= state;
|
|
|
|
if (error == HA_ERR_RETRY_INIT)
|
|
|
|
*(to_re_retry++)= plugin_ptr;
|
|
|
|
else if (error)
|
|
|
|
*(reap++)= plugin_ptr;
|
|
|
|
}
|
|
|
|
/* If the retry list has not changed, i.e. if all retry attempts
|
|
|
|
result in another retry request, empty the retry list */
|
|
|
|
if (to_re_retry == retry_end)
|
|
|
|
while (to_re_retry > retry_start)
|
|
|
|
{
|
|
|
|
plugin_ptr= *(--to_re_retry);
|
|
|
|
*(reap++)= plugin_ptr;
|
|
|
|
/** `plugin_do_initialize()' did not print any error in this
|
|
|
|
case, so we do it here. */
|
|
|
|
print_init_failed_error(plugin_ptr);
|
|
|
|
}
|
|
|
|
retry_end= to_re_retry;
|
|
|
|
}
|
2015-01-05 13:27:44 +01:00
|
|
|
|
|
|
|
/* load and init plugins from the plugin table (unless done already) */
|
|
|
|
if (flags & PLUGIN_INIT_SKIP_PLUGIN_TABLE)
|
|
|
|
break;
|
|
|
|
|
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
|
|
|
plugin_load(&tmp_root);
|
|
|
|
flags|= PLUGIN_INIT_SKIP_PLUGIN_TABLE;
|
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
Check if any plugins have to be reaped
|
2007-04-13 19:24:46 +02:00
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
while ((plugin_ptr= *(--reap)))
|
|
|
|
{
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2017-06-14 11:27:36 +02:00
|
|
|
if (plugin_is_forced(plugin_ptr))
|
2009-05-14 14:03:33 +02:00
|
|
|
reaped_mandatory_plugin= TRUE;
|
2007-04-13 19:23:02 +02:00
|
|
|
plugin_deinitialize(plugin_ptr, true);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_del(plugin_ptr);
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2023-07-25 05:10:52 +02:00
|
|
|
my_afree(retry_start);
|
2007-03-02 17:43:45 +01:00
|
|
|
my_afree(reap);
|
2020-03-21 20:09:50 +01:00
|
|
|
if (reaped_mandatory_plugin && !opt_help)
|
2009-05-14 14:03:33 +02:00
|
|
|
goto err;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
free_root(&tmp_root, MYF(0));
|
2007-05-24 12:24:36 +02:00
|
|
|
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_RETURN(0);
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
err_unlock:
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2005-12-21 19:18:40 +01:00
|
|
|
err:
|
2007-03-02 17:43:45 +01:00
|
|
|
free_root(&tmp_root, MYF(0));
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-01 16:34:51 +02:00
|
|
|
static bool register_builtin(struct st_maria_plugin *plugin,
|
2007-03-02 17:43:45 +01:00
|
|
|
struct st_plugin_int *tmp,
|
|
|
|
struct st_plugin_int **ptr)
|
2005-12-21 19:18:40 +01:00
|
|
|
{
|
2007-03-29 06:29:16 +02:00
|
|
|
DBUG_ENTER("register_builtin");
|
2007-03-02 17:43:45 +01:00
|
|
|
tmp->ref_count= 0;
|
|
|
|
tmp->plugin_dl= 0;
|
2005-12-21 19:18:40 +01:00
|
|
|
|
2007-05-31 21:28:04 +02:00
|
|
|
if (insert_dynamic(&plugin_array, (uchar*)&tmp))
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
|
2007-05-24 19:39:24 +02:00
|
|
|
*ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1,
|
|
|
|
struct st_plugin_int **)=
|
2007-05-31 22:07:44 +02:00
|
|
|
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)tmp,
|
2007-05-24 19:39:24 +02:00
|
|
|
sizeof(struct st_plugin_int));
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-05-24 18:47:58 +02:00
|
|
|
if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr))
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
called only by plugin_init()
|
|
|
|
*/
|
2014-01-28 08:12:43 +01:00
|
|
|
static void plugin_load(MEM_ROOT *tmp_root)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
TABLE_LIST tables;
|
|
|
|
TABLE *table;
|
|
|
|
READ_RECORD read_record_info;
|
2006-11-30 02:40:42 +01:00
|
|
|
int error;
|
2016-04-07 18:51:40 +02:00
|
|
|
THD *new_thd= new THD(0);
|
2010-08-19 11:33:37 +02:00
|
|
|
bool result;
|
2020-07-26 16:01:12 +02:00
|
|
|
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
|
|
|
|
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_ENTER("plugin_load");
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2015-09-03 12:58:41 +02:00
|
|
|
if (global_system_variables.log_warnings >= 9)
|
|
|
|
sql_print_information("Initializing installed plugins");
|
|
|
|
|
2005-11-24 05:15:35 +01:00
|
|
|
new_thd->thread_stack= (char*) &tables;
|
2005-11-05 12:20:35 +01:00
|
|
|
new_thd->store_globals();
|
2018-01-07 17:03:44 +01:00
|
|
|
new_thd->db= MYSQL_SCHEMA_NAME;
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
bzero((char*) &new_thd->net, sizeof(new_thd->net));
|
2018-01-07 17:03:44 +01:00
|
|
|
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_READ);
|
2015-01-05 13:27:44 +01:00
|
|
|
tables.open_strategy= TABLE_LIST::OPEN_NORMAL;
|
2010-08-19 11:33:37 +02:00
|
|
|
|
|
|
|
result= open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT);
|
|
|
|
|
2013-04-07 15:37:47 +02:00
|
|
|
table= tables.table;
|
2010-08-19 11:33:37 +02:00
|
|
|
if (result)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
DBUG_PRINT("error",("Can't open plugin table"));
|
2011-06-07 09:54:37 +02:00
|
|
|
if (!opt_help)
|
2020-02-12 17:31:09 +01:00
|
|
|
sql_print_error("Could not open mysql.plugin table: \"%s\". "
|
|
|
|
"Some plugins may be not loaded",
|
|
|
|
new_thd->get_stmt_da()->message());
|
2011-06-07 09:54:37 +02:00
|
|
|
else
|
2020-02-12 17:31:09 +01:00
|
|
|
sql_print_warning("Could not open mysql.plugin table: \"%s\". "
|
|
|
|
"Some options may be missing from the help text",
|
|
|
|
new_thd->get_stmt_da()->message());
|
2005-11-05 12:20:35 +01:00
|
|
|
goto end;
|
|
|
|
}
|
2013-04-07 15:37:47 +02:00
|
|
|
|
2016-03-22 20:51:59 +01:00
|
|
|
if (init_read_record(&read_record_info, new_thd, table, NULL, NULL, 1, 0,
|
|
|
|
FALSE))
|
2010-07-17 00:41:44 +02:00
|
|
|
{
|
|
|
|
sql_print_error("Could not initialize init_read_record; Plugins not "
|
|
|
|
"loaded");
|
|
|
|
goto end;
|
|
|
|
}
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
BitKeeper/etc/ignore:
added mysys/test_bitmap
include/base64.h:
Removed my_global.h, as this must be included first in any program
include/heap.h:
Added heap_reset() (Required by new handler interface)
include/my_base.h:
Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
Remove my_pthread.h (should be included at upper level)
Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
Simplify ldata usage
Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
Use copy instead of INSTALL_DB for master and slave databases.
(Speeds up startup time a lot!)
Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
Added drop of test function
mysql-test/r/innodb_mysql.result:
Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
More tests
Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
Better error message
mysql-test/r/ndb_replace.result:
New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
Drop used views
mysql-test/t/create.test:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
Added drop of test function
mysql-test/t/innodb_mysql.test:
Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
More tests
Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
Drop used views
mysql-test/valgrind.supp:
Added supression of not needed warnings when printing stack trace
mysys/base64.c:
Include my_global.h first
mysys/my_bitmap.c:
Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
Ensure 'use_all_columns()' is used for event tables
Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
(Rest of changes are only indentation cleanups)
sql/field.h:
Removed Field->query_id (replaced by table->read_set and table->write_set)
Removed Field->fieldnr (use Field->field_index instead)
Removed Field->add_index (Use Field->flags instead)
Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
This allowed me to remove checking of sql_command.
Create a temporary column bitmap for fields that are used by the sorting process.
Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
Update to 'newer' table handler interface
sql/ha_berkeley.h:
Update to 'newer' table handler interface
sql/ha_federated.cc:
Update to 'newer' table handler interface
Only read columns that are needed from remote server.
In case of eq ranges, don't generate two conditions in the WHERE clause
(this can still be optimized, but would require a bigger code change)
Use 'simpler to use' XXXX_LEN' macros
A bit simpler logic in ::write_row() when creating statements.
In update, only include test of fields actually read.
(This greatly simplifies the queries sent by the federated engine)
Similar changes done for delete_row()
sql/ha_federated.h:
Update to 'newer' table handler interface
Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
Update to 'newer' table handler interface
sql/ha_heap.h:
Update to 'newer' table handler interface
sql/ha_innodb.cc:
Update to 'newer' table handler interface
- Update innobase_create_handler() to new interface
- Removed HA_NOT_EXACT_COUNT (not needed)
- Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- Prefixed base status variables with 'stats'
- Use table column bitmaps instead of ha_get_bit_in_read_set()
- Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
- Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
Update to 'newer' table handler interface
- table_flags are now ulonglong
- Added reset() method
- Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
- Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
Update to 'newer' table handler interface
sql/ha_myisam.h:
Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
Update to 'newer' table handler interface
sql/ha_myisammrg.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
Update to 'newer' table handler interface
Fixed use_blob_value() to be accurate
In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
Correct dumping of field data with DBUG_DUMP
Prefix addresses in DBUG_PRINT with 0x
Fixed usage of not initialized memory
Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
Mark usage of all columns in ndbcluster binlog tables
false -> FALSE, true -> TRUE
Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
Update to 'newer' table handler interface
Added memroot to initialise_partitions() and related functions to get faster memory allocation.
partition_create_handler() is now responsible for initialisation of the partition object
Some trivial optimizations and indentation fixes
Ensure that table_flags() are up to date
Removed documentation for removed HA_EXTRA flags
Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
Update to 'newer' table handler interface
sql/handler.cc:
create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
Much simpler get_new_handler()
(Initialization of the object is now handled by the create method for the engine)
Moved all allocation of bitmap handling to the TABLE object (in table.cc)
Added column_bitmaps_signal() to signal column usage changes.
Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
HA_DUPP_POS -> HA_DUPLICATE_POS
HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Added future row type 'ROW_TYPE_PAGES'
Added MEM_ROOT to handlerton 'create' function
Added ha_statistics, a structure for all status variable in the base handler class.
Moved all status variables in the handler class into a stats structs to improve readability.
ha_table_flags() is now a cached (not virtual) version of table_flags()
reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
Renamed dupp_ref to dup_ref
Renamed not used handler::sortkey
Moved read_set and write_set to TABLE structure
handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
Added register_field_in_read_map() for marking used columns in expression.
This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
Initalize value.cs_info.character_set_client to fix core dump bug with --debug
set_query_id -> mark_used_columns
Mark used columns in read_set OR write_set.
sql/item.h:
Removed reset_query_id_processor() as it's not needed anymore.
Added register_field_in_read_map()
Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
sql/item_cmpfunc.cc:
Temporary mark used columns to be read/writable
Update Item::walk to new interface
sql/item_cmpfunc.h:
Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
Update Item::walk() to new interface
table_flags() -> ha_table_flags()
sql/item_func.h:
Update Item::walk() to new interface
sql/item_row.cc:
Update Item::walk() to new interface
sql/item_row.h:
Update Item::walk() to new interface
sql/item_strfunc.h:
Update Item::walk() to new interface
sql/item_subselect.cc:
Added Item_subselect::walk()
(It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
Update Item::walk() to new interface
sql/item_sum.cc:
Update Item::walk() to new interface
Updates for new handler interace
sql/item_sum.h:
Update Item::walk() to new interface
sql/key.cc:
Updates for new handler interace
sql/log.cc:
Mark all columns used for log tables
Split options flag
Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
Fixed comments to be withing 79 characters
Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
Updates for new handler interface
Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
Indentation fixes and removed old comment
sql/opt_range.cc:
Update to new handler and bitmap interface.
Fixed calls to cp_buffer_from_ref() and walk() (new argument).
Create new temporary bitmaps for ror scans.
(Needed because of handler changes and to get more accurate column bitmaps than before)
Remove not needed file->ha_reset() call before file->close().
Some trivial optimization and indentation fixes.
Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
(This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
Optimized bitmap handling in ror scans:
- Start bitmap at position 0, not 1
- Use same bitmap size as in TABLE
- Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
Updates for new handler interface
sql/set_var.cc:
Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
Fixed wrong
sql/sp.cc:
Mark that we are using all columns for the proc table
Update call to setup_tables() to use new prototype
sql/sp_head.cc:
Removed QQ comment
sql/spatial.cc:
Removed wrong QQ comment
sql/sql_acl.cc:
Mark that we need all columns for acl tables
Supply memroot to some 'new' calls.
Indentation fixes
sql/sql_base.cc:
set_query_id removed
Ensure we call ha_reset() at end of each statement
Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
Fixed marking of some columns that was not proplerly marked before
Maintain in TABLE->merge_keys set of all keys that are used in some way
Removed not used 'conds' argument from setup_tables()
Remove not used setting of 'dupp_field' in insert_fields()
Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
Added is_overlapping()
sql/sql_class.cc:
Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
set_query_id -> mark_used_columns
Simpler variable usage in pack_row() (cleanup)
Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
Added enum_mark_columns
Updated comments
Renamed dupp_field -> dup_field
Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
(This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
Updates to new handler interface
Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
Call table->prepare_for_position() to tell handler that we are going to call ha_position().
Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
Fixed calls to setup_tables()
sql/sql_do.cc:
Update call to setup_fields()
sql/sql_handler.cc:
Tell handler tables to always read all columns.
Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
Makr all used fields to be read
Update call to setup_fields()
sql/sql_insert.cc:
Tell handler we are going to update the auto_increment column
dupp_field -> dup_field
Set column usage bits for timestamp field.
Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
Removed not used argument from mysql_prepare_insert_check_table().
If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
Setup new bitmaps for delayed insert rows
Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
The issue was that one should not to reset this flag as it may be set by a previous statement.
The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
Don't close tables created with CREATE ... SELECT but keep them in the table cache.
Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
Update to use new handler and column marking interface
Update using setup_tables()
sql/sql_olap.cc:
Update calls to setup_tables
Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
Handle OPTION_KEEP_LOG:
- Set it on CREATE TEMPORARY TABLE / DROP TABLE
- Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
- Don't set it for CREATE ... SELECT (this is handled in select_create class)
Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
Update walk() usage
Trivial indentation fixes
sql/sql_plugin.cc:
Mark all columns as used for plugins
sql/sql_prepare.cc:
Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
Updates for new handler interface
Update calls to setup_fields()
sql/sql_repl.cc:
Indentation fixes
sql/sql_select.cc:
Update call to setup_tables() and setup_fields()
Remove some old disabled code
Update to new hadler interface
Indentation cleanups
Added column bitmaps for temporary tables.
Remove updating of the removed slots in the Field class
Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
Indentaition fixes.
Install temporary column usage maps when needed
Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
Update to new handler interface
Mark all columns used for internal tables.
Style fixes.
Added support for 'future' ROW_TYPE_PAGES.
Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
Update to new handler interface
Simple my_snprintf -> strmake()
Changed some constants to defines
Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
Mark all columns as used for ALTER TABLE
Style fixes
Update call to filesort()
sql/sql_trigger.h:
Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
Mark all columns as used for udf system table.
sql/sql_union.cc:
Update call to walk()
Update to new handler interface
sql/sql_update.cc:
Remove query_id argument from compare_record()
Use column bitmaps instead of query_id.
We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
Update call to setup_fields()
Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
Removed call to free_io_cache() as this is now done in ha_reset()
Call table->mark_columns_needed_for_update() and table->prepare_for_position()
Style fixes
sql/sql_view.cc:
Style fixes
sql/table.cc:
Remove implicitely include 'errno.h'
Remove code for building normalized path, as this is now identical to 'path'
Remove field->fieldnr
Added update of field->part_of_key_not_clustered()
Create column bitmaps in TABLE and TABLE_SHARE
Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
Update to new handler interface
Update call to walk()
Added new functions:
- st_table::clear_column_bitmaps()
- st_table::prepare_for_position()
- st_table::mark_columns_used_by_index()
- st_table::restore_column_maps_after_mark_index()
- st_table::mark_columns_used_by_index_no_reset()
- st_table::mark_auto_increment_column()
- st_table::mark_columns_needed_for_delete()
- st_table::mark_columns_needed_for_update()
- st_table::mark_columns_needed_for_insert()
sql/table.h:
Moved column usage bitmaps from handler to TABLE
Added to TABLE_SHARE all_set and column_bitmap_size
Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
Declared all new table column bitmap functions
Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
Update to new handler interface
storage/archive/ha_archive.h:
Update to new handler interface
storage/blackhole/ha_blackhole.cc:
Update to new handler interface
storage/blackhole/ha_blackhole.h:
Update to new handler interface
removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
Update to new handler interface
storage/csv/ha_tina.h:
Update to new handler interface
storage/example/ha_example.cc:
Update to new handler interface
storage/example/ha_example.h:
Update to new handler interface
storage/heap/hp_extra.c:
Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
Use heap_reset()
storage/myisam/ft_boolean_search.c:
Fixed compiler warning
storage/myisam/mi_extra.c:
Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
Use mi_reset()
storage/myisam/myisampack.c:
Use mi_reset()
storage/myisammrg/myrg_extra.c:
Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
Include my_global.h
Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
|
|
|
table->use_all_columns();
|
2017-08-25 13:36:13 +02:00
|
|
|
while (!(error= read_record_info.read_record()))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
DBUG_PRINT("info", ("init plugin record"));
|
2006-09-25 19:59:49 +02:00
|
|
|
String str_name, str_dl;
|
2007-03-02 17:43:45 +01:00
|
|
|
get_field(tmp_root, table->field[0], &str_name);
|
|
|
|
get_field(tmp_root, table->field[1], &str_dl);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING name= {str_name.ptr(), str_name.length()};
|
|
|
|
LEX_CSTRING dl= {str_dl.ptr(), str_dl.length()};
|
2006-09-25 19:59:49 +02:00
|
|
|
|
2019-04-16 06:03:02 +02:00
|
|
|
if (!name.length || !dl.length)
|
|
|
|
continue;
|
|
|
|
|
2020-07-26 16:01:12 +02:00
|
|
|
/*
|
|
|
|
Pre-acquire audit plugins for events that may potentially occur
|
|
|
|
during [UN]INSTALL PLUGIN.
|
|
|
|
|
|
|
|
When audit event is triggered, audit subsystem acquires interested
|
|
|
|
plugins by walking through plugin list. Evidently plugin list
|
|
|
|
iterator protects plugin list by acquiring LOCK_plugin, see
|
|
|
|
plugin_foreach_with_mask().
|
|
|
|
|
|
|
|
On the other hand plugin_load is acquiring LOCK_plugin
|
|
|
|
rather for a long time.
|
|
|
|
|
|
|
|
When audit event is triggered during plugin_load plugin
|
|
|
|
list iterator acquires the same lock (within the same thread)
|
|
|
|
second time.
|
|
|
|
|
|
|
|
This hack should be removed when LOCK_plugin is fixed so it
|
|
|
|
protects only what it supposed to protect.
|
|
|
|
|
|
|
|
See also mysql_install_plugin(), mysql_uninstall_plugin() and
|
|
|
|
initialize_audit_plugin()
|
|
|
|
*/
|
|
|
|
if (mysql_audit_general_enabled())
|
|
|
|
mysql_audit_acquire_plugins(new_thd, event_class_mask);
|
|
|
|
|
2011-06-21 17:40:51 +02:00
|
|
|
/*
|
|
|
|
there're no other threads running yet, so we don't need a mutex.
|
|
|
|
but plugin_add() before is designed to work in multi-threaded
|
2011-10-19 21:45:18 +02:00
|
|
|
environment, and it uses mysql_mutex_assert_owner(), so we lock
|
2011-06-21 17:40:51 +02:00
|
|
|
the mutex here to satisfy the assert
|
|
|
|
*/
|
2011-10-19 21:45:18 +02:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2023-08-31 05:14:03 +02:00
|
|
|
plugin_add(tmp_root, true, &name, &dl, MYF(ME_ERROR_LOG));
|
2007-04-15 15:47:27 +02:00
|
|
|
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
|
2011-10-19 21:45:18 +02:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error > 0))
|
2015-07-06 19:24:14 +02:00
|
|
|
sql_print_error(ER_THD(new_thd, ER_GET_ERRNO), my_errno,
|
|
|
|
table->file->table_type());
|
2005-11-05 12:20:35 +01:00
|
|
|
end_read_record(&read_record_info);
|
2020-05-22 17:02:24 +02:00
|
|
|
table->mark_table_for_reopen();
|
A pre-requisite patch for the fix for Bug#52044.
This patch also fixes Bug#55452 "SET PASSWORD is
replicated twice in RBR mode".
The goal of this patch is to remove the release of
metadata locks from close_thread_tables().
This is necessary to not mistakenly release
the locks in the course of a multi-step
operation that involves multiple close_thread_tables()
or close_tables_for_reopen().
On the same token, move statement commit outside
close_thread_tables().
Other cleanups:
Cleanup COM_FIELD_LIST.
Don't call close_thread_tables() in COM_SHUTDOWN -- there
are no open tables there that can be closed (we leave
the locked tables mode in THD destructor, and this
close_thread_tables() won't leave it anyway).
Make open_and_lock_tables() and open_and_lock_tables_derived()
call close_thread_tables() upon failure.
Remove the calls to close_thread_tables() that are now
unnecessary.
Simplify the back off condition in Open_table_context.
Streamline metadata lock handling in LOCK TABLES
implementation.
Add asserts to ensure correct life cycle of
statement transaction in a session.
Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
mysql-test/r/variables.result:
Update results: set @@autocommit and statement transaction/
prelocked mode.
mysql-test/r/view.result:
A harmless change in CHECK TABLE <view> status for a broken view.
If previously a failure to prelock all functions used in a view
would leave the connection in LTM_PRELOCKED mode, now we call
close_thread_tables() from open_and_lock_tables()
and leave prelocked mode, thus some check in mysql_admin_table() that
works only in prelocked/locked tables mode is no longer activated.
mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result:
Fixed Bug#55452 "SET PASSWORD is replicated twice in
RBR mode": extra binlog events are gone from the
binary log.
mysql-test/t/variables.test:
Add a test case: set autocommit and statement transaction/prelocked
mode.
sql/event_data_objects.cc:
Simplify code in Event_job_data::execute().
Move sp_head memory management to lex_end().
sql/event_db_repository.cc:
Move the release of metadata locks outside
close_thread_tables().
Make sure we call close_thread_tables() when
open_and_lock_tables() fails and remove extra
code from the events data dictionary.
Use close_mysql_tables(), a new internal
function to properly close mysql.* tables
in the data dictionary.
Contract Event_db_repository::drop_events_by_field,
drop_schema_events into one function.
When dropping all events in a schema,
make sure we don't mistakenly release all
locks acquired by DROP DATABASE. These
include locks on the database name
and the global intention exclusive
metadata lock.
sql/event_db_repository.h:
Function open_event_table() does not require an instance
of Event_db_repository.
sql/events.cc:
Use close_mysql_tables() instead of close_thread_tables()
to bootstrap events, since the latter no longer
releases metadata locks.
sql/ha_ndbcluster.cc:
- mysql_rm_table_part2 no longer releases
acquired metadata locks. Do it in the caller.
sql/ha_ndbcluster_binlog.cc:
Deploy the new protocol for closing thread
tables in run_query() and ndb_binlog_index
code.
sql/handler.cc:
Assert that we never call ha_commit_trans/
ha_rollback_trans in sub-statement, which
is now the case.
sql/handler.h:
Add an accessor to check whether THD_TRANS object
is empty (has no transaction started).
sql/log.cc:
Update a comment.
sql/log_event.cc:
Since now we commit/rollback statement transaction in
mysql_execute_command(), we need a mechanism to communicate
from Query_log_event::do_apply_event() to mysql_execute_command()
that the statement transaction should be rolled back, not committed.
Ideally it would be a virtual method of THD. I hesitate
to make THD a virtual base class in this already large patch.
Use a thd->variables.option_bits for now.
Remove a call to close_thread_tables() from the slave IO
thread. It doesn't open any tables, and the protocol
for closing thread tables is more complicated now.
Make sure we properly close thread tables, however,
in Load_data_log_event, which doesn't
follow the standard server execution procedure
with mysql_execute_command().
@todo: this piece should use Server_runnable
framework instead.
Remove an unnecessary call to mysql_unlock_tables().
sql/rpl_rli.cc:
Update Relay_log_info::slave_close_thread_tables()
to follow the new close protocol.
sql/set_var.cc:
Remove an unused header.
sql/slave.cc:
Remove an unnecessary call to
close_thread_tables().
sql/sp.cc:
Remove unnecessary calls to close_thread_tables()
from SP DDL implementation. The tables will
be closed by the caller, in mysql_execute_command().
When dropping all routines in a database, make sure
to not mistakenly drop all metadata locks acquired
so far, they include the scoped lock on the schema.
sql/sp_head.cc:
Correct the protocol that closes thread tables
in an SP instruction.
Clear lex->sphead before cleaning up lex
with lex_end to make sure that we don't
delete the sphead twice. It's considered
to be "cleaner" and more in line with
future changes than calling delete lex->sphead
in other places that cleanup the lex.
sql/sp_head.h:
When destroying m_lex_keeper of an instruction,
don't delete the sphead that all lex objects
share.
@todo: don't store a reference to routine's sp_head
instance in instruction's lex.
sql/sql_acl.cc:
Don't call close_thread_tables() where the caller will
do that for us.
Fix Bug#55452 "SET PASSWORD is replicated twice in RBR
mode" by disabling RBR replication in change_password()
function.
Use close_mysql_tables() in bootstrap and ACL reload
code to make sure we release all metadata locks.
sql/sql_base.cc:
This is the main part of the patch:
- remove manipulation with thd->transaction
and thd->mdl_context from close_thread_tables().
Now this function is only responsible for closing
tables, nothing else.
This is necessary to be able to easily use
close_thread_tables() in procedures, that
involve multiple open/close tables, which all
need to be protected continuously by metadata
locks.
Add asserts ensuring that TABLE object
is only used when is protected by a metadata lock.
Simplify the back off condition of Open_table_context,
we no longer need to look at the autocommit mode.
Make open_and_lock_tables() and open_normal_and_derived_tables()
close thread tables and release metadata locks acquired so-far
upon failure. This simplifies their usage.
Implement close_mysql_tables().
sql/sql_base.h:
Add declaration for close_mysql_tables().
sql/sql_class.cc:
Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
The code became dead when my_eof() was made a non-protocol method,
but a method that merely modifies the diagnostics area.
The code became redundant with the fix for Bug#37521, when
we started to cal close_thread_tables() before
Protocol::end_statement().
sql/sql_do.cc:
Do nothing in DO if inside a substatement
(the assert moved out of trans_rollback_stmt).
sql/sql_handler.cc:
Add comments.
sql/sql_insert.cc:
Remove dead code.
Release metadata locks explicitly at the
end of the delayed insert thread.
sql/sql_lex.cc:
Add destruction of lex->sphead to lex_end(),
lex "reset" method called at the end of each statement.
sql/sql_parse.cc:
Move close_thread_tables() and other related
cleanups to mysql_execute_command()
from dispatch_command(). This has become
possible after the fix for Bug#37521.
Mark federated SERVER statements as DDL.
Next step: make sure that we don't store
eof packet in the query cache, and move
the query cache code outside mysql_parse.
Brush up the code of COM_FIELD_LIST.
Remove unnecessary calls to close_thread_tables().
When killing a query, don't report "OK"
if it was a suicide.
sql/sql_parse.h:
Remove declaration of a function that is now static.
sql/sql_partition.cc:
Remove an unnecessary call to close_thread_tables().
sql/sql_plugin.cc:
open_and_lock_tables() will clean up
after itself after a failure.
Move close_thread_tables() above
end: label, and replace with close_mysql_tables(),
which will also release the metadata lock
on mysql.plugin.
sql/sql_prepare.cc:
Now that we no longer release locks in close_thread_tables()
statement prepare code has become more straightforward.
Remove the now redundant check for thd->killed() (used
only by the backup project) from Execute_server_runnable.
Reorder code to take into account that now mysql_execute_command()
performs lex->unit.cleanup() and close_thread_tables().
sql/sql_priv.h:
Add a new option to server options to interact
between the slave SQL thread and execution
framework (hack). @todo: use a virtual
method of class THD instead.
sql/sql_servers.cc:
Due to Bug 25705 replication of
DROP/CREATE/ALTER SERVER is broken.
Make sure at least we do not attempt to
replicate these statements using RBR,
as this violates the assert in close_mysql_tables().
sql/sql_table.cc:
Do not release metadata locks in mysql_rm_table_part2,
this is done by the caller.
Do not call close_thread_tables() in mysql_create_table(),
this is done by the caller.
Fix a bug in DROP TABLE under LOCK TABLES when,
upon error in wait_while_table_is_used() we would mistakenly
release the metadata lock on a non-dropped table.
Explicitly release metadata locks when doing an implicit
commit.
sql/sql_trigger.cc:
Now that we delete lex->sphead in lex_end(),
zero the trigger's sphead in lex after loading
the trigger, to avoid double deletion.
sql/sql_udf.cc:
Use close_mysql_tables() instead of close_thread_tables().
sql/sys_vars.cc:
Remove code added in scope of WL#4284 which would
break when we perform set @@session.autocommit along
with setting other variables and using tables or functions.
A test case added to variables.test.
sql/transaction.cc:
Add asserts.
sql/tztime.cc:
Use close_mysql_tables() rather than close_thread_tables().
2010-07-27 12:25:53 +02:00
|
|
|
close_mysql_tables(new_thd);
|
2005-11-05 12:20:35 +01:00
|
|
|
end:
|
2018-01-07 17:03:44 +01:00
|
|
|
new_thd->db= null_clex_str; // Avoid free on thd->db
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
delete new_thd;
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
called only by plugin_init()
|
|
|
|
*/
|
2014-01-28 08:12:43 +01:00
|
|
|
static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
char buffer[FN_REFLEN];
|
2018-08-23 21:41:22 +02:00
|
|
|
LEX_CSTRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name;
|
2007-03-02 17:43:45 +01:00
|
|
|
char *p= buffer;
|
|
|
|
DBUG_ENTER("plugin_load_list");
|
|
|
|
while (list)
|
2006-08-29 20:58:12 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
if (p == buffer + sizeof(buffer) - 1)
|
2008-01-26 01:05:15 +01:00
|
|
|
{
|
|
|
|
sql_print_error("plugin-load parameter too long");
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
switch ((*(p++)= *(list++))) {
|
|
|
|
case '\0':
|
|
|
|
list= NULL; /* terminate the loop */
|
2017-05-16 19:08:47 +02:00
|
|
|
/* fall through */
|
2017-09-16 14:52:42 +02:00
|
|
|
case ';':
|
2007-03-02 17:43:45 +01:00
|
|
|
#ifndef __WIN__
|
|
|
|
case ':': /* can't use this as delimiter as it may be drive letter */
|
|
|
|
#endif
|
2018-08-23 21:41:22 +02:00
|
|
|
p[-1]= 0;
|
2008-01-26 01:05:15 +01:00
|
|
|
if (str == &name) // load all plugins in named module
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2008-01-26 01:05:15 +01:00
|
|
|
if (!name.length)
|
|
|
|
{
|
|
|
|
p--; /* reset pointer */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
dl= name;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2012-03-05 21:48:06 +01:00
|
|
|
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
|
|
|
|
name.str= 0; // load everything
|
2018-08-23 21:41:22 +02:00
|
|
|
if (plugin_add(tmp_root, false, &name, &dl,
|
2018-07-04 11:27:20 +02:00
|
|
|
MYF(ME_ERROR_LOG)) != INSTALL_GOOD)
|
2012-03-05 21:48:06 +01:00
|
|
|
goto error;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2018-08-23 21:41:22 +02:00
|
|
|
if (plugin_add(tmp_root, false, &name, &dl,
|
2018-07-04 11:27:20 +02:00
|
|
|
MYF(ME_ERROR_LOG)) != INSTALL_GOOD)
|
2007-03-02 17:43:45 +01:00
|
|
|
goto error;
|
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
name.length= dl.length= 0;
|
|
|
|
dl.str= NULL; name.str= p= buffer;
|
|
|
|
str= &name;
|
|
|
|
continue;
|
|
|
|
case '=':
|
|
|
|
case '#':
|
|
|
|
if (str == &name)
|
|
|
|
{
|
2018-08-23 21:41:22 +02:00
|
|
|
p[-1]= 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
str= &dl;
|
|
|
|
str->str= p;
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-16 19:08:47 +02:00
|
|
|
/* fall through */
|
2007-03-02 17:43:45 +01:00
|
|
|
default:
|
|
|
|
str->length++;
|
|
|
|
continue;
|
|
|
|
}
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
error:
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2013-01-18 19:04:23 +01:00
|
|
|
if (name.str)
|
|
|
|
sql_print_error("Couldn't load plugin '%s' from '%s'.",
|
|
|
|
name.str, dl.str);
|
|
|
|
else
|
|
|
|
sql_print_error("Couldn't load plugins from '%s'.", dl.str);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2006-08-29 20:58:12 +02:00
|
|
|
void plugin_shutdown(void)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2009-09-04 12:32:21 +02:00
|
|
|
uint i, count= plugin_array.elements;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct st_plugin_int **plugins, *plugin;
|
|
|
|
struct st_plugin_dl **dl;
|
2006-08-29 20:58:12 +02:00
|
|
|
DBUG_ENTER("plugin_shutdown");
|
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
if (initialized)
|
2006-08-29 20:58:12 +02:00
|
|
|
{
|
2017-03-20 11:55:24 +01:00
|
|
|
if (opt_gtid_pos_auto_plugins)
|
|
|
|
{
|
|
|
|
free_engine_list(opt_gtid_pos_auto_plugins);
|
|
|
|
opt_gtid_pos_auto_plugins= NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2005-11-05 12:20:35 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
reap_needed= true;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
We want to shut down plugins in a reasonable order, this will
|
|
|
|
become important when we have plugins which depend upon each other.
|
|
|
|
Circular references cannot be reaped so they are forced afterwards.
|
|
|
|
TODO: Have an additional step here to notify all active plugins that
|
|
|
|
shutdown is requested to allow plugins to deinitialize in parallel.
|
|
|
|
*/
|
|
|
|
while (reap_needed && (count= plugin_array.elements))
|
|
|
|
{
|
2007-04-02 20:38:58 +02:00
|
|
|
reap_plugins();
|
2009-09-04 12:32:21 +02:00
|
|
|
for (i= 0; i < count; i++)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-05-24 19:39:24 +02:00
|
|
|
plugin= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
|
2009-09-04 12:32:21 +02:00
|
|
|
if (plugin->state == PLUGIN_IS_READY)
|
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin->state= PLUGIN_IS_DELETED;
|
|
|
|
reap_needed= true;
|
|
|
|
}
|
|
|
|
}
|
2007-04-02 20:38:58 +02:00
|
|
|
if (!reap_needed)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
release any plugin references held.
|
|
|
|
*/
|
|
|
|
unlock_variables(NULL, &global_system_variables);
|
|
|
|
unlock_variables(NULL, &max_system_variables);
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2007-03-23 18:14:46 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
plugins= (struct st_plugin_int **) my_alloca(sizeof(void*) * (count+1));
|
|
|
|
|
|
|
|
/*
|
|
|
|
If we have any plugins which did not die cleanly, we force shutdown
|
|
|
|
*/
|
|
|
|
for (i= 0; i < count; i++)
|
|
|
|
{
|
2007-05-24 19:39:24 +02:00
|
|
|
plugins[i]= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
|
2007-03-02 17:43:45 +01:00
|
|
|
/* change the state to ensure no reaping races */
|
|
|
|
if (plugins[i]->state == PLUGIN_IS_DELETED)
|
|
|
|
plugins[i]->state= PLUGIN_IS_DYING;
|
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
We loop through all plugins and call deinit() if they have one.
|
|
|
|
*/
|
|
|
|
for (i= 0; i < count; i++)
|
2008-12-17 16:45:34 +01:00
|
|
|
if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED |
|
|
|
|
PLUGIN_IS_DISABLED)))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-04-02 20:38:58 +02:00
|
|
|
/*
|
|
|
|
We are forcing deinit on plugins so we don't want to do a ref_count
|
|
|
|
check until we have processed all the plugins.
|
|
|
|
*/
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_deinitialize(plugins[i], false);
|
|
|
|
}
|
|
|
|
|
2007-04-13 19:23:02 +02:00
|
|
|
/*
|
|
|
|
It's perfectly safe not to lock LOCK_plugin, as there're no
|
|
|
|
concurrent threads anymore. But some functions called from here
|
2010-01-07 06:42:07 +01:00
|
|
|
use mysql_mutex_assert_owner(), so we lock the mutex to satisfy it
|
2007-04-13 19:23:02 +02:00
|
|
|
*/
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
We defer checking ref_counts until after all plugins are deinitialized
|
|
|
|
as some may have worker threads holding on to plugin references.
|
|
|
|
*/
|
|
|
|
for (i= 0; i < count; i++)
|
2007-04-13 19:23:02 +02:00
|
|
|
{
|
2007-03-02 17:43:45 +01:00
|
|
|
if (plugins[i]->ref_count)
|
|
|
|
sql_print_error("Plugin '%s' has ref_count=%d after shutdown.",
|
|
|
|
plugins[i]->name.str, plugins[i]->ref_count);
|
2011-07-10 20:09:17 +02:00
|
|
|
if (plugins[i]->state & PLUGIN_IS_UNINITIALIZED ||
|
|
|
|
plugins[i]->state & PLUGIN_IS_DISABLED)
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_del(plugins[i]);
|
2007-04-13 19:23:02 +02:00
|
|
|
}
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2007-03-23 18:14:46 +01:00
|
|
|
/*
|
|
|
|
Now we can deallocate all memory.
|
|
|
|
*/
|
2007-03-29 06:29:16 +02:00
|
|
|
|
2014-10-23 21:01:52 +02:00
|
|
|
cleanup_variables(&global_system_variables);
|
|
|
|
cleanup_variables(&max_system_variables);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
initialized= 0;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_destroy(&LOCK_plugin);
|
2006-08-29 20:58:12 +02:00
|
|
|
|
2007-03-23 18:14:46 +01:00
|
|
|
my_afree(plugins);
|
2006-08-29 20:58:12 +02:00
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/* Dispose of the memory */
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
2009-10-14 18:37:38 +02:00
|
|
|
my_hash_free(&plugin_hash[i]);
|
2005-11-05 12:20:35 +01:00
|
|
|
delete_dynamic(&plugin_array);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
count= plugin_dl_array.elements;
|
|
|
|
dl= (struct st_plugin_dl **)my_alloca(sizeof(void*) * count);
|
|
|
|
for (i= 0; i < count; i++)
|
2007-05-24 19:39:24 +02:00
|
|
|
dl[i]= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);
|
2005-11-05 12:20:35 +01:00
|
|
|
for (i= 0; i < plugin_dl_array.elements; i++)
|
2007-03-02 17:43:45 +01:00
|
|
|
free_plugin_mem(dl[i]);
|
|
|
|
my_afree(dl);
|
2005-11-05 12:20:35 +01:00
|
|
|
delete_dynamic(&plugin_dl_array);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-10-14 18:37:38 +02:00
|
|
|
my_hash_free(&bookmark_hash);
|
2007-03-02 17:43:45 +01:00
|
|
|
free_root(&plugin_mem_root, MYF(0));
|
2014-01-28 08:12:43 +01:00
|
|
|
free_root(&plugin_vars_mem_root, MYF(0));
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
global_variables_dynamic_size= 0;
|
|
|
|
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2012-03-05 21:48:06 +01:00
|
|
|
/**
|
|
|
|
complete plugin installation (after plugin_add).
|
2005-11-05 12:20:35 +01:00
|
|
|
|
2012-03-05 21:48:06 +01:00
|
|
|
That is, initialize it, and update mysql.plugin table
|
|
|
|
*/
|
2017-04-23 18:39:57 +02:00
|
|
|
static bool finalize_install(THD *thd, TABLE *table, const LEX_CSTRING *name,
|
2014-01-28 08:12:43 +01:00
|
|
|
int *argc, char **argv)
|
2012-03-05 21:48:06 +01:00
|
|
|
{
|
|
|
|
struct st_plugin_int *tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN);
|
|
|
|
int error;
|
|
|
|
DBUG_ASSERT(tmp);
|
2013-01-15 19:16:29 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin); // because of tmp->state
|
2012-03-05 21:48:06 +01:00
|
|
|
|
2014-01-28 08:12:43 +01:00
|
|
|
if (tmp->state != PLUGIN_IS_UNINITIALIZED)
|
2013-06-13 20:19:11 +02:00
|
|
|
{
|
|
|
|
/* already installed */
|
|
|
|
return 0;
|
|
|
|
}
|
2012-03-05 21:48:06 +01:00
|
|
|
else
|
|
|
|
{
|
2014-01-28 08:12:43 +01:00
|
|
|
if (plugin_initialize(thd->mem_root, tmp, argc, argv, false))
|
2012-03-05 21:48:06 +01:00
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
|
2012-03-05 21:48:06 +01:00
|
|
|
"Plugin initialization function failed.");
|
|
|
|
tmp->state= PLUGIN_IS_DELETED;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2014-01-28 08:12:43 +01:00
|
|
|
if (tmp->state == PLUGIN_IS_DISABLED)
|
|
|
|
{
|
|
|
|
if (global_system_variables.log_warnings)
|
2014-02-03 15:22:39 +01:00
|
|
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
2015-07-06 19:24:14 +02:00
|
|
|
ER_CANT_INITIALIZE_UDF,
|
|
|
|
ER_THD(thd, ER_CANT_INITIALIZE_UDF),
|
2014-01-28 08:12:43 +01:00
|
|
|
name->str, "Plugin is disabled");
|
|
|
|
}
|
2012-03-05 21:48:06 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
We do not replicate the INSTALL PLUGIN statement. Disable binlogging
|
|
|
|
of the insert into the plugin table, so that it is not replicated in
|
|
|
|
row based mode.
|
|
|
|
*/
|
2020-01-28 22:23:51 +01:00
|
|
|
DBUG_ASSERT(!table->file->row_logging);
|
2012-03-05 21:48:06 +01:00
|
|
|
table->use_all_columns();
|
|
|
|
restore_record(table, s->default_values);
|
|
|
|
table->field[0]->store(name->str, name->length, system_charset_info);
|
|
|
|
table->field[1]->store(tmp->plugin_dl->dl.str, tmp->plugin_dl->dl.length,
|
|
|
|
files_charset_info);
|
|
|
|
error= table->file->ha_write_row(table->record[0]);
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error))
|
2012-03-05 21:48:06 +01:00
|
|
|
{
|
|
|
|
table->file->print_error(error, MYF(0));
|
|
|
|
tmp->state= PLUGIN_IS_DELETED;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name,
|
|
|
|
const LEX_CSTRING *dl_arg)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
TABLE_LIST tables;
|
|
|
|
TABLE *table;
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING dl= *dl_arg;
|
2018-07-04 11:27:20 +02:00
|
|
|
enum install_status error;
|
2012-03-05 21:48:06 +01:00
|
|
|
int argc=orig_argc;
|
2009-03-13 09:51:25 +01:00
|
|
|
char **argv=orig_argv;
|
2017-10-03 22:37:02 +02:00
|
|
|
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
|
|
|
|
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_ENTER("mysql_install_plugin");
|
2005-12-21 19:18:40 +01:00
|
|
|
|
2018-01-07 17:03:44 +01:00
|
|
|
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_WRITE);
|
2015-03-15 04:50:22 +01:00
|
|
|
if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE))
|
2005-11-05 12:20:35 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
2017-10-10 22:39:48 +02:00
|
|
|
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
|
2017-10-03 22:37:02 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/* need to open before acquiring LOCK_plugin or it will deadlock */
|
2010-02-24 18:04:00 +01:00
|
|
|
if (! (table = open_ltable(thd, &tables, TL_WRITE,
|
|
|
|
MYSQL_LOCK_IGNORE_TIMEOUT)))
|
2005-12-21 19:18:40 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
|
2014-01-28 08:12:43 +01:00
|
|
|
if (my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL))
|
|
|
|
{
|
2018-05-18 10:28:53 +02:00
|
|
|
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), name->str);
|
2014-01-28 08:12:43 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
2010-08-20 11:58:28 +02:00
|
|
|
/*
|
|
|
|
Pre-acquire audit plugins for events that may potentially occur
|
|
|
|
during [UN]INSTALL PLUGIN.
|
|
|
|
|
|
|
|
When audit event is triggered, audit subsystem acquires interested
|
|
|
|
plugins by walking through plugin list. Evidently plugin list
|
|
|
|
iterator protects plugin list by acquiring LOCK_plugin, see
|
|
|
|
plugin_foreach_with_mask().
|
|
|
|
|
|
|
|
On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin
|
|
|
|
rather for a long time.
|
|
|
|
|
|
|
|
When audit event is triggered during [UN]INSTALL PLUGIN, plugin
|
|
|
|
list iterator acquires the same lock (within the same thread)
|
|
|
|
second time.
|
|
|
|
|
|
|
|
This hack should be removed when LOCK_plugin is fixed so it
|
|
|
|
protects only what it supposed to protect.
|
2013-01-15 19:16:29 +01:00
|
|
|
|
|
|
|
See also mysql_uninstall_plugin() and initialize_audit_plugin()
|
2010-08-20 11:58:28 +02:00
|
|
|
*/
|
2016-03-01 07:21:42 +01:00
|
|
|
if (mysql_audit_general_enabled())
|
|
|
|
mysql_audit_acquire_plugins(thd, event_class_mask);
|
2010-08-20 11:58:28 +02:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2020-02-15 18:25:57 +01:00
|
|
|
DEBUG_SYNC(thd, "acquired_LOCK_plugin");
|
2018-08-23 21:41:22 +02:00
|
|
|
error= plugin_add(thd->mem_root, thd->lex->create_info.if_not_exists(),
|
|
|
|
name, &dl, MYF(0));
|
2018-07-04 11:27:20 +02:00
|
|
|
if (unlikely(error != INSTALL_GOOD))
|
2005-11-05 12:20:35 +01:00
|
|
|
goto err;
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2012-03-05 21:48:06 +01:00
|
|
|
if (name->str)
|
2018-07-04 11:27:20 +02:00
|
|
|
error= finalize_install(thd, table, name, &argc, argv)
|
|
|
|
? INSTALL_FAIL_NOT_OK : INSTALL_GOOD;
|
2009-03-13 09:51:25 +01:00
|
|
|
else
|
|
|
|
{
|
2012-03-05 21:48:06 +01:00
|
|
|
st_plugin_dl *plugin_dl= plugin_dl_find(&dl);
|
|
|
|
struct st_maria_plugin *plugin;
|
|
|
|
for (plugin= plugin_dl->plugins; plugin->info; plugin++)
|
2009-03-13 09:51:25 +01:00
|
|
|
{
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING str= { plugin->name, strlen(plugin->name) };
|
2018-07-04 11:27:20 +02:00
|
|
|
if (finalize_install(thd, table, &str, &argc, argv))
|
|
|
|
error= INSTALL_FAIL_NOT_OK;
|
2009-03-13 09:51:25 +01:00
|
|
|
}
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2005-12-21 19:18:40 +01:00
|
|
|
|
2018-07-04 11:27:20 +02:00
|
|
|
if (unlikely(error != INSTALL_GOOD))
|
2014-01-28 08:12:43 +01:00
|
|
|
{
|
|
|
|
reap_needed= true;
|
|
|
|
reap_plugins();
|
|
|
|
}
|
2006-09-25 20:48:51 +02:00
|
|
|
err:
|
2019-06-14 23:02:55 +02:00
|
|
|
global_plugin_version++;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2014-01-28 08:12:43 +01:00
|
|
|
if (argv)
|
|
|
|
free_defaults(argv);
|
2018-07-04 11:27:20 +02:00
|
|
|
DBUG_RETURN(error == INSTALL_FAIL_NOT_OK);
|
2017-10-03 22:37:02 +02:00
|
|
|
#ifdef WITH_WSREP
|
2018-11-06 15:24:16 +01:00
|
|
|
wsrep_error_label:
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
#endif
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
static bool do_uninstall(THD *thd, TABLE *table, const LEX_CSTRING *name)
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
struct st_plugin_int *plugin;
|
2012-03-05 21:48:06 +01:00
|
|
|
mysql_mutex_assert_owner(&LOCK_plugin);
|
2010-08-20 11:58:28 +02:00
|
|
|
|
2012-08-24 11:25:47 +02:00
|
|
|
if (!(plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)) ||
|
|
|
|
plugin->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_DYING))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
2020-07-31 17:09:08 +02:00
|
|
|
// maybe plugin is present in mysql.plugin; postpone the error
|
|
|
|
plugin= nullptr;
|
2005-12-21 19:18:40 +01:00
|
|
|
}
|
2020-07-28 10:39:05 +02:00
|
|
|
|
|
|
|
if (plugin)
|
2010-09-27 14:55:09 +02:00
|
|
|
{
|
2020-07-28 10:39:05 +02:00
|
|
|
if (!plugin->plugin_dl)
|
|
|
|
{
|
|
|
|
my_error(ER_PLUGIN_DELETE_BUILTIN, MYF(0));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (plugin->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
|
|
|
|
{
|
|
|
|
my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
|
|
|
|
return 1;
|
|
|
|
}
|
2006-01-07 14:41:57 +01:00
|
|
|
|
2020-07-28 10:39:05 +02:00
|
|
|
plugin->state= PLUGIN_IS_DELETED;
|
|
|
|
if (plugin->ref_count)
|
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
|
|
|
WARN_PLUGIN_BUSY, ER_THD(thd, WARN_PLUGIN_BUSY));
|
|
|
|
else
|
|
|
|
reap_needed= true;
|
|
|
|
}
|
2005-12-21 19:18:40 +01:00
|
|
|
|
2009-10-12 20:15:10 +02:00
|
|
|
uchar user_key[MAX_KEY_LENGTH];
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
BitKeeper/etc/ignore:
added mysys/test_bitmap
include/base64.h:
Removed my_global.h, as this must be included first in any program
include/heap.h:
Added heap_reset() (Required by new handler interface)
include/my_base.h:
Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
Remove my_pthread.h (should be included at upper level)
Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
Simplify ldata usage
Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
Use copy instead of INSTALL_DB for master and slave databases.
(Speeds up startup time a lot!)
Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
Added drop of test function
mysql-test/r/innodb_mysql.result:
Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
More tests
Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
Better error message
mysql-test/r/ndb_replace.result:
New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
Drop used views
mysql-test/t/create.test:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
Added drop of test function
mysql-test/t/innodb_mysql.test:
Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
More tests
Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
Drop used views
mysql-test/valgrind.supp:
Added supression of not needed warnings when printing stack trace
mysys/base64.c:
Include my_global.h first
mysys/my_bitmap.c:
Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
Ensure 'use_all_columns()' is used for event tables
Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
(Rest of changes are only indentation cleanups)
sql/field.h:
Removed Field->query_id (replaced by table->read_set and table->write_set)
Removed Field->fieldnr (use Field->field_index instead)
Removed Field->add_index (Use Field->flags instead)
Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
This allowed me to remove checking of sql_command.
Create a temporary column bitmap for fields that are used by the sorting process.
Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
Update to 'newer' table handler interface
sql/ha_berkeley.h:
Update to 'newer' table handler interface
sql/ha_federated.cc:
Update to 'newer' table handler interface
Only read columns that are needed from remote server.
In case of eq ranges, don't generate two conditions in the WHERE clause
(this can still be optimized, but would require a bigger code change)
Use 'simpler to use' XXXX_LEN' macros
A bit simpler logic in ::write_row() when creating statements.
In update, only include test of fields actually read.
(This greatly simplifies the queries sent by the federated engine)
Similar changes done for delete_row()
sql/ha_federated.h:
Update to 'newer' table handler interface
Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
Update to 'newer' table handler interface
sql/ha_heap.h:
Update to 'newer' table handler interface
sql/ha_innodb.cc:
Update to 'newer' table handler interface
- Update innobase_create_handler() to new interface
- Removed HA_NOT_EXACT_COUNT (not needed)
- Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- Prefixed base status variables with 'stats'
- Use table column bitmaps instead of ha_get_bit_in_read_set()
- Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
- Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
Update to 'newer' table handler interface
- table_flags are now ulonglong
- Added reset() method
- Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
- Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
Update to 'newer' table handler interface
sql/ha_myisam.h:
Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
Update to 'newer' table handler interface
sql/ha_myisammrg.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
Update to 'newer' table handler interface
Fixed use_blob_value() to be accurate
In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
Correct dumping of field data with DBUG_DUMP
Prefix addresses in DBUG_PRINT with 0x
Fixed usage of not initialized memory
Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
Mark usage of all columns in ndbcluster binlog tables
false -> FALSE, true -> TRUE
Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
Update to 'newer' table handler interface
Added memroot to initialise_partitions() and related functions to get faster memory allocation.
partition_create_handler() is now responsible for initialisation of the partition object
Some trivial optimizations and indentation fixes
Ensure that table_flags() are up to date
Removed documentation for removed HA_EXTRA flags
Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
Update to 'newer' table handler interface
sql/handler.cc:
create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
Much simpler get_new_handler()
(Initialization of the object is now handled by the create method for the engine)
Moved all allocation of bitmap handling to the TABLE object (in table.cc)
Added column_bitmaps_signal() to signal column usage changes.
Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
HA_DUPP_POS -> HA_DUPLICATE_POS
HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Added future row type 'ROW_TYPE_PAGES'
Added MEM_ROOT to handlerton 'create' function
Added ha_statistics, a structure for all status variable in the base handler class.
Moved all status variables in the handler class into a stats structs to improve readability.
ha_table_flags() is now a cached (not virtual) version of table_flags()
reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
Renamed dupp_ref to dup_ref
Renamed not used handler::sortkey
Moved read_set and write_set to TABLE structure
handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
Added register_field_in_read_map() for marking used columns in expression.
This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
Initalize value.cs_info.character_set_client to fix core dump bug with --debug
set_query_id -> mark_used_columns
Mark used columns in read_set OR write_set.
sql/item.h:
Removed reset_query_id_processor() as it's not needed anymore.
Added register_field_in_read_map()
Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
sql/item_cmpfunc.cc:
Temporary mark used columns to be read/writable
Update Item::walk to new interface
sql/item_cmpfunc.h:
Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
Update Item::walk() to new interface
table_flags() -> ha_table_flags()
sql/item_func.h:
Update Item::walk() to new interface
sql/item_row.cc:
Update Item::walk() to new interface
sql/item_row.h:
Update Item::walk() to new interface
sql/item_strfunc.h:
Update Item::walk() to new interface
sql/item_subselect.cc:
Added Item_subselect::walk()
(It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
Update Item::walk() to new interface
sql/item_sum.cc:
Update Item::walk() to new interface
Updates for new handler interace
sql/item_sum.h:
Update Item::walk() to new interface
sql/key.cc:
Updates for new handler interace
sql/log.cc:
Mark all columns used for log tables
Split options flag
Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
Fixed comments to be withing 79 characters
Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
Updates for new handler interface
Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
Indentation fixes and removed old comment
sql/opt_range.cc:
Update to new handler and bitmap interface.
Fixed calls to cp_buffer_from_ref() and walk() (new argument).
Create new temporary bitmaps for ror scans.
(Needed because of handler changes and to get more accurate column bitmaps than before)
Remove not needed file->ha_reset() call before file->close().
Some trivial optimization and indentation fixes.
Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
(This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
Optimized bitmap handling in ror scans:
- Start bitmap at position 0, not 1
- Use same bitmap size as in TABLE
- Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
Updates for new handler interface
sql/set_var.cc:
Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
Fixed wrong
sql/sp.cc:
Mark that we are using all columns for the proc table
Update call to setup_tables() to use new prototype
sql/sp_head.cc:
Removed QQ comment
sql/spatial.cc:
Removed wrong QQ comment
sql/sql_acl.cc:
Mark that we need all columns for acl tables
Supply memroot to some 'new' calls.
Indentation fixes
sql/sql_base.cc:
set_query_id removed
Ensure we call ha_reset() at end of each statement
Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
Fixed marking of some columns that was not proplerly marked before
Maintain in TABLE->merge_keys set of all keys that are used in some way
Removed not used 'conds' argument from setup_tables()
Remove not used setting of 'dupp_field' in insert_fields()
Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
Added is_overlapping()
sql/sql_class.cc:
Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
set_query_id -> mark_used_columns
Simpler variable usage in pack_row() (cleanup)
Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
Added enum_mark_columns
Updated comments
Renamed dupp_field -> dup_field
Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
(This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
Updates to new handler interface
Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
Call table->prepare_for_position() to tell handler that we are going to call ha_position().
Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
Fixed calls to setup_tables()
sql/sql_do.cc:
Update call to setup_fields()
sql/sql_handler.cc:
Tell handler tables to always read all columns.
Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
Makr all used fields to be read
Update call to setup_fields()
sql/sql_insert.cc:
Tell handler we are going to update the auto_increment column
dupp_field -> dup_field
Set column usage bits for timestamp field.
Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
Removed not used argument from mysql_prepare_insert_check_table().
If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
Setup new bitmaps for delayed insert rows
Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
The issue was that one should not to reset this flag as it may be set by a previous statement.
The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
Don't close tables created with CREATE ... SELECT but keep them in the table cache.
Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
Update to use new handler and column marking interface
Update using setup_tables()
sql/sql_olap.cc:
Update calls to setup_tables
Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
Handle OPTION_KEEP_LOG:
- Set it on CREATE TEMPORARY TABLE / DROP TABLE
- Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
- Don't set it for CREATE ... SELECT (this is handled in select_create class)
Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
Update walk() usage
Trivial indentation fixes
sql/sql_plugin.cc:
Mark all columns as used for plugins
sql/sql_prepare.cc:
Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
Updates for new handler interface
Update calls to setup_fields()
sql/sql_repl.cc:
Indentation fixes
sql/sql_select.cc:
Update call to setup_tables() and setup_fields()
Remove some old disabled code
Update to new hadler interface
Indentation cleanups
Added column bitmaps for temporary tables.
Remove updating of the removed slots in the Field class
Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
Indentaition fixes.
Install temporary column usage maps when needed
Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
Update to new handler interface
Mark all columns used for internal tables.
Style fixes.
Added support for 'future' ROW_TYPE_PAGES.
Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
Update to new handler interface
Simple my_snprintf -> strmake()
Changed some constants to defines
Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
Mark all columns as used for ALTER TABLE
Style fixes
Update call to filesort()
sql/sql_trigger.h:
Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
Mark all columns as used for udf system table.
sql/sql_union.cc:
Update call to walk()
Update to new handler interface
sql/sql_update.cc:
Remove query_id argument from compare_record()
Use column bitmaps instead of query_id.
We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
Update call to setup_fields()
Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
Removed call to free_io_cache() as this is now done in ha_reset()
Call table->mark_columns_needed_for_update() and table->prepare_for_position()
Style fixes
sql/sql_view.cc:
Style fixes
sql/table.cc:
Remove implicitely include 'errno.h'
Remove code for building normalized path, as this is now identical to 'path'
Remove field->fieldnr
Added update of field->part_of_key_not_clustered()
Create column bitmaps in TABLE and TABLE_SHARE
Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
Update to new handler interface
Update call to walk()
Added new functions:
- st_table::clear_column_bitmaps()
- st_table::prepare_for_position()
- st_table::mark_columns_used_by_index()
- st_table::restore_column_maps_after_mark_index()
- st_table::mark_columns_used_by_index_no_reset()
- st_table::mark_auto_increment_column()
- st_table::mark_columns_needed_for_delete()
- st_table::mark_columns_needed_for_update()
- st_table::mark_columns_needed_for_insert()
sql/table.h:
Moved column usage bitmaps from handler to TABLE
Added to TABLE_SHARE all_set and column_bitmap_size
Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
Declared all new table column bitmap functions
Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
Update to new handler interface
storage/archive/ha_archive.h:
Update to new handler interface
storage/blackhole/ha_blackhole.cc:
Update to new handler interface
storage/blackhole/ha_blackhole.h:
Update to new handler interface
removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
Update to new handler interface
storage/csv/ha_tina.h:
Update to new handler interface
storage/example/ha_example.cc:
Update to new handler interface
storage/example/ha_example.h:
Update to new handler interface
storage/heap/hp_extra.c:
Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
Use heap_reset()
storage/myisam/ft_boolean_search.c:
Fixed compiler warning
storage/myisam/mi_extra.c:
Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
Use mi_reset()
storage/myisam/myisampack.c:
Use mi_reset()
storage/myisammrg/myrg_extra.c:
Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
Include my_global.h
Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
|
|
|
table->use_all_columns();
|
2005-11-05 12:20:35 +01:00
|
|
|
table->field[0]->store(name->str, name->length, system_charset_info);
|
2009-10-12 20:15:10 +02:00
|
|
|
key_copy(user_key, table->record[0], table->key_info,
|
|
|
|
table->key_info->key_length);
|
2010-11-25 18:17:28 +01:00
|
|
|
if (! table->file->ha_index_read_idx_map(table->record[0], 0, user_key,
|
|
|
|
HA_WHOLE_KEY, HA_READ_KEY_EXACT))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
int error;
|
2008-08-19 17:35:56 +02:00
|
|
|
/*
|
|
|
|
We do not replicate the UNINSTALL PLUGIN statement. Disable binlogging
|
|
|
|
of the delete from the plugin table, so that it is not replicated in
|
|
|
|
row based mode.
|
|
|
|
*/
|
2020-01-28 22:23:51 +01:00
|
|
|
table->file->row_logging= 0; // No logging
|
2008-08-19 17:35:56 +02:00
|
|
|
error= table->file->ha_delete_row(table->record[0]);
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error))
|
2005-11-05 12:20:35 +01:00
|
|
|
{
|
|
|
|
table->file->print_error(error, MYF(0));
|
2012-03-05 21:48:06 +01:00
|
|
|
return 1;
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
|
|
|
}
|
2020-07-28 10:39:05 +02:00
|
|
|
else if (!plugin)
|
|
|
|
{
|
2020-07-31 17:09:08 +02:00
|
|
|
const myf MyFlags= thd->lex->if_exists() ? ME_NOTE : 0;
|
|
|
|
my_error(ER_SP_DOES_NOT_EXIST, MyFlags, "PLUGIN", name->str);
|
|
|
|
return !MyFlags;
|
2020-07-28 10:39:05 +02:00
|
|
|
}
|
2012-03-05 21:48:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,
|
|
|
|
const LEX_CSTRING *dl_arg)
|
2012-03-05 21:48:06 +01:00
|
|
|
{
|
|
|
|
TABLE *table;
|
|
|
|
TABLE_LIST tables;
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING dl= *dl_arg;
|
2012-03-05 21:48:06 +01:00
|
|
|
bool error= false;
|
2017-10-03 22:37:02 +02:00
|
|
|
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
|
|
|
|
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
|
2012-03-05 21:48:06 +01:00
|
|
|
DBUG_ENTER("mysql_uninstall_plugin");
|
|
|
|
|
2018-01-07 17:03:44 +01:00
|
|
|
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_WRITE);
|
2012-03-05 21:48:06 +01:00
|
|
|
|
2015-03-15 04:50:22 +01:00
|
|
|
if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE))
|
2012-03-05 21:48:06 +01:00
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
|
2018-10-18 19:33:41 +02:00
|
|
|
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
|
2017-10-03 22:37:02 +02:00
|
|
|
|
2012-03-05 21:48:06 +01:00
|
|
|
/* need to open before acquiring LOCK_plugin or it will deadlock */
|
|
|
|
if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
|
2017-12-05 15:19:59 +01:00
|
|
|
if (!table->key_info)
|
|
|
|
{
|
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
2018-04-19 22:27:02 +02:00
|
|
|
"The table %s.%s has no primary key. "
|
|
|
|
"Please check the table definition and "
|
|
|
|
"create the primary key accordingly.", MYF(0),
|
2017-12-05 15:19:59 +01:00
|
|
|
table->s->db.str, table->s->table_name.str);
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
|
2012-03-05 21:48:06 +01:00
|
|
|
/*
|
|
|
|
Pre-acquire audit plugins for events that may potentially occur
|
|
|
|
during [UN]INSTALL PLUGIN.
|
|
|
|
|
|
|
|
When audit event is triggered, audit subsystem acquires interested
|
|
|
|
plugins by walking through plugin list. Evidently plugin list
|
|
|
|
iterator protects plugin list by acquiring LOCK_plugin, see
|
|
|
|
plugin_foreach_with_mask().
|
|
|
|
|
|
|
|
On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin
|
|
|
|
rather for a long time.
|
|
|
|
|
|
|
|
When audit event is triggered during [UN]INSTALL PLUGIN, plugin
|
|
|
|
list iterator acquires the same lock (within the same thread)
|
|
|
|
second time.
|
2013-01-15 19:16:29 +01:00
|
|
|
|
|
|
|
This hack should be removed when LOCK_plugin is fixed so it
|
|
|
|
protects only what it supposed to protect.
|
|
|
|
|
|
|
|
See also mysql_install_plugin() and initialize_audit_plugin()
|
2012-03-05 21:48:06 +01:00
|
|
|
*/
|
2016-03-01 07:21:42 +01:00
|
|
|
if (mysql_audit_general_enabled())
|
|
|
|
mysql_audit_acquire_plugins(thd, event_class_mask);
|
2012-03-05 21:48:06 +01:00
|
|
|
|
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
|
|
|
|
if (name->str)
|
|
|
|
error= do_uninstall(thd, table, name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fix_dl_name(thd->mem_root, &dl);
|
|
|
|
st_plugin_dl *plugin_dl= plugin_dl_find(&dl);
|
2013-01-09 17:29:51 +01:00
|
|
|
if (plugin_dl)
|
2012-03-05 21:48:06 +01:00
|
|
|
{
|
2013-01-09 17:29:51 +01:00
|
|
|
for (struct st_maria_plugin *plugin= plugin_dl->plugins;
|
|
|
|
plugin->info; plugin++)
|
|
|
|
{
|
2017-04-23 18:39:57 +02:00
|
|
|
LEX_CSTRING str= { plugin->name, strlen(plugin->name) };
|
2013-01-09 17:29:51 +01:00
|
|
|
error|= do_uninstall(thd, table, &str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-08-23 21:41:22 +02:00
|
|
|
myf MyFlags= thd->lex->if_exists() ? ME_NOTE : 0;
|
|
|
|
my_error(ER_SP_DOES_NOT_EXIST, MyFlags, "SONAME", dl.str);
|
|
|
|
error|= !MyFlags;
|
2012-03-05 21:48:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
reap_plugins();
|
|
|
|
|
2019-06-14 23:02:55 +02:00
|
|
|
global_plugin_version++;
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2012-03-05 21:48:06 +01:00
|
|
|
DBUG_RETURN(error);
|
2017-10-03 22:37:02 +02:00
|
|
|
#ifdef WITH_WSREP
|
2018-11-06 15:24:16 +01:00
|
|
|
wsrep_error_label:
|
|
|
|
DBUG_RETURN(true);
|
|
|
|
#endif
|
2005-11-05 12:20:35 +01:00
|
|
|
}
|
2005-12-21 19:18:40 +01:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
|
2006-09-06 10:22:59 +02:00
|
|
|
int type, uint state_mask, void *arg)
|
2005-12-21 19:18:40 +01:00
|
|
|
{
|
2017-10-12 11:30:02 +02:00
|
|
|
uint idx, total= 0;
|
|
|
|
struct st_plugin_int *plugin;
|
|
|
|
plugin_ref *plugins;
|
|
|
|
my_bool res= FALSE;
|
2006-09-06 10:22:59 +02:00
|
|
|
DBUG_ENTER("plugin_foreach_with_mask");
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!initialized)
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2006-10-25 01:41:13 +02:00
|
|
|
/*
|
|
|
|
Do the alloca out here in case we do have a working alloca:
|
2017-10-12 11:30:02 +02:00
|
|
|
leaving the nested stack frame invalidates alloca allocation.
|
2006-10-25 01:41:13 +02:00
|
|
|
*/
|
2005-12-21 19:18:40 +01:00
|
|
|
if (type == MYSQL_ANY_PLUGIN)
|
|
|
|
{
|
2017-10-12 11:30:02 +02:00
|
|
|
plugins= (plugin_ref*) my_alloca(plugin_array.elements * sizeof(plugin_ref));
|
|
|
|
for (idx= 0; idx < plugin_array.elements; idx++)
|
2005-12-21 19:18:40 +01:00
|
|
|
{
|
2007-05-24 19:39:24 +02:00
|
|
|
plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
|
2017-10-12 11:30:02 +02:00
|
|
|
if ((plugins[total]= intern_plugin_lock(0, plugin_int_to_ref(plugin),
|
|
|
|
state_mask)))
|
|
|
|
total++;
|
2005-12-21 19:18:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-25 01:41:13 +02:00
|
|
|
HASH *hash= plugin_hash + type;
|
2017-10-12 11:30:02 +02:00
|
|
|
plugins= (plugin_ref*) my_alloca(hash->records * sizeof(plugin_ref));
|
|
|
|
for (idx= 0; idx < hash->records; idx++)
|
2005-12-21 19:18:40 +01:00
|
|
|
{
|
2009-10-14 18:37:38 +02:00
|
|
|
plugin= (struct st_plugin_int *) my_hash_element(hash, idx);
|
2017-10-12 11:30:02 +02:00
|
|
|
if ((plugins[total]= intern_plugin_lock(0, plugin_int_to_ref(plugin),
|
|
|
|
state_mask)))
|
|
|
|
total++;
|
2005-12-21 19:18:40 +01:00
|
|
|
}
|
|
|
|
}
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2006-09-05 23:59:16 +02:00
|
|
|
|
|
|
|
for (idx= 0; idx < total; idx++)
|
|
|
|
{
|
2007-04-16 09:15:47 +02:00
|
|
|
/* It will stop iterating on first engine error when "func" returns TRUE */
|
2017-10-12 11:30:02 +02:00
|
|
|
if ((res= func(thd, plugins[idx], arg)))
|
|
|
|
break;
|
2006-09-05 23:59:16 +02:00
|
|
|
}
|
|
|
|
|
2017-10-12 11:30:02 +02:00
|
|
|
plugin_unlock_list(0, plugins, total);
|
2006-09-05 23:59:16 +02:00
|
|
|
my_afree(plugins);
|
2017-10-12 11:30:02 +02:00
|
|
|
DBUG_RETURN(res);
|
2005-12-21 19:18:40 +01:00
|
|
|
}
|
2006-09-05 23:59:16 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2013-04-09 23:27:29 +02:00
|
|
|
static bool plugin_dl_foreach_internal(THD *thd, st_plugin_dl *plugin_dl,
|
|
|
|
st_maria_plugin *plug,
|
|
|
|
plugin_foreach_func *func, void *arg)
|
|
|
|
{
|
|
|
|
for (; plug->name; plug++)
|
|
|
|
{
|
|
|
|
st_plugin_int tmp, *plugin;
|
|
|
|
|
|
|
|
tmp.name.str= const_cast<char*>(plug->name);
|
|
|
|
tmp.name.length= strlen(plug->name);
|
|
|
|
tmp.plugin= plug;
|
|
|
|
tmp.plugin_dl= plugin_dl;
|
|
|
|
|
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2022-08-01 11:11:26 +02:00
|
|
|
if ((plugin= plugin_find_internal(&tmp.name, plug->type)) &&
|
2013-04-09 23:27:29 +02:00
|
|
|
plugin->plugin == plug)
|
|
|
|
|
|
|
|
{
|
|
|
|
tmp.state= plugin->state;
|
|
|
|
tmp.load_option= plugin->load_option;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp.state= PLUGIN_IS_FREED;
|
|
|
|
tmp.load_option= PLUGIN_OFF;
|
|
|
|
}
|
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
|
|
|
|
|
|
|
plugin= &tmp;
|
|
|
|
if (func(thd, plugin_int_to_ref(plugin), arg))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
bool plugin_dl_foreach(THD *thd, const LEX_CSTRING *dl,
|
2013-04-09 23:27:29 +02:00
|
|
|
plugin_foreach_func *func, void *arg)
|
|
|
|
{
|
|
|
|
bool err= 0;
|
|
|
|
|
|
|
|
if (dl)
|
|
|
|
{
|
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2018-05-18 10:28:53 +02:00
|
|
|
st_plugin_dl *plugin_dl= plugin_dl_add(dl, MYF(0));
|
2013-04-09 23:27:29 +02:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
|
|
|
|
|
|
|
if (!plugin_dl)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
err= plugin_dl_foreach_internal(thd, plugin_dl, plugin_dl->plugins,
|
|
|
|
func, arg);
|
|
|
|
|
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
plugin_dl_del(plugin_dl);
|
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct st_maria_plugin **builtins;
|
|
|
|
for (builtins= mysql_mandatory_plugins; !err && *builtins; builtins++)
|
|
|
|
err= plugin_dl_foreach_internal(thd, 0, *builtins, func, arg);
|
|
|
|
for (builtins= mysql_optional_plugins; !err && *builtins; builtins++)
|
|
|
|
err= plugin_dl_foreach_internal(thd, 0, *builtins, func, arg);
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
Internal type declarations for variables support
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#undef MYSQL_SYSVAR_NAME
|
|
|
|
#define MYSQL_SYSVAR_NAME(name) name
|
2013-04-07 15:26:58 +02:00
|
|
|
#define PLUGIN_VAR_TYPEMASK 0x7f
|
|
|
|
#define BOOKMARK_MEMALLOC 0x80
|
|
|
|
|
|
|
|
static inline char plugin_var_bookmark_key(uint flags)
|
|
|
|
{
|
|
|
|
return (flags & PLUGIN_VAR_TYPEMASK) |
|
|
|
|
(flags & PLUGIN_VAR_MEMALLOC ? BOOKMARK_MEMALLOC : 0);
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
#define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */
|
|
|
|
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_bool_t, my_bool);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_bool_t, my_bool);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_str_t, char *);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_str_t, char *);
|
|
|
|
|
2007-05-01 01:42:15 +02:00
|
|
|
typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_set_t, ulonglong);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_set_t, ulonglong);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_int_t, int);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_long_t, long);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_longlong_t, longlong);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_uint_t, uint);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_ulong_t, ulong);
|
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_ulonglong_t, ulonglong);
|
2013-05-19 20:08:06 +02:00
|
|
|
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_double_t, double);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int_t, int);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_long_t, long);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_longlong_t, longlong);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_uint_t, uint);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulong_t, ulong);
|
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulonglong_t, ulonglong);
|
2013-05-19 20:08:06 +02:00
|
|
|
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_double_t, double);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
default variable data check and update functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int check_func_bool(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2009-12-22 10:35:56 +01:00
|
|
|
const char *str;
|
2007-03-02 17:43:45 +01:00
|
|
|
int result, length;
|
2007-04-13 19:23:02 +02:00
|
|
|
long long tmp;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (value->value_type(value) == MYSQL_VALUE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
length= sizeof(buff);
|
|
|
|
if (!(str= value->val_str(value, buff, &length)) ||
|
|
|
|
(result= find_type(&bool_typelib, str, length, 1)-1) < 0)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-13 19:23:02 +02:00
|
|
|
if (value->val_int(value, &tmp) < 0)
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
2012-04-02 10:45:07 +02:00
|
|
|
if (tmp != 0 && tmp != 1)
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
|
|
|
result= (int) tmp;
|
|
|
|
}
|
2012-04-02 10:45:07 +02:00
|
|
|
*(my_bool *) save= result ? 1 : 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_bool fixed1, fixed2;
|
|
|
|
long long orig, val;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct my_option options;
|
2009-12-22 10:35:56 +01:00
|
|
|
value->val_int(value, &orig);
|
|
|
|
val= orig;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_opt_set_limits(&options, var);
|
2007-12-04 01:17:52 +01:00
|
|
|
|
|
|
|
if (var->flags & PLUGIN_VAR_UNSIGNED)
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
if ((fixed1= (!value->is_unsigned(value) && val < 0)))
|
|
|
|
val=0;
|
|
|
|
*(uint *)save= (uint) getopt_ull_limit_value((ulonglong) val, &options,
|
|
|
|
&fixed2);
|
|
|
|
}
|
2007-12-04 01:17:52 +01:00
|
|
|
else
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
if ((fixed1= (value->is_unsigned(value) && val < 0)))
|
|
|
|
val=LONGLONG_MAX;
|
|
|
|
*(int *)save= (int) getopt_ll_limit_value(val, &options, &fixed2);
|
|
|
|
}
|
2007-12-04 01:17:52 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
return throw_bounds_warning(thd, var->name, fixed1 || fixed2,
|
|
|
|
value->is_unsigned(value), (longlong) orig);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_bool fixed1, fixed2;
|
|
|
|
long long orig, val;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct my_option options;
|
2009-12-22 10:35:56 +01:00
|
|
|
value->val_int(value, &orig);
|
|
|
|
val= orig;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_opt_set_limits(&options, var);
|
2007-12-04 01:17:52 +01:00
|
|
|
|
|
|
|
if (var->flags & PLUGIN_VAR_UNSIGNED)
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
if ((fixed1= (!value->is_unsigned(value) && val < 0)))
|
|
|
|
val=0;
|
|
|
|
*(ulong *)save= (ulong) getopt_ull_limit_value((ulonglong) val, &options,
|
|
|
|
&fixed2);
|
|
|
|
}
|
2007-12-04 01:17:52 +01:00
|
|
|
else
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
if ((fixed1= (value->is_unsigned(value) && val < 0)))
|
|
|
|
val=LONGLONG_MAX;
|
|
|
|
*(long *)save= (long) getopt_ll_limit_value(val, &options, &fixed2);
|
|
|
|
}
|
2007-12-04 01:17:52 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
return throw_bounds_warning(thd, var->name, fixed1 || fixed2,
|
|
|
|
value->is_unsigned(value), (longlong) orig);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,
|
Bug#31177: Server variables can't be set to their current values
5.1+ specific fixes (plugins etc.)
include/my_getopt.h:
make both ull and ll global
mysql-test/r/index_merge_myisam.result:
we throw warnings to the client, yea, verily
mysql-test/r/innodb.result:
we throw warnings to the client, yea, verily
mysql-test/r/variables.result:
we throw warnings to the client, yea, verily
mysql-test/t/variables.test:
correct result, is multiple of variable's block_size now
mysys/my_getopt.c:
export getopt_ll_limit_value(), check for integer wrap-around
in it, same as in ull variant. Only print warnings to reporter
when caller didn't ask for diagnostics, otherwise assume caller
will handle any warnings (id est, throw them client-wards)
sql/mysqld.cc:
correct signedness of "concurrent-insert"
sql/sql_plugin.cc:
Throw sys-var out-of-range warnings client-wards for
plugins, too.
2007-12-01 19:55:06 +01:00
|
|
|
void *save, st_mysql_value *value)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
my_bool fixed1, fixed2;
|
|
|
|
long long orig, val;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct my_option options;
|
2009-12-22 10:35:56 +01:00
|
|
|
value->val_int(value, &orig);
|
|
|
|
val= orig;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_opt_set_limits(&options, var);
|
2007-12-04 01:17:52 +01:00
|
|
|
|
|
|
|
if (var->flags & PLUGIN_VAR_UNSIGNED)
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
if ((fixed1= (!value->is_unsigned(value) && val < 0)))
|
|
|
|
val=0;
|
|
|
|
*(ulonglong *)save= getopt_ull_limit_value((ulonglong) val, &options,
|
|
|
|
&fixed2);
|
|
|
|
}
|
2007-12-04 01:17:52 +01:00
|
|
|
else
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
if ((fixed1= (value->is_unsigned(value) && val < 0)))
|
|
|
|
val=LONGLONG_MAX;
|
|
|
|
*(longlong *)save= getopt_ll_limit_value(val, &options, &fixed2);
|
|
|
|
}
|
2007-12-04 01:17:52 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
return throw_bounds_warning(thd, var->name, fixed1 || fixed2,
|
|
|
|
value->is_unsigned(value), (longlong) orig);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int check_func_str(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
|
|
|
const char *str;
|
|
|
|
int length;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
length= sizeof(buff);
|
|
|
|
if ((str= value->val_str(value, buff, &length)))
|
|
|
|
str= thd->strmake(str, length);
|
|
|
|
*(const char**)save= str;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int check_func_enum(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE];
|
2009-12-22 10:35:56 +01:00
|
|
|
const char *str;
|
2007-03-02 17:43:45 +01:00
|
|
|
TYPELIB *typelib;
|
2007-04-13 19:23:02 +02:00
|
|
|
long long tmp;
|
2007-03-02 17:43:45 +01:00
|
|
|
long result;
|
|
|
|
int length;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (var->flags & PLUGIN_VAR_THDLOCAL)
|
2007-05-01 01:42:15 +02:00
|
|
|
typelib= ((thdvar_enum_t*) var)->typelib;
|
2007-03-02 17:43:45 +01:00
|
|
|
else
|
2007-05-01 01:42:15 +02:00
|
|
|
typelib= ((sysvar_enum_t*) var)->typelib;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (value->value_type(value) == MYSQL_VALUE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
length= sizeof(buff);
|
|
|
|
if (!(str= value->val_str(value, buff, &length)))
|
|
|
|
goto err;
|
2009-12-22 10:35:56 +01:00
|
|
|
if ((result= (long)find_type(typelib, str, length, 0) - 1) < 0)
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-13 19:23:02 +02:00
|
|
|
if (value->val_int(value, &tmp))
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
2009-12-22 10:35:56 +01:00
|
|
|
if (tmp < 0 || tmp >= typelib->count)
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
|
|
|
result= (long) tmp;
|
|
|
|
}
|
|
|
|
*(long*)save= result;
|
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int check_func_set(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
|
|
|
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
|
2009-12-22 10:35:56 +01:00
|
|
|
const char *str;
|
2007-03-02 17:43:45 +01:00
|
|
|
TYPELIB *typelib;
|
2007-05-02 03:25:29 +02:00
|
|
|
ulonglong result;
|
2009-10-27 14:16:02 +01:00
|
|
|
uint error_len= 0; // init as only set on error
|
2007-03-02 17:43:45 +01:00
|
|
|
bool not_used;
|
|
|
|
int length;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (var->flags & PLUGIN_VAR_THDLOCAL)
|
2007-05-01 01:42:15 +02:00
|
|
|
typelib= ((thdvar_set_t*) var)->typelib;
|
2007-03-02 17:43:45 +01:00
|
|
|
else
|
2007-05-01 01:42:15 +02:00
|
|
|
typelib= ((sysvar_set_t*)var)->typelib;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
if (value->value_type(value) == MYSQL_VALUE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
length= sizeof(buff);
|
|
|
|
if (!(str= value->val_str(value, buff, &length)))
|
|
|
|
goto err;
|
|
|
|
result= find_set(typelib, str, length, NULL,
|
|
|
|
&error, &error_len, ¬_used);
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error_len))
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-05-02 03:25:29 +02:00
|
|
|
if (value->val_int(value, (long long *)&result))
|
2007-03-02 17:43:45 +01:00
|
|
|
goto err;
|
2010-01-19 14:30:55 +01:00
|
|
|
if (unlikely((result >= (1ULL << typelib->count)) &&
|
2007-03-02 17:43:45 +01:00
|
|
|
(typelib->count < sizeof(long)*8)))
|
|
|
|
goto err;
|
|
|
|
}
|
2007-05-02 03:25:29 +02:00
|
|
|
*(ulonglong*)save= result;
|
2007-03-02 17:43:45 +01:00
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-05-19 20:08:06 +02:00
|
|
|
static int check_func_double(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, st_mysql_value *value)
|
|
|
|
{
|
|
|
|
double v;
|
|
|
|
my_bool fixed;
|
|
|
|
struct my_option option;
|
|
|
|
|
|
|
|
value->val_real(value, &v);
|
|
|
|
plugin_opt_set_limits(&option, var);
|
|
|
|
*(double *) save= getopt_double_limit_value(v, &option, &fixed);
|
|
|
|
|
|
|
|
return throw_bounds_warning(thd, var->name, fixed, v);
|
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
static void update_func_bool(THD *thd, struct st_mysql_sys_var *var,
|
2008-02-19 21:55:13 +01:00
|
|
|
void *tgt, const void *save)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2012-04-02 10:45:07 +02:00
|
|
|
*(my_bool *) tgt= *(my_bool *) save ? 1 : 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void update_func_int(THD *thd, struct st_mysql_sys_var *var,
|
2008-02-19 21:55:13 +01:00
|
|
|
void *tgt, const void *save)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
*(int *)tgt= *(int *) save;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void update_func_long(THD *thd, struct st_mysql_sys_var *var,
|
2008-02-19 21:55:13 +01:00
|
|
|
void *tgt, const void *save)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
*(long *)tgt= *(long *) save;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void update_func_longlong(THD *thd, struct st_mysql_sys_var *var,
|
2008-02-19 21:55:13 +01:00
|
|
|
void *tgt, const void *save)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
*(longlong *)tgt= *(ulonglong *) save;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void update_func_str(THD *thd, struct st_mysql_sys_var *var,
|
2008-02-19 21:55:13 +01:00
|
|
|
void *tgt, const void *save)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2013-08-06 12:02:07 +02:00
|
|
|
char *value= *(char**) save;
|
2007-03-02 17:43:45 +01:00
|
|
|
if (var->flags & PLUGIN_VAR_MEMALLOC)
|
|
|
|
{
|
2013-08-06 12:02:07 +02:00
|
|
|
char *old= *(char**) tgt;
|
|
|
|
if (value)
|
2020-01-29 13:50:26 +01:00
|
|
|
*(char**) tgt= my_strdup(key_memory_global_system_variables,
|
|
|
|
value, MYF(0));
|
2013-09-09 13:56:35 +02:00
|
|
|
else
|
|
|
|
*(char**) tgt= 0;
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(old);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2013-08-06 12:02:07 +02:00
|
|
|
else
|
|
|
|
*(char**) tgt= value;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2013-05-19 20:08:06 +02:00
|
|
|
static void update_func_double(THD *thd, struct st_mysql_sys_var *var,
|
|
|
|
void *tgt, const void *save)
|
|
|
|
{
|
|
|
|
*(double *) tgt= *(double *) save;
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
System Variables support
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-03-20 21:42:48 +01:00
|
|
|
sys_var *find_sys_var(THD *thd, const char *str, size_t length,
|
|
|
|
bool throw_error)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
sys_var *var;
|
2019-03-20 21:42:48 +01:00
|
|
|
sys_var_pluginvar *pi;
|
|
|
|
DBUG_ENTER("find_sys_var");
|
2016-04-15 20:47:45 +02:00
|
|
|
DBUG_PRINT("enter", ("var '%.*s'", (int)length, str));
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_rdlock(&LOCK_system_variables_hash);
|
2009-12-22 10:35:56 +01:00
|
|
|
if ((var= intern_find_sys_var(str, length)) &&
|
2007-03-02 17:43:45 +01:00
|
|
|
(pi= var->cast_pluginvar()))
|
|
|
|
{
|
2019-03-20 21:42:48 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
if (!intern_plugin_lock(thd ? thd->lex : 0, plugin_int_to_ref(pi->plugin),
|
|
|
|
PLUGIN_IS_READY))
|
2007-03-02 17:43:45 +01:00
|
|
|
var= NULL; /* failed to lock it, it must be uninstalling */
|
2016-04-15 20:47:45 +02:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2019-03-20 21:42:48 +01:00
|
|
|
}
|
|
|
|
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(!throw_error && !var))
|
2017-02-07 10:27:42 +01:00
|
|
|
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0),
|
|
|
|
(int) (length ? length : strlen(str)), (char*) str);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(var);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
called by register_var, construct_options and test_plugin_options.
|
|
|
|
Returns the 'bookmark' for the named variable.
|
2023-01-19 21:53:16 +01:00
|
|
|
returns null for non thd-local variables.
|
2007-03-02 17:43:45 +01:00
|
|
|
LOCK_system_variables_hash should be at least read locked
|
|
|
|
*/
|
|
|
|
static st_bookmark *find_bookmark(const char *plugin, const char *name,
|
|
|
|
int flags)
|
|
|
|
{
|
|
|
|
st_bookmark *result= NULL;
|
2018-02-06 13:55:58 +01:00
|
|
|
size_t namelen, length, pluginlen= 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
char *varname, *p;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!(flags & PLUGIN_VAR_THDLOCAL))
|
|
|
|
return NULL;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
namelen= strlen(name);
|
|
|
|
if (plugin)
|
|
|
|
pluginlen= strlen(plugin) + 1;
|
|
|
|
length= namelen + pluginlen + 2;
|
|
|
|
varname= (char*) my_alloca(length);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (plugin)
|
|
|
|
{
|
|
|
|
strxmov(varname + 1, plugin, "_", name, NullS);
|
|
|
|
for (p= varname + 1; *p; p++)
|
|
|
|
if (*p == '-')
|
2007-04-13 19:24:46 +02:00
|
|
|
*p= '_';
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
memcpy(varname + 1, name, namelen + 1);
|
|
|
|
|
2013-04-07 15:26:58 +02:00
|
|
|
varname[0]= plugin_var_bookmark_key(flags);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-10-14 18:37:38 +02:00
|
|
|
result= (st_bookmark*) my_hash_search(&bookmark_hash,
|
|
|
|
(const uchar*) varname, length - 1);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
my_afree(varname);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-26 17:48:08 +02:00
|
|
|
static size_t var_storage_size(int flags)
|
|
|
|
{
|
|
|
|
switch (flags & PLUGIN_VAR_TYPEMASK) {
|
|
|
|
case PLUGIN_VAR_BOOL: return sizeof(my_bool);
|
|
|
|
case PLUGIN_VAR_INT: return sizeof(int);
|
|
|
|
case PLUGIN_VAR_LONG: return sizeof(long);
|
|
|
|
case PLUGIN_VAR_ENUM: return sizeof(long);
|
|
|
|
case PLUGIN_VAR_LONGLONG: return sizeof(ulonglong);
|
|
|
|
case PLUGIN_VAR_SET: return sizeof(ulonglong);
|
|
|
|
case PLUGIN_VAR_STR: return sizeof(char*);
|
|
|
|
case PLUGIN_VAR_DOUBLE: return sizeof(double);
|
|
|
|
default: DBUG_ASSERT(0); return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
returns a bookmark for thd-local variables, creating if neccessary.
|
|
|
|
Requires that a write lock is obtained on LOCK_system_variables_hash
|
|
|
|
*/
|
|
|
|
static st_bookmark *register_var(const char *plugin, const char *name,
|
|
|
|
int flags)
|
|
|
|
{
|
2018-02-06 13:55:58 +01:00
|
|
|
size_t length= strlen(plugin) + strlen(name) + 3, size, offset, new_size;
|
2007-03-02 17:43:45 +01:00
|
|
|
st_bookmark *result;
|
|
|
|
char *varname, *p;
|
|
|
|
|
2016-09-26 17:48:08 +02:00
|
|
|
DBUG_ASSERT(flags & PLUGIN_VAR_THDLOCAL);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2016-09-26 17:48:08 +02:00
|
|
|
size= var_storage_size(flags);
|
2007-03-02 17:43:45 +01:00
|
|
|
varname= ((char*) my_alloca(length));
|
|
|
|
strxmov(varname + 1, plugin, "_", name, NullS);
|
|
|
|
for (p= varname + 1; *p; p++)
|
|
|
|
if (*p == '-')
|
|
|
|
*p= '_';
|
|
|
|
|
|
|
|
if (!(result= find_bookmark(NULL, varname + 1, flags)))
|
|
|
|
{
|
2014-01-28 08:12:43 +01:00
|
|
|
result= (st_bookmark*) alloc_root(&plugin_vars_mem_root,
|
2007-04-13 19:23:02 +02:00
|
|
|
sizeof(struct st_bookmark) + length-1);
|
2013-04-07 15:26:58 +02:00
|
|
|
varname[0]= plugin_var_bookmark_key(flags);
|
2007-04-02 20:38:58 +02:00
|
|
|
memcpy(result->key, varname, length);
|
2018-02-06 13:55:58 +01:00
|
|
|
result->name_len= (uint)(length - 2);
|
2007-03-02 17:43:45 +01:00
|
|
|
result->offset= -1;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ASSERT(size && !(size & (size-1))); /* must be power of 2 */
|
|
|
|
|
|
|
|
offset= global_system_variables.dynamic_variables_size;
|
|
|
|
offset= (offset + size - 1) & ~(size - 1);
|
|
|
|
result->offset= (int) offset;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
new_size= (offset + size + 63) & ~63;
|
|
|
|
|
|
|
|
if (new_size > global_variables_dynamic_size)
|
|
|
|
{
|
2007-05-24 18:47:58 +02:00
|
|
|
global_system_variables.dynamic_variables_ptr= (char*)
|
2020-01-29 13:50:26 +01:00
|
|
|
my_realloc(key_memory_global_system_variables,
|
|
|
|
global_system_variables.dynamic_variables_ptr, new_size,
|
2007-03-02 17:43:45 +01:00
|
|
|
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
|
2007-05-24 18:47:58 +02:00
|
|
|
max_system_variables.dynamic_variables_ptr= (char*)
|
2020-01-29 13:50:26 +01:00
|
|
|
my_realloc(key_memory_global_system_variables,
|
|
|
|
max_system_variables.dynamic_variables_ptr, new_size,
|
2007-03-02 17:43:45 +01:00
|
|
|
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
|
2007-04-26 21:26:04 +02:00
|
|
|
/*
|
|
|
|
Clear the new variable value space. This is required for string
|
|
|
|
variables. If their value is non-NULL, it must point to a valid
|
|
|
|
string.
|
|
|
|
*/
|
|
|
|
bzero(global_system_variables.dynamic_variables_ptr +
|
|
|
|
global_variables_dynamic_size,
|
|
|
|
new_size - global_variables_dynamic_size);
|
|
|
|
bzero(max_system_variables.dynamic_variables_ptr +
|
|
|
|
global_variables_dynamic_size,
|
|
|
|
new_size - global_variables_dynamic_size);
|
2007-03-02 17:43:45 +01:00
|
|
|
global_variables_dynamic_size= new_size;
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2018-02-06 13:55:58 +01:00
|
|
|
global_system_variables.dynamic_variables_head= (uint)offset;
|
|
|
|
max_system_variables.dynamic_variables_head= (uint)offset;
|
|
|
|
global_system_variables.dynamic_variables_size= (uint)(offset + size);
|
|
|
|
max_system_variables.dynamic_variables_size= (uint)(offset + size);
|
2007-03-02 17:43:45 +01:00
|
|
|
global_system_variables.dynamic_variables_version++;
|
|
|
|
max_system_variables.dynamic_variables_version++;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
result->version= global_system_variables.dynamic_variables_version;
|
|
|
|
|
|
|
|
/* this should succeed because we have already checked if a dup exists */
|
2007-05-24 18:47:58 +02:00
|
|
|
if (my_hash_insert(&bookmark_hash, (uchar*) result))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "failed to add placeholder to hash");
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my_afree(varname);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-06-27 13:01:22 +02:00
|
|
|
|
|
|
|
void sync_dynamic_session_variables(THD* thd, bool global_lock)
|
|
|
|
{
|
|
|
|
uint idx;
|
|
|
|
|
|
|
|
thd->variables.dynamic_variables_ptr= (char*)
|
2020-01-29 13:50:26 +01:00
|
|
|
my_realloc(key_memory_THD_variables,
|
|
|
|
thd->variables.dynamic_variables_ptr,
|
2016-06-27 13:01:22 +02:00
|
|
|
global_variables_dynamic_size,
|
|
|
|
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
|
|
|
|
|
|
|
|
if (global_lock)
|
|
|
|
mysql_mutex_lock(&LOCK_global_system_variables);
|
|
|
|
|
|
|
|
mysql_mutex_assert_owner(&LOCK_global_system_variables);
|
|
|
|
|
|
|
|
memcpy(thd->variables.dynamic_variables_ptr +
|
|
|
|
thd->variables.dynamic_variables_size,
|
|
|
|
global_system_variables.dynamic_variables_ptr +
|
|
|
|
thd->variables.dynamic_variables_size,
|
|
|
|
global_system_variables.dynamic_variables_size -
|
|
|
|
thd->variables.dynamic_variables_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
now we need to iterate through any newly copied 'defaults'
|
|
|
|
and if it is a string type with MEMALLOC flag, we need to strdup
|
|
|
|
*/
|
|
|
|
for (idx= 0; idx < bookmark_hash.records; idx++)
|
|
|
|
{
|
|
|
|
st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx);
|
|
|
|
|
|
|
|
if (v->version <= thd->variables.dynamic_variables_version)
|
|
|
|
continue; /* already in thd->variables */
|
|
|
|
|
|
|
|
/* Here we do anything special that may be required of the data types */
|
|
|
|
|
2016-09-28 17:55:28 +02:00
|
|
|
if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
|
|
|
|
v->key[0] & BOOKMARK_MEMALLOC)
|
2016-06-27 13:01:22 +02:00
|
|
|
{
|
2016-09-28 17:55:28 +02:00
|
|
|
char **pp= (char**) (thd->variables.dynamic_variables_ptr + v->offset);
|
2016-06-27 13:01:22 +02:00
|
|
|
if (*pp)
|
2020-01-29 13:50:26 +01:00
|
|
|
*pp= my_strdup(key_memory_THD_variables, *pp, MYF(MY_WME|MY_FAE));
|
2016-06-27 13:01:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (global_lock)
|
|
|
|
mysql_mutex_unlock(&LOCK_global_system_variables);
|
|
|
|
|
|
|
|
thd->variables.dynamic_variables_version=
|
|
|
|
global_system_variables.dynamic_variables_version;
|
|
|
|
thd->variables.dynamic_variables_head=
|
|
|
|
global_system_variables.dynamic_variables_head;
|
|
|
|
thd->variables.dynamic_variables_size=
|
|
|
|
global_system_variables.dynamic_variables_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
returns a pointer to the memory which holds the thd-local variable or
|
|
|
|
a pointer to the global variable if thd==null.
|
|
|
|
If required, will sync with global variables if the requested variable
|
|
|
|
has not yet been allocated in the current thread.
|
|
|
|
*/
|
2007-05-24 18:47:58 +02:00
|
|
|
static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2011-07-10 20:21:18 +02:00
|
|
|
DBUG_ENTER("intern_sys_var_ptr");
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ASSERT(offset >= 0);
|
|
|
|
DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!thd)
|
2011-07-10 20:21:18 +02:00
|
|
|
DBUG_RETURN((uchar*) global_system_variables.dynamic_variables_ptr + offset);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
2007-03-23 18:14:46 +01:00
|
|
|
dynamic_variables_head points to the largest valid offset
|
2007-03-02 17:43:45 +01:00
|
|
|
*/
|
|
|
|
if (!thd->variables.dynamic_variables_ptr ||
|
|
|
|
(uint)offset > thd->variables.dynamic_variables_head)
|
|
|
|
{
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_rdlock(&LOCK_system_variables_hash);
|
2016-06-27 13:01:22 +02:00
|
|
|
sync_dynamic_session_variables(thd, global_lock);
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2011-07-10 20:21:18 +02:00
|
|
|
DBUG_RETURN((uchar*)thd->variables.dynamic_variables_ptr + offset);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
For correctness and simplicity's sake, a pointer to a function
|
|
|
|
must be compatible with pointed-to type, that is, the return and
|
|
|
|
parameters types must be the same. Thus, a callback function is
|
|
|
|
defined for each scalar type. The functions are assigned in
|
|
|
|
construct_options to their respective types.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char *mysql_sys_var_char(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (char *) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int *mysql_sys_var_int(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (int *) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static long *mysql_sys_var_long(THD* thd, int offset)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
return (long *) intern_sys_var_ptr(thd, offset, true);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
static unsigned long *mysql_sys_var_ulong(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (unsigned long *) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static long long *mysql_sys_var_longlong(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (long long *) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long long *mysql_sys_var_ulonglong(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (unsigned long long *) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char **mysql_sys_var_str(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (char **) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2013-05-19 20:08:06 +02:00
|
|
|
static double *mysql_sys_var_double(THD* thd, int offset)
|
|
|
|
{
|
|
|
|
return (double *) intern_sys_var_ptr(thd, offset, true);
|
|
|
|
}
|
|
|
|
|
2007-04-02 20:38:58 +02:00
|
|
|
void plugin_thdvar_init(THD *thd)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-05-05 01:44:07 +02:00
|
|
|
plugin_ref old_table_plugin= thd->variables.table_plugin;
|
2014-06-14 22:15:52 +02:00
|
|
|
plugin_ref old_tmp_table_plugin= thd->variables.tmp_table_plugin;
|
2015-03-10 07:28:51 +01:00
|
|
|
plugin_ref old_enforced_table_plugin= thd->variables.enforced_table_plugin;
|
2007-05-05 01:44:07 +02:00
|
|
|
DBUG_ENTER("plugin_thdvar_init");
|
2014-10-04 19:59:07 +02:00
|
|
|
|
2014-06-14 22:15:52 +02:00
|
|
|
// This function may be called many times per THD (e.g. on COM_CHANGE_USER)
|
2007-05-05 01:44:07 +02:00
|
|
|
thd->variables.table_plugin= NULL;
|
2014-06-14 22:15:52 +02:00
|
|
|
thd->variables.tmp_table_plugin= NULL;
|
2015-03-10 07:28:51 +01:00
|
|
|
thd->variables.enforced_table_plugin= NULL;
|
2014-10-23 21:01:52 +02:00
|
|
|
cleanup_variables(&thd->variables);
|
2014-10-04 19:59:07 +02:00
|
|
|
|
2019-03-19 17:04:10 +01:00
|
|
|
/* This and all other variable cleanups are here for COM_CHANGE_USER :( */
|
|
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
|
thd->session_tracker.sysvars.deinit(thd);
|
|
|
|
#endif
|
|
|
|
|
2007-05-05 01:44:07 +02:00
|
|
|
thd->variables= global_system_variables;
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/* we are going to allocate these lazily */
|
|
|
|
thd->variables.dynamic_variables_version= 0;
|
|
|
|
thd->variables.dynamic_variables_size= 0;
|
|
|
|
thd->variables.dynamic_variables_ptr= 0;
|
|
|
|
|
2016-09-28 19:26:13 +02:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
|
|
|
thd->variables.table_plugin=
|
|
|
|
intern_plugin_lock(NULL, global_system_variables.table_plugin);
|
|
|
|
if (global_system_variables.tmp_table_plugin)
|
|
|
|
thd->variables.tmp_table_plugin=
|
|
|
|
intern_plugin_lock(NULL, global_system_variables.tmp_table_plugin);
|
|
|
|
if (global_system_variables.enforced_table_plugin)
|
|
|
|
thd->variables.enforced_table_plugin=
|
|
|
|
intern_plugin_lock(NULL, global_system_variables.enforced_table_plugin);
|
|
|
|
intern_plugin_unlock(NULL, old_table_plugin);
|
|
|
|
intern_plugin_unlock(NULL, old_tmp_table_plugin);
|
|
|
|
intern_plugin_unlock(NULL, old_enforced_table_plugin);
|
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2014-08-06 14:39:15 +02:00
|
|
|
|
2019-03-19 17:04:10 +01:00
|
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
|
thd->session_tracker.sysvars.init(thd);
|
|
|
|
#endif
|
2007-05-05 01:44:07 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2007-04-02 20:38:58 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Unlocks all system variables which hold a reference
|
|
|
|
*/
|
|
|
|
static void unlock_variables(THD *thd, struct system_variables *vars)
|
|
|
|
{
|
|
|
|
intern_plugin_unlock(NULL, vars->table_plugin);
|
2014-06-14 22:15:52 +02:00
|
|
|
intern_plugin_unlock(NULL, vars->tmp_table_plugin);
|
2015-03-10 07:28:51 +01:00
|
|
|
intern_plugin_unlock(NULL, vars->enforced_table_plugin);
|
|
|
|
vars->table_plugin= vars->tmp_table_plugin= vars->enforced_table_plugin= NULL;
|
2007-04-02 20:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Frees memory used by system variables
|
2007-04-26 21:26:04 +02:00
|
|
|
|
|
|
|
Unlike plugin_vars_free_values() it frees all variables of all plugins,
|
|
|
|
it's used on shutdown.
|
2007-04-02 20:38:58 +02:00
|
|
|
*/
|
2014-10-23 21:01:52 +02:00
|
|
|
static void cleanup_variables(struct system_variables *vars)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
st_bookmark *v;
|
|
|
|
uint idx;
|
|
|
|
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_rdlock(&LOCK_system_variables_hash);
|
2007-03-02 17:43:45 +01:00
|
|
|
for (idx= 0; idx < bookmark_hash.records; idx++)
|
|
|
|
{
|
2009-10-14 18:37:38 +02:00
|
|
|
v= (st_bookmark*) my_hash_element(&bookmark_hash, idx);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2011-07-10 20:09:17 +02:00
|
|
|
if (v->version > vars->dynamic_variables_version)
|
|
|
|
continue; /* not in vars */
|
|
|
|
|
|
|
|
DBUG_ASSERT((uint)v->offset <= vars->dynamic_variables_head);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2014-10-23 21:01:52 +02:00
|
|
|
/* free allocated strings (PLUGIN_VAR_STR | PLUGIN_VAR_MEMALLOC) */
|
2011-07-10 20:09:17 +02:00
|
|
|
if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
|
2013-04-07 15:26:58 +02:00
|
|
|
v->key[0] & BOOKMARK_MEMALLOC)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2011-07-10 20:09:17 +02:00
|
|
|
char **ptr= (char**)(vars->dynamic_variables_ptr + v->offset);
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(*ptr);
|
2007-03-02 17:43:45 +01:00
|
|
|
*ptr= NULL;
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
}
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-04-13 19:23:02 +02:00
|
|
|
DBUG_ASSERT(vars->table_plugin == NULL);
|
2014-06-14 22:15:52 +02:00
|
|
|
DBUG_ASSERT(vars->tmp_table_plugin == NULL);
|
2015-03-10 07:28:51 +01:00
|
|
|
DBUG_ASSERT(vars->enforced_table_plugin == NULL);
|
2007-04-13 19:23:02 +02:00
|
|
|
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(vars->dynamic_variables_ptr);
|
2007-04-02 20:38:58 +02:00
|
|
|
vars->dynamic_variables_ptr= NULL;
|
|
|
|
vars->dynamic_variables_size= 0;
|
|
|
|
vars->dynamic_variables_version= 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void plugin_thdvar_cleanup(THD *thd)
|
|
|
|
{
|
|
|
|
uint idx;
|
|
|
|
plugin_ref *list;
|
|
|
|
DBUG_ENTER("plugin_thdvar_cleanup");
|
|
|
|
|
2019-03-19 17:04:10 +01:00
|
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
|
thd->session_tracker.sysvars.deinit(thd);
|
|
|
|
#endif
|
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-04-02 20:38:58 +02:00
|
|
|
unlock_variables(thd, &thd->variables);
|
2014-10-23 21:01:52 +02:00
|
|
|
cleanup_variables(&thd->variables);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-04-16 18:16:17 +02:00
|
|
|
if ((idx= thd->lex->plugins.elements))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-04-16 18:16:17 +02:00
|
|
|
list= ((plugin_ref*) thd->lex->plugins.buffer) + idx - 1;
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_PRINT("info",("unlocking %d plugins", idx));
|
2007-05-24 18:47:58 +02:00
|
|
|
while ((uchar*) list >= thd->lex->plugins.buffer)
|
2007-03-02 17:43:45 +01:00
|
|
|
intern_plugin_unlock(NULL, *list--);
|
|
|
|
}
|
|
|
|
|
|
|
|
reap_plugins();
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_plugin);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-04-16 18:16:17 +02:00
|
|
|
reset_dynamic(&thd->lex->plugins);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 21:26:04 +02:00
|
|
|
/**
|
|
|
|
@brief Free values of thread variables of a plugin.
|
|
|
|
|
2007-08-15 15:43:08 +02:00
|
|
|
This must be called before a plugin is deleted. Otherwise its
|
2007-04-26 21:26:04 +02:00
|
|
|
variables are no longer accessible and the value space is lost. Note
|
|
|
|
that only string values with PLUGIN_VAR_MEMALLOC are allocated and
|
|
|
|
must be freed.
|
|
|
|
*/
|
|
|
|
|
2023-01-19 21:53:16 +01:00
|
|
|
static void plugin_vars_free_values(st_mysql_sys_var **vars)
|
2007-04-26 21:26:04 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("plugin_vars_free_values");
|
|
|
|
|
2023-01-19 21:53:16 +01:00
|
|
|
if (!vars)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
|
|
|
|
while(st_mysql_sys_var *var= *vars++)
|
2007-04-26 21:26:04 +02:00
|
|
|
{
|
2023-01-19 21:53:16 +01:00
|
|
|
if ((var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
|
|
|
|
var->flags & PLUGIN_VAR_MEMALLOC)
|
2007-04-26 21:26:04 +02:00
|
|
|
{
|
2023-01-19 21:53:16 +01:00
|
|
|
char **val;
|
|
|
|
if (var->flags & PLUGIN_VAR_THDLOCAL)
|
|
|
|
{
|
|
|
|
st_bookmark *v= find_bookmark(0, var->name, var->flags);
|
|
|
|
if (!v)
|
|
|
|
continue;
|
|
|
|
val= (char**)(global_system_variables.dynamic_variables_ptr + v->offset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val= *(char***) (var + 1);
|
|
|
|
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("plugin", ("freeing value for: '%s' addr: %p",
|
2023-01-19 21:53:16 +01:00
|
|
|
var->name, val));
|
|
|
|
my_free(*val);
|
|
|
|
*val= NULL;
|
2007-04-26 21:26:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2014-08-27 23:28:59 +02:00
|
|
|
static SHOW_TYPE pluginvar_show_type(const st_mysql_sys_var *plugin_var)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2014-04-09 14:28:07 +02:00
|
|
|
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_UNSIGNED)) {
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_BOOL:
|
|
|
|
return SHOW_MY_BOOL;
|
2007-03-02 17:43:45 +01:00
|
|
|
case PLUGIN_VAR_INT:
|
2014-04-09 14:28:07 +02:00
|
|
|
return SHOW_SINT;
|
|
|
|
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED:
|
|
|
|
return SHOW_UINT;
|
2007-03-02 17:43:45 +01:00
|
|
|
case PLUGIN_VAR_LONG:
|
2014-04-09 14:28:07 +02:00
|
|
|
return SHOW_SLONG;
|
|
|
|
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED:
|
|
|
|
return SHOW_ULONG;
|
2007-03-02 17:43:45 +01:00
|
|
|
case PLUGIN_VAR_LONGLONG:
|
2014-04-09 14:28:07 +02:00
|
|
|
return SHOW_SLONGLONG;
|
|
|
|
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED:
|
|
|
|
return SHOW_ULONGLONG;
|
2007-03-02 17:43:45 +01:00
|
|
|
case PLUGIN_VAR_STR:
|
2009-12-22 10:35:56 +01:00
|
|
|
return SHOW_CHAR_PTR;
|
|
|
|
case PLUGIN_VAR_ENUM:
|
|
|
|
case PLUGIN_VAR_SET:
|
|
|
|
return SHOW_CHAR;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE:
|
|
|
|
return SHOW_DOUBLE;
|
2007-03-02 17:43:45 +01:00
|
|
|
default:
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return SHOW_UNDEF;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2014-08-27 23:28:59 +02:00
|
|
|
static int pluginvar_sysvar_flags(const st_mysql_sys_var *p)
|
|
|
|
{
|
|
|
|
return (p->flags & PLUGIN_VAR_THDLOCAL ? sys_var::SESSION : sys_var::GLOBAL)
|
|
|
|
| (p->flags & PLUGIN_VAR_READONLY ? sys_var::READONLY : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sys_var_pluginvar::sys_var_pluginvar(sys_var_chain *chain, const char *name_arg,
|
2022-02-15 08:18:55 +01:00
|
|
|
st_plugin_int *p, st_mysql_sys_var *pv, const char *substitute)
|
2014-08-27 23:28:59 +02:00
|
|
|
: sys_var(chain, name_arg, pv->comment, pluginvar_sysvar_flags(pv),
|
|
|
|
0, pv->flags & PLUGIN_VAR_NOCMDOPT ? -1 : 0, NO_ARG,
|
|
|
|
pluginvar_show_type(pv), 0,
|
2022-02-15 08:18:55 +01:00
|
|
|
NULL, VARIABLE_NOT_IN_BINLOG, NULL, NULL, substitute),
|
2014-08-27 23:28:59 +02:00
|
|
|
plugin(p), plugin_var(pv)
|
|
|
|
{
|
|
|
|
plugin_var->name= name_arg;
|
|
|
|
plugin_opt_set_limits(&option, pv);
|
|
|
|
}
|
|
|
|
|
2019-07-17 19:15:55 +02:00
|
|
|
uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) const
|
2007-04-13 19:24:46 +02:00
|
|
|
{
|
2014-09-03 20:16:51 +02:00
|
|
|
if (type == OPT_DEFAULT)
|
2015-02-05 10:54:55 +01:00
|
|
|
{
|
|
|
|
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
|
|
|
|
case PLUGIN_VAR_BOOL:
|
2017-09-28 12:38:02 +02:00
|
|
|
thd->sys_var_tmp.my_bool_value= (my_bool)option.def_value;
|
2015-02-05 10:54:55 +01:00
|
|
|
return (uchar*) &thd->sys_var_tmp.my_bool_value;
|
|
|
|
case PLUGIN_VAR_INT:
|
2017-09-28 12:38:02 +02:00
|
|
|
thd->sys_var_tmp.int_value= (int)option.def_value;
|
2015-02-05 10:54:55 +01:00
|
|
|
return (uchar*) &thd->sys_var_tmp.int_value;
|
|
|
|
case PLUGIN_VAR_LONG:
|
|
|
|
case PLUGIN_VAR_ENUM:
|
2017-09-28 12:38:02 +02:00
|
|
|
thd->sys_var_tmp.long_value= (long)option.def_value;
|
2015-02-05 10:54:55 +01:00
|
|
|
return (uchar*) &thd->sys_var_tmp.long_value;
|
|
|
|
case PLUGIN_VAR_LONGLONG:
|
|
|
|
case PLUGIN_VAR_SET:
|
|
|
|
return (uchar*) &option.def_value;
|
|
|
|
case PLUGIN_VAR_STR:
|
|
|
|
thd->sys_var_tmp.ptr_value= (void*) option.def_value;
|
|
|
|
return (uchar*) &thd->sys_var_tmp.ptr_value;
|
|
|
|
case PLUGIN_VAR_DOUBLE:
|
|
|
|
thd->sys_var_tmp.double_value= getopt_ulonglong2double(option.def_value);
|
|
|
|
return (uchar*) &thd->sys_var_tmp.double_value;
|
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
2014-09-03 20:16:51 +02:00
|
|
|
|
2007-04-27 23:42:22 +02:00
|
|
|
DBUG_ASSERT(thd || (type == OPT_GLOBAL));
|
2007-03-02 17:43:45 +01:00
|
|
|
if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
|
|
|
|
{
|
2007-04-27 23:42:22 +02:00
|
|
|
if (type == OPT_GLOBAL)
|
2007-03-02 17:43:45 +01:00
|
|
|
thd= NULL;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
return intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false);
|
|
|
|
}
|
2007-05-24 18:47:58 +02:00
|
|
|
return *(uchar**) (plugin_var+1);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2015-04-10 02:36:54 +02:00
|
|
|
bool sys_var_pluginvar::session_is_default(THD *thd)
|
|
|
|
{
|
|
|
|
uchar *value= plugin_var->flags & PLUGIN_VAR_THDLOCAL
|
|
|
|
? intern_sys_var_ptr(thd, *(int*) (plugin_var+1), true)
|
|
|
|
: *(uchar**) (plugin_var+1);
|
|
|
|
|
|
|
|
real_value_ptr(thd, OPT_SESSION);
|
|
|
|
|
|
|
|
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
|
|
|
|
case PLUGIN_VAR_BOOL:
|
|
|
|
return option.def_value == *(my_bool*)value;
|
|
|
|
case PLUGIN_VAR_INT:
|
|
|
|
return option.def_value == *(int*)value;
|
|
|
|
case PLUGIN_VAR_LONG:
|
|
|
|
case PLUGIN_VAR_ENUM:
|
|
|
|
return option.def_value == *(long*)value;
|
|
|
|
case PLUGIN_VAR_LONGLONG:
|
|
|
|
case PLUGIN_VAR_SET:
|
|
|
|
return option.def_value == *(longlong*)value;
|
|
|
|
case PLUGIN_VAR_STR:
|
|
|
|
{
|
|
|
|
const char *a=(char*)option.def_value;
|
|
|
|
const char *b=(char*)value;
|
|
|
|
return (!a && !b) || (a && b && strcmp(a,b));
|
|
|
|
}
|
|
|
|
case PLUGIN_VAR_DOUBLE:
|
|
|
|
return getopt_ulonglong2double(option.def_value) == *(double*)value;
|
|
|
|
}
|
2015-06-22 17:17:03 +02:00
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return 0;
|
2015-04-10 02:36:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-17 19:15:55 +02:00
|
|
|
TYPELIB* sys_var_pluginvar::plugin_var_typelib(void) const
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-05-01 01:42:15 +02:00
|
|
|
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {
|
|
|
|
case PLUGIN_VAR_ENUM:
|
|
|
|
return ((sysvar_enum_t *)plugin_var)->typelib;
|
|
|
|
case PLUGIN_VAR_SET:
|
|
|
|
return ((sysvar_set_t *)plugin_var)->typelib;
|
|
|
|
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
|
|
|
return ((thdvar_enum_t *)plugin_var)->typelib;
|
|
|
|
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
|
|
|
return ((thdvar_set_t *)plugin_var)->typelib;
|
|
|
|
default:
|
|
|
|
return NULL;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2010-01-19 14:30:55 +01:00
|
|
|
return NULL; /* Keep compiler happy */
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2019-07-17 19:15:55 +02:00
|
|
|
const uchar* sys_var_pluginvar::do_value_ptr(THD *thd, enum_var_type type,
|
|
|
|
const LEX_CSTRING *base) const
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2019-07-17 19:15:55 +02:00
|
|
|
const uchar* result= real_value_ptr(thd, type);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2007-04-30 18:49:38 +02:00
|
|
|
if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_ENUM)
|
2007-05-24 18:47:58 +02:00
|
|
|
result= (uchar*) get_type(plugin_var_typelib(), *(ulong*)result);
|
2007-04-30 18:49:38 +02:00
|
|
|
else if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_SET)
|
2009-12-22 10:35:56 +01:00
|
|
|
result= (uchar*) set_to_string(thd, 0, *(ulonglong*) result,
|
|
|
|
plugin_var_typelib()->type_names);
|
2007-03-02 17:43:45 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
bool sys_var_pluginvar::do_check(THD *thd, set_var *var)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
st_item_value_holder value;
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_ASSERT(!is_readonly());
|
|
|
|
DBUG_ASSERT(plugin_var->check);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
value.value_type= item_value_type;
|
|
|
|
value.val_str= item_val_str;
|
|
|
|
value.val_int= item_val_int;
|
|
|
|
value.val_real= item_val_real;
|
2009-12-22 10:35:56 +01:00
|
|
|
value.is_unsigned= item_is_unsigned;
|
2007-03-02 17:43:45 +01:00
|
|
|
value.item= var->value;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
return plugin_var->check(thd, plugin_var, &var->save_result, &value);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
bool sys_var_pluginvar::session_update(THD *thd, set_var *var)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2009-12-22 10:35:56 +01:00
|
|
|
DBUG_ASSERT(!is_readonly());
|
|
|
|
DBUG_ASSERT(plugin_var->flags & PLUGIN_VAR_THDLOCAL);
|
|
|
|
DBUG_ASSERT(thd == current_thd);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_lock(&LOCK_global_system_variables);
|
2014-09-03 20:16:51 +02:00
|
|
|
void *tgt= real_value_ptr(thd, OPT_SESSION);
|
2009-12-22 10:35:56 +01:00
|
|
|
const void *src= var->value ? (void*)&var->save_result
|
|
|
|
: (void*)real_value_ptr(thd, OPT_GLOBAL);
|
2010-01-07 06:42:07 +01:00
|
|
|
mysql_mutex_unlock(&LOCK_global_system_variables);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2012-01-16 20:16:35 +01:00
|
|
|
plugin_var->update(thd, plugin_var, tgt, src);
|
2014-07-09 10:35:31 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
return false;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2016-09-26 17:48:08 +02:00
|
|
|
static const void *var_def_ptr(st_mysql_sys_var *pv)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2016-09-26 17:48:08 +02:00
|
|
|
switch (pv->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_INT:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_uint_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_LONG:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_ulong_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_LONGLONG:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_ulonglong_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_ENUM:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_enum_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_SET:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_set_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_BOOL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_bool_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_STR:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_str_t*) pv)->def_val;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((sysvar_double_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_uint_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_ulong_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_ulonglong_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_enum_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_set_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_bool_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_str_t*) pv)->def_val;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL:
|
2016-09-26 17:48:08 +02:00
|
|
|
return &((thdvar_double_t*) pv)->def_val;
|
2009-12-22 10:35:56 +01:00
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0);
|
2016-09-26 17:48:08 +02:00
|
|
|
return NULL;
|
2009-12-22 10:35:56 +01:00
|
|
|
}
|
2016-09-26 17:48:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sys_var_pluginvar::global_update(THD *thd, set_var *var)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(!is_readonly());
|
|
|
|
mysql_mutex_assert_owner(&LOCK_global_system_variables);
|
|
|
|
|
2016-09-28 17:55:28 +02:00
|
|
|
void *tgt= real_value_ptr(thd, OPT_GLOBAL);
|
2016-09-26 17:48:08 +02:00
|
|
|
const void *src= &var->save_result;
|
|
|
|
|
|
|
|
if (!var->value)
|
|
|
|
src= var_def_ptr(plugin_var);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
|
|
|
plugin_var->update(thd, plugin_var, tgt, src);
|
|
|
|
return false;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define OPTION_SET_LIMITS(type, options, opt) \
|
|
|
|
options->var_type= type; \
|
|
|
|
options->def_value= (opt)->def_val; \
|
|
|
|
options->min_value= (opt)->min_val; \
|
|
|
|
options->max_value= (opt)->max_val; \
|
2007-04-30 18:49:38 +02:00
|
|
|
options->block_size= (long) (opt)->blk_sz
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2013-05-19 20:08:06 +02:00
|
|
|
#define OPTION_SET_LIMITS_DOUBLE(options, opt) \
|
|
|
|
options->var_type= GET_DOUBLE; \
|
|
|
|
options->def_value= (longlong) getopt_double2ulonglong((opt)->def_val); \
|
|
|
|
options->min_value= (longlong) getopt_double2ulonglong((opt)->min_val); \
|
|
|
|
options->max_value= getopt_double2ulonglong((opt)->max_val); \
|
|
|
|
options->block_size= (long) (opt)->blk_sz;
|
|
|
|
|
2013-04-09 23:27:24 +02:00
|
|
|
void plugin_opt_set_limits(struct my_option *options,
|
|
|
|
const struct st_mysql_sys_var *opt)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-12-06 18:03:30 +01:00
|
|
|
options->sub_size= 0;
|
|
|
|
|
2007-04-13 19:24:46 +02:00
|
|
|
switch (opt->flags & (PLUGIN_VAR_TYPEMASK |
|
2007-03-02 17:43:45 +01:00
|
|
|
PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL)) {
|
|
|
|
/* global system variables */
|
|
|
|
case PLUGIN_VAR_INT:
|
|
|
|
OPTION_SET_LIMITS(GET_INT, options, (sysvar_int_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED:
|
|
|
|
OPTION_SET_LIMITS(GET_UINT, options, (sysvar_uint_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONG:
|
|
|
|
OPTION_SET_LIMITS(GET_LONG, options, (sysvar_long_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED:
|
|
|
|
OPTION_SET_LIMITS(GET_ULONG, options, (sysvar_ulong_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONGLONG:
|
|
|
|
OPTION_SET_LIMITS(GET_LL, options, (sysvar_longlong_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED:
|
|
|
|
OPTION_SET_LIMITS(GET_ULL, options, (sysvar_ulonglong_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_ENUM:
|
|
|
|
options->var_type= GET_ENUM;
|
2007-05-01 01:42:15 +02:00
|
|
|
options->typelib= ((sysvar_enum_t*) opt)->typelib;
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= ((sysvar_enum_t*) opt)->def_val;
|
2007-03-02 17:43:45 +01:00
|
|
|
options->min_value= options->block_size= 0;
|
|
|
|
options->max_value= options->typelib->count - 1;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_SET:
|
|
|
|
options->var_type= GET_SET;
|
2007-05-01 01:42:15 +02:00
|
|
|
options->typelib= ((sysvar_set_t*) opt)->typelib;
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= ((sysvar_set_t*) opt)->def_val;
|
2007-03-02 17:43:45 +01:00
|
|
|
options->min_value= options->block_size= 0;
|
2010-01-19 14:30:55 +01:00
|
|
|
options->max_value= (1ULL << options->typelib->count) - 1;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_BOOL:
|
|
|
|
options->var_type= GET_BOOL;
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= ((sysvar_bool_t*) opt)->def_val;
|
2016-07-12 13:41:29 +02:00
|
|
|
options->typelib= &bool_typelib;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_STR:
|
2007-04-26 21:26:04 +02:00
|
|
|
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?
|
|
|
|
GET_STR_ALLOC : GET_STR);
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= (intptr) ((sysvar_str_t*) opt)->def_val;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE:
|
|
|
|
OPTION_SET_LIMITS_DOUBLE(options, (sysvar_double_t*) opt);
|
|
|
|
break;
|
2007-03-02 17:43:45 +01:00
|
|
|
/* threadlocal variables */
|
|
|
|
case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS(GET_INT, options, (thdvar_int_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS(GET_UINT, options, (thdvar_uint_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS(GET_LONG, options, (thdvar_long_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS(GET_ULONG, options, (thdvar_ulong_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS(GET_LL, options, (thdvar_longlong_t*) opt);
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS(GET_ULL, options, (thdvar_ulonglong_t*) opt);
|
|
|
|
break;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL:
|
|
|
|
OPTION_SET_LIMITS_DOUBLE(options, (thdvar_double_t*) opt);
|
|
|
|
break;
|
2007-03-02 17:43:45 +01:00
|
|
|
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
|
|
|
options->var_type= GET_ENUM;
|
2007-05-01 01:42:15 +02:00
|
|
|
options->typelib= ((thdvar_enum_t*) opt)->typelib;
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= ((thdvar_enum_t*) opt)->def_val;
|
2007-03-02 17:43:45 +01:00
|
|
|
options->min_value= options->block_size= 0;
|
|
|
|
options->max_value= options->typelib->count - 1;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
|
|
|
options->var_type= GET_SET;
|
2007-05-01 01:42:15 +02:00
|
|
|
options->typelib= ((thdvar_set_t*) opt)->typelib;
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= ((thdvar_set_t*) opt)->def_val;
|
2007-03-02 17:43:45 +01:00
|
|
|
options->min_value= options->block_size= 0;
|
2010-01-19 14:30:55 +01:00
|
|
|
options->max_value= (1ULL << options->typelib->count) - 1;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
|
|
|
|
options->var_type= GET_BOOL;
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= ((thdvar_bool_t*) opt)->def_val;
|
2016-07-12 13:41:29 +02:00
|
|
|
options->typelib= &bool_typelib;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
|
2007-04-26 21:26:04 +02:00
|
|
|
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?
|
|
|
|
GET_STR_ALLOC : GET_STR);
|
2008-02-19 21:55:13 +01:00
|
|
|
options->def_value= (intptr) ((thdvar_str_t*) opt)->def_val;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
options->arg_type= REQUIRED_ARG;
|
|
|
|
if (opt->flags & PLUGIN_VAR_NOCMDARG)
|
|
|
|
options->arg_type= NO_ARG;
|
|
|
|
if (opt->flags & PLUGIN_VAR_OPCMDARG)
|
2007-04-13 19:24:46 +02:00
|
|
|
options->arg_type= OPT_ARG;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
/**
|
|
|
|
Creates a set of my_option objects associated with a specified plugin-
|
|
|
|
handle.
|
|
|
|
|
|
|
|
@param mem_root Memory allocator to be used.
|
|
|
|
@param tmp A pointer to a plugin handle
|
|
|
|
@param[out] options A pointer to a pre-allocated static array
|
|
|
|
|
|
|
|
The set is stored in the pre-allocated static array supplied to the function.
|
|
|
|
The size of the array is calculated as (number_of_plugin_varaibles*2+3). The
|
|
|
|
reason is that each option can have a prefix '--plugin-' in addtion to the
|
|
|
|
shorter form '--<plugin-name>'. There is also space allocated for
|
|
|
|
terminating NULL pointers.
|
|
|
|
|
|
|
|
@return
|
|
|
|
@retval -1 An error occurred
|
|
|
|
@retval 0 Success
|
|
|
|
*/
|
|
|
|
|
2007-04-13 19:23:02 +02:00
|
|
|
static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
|
2009-05-14 14:03:33 +02:00
|
|
|
my_option *options)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
const char *plugin_name= tmp->plugin->name;
|
2018-01-08 14:33:23 +01:00
|
|
|
const LEX_CSTRING plugin_dash = { STRING_WITH_LEN("plugin-") };
|
2018-02-06 13:55:58 +01:00
|
|
|
size_t plugin_name_len= strlen(plugin_name);
|
|
|
|
size_t optnamelen;
|
2019-06-10 18:07:49 +02:00
|
|
|
const int max_comment_len= 255;
|
2009-05-14 14:03:33 +02:00
|
|
|
char *comment= (char *) alloc_root(mem_root, max_comment_len + 1);
|
|
|
|
char *optname;
|
|
|
|
|
2014-10-23 21:01:52 +02:00
|
|
|
int index= 0, UNINIT_VAR(offset);
|
2007-03-02 17:43:45 +01:00
|
|
|
st_mysql_sys_var *opt, **plugin_option;
|
|
|
|
st_bookmark *v;
|
2009-05-14 14:03:33 +02:00
|
|
|
|
|
|
|
/** Used to circumvent the const attribute on my_option::name */
|
|
|
|
char *plugin_name_ptr, *plugin_name_with_prefix_ptr;
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ENTER("construct_options");
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
plugin_name_ptr= (char*) alloc_root(mem_root, plugin_name_len + 1);
|
2009-05-14 14:03:33 +02:00
|
|
|
strcpy(plugin_name_ptr, plugin_name);
|
|
|
|
my_casedn_str(&my_charset_latin1, plugin_name_ptr);
|
|
|
|
convert_underscore_to_dash(plugin_name_ptr, plugin_name_len);
|
2009-12-22 10:35:56 +01:00
|
|
|
plugin_name_with_prefix_ptr= (char*) alloc_root(mem_root,
|
|
|
|
plugin_name_len +
|
|
|
|
plugin_dash.length + 1);
|
|
|
|
strxmov(plugin_name_with_prefix_ptr, plugin_dash.str, plugin_name_ptr, NullS);
|
|
|
|
|
2017-06-14 11:27:36 +02:00
|
|
|
if (!plugin_is_forced(tmp))
|
2009-12-22 10:35:56 +01:00
|
|
|
{
|
|
|
|
/* support --skip-plugin-foo syntax */
|
|
|
|
options[0].name= plugin_name_ptr;
|
|
|
|
options[1].name= plugin_name_with_prefix_ptr;
|
|
|
|
options[0].id= options[1].id= 0;
|
|
|
|
options[0].var_type= options[1].var_type= GET_ENUM;
|
|
|
|
options[0].arg_type= options[1].arg_type= OPT_ARG;
|
|
|
|
options[0].def_value= options[1].def_value= 1; /* ON */
|
|
|
|
options[0].typelib= options[1].typelib= &global_plugin_typelib;
|
|
|
|
|
|
|
|
strxnmov(comment, max_comment_len, "Enable or disable ", plugin_name,
|
2019-06-10 18:07:49 +02:00
|
|
|
" plugin. One of: ON, OFF, FORCE (don't start if the plugin"
|
|
|
|
" fails to load), FORCE_PLUS_PERMANENT (like FORCE, but the"
|
|
|
|
" plugin can not be uninstalled).", NullS);
|
2009-12-22 10:35:56 +01:00
|
|
|
options[0].comment= comment;
|
|
|
|
/*
|
|
|
|
Allocate temporary space for the value of the tristate.
|
|
|
|
This option will have a limited lifetime and is not used beyond
|
|
|
|
server initialization.
|
2010-08-05 14:34:19 +02:00
|
|
|
GET_ENUM value is an unsigned long integer.
|
2009-12-22 10:35:56 +01:00
|
|
|
*/
|
|
|
|
options[0].value= options[1].value=
|
2010-08-05 14:34:19 +02:00
|
|
|
(uchar **)alloc_root(mem_root, sizeof(ulong));
|
|
|
|
*((ulong*) options[0].value)= (ulong) options[0].def_value;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
options+= 2;
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
/*
|
|
|
|
Two passes as the 2nd pass will take pointer addresses for use
|
|
|
|
by my_getopt and register_var() in the first pass uses realloc
|
|
|
|
*/
|
|
|
|
|
2007-04-13 19:24:46 +02:00
|
|
|
for (plugin_option= tmp->plugin->system_vars;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_option && *plugin_option; plugin_option++, index++)
|
|
|
|
{
|
2007-04-13 19:24:46 +02:00
|
|
|
opt= *plugin_option;
|
2014-10-23 21:01:52 +02:00
|
|
|
|
|
|
|
if (!opt->name)
|
|
|
|
{
|
|
|
|
sql_print_error("Missing variable name in plugin '%s'.",
|
|
|
|
plugin_name);
|
|
|
|
DBUG_RETURN(-1);
|
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!(opt->flags & PLUGIN_VAR_THDLOCAL))
|
|
|
|
continue;
|
2009-05-14 14:03:33 +02:00
|
|
|
if (!(register_var(plugin_name_ptr, opt->name, opt->flags)))
|
2007-03-02 17:43:45 +01:00
|
|
|
continue;
|
|
|
|
switch (opt->flags & PLUGIN_VAR_TYPEMASK) {
|
|
|
|
case PLUGIN_VAR_BOOL:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_bool_t *) opt)->resolve= mysql_sys_var_char;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_INT:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_int_t *) opt)->resolve= mysql_sys_var_int;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONG:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_long_t *) opt)->resolve= mysql_sys_var_long;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONGLONG:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_longlong_t *) opt)->resolve= mysql_sys_var_longlong;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_STR:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_str_t *) opt)->resolve= mysql_sys_var_str;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_ENUM:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_enum_t *) opt)->resolve= mysql_sys_var_ulong;
|
2007-05-01 01:42:15 +02:00
|
|
|
break;
|
2007-03-02 17:43:45 +01:00
|
|
|
case PLUGIN_VAR_SET:
|
Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
2010-06-10 22:16:43 +02:00
|
|
|
((thdvar_set_t *) opt)->resolve= mysql_sys_var_ulonglong;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE:
|
|
|
|
((thdvar_double_t *) opt)->resolve= mysql_sys_var_double;
|
|
|
|
break;
|
2007-03-02 17:43:45 +01:00
|
|
|
default:
|
|
|
|
sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
|
2007-04-23 19:05:38 +02:00
|
|
|
opt->flags, plugin_name);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(-1);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2007-04-13 19:24:46 +02:00
|
|
|
for (plugin_option= tmp->plugin->system_vars;
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_option && *plugin_option; plugin_option++, index++)
|
|
|
|
{
|
|
|
|
switch ((opt= *plugin_option)->flags & PLUGIN_VAR_TYPEMASK) {
|
|
|
|
case PLUGIN_VAR_BOOL:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_bool;
|
|
|
|
if (!opt->update)
|
|
|
|
opt->update= update_func_bool;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_INT:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_int;
|
|
|
|
if (!opt->update)
|
|
|
|
opt->update= update_func_int;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONG:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_long;
|
|
|
|
if (!opt->update)
|
|
|
|
opt->update= update_func_long;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_LONGLONG:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_longlong;
|
|
|
|
if (!opt->update)
|
|
|
|
opt->update= update_func_longlong;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_STR:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_str;
|
|
|
|
if (!opt->update)
|
|
|
|
{
|
|
|
|
opt->update= update_func_str;
|
2009-05-14 14:03:33 +02:00
|
|
|
if (!(opt->flags & (PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)))
|
2007-04-23 19:05:38 +02:00
|
|
|
{
|
2007-05-31 16:45:22 +02:00
|
|
|
opt->flags|= PLUGIN_VAR_READONLY;
|
2007-04-23 19:05:38 +02:00
|
|
|
sql_print_warning("Server variable %s of plugin %s was forced "
|
|
|
|
"to be read-only: string variable without "
|
|
|
|
"update_func and PLUGIN_VAR_MEMALLOC flag",
|
|
|
|
opt->name, plugin_name);
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_ENUM:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_enum;
|
|
|
|
if (!opt->update)
|
|
|
|
opt->update= update_func_long;
|
|
|
|
break;
|
|
|
|
case PLUGIN_VAR_SET:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_set;
|
|
|
|
if (!opt->update)
|
2007-05-02 03:25:29 +02:00
|
|
|
opt->update= update_func_longlong;
|
2007-03-02 17:43:45 +01:00
|
|
|
break;
|
2013-05-19 20:08:06 +02:00
|
|
|
case PLUGIN_VAR_DOUBLE:
|
|
|
|
if (!opt->check)
|
|
|
|
opt->check= check_func_double;
|
|
|
|
if (!opt->update)
|
|
|
|
opt->update= update_func_double;
|
|
|
|
break;
|
2007-03-02 17:43:45 +01:00
|
|
|
default:
|
|
|
|
sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
|
2007-04-23 19:05:38 +02:00
|
|
|
opt->flags, plugin_name);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(-1);
|
|
|
|
}
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2008-01-26 01:05:15 +01:00
|
|
|
if ((opt->flags & (PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_THDLOCAL))
|
|
|
|
== PLUGIN_VAR_NOCMDOPT)
|
2007-03-02 17:43:45 +01:00
|
|
|
continue;
|
|
|
|
|
2008-01-26 01:05:15 +01:00
|
|
|
if (!(opt->flags & PLUGIN_VAR_THDLOCAL))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
optnamelen= strlen(opt->name);
|
2009-05-14 14:03:33 +02:00
|
|
|
optname= (char*) alloc_root(mem_root, plugin_name_len + optnamelen + 2);
|
|
|
|
strxmov(optname, plugin_name_ptr, "-", opt->name, NullS);
|
|
|
|
optnamelen= plugin_name_len + optnamelen + 1;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
else
|
2008-01-26 01:05:15 +01:00
|
|
|
{
|
|
|
|
/* this should not fail because register_var should create entry */
|
2009-05-14 14:03:33 +02:00
|
|
|
if (!(v= find_bookmark(plugin_name_ptr, opt->name, opt->flags)))
|
2008-01-26 01:05:15 +01:00
|
|
|
{
|
|
|
|
sql_print_error("Thread local variable '%s' not allocated "
|
|
|
|
"in plugin '%s'.", opt->name, plugin_name);
|
|
|
|
DBUG_RETURN(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
*(int*)(opt + 1)= offset= v->offset;
|
|
|
|
|
|
|
|
if (opt->flags & PLUGIN_VAR_NOCMDOPT)
|
2016-09-26 17:48:08 +02:00
|
|
|
{
|
|
|
|
char *val= global_system_variables.dynamic_variables_ptr + offset;
|
|
|
|
if (((opt->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR) &&
|
|
|
|
(opt->flags & PLUGIN_VAR_MEMALLOC))
|
|
|
|
{
|
|
|
|
char *def_val= *(char**)var_def_ptr(opt);
|
2020-01-29 13:50:26 +01:00
|
|
|
*(char**)val= def_val ? my_strdup(PSI_INSTRUMENT_ME, def_val, MYF(0)) : NULL;
|
2016-09-26 17:48:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
memcpy(val, var_def_ptr(opt), var_storage_size(opt->flags));
|
2008-01-26 01:05:15 +01:00
|
|
|
continue;
|
2016-09-26 17:48:08 +02:00
|
|
|
}
|
2008-01-26 01:05:15 +01:00
|
|
|
|
2014-07-09 10:35:31 +02:00
|
|
|
optname= (char*) memdup_root(mem_root, v->key + 1,
|
2008-01-26 01:05:15 +01:00
|
|
|
(optnamelen= v->name_len) + 1);
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
convert_underscore_to_dash(optname, optnamelen);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
options->name= optname;
|
|
|
|
options->comment= opt->comment;
|
2015-01-15 14:57:50 +01:00
|
|
|
options->app_type= (opt->flags & PLUGIN_VAR_NOSYSVAR) ? NULL : opt;
|
2009-12-22 10:35:56 +01:00
|
|
|
options->id= 0;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
plugin_opt_set_limits(options, opt);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2008-01-26 01:05:15 +01:00
|
|
|
if (opt->flags & PLUGIN_VAR_THDLOCAL)
|
|
|
|
options->value= options->u_max_value= (uchar**)
|
|
|
|
(global_system_variables.dynamic_variables_ptr + offset);
|
|
|
|
else
|
|
|
|
options->value= options->u_max_value= *(uchar***) (opt + 1);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
char *option_name_ptr;
|
2007-03-02 17:43:45 +01:00
|
|
|
options[1]= options[0];
|
2009-05-14 14:03:33 +02:00
|
|
|
options[1].name= option_name_ptr= (char*) alloc_root(mem_root,
|
|
|
|
plugin_dash.length +
|
|
|
|
optnamelen + 1);
|
|
|
|
options[1].comment= 0; /* Hidden from the help text */
|
|
|
|
strxmov(option_name_ptr, plugin_dash.str, optname, NullS);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
options+= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static my_option *construct_help_options(MEM_ROOT *mem_root,
|
|
|
|
struct st_plugin_int *p)
|
|
|
|
{
|
|
|
|
st_mysql_sys_var **opt;
|
|
|
|
my_option *opts;
|
|
|
|
uint count= EXTRA_OPTIONS;
|
|
|
|
DBUG_ENTER("construct_help_options");
|
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2)
|
|
|
|
;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
|
|
|
if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count)))
|
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
|
|
|
|
bzero(opts, sizeof(my_option) * count);
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/**
|
2023-01-19 21:53:16 +01:00
|
|
|
some plugin variables
|
2009-12-22 10:35:56 +01:00
|
|
|
have their names prefixed with the plugin name. Restore the names here
|
|
|
|
to get the correct (not double-prefixed) help text.
|
|
|
|
We won't need @@sysvars anymore and don't care about their proper names.
|
|
|
|
*/
|
2013-12-09 12:39:19 +01:00
|
|
|
restore_ptr_backup(p->nbackups, p->ptr_backup);
|
2009-12-22 10:35:56 +01:00
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
if (construct_options(mem_root, p, opts))
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
|
|
|
|
DBUG_RETURN(opts);
|
|
|
|
}
|
|
|
|
|
2021-02-05 13:57:46 +01:00
|
|
|
extern "C" my_bool mark_changed(const struct my_option *, const char *,
|
|
|
|
const char *);
|
|
|
|
my_bool mark_changed(const struct my_option *opt, const char *,
|
|
|
|
const char *filename)
|
2014-09-01 20:29:58 +02:00
|
|
|
{
|
|
|
|
if (opt->app_type)
|
|
|
|
{
|
|
|
|
sys_var *var= (sys_var*) opt->app_type;
|
2019-09-29 22:07:48 +02:00
|
|
|
if (*filename)
|
|
|
|
{
|
|
|
|
var->origin_filename= filename;
|
|
|
|
var->value_origin= sys_var::CONFIG;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
var->value_origin= sys_var::COMMAND_LINE;
|
2014-09-01 20:29:58 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-15 20:47:45 +02:00
|
|
|
/**
|
|
|
|
It is always false to mark global plugin variable unloaded just to be
|
|
|
|
safe because we have no way now to know truth about them.
|
|
|
|
|
|
|
|
TODO: make correct mechanism for global plugin variables
|
|
|
|
*/
|
|
|
|
static bool static_unload= FALSE;
|
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
/**
|
|
|
|
Create and register system variables supplied from the plugin and
|
|
|
|
assigns initial values from corresponding command line arguments.
|
|
|
|
|
|
|
|
@param tmp_root Temporary scratch space
|
|
|
|
@param[out] plugin Internal plugin structure
|
|
|
|
@param argc Number of command line arguments
|
|
|
|
@param argv Command line argument vector
|
|
|
|
|
|
|
|
The plugin will be updated with a policy on how to handle errors during
|
|
|
|
initialization.
|
|
|
|
|
|
|
|
@note Requires that a write-lock is held on LOCK_system_variables_hash
|
|
|
|
|
|
|
|
@return How initialization of the plugin should be handled.
|
|
|
|
@retval 0 Initialization should proceed.
|
|
|
|
@retval 1 Plugin is disabled.
|
|
|
|
@retval -1 An error has occurred.
|
2007-03-02 17:43:45 +01:00
|
|
|
*/
|
2009-05-14 14:03:33 +02:00
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
|
2009-05-14 14:03:33 +02:00
|
|
|
int *argc, char **argv)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
struct sys_var_chain chain= { NULL, NULL };
|
2009-05-14 14:03:33 +02:00
|
|
|
bool disable_plugin;
|
2010-09-27 14:55:09 +02:00
|
|
|
enum_plugin_load_option plugin_load_option= tmp->load_option;
|
2009-05-14 14:03:33 +02:00
|
|
|
|
2007-04-13 19:24:46 +02:00
|
|
|
MEM_ROOT *mem_root= alloc_root_inited(&tmp->mem_root) ?
|
2014-01-28 08:12:43 +01:00
|
|
|
&tmp->mem_root : &plugin_vars_mem_root;
|
2007-03-02 17:43:45 +01:00
|
|
|
st_mysql_sys_var **opt;
|
2007-10-05 02:34:28 +02:00
|
|
|
my_option *opts= NULL;
|
2014-11-29 00:53:09 +01:00
|
|
|
int error= 1;
|
2007-03-02 17:43:45 +01:00
|
|
|
struct st_bookmark *var;
|
2018-02-06 13:55:58 +01:00
|
|
|
size_t len=0, count= EXTRA_OPTIONS;
|
2013-12-09 12:39:19 +01:00
|
|
|
st_ptr_backup *tmp_backup= 0;
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_ENTER("test_plugin_options");
|
2007-04-13 19:23:02 +02:00
|
|
|
DBUG_ASSERT(tmp->plugin && tmp->name.str);
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
if (tmp->plugin->system_vars || (*argc > 1))
|
2007-04-13 19:24:46 +02:00
|
|
|
{
|
2014-09-01 20:29:58 +02:00
|
|
|
for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
|
|
|
|
{
|
|
|
|
len++;
|
|
|
|
if (!((*opt)->flags & PLUGIN_VAR_NOCMDOPT))
|
|
|
|
count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
|
|
|
|
}
|
|
|
|
|
2007-03-02 17:43:45 +01:00
|
|
|
if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count)))
|
|
|
|
{
|
2007-04-13 19:23:02 +02:00
|
|
|
sql_print_error("Out of memory for plugin '%s'.", tmp->name.str);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(-1);
|
|
|
|
}
|
|
|
|
bzero(opts, sizeof(my_option) * count);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
if (construct_options(tmp_root, tmp, opts))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-04-13 19:23:02 +02:00
|
|
|
sql_print_error("Bad options for plugin '%s'.", tmp->name.str);
|
2007-03-02 17:43:45 +01:00
|
|
|
DBUG_RETURN(-1);
|
|
|
|
}
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
if (tmp->plugin->system_vars)
|
|
|
|
{
|
|
|
|
tmp_backup= (st_ptr_backup *)my_alloca(len * sizeof(tmp_backup[0]));
|
|
|
|
DBUG_ASSERT(tmp->nbackups == 0);
|
|
|
|
DBUG_ASSERT(tmp->ptr_backup == 0);
|
|
|
|
|
|
|
|
for (opt= tmp->plugin->system_vars; *opt; opt++)
|
|
|
|
{
|
|
|
|
st_mysql_sys_var *o= *opt;
|
|
|
|
char *varname;
|
|
|
|
sys_var *v;
|
|
|
|
|
|
|
|
tmp_backup[tmp->nbackups++].save(&o->name);
|
|
|
|
if ((var= find_bookmark(tmp->name.str, o->name, o->flags)))
|
2016-04-15 20:47:45 +02:00
|
|
|
{
|
2014-09-01 20:29:58 +02:00
|
|
|
varname= var->key + 1;
|
2016-04-15 20:47:45 +02:00
|
|
|
var->loaded= TRUE;
|
|
|
|
}
|
2014-09-01 20:29:58 +02:00
|
|
|
else
|
|
|
|
{
|
2016-04-15 20:47:45 +02:00
|
|
|
var= NULL;
|
2014-09-01 20:29:58 +02:00
|
|
|
len= tmp->name.length + strlen(o->name) + 2;
|
|
|
|
varname= (char*) alloc_root(mem_root, len);
|
|
|
|
strxmov(varname, tmp->name.str, "-", o->name, NullS);
|
|
|
|
my_casedn_str(&my_charset_latin1, varname);
|
|
|
|
convert_dash_to_underscore(varname, len-1);
|
|
|
|
}
|
2023-01-19 21:53:16 +01:00
|
|
|
if (o->flags & PLUGIN_VAR_NOSYSVAR)
|
|
|
|
{
|
|
|
|
o->name= varname;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-02-15 08:18:55 +01:00
|
|
|
const char *s= o->flags & PLUGIN_VAR_DEPRECATED ? "" : NULL;
|
|
|
|
v= new (mem_root) sys_var_pluginvar(&chain, varname, tmp, o, s);
|
2016-04-15 20:47:45 +02:00
|
|
|
v->test_load= (var ? &var->loaded : &static_unload);
|
|
|
|
DBUG_ASSERT(static_unload == FALSE);
|
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
if (!(o->flags & PLUGIN_VAR_NOCMDOPT))
|
|
|
|
{
|
2015-01-15 14:57:50 +01:00
|
|
|
// update app_type, used for I_S.SYSTEM_VARIABLES
|
2014-09-01 20:29:58 +02:00
|
|
|
for (my_option *mo=opts; mo->name; mo++)
|
|
|
|
if (mo->app_type == o)
|
|
|
|
mo->app_type= v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp->nbackups)
|
|
|
|
{
|
|
|
|
size_t bytes= tmp->nbackups * sizeof(tmp->ptr_backup[0]);
|
|
|
|
tmp->ptr_backup= (st_ptr_backup *)alloc_root(mem_root, bytes);
|
|
|
|
if (!tmp->ptr_backup)
|
|
|
|
{
|
|
|
|
restore_ptr_backup(tmp->nbackups, tmp_backup);
|
|
|
|
my_afree(tmp_backup);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
memcpy(tmp->ptr_backup, tmp_backup, bytes);
|
|
|
|
}
|
|
|
|
my_afree(tmp_backup);
|
|
|
|
}
|
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
/*
|
|
|
|
We adjust the default value to account for the hardcoded exceptions
|
|
|
|
we have set for the federated and ndbcluster storage engines.
|
|
|
|
*/
|
2017-06-14 11:27:36 +02:00
|
|
|
if (!plugin_is_forced(tmp))
|
2010-09-27 14:55:09 +02:00
|
|
|
opts[0].def_value= opts[1].def_value= plugin_load_option;
|
2009-05-14 14:03:33 +02:00
|
|
|
|
2014-09-01 20:29:58 +02:00
|
|
|
error= handle_options(argc, &argv, opts, mark_changed);
|
2007-03-02 17:43:45 +01:00
|
|
|
(*argc)++; /* add back one for the program name */
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2018-04-04 11:16:12 +02:00
|
|
|
if (unlikely(error))
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2007-04-13 19:24:46 +02:00
|
|
|
sql_print_error("Parsing options for plugin '%s' failed.",
|
2007-04-13 19:23:02 +02:00
|
|
|
tmp->name.str);
|
2014-09-01 20:29:58 +02:00
|
|
|
goto err;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2009-05-14 14:03:33 +02:00
|
|
|
/*
|
|
|
|
Set plugin loading policy from option value. First element in the option
|
|
|
|
list is always the <plugin name> option value.
|
|
|
|
*/
|
2017-06-14 11:27:36 +02:00
|
|
|
if (!plugin_is_forced(tmp))
|
2010-09-27 14:55:09 +02:00
|
|
|
plugin_load_option= (enum_plugin_load_option) *(ulong*) opts[0].value;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2010-09-27 14:55:09 +02:00
|
|
|
disable_plugin= (plugin_load_option == PLUGIN_OFF);
|
|
|
|
tmp->load_option= plugin_load_option;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2014-08-27 10:23:20 +02:00
|
|
|
error= 1;
|
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
/*
|
|
|
|
If the plugin is disabled it should not be initialized.
|
|
|
|
*/
|
|
|
|
if (disable_plugin)
|
|
|
|
{
|
2020-02-24 16:38:14 +01:00
|
|
|
if (global_system_variables.log_warnings && !opt_help)
|
2009-05-14 14:03:33 +02:00
|
|
|
sql_print_information("Plugin '%s' is disabled.",
|
|
|
|
tmp->name.str);
|
2014-08-27 10:23:20 +02:00
|
|
|
goto err;
|
2009-05-14 14:03:33 +02:00
|
|
|
}
|
2007-10-04 19:55:08 +02:00
|
|
|
|
2013-12-09 12:39:19 +01:00
|
|
|
if (tmp->plugin->system_vars)
|
2007-04-13 19:24:46 +02:00
|
|
|
{
|
2019-09-29 22:07:48 +02:00
|
|
|
if (mysqld_server_started)
|
2012-04-17 20:29:43 +02:00
|
|
|
{
|
2013-12-09 12:39:19 +01:00
|
|
|
/*
|
|
|
|
PLUGIN_VAR_STR command-line options without PLUGIN_VAR_MEMALLOC, point
|
|
|
|
directly to values in the argv[] array. For plugins started at the
|
|
|
|
server startup, argv[] array is allocated with load_defaults(), and
|
|
|
|
freed when the server is shut down. But for plugins loaded with
|
|
|
|
INSTALL PLUGIN, the memory allocated with load_defaults() is freed with
|
2014-09-01 20:29:58 +02:00
|
|
|
free() at the end of mysql_install_plugin(). Which means we cannot
|
2013-12-09 12:39:19 +01:00
|
|
|
allow any pointers into that area.
|
|
|
|
Thus, for all plugins loaded after the server was started,
|
|
|
|
we copy string values to a plugin's memroot.
|
|
|
|
*/
|
2019-09-29 22:07:48 +02:00
|
|
|
for (opt= tmp->plugin->system_vars; *opt; opt++)
|
|
|
|
{
|
|
|
|
if ((((*opt)->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_NOCMDOPT |
|
|
|
|
PLUGIN_VAR_MEMALLOC)) == PLUGIN_VAR_STR))
|
|
|
|
{
|
|
|
|
sysvar_str_t* str= (sysvar_str_t *)*opt;
|
|
|
|
if (*str->value)
|
|
|
|
*str->value= strdup_root(mem_root, *str->value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* same issue with config file names */
|
|
|
|
for (my_option *mo=opts; mo->name; mo++)
|
2013-12-09 12:39:19 +01:00
|
|
|
{
|
2019-09-29 22:07:48 +02:00
|
|
|
sys_var *var= (sys_var*) mo->app_type;
|
|
|
|
if (var && var->value_origin == sys_var::CONFIG)
|
|
|
|
var->origin_filename= strdup_root(mem_root, var->origin_filename);
|
2013-12-09 12:39:19 +01:00
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
2013-12-09 12:39:19 +01:00
|
|
|
|
|
|
|
if (chain.first)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
2013-12-09 12:39:19 +01:00
|
|
|
chain.last->next = NULL;
|
|
|
|
if (mysql_add_sys_var_chain(chain.first))
|
|
|
|
{
|
|
|
|
sql_print_error("Plugin '%s' has conflicting system variables",
|
|
|
|
tmp->name.str);
|
2014-09-01 20:29:58 +02:00
|
|
|
goto err;
|
2013-12-09 12:39:19 +01:00
|
|
|
}
|
|
|
|
tmp->system_vars= chain.first;
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-09 12:39:19 +01:00
|
|
|
|
2009-05-14 14:03:33 +02:00
|
|
|
DBUG_RETURN(0);
|
2014-07-09 10:35:31 +02:00
|
|
|
|
2014-08-27 10:23:20 +02:00
|
|
|
err:
|
2007-10-05 02:34:28 +02:00
|
|
|
if (opts)
|
|
|
|
my_cleanup_options(opts);
|
2007-10-04 19:55:08 +02:00
|
|
|
DBUG_RETURN(error);
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Help Verbose text with Plugin System Variables
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root)
|
2007-03-02 17:43:45 +01:00
|
|
|
{
|
|
|
|
struct st_plugin_int *p;
|
|
|
|
my_option *opt;
|
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
if (!initialized)
|
|
|
|
return;
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
for (uint idx= 0; idx < plugin_array.elements; idx++)
|
|
|
|
{
|
|
|
|
p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
|
2007-04-13 19:24:46 +02:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
if (!(opt= construct_help_options(mem_root, p)))
|
|
|
|
continue;
|
2007-03-02 17:43:45 +01:00
|
|
|
|
2009-12-22 10:35:56 +01:00
|
|
|
/* Only options with a non-NULL comment are displayed in help text */
|
|
|
|
for (;opt->name; opt++)
|
|
|
|
if (opt->comment)
|
|
|
|
insert_dynamic(options, (uchar*) opt);
|
|
|
|
}
|
2007-03-02 17:43:45 +01:00
|
|
|
}
|
|
|
|
|
2013-04-09 23:27:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a sys_var corresponding to a particular MYSQL_SYSVAR(...)
|
|
|
|
*/
|
|
|
|
sys_var *find_plugin_sysvar(st_plugin_int *plugin, st_mysql_sys_var *plugin_var)
|
|
|
|
{
|
|
|
|
for (sys_var *var= plugin->system_vars; var; var= var->next)
|
|
|
|
{
|
|
|
|
sys_var_pluginvar *pvar=var->cast_pluginvar();
|
|
|
|
if (pvar->plugin_var == plugin_var)
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-09 12:39:13 +01:00
|
|
|
/*
|
|
|
|
On dlclose() we need to restore values of all symbols that we've modified in
|
|
|
|
the DSO. The reason is - the DSO might not actually be unloaded, so on the
|
|
|
|
next dlopen() these symbols will have old values, they won't be
|
|
|
|
reinitialized.
|
|
|
|
|
|
|
|
Perhaps, there can be many reason, why a DSO won't be unloaded. Strictly
|
|
|
|
speaking, it's implementation defined whether to unload an unused DSO or to
|
|
|
|
keep it in memory.
|
|
|
|
|
|
|
|
In particular, this happens for some plugins: In 2009 a new ELF stub was
|
|
|
|
introduced, see Ulrich Drepper's email "Unique symbols for C++"
|
|
|
|
http://www.redhat.com/archives/posix-c++-wg/2009-August/msg00002.html
|
|
|
|
|
|
|
|
DSO that has objects with this stub (STB_GNU_UNIQUE) cannot be unloaded
|
|
|
|
(this is mentioned in the email, see the url above).
|
|
|
|
|
|
|
|
These "unique" objects are, for example, static variables in templates,
|
|
|
|
in inline functions, in classes. So any DSO that uses them can
|
|
|
|
only be loaded once. And because Boost has them, any DSO that uses Boost
|
|
|
|
almost certainly cannot be unloaded.
|
|
|
|
|
|
|
|
To know whether a particular DSO has these objects, one can use
|
|
|
|
|
|
|
|
readelf -s /path/to/plugin.so|grep UNIQUE
|
|
|
|
|
|
|
|
There's nothing we can do about it, but to reset the DSO to its initial
|
|
|
|
state before dlclose().
|
|
|
|
*/
|
|
|
|
static void restore_ptr_backup(uint n, st_ptr_backup *backup)
|
|
|
|
{
|
|
|
|
while (n--)
|
|
|
|
(backup++)->restore();
|
|
|
|
}
|
|
|
|
|
2014-12-03 23:51:47 +01:00
|
|
|
/****************************************************************************
|
|
|
|
thd specifics service, see include/mysql/service_thd_specifics.h
|
|
|
|
****************************************************************************/
|
|
|
|
static const int INVALID_THD_KEY= -1;
|
|
|
|
static uint thd_key_no = 42;
|
|
|
|
|
|
|
|
int thd_key_create(MYSQL_THD_KEY_T *key)
|
|
|
|
{
|
|
|
|
int flags= PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_STR |
|
|
|
|
PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT;
|
|
|
|
char namebuf[256];
|
|
|
|
snprintf(namebuf, sizeof(namebuf), "%u", thd_key_no++);
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_wrlock(&LOCK_system_variables_hash);
|
2014-12-03 23:51:47 +01:00
|
|
|
// non-letters in the name as an extra safety
|
|
|
|
st_bookmark *bookmark= register_var("\a\v\a\t\a\r", namebuf, flags);
|
2018-01-27 18:46:31 +01:00
|
|
|
mysql_prlock_unlock(&LOCK_system_variables_hash);
|
2014-12-03 23:51:47 +01:00
|
|
|
if (bookmark)
|
|
|
|
{
|
|
|
|
*key= bookmark->offset;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
void thd_key_delete(MYSQL_THD_KEY_T *key)
|
|
|
|
{
|
|
|
|
*key= INVALID_THD_KEY;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* thd_getspecific(MYSQL_THD thd, MYSQL_THD_KEY_T key)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(key != INVALID_THD_KEY);
|
|
|
|
if (key == INVALID_THD_KEY || (!thd && !(thd= current_thd)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return *(void**)(intern_sys_var_ptr(thd, key, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
int thd_setspecific(MYSQL_THD thd, MYSQL_THD_KEY_T key, void *value)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(key != INVALID_THD_KEY);
|
|
|
|
if (key == INVALID_THD_KEY || (!thd && !(thd= current_thd)))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
memcpy(intern_sys_var_ptr(thd, key, true), &value, sizeof(void*));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-28 19:26:13 +02:00
|
|
|
void plugin_mutex_init()
|
|
|
|
{
|
2016-09-29 11:50:13 +02:00
|
|
|
init_plugin_psi_keys();
|
2016-09-28 19:26:13 +02:00
|
|
|
mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_WSREP
|
|
|
|
|
|
|
|
/*
|
|
|
|
Placeholder for global_system_variables.table_plugin required during
|
|
|
|
initialization of startup wsrep threads.
|
|
|
|
*/
|
|
|
|
static st_plugin_int wsrep_dummy_plugin;
|
|
|
|
static st_plugin_int *wsrep_dummy_plugin_ptr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Initialize wsrep_dummy_plugin and assign it to
|
|
|
|
global_system_variables.table_plugin.
|
|
|
|
*/
|
|
|
|
void wsrep_plugins_pre_init()
|
|
|
|
{
|
|
|
|
wsrep_dummy_plugin_ptr= &wsrep_dummy_plugin;
|
|
|
|
wsrep_dummy_plugin.state= PLUGIN_IS_DISABLED;
|
|
|
|
global_system_variables.table_plugin=
|
|
|
|
plugin_int_to_ref(wsrep_dummy_plugin_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function is intended to be called after the plugins and related
|
|
|
|
global system variables are initialized. It re-initializes some data
|
|
|
|
members of wsrep startup threads with correct values, as these value
|
|
|
|
were not available at the time these threads were created.
|
|
|
|
*/
|
|
|
|
|
2019-01-19 23:32:35 +01:00
|
|
|
my_bool post_init_callback(THD *thd, void *)
|
|
|
|
{
|
2019-05-13 11:46:50 +02:00
|
|
|
DBUG_ASSERT(!current_thd);
|
2019-01-19 23:32:35 +01:00
|
|
|
if (thd->wsrep_applier)
|
2016-09-28 19:26:13 +02:00
|
|
|
{
|
2019-05-13 11:46:50 +02:00
|
|
|
// Save options_bits as it will get overwritten in
|
|
|
|
// plugin_thdvar_init() (verified)
|
2019-01-19 23:32:35 +01:00
|
|
|
ulonglong option_bits_saved= thd->variables.option_bits;
|
2019-05-13 11:46:50 +02:00
|
|
|
|
|
|
|
set_current_thd(thd);
|
2019-01-19 23:32:35 +01:00
|
|
|
plugin_thdvar_init(thd);
|
2019-05-13 11:46:50 +02:00
|
|
|
|
2019-01-19 23:32:35 +01:00
|
|
|
// Restore option_bits
|
|
|
|
thd->variables.option_bits= option_bits_saved;
|
2016-09-28 19:26:13 +02:00
|
|
|
}
|
2019-05-13 11:46:50 +02:00
|
|
|
set_current_thd(0);
|
2019-01-19 23:32:35 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2016-09-28 19:26:13 +02:00
|
|
|
|
2019-01-19 23:32:35 +01:00
|
|
|
|
|
|
|
void wsrep_plugins_post_init()
|
|
|
|
{
|
2019-05-13 11:46:50 +02:00
|
|
|
mysql_mutex_lock(&LOCK_global_system_variables);
|
2019-01-19 23:32:35 +01:00
|
|
|
server_threads.iterate(post_init_callback);
|
2019-05-13 11:46:50 +02:00
|
|
|
mysql_mutex_unlock(&LOCK_global_system_variables);
|
2016-09-28 19:26:13 +02:00
|
|
|
}
|
|
|
|
#endif /* WITH_WSREP */
|