Commit graph

51 commits

Author SHA1 Message Date
Marko Mäkelä
4a25957274 Merge 10.4 into 10.5 2021-08-18 18:22:35 +03:00
Alexey Botchkov
38b79d7295 MENT-1019.
Audit-plugin related fixes.
2021-08-11 23:00:37 +04:00
Alexey Botchkov
b01c426146 MDEV-19275 Provide SQL service to plugins.
Protocol_local fixed so it can be used now.
Some Protocol:: methods made virtual so they can adapt.
as well as net_ok and net_send_error functions.
execute_sql_string function is exported to the plugins.
To be changed with the mysql_use_result.
2020-08-14 21:04:25 +04:00
Marko Mäkelä
5ab70e7f68 Merge 10.2 into 10.3 2019-12-27 15:14:48 +02:00
Alexey Botchkov
aaaf6ceb8b MDE-21369 rpl.rpl_timezone fails with valgrind: Use of uninitialised value.
It's not safe to chenge the THD::thread_id.
So send the thread_id as an argument to the mysql_audit_external_lock.
2019-12-21 13:46:33 +04:00
Marko Mäkelä
e82fe21e3a Merge 10.2 into 10.3 2019-07-02 17:46:22 +03:00
Eugene Kosov
ddeeb42e0b Merge 10.1 into 10.2 2019-06-23 20:33:13 +03:00
Alexey Botchkov
65e0c9b91b MDEV-18661 loading the audit plugin causes performance regression.
Plugin fixed to not lock the LOCK_operations when not active.
Server fixed to lock the LOCK_plugin less - do it once per
thread and then only if a plugin was installed/uninstalled.
2019-06-15 01:02:55 +04:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
Vicențiu Ciorbaru
5543b75550 Update FSF Address
* Update wrong zip-code
2019-05-11 21:29:06 +03:00
Monty
a7e352b54d Changed database, tablename and alias to be LEX_CSTRING
This was done in, among other things:
- thd->db and thd->db_length
- TABLE_LIST tablename, db, alias and schema_name
- Audit plugin database name
- lex->db
- All db and table names in Alter_table_ctx
- st_select_lex db

Other things:
- Changed a lot of functions to take const LEX_CSTRING* as argument
  for db, table_name and alias. See init_one_table() as an example.
- Changed some function arguments from LEX_CSTRING to const LEX_CSTRING
- Changed some lists from LEX_STRING to LEX_CSTRING
- threads_mysql.result changed because process list_db wasn't always
  correctly updated
- New append_identifier() function that takes LEX_CSTRING* as arguments
- Added new element tmp_buff to Alter_table_ctx to separate temp name
  handling from temporary space
- Ensure we store the length after my_casedn_str() of table/db names
- Removed not used version of rename_table_in_stat_tables()
- Changed Natural_join_column::table_name and db_name() to never return
  NULL (used for print)
- thd->get_db() now returns db as a printable string (thd->db.str or "")
2018-01-30 21:33:55 +02:00
Marko Mäkelä
2c1067166d Merge bb-10.2-ext into 10.3 2017-10-04 08:24:06 +03:00
Vladislav Vaintroub
7354dc6773 MDEV-13384 - misc Windows warnings fixed 2017-09-28 17:20:46 +00:00
Monty
21518ab2e4 New option for slow logging (log_slow_disable_statements)
This fixes MDEV-7742 and MDEV-8305 (Allow user to specify if stored
procedures should be logged in the slow and general log)

New functionality:
- Added new variables log_slow_disable_statements and log_disable_statements
  that can be used to disable logging of certain queries to slow and
  general log. Currently supported options are 'admin', 'call', 'slave'
  and 'sp'.
  Defaults are as before. Only 'sp' (stored procedure statements) is
  disabled for  slow and general_log.
- Slow log to files now includes the following new information:
  - When logging stored procedure statements the name of stored
    procedure is logged.
  - Number of created tmp_tables, tmp_disk_tables and the space used
    by temporary tables.
- When logging 'call', the logged status now contains the sum of all
  included statements.  Before only 'time' was correct.
- Added filsort_priority_queue as an option for log_slow_filter (this
  variable existed before, but was not exposed)
- Added support for BIT types in my_getopt()

Mapped some old variables to bitmaps (old variables can still be used)
- Variable 'log_queries_not_using_indexes' is mapped to
  log_slow_filter='not_using_index'
- Variable 'log_slow_slave_statements' is mapped to
  log_slow_disabled_statements='slave'
- Variable 'log_slow_admin_statements' is mapped to
  log_slow_disabled_statements='admin'
- All the above variables are changed to session variables from global
  variables

Other things:
- Simplified LOGGER::log_command. We don't need to check for super if
  OPTION_LOG_OFF is set as this flag can only be set if one is a super
  user.
- Removed some setting of enable_slow_log as it's guaranteed to be set by
  mysql_parse()
- mysql_admin_table() now sets thd->enable_slow_log
- Added prepare_logs_for_admin_command() to reset thd->enable_slow_log if
  needed.
- Added new functions to store, restore and add slow query status
- Added new functions to store and restore query start time
- Reorganized Sub_statement_state according to types
- Added code in dispatch_command() to ensure that
  thd->reset_for_next_command() is always called for a query.
- Added thd->last_sql_command to simplify checking of what was the type
  of the last command. Needed when logging to slow log as lex->sql_command
  may have changed before slow logging is called.
- Moved QPLAN_TMP_... to where status for tmp tables are updated
- Added new THD variable, affected_rows, to be able to correctly log
  number of affected rows to slow log.
2017-08-24 01:05:51 +02:00
Michael Widenius
4aaa38d26e Enusure that my_global.h is included first
- Added sql/mariadb.h file that should be included first by files in sql
  directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables
  that must be done before my_global.h is included)
- Removed a lot of include my_global.h from include files
- Removed include's of some files that my_global.h automatically includes
- Removed duplicated include's of my_sys.h
- Replaced include my_config.h with my_global.h
2017-08-24 01:05:44 +02:00
Sergei Golubchik
2bf017c210 MDEV-13060 Server Audit Plugin Crashes with AWS KMS plugin
don't do auditing if thd is NULL.

Collaterals:
* copy-paste bugs server_audit.c
* uninitialized user field when thd in NULL
2017-07-05 17:15:58 +02:00
Marko Mäkelä
89d80c1b0b Fix many -Wconversion warnings.
Define my_thread_id as an unsigned type, to avoid mismatch with
ulonglong.  Change some parameters to this type.

Use size_t in a few more places.

Declare many flag constants as unsigned to avoid sign mismatch
when shifting bits or applying the unary ~ operator.

When applying the unary ~ operator to enum constants, explictly
cast the result to an unsigned type, because enum constants can
be treated as signed.

In InnoDB, change the source code line number parameters from
ulint to unsigned type. Also, make some InnoDB functions return
a narrower type (unsigned or uint32_t instead of ulint;
bool instead of ibool).
2017-03-07 19:07:27 +02:00
Vladislav Vaintroub
6950f83d5e fix most annoying warnings on Windows 2016-03-22 18:46:02 +01: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
Michael Widenius
e63c03db8d Merge with 10.0-base
Automatic merge, except for server_audit.cc that had to be modified slightly
Changes to xtradb and innobase where ignored was these made no sence for 10.0
2014-03-13 16:43:11 +02:00
Michael Widenius
1727849659 Merge with 5.5 2014-03-11 17:49:09 +02:00
Alexey Botchkov
3f3a84f46e MDEV-5436 mysqld crash signal 11 in mysql_audit_general.
That error 'Can't open the pid file' leads to mysqld crash signal 11 in mysql_audit_general() called
   with the 'thd' parameter set to NULL. That wasn't checked when the thd->db and thd->db_length
   were accessed. Fixed by checking for the NULL thd.
2014-02-28 00:23:20 +04:00
Sergei Golubchik
0dc23679c8 10.0-base merge 2014-02-26 15:28:07 +01:00
Sergei Golubchik
0b9a0a3517 5.5 merge 2014-02-25 16:04:35 +01:00
Sergei Golubchik
84651126c0 MySQL-5.5.36 merge
(without few incorrect bugfixes and with 1250 files where only a copyright year was changed)
2014-02-17 11:00:51 +01:00
Murthy Narkedimilli
c92223e198 Updated/added copyright headers 2014-01-06 10:52:35 +05:30
Sergei Golubchik
9af177042e 10.0-base merge.
Partitioning/InnoDB changes are *not* merged (they'll come from 5.6)
TokuDB does not compile (not updated to 10.0 SE API)
2013-09-21 10:14:42 +02:00
Sergei Golubchik
4ec2e9d7ed 5.5 merge and fixes for compiler/test errors 2013-09-18 13:07:31 +02:00
Alexey Botchkov
92265da9d7 MDEV-4472 Audit-plugin. Server-related part of the task.
file_logger became the service.
     Data like query_id now are sent to the audit plugin.
     Fix for MDEV-4770 ported from 10.0.
     Fix added for the read_maria_plugin_info().
     Log rotation can be disabled with 'set rotations=0'.
2013-09-09 16:56:35 +05:00
Ashish Agarwal
292aa926c1 WL#7076: Backporting wl6715 to support both formats
in 5.5, 5.6, 5.7.
2013-08-23 09:07:09 +05:30
Sergei Golubchik
b7b5f6f1ab 10.0-monty merge
includes:
* remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING"
* introduce LOCK_share, now LOCK_ha_data is strictly for engines
* rea_create_table() always creates .par file (even in "frm-only" mode)
* fix a 5.6 bug, temp file leak on dummy ALTER TABLE
2013-07-21 16:39:19 +02:00
Ashish Agarwal
e879caf845 WL#7076: Backporting wl6715 to support both formats in 5.5, 5.6, 5.7
Backporting wl6715 to mysql-5.5
2013-07-02 11:58:39 +05:30
Michael Widenius
5f1f2fc0e4 Applied all changes from Igor and Sanja 2013-06-15 18:32:08 +03:00
Sergei Golubchik
4749d40c63 5.5 merge 2013-06-06 17:51:28 +02:00
Sergei Golubchik
b9b3d5330a MDEV-260 auditing table accesses 2013-04-19 12:50:16 +02:00
Sergei Golubchik
68f6c229c5 prefer static inline functions to macros.
avoid unnecessary strlen()'s
2013-04-09 23:27:37 +02:00
Sergei Golubchik
4ce53556ce Test case and a different fix for MySQL bug#14485479 2013-01-15 19:16:29 +01:00
Sergei Golubchik
53578613e9 MDEV-259 audit plugin does not see sub-statements 2012-11-08 16:49:07 +01:00
Sergei Golubchik
d473199744 MDEV-258 audit plugin only see queries if general log is enabled 2012-11-08 14:17:53 +01:00
Kent Boortz
02e07e3b51 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Tor Didriksen
029a5df870 Bug #58699 cannot build with gcc dbg on solaris
cmake/os/SunOS.cmake:
  Remove TARGET_OS_SOLARIS
config.h.cmake:
  Remove TARGET_OS_SOLARIS
  Add PTHREAD_ONCE_INITIALIZER
configure.cmake:
  Add function for testing whether we need { PTHREAD_ONCE_INIT } rather than PTHREAD_ONCE_INIT
include/my_pthread.h:
  Use PTHREAD_ONCE_INITIALIZER if set by cmake.
include/mysql/psi/mysql_file.h:
  Include my_global.h first, to get correct platform definitions.
mysys/ptr_cmp.c:
  Hide the unused static functions in #ifdef's on solaris.
  Use __sun (defined by both gcc and SunPro cc) rather than TARGET_OS_SOLARIS
sql/my_decimal.cc:
  Include my_global.h first, to get correct platform definitions.
sql/mysqld.cc:
  Fix signed/unsigned comparison warning.
sql/sql_audit.h:
  Include my_global.h first, to get correct platform definitions.
sql/sql_plugin.h:
  Include my_global.h first, to get correct platform definitions.
sql/sql_show.cc:
  Fix: warning: cast from pointer to integer of different size
sql/sys_vars.h:
  Use reinterpret_cast rather than c-style cast.
storage/perfschema/pfs_instr.cc:
  Include my_global.h first, to get correct platform definitions.
2010-12-21 13:00:26 +01:00
Sergey Vojtovich
9a3e46c520 WL#5571 - Audit interface: MYSQL_AUDIT_GENERAL_STATUS event
include/mysql/plugin_audit.h:
  Connection auditing class.
include/mysql/plugin_audit.h.pp:
  Connection auditing class.
sql/mysqld.cc:
  Notify disconnect to auditing.
sql/sql_audit.cc:
  Connection class event dispatcher.
sql/sql_audit.h:
  mysql_audit_notify() is not available in embedded.
sql/sql_connect.cc:
  Notify connect to auditing.
sql/sql_parse.cc:
  Notify user change to auditing.
2010-12-14 17:34:23 +03:00
Alexander Barkov
185e189da3 Bug#57306 SHOW PROCESSLIST does not display string literals well.
Problem: Extended characters outside of ASCII range where not displayed
properly in SHOW PROCESSLIST, because thd_info->query was always sent as 
system_character_set (utf8). This was wrong, because query buffer
is never converted to utf8 - it is always have client character set.

Fix: sending query buffer using query character set

  @ sql/sql_class.cc
  @ sql/sql_class.h
    Introducing a new class CSET_STRING, a LEX_STRING with character set.
    Adding set_query(&CSET_STRING)
    Adding reset_query(), to use instead of set_query(0, NULL).

  @ sql/event_data_objects.cc
    Using reset_query()

  @ sql/log_event.cc
    Using reset_query()
    Adding charset argument to set_query_and_id().

  @ sql/slave.cc
    Using reset_query().

  @ sql/sp_head.cc
    Changing backing up and restore code to use CSET_STRING.

  @ sql/sql_audit.h
    Using CSET_STRING.
    In the "else" branch it's OK not to use
    global_system_variables.character_set_client.
    &my_charset_latin1, which is set in constructor, is fine
    (verified with Sergey Vojtovich).

  @ sql/sql_insert.cc
    Using set_query() with proper character set: table_name is utf8.

  @ sql/sql_parse.cc
    Adding character set argument to set_query_and_id().
    (This is the main point where thd->charset() is stored
     into thd->query_string.cs, for use in "SHOW PROCESSLIST".)
    Using reset_query().
    
  @ sql/sql_prepare.cc
    Storing client character set into thd->query_string.cs.

  @ sql/sql_show.cc
    Using CSET_STRING to fetch and send charset-aware query information
    from threads.

  @ storage/myisam/ha_myisam.cc
    Using set_query() with proper character set: table_name is utf8.

  @ mysql-test/r/show_check.result
  @ mysql-test/t/show_check.test
    Adding tests
2010-11-18 17:08:32 +03:00
Georgi Kodinov
353739fdef merge of mysql-5.5 into mysql-5.5-wl1054 2010-09-20 17:17:32 +03:00
Sergey Vojtovich
b51c8cab3e BUG#54989 - With null_audit installed, server hangs on an
attempt to install a plugin twice

Server crashes when [UN]INSTALL PLUGIN fails (returns an
error) and general log is disabled and there are audit
plugins interested in MYSQL_AUDIT_GENERAL_CLASS. 

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.

Repeatable only with general_log disabled, because general_log
triggers MYSQL_AUDIT_GENERAL_LOG event, which acquires audit
plugins before [UN]INSTALL PLUGIN acquired LOCK_plugin.

With this fix we pre-acquire audit plugins for events that
may potentially occur during [UN]INSTALL PLUGIN.

This hack should be removed when LOCK_plugin is fixed so it
protects only what it supposed to protect.

No test case for this fix - we do not have facility to test
audit plugins yet.

sql/sql_audit.cc:
  Move "acquire audit plugin" logics to a separate
  function.
sql/sql_audit.h:
  Move "acquire audit plugin" logics to a separate
  function.
sql/sql_plugin.cc:
  Pre-acquire audit plugins for events that may potentially occur
  during [UN]INSTALL PLUGIN.
2010-08-20 13:58:28 +04:00
Georgi Kodinov
9705711596 WL#1054: Pluggable authentication support
Merged the implementation to a new base tree.
2010-08-09 11:32:50 +03:00
Mats Kindahl
23d8586dbf WL#5030: Split and remove mysql_priv.h
This patch:

- Moves all definitions from the mysql_priv.h file into
  header files for the component where the variable is
  defined
- Creates header files if the component lacks one
- Eliminates all include directives from mysql_priv.h
- Eliminates all circular include cycles
- Rename time.cc to sql_time.cc
- Rename mysql_priv.h to sql_priv.h
2010-03-31 16:05:33 +02:00
Sergey Vojtovich
9130563708 Backport from 6.0-codebase.
Bug #36098 Audit plugin (wl 3771) feature disabled in 6.0
avoid recusrive locking of LOCK_plugin

include/mysql/plugin_audit.h:
  fix incorrect version
sql/log.cc:
  move the common code to a shared header
sql/mysqld.cc:
  restore the deleted functionality
sql/set_var.cc:
  remove unused parameter
sql/sql_audit.h:
  two inline convenience functions
sql/sql_parse.cc:
  use a simplified convenience call
sql/sql_plugin.cc:
  unlock LOCK_plugin for plugin->init() call, add missing OOM check,
  issue "unknown variable" error in find_sys_var, not down the stack
2009-12-16 15:56:36 +04:00