Commit graph

802 commits

Author SHA1 Message Date
Sven Sandberg
f3985c649d BUG#39934: Slave stops for engine that only support row-based logging
General overview:
The logic for switching to row format when binlog_format=MIXED had
numerous flaws. The underlying problem was the lack of a consistent
architecture.
General purpose of this changeset:
This changeset introduces an architecture for switching to row format
when binlog_format=MIXED. It enforces the architecture where it has
to. It leaves some bugs to be fixed later. It adds extensive tests to
verify that unsafe statements work as expected and that appropriate
errors are produced by problems with the selection of binlog format.
It was not practical to split this into smaller pieces of work.

Problem 1:
To determine the logging mode, the code has to take several parameters
into account (namely: (1) the value of binlog_format; (2) the
capabilities of the engines; (3) the type of the current statement:
normal, unsafe, or row injection). These parameters may conflict in
several ways, namely:
 - binlog_format=STATEMENT for a row injection
 - binlog_format=STATEMENT for an unsafe statement
 - binlog_format=STATEMENT for an engine only supporting row logging
 - binlog_format=ROW for an engine only supporting statement logging
 - statement is unsafe and engine does not support row logging
 - row injection in a table that does not support statement logging
 - statement modifies one table that does not support row logging and
   one that does not support statement logging
Several of these conflicts were not detected, or were detected with
an inappropriate error message. The problem of BUG#39934 was that no
appropriate error message was written for the case when an engine
only supporting row logging executed a row injection with
binlog_format=ROW. However, all above cases must be handled.
Fix 1:
Introduce new error codes (sql/share/errmsg.txt). Ensure that all
conditions are detected and handled in decide_logging_format()

Problem 2:
The binlog format shall be determined once per statement, in
decide_logging_format(). It shall not be changed before or after that.
Before decide_logging_format() is called, all information necessary to
determine the logging format must be available. This principle ensures
that all unsafe statements are handled in a consistent way.
However, this principle is not followed:
thd->set_current_stmt_binlog_row_based_if_mixed() is called in several
places, including from code executing UPDATE..LIMIT,
INSERT..SELECT..LIMIT, DELETE..LIMIT, INSERT DELAYED, and
SET @@binlog_format. After Problem 1 was fixed, that caused
inconsistencies where these unsafe statements would not print the
appropriate warnings or errors for some of the conflicts.
Fix 2:
Remove calls to THD::set_current_stmt_binlog_row_based_if_mixed() from
code executed after decide_logging_format(). Compensate by calling the
set_current_stmt_unsafe() at parse time. This way, all unsafe statements
are detected by decide_logging_format().

Problem 3:
INSERT DELAYED is not unsafe: it is logged in statement format even if
binlog_format=MIXED, and no warning is printed even if
binlog_format=STATEMENT. This is BUG#45825.
Fix 3:
Made INSERT DELAYED set itself to unsafe at parse time. This allows
decide_logging_format() to detect that a warning should be printed or
the binlog_format changed.

Problem 4:
LIMIT clause were not marked as unsafe when executed inside stored
functions/triggers/views/prepared statements. This is
BUG#45785.
Fix 4:
Make statements containing the LIMIT clause marked as unsafe at
parse time, instead of at execution time. This allows propagating
unsafe-ness to the view.
2009-07-14 21:31:19 +02:00
Davi Arnaut
1ad8016974 Bug#45100: Incomplete DROP USER in case of SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH'
The SQL-mode PAD_CHAR_TO_FULL_LENGTH could prevent a DROP USER
statement from privileges associated with the user being dropped.
What ocurred was that reading from the User and Host fields of
the tables tables_priv or columns_priv would yield values padded
with spaces, causing a failure to match a specified user or host 
('user' != 'user     ');

The solution is to disregard the PAD_CHAR_TO_FULL_LENGTH mode
when iterating over and matching values in the privileges tables
for a DROP USER statement.
2009-06-12 18:11:19 -03:00
Sergey Glukhov
9379a4e0c0 5.0-bugteam->5.1-bugteam merge 2009-06-04 10:54:23 +05:00
Sergey Glukhov
1a1ffe7312 Bug#44798 MySQL engine crashes when creating stored procedures with execute_priv=N
The crash happens because of uninitialized
lex->ssl_cipher, lex->x509_subject, lex->x509_issuer variables.
The fix is to add initialization of these variables for
stored procedures&functions.
2009-06-04 10:28:45 +05:00
He Zhenxing
0793eec018 BUG#41948 Query_log_event constructor needlessly contorted
Make the caller of Query_log_event, Execute_load_log_event
constructors and THD::binlog_query to provide the error code
instead of having the constructors to figure out the error code.
2009-05-30 21:32:28 +08:00
Kristofer Pettersson
dc4feaa4cb Automerge 2009-05-29 16:25:22 +02:00
Kristofer Pettersson
a645555432 Bug#44658 Create procedure makes server crash when user does not have ALL privilege
MySQL crashes if a user without proper privileges attempts to create a procedure.

The crash happens because more than one error state is pushed onto the Diagnostic
area. In this particular case the user is denied to implicitly create a new user
account with the implicitly granted privileges ALTER- and EXECUTE ROUTINE.

The new account is needed if the original user account contained a host mask.
A user account with a host mask is a distinct user account in this context.
An alternative would be to first get the most permissive user account which
include the current user connection and then assign privileges to that
account. This behavior change is considered out of scope for this bug patch.

The implicit assignment of privileges when a user creates a stored routine is a
considered to be a feature for user convenience and as such it is not
a critical operation. Any failure to complete this operation is thus considered
non-fatal (an error becomes a warning).

The patch back ports a stack implementation of the internal error handler interface.
This enables the use of multiple error handlers so that it is possible to intercept
and cancel errors thrown by lower layers. This is needed as a error handler already
is used in the call stack emitting the errors which needs to be converted.
2009-05-29 15:37:54 +02:00
Davi Arnaut
981ff94d80 Bug#42158: leak: SSL_get_peer_certificate() doesn't have matching X509_free()
The problem is that the server failed to follow the rule that
every X509 object retrieved using SSL_get_peer_certificate()
must be explicitly freed by X509_free(). This caused a memory
leak for builds linked against OpenSSL where the X509 object
is reference counted -- improper counting will prevent the
object from being destroyed once the session containing the
peer certificate is freed.

The solution is to explicitly free every X509 object used.
2009-05-25 10:00:18 -03:00
He Zhenxing
435d6631aa Manually merge BUG#37145 to 5.1-bugteam 2009-04-09 07:42:51 +08:00
He Zhenxing
9530126822 BUG#37145 Killing a statement doing DDL may log binlog event with error code 1053
When the thread executing a DDL was killed after finished its
execution but before writing the binlog event, the error code in
the binlog event could be set wrongly to ER_SERVER_SHUTDOWN or
ER_QUERY_INTERRUPTED.

This patch fixed the problem by ignoring the kill status when
constructing the event for DDL statements.

This patch also included the following changes in order to
provide the test case.

 1) modified mysqltest to support variable for connection command

 2) modified mysql-test-run.pl, add new variable MYSQL_SLAVE to
    run mysql client against the slave mysqld.
2009-03-27 13:19:50 +08:00
Ignacio Galarza
e82390130e auto-merge 2009-03-19 09:44:58 -04:00
Georgi Kodinov
b337ac28d0 Bug #41354: Access control is bypassed when all columns
of a view are selected by * wildcard

Backported a part of the fix for 36086 to 5.0
2009-02-26 19:00:44 +02:00
Ignacio Galarza
2b85c64d65 Bug#29125 Windows Server X64: so many compiler warnings
- Remove bothersome warning messages.  This change focuses on the warnings 
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
2009-02-10 17:47:54 -05:00
Sergey Glukhov
cc62fda2d9 5.0-bugteam->5.1-bugteam merge 2008-12-24 18:47:24 +04:00
Sergey Glukhov
4e8fae9ec2 compiler warning fix 2008-12-24 18:45:47 +04:00
Sergey Glukhov
d02d2143b5 5.0-bugteam->5.1-bugteam merge 2008-12-23 19:06:42 +04:00
Sergey Glukhov
b5f005f65a Bug#41079 information_schema.schema_privileges is limited to 7680 records.
The problem is that we cannot insert new record into memory table
when table size exceeds max memory table size.
The fix is to use schema_table_store_record() function which
converts memory table into MyISAM in case of table size exceeding.

Note:
There is no test case for this bug, the reason is that
1. The code  that was added already is checked(i.e. works) with existing tests
2. Correct work of schema_table_store_record() is checked with other test cases
   (information_schema tests)
So new code is fully covered with existing test cases.
2008-12-23 18:56:08 +04:00
Martin Hansson
a43242ea6d Bug#36086: SELECT * from views don't check column grants
This patch also fixes bugs 36963 and 35600.
                      
- In many places a view was confused with an anonymous derived
  table, i.e. access checking was skipped. Fixed by introducing a
  predicate to tell the difference between named and anonymous
  derived tables.
                      
- When inserting fields for "SELECT * ", there was no 
  distinction between base tables and views, where one should be
  made. View privileges are checked elsewhere.
2008-09-03 16:45:40 +02:00
Kristofer Pettersson
6b2bd29ac8 Manual merge 5.0->5.1 2008-08-06 16:20:41 +02:00
Kristofer Pettersson
d298e107f7 Bug#37781 mysql_drop_user calls get_current_user() twice for no reason
Fixed typo and removed duplicate call to get_current_user.
2008-07-29 15:37:09 +02:00
Sergey Petrunia
eb8d8d3e3a Merge fix for BUG#35478 into 5.1 2008-07-15 21:46:02 +04:00
Sergey Petrunia
2951f00be4 BUG#35478: sort_union() returns bad data when sort_buffer_size is hit
- In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique,
  tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted
  and b) it might be that the the data is used by filesort(), which will need record rowids
  (which rr_from_cache() cannot provide).
- Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next(). This fixes BUG#35477.
(bk trigger: file as fix for BUG#35478).
2008-07-15 18:13:21 +04:00
thek@adventure.(none)
38effd5603 Merge error between two patches caused error out-of-bounds assignment. 2008-04-08 15:57:44 +02:00
anozdrin/alik@quad.opbmk
83b5f82e3f Merge quad.opbmk:/mnt/raid/alik/MySQL/devel/5.1
into  quad.opbmk:/mnt/raid/alik/MySQL/devel/5.1-rt-merged
2008-03-28 14:40:11 +03:00
gkodinov/kgeorge@magare.gmz
fb931bad54 Merge bk-internal:/home/bk/mysql-5.0
into  magare.gmz:/home/kgeorge/mysql/work/merge-5.0-bugteam
2008-03-28 11:26:40 +02:00
tnurnberg@white.intern.koehntopp.de
a3df2a4cf4 Merge mysql.com:/misc/mysql/mysql-5.1
into  mysql.com:/misc/mysql/mysql-5.1-opt
2008-03-27 23:34:12 +01:00
davi@endora.local
c0aff004b9 Merge mysql.com:/Users/davi/mysql/mysql-5.1-bug33201
into  mysql.com:/Users/davi/mysql/mysql-5.0-bugteam
2008-03-27 09:13:51 -03:00
gshchepa/uchum@host.loc
810059404e Merge host.loc:/home/uchum/work/mysql-5.1
into  host.loc:/home/uchum/work/5.1-opt
2008-03-27 15:54:45 +04:00
tsmith@rhel5-ia64-a.mysql.com
3069db1da7 Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1
into  rhel5-ia64-a.mysql.com:/data0/tsmith/build/51
2008-03-27 08:20:25 +01:00
thek@adventure.(none)
e569b16756 Merge adventure.(none):/home/thek/Development/cpp/bug33275/my51-bug33275
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime
2008-03-26 14:20:12 +01:00
thek@adventure.(none)
c87a6342da Merge adventure.(none):/home/thek/Development/cpp/bug33275/my50-bug33275
into  adventure.(none):/home/thek/Development/cpp/bug33275/my51-bug33275
2008-03-26 11:07:10 +01:00
thek@adventure.(none)
eb5cdca66f Bug#33275 Server crash when creating temporary table mysql.user
When creating a temporary table that uses the same name as the mysql
privs table the server would crash on FLUSH PRIVILEGES.

This patches corrects the problem by setting a flag to ignore any
temporary table when trying to reload the privileges.
2008-03-25 12:52:55 +01:00
gkodinov/kgeorge@magare.gmz
f6871c0d66 Merge magare.gmz:/home/kgeorge/mysql/autopush/B26461-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/work/B26461-5.1-opt
2008-03-21 17:48:28 +02:00
gkodinov/kgeorge@macbook.gmz
ff0aac178d Bug #26461: Intrinsic data type bool (1 byte) redefined to BOOL (4 bytes)
The bool data type was redefined to BOOL (4 bytes on windows).
Removed the #define and fixed some of the warnings that were uncovered
by this.
Note that the fix also disables 2 warnings :
4800 : 'type' : forcing value to bool 'true' or 'false' (performance warning)
4805: 'operation' : unsafe mix of type 'type' and type 'type' in operation

These warnings will be handled in a separate bug, as they are performance related or bogus.

Fixed to int the return type of functions that return more than 
2 distinct values.
2008-03-21 17:23:17 +02:00
thek@adventure.(none)
da813ebbee Merge kpettersson@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime
2008-03-18 13:31:10 +01:00
thek@adventure.(none)
cee1b1fd99 Bug#25175 Too much memory used by MySQL grant system
Each time the server reloads privileges containing table grants, the 
system will allocate too much memory than needed because of badly
chosen growth prediction in the underlying dynamic arrays.

This patch introduces a new signature to the hash container initializer
which enables a much more pessimistic approach in favour for more
efficient memory useage.

This patch was supplied by Google Inc.
2008-03-18 10:45:36 +01:00
joerg@trift2.
e784898959 Merge trift2.:/MySQL/M51/mysql-5.1
into  trift2.:/MySQL/M51/push-5.1
2008-03-14 14:41:08 +01:00
kaa@kaamos.(none)
0a7052e4d3 Merge kaamos.(none):/data/src/mysql-5.1
into  kaamos.(none):/data/src/opt/mysql-5.1-opt
2008-03-12 11:19:46 +03:00
cmiller@zippy.cornsilk.net
ed9361df27 Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug#33464/my51-bug#33464
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-build
2008-03-05 09:42:16 -05:00
cmiller@zippy.cornsilk.net
6217dd728a Bug#33464: DROP FUNCTION caused a crash
The cause of the crash is an assertion failure that we do not emit 
an error message (grant not found) and then return "ok".  The 
assertion is valid, and we were ignoring the buggy behavior prior 
to the "Diagnostics" result-verification.

Use an error handler to mutate innocuous missing-grant errors, when 
removing routines, into warnings.
2008-03-05 09:33:32 -05:00
tnurnberg@white.intern.koehntopp.de
468c8ebde7 Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into  mysql.com:/misc/mysql/99999/51-99999
2008-02-24 14:23:28 +01:00
tnurnberg@mysql.com/white.intern.koehntopp.de
60fc91570b Bug#32753: PAD_CHAR_TO_FULL_LENGTH is not documented and interferes with grant tables
SQL-mode PAD_CHAR_TO_FULL_LENGTH affected mysqld's user-table too. If
enabled, user-name and host were space-padded and no longer matched
the login-data of incoming connexions.

Patch disregards pad-flag while loading privileges so ability to log
in does not depend on SQL-mode.
2008-02-24 13:58:07 +01:00
kostja@dipika.(none)
72495c968b Rename send_eof() to my_eof() for consistency with my_ok() and my_error() 2008-02-19 15:58:08 +03:00
kostja@dipika.(none)
f106d9738a Rename send_ok to my_ok. Similarly to my_error, it only records the status,
does not send it to the client.
2008-02-19 15:45:21 +03:00
kaa@kaamos.(none)
5647dee192 Merge kaamos.(none):/data/src/mysql-5.1
into  kaamos.(none):/data/src/opt/mysql-5.1-opt
2008-02-17 14:57:01 +03:00
kaa@kaamos.(none)
3daeb40f1f Merge kaamos.(none):/data/src/mysql-5.0
into  kaamos.(none):/data/src/opt/mysql-5.0-opt
2008-02-17 14:37:39 +03:00
gshchepa/uchum@host.loc
e64b879510 Merge host.loc:/home/uchum/work/5.0-opt-gca
into  host.loc:/home/uchum/work/5.1-opt-gca
2008-02-13 19:37:05 +04:00
gshchepa/uchum@host.loc
18770a0de8 Fixed bug#31194: Privilege ordering does not order properly
for wildcard values.
The server ignored escape character before wildcards during
the calculation of priority values for sorting of a privilege
list. (Actually the server counted an escape character as an
ordinary wildcard like % or _). I.e. the table name template
with a wildcard character like 'tbl_1' had higher priority in
a privilege list than concrete table name without wildcards
like 'tbl\_1', and some privileges of 'tbl\_1' was hidden
by privileges for 'tbl_1'.

The get_sort function has been modified to ignore escaped
wildcards as usual.
2008-02-13 19:34:12 +04:00
kostja@dipika.(none)
e9c887cc3d Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  dipika.(none):/opt/local/work/mysql-5.1-runtime
2008-02-08 18:55:07 +03:00
thek@adventure.(none)
83428ce932 Merge kpettersson@bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime
2008-02-01 17:00:54 +01:00