Commit graph

2522 commits

Author SHA1 Message Date
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
Sergei Golubchik
3b0c7ac1f9 Merge branch '10.0' into 10.1 2016-03-21 13:02:53 +01:00
Oleksandr Byelkin
dc08ccab42 MDEV-9704: ALTER TABLE does not work from client
Do not try to send progress packets if client was not informed about them.
2016-03-14 18:30:14 +01:00
Vicențiu Ciorbaru
9c6fd420c1 [MDEV-7978] Post review fixes and cleanups.
* Maintain coding style in sql_yacc.yy in regards to optional clauses.
* Remove unused variable from sql_acl.cc.
* Update test case
2016-03-08 16:55:17 +02:00
Vicențiu Ciorbaru
5e873141a5 [MDEV-7978] Added show create user implementation. 2016-03-08 16:55:17 +02:00
Vicențiu Ciorbaru
b4fcd1a408 [MDEV-7978] Updated syntax for SHOW CREATE USER 2016-03-08 16:55:17 +02:00
Vicențiu Ciorbaru
b45c3d0b08 [MDEV-7978] Implement alter user and tested create user
Implemented the alter user syntax. Also tested that create user
creates users accordingly.
2016-03-08 16:55:17 +02:00
Vicențiu Ciorbaru
90b717b3cd [MDEV-7978] Update grammar for new syntax
Extend the syntax accepted by the grammar to account for the new create user
and alter user syntax.
2016-03-08 16:55:17 +02:00
Vicențiu Ciorbaru
6066ede444 Fix warnings in sql_acl.cc 2016-03-08 16:55:17 +02:00
Otto Kekäläinen
1777fd5f55 Fix spelling: occurred, execute, which etc 2016-03-04 02:09:37 +02:00
Arun Kuruvila
447eaa5bc0 2016-02-23 11:54:59 +05:30
Monty
b2f8d7b410 Merge branch '10.1' into 10.2
Conflicts:
	VERSION
	cmake/plugin.cmake
	config.h.cmake
	configure.cmake
	plugin/server_audit/server_audit.c
	sql/sql_yacc.yy
2016-02-06 18:14:54 +02:00
Oleksandr Byelkin
d4b3a199ac MDEV-9117: Client Server capability negotiation for MariaDB specific functionality
New capability flags space.
Removed old progress flag, added new one.
2016-02-02 14:35:10 +01:00
Alexey Botchkov
552d33095a MDEV-5273 Prepared statement doesn't return metadata after prepare.
Fix for SHOW GRANTS statement.
2016-01-28 11:12:03 +04:00
Georg Richter
c1bf5ba27e Revert "On Windows SSL works with sockets only, so we shouldn't tell the client"
This reverts commit 2ee149be4e.
2016-01-27 16:34:05 +01:00
Georg Richter
33e5a8aba2 On Windows SSL works with sockets only, so we shouldn't tell the client
that we support SSL when using named pipes or shared memory.
2016-01-27 16:34:05 +01:00
Sergei Golubchik
68910e7092 MDEV-9273 ERROR 1819 on grant statment for existing user
Cannot do password validation in fix_lex_user(), we don't know
there what "GRANT ... TO user" means - creating a new user with
an empty password (need validation) or granting privileges
to an existing user (no validation needed).

Move validation down into replace_user_table(). And copy into
check_change_password().
2016-01-25 22:57:53 +01:00
Sergei Golubchik
d14c4c7874 cleanup: move all password validation logic into one function 2016-01-25 22:57:53 +01:00
Sergei Golubchik
c37107380a cleanup: LEX_USER::pwtext and LEX_USER::pwhash
Was:
* LEX_USER::password was storing sometimes
  plaintext password and sometimes password hash
* LEX_USER::auth was storing sometimes password hash and
  sometimes plugin authentication string

Now:
* LEX_USER::pwtext stores the password in plain-text
* LEX_USER::pwhash stores the password hash
* LEX_USER::auth stores the plugin authentication string
2016-01-25 17:04:15 +01:00
Sergei Golubchik
1fea7e785f cleanup: create LEX_USER::reset_auth()
as this is used quite often
2016-01-25 17:04:14 +01:00
Alexander Barkov
2ba7ed77aa Merge remote-tracking branch 'origin/10.1' into 10.2 2015-12-29 19:37:11 +04:00
Sergei Golubchik
a2bcee626d Merge branch '10.0' into 10.1 2015-12-21 21:24:22 +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
1623995158 Merge branch '5.5' into 10.0 2015-12-13 00:10:40 +01:00
Sergei Golubchik
abf9d35213 Merge branch 'mysql/5.5' into 5.5 2015-12-09 10:00:49 +01:00
Sergey Vojtovich
54689e1d5c MDEV-8715 - Obsolete sql_alloc() in favor of THD::alloc() and thd_alloc()
The following left in semi-improved state to keep patch size reasonable:
- Field operator new: left thd_alloc(current_thd)
- Sql_alloc operator new: left thd_alloc(thd_get_current_thd())
- Item_args constructors: left thd_alloc(thd)
- Item_func_interval::fix_length_and_dec(): no THD arg, have to call current_thd
- Item_func_dyncol_exists::val_int(): same
- Item_dyncol_get::val_str(): same
- Item_dyncol_get::val_int(): same
- Item_dyncol_get::val_real(): same
- Item_dyncol_get::val_decimal(): same
- Item_singlerow_subselect::fix_length_and_dec(): same
2015-11-26 11:34:17 +04:00
Sergei Golubchik
2fc3dc393d Merge branch '10.1' into bb-10.1-serg 2015-11-20 09:31:13 +01:00
Monty
1e156e1436 Fixed compile warnings on Solaris 2015-11-20 10:00:06 +02:00
Sergei Golubchik
beded7d9c9 Merge branch '10.0' into 10.1 2015-11-19 15:52:14 +01:00
Sergei Golubchik
6f0754789c MDEV-8614 Assertion `status == 0' failed in add_role_user_mapping_action on RENAME USER
don't forget to re-examine the current element when updating a HASH
2015-10-22 13:09:38 +02:00
Sergei Golubchik
3e1c743d4a MDEV-7656 init_file option does not allow changing passwords
allow SET PASSWORD from  bootstrap and init-file
2015-10-22 07:23:59 +02:00
Arun Kuruvila
3846b08552 Bug #21602056 : CONCURRENT FLUSH PRIVILEGES + REVOKE/GRANT
CRASHES IN WILD_CASE_COMPARE!

Description:- Executing FLUSH PRIVILEGES and REVOKE/
GRANT concurrently crashes the server.

Analysis:- Concurrent FLUSH PRIVILEGES and REVOKE/GRANT
might trigger a small time frame in which REVOKE/GRANT
fetches the "acl_proxy_user" information as a part of
"acl_check_proxy_grant_access()". Meanwhile FLUSH PRIVILEGES
deletes the old acl structures as a part of "acl_reload()".
After which REVOKE/GRANT tries to access the hostname in
"wild_case_compare()" which leads to a crash because of the
invalid memory access.

Fix:- Mutex lock on "acl_cache" is acquired before fetching
"acl_proxy_user" information in
"acl_check_proxy_grant_access()".
2015-10-14 11:08:49 +05:30
Sergei Golubchik
dfb74dea30 Merge branch '10.0' into 10.1 2015-10-12 00:37:58 +02:00
Sergei Golubchik
cfeedbfd3e Merge branch '5.5' into 10.0 2015-10-09 17:12:26 +02:00
Sergei Golubchik
82e9f6d948 Merge remote-tracking branch 'mysql/5.5' into 5.5 2015-10-08 22:54:24 +02:00
Monty
56aa19989f MDEV-6152: Remove calls to current_thd while creating Item
Part 5: Removing calls to current_thd in net_read calls, creating fields,
        query_cache, acl and some other places where thd was available
2015-09-01 18:42:02 +03:00
Monty
3cb578c001 MDEV-6152: Remove calls to current_thd while creating Item
- Part 3: Adding mem_root to push_back() and push_front()

Other things:
- Added THD as an argument to some partition functions.
- Added memory overflow checking for XML tag's in read_xml()
2015-08-27 22:21:08 +03:00
Monty
1bae0d9e56 Stage 2 of MDEV-6152:
- Added mem_root to all calls to new Item
- Added private method operator new(size_t size) to Item to ensure that
  we always use a mem_root when creating an item.

This saves use once call to current_thd per Item creation
2015-08-21 10:40:51 +04:00
Sergey Vojtovich
31e365efae MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)
Added mandatory thd parameter to Item (and all derivative classes) constructor.
Added thd parameter to all routines that may create items.
Also removed "current_thd" from Item::Item. This reduced number of
pthread_getspecific() calls from 290 to 177 per OLTP RO transaction.
2015-08-21 10:40:39 +04:00
Sreeharsha Ramanavarapu
6fb2cdbc74 Bug #20777016: DELETE CHECKS PRIVILEGES ON THE WRONG
DATABASE WHEN USING TABLE ALIASES

Issue:
-----
When using table aliases for deleting, MySQL checks
privileges against the current database and not the
privileges on the actual table or database the table
resides.


SOLUTION:
---------
While checking privileges for multi-deletes,
correspondent_table should be used since it points to the
correct table and database.
2015-07-13 07:51:23 +05:30
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
Vicențiu Ciorbaru
0357791e3c MDEV-8280: crash in 'show global status' with --skip-grant-tables
The crash was caused by attempting to use a hashtable without
it getting initialized, due to the --skip-grant-tables switch.
2015-06-22 08:44:46 +03:00
Sergei Golubchik
5091a4ba75 Merge tag 'mariadb-10.0.19' into 10.1 2015-06-01 15:51:25 +02:00
Vicențiu Ciorbaru
d3a3adb833 MDEV-7985: MySQL Users Break when Migrating to MariaDB, part 2
Gave priority to password field when using a native authentication
plugin.

Also, prevented a user from setting an invalid auth_string, when using
native authentication.
2015-05-05 22:50:32 +03:00
Vicențiu Ciorbaru
6c55e52b10 MDEV-7774: Crash when dropping user within rebuild_role_grants
The issue comes from not taking all possibilities to match an entry
within the roles_mapping HASH, when updating the data structure.
2015-05-03 11:49:49 +03:00
Arun Kuruvila
c9a38e8698 Merge branch 'mysql-5.1' into mysql-5.5 2015-04-28 14:58:01 +05:30
Arun Kuruvila
fdae90dd11 Bug #20181776 :- ACCESS CONTROL DOESN'T MATCH MOST SPECIFIC
HOST WHEN IT CONTAINS WILDCARD

Description :- Incorrect access privileges are provided to a
user due to wrong sorting of users when wildcard characters
is present in the hostname.

Analysis :- Function "get_sorts()" is used to sort the
strings of user name, hostname, database name. It is used
to arrange the users in the access privilege matching order.
When a user connects, it checks in the sorted user access
privilege list and finds a corresponding matching entry for
the user. Algorithm used in "get_sort()" sorts the strings
inappropriately. As a result, when a user connects to the
server, it is mapped to incorrect user access privileges.
Algorithm used in "get_sort()" counts the number of
characters before the first occurence of any one of the
wildcard characters (single-wildcard character '_' or
multi-wildcard character '%') and sorts in that order.
As a result of inconnect sorting it treats hostname "%" and
"%.mysql.com" as equally-specific values and therefore
the order is indeterminate.

Fix:- The "get_sort()" algorithm has been modified to treat
"%" seperately. Now "get_sort()" returns a number which, if
sorted in descending order, puts strings in the following
order:-
* strings with no wildcards
* strings containg wildcards and non-wildcard characters
* single muilt-wildcard character('%')
* empty string.
2015-04-28 14:56:55 +05:30
V S Murthy Sidagam
7797ef4dec Merge branch 'mysql-5.1' into mysql-5.5 2015-04-27 14:46:40 +05:30
V S Murthy Sidagam
c655515d1b Bug #20683237 BACKPORT 19817663 TO 5.1 and 5.5
Restrict when user table hashes can be viewed. Require SUPER privileges.
2015-04-27 14:33:25 +05:30
Vicențiu Ciorbaru
1a32993537 MDEV-5214 Status variables for number of global/db/table/column/role grants
Implemented the status variables for use with the feedback plugin.
2015-03-19 22:41:43 +02:00
Alexander Barkov
e6f67c64cd MDEV-6572 "USE dbname" with a bad sequence erroneously connects to a wrong database 2015-03-16 21:55:10 +04:00
Sergei Golubchik
2db62f686e Merge branch '10.0' into 10.1 2015-03-07 13:21:02 +01:00
Sergei Golubchik
44cf4d6751 fix a case where automatic procedure grant was changing user's password
phase out make_password_from_salt() to be removed in 10.1
2015-02-17 18:07:56 +01:00
Monty
3a3ec744b5 cleanups done as part of adding encryption
- Fixed compiler warnings
- Added include/wait_for_binlog_checkpoint.inc, as suggested by JonasO
- Updated 'build-tags' to work with git (Patch by Serg)
2015-02-10 10:21:16 +01:00
Sergei Golubchik
0ce8703e99 password validation plugin API: renames 2015-02-10 10:21:15 +01:00
Vicențiu Ciorbaru
4c69a6fff2 MDEV-6918 Create a way to see a user's default role.
Added an extra column to i_s_applicable_roles, named IS_DEFAULT.
The column displays which role is the default role for the user
querying the table.
2015-02-09 17:16:55 +02: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
Alexander Barkov
1f0ad6c6b3 MDEV-7288 USER/ROLE: CREATE OR REPLACE, CREATE IF NOT EXISTS, DROP IF EXISTS 2015-01-13 11:50:33 +04:00
Sergei Golubchik
7516a3c7f4 strict_password_validation 2014-12-04 10:41:55 +01:00
Sergei Golubchik
b814046719 validate SET PASSWORD 2014-12-04 10:41:55 +01:00
Sergei Golubchik
8934794a70 password validation function in sql_acl.cc 2014-12-04 10:41:54 +01:00
Sergei Golubchik
b5357f025b GRANT: calculate pasword hash in sql_acl.cc
don't do it in the parser, one should not make run-time
decisions (like, checking thd->variables.old_passwords variable)
during parsing.
2014-12-04 10:41:54 +01:00
Sergei Golubchik
7bd9eb1f41 parser: store the password hash in LEX_USER::auth, not in ::password
* indeed, "username IDENTIFIED BY PASSWORD hash" is the same
  as "username IDENTIFIED VIA mysql_native_password USING hash"
* LEX_USER::password can now be used for plain-text passwords
2014-12-04 10:41:54 +01:00
Sergei Golubchik
91ad0cd580 sql_acl.cc: better recognize the context to tell the role from a user
REQUIRE and MAX_QUERIES_PER_HOUR can not possibly apply to a role
2014-12-04 10:41:54 +01:00
Sergei Golubchik
bc603c604d bugfix: IDENTIFIED BY clause was lost in some GRANT variants 2014-12-04 10:41:54 +01:00
Sergei Golubchik
61820bca9b cleanup: sql_acl.cc
* remove no-op check_password_policy() and references to it
* add 'static' to functions that need it
* remove unused function check_acl_user()
2014-12-04 10:41:53 +01:00
Sergei Golubchik
f5722f5851 cleanup: normalize LEX_USER to get rid of different representation of the same thing
username IDENTIFIED BY PASSWORD xxx
  username IDENTIFIED VIA mysql_native_password USING xxx
  etc

also check for valid strlen(xxx)
2014-12-04 10:41:53 +01:00
Sergei Golubchik
c1204da1c7 cleanup: bool_variable= -1; -> bool_variable= true; 2014-12-04 10:41:53 +01:00
Sergei Golubchik
2ae7541bcf cleanup: s/const CHARSET_INFO/CHARSET_INFO/
as CHARSET_INFO is already const, using const on it
is redundant and results in compiler warnings (on Windows)
2014-12-04 10:41:51 +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
3182938d22 move userstat tables to a plugin 2014-10-11 18:53:05 +02:00
Sergei Golubchik
2a4e8813f6 GLOBAL_VALUE_ORIGIN=AUTO 2014-10-11 10:23:21 +02:00
Sergei Golubchik
99677cc510 cleanup: move safe_str*() from sql_acl.cc to m_string.h 2014-10-10 22:27:41 +02:00
Sergei Golubchik
03ec3511a8 cleanup: galera misc cleanups
also disable galera-specific output in mysql_tzinfo_to_sql,
it'll be enabled later.
2014-10-10 22:27:36 +02:00
Sergei Golubchik
1b75bed00f 5.5.40+ merge 2014-10-09 10:30:11 +02:00
Monty
cc8aed3eb7 MDEV 4427: query timeouts
Added MAX_STATEMENT_TIME user variable to automaticly kill queries after a given time limit has expired.

- Added timer functions based on pthread_cond_timedwait
- Added kill_handlerton() to signal storage engines about kill/timeout
- Added support for GRANT ... MAX_STATEMENT_TIME=#
- Copy max_statement_time to current user, if stored in mysql.user
- Added status variable max_statement_time_exceeded
- Added KILL_TIMEOUT
- Removed digest hash from performance schema tests as they change all the time.
- Updated test results that changed because of the new user variables or new fields in mysql.user

This functionallity is inspired by work done by Davi Arnaut at twitter.
Test case is copied from Davi's work.

Documentation can be found at
https://kb.askmonty.org/en/how-to-limittimeout-queries/

mysql-test/r/mysqld--help.result:
  Updated for new help message
mysql-test/suite/perfschema/r/all_instances.result:
  Added new mutex
mysql-test/suite/sys_vars/r/max_statement_time_basic.result:
  Added testing of max_statement_time
mysql-test/suite/sys_vars/t/max_statement_time_basic.test:
  Added testing of max_statement_time
mysql-test/t/max_statement_time.test:
  Added testing of max_statement_time
mysys/CMakeLists.txt:
  Added thr_timer
mysys/my_init.c:
mysys/mysys_priv.h:
  Added new mutex and condition variables
  Added new mutex and condition variables
mysys/thr_timer.c:
  Added timer functions based on pthread_cond_timedwait()
  This can be compiled with HAVE_TIMER_CREATE to benchmark agains timer_create()/timer_settime()
sql/lex.h:
  Added MAX_STATEMENT_TIME
sql/log_event.cc:
  Safety fix (timeout should be threated as an interrupted query)
sql/mysqld.cc:
  Added support for timers
  Added status variable max_statement_time_exceeded
sql/share/errmsg-utf8.txt:
  Added ER_QUERY_TIMEOUT
sql/signal_handler.cc:
  Added support for KILL_TIMEOUT
sql/sql_acl.cc:
  Added support for GRANT ... MAX_STATEMENT_TIME=#
  Copy max_statement_time to current user
sql/sql_class.cc:
  Added timer functionality to THD.
  Added thd_kill_timeout()
sql/sql_class.h:
  Added timer functionality to THD.
  Added KILL_TIMEOUT
  Added max_statement_time variable in similar manner as long_query_time was done.
sql/sql_connect.cc:
  Added handling of max_statement_time_exceeded
sql/sql_parse.cc:
  Added starting and stopping timers for queries.
sql/sql_show.cc:
  Added max_statement_time_exceeded for user/connects status in MariaDB 10.0
sql/sql_yacc.yy:
  Added support for GRANT ... MAX_STATEMENT_TIME=# syntax, to be enabled in 10.0
sql/structs.h:
  Added max_statement_time user resource
sql/sys_vars.cc:
  Added max_statement_time variables
mysql-test/suite/roles/create_and_drop_role_invalid_user_table.test
  Removed test as we require all fields in mysql.user table.
scripts/mysql_system_tables.sql
scripts/mysql_system_tables_data.sql
scripts/mysql_system_tables_fix.sql
  Updated mysql.user with new max_statement_time field
2014-10-07 11:37:36 +03:00
Sergei Golubchik
3620910eea cleanup: galera merge, simple changes 2014-10-01 23:38:27 +02:00
Michael Widenius
70823e1d91 MDEV-5120 Test suite test maria-no-logging fails
The reason for the failure was a bug in an include file on debian that causes 'struct stat'
to have different sized depending on the environment.

This patch fixes so that we always include my_global.h or my_config.h before we include any other files.

Other things:
- Removed #include <my_global.h> in some include files; Better to always do this at the top level to have as few
  "always-include-this-file-first' files as possible.
- Removed usage of some include files that where already included by my_global.h or by other files.


client/mysql_plugin.c:
  Use my_global.h first
client/mysqlslap.c:
  Remove duplicated include files
extra/comp_err.c:
  Remove duplicated include files
include/m_string.h:
  Remove duplicated include files
include/maria.h:
  Remove duplicated include files
libmysqld/emb_qcache.cc:
  Use my_global.h first
plugin/semisync/semisync.h:
  Use my_pthread.h first
sql/datadict.cc:
  Use my_global.h first
sql/debug_sync.cc:
  Use my_global.h first
sql/derror.cc:
  Use my_global.h first
sql/des_key_file.cc:
  Use my_global.h first
sql/discover.cc:
  Use my_global.h first
sql/event_data_objects.cc:
  Use my_global.h first
sql/event_db_repository.cc:
  Use my_global.h first
sql/event_parse_data.cc:
  Use my_global.h first
sql/event_queue.cc:
  Use my_global.h first
sql/event_scheduler.cc:
  Use my_global.h first
sql/events.cc:
  Use my_global.h first
sql/field.cc:
  Use my_global.h first
  Remove duplicated include files
sql/field_conv.cc:
  Use my_global.h first
sql/filesort.cc:
  Use my_global.h first
  Remove duplicated include files
sql/gstream.cc:
  Use my_global.h first
sql/ha_ndbcluster.cc:
  Use my_global.h first
sql/ha_ndbcluster_binlog.cc:
  Use my_global.h first
sql/ha_ndbcluster_cond.cc:
  Use my_global.h first
sql/ha_partition.cc:
  Use my_global.h first
sql/handler.cc:
  Use my_global.h first
sql/hash_filo.cc:
  Use my_global.h first
sql/hostname.cc:
  Use my_global.h first
sql/init.cc:
  Use my_global.h first
sql/item.cc:
  Use my_global.h first
sql/item_buff.cc:
  Use my_global.h first
sql/item_cmpfunc.cc:
  Use my_global.h first
sql/item_create.cc:
  Use my_global.h first
sql/item_geofunc.cc:
  Use my_global.h first
sql/item_inetfunc.cc:
  Use my_global.h first
sql/item_row.cc:
  Use my_global.h first
sql/item_strfunc.cc:
  Use my_global.h first
sql/item_subselect.cc:
  Use my_global.h first
sql/item_sum.cc:
  Use my_global.h first
sql/item_timefunc.cc:
  Use my_global.h first
sql/item_xmlfunc.cc:
  Use my_global.h first
sql/key.cc:
  Use my_global.h first
sql/lock.cc:
  Use my_global.h first
sql/log.cc:
  Use my_global.h first
sql/log_event.cc:
  Use my_global.h first
sql/log_event_old.cc:
  Use my_global.h first
sql/mf_iocache.cc:
  Use my_global.h first
sql/mysql_install_db.cc:
  Remove duplicated include files
sql/mysqld.cc:
  Remove duplicated include files
sql/net_serv.cc:
  Remove duplicated include files
sql/opt_range.cc:
  Use my_global.h first
sql/opt_subselect.cc:
  Use my_global.h first
sql/opt_sum.cc:
  Use my_global.h first
sql/parse_file.cc:
  Use my_global.h first
sql/partition_info.cc:
  Use my_global.h first
sql/procedure.cc:
  Use my_global.h first
sql/protocol.cc:
  Use my_global.h first
sql/records.cc:
  Use my_global.h first
sql/records.h:
  Don't include my_global.h
  Better to do this at the upper level
sql/repl_failsafe.cc:
  Use my_global.h first
sql/rpl_filter.cc:
  Use my_global.h first
sql/rpl_gtid.cc:
  Use my_global.h first
sql/rpl_handler.cc:
  Use my_global.h first
sql/rpl_injector.cc:
  Use my_global.h first
sql/rpl_record.cc:
  Use my_global.h first
sql/rpl_record_old.cc:
  Use my_global.h first
sql/rpl_reporting.cc:
  Use my_global.h first
sql/rpl_rli.cc:
  Use my_global.h first
sql/rpl_tblmap.cc:
  Use my_global.h first
sql/rpl_utility.cc:
  Use my_global.h first
sql/set_var.cc:
  Added comment
sql/slave.cc:
  Use my_global.h first
sql/sp.cc:
  Use my_global.h first
sql/sp_cache.cc:
  Use my_global.h first
sql/sp_head.cc:
  Use my_global.h first
sql/sp_pcontext.cc:
  Use my_global.h first
sql/sp_rcontext.cc:
  Use my_global.h first
sql/spatial.cc:
  Use my_global.h first
sql/sql_acl.cc:
  Use my_global.h first
sql/sql_admin.cc:
  Use my_global.h first
sql/sql_analyse.cc:
  Use my_global.h first
sql/sql_audit.cc:
  Use my_global.h first
sql/sql_base.cc:
  Use my_global.h first
sql/sql_binlog.cc:
  Use my_global.h first
sql/sql_bootstrap.cc:
  Use my_global.h first
  Use my_global.h first
sql/sql_cache.cc:
  Use my_global.h first
sql/sql_class.cc:
  Use my_global.h first
sql/sql_client.cc:
  Use my_global.h first
sql/sql_connect.cc:
  Use my_global.h first
sql/sql_crypt.cc:
  Use my_global.h first
sql/sql_cursor.cc:
  Use my_global.h first
sql/sql_db.cc:
  Use my_global.h first
sql/sql_delete.cc:
  Use my_global.h first
sql/sql_derived.cc:
  Use my_global.h first
sql/sql_do.cc:
  Use my_global.h first
sql/sql_error.cc:
  Use my_global.h first
sql/sql_explain.cc:
  Use my_global.h first
sql/sql_expression_cache.cc:
  Use my_global.h first
sql/sql_handler.cc:
  Use my_global.h first
sql/sql_help.cc:
  Use my_global.h first
sql/sql_insert.cc:
  Use my_global.h first
sql/sql_lex.cc:
  Use my_global.h first
sql/sql_load.cc:
  Use my_global.h first
sql/sql_locale.cc:
  Use my_global.h first
sql/sql_manager.cc:
  Use my_global.h first
sql/sql_parse.cc:
  Use my_global.h first
sql/sql_partition.cc:
  Use my_global.h first
sql/sql_plugin.cc:
  Added comment
sql/sql_prepare.cc:
  Use my_global.h first
sql/sql_priv.h:
  Added error if we use this before including my_global.h
  This check is here becasue so many files includes sql_priv.h first.
sql/sql_profile.cc:
  Use my_global.h first
sql/sql_reload.cc:
  Use my_global.h first
sql/sql_rename.cc:
  Use my_global.h first
sql/sql_repl.cc:
  Use my_global.h first
sql/sql_select.cc:
  Use my_global.h first
sql/sql_servers.cc:
  Use my_global.h first
sql/sql_show.cc:
  Added comment
sql/sql_signal.cc:
  Use my_global.h first
sql/sql_statistics.cc:
  Use my_global.h first
sql/sql_table.cc:
  Use my_global.h first
sql/sql_tablespace.cc:
  Use my_global.h first
sql/sql_test.cc:
  Use my_global.h first
sql/sql_time.cc:
  Use my_global.h first
sql/sql_trigger.cc:
  Use my_global.h first
sql/sql_udf.cc:
  Use my_global.h first
sql/sql_union.cc:
  Use my_global.h first
sql/sql_update.cc:
  Use my_global.h first
sql/sql_view.cc:
  Use my_global.h first
sql/sys_vars.cc:
  Added comment
sql/table.cc:
  Use my_global.h first
sql/thr_malloc.cc:
  Use my_global.h first
sql/transaction.cc:
  Use my_global.h first
sql/uniques.cc:
  Use my_global.h first
sql/unireg.cc:
  Use my_global.h first
sql/unireg.h:
  Removed inclusion of my_global.h
storage/archive/ha_archive.cc:
  Added comment
storage/blackhole/ha_blackhole.cc:
  Use my_global.h first
storage/csv/ha_tina.cc:
  Use my_global.h first
storage/csv/transparent_file.cc:
  Use my_global.h first
storage/federated/ha_federated.cc:
  Use my_global.h first
storage/federatedx/federatedx_io.cc:
  Use my_global.h first
storage/federatedx/federatedx_io_mysql.cc:
  Use my_global.h first
storage/federatedx/federatedx_io_null.cc:
  Use my_global.h first
storage/federatedx/federatedx_txn.cc:
  Use my_global.h first
storage/heap/ha_heap.cc:
  Use my_global.h first
storage/innobase/handler/handler0alter.cc:
  Use my_global.h first
storage/maria/ha_maria.cc:
  Use my_global.h first
storage/maria/unittest/ma_maria_log_cleanup.c:
  Remove duplicated include files
storage/maria/unittest/test_file.c:
  Added comment
storage/myisam/ha_myisam.cc:
  Move sql_plugin.h first as this includes my_global.h
storage/myisammrg/ha_myisammrg.cc:
  Use my_global.h first
storage/oqgraph/oqgraph_thunk.cc:
  Use my_config.h and my_global.h first
  One could not include my_global.h before oqgraph_thunk.h (don't know why)
storage/spider/ha_spider.cc:
  Use my_global.h first
storage/spider/hs_client/config.cpp:
  Use my_global.h first
storage/spider/hs_client/escape.cpp:
  Use my_global.h first
storage/spider/hs_client/fatal.cpp:
  Use my_global.h first
storage/spider/hs_client/hstcpcli.cpp:
  Use my_global.h first
storage/spider/hs_client/socket.cpp:
  Use my_global.h first
storage/spider/hs_client/string_util.cpp:
  Use my_global.h first
storage/spider/spd_conn.cc:
  Use my_global.h first
storage/spider/spd_copy_tables.cc:
  Use my_global.h first
storage/spider/spd_db_conn.cc:
  Use my_global.h first
storage/spider/spd_db_handlersocket.cc:
  Use my_global.h first
storage/spider/spd_db_mysql.cc:
  Use my_global.h first
storage/spider/spd_db_oracle.cc:
  Use my_global.h first
storage/spider/spd_direct_sql.cc:
  Use my_global.h first
storage/spider/spd_i_s.cc:
  Use my_global.h first
storage/spider/spd_malloc.cc:
  Use my_global.h first
storage/spider/spd_param.cc:
  Use my_global.h first
storage/spider/spd_ping_table.cc:
  Use my_global.h first
storage/spider/spd_sys_table.cc:
  Use my_global.h first
storage/spider/spd_table.cc:
  Use my_global.h first
storage/spider/spd_trx.cc:
  Use my_global.h first
storage/xtradb/handler/handler0alter.cc:
  Use my_global.h first
storage/xtradb/handler/i_s.cc:
  Use my_global.h first
2014-09-30 20:31:14 +03:00
Sergei Petrunia
30fab5fb51 MDEV-6788: The variable 'role' is being used without being initialized at sql_acl.cc:8840
[re-commit in git]
Second variant of the fix: reduce the scope of 'role' variable
2014-09-25 19:14:16 +04:00
Sergey Petrunya
1f437f3e8c MDEV-6788: The variable 'role' is being used without being initialized at sql_acl.cc:8840
Second variant of the fix: reduce the scope of 'role' variable
2014-09-25 19:12:52 +04:00
Sergei Petrunia
532334cb11 MDEV-6788: The variable 'role' is being used without being initialized at sql_acl.cc:8840
[Re-commit in git]
Don't check the value of 'role' variable in the cases where we don't need
it. (it may be marked as uninitialized and we get a runtime error).
2014-09-25 18:27:20 +04:00
Sergey Petrunya
949989e5ff MDEV-6788: The variable 'role' is being used without being initialized at sql_acl.cc:8840
Don't check the value of 'role' variable in the cases where we don't need it. (it 
may be marked as unitialized and we get a runtime error).
2014-09-25 18:16:29 +04:00
Sergey Vojtovich
d1e46a50bc MDEV-6749 - Deadlock between GRANT/REVOKE, SELECT FROM I_S.COLUMNS,
SET slow_query_log and failed connection attempt

A very subtle though valid deadlock. Deadlock chain:
wrlock(LOCK_grant)    -> lock(acl_cache->lock) GRANT/REVOKE CREATE/DROP USER
lock(LOCK_open)       -> rdlock(LOCK_grant)    SELECT * FROM I_S.COLUMNS
wrlock(LOCK_logger)   -> lock(LOCK_open)       SET @@global.slow_query_log='ON'
lock(acl_cache->lock) -> rdlock(LOCK_logger)   Failed connection

Fixed by removing relationship between acl_cache->lock and LOCK_logger
during failed connection attempt.
2014-09-18 19:45:06 +04:00
Sergei Golubchik
c338772a59 fixes for valgrind failures
sql/item.cc:
  don't forget to adjust the length of the string when removing leading spaces
sql/sql_acl.cc:
  when updating the hostname of the ACL_USER, update the hostname_length too
sql/sql_parse.cc:
  first compare the username string, then test the host pointer
  (host pointer is undefined when the username string is one of the hard-coded values
  set by the parser). This is not a bug, old code is perfectly safe as the undefined
  host pointer is never dereferenced, but let's keep valgrind happy.
2014-09-17 19:38:42 +02:00
Alexander Barkov
1e66871713 Adding Item_string_sys and Item_string_ascii to reduce duplicate code 2014-09-03 18:24:31 +04:00
Jan Lindström
df4dd593f2 MDEV-6247: Merge 10.0-galera to 10.1.
Merged lp:maria/maria-10.0-galera up to revision 3879.

Added a new functions to handler API to forcefully abort_transaction,
producing fake_trx_id, get_checkpoint and set_checkpoint for XA. These
were added for future possiblity to add more storage engines that
could use galera replication.
2014-08-26 15:43:46 +03:00
Sergei Golubchik
911c4811de cleanup and updated test results 2014-07-23 14:48:13 +02:00
Vicentiu Ciorbaru
5298996180 Fixed comment. 2014-07-23 14:48:12 +02:00
Vicentiu Ciorbaru
64b27c734e Added default role implementation 2014-07-23 14:48:12 +02:00
Venkata Sidagam
3bba29a397 Bug #17357528 BACKPORT BUG#16513435 TO 5.5 AND 5.6
Description: Backporting BUG#16513435 to 5.5 and 5.6
This is a fix for REMOTE PREAUTH USER ENUMERATION FLAW bug
2014-06-30 19:24:25 +05:30
Sergei Golubchik
b9ddeeff24 MDEV-6401 SET ROLE returning ERROR 1959 Invalid role specification for valid role
Use user's ip address when verifying privileges for SET ROLE (just like check_access() does)
2014-06-27 09:32:55 +02:00
Sergei Golubchik
e0c8d729a2 long overdue: change maturity level for built-in auth plugins to stable 2014-06-23 20:06:24 +02:00
Sergei Golubchik
242e7f958d MDEV-4549 [PATCH] Clean up code working with ACL tables
* enum values to index different ACL tables, instead of hard-coded numbers
  (even different in diffent functions).
* move TABLE_LIST initialization into open_grant_tables()
  and use it everywhere
* change few my_bool's to bool's
2014-06-23 16:23:51 +02:00
Sergei Golubchik
1eaf2106e5 MDEV-6253 MySQL Users Break when Migrating from MySQL 5.1 to MariaDB 10.0.10
When plugin=mysql_native_password (or mysql_old_password) take the password
from *either* password *or* authentication_string, whichever is set.
This makes no sense, but alas, that's what MySQL-5.6 does.
2014-06-11 10:09:29 +02:00
Sergei Golubchik
08f3280235 5.6-compatibility, per-host connect error counter is reset only after the
successful connection, not when a client reply packet is received
(that still might be invalid).

(test case was merged with perfschema 5.6.17)
2014-05-07 16:13:00 +02:00
unknown
64923bb653 MDEV-6156: Parallel replication incorrectly caches charset between worker threads
The previous patch for this bug was unfortunately completely wrong.

The purpose of cached_charset is to remember which character set we
have installed currently in the THD, so that in the common case where
charset does not change between queries, we do not need to update it
in the THD. Thus, it is important that the cached_charset field is
tightly coupled to the THD for which it handles caching.

Thus the right place to put cached_charset seems to be in the THD.
This patch introduces a field THD:system_thread_info where such info
in general can be placed without further inflating the THD with unused
data for other threads (THD is already far too big as it is). It then
moves the cached_charset into this slot for the SQL driver thread and
for the parallel replication worker threads.

The THD::rpl_filter field is also moved inside system_thread_info, to
keep the size of THD unchanged. Moving further fields in to reduce the
size of THD is a separate task, filed as MDEV-6164.
2014-04-25 12:58:31 +02:00
Sergei Golubchik
0643d1f319 another post-fix patch for MDEV-5850: MySQL Bug#21317: SHOW CREATE DATABASE does not obey to lower_case_table_names
(for case-insensitive filesystems)

sql/events.cc:
  for "SHOW EVENTS IN db_name"
sql/sp_head.h:
  for "CREATE EVENT", and everything SP-related
sql/sql_acl.cc:
  privilege check for mysql_change_db()
sql/sql_db.cc:
  for metadata locking of db names
sql/sql_parse.cc:
  any_db is a constant, it is not writable
sql/sql_show.cc:
  for SHOW CREATE TRIGGER and other trigger-related statements
2014-03-29 11:33:25 +01:00
Sergei Golubchik
97687f2888 Fix hostcache_ipv4_blocked and hostcache_ipv6_blocked to pass.
Don't abort plugin reads whem mpvio->make_it_fail is set - this can leak information.
2014-03-26 22:32:10 +01:00
Sergei Golubchik
10740939eb 5.5 merge 2014-03-26 22:25:38 +01:00
Sergei Golubchik
319bcde937 MDEV-5861 MySQL Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION
escape usernames in CREATE/DROP USER error messages according to NO_BACKSLASH_ESCAPES
2014-03-26 09:42:52 +01:00
Sergei Golubchik
d0c6a05eb5 small cleanup in sql_acl.cc:
use LEX_STRING, keep similar functions together, remove duplicated code
2014-03-26 09:41:37 +01:00
Sergei Golubchik
3e3d627114 MDEV-5771 Privileges acquired via roles depend on the order of granting
GRANT ROLE: don't forget to propagate privileges from granted role to a grantee
2014-03-19 09:57:45 +01:00
Sergei Golubchik
ee9d0f4671 1. move Debug_role_merges_routine status variable increment to a correct function
(similar to other Debug_role_merges_* variables).
2. make optional arguments of propagate_role_grants() really optional
2014-03-19 09:57:17 +01:00
Sergei Golubchik
16d8367aae List<>-style template wrapper over hash_filo 2014-03-19 09:57:09 +01:00
Sergei Golubchik
5d8c15228e 5.3-merge 2014-03-16 19:21:37 +01:00
Sergei Golubchik
a0ea960c3e 5.2 merge 2014-03-13 18:36:52 +01:00
Sergei Golubchik
5616bd5597 unix_socket bypasses make_if_fail by not doing any network reads 2014-03-13 16:35:14 +01:00
Sergey Vojtovich
b95c8ce530 MDEV-5675 - Performance: my_hash_sort_bin is called too often
Reduced number of my_hash_sort_bin() calls from 4 to 1 per query.
Reduced number of memory accesses done by my_hash_sort_bin().

Details:
- let MDL subsystem use pre-calculated hash value for hash
  inserts and deletes
- let table cache use pre-calculated MDL hash value
- MDL namespace is excluded from hash value calculation, so that
  hash value can be used by table cache as is
- hash value for MDL is calculated as resulting hash value + MDL
  namespace
- extended hash implementation to accept user defined hash function
2014-03-06 16:19:12 +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
Sergey Vojtovich
d12c7adf71 MDEV-5314 - Compiling fails on OSX using clang
This is port of fix for MySQL BUG#17647863.

revno: 5572
revision-id: jon.hauglid@oracle.com-20131030232243-b0pw98oy72uka2sj
committer: Jon Olav Hauglid <jon.hauglid@oracle.com>
timestamp: Thu 2013-10-31 00:22:43 +0100
message:
  Bug#17647863: MYSQL DOES NOT COMPILE ON OSX 10.9 GM

  Rename test() macro to MY_TEST() to avoid conflict with libc++.
2014-02-19 14:05:15 +04: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
Sergei Golubchik
dba4e82a84 MDEV-5525 Assertion `status == 0' fails on creating user after granting it role admin option
don't add entries to acl_roles_mappings hash for non-existing grantees.
2014-01-29 11:00:06 +01:00
Sergei Golubchik
416148a4cf MDEV-5526 Assertion `proxied_user->host.length' fails on GRANT PROXY ON <role>
recognize the context better:
always treat the barename as a username in the username context
2014-01-29 00:05:24 +01:00
Sergei Golubchik
5a385146ae MDEV-5523 Server crashes on DROP USER <rolename>
use 'user_name' for the error message (fixed, after get_current_user()),
not the original tmp_user_name, as it comes from the parser (host == NULL).
2014-01-28 21:11:56 +01:00
Sergei Golubchik
03b428d2cd MDEV-5520 Connection lost on wrong CREATE ROLE 2014-01-28 21:01:21 +01:00
Murthy Narkedimilli
c92223e198 Updated/added copyright headers 2014-01-06 10:52:35 +05:30
Murthy Narkedimilli
496abd0814 Updated/added copyright headers 2014-01-06 10:52:35 +05:30
Vicentiu Ciorbaru
ad5ddaff12 Fix for:
MDEV-5221: User auto-creation does not work upon GRANT <role>
2013-12-18 15:39:09 +02:00
Sergei Golubchik
ff485d2dc4 MDEV-5438 A view can mask a table that supports discovery 2013-12-13 14:26:10 +01:00
Sergei Golubchik
cec76b3861 correct old assert in add_role_user_mapping_action to match changed function prototypes.
fix the element deleting logic for roles_mappings_hash
2013-12-09 12:39:31 +01:00
Sergei Golubchik
517b1f4fb4 cleanups:
* comments from WL#5602 in sql_acl.cc
* rename global memroots in sql_acl.cc
* remove the second empty lex string constant
2013-12-09 12:38:30 +01:00
Sergei Golubchik
e252af7b7e reuse new safe_net_field_length_ll function where appropriate 2013-12-09 12:38:09 +01:00
Sergei Golubchik
bec1d903d9 Do the partial merge of WL#5602 correctly:
Remove unused code (that should not have been merged)
  Add protocol extension (that should have been merged)
  Fix bugs (see pack.c)
2013-12-09 12:38:02 +01:00
Sergei Golubchik
5290811c5c MDEV-5367 Server crashes in acl_authenticate on concurrent thread connection, FLUSH PRIVILEGES
fix a copy-paste error, introduced in role refactoring
2013-12-01 12:16:24 +01:00
Sergei Golubchik
09b63917be MDEV-5238 Server crashes in find_role_grant_pair on SHOW GRANTS for an anonymous user 2013-11-10 17:50:52 +01:00
Sergei Golubchik
0150dc6ed9 10.0-base merge 2013-11-04 21:47:54 +01:00
Sergei Golubchik
79d2e6c82f MDEV-5232 SET ROLE checks privileges differently from check_access()
use the same inconsistent priv_user@host pair for SET ROLE privilege checks,
just as check_access() does
2013-11-04 13:37:39 +01:00
Sergei Golubchik
ed4a31e8d5 10.0-base merge 2013-11-02 17:59:16 +01:00
Sergei Golubchik
1f0368658b MDEV-5225 Server crashes on CREATE USER|ROLE CURRENT_ROLE or DROP ROLE CURRENT_ROLE 2013-11-02 16:26:01 +01:00
Sergei Golubchik
0fdb3bcfdb 10.0-base merge (roles) 2013-10-29 15:08:44 +01:00
Sergei Golubchik
fef4166990 Don't allow authentication clauses for roles, in particular:
GRANT ... IDENTIFIED BY [ PASSWORD ] ...
  GRANT ... IDENTIFIED VIA ... [ USING ... ]
  GRANT ... REQUIRE ...
  GRANT ... MAX_xxx ...
  SET PASSWORD FOR ... = ...
2013-10-28 07:46:17 +01:00
Sergei Golubchik
d5c9712225 post-review cleanup 2013-10-27 08:19:21 +01:00
Sergei Golubchik
e46eea8660 remove inherited routine grants when a routine is dropped 2013-10-26 15:52:29 +02:00
Vicențiu Ciorbaru
2eed3b7d07 Implemented REVOKE ALL FROM for Roles and role grants. 2013-10-26 15:38:48 +02:00
Sergei Golubchik
65eee0be5f MDEV-5176 Server crashes in fill_schema_applicable_roles on select from APPLICABLE_ROLES after a suicide
Don't assume that thd->security_ctx->priv_user is an actually existing user account
2013-10-23 09:54:10 -07:00
Sergei Golubchik
7761a278f6 MDEV-5170 Assertion `(&(&acl_cache->lock)->m_mutex)->count > 0 && pthread_equal(pthread_self(), (&(&acl_cache->lock)->m_mutex)->thread)' fails after restarting server with a pre-created role grants
lock acl_cache->lock mutex for the duration of acl_load
2013-10-23 09:49:47 -07:00
Sergei Golubchik
f6b8f6d156 reset the db privilege cache when revoking db priviges on DROP ROLE 2013-10-23 05:09:17 -07:00
Sergei Golubchik
614478921f MDEV-5172 safe_mutex: Trying to lock mutex when the mutex was already locked on using a role and I_S role tables
don't forget to unlock if the current role isn't found
2013-10-23 03:28:41 -07:00
Sergei Golubchik
fd826cc3bd properly propagate privilege changes on DROP ROLE 2013-10-23 03:26:09 -07:00
Sergei Golubchik
82037f9c0e don't rebuild all parent_grantees/role_grants arrays when a role is dropped,
only remove this role from the arrays where it is present.
2013-10-23 03:25:24 -07:00
Sergei Golubchik
779693f409 fixes for builbot 1 2013-10-20 16:39:51 -07:00
Sergei Golubchik
c1c0a83772 ACL_USER methods for comparing ACL_USER objects 2013-10-20 08:51:49 +02:00
Sergei Golubchik
ce68878947 fixes for embedded 2013-10-18 18:56:28 -07:00
Sergei Golubchik
cb9d3bec46 post-review changes 2013-10-18 15:54:41 -07:00
Sergei Golubchik
40c43c395b remove old incorrect bugfix that moved reading of procs_priv table into a separate function.
FLUSH PRIVILEGES no longer returns an error, when it was successful.
LOCK_grant is no longed unlocked/relocked between tables_priv and procs_priv
2013-10-18 15:52:33 -07:00
Sergei Golubchik
f74b9eca6e remove ER_RESERVED_ROLE.
Only allow NONE instead of a role name in SET ROLE.
Don't allow PUBLIC as a role name anywhere (to be fixed later)
Fix db_access calculations on SET ROLE
Reduce the size of role_grants and parent_grantee per-user/role arrays.
Fix the wording and specify the correct sqlstate for ER_INVALID_ROLE
2013-10-18 15:52:26 -07:00
Sergei Golubchik
4ec26a7c2d replication of GRANT role statement 2013-10-18 13:18:03 -07:00
Sergei Golubchik
4d3e4c2984 make functions static, remove unused constructors, other small cleanups 2013-10-18 13:17:42 -07:00
Sergei Golubchik
d2c683527f recursive privilege propagation for roles.
functions for traversing the role graph in either direction.
merging of global, database, table, column, routine privileges.
debug status variables for counting number of privilege merges.
tests.
2013-10-18 13:06:41 -07:00
Sergei Golubchik
b221ec6529 enforce privileges for GRANT role 2013-10-18 12:34:59 -07:00
Sergei Golubchik
2f2699f97b cleanup.
mainly to avoid the pattern of
* get username/hostname/rolename
* optionally find the corresponding ACL_USER and ACL_ROLE
* allocate memory, concatenate username/hostname/rolename
* call a function passing only this memory as an argument
** use concatenated username/etc to find ACL_USER and ACL_ROLE again
** do something
* free the object

Also to undo push_dynamic we use pop_dynamic now,
not a linear search/scan through the dynamic array.

as a bonus, role@ is now an invalid way to refer to a role.
2013-10-18 12:34:44 -07:00
Sergei Golubchik
f1a71b6815 bugfix: missing restore_record when modifying roles_mapping() table.
(and an assert in myisam to catch these bugs easier in the future)
update tests/results
2013-10-18 12:27:07 -07:00
Sergei Golubchik
e5211e0cde information_schema.applicable_roles.is_grantable column 2013-10-18 12:26:43 -07:00
Sergei Golubchik
67985b283a require SUPER to specify an arbitrary admin 2013-10-18 12:26:29 -07:00
Sergei Golubchik
7fb978c793 auto-grant a role to its admin on CREATE ROLE 2013-10-18 12:26:05 -07:00
Sergei Golubchik
46622dbea2 load with_admin flag from the mysql.roles_mapping table 2013-10-18 12:25:52 -07:00
Sergei Golubchik
9d6e9c242e store ADMIN OPTION in the roles_mapping hash and table 2013-10-18 12:25:39 -07:00
Sergei Golubchik
66f0c2e308 small cleanup 2013-10-18 12:25:23 -07:00
Sergei Golubchik
c28bf2a344 bugfix: propagate grant changes through the role graph after table/column/routine grants 2013-10-18 12:21:37 -07:00
Sergei Golubchik
d0db4f2261 add Admin_option column to mysql.roles_mapping. update tests/results 2013-10-18 12:21:10 -07:00
Sergei Golubchik
7dda698734 rename columns in mysql.roles_mapping to be consistent with other privilege tables 2013-10-18 12:19:37 -07:00
Sergei Golubchik
b2f16628cf support DEFINER=role and DEFINER=current_role 2013-10-18 12:17:49 -07:00
Sergei Golubchik
b054700619 speed up fill_effective_table_privileges() - avoid calling expensive acl_get() 2013-10-18 11:46:43 -07:00
Sergei Golubchik
02a7291954 cleanup
sql/sp.cc:
  don't split "user@host" string in db_load_routine, because the caller needs to
  generate it from user and host. instead pass user and host directly into db_load_routine
sql/sql_parse.cc:
  1. REVOKE ALL doesn't need invoker.
  2. make sp_process_definer() reusable
sql/sql_trigger.cc:
  don't duplicate the code from sp_process_definer(), reuse it
sql/sql_view.cc:
  don't duplicate the code from sp_process_definer(), reuse it
2013-10-18 11:46:30 -07:00
Sergei Golubchik
ac6877d420 SET PASSWORD bugfixes:
* work as documented, use CURRENT_USER()
* move the check for ER_PASSWORD_ANONYMOUS_USER where it can actually work
2013-10-18 11:41:40 -07:00
Sergei Golubchik
4cc8cda346 Remove the very old historical but never documented behavior,
than an empty host '' is the same as any-host wildcard '%'.

Replace '' with '%' in the parser (for GRANT ... foo@'') and when loading grant tables.

Side effect: one cannot have foo@'' and foo@'%' both at the same time
(but one can have foo@'%' and foo@'%%')
2013-10-18 11:38:13 -07:00
Vicențiu Ciorbaru
5630967dd5 Fixed GRANT ROLE TO ROLE not updating acl_roles_mappings hash.
Also fixed possible memory exploit by repeteadly calling:
GRANT role to user; where role was already granted to user.
2013-10-18 09:26:02 -07:00
Vicențiu Ciorbaru
a34dff8825 Removed redundant code in update_acl_user. User related functions
should deal with users, while role related functions should deal
with roles.
2013-10-18 09:25:53 -07:00
Vicențiu Ciorbaru
60f19cbc9a Added GRANT ROLE TO ... and REVOKE ROLE FROM ... functionality.
TODO:

Privilege checks are not done upon executing the command.
2013-10-18 09:25:42 -07:00
Vicențiu Ciorbaru
df48f63684 Fixed rolenames case insensitivity bug. Also cleared compiler warning.
Fixed segmentation fault caused in traverse_role_graph by previous commit
2013-10-18 09:20:59 -07:00
Vicențiu Ciorbaru
507c4be955 Fixed bug that caused the ROLE_VISITED flag to remain set if the exploration
was halted on a cycle detect. Now the to_clear array is populated during
the open event and not the close event.
2013-10-18 09:19:53 -07:00
Sergei Golubchik
fe2d265704 INFORMATION_SCHEMA.APPLICABLE_ROLES table 2013-10-18 09:15:55 -07:00
Sergei Golubchik
7f0965f490 information_schema.enabled_roles table 2013-10-18 09:15:46 -07:00
Sergei Golubchik
353576f3d3 GRANT/REVOKE should specify role name as 'role' not as 'role'@'%' 2013-10-18 09:08:42 -07:00
Sergei Golubchik
06e16b8c97 cannot use lex->grant_user= &current_user, where LEX_USER current_user is a global constant,
because parser might modify the lex->user (e.g. set lex->user-password).
switch to use LEX_STRING current_user string, and also change other similar constants
to be LEX_STRING's for consistency.
2013-10-18 08:17:56 -07:00
Sergei Golubchik
72d8b533cc Fixes for mysql-test failures
mysql-test/r/acl_roles_show_grants.result:
  one can do SHOW GRANTS for himself
mysql-test/t/acl_roles_set_role-table-column-priv.test:
  correct error message
mysql-test/t/acl_roles_show_grants.test:
  one can SHOW GRANTS for himself
sql/sql_acl.cc:
  bugfixing:
  * don't assign with && - it can shortcut and the second assignment won't be executed
  * correct the test in check_grant_all_columns() - want_access should not be modified
  *
sql/sql_cmd.h.OTHER:
  add new commands at the end
sql/sql_db.cc:
  don't call acl_get() if all privileges are already satisfied
  (crashes when run with --skip-grants, because acl data stuctures aren't initialized)
sql/sql_parse.cc:
  * test for current_user in get_current_user()
  * map explicitly specified user@host to current_user
2013-10-18 08:10:51 -07:00
Vicențiu Ciorbaru
1ac0b920d5 Added GRANT ROLE TO ROLE | USER functionality.
The command only currenty affects in memory data structures. Writing to
the roles_mapping table needs to be implemented.
2013-10-18 06:49:53 -07:00
Vicențiu Ciorbaru
95ef78e432 SET ROLE now works recursively for routines.
The warnings present in the set_role_routine-simple testcase will
be removed when reworking the grant privilege to call.
2013-10-18 06:49:38 -07:00
Vicențiu Ciorbaru
bbc2771d24 SET ROLE now works recursively for table and column level privileges 2013-10-18 06:47:49 -07:00
Vicențiu Ciorbaru
1aedd4a585 Removed init_hash_columns hash and instead added an init_rights field
to the hash_columns' original elements (GRANT_COLUMN)
2013-10-18 06:45:36 -07:00
Vicențiu Ciorbaru
6f9d26f09f Show grants now correctly prints procedure privileges. 2013-10-18 06:42:59 -07:00
Vicențiu Ciorbaru
d83bbc1ffc Initialize init_access fields for all privilege data structures. 2013-10-18 06:42:03 -07:00
Vicențiu Ciorbaru
4a58599930 Implemented SHOW GRANTS functionality 2013-10-18 06:40:25 -07:00
Vicențiu Ciorbaru
d24ead2c6f Various bug fixes.
Also updated tests to reflect new show grants functionality.
2013-10-18 06:34:27 -07:00
Vicențiu Ciorbaru
8c7ca88a6c Added comment for database privilege checks. 2013-10-18 06:34:18 -07:00
Vicențiu Ciorbaru
f2ab661999 Added SHOW GRANTS recursive role print.
The output is not completely correct due to recursive role grants not
being completly implemented. However, this will help with testing the
implementation of set role with recursive grants.
2013-10-18 06:34:07 -07:00
Vicențiu Ciorbaru
3436691899 Refactored get_role_access into a generic traverse function.
The function now performs a DEPTH FIRST SEARCH on the role graph.

At various key points: on_start, on_open, on_cycle, on_finish,
the function calls one of the corresponding functions passed as parameters.
2013-10-18 06:22:17 -07:00
Vicențiu Ciorbaru
1bfc610dc7 Added show role grants functionality to the mysql_show_grants function. 2013-10-18 06:17:47 -07:00
Vicențiu Ciorbaru
0fea3316dd Refactored mysql_show_grants table and column privilege print into a separate
function.

The function will be used to help print roles privileges recursively.
2013-10-18 06:17:19 -07:00
Vicențiu Ciorbaru
d611407529 Refactored mysql_show_grants database privilege print into a separate
function.

The function will be used to help print roles privileges recursively.
2013-10-18 06:15:50 -07:00
Vicențiu Ciorbaru
4a9832680c Refactored mysql_show_grants global privilege print into a separate
function.

The function will be used to help print roles privileges recursively.
2013-10-18 06:09:30 -07:00
Vicențiu Ciorbaru
daf0345a7b Added recursive database roles privilege propagation.
The privileges are not correctly updated via grant commands yet.
2013-10-18 06:00:48 -07:00
Vicențiu Ciorbaru
766ae81aa4 Fixed bug that caused rename user test case to fail.
The bug was caused by not renaming the role if it was previously
modified by the handle_grant_struct(ROLE_ACL,...) call.

The same function used find_acl_role and would search for the already
renamed role when it handled ROLES_MAPPINGS_HASH. This caused it to not rename
the role/user correctly.
2013-10-18 05:41:52 -07:00
Vicențiu Ciorbaru
1fe9272479 Removed no longer used error message. 2013-10-18 05:41:43 -07:00
Vicențiu Ciorbaru
3fa2cb2126 Updated error message in case the user table's format is not up to date and can
not support roles
2013-10-18 05:41:34 -07:00
Vicențiu Ciorbaru
ce4851c3d0 Reworked the implementation of create role and drop role.
Also fixed issue with drop role not clearing internal memory entry
for that role. The issue was due to a condition introduced in handle_grant_data

Updated testsuite to also check the possible error conditions.
2013-10-18 05:41:25 -07:00
Vicențiu Ciorbaru
db850c525f Added CREATE ROLE support as well as DROP ROLE support. 2013-10-18 05:41:13 -07:00
Vicențiu Ciorbaru
81b2856e10 Refactored yacc grammar to make use of named constants. 2013-10-18 05:16:38 -07:00