Commit graph

465 commits

Author SHA1 Message Date
Monty
89685d55d7 Reuse THD for new user connections
- To ensure that mallocs are marked for the correct THD, even if it's
  allocated in another thread, I added the thread_id to the THD constructor
- Added st_my_thread_var to thr_lock_info_init() to avoid a call to my_thread_var
- Moved things from THD::THD() to THD::init()
- Moved some things to THD::cleanup()
- Added THD::free_connection() and THD::reset_for_reuse()
- Added THD to CONNECT::create_thd()
- Added THD::thread_dbug_id and st_my_thread_var->dbug_id. These are needed
  to ensure that we have a constant thread_id used for debugging with a THD,
  even if it changes thread_id (=connection_id)
- Set variables.pseudo_thread_id in constructor. Removed not needed sets.
2016-06-04 09:06:00 +02:00
Monty
fabeab7819 Cleanups
- Avoid some realloc() during startup
- Ensure that file_key_management_plugin frees it's memory early, even if
  it's linked statically.
- Fixed compiler warnings from unused variables and missing destructors
- Fixed wrong indentation
2016-04-28 16:36:02 +03:00
Monty
260dd476b0 Removed TABLE->sort to make it possible to have multiple active calls to
filesort and init_read_record() for the same table.
This will simplify code for WINDOW FUNCTIONS (MDEV-6115)

- Filesort_info renamed to SORT_INFO and moved to filesort.h
- filesort now returns SORT_INFO
- init_read_record() now takes a SORT_INFO parameter.
- unique declaration is moved to uniques.h
- subselect caching of buffers is now more explicit than before
- filesort_buffer is now reusable even if rec_length has changed.
- filsort_free_buffers() and free_io_cache() calls are removed
- Remove one malloc() when using get_addon_fields()

Other things:
- Added --debug-assert-on-not-freed-memory option to make it easier to
  debug some not-freed-memory issues.
2016-03-22 23:44:52 +02:00
Sergey Vojtovich
a8d97fb818 MDEV-9651 - Simplify audit event dispatching
Simplified audit event dispatching call chain from:
  mysql_audit_notify_connection_connect() // can be inlined
  mysql_audit_notify()                    // can't be inlined
  connection_class_handler()              // can't be inlined
  event_class_dispatch()                  // can be inlined
  plugins_dispatch()                      // can be inlined
  plugin->event_notify()                  // can't be inlined
to:
  mysql_audit_notify_connection_connect() // can be inlined
  mysql_audit_notify()                    // can't be inlined
  plugins_dispatch()                      // can be inlined
  plugin->event_notify()                  // can't be inlined
2016-03-08 11:26:28 +04:00
Sergei Golubchik
a2bcee626d Merge branch '10.0' into 10.1 2015-12-21 21:24:22 +01:00
Sergei Golubchik
392d557901 MDEV-9183 MariaDB 10.1 crash on mysqld --verbose --help
plugin_init() works like this:
1. init MyISAM
2. load plugins from mysql.plugin, if it's a MyISAM table
3. init all not initialized plugins
4. all done, if step 2 loaded mysql.plugin,
   otherwise:
5. load plugins from mysql.plugin
6. init all not initialized plugins

now, with --help --verbose, step 3 will not actually
initialize them, and if mysql.plugin is unreadable,
step 6 will try to initialize existing plugins again.
Fix: when skipping initialization because of --help,
change plugin status from PLUGIN_IS_UNINITIALIZED.
2015-12-19 13:59:29 +01:00
Sergei Golubchik
865548fc8d MDEV-9088 Server crashes on shutdown after the second post of feedback report
On shutdown feedback was sending a short report without creating
a THD. At that point current_thd was pointing to the already
destroyed THD from the previous full report.

backport from 10.1:
  commit bfe703a
  Author: Sergei Golubchik <serg@mariadb.org>
  Date:   Tue Feb 3 18:19:56 2015 +0100

      don't let current_thd to point to a destroyed THD
2015-12-19 13:36:21 +01:00
Sergei Golubchik
530a6e7481 Merge branch '10.0' into 10.1
referenced_by_foreign_key2(), needed for InnoDB to compile,
was taken from 10.0-galera
2015-09-03 12:58:41 +02:00
Sergey Vojtovich
4188ba9c1e MDEV-7652 - More explanatory ERROR and WARNING messages when loading plugins
with plugin-load-add that are already registered at mysql.plugin

- issue just one error message, without this extra warning
- don't abuse ER_UDF_EXISTS, instead add a proper error message for plugins
- report started initialization for each plugin source
2015-07-29 13:51:22 +04:00
Monty
7332af49e4 - Renaming variables so that they don't shadow others (After this patch one can compile with -Wshadow and get much fewer warnings)
- Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function.
- Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined.
- Removing calls to current_thd when we have access to thd

Part of this is optimization (not calling current_thd when not needed),
but part is bug fixing for error condition when current_thd is not defined
(For example on startup and end of mysqld)

Notable renames done as otherwise a lot of functions would have to be changed:
- In JOIN structure renamed:
   examined_rows -> join_examined_rows
   record_count -> join_record_count
- In Field, renamed new_field() to make_new_field()

Other things:
- Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe.
- Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly
- Added 'thd' as argument to a few functions to avoid calling current_thd.
2015-07-06 20:24:14 +03:00
Sergei Golubchik
26162c71c5 rename {sys_vars,sql_plugin_services}.h -> *.ic 2015-06-28 12:09:46 +02:00
Sergei Golubchik
bfabaf6486 Deinitialize plugins in the reverse plugin_type_initialization_order
Old code worked because plugin locking guaranteed that
encryption plugin is deinitialized last.
But compiled-in plugins are never locked.

This fixes encryption failures on fulltest builder
2015-06-27 09:40:55 +02:00
Sergei Golubchik
810cf362ea Merge branch '5.5' into 10.0 2015-06-11 20:20:35 +02:00
Sergey Vojtovich
3a50a8c9be MDEV-363 - Server crashes in intern_plugin_lock on concurrent installing
semisync plugin and setting rpl_semi_sync_master_enabled

There was race condition between INSTALL PLUGIN and SET. It was caused by a
gap in INSTALL PLUGIN when plugin variables were registered but not fully
initialized. Accessing such variables concurrently may reference uninitialized
memory, specifically sys_var_pluginvar::plugin.

Fixed by initializing sys_var_pluginvar::plugin early, before variable is
registered.
2015-06-09 23:24:02 +04:00
Sergey Vojtovich
49a3392441 MDEV-363 - Server crashes in intern_plugin_lock on concurrent installing
semisync plugin and setting rpl_semi_sync_master_enabled

Cleanup:
Removed my_intern_plugin_lock() and my_intern_plugin_lock_ci() wrappers. They
were obsoleted by revision f56dd32bf.
2015-06-09 23:24:02 +04:00
Sergei Golubchik
9c41b35b6a MDEV-8220 Server crashes if started with --enforce-storage-engine option 2015-06-01 16:33:41 +02:00
Sergei Golubchik
5091a4ba75 Merge tag 'mariadb-10.0.19' into 10.1 2015-06-01 15:51:25 +02:00
Sergei Golubchik
dd8f931957 be less annoying about sysvar-based table attributes
do not *always* add them to the create table definition,
but only when a sysvar value is different from a default.

also, when adding them - don't quote numbers
2015-04-10 02:36:54 +02:00
Sergei Golubchik
c0878f64c5 remove wrappers in encryption_keys.cc
invoke plugin methods directly
2015-04-09 18:42:43 +02:00
Sergei Golubchik
9ccafffc29 rename "encryption key management plugin" to "encryption plugin"
because it's going to do more than just key management
2015-04-09 18:42:43 +02:00
Sergei Golubchik
9bda4bc52a report a plugin loading offset at dlopen time
not an address of some arbitrarily chosen symbol;
not when plugin is successfully loaded (which means - no info
  when plugin->init failed);
2015-04-08 10:58:49 +02:00
Sergei Golubchik
6a7ee5a5a5 encryption cleanup: small changes
* comments
* move my_bytes_to_key() and my_aes_hex2uint() into file_key_management_plugin
* rename HA_INSERT_ORDER -> HA_PRESERVE_INSERT_ORDER
* remove unused variables and declarations
* fix casts
* don't link innodb with pcre
* remove redundant entries from aria's TARGET_LINK_LIBRARIES
2015-04-05 13:14:37 +02:00
Daniel Black
fd977398c7 Allow {un,}install plugins during bootstrap/skip-grant-tables
This aids packagers to install/uninstall plugins without starting a full
mysql instance.

for MDEV-7781.
2015-03-15 14:50:22 +11:00
Jan Lindström
8249dcaaeb MDEV-6858: enforce_storage_engine option
Merge from Percona Server enforced use of a specific storage engine
authored by Stewart Smith.

Modified to be session variable and modifiable only by SUPER. Use
similar implementation as default_storage_engine.
2015-03-12 12:17:14 +02:00
Sergei Golubchik
da181fee4e disable feedback plugin again 2015-02-24 16:26:18 +01:00
Sergei Golubchik
cf8bf0b68e encryption key management plugin api 2015-02-10 10:21:17 +01:00
Sergei Golubchik
c8997c39b4 initialize plugins in the specific order by plugin type
but do MyISAM first - to read mysql.plugin table
2015-02-10 10:21:17 +01:00
Monty
d7d589dc01 Push for testing of encryption 2015-02-10 10:21:17 +01:00
Sergey Vojtovich
451e9b7a50 MDEV-7499 - System variables have broken default values on big endian
INFORMATION_SCHEMA.SYSTEM_VARIABLES.DEFAULT_VALUE had broken values on
big endian.

Default value is internally stored as longlong, while I_S references it's
pointer (longlong *) according to variable type (e.g. int, my_bool, etc). This
works well on little endian, but on big endian we always get 0 for such
variables.
2015-02-05 13:54:55 +04:00
Sergei Golubchik
bfe703a458 don't let current_thd to point to a destroyed THD
* reset current_thd in THD::~THD, otherwise my_malloc_size_cb_func()
  might access THD after it was destroyed.
* remove now redundant set_current_thd(0) calls that follow delete thd.
2015-02-03 18:19:56 +01:00
Sergei Golubchik
4b21cd21fe Merge branch '10.0' into merge-wip 2015-01-31 21:48:47 +01:00
Sergei Golubchik
d9c01e4b4a 5.5 merge 2015-01-21 12:03:02 +01:00
Sergei Golubchik
595cf636fd MDEV-7475 Wrong implementation of checking PLUGIN_VAR_SET condition
correct the check for PLUGIN_VAR_STR
2015-01-19 16:29:18 +01:00
Sergei Golubchik
90f2ec5122 bugfix: incorrect cast causing random memory write
options->app_type was set to mysql_sysvar_t* pointer,
later changed to sys_var* pointer, and even later dereferenced as
sys_var*. But for PLUGIN_VAR_NOSYSVAR variables the pointer wasn't
changed to sys_var*, so mysql_sysvar_t* pointer was dereferenced
(and updated!) as if it was sys_var*.

This caused maria.maria-gis-recovery test failure on x86 (fulltest2).
2015-01-15 14:57:50 +01:00
Sergei Golubchik
4ce39dca99 enable feedback plugin by default
As requested by Monty
2015-01-08 16:51:30 +01:00
Sergei Golubchik
227510e039 parser cleanup: don't store field properties in LEX, use Create_field directly
length/dec/charset are still in LEX, because they're also used
for CAST and dynamic columns.

also
1. fix "MDEV-7041 COLLATION(CAST('a' AS CHAR BINARY)) returns a wrong result"
2. allow BINARY modifier in stored function RETURN clause
3. allow "COLLATION without CHARSET" in SP/SF (parameters, RETURN, DECLARE)
4. print correct variable name in error messages for stored routine parameters
2014-12-04 16:09:34 +01:00
Sergei Golubchik
8360e1a5b5 MDEV-6712 THD specifics for plugins
thd_specifics service
2014-12-04 10:41:55 +01:00
Sergei Golubchik
c98b2b393d password validation plugin type and a simple plugin 2014-12-04 10:41:54 +01:00
Sergei Golubchik
4027e3b885 don't load plugin of unsupported types 2014-12-04 10:41:53 +01:00
Sergei Golubchik
77e3cb7dc1 cleanup: sql_plugin.cc
* test for opt->name being non-NULL *before* dereferencing it
* remove unused argument in cleanup_variables()
* simplify
2014-12-04 10:41:53 +01:00
Sergei Golubchik
fc40f81eda a case of uninitialized variable 2014-12-04 10:41:53 +01:00
Sergei Golubchik
853077ad7e Merge branch '10.0' into bb-10.1-merge
Conflicts:
	.bzrignore
	VERSION
	cmake/plugin.cmake
	debian/dist/Debian/control
	debian/dist/Ubuntu/control
	mysql-test/r/join_outer.result
	mysql-test/r/join_outer_jcl6.result
	mysql-test/r/null.result
	mysql-test/r/old-mode.result
	mysql-test/r/union.result
	mysql-test/t/join_outer.test
	mysql-test/t/null.test
	mysql-test/t/old-mode.test
	mysql-test/t/union.test
	packaging/rpm-oel/mysql.spec.in
	scripts/mysql_config.sh
	sql/ha_ndbcluster.cc
	sql/ha_ndbcluster_binlog.cc
	sql/ha_ndbcluster_cond.cc
	sql/item_cmpfunc.h
	sql/lock.cc
	sql/sql_select.cc
	sql/sql_show.cc
	sql/sql_update.cc
	sql/sql_yacc.yy
	storage/innobase/buf/buf0flu.cc
	storage/innobase/fil/fil0fil.cc
	storage/innobase/include/srv0srv.h
	storage/innobase/lock/lock0lock.cc
	storage/tokudb/CMakeLists.txt
	storage/xtradb/buf/buf0flu.cc
	storage/xtradb/fil/fil0fil.cc
	storage/xtradb/include/srv0srv.h
	storage/xtradb/lock/lock0lock.cc
	support-files/mysql.spec.sh
2014-12-02 22:25:16 +01:00
Sergei Golubchik
f62c12b405 Merge 10.0.14 into 10.1 2014-10-15 12:59:13 +02:00
Sergei Golubchik
7f5e51b940 MDEV-34 delete storage/ndb and sql/*ndb* (and collateral changes)
remove:
* NDB from everywhere
* IM from mtr-v1
* packaging/rpm-oel and packaging/rpm-uln
* few unused spec files
* plug.in file
* .bzrignore
2014-10-11 18:53:06 +02:00
Sergei Golubchik
3fa8c279d5 INFORMATION_SCHEMA.SYSTEM_VARIABLES.GLOBAL_VALUE_ORIGIN 2014-10-11 10:23:20 +02:00
Sergei Golubchik
513f5840f8 MDEV-6138 show sysvar's help in I_S tables
INFORMATION_SCHEMA.SYSTEM_VARIABLES
2014-10-11 10:23:20 +02:00
Sergei Golubchik
d508ef7898 cleanup: more 'const' qualifiers 2014-10-10 22:27:41 +02:00
Sergei Golubchik
9ccaa62dd5 sys_var_pluginvar: populate my_option and misc cleanup 2014-10-10 22:27:41 +02:00
Sergei Golubchik
28ebc2a724 cleanup: sysvar, only one common check_update_type() 2014-10-10 22:27:41 +02:00
Sergei Golubchik
db2399b0c1 small cleanup 2014-10-10 22:27:40 +02:00