Commit graph

25778 commits

Author SHA1 Message Date
Alexey Botchkov
dfd8880de8 merging 2009-09-29 17:49:36 +05:00
Davi Arnaut
8d3d35ea57 Bug#45567: Fast ALTER TABLE broken for enum and set
The problem was that appending values to the end of an existing
ENUM or SET column was being treated as table data modification,
preventing a immediately (fast) table alteration that occurs when
only table metadata is being modified.

The cause was twofold: adding a enumeration or set members to the 
end of the list of valid member values was not being considered
a "compatible" table alteration, and for SET columns, the check
was being done upon the max display length and not the underlying
(pack) length of the field.

The solution is to augment the function that checks wether two ENUM
or SET fields are compatible -- by comparing the pack lengths and
performing a limited comparison of the member values.

mysql-test/r/alter_table.result:
  Add test case result for Bug#45567
mysql-test/t/alter_table.test:
  Add test case for Bug#45567
sql/field.cc:
  Check whether two fields can be considered 'equal' for table
  alteration purposes. Fields are equal if they retain the same
  pack length and if new members are added to the end of the list.
sql/field.h:
  Add comment and remove method.
2009-09-29 07:58:42 -03:00
Mattias Jonsson
1d1a293b26 merge 2009-09-29 10:12:04 +02:00
Sergey Glukhov
5f8bb5c507 Bug#47150 Assertion in Field_long::val_int() on MERGE + TRIGGER + multi-table UPDATE
The bug is not related to MERGE table or TRIGGER. More correct description
would be 'assertion on multi-table UPDATE + NATURAL JOIN + MERGEABLE VIEW'.
On PREPARE stage(see test case) we call mark_common_columns() func which
creates ON condition for NATURAL JOIN and sets appropriate
table read_set bitmaps for fields which are used in ON condition.
On EXECUTE stage mark_common_columns() is not called, we set
necessary read_set bitmaps in setup_conds(). But 'B.f1' field
is already processed and related item alredy fixed before
setup_conds() as updated field and setup_conds can not set
read_set bitmap because of that.
The fix is to set read_set bitmap for appropriate table field even
if Item_direct_view_ref item which represents a refernce to this field
is fixed.



mysql-test/r/join.result:
  test result
mysql-test/t/join.test:
  test case
sql/item.cc:
  The bug is not related to MERGE table or TRIGGER. More correct description
  would be 'assertion on multi-table UPDATE + NATURAL JOIN + MERGEABLE VIEW'.
  On PREPARE stage(see test case) we call mark_common_columns() func which
  creates ON condition for NATURAL JOIN and sets appropriate
  table read_set bitmaps for fields which are used in ON condition.
  On EXECUTE stage mark_common_columns() is not called, we set
  necessary read_set bitmaps in setup_conds(). But 'B.f1' field
  is already processed and related item alredy fixed before
  setup_conds() as updated field and setup_conds can not set
  read_set bitmap because of that.
  The fix is to set read_set bitmap for appropriate table field even
  if Item_direct_view_ref item which represents a refernce to this field
  is fixed.
2009-09-29 07:23:38 +05:00
Georgi Kodinov
7aece82ceb merge 2009-09-28 16:48:40 +03:00
Tatiana A. Nurnberg
4102363f37 Bug#43746: YACC return wrong query string when parse 'load data infile' sql statement
"load data" statements were written to the binlog as a mix of the original statement
and bits recreated from parse-info. This relied on implementation details and broke
with IGNORE_SPACES and versioned comments.

We now completely resynthesize the query for LOAD DATA for binlog (which among other
things normalizes them somewhat with regard to case, spaces, etc.).
We have already parsed the query properly, so we make use of that rather
than mix-and-match string literals and parsed items.
This should make us safe with regard to versioned comments, even those
spanning multiple tokens. Also no longer affected by IGNORE_SPACES.

mysql-test/r/mysqlbinlog.result:
  LOAD DATA INFILE normalized
mysql-test/suite/binlog/r/binlog_killed_simulate.result:
  LOAD DATA INFILE normalized
mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  LOAD DATA INFILE normalized
mysql-test/suite/binlog/r/binlog_stm_blackhole.result:
  LOAD DATA INFILE normalized
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  LOAD DATA INFILE normalized
mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result:
  LOAD DATA INFILE normalized
mysql-test/suite/rpl/r/rpl_loaddata.result:
  LOAD DATA INFILE normalized
mysql-test/suite/rpl/r/rpl_loaddata_fatal.result:
  LOAD DATA INFILE normalized; offsets adjusted to reflect that
mysql-test/suite/rpl/r/rpl_loaddata_map.result:
  LOAD DATA INFILE normalized
mysql-test/suite/rpl/r/rpl_loaddatalocal.result:
  test for #43746 - trying to break LOAD DATA part of parser
mysql-test/suite/rpl/r/rpl_stm_log.result:
  LOAD DATA INFILE normalized
mysql-test/suite/rpl/t/rpl_loaddatalocal.test:
  try to break the LOAD DATA part of the parser (test for #43746)
mysql-test/t/mysqlbinlog.test:
  LOAD DATA INFILE normalized; adjust offsets to reflect that
sql/log_event.cc:
  clean up Load_log_event::print_query and friends so they don't print
  excess spaces. add support for printing charset names to print_query.
sql/log_event.h:
  We already have three places where we synthesize LOAD DATA queries.
  Better use one of those!
sql/sql_lex.h:
  When binlogging LOAD DATA statements, we make up the statement to
  be logged (from the parse-info, rather than substrings of the
  original query) now. Consequently, we no longer need (string-)
  pointers into the original query.
sql/sql_load.cc:
  Completely rewrote write_execute_load_query_log_event() to synthesize the
  LOAD DATA statement wholesale, rather than piece it together from
  synthesized bits and literal excerpts from the original query. This
  will not only give us a nice, normalized statement (all uppercase,
  no excess spaces, etc.), it will also handle comments, including
  versioned comments right, which is certainly more than we can say
  about the previous incarnation.
sql/sql_yacc.yy:
  We're no longer assembling LOAD DATA statements from bodyparts of the
  original query, so some bookkeeping in the parser can go.
2009-09-28 05:41:10 -07:00
Martin Hansson
e86f08d054 Bug#35996: SELECT + SHOW VIEW should be enough to display
view definition

During SHOW CREATE VIEW there is no reason to 'anonymize'
errors that name objects that a user does not have access
to. Moreover it was inconsistently implemented. For example
base tables being referenced from a view appear to be ok,
but not views. The manual on the other hand is clear: If a
user has the privileges SELECT and SHOW VIEW, the view
definition is available to that user, period. The fix
changes the behavior to support the manual.


mysql-test/r/information_schema_db.result:
  Bug#35996: Changed warnings.
mysql-test/r/view_grant.result:
  Bug#35996: Changed warnings, test result.
mysql-test/t/information_schema_db.test:
  Bug#35996: Changed test case to reflect new behavior.
mysql-test/t/view_grant.test:
  Bug#35996: Test case.
sql/sql_acl.cc:
  Bug#35996: Code no longer necessary, we may as well exempt 
  SHOW CREATE VIEW from this check.
sql/sql_show.cc:
  Bug#35996: The fix: An Internal_error_handler that hides
  most errors raised by access checking as they are not
  relevant to SHOW CREATE VIEW.
sql/table.cc:
  Bug#35996: Restricting this hack to act only when there is 
  no Internal_error_handler.
2009-09-28 13:25:47 +02:00
Martin Hansson
2dbe095c3a Bug#46958: Assertion in Diagnostics_area::set_ok_status,
trigger, merge table
            
The problem with break statements is that they have very
local effects. Hence a break statement within the inner loop
of a nested-loops join caused execution to proceed to the
next table even though a serious error occurred. The problem
was fixed by breaking out the inner loop into its own
method. The change empowers all errors to terminate the
execution.
            
The errors that will now halt multi-DELETE execution
altogether are 
  - triggers returning errors
  - handler errors
  - server being killed


mysql-test/r/delete.result:
  Bug#46958: Test result.
mysql-test/t/delete.test:
  Bug#46958: Test case.
sql/sql_class.h:
  Bug#46958: New method declaration.
sql/sql_delete.cc:
  Bug#46958: New method implementation.
2009-09-28 12:48:52 +02:00
unknown
c6186a2500 BUG #46572 DROP TEMPORARY table IF EXISTS does not have a consistent behavior in ROW mode
In RBR, 'DROP TEMPORARY TABLE IF EXISTS...' statement is binlogged when the table
does not exist.
      
In fact, 'DROP TEMPORARY TABLE ...' statement should never be binlogged in RBR
no matter if the table exists or not. 
This patch addresses this by checking whether we are dropping a
temporary table or not, when building the custom drop statement.
2009-09-28 10:23:06 +08:00
Luis Soares
3d211f3981 BUG#47312: RBR: Disabling key on slave breaks replication:
HA_ERR_WRONG_INDEX
      
In RBR, disabling keys on slave table will break replication when
updating or deleting a record. When the slave thread tries to
find the row, by searching in the storage engine, it checks
whether the table has a key or not. If it has one, then the slave
thread uses it to search the record.
      
Nonetheless, the slave only checks whether the key exists or not,
it does not verify if it is active. Should the key be
disabled (eg, DBA has issued an ALTER TABLE ... DISABLE KEYS)
then it will result in error: HA_ERR_WRONG_INDEX.
      
This patch addresses this issue by making the slave thread also
check whether the key is active or not before actually using it.
2009-09-27 22:02:47 +01:00
Mattias Jonsson
43e6919d56 Bug#32430: 'show innodb status' causes errors
Invalid (old?) table or database name in logs

Problem was still not completely fixed, due to
qouting.

This is the server side only fix (in explain_filename),
the change from filename_to_tablename to use explain_filename
in the InnoDB code must be done before the bug is
fixed.


mysql-test/include/have_not_innodb_plugin.inc:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Added include file to allow test for only the
  'old' built-in innodb engine
mysql-test/r/not_true.require:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Added require to match 'not' TRUE
mysql-test/r/partition_innodb_builtin.result:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  New result file for partitioning specific to
  the 'old' built-in innodb engine
mysql-test/r/partition_innodb_plugin.result:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  New result file for partitioning specific to
  the new plugin innodb engine
mysql-test/t/disabled.def:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Disabling the new test until the fix is
  included in the InnoDB source too.
mysql-test/t/partition_innodb_builtin.test:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  New test file for partitioning specific to
  the 'old' built-in innodb engine
mysql-test/t/partition_innodb_plugin.test:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  New test file for partitioning specific to
  the new plugin innodb engine
sql/mysql_priv.h:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Added thd as a parameter to explain_filename
  to be able to use the correct quote character
sql/sql_table.cc:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Changed explain_filename, so that it does qouting
  correctly according to the sessions qoute char.
2009-09-25 11:26:49 +02:00
Luis Soares
9ae9f84ef4 BUG#42829: binlogging enabled for all schemas regardless of
binlog-db-db / binlog-ignore-db
      
InnoDB will return an error if statement based replication is used
along with transaction isolation level READ-COMMITTED (or weaker),
even if the statement in question is filtered out according to the
binlog-do-db rules set. In this case, an error should not be printed.
      
This patch addresses this issue by extending the existing check in
external_lock to take into account the filter rules before deciding to
print an error. Furthermore, it also changes decide_logging_format to
take into consideration whether the statement is filtered out from 
binlog before decision is made.

sql/sql_base.cc:
  Changed the check on decide_logging_format to take into account
  whether statement is filtered or not in SBR.
sql/sql_class.cc:
  Added the thd_binlog_filter_ok to INNODB_COMPATIBILITY_HOOKS set.
storage/innobase/handler/ha_innodb.cc:
  Extended check in external_lock to take into consideration the
  filtering when deciding to throw an error.
storage/innobase/handler/ha_innodb.h:
  Added declaration of new hook.
storage/innodb_plugin/handler/ha_innodb.cc:
  Extended check in external_lock to take into consideration the
  filtering when deciding to throw an error.
storage/innodb_plugin/handler/ha_innodb.h:
  Added declaration of new hook.
2009-09-24 15:52:52 +01:00
Georgi Kodinov
49557aae69 merged compilation warning fixes 2009-09-24 16:28:13 +03:00
Georgi Kodinov
45c70a2ec5 fixed compilation warnings 2009-09-24 16:21:46 +03:00
Staale Smedseng
6a89842e36 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2

Cleaning up warnings not present in 5.0.
2009-09-23 15:21:29 +02:00
Alexander Nozdrin
d499138770 A patch for Bug#47474 (mysqld hits Dbug_violation_helper assert
when compiled with Sun Studio compiler).

The thing is that Sun Studio compiler calls destructor of stack
objects when pthread_exit() is called. That triggered an assertion
in DBUG_ENTER()/DBUG_RETURN() validation logic (if DBUG_ENTER() is
used in the beginning of function, all returns should be replaced
by DBUG_RETURN/DBUG_VOID_RETURN macros).

A fix is to explicitly use DBUG_LEAVE macro.
2009-09-23 17:10:23 +04:00
Davi Arnaut
83bc7980ce Bug#45498: Socket variable not available on Windows
The "socket" variable is not available on Windows even though
the --socket option can be used to specify the pipe name for
local connections that use a named pipe.

The solution is to ensure that the variable is always defined.


mysql-test/r/windows.result:
  Add test case result for Bug#45498
mysql-test/t/windows.test:
  Add test case for Bug#45498
sql/set_var.cc:
  socket variable must always be present.
2009-09-22 08:22:07 -03:00
Georgi Kodinov
9a42d81f98 automerge 2009-09-23 14:11:48 +03:00
Sergey Glukhov
beb519e3ca Bug#45989 memory leak after explain encounters an error in the query
the fix is reverted from 5.1, mysql-pe as 
unnecessary(no valgrind warnings there).

sql/sql_select.cc:
  the fix is reverted from 5.1, mysql-pe as 
  unnecessary(no valgrind warnings there).
2009-09-23 13:40:33 +05:00
Georgi Kodinov
8705b0e1f6 automerge 2009-09-23 11:27:12 +03:00
Anurag Shekhar
fe0437d3f9 merged with local branch. 2009-09-22 16:16:24 +05:30
Kristofer Pettersson
5ec6043ac3 Fix for BUG#35570 "CHECKSUM TABLE unreliable if LINESTRING field (same content/ differen
checksum)"

The problem was that checksum of GEOMETRY type used memory addresses
in the computation, making it un-repeatable thus useless.
(This patch is a backport from 6.0 branch)

mysql-test/r/myisam.result:
  test case for bug35570 that same tables give same checksums
mysql-test/t/myisam.test:
  test case for bug35570 that same tables give same checksums
sql/sql_table.cc:
  Type GEOMETRY is implemented on top of type BLOB, so, just like for BLOB,
  its 'field' contains pointers which it does not make sense to include in
  the checksum; it rather has to be converted to a string and then we can
  compute the checksum.
2009-09-21 11:58:15 +02:00
Georgi Kodinov
4ac694822b automerge 2009-09-18 16:35:40 +03:00
Georgi Kodinov
5080092322 automerge 2009-09-18 16:19:58 +03:00
Georgi Kodinov
01e5bc703d Bug#46760: Fast ALTER TABLE no longer works for InnoDB
Despite copying the value of the old table's row type
we don't always have to mark row type as being specified.
Innodb uses this to check if it can do fast ALTER TABLE
or not.
Fixed by correctly flagging the presence of row_type 
only when it's actually changed.
Added a test case for 39200.
2009-09-18 16:01:18 +03:00
Anurag Shekhar
f2f2e981c1 merging with latest changes in bugteam. 2009-09-18 16:55:36 +05:30
Georgi Kodinov
5dda6c18cd Bug #47106: Crash / segfault on adding EXPLAIN to a non-crashing
query
      
The fix for bug 46749 removed the check for OUTER_REF_TABLE_BIT 
and substituted it for a check on the presence of 
Item_ident::depended_from.
Removing it altogether was wrong : OUTER_REF_TABLE_BIT should 
still be checked in addition to depended_from (because it's not 
set in all cases and doesn't contradict to the check of depended_from).
Fixed by returning the old condition back as a compliment to the 
new one.
2009-09-18 12:34:08 +03:00
unknown
64badb5f26 Bug #42914 Log event that larger than max_allowed_packet results in stop of slave I/O thread,
But there is no Last_IO_Error reported.

On the master, if a binary log event is larger than max_allowed_packet,
ER_MASTER_FATAL_ERROR_READING_BINLOG and the specific reason of this error is
sent to a slave when it requests a dump from the master, thus leading
the I/O thread to stop.

On a slave, the I/O thread stops when receiving a packet larger than max_allowed_packet.

In both cases, however, there was no Last_IO_Error reported.

This patch adds code to report the Last_IO_Error and exact reason before stopping the
I/O thread and also reports the case the out memory pops up while
handling packets from the master.


sql/sql_repl.cc:
  The master send the Specific reasons instead of "error reading log entry" to the slave which is requesting a dump.
  if an fatal error is returned by read_log_event function.
2009-09-18 16:20:29 +08:00
Staale Smedseng
d6ca0cbb23 Merge from 5.0 2009-09-17 17:25:52 +02:00
Staale Smedseng
e5888b16af Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
This is the fifth patch cleaning up more GCC warnings about
variables used before initialized using the new macro
UNINIT_VAR().
2009-09-17 17:10:30 +02:00
Anurag Shekhar
5999113f33 Bug #45840 read_buffer_size allocated for each partition when
"insert into.. select * from"

When inserting into a partitioned table using 'insert into
<target> select * from <src>', read_buffer_size bytes of memory
are allocated for each partition in the target table.

This resulted in large memory consumption when the number of
partitions are high.

This patch introduces a new method which tries to estimate the
buffer size required for each partition and limits the maximum
buffer size used to maximum of 10 * read_buffer_size, 
11 * read_buffer_size in case of monotonic partition functions.

sql/ha_partition.cc:
  Introduced a method ha_partition::estimate_read_buffer_size
  to estimate buffer size required for each partition. 
  Method ha_partition::start_part_bulk_insert updated
  to update the read_buffer_size before calling bulk upload
  in storage engines.
  Added thd in ha_partition::start_part_bulk_insert method signature.
sql/ha_partition.h:
  Introduced a method ha_partition::estimate_read_buffer_size.
  Added thd in ha_partition::start_part_bulk_insert method signature.
2009-09-17 17:35:43 +05:30
Sergey Glukhov
2535ede713 Bug#42364 SHOW ERRORS returns empty resultset after dropping non existent table
additional backport of of bug43138 fix


mysql-test/t/myisam-system.test:
  additional backport of of bug43138 fix
sql/sql_db.cc:
  additional backport of of bug43138 fix
2009-09-17 16:33:23 +05:00
Georgi Kodinov
31809edc24 Bug #46917: mysqd-nt installs wrong
When parsing the service installation parameter in 
default_service_handling() make sure the value of the
optional parameter doesn't overwrite it's name.
2009-09-17 14:25:07 +03:00
Ingo Struewing
3dea04c58b Pull from mysql-5.0-bugteam 2009-09-16 12:07:57 +02:00
Kristofer Pettersson
7ee331ab5d autocommit 2009-09-15 09:34:30 +02:00
Kristofer Pettersson
d98625d5ca autocommit 2009-09-15 09:33:25 +02:00
Mattias Jonsson
23dc8abe2b merge 2009-09-12 00:40:23 +02:00
Ramil Kalimullin
b6c16b329a Fix for bug#47130: misplaced or redundant check for null pointer?
Problem: LOGGER::general_log_write() relied on valid "thd" parameter passed
but had inconsistent "if (thd)" check.

Fix: as we always pass a valid "thd" parameter to the method, 
redundant check removed.


sql/log.cc:
  Fix for bug#47130: misplaced or redundant check for null pointer?
    - code clean-up, as we rely on the "thd" parameter in the
  LOGGER::general_log_write(), redundant "if (thd)" check removed, 
  added assert(thd) instead.
2009-09-11 22:06:27 +05:00
Sergey Glukhov
0412a7c753 5.0-bugteam->5.1-bugteam merge 2009-09-10 15:30:03 +05:00
Sergey Glukhov
10406ae658 Bug#46815 CONCAT_WS returning wrong data
The problem is that argument buffer can be used as result buffer
and it leads to argument value change.
The fix is to use 'old buffer' as result buffer only
if first argument is not constant item.


mysql-test/r/func_str.result:
  test result
mysql-test/t/func_str.test:
  test case
sql/item_strfunc.cc:
  The problem is that argument buffer can be used as result buffer
  and it leads to argument value change.
  The fix is to use 'old buffer' as result buffer only
  if first argument is not constant item.
2009-09-10 15:24:07 +05:00
unknown
e436b8866b BUG#45999 Row based replication fails when auto_increment field = 0
In RBR, There is an inconsistency between slaves and master.
When INSERT statement which includes an auto_increment field is executed,
Store engine of master will check the value of the auto_increment field. 
It will generate a sequence number and then replace the value, if its value is NULL or empty.
if the field's value is 0, the store engine will do like encountering the NULL values 
unless NO_AUTO_VALUE_ON_ZERO is set into SQL_MODE.
In contrast, if the field's value is 0, Store engine of slave always generates a new sequence number 
whether or not NO_AUTO_VALUE_ON_ZERO is set into SQL_MODE.

SQL MODE of slave sql thread is always consistency with master's.
Another variable is related to this bug.
If generateing a sequence number is decided by the values of
table->auto_increment_field_not_null and SQL_MODE(if includes MODE_NO_AUTO_VALUE_ON_ZERO)
The table->auto_increment_is_not_null is FALSE, which causes this bug to appear. ..
2009-09-10 18:05:53 +08:00
Sergey Glukhov
104d9ce76a Bug#42364 SHOW ERRORS returns empty resultset after dropping non existent table
partial backport of bug43138 fix


mysql-test/r/warnings.result:
  test result
mysql-test/t/warnings.test:
  test case
sql/sql_class.cc:
  partial backport of bug43138 fix
sql/sql_class.h:
  partial backport of bug43138 fix
sql/sql_table.cc:
  partial backport of bug43138 fix
2009-09-10 13:49:49 +05:00
Sergey Vojtovich
6d3e743d5b Merge 5.1-bugteam -> 5.1-bugteam-local. 2009-09-10 13:38:59 +05:00
Alexander Nozdrin
70972926ab A patch for Bug#45118 (mysqld.exe crashed in debug mode
on Windows in dbug.c) -- part 2: a patch for the DBUG subsystem
to detect misuse of DBUG_ENTER / DBUG_RETURN macros.
5.1 version.
2009-09-10 11:40:57 +04:00
Sergey Vojtovich
eb7a3fc9cb Local merge. 2009-09-10 11:54:26 +05:00
Sergey Vojtovich
32055c1c72 Local merge. 2009-09-10 11:53:35 +05:00
Sergey Vojtovich
3228a2be66 BUG#45638 - Create temporary table with engine innodb fails
Create temporary InnoDB table fails on case insensitive
filesystems, when lower_case_table_names is 2 (e.g. OS X)
and temporary directory path contains upper case letters.

The problem was that tmpdir prefix was converted to lower
case when table was created, but was passed as is when
table was opened.

Fixed by leaving tmpdir prefix part intact.

mysql-test/r/lowercase_mixed_tmpdir_innodb.result:
  A test case for BUG#45638.
mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt:
  A test case for BUG#45638.
mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh:
  A test case for BUG#45638.
mysql-test/t/lowercase_mixed_tmpdir_innodb.test:
  A test case for BUG#45638.
sql/handler.cc:
  Fixed get_canonical_filename() to not lowercase filesystem
  path prefix for temporary tables.
2009-09-09 14:38:50 +05:00
Georgi Kodinov
0ab24bef29 automerge 2009-09-08 12:37:09 +03:00
Alexey Kopytov
0a7e41864c Automerge. 2009-09-08 12:36:40 +04:00
Ingo Struewing
540b2dc004 Bug#17332 - changing key_buffer_size on a running server
can crash under load

Backport from 5.1.
Does also include key cache fixes from:
Bug 44068 (RESTORE can disable the MyISAM Key Cache)
Bug 40944 (Backup: crash after myisampack)



include/keycache.h:
  Bug#17332 - changing key_buffer_size on a running server
              can crash under load
  Added KEY_CACHE components in_resize and waiting_for_resize_cnt.
myisam/mi_preload.c:
  Bug#17332 - changing key_buffer_size on a running server
              can crash under load
  Added code to allow LOAD INDEX to load indexes of different block size.
mysys/mf_keycache.c:
  Bug#17332 - changing key_buffer_size on a running server
              can crash under load
  .
  Changed resize_key_cache() to not disable the key cache
  after the flush phase. Changed queue handling to use
  standard functions. Wake all threads waiting on resize_queue.
  We can now have read/write threads waiting there (see below).
  .
  Combined add_to_queue() and the wait loops that were always
  following it to the new function wait_on_queue().
  Combined release_queue() and the condition that was always
  preceding it to the new function release_whole_queue().
  .
  Added code to flag and respect the exceptional situation
  BLOCK_IN_EVICTION.
  .
  Rewrote the resize branch of find_key_block().
  .
  Added code to the eviction handling in find_key_block()
  to catch more exceptional cases.
  .
  Changed key_cache_read(), key_cache_insert() and key_cache_write()
  so that they lock keycache->cache_lock whenever the key cache is
  initialized. Checking for a disabled cache and incrementing and
  decrementing the "resize counter" is always done within the lock.
  Locking and unlocking as well as counting the "resize counter" is
  now done once outside the loop. All three functions can now handle
  a NULL return from find_key_block. This happens in the flush phase
  of a resize and demands direct file I/O. Care is taken for
  secondary requests (PAGE_WAIT_TO_BE_READ) to wait in any case.
  Moved block status changes behind the copying of buffer data.
  key_cache_insert() does now read the block if the caller did
  supply less data than a full cache block.
  key_cache_write() does now take care of parallel running flushes
  (BLOCK_FOR_UPDATE, BLOCK_IN_FLUSHWRITE).
  .
  Changed free_block() to un-initialize block variables in the
  correct order and respect an exceptional BLOCK_IN_EVICTION state.
  .
  Changed flushing to take care for parallel running writes.
  Changed flushing to avoid freeing blocks in eviction.
  Changed flushing to consider that parallel writes can move blocks
  from the file_blocks hash to the changed_blocks hash.
  Changed flushing to take care for other parallel flushes.
  Changed flushing to assure that it ends with everything flushed.
  Optimized normal flush at end of statement (FLUSH_KEEP),
  but let other flush types be stringent.
  .
  Added some comments and debugging statements.
mysys/my_static.c:
  Bug#17332 - changing key_buffer_size on a running server
              can crash under load
  Removed an unused global variable.
sql/ha_myisam.cc:
  Bug#17332 - changing key_buffer_size on a running server
              can crash under load
  Moved an automatic (stack) variable to the scope where it is used.
sql/sql_table.cc:
  Bug#17332 - changing key_buffer_size on a running server
              can crash under load
  Changed TL_READ to TL_READ_NO_INSERT in mysql_preload_keys.
2009-09-07 18:35:37 +02:00
Martin Hansson
fe3b6356ca Bug#46259: Merge 2009-09-07 16:52:47 +02:00
Mikael Ronstrom
bdd4374445 Automerge 2009-09-07 12:22:57 +02:00
Martin Hansson
2cb3a131f4 Bug#46259: 5.0.83 -> 5.1.36, query doesn't work
The parser rule for expressions in a udf parameter list contains 
two hacks: 
First, the parser input stream is read verbatim, bypassing 
the lexer.
Second, the Item::name field is overwritten. If the argument to a
udf was a field, the field's name as seen by name resolution was
overwritten this way.
If the field name was quoted or escaped, it would appear as e.g. "`field`".
Fixed by not overwriting field names.

mysql-test/r/udf.result:
  Bug#46259: Test result.
mysql-test/t/udf.test:
  Bug#46259: Test case.
sql/sql_yacc.yy:
  Bug#46259: Fix.
2009-09-07 11:57:22 +02:00
Mikael Ronstrom
dd407c5228 Fix to ensure that all subpartitions gets deleted before renaming starts, BUG#47029 2009-09-07 10:37:54 +02:00
Alexey Kopytov
505346028f Bug #46159: simple query that never returns
The external 'for' loop in remove_dup_with_compare() handled 
HA_ERR_RECORD_DELETED by just starting over without advancing 
to the next record which caused an infinite loop. 
 
This condition could be triggered on certain data by a SELECT 
query containing DISTINCT, GROUP BY and HAVING clauses. 

Fixed remove_dup_with_compare() so that we always advance to 
the next record when receiving HA_ERR_RECORD_DELETED from 
rnd_next(). 

mysql-test/r/distinct.result:
  Added a test case for bug #46159.
mysql-test/t/distinct.test:
  Added a test case for bug #46159.
sql/sql_select.cc:
  Fixed remove_dup_with_compare() so that we always advance to 
  the next record when receiving HA_ERR_RECORD_DELETED from 
  rnd_next().
2009-09-06 00:42:17 +04:00
Ramil Kalimullin
8a3d59ea99 Automerge 2009-09-04 21:37:40 +05:00
Mattias Jonsson
35d6911b28 Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions
(Backport)

Problem is that when insert (ha_start_bulk_insert) in i partitioned table,
it will call ha_start_bulk_insert for every partition, used or not.

Solution is to delay the call to the partitions ha_start_bulk_insert until
the first row is to be inserted into that partition


sql/ha_partition.cc:
  Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions
  
  Using a bitmap for keeping record of which partitions for which
  ha_start_bulk_insert has been called, and check against that if one
  should call it before continue with the insert/update, or if it has already
  been called.
  
  This way it will only call ha_start_bulk_insert for the used partitions.
  There is also a little prediction on how many rows that will be inserted into
  the current partition, it will guess on equal distribution of the records
  across all partitions, accept for the first used partition, which will guess
  at 50% of the given estimate, if it is a monotonic partitioning function.
sql/ha_partition.h:
  Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions
  
  Added help variables and function for delaying ha_bulk_insert until it has
  to be called.
  
  Fixed a comment.
2009-09-04 15:02:15 +02:00
Kristofer Pettersson
0c4c2d7b8d Bug#46486 warnings produced when running mysql_install_db
Incremental patch part 2

Removing dead code and changing a note level message to a warning.


sql/sql_plugin.cc:
  * Remove free_slots. The only purpose for this variable was to trigger
    a redundant warning message  and it failed.
  * Change the note level message about shutting down plugins which
    didn't end nicely to a warning level message. (If this shutdown
    fails and there still are reference counts in the plugin an
    additional error level message is emitted)
2009-09-04 12:32:21 +02:00
Ramil Kalimullin
2a6ac469fc Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0'
on subquery inside a SP 

Problem: repeated call of a SP containing an incorrect query with a 
subselect may lead to failed ASSERT().

Fix: set proper sublelect's state in case of error occured during 
subquery transformation.


mysql-test/r/sp.result:
  Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
  on subquery inside a SP 
    - test result.
mysql-test/t/sp.test:
  Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
  on subquery inside a SP 
    - test case.
sql/item_subselect.cc:
  Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
  on subquery inside a SP 
    - don't set Item_subselect::changed in the Item_subselect::fix_fields()
  if an error occured during subquery transformation.
  That prevents us of further processing incorrect subqueries after 
  Item_in_subselect::select_in_like_transformer().
2009-09-04 13:14:54 +05:00
Sergey Glukhov
79b5063ddf 5.0-bugteam->5.1-bugteam merge 2009-09-04 12:39:56 +05:00
Sergey Glukhov
643fbe4234 Bug#45989 memory leak after explain encounters an error in the query
Memory allocated in TMP_TABLE_PARAM::copy_field is not cleaned up.
The fix is to clean up TMP_TABLE_PARAM::copy_field array in JOIN::destroy.


mysql-test/r/explain.result:
  test result
mysql-test/t/explain.test:
  test case
sql/sql_select.cc:
  Memory allocated in TMP_TABLE_PARAM::copy_field is not cleaned up.
  The fix is to clean up TMP_TABLE_PARAM::copy_field array in JOIN::destroy.
2009-09-04 12:20:53 +05:00
Satya B
7bfdc5bbf5 merge mysql-5.0-bugteam to mysql-5.1-bugteam 2009-09-04 12:27:10 +05:30
Satya B
6e27ef435e Fix for BUG#46384 - mysqld segfault when trying to create table with same
name as existing view

When trying to create a table with the same name as existing view with
join, mysql server crashes.

The problem is when create table is issued with the same name as view, while
verifying with the existing tables, we assume that base table object is 
created always.

In this case, since it is a view over multiple tables, we don't have the 
mysql derived table object.

Fixed the logic which checks if there is an existing table to not to assume
that table object is created when the base table is view over multiple 
tables.

mysql-test/r/create.result:
  BUG#46384 - mysqld segfault when trying to create table with same 
              name as existing view
  
  Testcase for the bug
mysql-test/t/create.test:
  BUG#46384 - mysqld segfault when trying to create table with same 
              name as existing view
  
  Testcase for the bug
sql/sql_insert.cc:
  BUG#46384 - mysqld segfault when trying to create table with same 
                  name as existing view
      
  Fixed create_table_from_items() method to properly check, if the base table 
  is a view over multiple tables.
2009-09-04 12:21:54 +05:30
V Narayanan
9776b6f9cd Bug#45823 Assertion failure in file row/row0mysql.c line 1386
Inserting a negative value in the autoincrement column of a
partitioned innodb table was causing the value of the auto
increment counter to wrap around into a very large positive
value. The consequences are the same as if a very large positive
value was inserted into a column, e.g. reduced autoincrement
range, failure to read autoincrement counter.

The current patch ensures that before calculating the next
auto increment value, the current value is within the positive
maximum allowed limit.

mysql-test/suite/parts/inc/partition_auto_increment.inc:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Adds tests for performing insert,update and delete on a partition
  table with negative auto_increment values.
mysql-test/suite/parts/r/partition_auto_increment_innodb.result:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Result file for the innodb engine.
mysql-test/suite/parts/r/partition_auto_increment_memory.result:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Result file for the memory engine.
mysql-test/suite/parts/r/partition_auto_increment_myisam.result:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Result file for the myisam engine.
mysql-test/suite/parts/r/partition_auto_increment_ndb.result:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Result file for the ndb engine.
mysql-test/suite/parts/t/partition_auto_increment_archive.test:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Adds a variable that allows the Archive engine to skip tests
  that involve insertion of negative auto increment values.
mysql-test/suite/parts/t/partition_auto_increment_blackhole.test:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Adds a variable that allows the Blackhole engine to skip tests
  that involve insertion of negative auto increment values.
sql/ha_partition.cc:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Ensures that the current value is lesser than the upper limit
  for the type of the field before setting the next auto increment
  value to be calculated.
sql/ha_partition.h:
  Bug#45823 Assertion failure in file row/row0mysql.c line 1386
  
  Modifies the set_auto_increment_if_higher function, to take
  into account negative auto increment values when doing a
  comparison.
2009-09-04 09:27:11 +05:30
Georgi Kodinov
629557ff13 Bug #46791: Assertion failed:(table->key_read==0),function unknown
function,file sql_base.cc

When uncacheable queries are written to a temp table the optimizer must 
preserve the original JOIN structure, because it is re-using the JOIN 
structure to read from the resulting temporary table.
This was done only for uncacheable sub-queries. 
But top level queries can also benefit from this mechanism, specially if 
they're using index access and need a reset.
Fixed by not limiting the saving of JOIN structure to subqueries
exclusively.
Added a new test file to extend the existing (large) subquery.test.
2009-09-03 18:03:46 +03:00
Satya B
33f9066e39 merge mysql-5.0-bugteam to mysql-5.1-bugteam 2009-09-03 17:59:25 +05:30
Satya B
2fc9c5d199 Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for
CREATE TABLE...LIKE...
      
The mysql server option 'sync_frm' is ignored when table is created with 
syntax CREATE TABLE .. LIKE.. 
      
Fixed by adding the MY_SYNC flag and calling my_sync() from my_copy() when
the flag is set.

In mysql_create_table(), when the 'sync_frm' is set, MY_SYNC flag is passed 
to my_copy(). 
      
Note: TestCase is not attached and can be tested manually using debugger.

client/Makefile.am:
  BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
              CREATE TABLE...LIKE...
      
  add my_sync to sources as it is used in my_copy() method
include/my_sys.h:
  BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
              CREATE TABLE...LIKE...
      
  MY_SYNC flag is added to call my_sync() method
mysys/my_copy.c:
  BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
              CREATE TABLE...LIKE...
      
  my_sync() is method is called when MY_SYNC is set in my_copy()
sql/sql_table.cc:
  BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 
              CREATE TABLE...LIKE...
      
  Fixed mysql_create_like_table() to call my_sync() when opt_sync_frm variable
  is set
2009-09-03 16:02:03 +05:30
Kristofer Pettersson
76b8bd3589 Bug#46486 warnings produced when running mysql_install_db
During start up some plugins are disabled by default. This caused an additional
warning level message to be emitted as a result of a previous bug patch. Since
there is risk of unnecessary confusion regarding the operation level of the server
the redundant information is removed.
2009-09-03 12:08:55 +02:00
Bjorn Munch
31f9d5fd16 second merge from main, with adaptions 2009-09-02 23:29:11 +02:00
Bjorn Munch
a829604260 first merge from main 2009-09-02 18:58:17 +02:00
Georgi Kodinov
b64e7fb5be fixed a valgrind warning in partition_pruning 2009-09-02 18:42:08 +03:00
Georgi Kodinov
7c9e39f5c5 fixed a valgrind warning in partitioning code 2009-09-02 15:20:47 +03:00
Sergey Vojtovich
32c7efa6b4 BUG#46483 - drop table of partitioned table may leave
extraneous file

Online/fast ALTER TABLE of a partitioned table may leave
temporary file in database directory.

Fixed by removing unnecessary call to
handler::ha_create_handler_files(), which was creating
partitioning definition file.

mysql-test/r/partition_innodb.result:
  A test case for BUG#46483.
mysql-test/t/partition_innodb.test:
  A test case for BUG#46483.
sql/unireg.cc:
  Do not call ha_create_handler_files() when we were requested
  to create only dot-frm file.
2009-09-02 16:19:28 +05:00
Georgi Kodinov
f0720480dc Fixed win32 compilation warnings 2009-09-02 13:22:47 +03:00
Georgi Kodinov
38cb188e24 automerge 2009-08-31 16:40:35 +03:00
Staale Smedseng
4d7202a02b Merge from 5.1-bugteam 2009-08-30 19:01:48 +02:00
Alexey Kopytov
54e4516063 Automerge. 2009-08-30 11:38:49 +04:00
Alexey Kopytov
6ce48392ea Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM)
results in server crash 
 
check_group_min_max_predicates() assumed the input condition 
item to be one of COND_ITEM, SUBSELECT_ITEM, or FUNC_ITEM. 
Since a condition of the form "field" is also a valid condition 
equivalent to "field <> 0", using such a condition in a query 
where the loose index scan was chosen resulted in a debug 
assertion failure. 
 
Fixed by handling conditions of the FIELD_ITEM type in 
check_group_min_max_predicates(). 

mysql-test/r/group_min_max.result:
  Added a test case for bug #46607.
mysql-test/t/group_min_max.test:
  Added a test case for bug #46607.
sql/opt_range.cc:
  Handle conditions of the FUNC_ITEM type in 
  check_group_mix_max_predicates().
2009-08-30 11:03:37 +04:00
unknown
f32c08bd0c Bug #44331 Restore of database with events produces warning in replication
If an EVENT is created without the DEFINER clause set explicitly or with it set  
to CURRENT_USER, the master and slaves become inconsistent. This issue stems from 
the fact that in both cases, the DEFINER is set to the CURRENT_USER of the current 
thread. On the master, the CURRENT_USER is the mysqld's user, while on the slave,  
the CURRENT_USER is empty for the SQL Thread which is responsible for executing 
the statement.

To fix the problem, we do what follows. If the definer is not set explicitly,  
a DEFINER clause is added when writing the query into binlog; if 'CURRENT_USER' is 
used as the DEFINER, it is replaced with the value of the current user before 
writing to binlog.

mysql-test/suite/rpl/r/rpl_create_if_not_exists.result:
  Updated the result file after fixing bug#44331
mysql-test/suite/rpl/r/rpl_drop_if_exists.result:
  Updated the result file after fixing bug#44331
mysql-test/suite/rpl/r/rpl_events.result:
  Test result of Bug#44331
mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result:
  Updated the result file after fixing bug#44331
mysql-test/suite/rpl/t/rpl_events.test:
  Added test to verify if the definer is consistent between master and slave
  when the event is created without the DEFINER clause set explicitly or the
  DEFINER is set to CURRENT_USER
sql/events.cc:
  The "create_query_string" function is added to create a new query string 
  for removing executable comments.
sql/sql_yacc.yy:
  The remember_name token was added for recording the offset of EVENT_SYM.
2009-08-29 16:52:22 +08:00
Staale Smedseng
5be4c38226 Merge from 5.0 for 43414 2009-08-28 18:21:54 +02:00
Staale Smedseng
1ba25ae47c Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
This patch fixes a number of GCC warnings about variables used
before initialized. A new macro UNINIT_VAR() is introduced for
use in the variable declaration, and LINT_INIT() usage will be
gradually deprecated. (A workaround is used for g++, pending a
patch for a g++ bug.)
      
GCC warnings for unused results (attribute warn_unused_result)
for a number of system calls (present at least in later
Ubuntus, where the usual void cast trick doesn't work) are
also fixed.


client/mysqlmanager-pwgen.c:
  A fix for warn_unused_result, adding fallback to use of
  srand()/rand() if /dev/random cannot be used. Also actually
  adds calls to rand() in the second branch so that it actually
  creates a random password.
2009-08-28 17:51:31 +02:00
Davi Arnaut
169f7da04c Fix for a few assorted compiler warnings.
client/mysql.cc:
  Remove leading whitespace.
  Remove extra text after #else directive.
client/mysqldump.c:
  Function does not take a parameter.
mysys/array.c:
  buffer is a uchar pointer.
sql/item.cc:
  Assert if it should not happen.
storage/myisam/mi_check.c:
  Cast to expected type. This is probably a bug, but it is
  casted in a similar way in another part of the code.
storage/ndb/include/mgmapi/ndb_logevent.h:
  Apply fix from cluster team.
tests/mysql_client_test.c:
  Remove extraneous slash.
2009-08-28 12:06:59 -03:00
Mattias Jonsson
99413e461f merge 2009-08-28 13:54:17 +02:00
Mattias Jonsson
0a76397171 Manual merge between bug#46362 and bug#20577.
sql/opt_range.cc:
  Removed duplicate code (if statement must have been duplicated during earlier merge).
sql/sql_partition.cc:
  After mergeing bug#46362 and bug#20577, the NULL partition was also searched
  when col = const, fixed by checking if = or range.
2009-08-28 12:55:59 +02:00
Alfranio Correia
f9e413a1a5 merge mysql-5.0-bugteam --> mysql-5.1-bugteam 2009-08-28 10:45:57 +01:00
Alfranio Correia
5edd807a7a auto-merge mysql-5.0-bugteam (local) --> mysql-5.0-bugteam 2009-08-28 10:29:04 +01:00
Alfranio Correia
ea06bbd2b0 BUG#46861 Auto-closing of temporary tables broken by replicate-rewrite-db
When a connection is dropped any remaining temporary table is also automatically
dropped and the SQL statement of this operation is written to the binary log in
order to drop such tables on the slave and keep the slave in sync. Specifically,
the current code base creates the following type of statement:
DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `db`.`table`;

Unfortunately, appending the database to the table name in this manner circumvents
the replicate-rewrite-db option (and any options that check the current database).
To solve the issue, we started writing the statement to the binary as follows:
use `db`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `table`;
2009-08-27 17:28:09 +01:00
Alfranio Correia
354f5f7bac BUG#46864 Incorrect update of InnoDB table on slave when using trigger with myisam table
Slave does not correctly handle "expected errors" leading to inconsistencies
between the mater and slave. Specifically, when a statement changes both
transactional and non-transactional tables, the transactional changes are
automatically rolled back on the master but the slave ignores the error and
does not roll them back thus leading to inconsistencies.
      
To fix the problem, we automatically roll back a statement that fails on
the slave but note that the transaction is not rolled back unless a "rollback"
command is in the relay log file.

mysql-test/extra/rpl_tests/rpl_mixing_engines.test:
  Enabled item 13.e which was disabled because of the bug fixed by the
  current and removed item 14 which was introduced by mistake.
2009-08-27 13:46:29 +01:00
Georgi Kodinov
a22c29d5e4 Bug #46749: Segfault in add_key_fields() with outer subquery level
field references

This error requires a combination of factors : 
1. An "impossible where" in the outermost SELECT
2. An aggregate in the outermost SELECT
3. A correlated subquery with a WHERE clause that includes an outer 
field reference as a top level WHERE sargable predicate

When JOIN::optimize detects an "impossible WHERE" it will bail out
without doing the rest of the work and initializations. It will not
call make_join_statistics() as well.  And make_join_statistics fills 
in various structures for each table referenced.
When processing the result of the "impossible WHERE" the query must
send a single row of data if there are aggregate functions in it.
In this case the server marks all the aggregates as having received 
no rows and calls the relevant Item::val_xxx() method on the SELECT
list. However if this SELECT list happens to contain a correlated 
subquery this subquery is evaluated in a normal evaluation mode.
And if this correlated subquery has a reference to a field from the 
outermost "impossible where" SELECT the add_key_fields will mistakenly
consider the outer field reference as a "local" field reference when 
looking for sargable predicates.
But since the SELECT where the outer field reference refers to is not
completely initialized due to the "impossible WHERE" in this level
we'll get a NULL pointer reference.
Fixed by making a better condition for discovering if a field is "local"
to the SELECT level being processed. 
It's not enough to look for OUTER_REF_TABLE_BIT in this case since 
for outer references to constant tables the Item_field::used_tables() 
will return 0 regardless of whether the field reference is from the 
local SELECT or not.
2009-08-27 14:40:42 +03:00
Sergey Glukhov
51f4ccfa43 5.0-bugteam->5.1-bugteam merge 2009-08-27 15:59:25 +05:00
Sergey Glukhov
367c14b854 Bug#46184 Crash, SELECT ... FROM derived table procedure analyze
The crash happens because select_union object is used as result set
for queries which have derived tables.
select_union use temporary table as data storage and if
fields count exceeds 10(count of values for procedure ANALYSE())
then we get a crash on fill_record() function.


mysql-test/r/analyse.result:
  test result
mysql-test/r/subselect.result:
  result fix
mysql-test/t/analyse.test:
  test case
mysql-test/t/subselect.test:
  test fix
sql/sql_yacc.yy:
  The crash happens because select_union object is used as result set
  for queries which have derived tables.
  select_union use temporary table as data storage and if
  fields count exceeds 10(count of values for procedure ANALYSE())
  then we get a crash on fill_record() function.
2009-08-27 15:22:19 +05:00
Georgi Kodinov
f10e85f5f2 merged 5.0-bugteam -> 5.1-bugteam 2009-08-27 10:46:35 +03:00
Alfranio Correia
6c2b32515e BUG#28976 Mixing trans and non-trans tables in one transaction results in incorrect
binlog

Mixing transactional (T) and non-transactional (N) tables on behalf of a
transaction may lead to inconsistencies among masters and slaves in STATEMENT
mode. The problem stems from the fact that although modifications done to
non-transactional tables on behalf of a transaction become immediately visible
to other connections they do not immediately get to the binary log and therefore
consistency is broken. Although there may be issues in mixing T and M tables in
STATEMENT mode, there are safe combinations that clients find useful.

In this bug, we fix the following issue. Mixing N and T tables in multi-level
(e.g. a statement that fires a trigger) or multi-table table statements (e.g.
update t1, t2...) were not handled correctly. In such cases, it was not possible
to distinguish when a T table was updated if the sequence of changes was N and T.
In a nutshell, just the flag "modified_non_trans_table" was not enough to reflect
that both a N and T tables were changed. To circumvent this issue, we check if an
engine is registered in the handler's list and changed something which means that
a T table was modified.

Check WL 2687 for a full-fledged patch that will make the use of either the MIXED or
ROW modes completely safe.

mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
2009-08-27 00:13:03 +01:00
Mattias Jonsson
cb57e856b6 merge 2009-08-26 14:45:50 +02:00
Mattias Jonsson
0000c9417a merge 2009-08-26 14:40:18 +02:00
Mattias Jonsson
67214ef433 Bug#20577: Partitions: use of to_days() function leads to selection failures
Problem was that the partition containing NULL values
was pruned away, since '2001-01-01' < '2001-02-00' but
TO_DAYS('2001-02-00') is NULL.

Added the NULL partition for RANGE/LIST partitioning on TO_DAYS()
function to be scanned too.

Also fixed a bug that added ALLOW_INVALID_DATES to sql_mode
(SELECT * FROM t WHERE date_col < '1999-99-99' on a RANGE/LIST
partitioned table would add it).

mysql-test/include/partition_date_range.inc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added include file to decrease test code duplication
mysql-test/r/partition_pruning.result:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added test results
mysql-test/r/partition_range.result:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Updated test result.
  This fix adds the partition containing NULL values to
  the list of partitions to be scanned.
mysql-test/t/partition_pruning.test:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added test case
sql/item.h:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Added MONOTONIC_*INCREASE_NOT_NULL values to be used by TO_DAYS.
sql/item_timefunc.cc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Calculate the number of days as return value even for invalid dates.
  This is so that pruning can be used even for invalid dates.
sql/opt_range.cc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Fixed a bug that added ALLOW_INVALID_DATES to sql_mode
  (SELECT * FROM t WHERE date_col < '1999-99-99' on a RANGE/LIST
  partitioned table would add it).
sql/partition_info.h:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Resetting ret_null_part when a single partition is to be used, this
  to avoid adding the NULL partition.
sql/sql_partition.cc:
  Bug#20577: Partitions: use of to_days() function leads to selection failures
  
  Always include the NULL partition if RANGE or LIST.
  Use the returned value for the function for pruning, even if
  it is marked as NULL, so that even '2000-00-00' can be
  used for pruning, even if TO_DAYS('2000-00-00') is NULL.
  
  Changed == to >= in get_next_partition_id_list to avoid
  crash if part_iter->part_nums is not correctly setup.
2009-08-26 12:59:49 +02:00
Mattias Jonsson
4655118bea Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
There were a problem since pruning uses the field
for comparison (while evaluate_join_record uses longlong),
resulting in pruning failures when comparing DATE to DATETIME.

Fix was to always comparing DATE vs DATETIME as DATETIME,
by adding ' 00:00:00' to the DATE string.

And adding optimization for comparing with 23:59:59, so that
DATETIME_col > '2001-02-03 23:59:59' ->
TO_DAYS(DATETIME_col) > TO_DAYS('2001-02-03 23:59:59') instead
of '>='.

mysql-test/r/partition_pruning.result:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  Updated result-file
mysql-test/t/partition_pruning.test:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  Added testcases.
sql-common/my_time.c:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  removed duplicate assignment.
sql/item.cc:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  Changed field_is_equal_to_item into field_cmp_to_item, to
  better handling DATE vs DATETIME comparision.
sql/item.h:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  Updated comment
sql/item_timefunc.cc:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  Added optimization (pruning) of DATETIME where time-part is
  23:59:59
sql/opt_range.cc:
  Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
  
  Using the new stored_field_cmp_to_item for better pruning.
2009-08-26 12:51:23 +02:00
Davi Arnaut
fc39459504 Bug#45261: Crash, stored procedure + decimal
The problem was that creating a DECIMAL column from a decimal
value could lead to a failed assertion as decimal values can
have a higher precision than those attached to a table. The
assert could be triggered by creating a table from a decimal
with a large (> 30) scale. Also, there was a problem in
calculating the number of digits in the integral and fractional
parts if both exceeded the maximum number of digits permitted
by the new decimal type.

The solution is to ensure that truncation procedure is executed
when deducing a DECIMAL column from a decimal value of higher
precision. If the integer part is equal to or bigger than the
maximum precision for the DECIMAL type (65), the integer part
is truncated to fit and the fractional becomes zero. Otherwise,
the fractional part is truncated to fit into the space left
after the integer part is copied.

This patch borrows code and ideas from Martin Hansson's patch.

mysql-test/r/type_newdecimal.result:
  Add test case result for Bug#45261. Also, update test case to
  reflect that an additive operation increases the precision of
  the resulting type by 1.
mysql-test/t/type_newdecimal.test:
  Add test case for Bug#45261
sql/field.cc:
  Added DBUG_ASSERT to ensure object's invariant is maintained.
  Implement method to create a field to hold a decimal value
  from an item.
sql/field.h:
  Explain member variable. Add method to create a new decimal field.
sql/item.cc:
  The precision should only be capped when storing the value
  on a table. Also, this makes it impossible to calculate the
  integer part if Item::decimals (the scale) is larger than the
  precision.
sql/item.h:
  Simplify calculation of integer part.
sql/item_cmpfunc.cc:
  Do not limit the precision. It will be capped later.
sql/item_func.cc:
  Use new method for allocating a new decimal field.
  Add a specialized method for retrieving the precision
  of a user variable item.
sql/item_func.h:
  Add method to return the precision of a user variable.
sql/item_sum.cc:
  Use new method for allocating a new decimal field.
sql/my_decimal.h:
  The integer part could be improperly calculated for a decimal
  with 31 digits in the fractional part.
sql/sql_select.cc:
  Use new method which truncates the integer or decimal parts
  as needed.
2009-08-24 16:47:08 -03:00
Georgi Kodinov
7492d622e4 Bug #37044: Read overflow in opt_range.cc found during "make test"
The code was using a special global buffer for the value of IS NULL ranges.
This was not always long enough to be copied by a regular memcpy. As a 
result read buffer overflows may occur.
Fixed by setting the null byte to 1 and setting the rest of the field disk image
to NULL with a bzero (instead of relying on the buffer and memcpy()).
2009-08-24 15:28:03 +03:00
Alfranio Correia
e31a41d10b auto-merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-08-24 11:37:44 +01:00
Alfranio Correia
9a632549da auto-merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-08-24 10:24:52 +01:00
Mattias Jonsson
8b0ec01448 merge 2009-08-21 18:00:38 +02:00
Mattias Jonsson
a4e832d69d Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...

Problem was that when bulk insert is used on an empty
table/partition, it disables the indexes for better
performance, but in this specific case it also tries
to read from that partition using an index, which is
not possible since it has been disabled.

Solution was to allow index reads on disabled indexes
if there are no records.

Also reverted the patch for bug#38005, since that was a workaround
in the partitioning engine instead of a fix in myisam.

mysql-test/r/partition.result:
  Bug#46639: 1030 (HY000): Got error 124 from storage engine on
  INSERT ... SELECT ...
  
  updated result file
mysql-test/t/partition.test:
  Bug#46639: 1030 (HY000): Got error 124 from storage engine on
  INSERT ... SELECT ...
  
  Added testcase
sql/ha_partition.cc:
  Bug#46639: 1030 (HY000): Got error 124 from storage engine on
  INSERT ... SELECT ...
  
  reverted the patch for bug#38005, since that was a workaround
  around this problem, not needed after fixing it in myisam.
storage/myisam/mi_search.c:
  Bug#46639: 1030 (HY000): Got error 124 from storage engine on
  INSERT ... SELECT ...
  
  Return HA_ERR_END_OF_FILE instead of HA_ERR_WRONG_INDEX
  when there are no rows.
2009-08-21 17:38:29 +02:00
Georgi Kodinov
787a4940ca reverted the fix for bug #46019 from 5.1-bugteam 2009-08-21 17:41:48 +03:00
Georgi Kodinov
8723e9d226 automerge 2009-08-21 17:12:03 +03:00
Georgi Kodinov
66ce3dee92 Revert of the fix for bug #46019. 2009-08-21 17:10:55 +03:00
Martin Hansson
8f75260b7d Merge. 2009-08-21 14:31:40 +02:00
Martin Hansson
b011f1ea1c Merge. 2009-08-21 12:13:03 +02:00
Ramil Kalimullin
fb9ba3734b Fix for bug #46456 [Ver->Prg]: HANDLER OPEN + TRUNCATE + DROP
(temporary) TABLE, crash

Problem: if one has an open "HANDLER t1", further "TRUNCATE t1" 
doesn't close the handler and leaves handler table hash in an 
inconsistent state, that may lead to a server crash.

Fix: TRUNCATE should implicitly close all open handlers.

Doc. request: the fact should be described in the manual accordingly.


mysql-test/r/handler_myisam.result:
  Fix for bug #46456 [Ver->Prg]: HANDLER OPEN + TRUNCATE + DROP
  (temporary) TABLE, crash
    - test result.
mysql-test/t/handler_myisam.test:
  Fix for bug #46456 [Ver->Prg]: HANDLER OPEN + TRUNCATE + DROP
  (temporary) TABLE, crash
    - test case.
sql/sql_delete.cc:
  Fix for bug #46456 [Ver->Prg]: HANDLER OPEN + TRUNCATE + DROP
   (temporary) TABLE, crash
    - remove all truncated tables from the HANDLER's hash.
2009-08-21 10:55:35 +05:00
Georgi Kodinov
1317d24b33 merge of bug #46019 to 5.1-bugteam 2009-08-20 17:11:22 +03:00
Martin Hansson
acdbef4520 Bug#46616: Merge
mysql-test/r/auto_increment.result:
  Bug#46616: Test result.
mysql-test/t/auto_increment.test:
  Bug#46616: Test case.
sql/sql_update.cc:
  Bug#46616: Fix.
2009-08-20 14:30:59 +02:00
Martin Hansson
e66fba53a7 Bug#46616: Assertion `!table->auto_increment_field_not_null' on
view manipulations
      
The bespoke flag was not properly reset after last call to 
fill_record. Fixed by resetting in caller mysql_update.

mysql-test/r/auto_increment.result:
  Bug#46616: Test result.
mysql-test/t/auto_increment.test:
  Bug#46616: Test case.
sql/sql_update.cc:
  Bug#46616: Fix.
2009-08-20 13:56:29 +02:00
Alfranio Correia
40b9df3995 BUG#45694 Deadlock in replicated statement is not retried
If the SQL Thread fails to execute an event due to a temporary error (e.g.
ER_LOCK_DEADLOCK) and the option "--slave_transaction_retries" is set the SQL
Thread should not be aborted and the transaction should be restarted from the
beginning and re-executed.

Unfortunately, a wrong interpretation of the THD::is_fatal_error was preventing
this behavior. In a nutshell, "this variable is set to TRUE if an execution of a
compound statement cannot continue. In particular, it is used to disable access
to the CONTINUE or EXIT handlers of stored routines. So even temporary errors
may have this variable set.

To fix the bug, we have done what follows:

   DBUG_ENTER("has_temporary_error");

-  if (thd->is_fatal_error)
-    DBUG_RETURN(0);
-
   DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
                   if (thd->main_da.is_error())
                   {
2009-08-19 16:38:18 +01:00
Georgi Kodinov
152943f39f Bug #46807: subselect test fails on PB-2 with a crash
The check for stack overflow was independent of the size of the 
structure stored in the heap. 
Fixed by adding sizeof(PARAM) to the requested free heap size.
2009-08-19 17:53:43 +03:00
Georgi Kodinov
0665536995 Bug #46019: ERROR 1356 When selecting from within another
view that has Group By
      
Table access rights checking function check_grant() assumed
that no view is opened when it's called.
This is not true with nested views where the inner view
needs materialization. In this case the view is already 
materialized when check_grant() is called for it.
This caused check_grant() to not look for table level
grants on the materialized view table.
Fixed by checking if a view is already materialized and if 
it is check table level grants using the original table name
(not the ones of the materialized temp table).
2009-08-19 15:14:57 +03:00
Georgi Kodinov
def7b58466 automerge 2009-08-17 17:14:51 +03:00
Ramil Kalimullin
a6ddf8b18a Automerge 2009-08-14 14:13:16 +05:00
Davi Arnaut
1c2556ff46 Merge from mysql-5.0-bugteam. 2009-08-13 17:45:01 -03:00
Davi Arnaut
050c36c7de Bug#46013: rpl_extraColmaster_myisam fails on pb2
Bug#45243: crash on win in sql thread clear_tables_to_lock() -> free()
Bug#45242: crash on win in mysql_close() -> free()
Bug#45238: rpl_slave_skip, rpl_change_master failed (lost connection) for STOP SLAVE
Bug#46030: rpl_truncate_3innodb causes server crash on windows
Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2

When killing a user session on the server, it's necessary to
interrupt (notify) the thread associated with the session that
the connection is being killed so that the thread is woken up
if waiting for I/O. On a few platforms (Mac, Windows and HP-UX)
where the SIGNAL_WITH_VIO_CLOSE flag is defined, this interruption
procedure is to asynchronously close the underlying socket of
the connection.

In order to enable this schema, each connection serving thread
registers its VIO (I/O interface) so that other threads can
access it and close the connection. But only the owner thread of
the VIO might delete it as to guarantee that other threads won't
see freed memory (the thread unregisters the VIO before deleting
it). A side note: closing the socket introduces a harmless race
that might cause a thread attempt to read from a closed socket,
but this is deemed acceptable.

The problem is that this infrastructure was meant to only be used
by server threads, but the slave I/O thread was registering the
VIO of a mysql handle (a client API structure that represents a
connection to another server instance) as a active connection of
the thread. But under some circumstances such as network failures,
the client API might destroy the VIO associated with a handle at
will, yet the VIO wouldn't be properly unregistered. This could
lead to accesses to freed data if a thread attempted to kill a
slave I/O thread whose connection was already broken.

There was a attempt to work around this by checking whether
the socket was being interrupted, but this hack didn't work as
intended due to the aforementioned race -- attempting to read
from the socket would yield a "bad file descriptor" error.

The solution is to add a hook to the client API that is called
from the client code before the VIO of a handle is deleted.
This hook allows the slave I/O thread to detach the active vio
so it does not point to freed memory.

server-tools/instance-manager/mysql_connection.cc:
  Add stub method required for linking.
sql-common/client.c:
  Invoke hook.
sql/client_settings.h:
  Export hook.
sql/slave.cc:
  Introduce hook that clears the active VIO before it is freed
  by the client API.
2009-08-13 17:07:20 -03:00
Ramil Kalimullin
3b1280fa7e Fix for bug #46614: Assertion in show_create_trigger()
on SHOW CREATE TRIGGER + MERGE table

Problem: SHOW CREATE TRIGGER erroneously relies on fact
that we have the only underlying table for a trigger
(wrong for merge tables).

Fix: remove erroneous assert().


mysql-test/r/merge.result:
  Fix for bug #46614: Assertion in show_create_trigger() 
  on SHOW CREATE TRIGGER + MERGE table
    - test result.
mysql-test/t/merge.test:
  Fix for bug #46614: Assertion in show_create_trigger() 
  on SHOW CREATE TRIGGER + MERGE table
    - test case.
sql/sql_show.cc:
  Fix for bug #46614: Assertion in show_create_trigger() 
  on SHOW CREATE TRIGGER + MERGE table
    - unnecessary assert() removed as we may have more than 1 
  tables open e.g. for a merge table.
2009-08-14 00:49:28 +05:00
Alfranio Correia
78585a25ff BUG#46130 Slave does not correctly handle "expected errors"
In STATEMENT based replication, a statement that failed on the master but that
updated non-transactional tables is written to binary log with the error code
appended to it. On the slave, the statement is executed and the same error is
expected. However, when an "expected error" did not happen on the slave and was
either ignored or was related to a concurrency issue on the master, the slave
did not rollback the effects of the statement and as such inconsistencies might
happen.

To fix the problem, we automatically rollback a statement that should have
failed on a slave but succeded and whose expected failure is either ignored or
stems from a concurrency issue on the master.
2009-08-13 17:21:01 +01:00
unknown
fce4fa362c BUG#45574 CREATE IF NOT EXISTS is not binlogged if the object exists
There is an inconsistency with DROP DATABASE|TABLE|EVENT IF EXISTS and
CREATE DATABASE|TABLE|EVENT IF NOT EXISTS. DROP IF EXISTS statements are
binlogged even if either the DB, TABLE or EVENT does not exist. In
contrast, Only the CREATE EVENT IF NOT EXISTS is binlogged when the EVENT
exists.  

This patch fixes the following cases for all the replication formats:
CREATE DATABASE IF NOT EXISTS.
CREATE TABLE IF NOT EXISTS,
CREATE TABLE IF NOT EXISTS ... LIKE,
CREAET TABLE IF NOT EXISTS ... SELECT.

sql/sql_insert.cc:
  Part of the code was moved from the create_table_from_items to select_create::prepare.
  When replication is row based, CREATE TABLE IF NOT EXISTS.. SELECT is binlogged if the table exists.
2009-08-13 10:48:57 +08:00
Mattias Jonsson
89260b24c9 merge 2009-08-12 18:53:33 +02:00
Konstantin Osipov
b28f09bd8c A follow up patch for the follow up patch for Bug#45829
"CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, 
does nothing".

Put back stubs for members of structures that are shared between
sql/ and pluggable storage engines. to not break ABI unnecessarily.
To be NULL-merged into 5.4, where we do break the ABI already.
2009-08-12 17:11:06 +04:00
Konstantin Osipov
1402275a53 A follow up patch for Bug#45829 "CREATE TABLE TRANSACTIONAL
PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing"
Remove unused code that would lead to warnings when compiling
sql_yacc.yy.


sql/handler.h:
  Remove unused defines.
sql/sql_yacc.yy:
  Remove unused grammar.
sql/table.h:
  Remove unused TABLE members.
2009-08-12 14:57:41 +04:00
Mattias Jonsson
abc73040b5 manual merge 2009-08-12 12:03:05 +02:00
Mattias Jonsson
f09fc50004 merge 2009-08-12 11:46:08 +02:00
unknown
7b8d509b2d Manual Merge 2009-08-12 13:31:56 +08:00
unknown
0d821fafe9 BUG#45516 SQL thread does not use database charset properly
Replication SQL thread does not set database default charset to 
thd->variables.collation_database properly, when executing LOAD DATA binlog.
This bug can be repeated by using "LOAD DATA" command in STATEMENT mode.
        
This patch adds code to find the default character set of the current database 
then assign it to thd->db_charset when slave server begins to execute a relay log.
The test of this bug is added into rpl_loaddata_charset.test
2009-08-12 11:54:05 +08:00
Davi Arnaut
b928a3295c Merge from mysql-5.1-bugteam. 2009-08-11 11:29:07 -03:00
Sergey Vojtovich
24e418df69 Merge mysql-5.1-innodb_plugin to mysql-5.1. 2009-08-11 18:05:25 +05:00
Davi Arnaut
19b325499e Manual merge. 2009-08-10 15:46:20 -03:00
Martin Hansson
527e5fd3a2 Merge 2009-08-10 16:08:51 +02:00
Davi Arnaut
c7163c630a Bug#45010: invalid memory reads during parsing some strange statements
The problem is that the lexer could inadvertently skip over the
end of a query being parsed if it encountered a malformed multibyte
character. A specially crated query string could cause the lexer
to jump up to six bytes past the end of the query buffer. Another
problem was that the laxer could use unfiltered user input as
a signed array index for the parser maps (having upper and lower
bounds 0 and 256 respectively).

The solution is to ensure that the lexer only skips over well-formed
multibyte characters and that the index value of the parser maps
is always a unsigned value.

mysql-test/r/ctype_recoding.result:
  Update test case result: ending backtick is not skipped over anymore.
sql/sql_lex.cc:
  Characters being analyzed must be unsigned as they can be
  used as indexes for the parser maps. Only skip over if the
  string is a valid multi-byte sequence.
tests/mysql_client_test.c:
  Add test case for Bug#45010
2009-08-07 23:32:01 -03:00
Mattias Jonsson
f42fab1b76 Bug#32430: 'show innodb status' causes errors
Invalid (old?) table or database name in logs

Post push patch.

Bug was that a non partitioned table file was not
converted to system_charset, (due to table_name_len was not set).

Also missing DBUG_RETURN.

And Innodb adds quotes after calling the function,
so I added one more mode where explain_filename does not
add quotes. But it still appends the [sub]partition name
as a comment.

Also caught a minor quoting bug, the character '`' was
not quoted in the identifier. (so 'a`b' was quoted as `a`b`
and not `a``b`, this is mulitbyte characters aware.)

sql/mysql_priv.h:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Added an unquoted mode
sql/share/errmsg.txt:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Removed the quoting of identifier, only leaving the translated word.
sql/sql_table.cc:
  Bug#32430: 'show innodb status' causes errors
  Invalid (old?) table or database name in logs
  
  Fixed quoting of '`'
  Added DBUG_RETURN.
  Corrected table_name_len.
  Added unquoted mode.
2009-08-07 15:08:32 +02:00
Martin Hansson
4c3917b6f8 Bug#46454: MySQL wrong index optimisation leads to incorrect result & crashes
Problem 1:
When the 'Using index' optimization is used, the optimizer may still - after
cost-based optimization - decide to use another index in order to avoid using
a temporary table. But when this happens, the flag to the storage engine to 
read index only (not table) was still set. Fixed by resetting the flag in the 
storage engine and TABLE structure in the above scenario, unless the new index
allows for the same optimization.
Problem 2:
When a 'ref' access method was employed by cost-based optimizer, (when the column
is non-NULLable), it was assumed that it needed no initialization if 'quick' access
methods (since they are based on range scan). When ORDER BY optimization overrides 
the decision, however, it expects to have this initialized and hence crashes. 
Fixed in 5.1 (was fixed in 6.0 already) by initializing 'quick' even when there's 
'ref' access. 

mysql-test/r/order_by.result:
  Bug#46454: Test result.
mysql-test/t/order_by.test:
  Bug#46454: Test case.
sql/sql_select.cc:
  Bug#46454: 
  Problem 1 fixed in make_join_select()
  Problem 2 fixed in test_if_skip_sort_order()
sql/table.h:
  Bug#46454: Added comment to field.
2009-08-07 13:51:40 +02:00
Ignacio Galarza
466847a0b8 Auto-merge 2009-08-06 10:54:53 -04:00
Ignacio Galarza
a791f20089 Bug #27535 Installing Windows service with --defaults-file option - quotation marks issues
- Remove offensive quotes.
2009-08-06 10:24:28 -04:00
Mattias Jonsson
dd10de57d3 Bug#46478: timestamp field incorrectly defaulted
when partition is reoganized.

Problem was that table->timestamp_field_type was not changed
before copying rows between partitions.

fixed by setting it to TIMESTAMP_NO_AUTO_SET as the first thing
in fast_alter_partition_table, so that all if-branches is covered.
2009-08-06 14:28:39 +02:00
Satya B
d933cb1669 Fix for BUG#45816 - assertion failure with index containing double
column on partitioned table
      
      
An assertion 'ASSERT_COULUMN_MARKED_FOR_READ' is failed if the query 
is executed with index containing double column on partitioned table.
The problem is that assertion expects all the fields which are read,
to be in the read_set.
      
In this query only the field 'a' is in the readset as the tables in
the query are joined by the field 'a' and so the assertion fails 
expecting other field 'b'.
      
Since the function cmp() is just comparison of two parameters passed, 
the assertion is not required.
      
Fixed by removing the assertion in the double fields comparision
function and also fixed the index initialization to do ordered
index scan with RW LOCK which ensures all the fields from a key are in
the read_set.
 

Note: this bug is not reproducible with other datatypes because the
      assertion doesn't exist in comparision function for other 
      datatypes.

mysql-test/r/partition.result:
  Testcase for BUG#45816
mysql-test/t/partition.test:
  Testcase for BUG#45816
sql/field.cc:
  Removed the assertion ASSERT_COLUMN_MARED_FOR_READ in Field_double::cmp()
  function
sql/ha_partition.cc:
  Fixed index_int() method to make it initialize the read_set properly if
  ordered index scan with RW lock is requested.
2009-08-06 17:01:26 +05:30
Davi Arnaut
439e1eb0e0 Backport Tomas Ulin fix for a spurious failure on PushBuild:
http://lists.mysql.com/commits/53569

sql/ha_ndbcluster_binlog.cc:
  Remove extraneous mutex lock which could cause the server to deadlock.
2009-08-01 18:24:20 -03:00
Ignacio Galarza
276d3dd228 Auto-merge 2009-07-31 16:33:09 -04:00
Tatiana A. Nurnberg
e26350e000 auto-merge 2009-07-31 21:58:40 +02:00
Ignacio Galarza
008dd95f70 Auto-merge 2009-07-31 15:28:15 -04:00
Ignacio Galarza
09877515f2 Bug#17270 - mysql client tool could not find ../share/charsets folder and fails.
- Define and pass compile time path variables as pre-processor definitions to 
  mimic the makefile build.
- Set new CMake version and policy requirements explicitly.
- Changed DATADIR to MYSQL_DATADIR to avoid conflicting definition in 
  Platform SDK header ObjIdl.h which also defines DATADIR.
2009-07-31 15:22:02 -04:00
Gleb Shchepa
4e95179af9 Bug# 30946: mysqldump silently ignores --default-character-set
when used with --tab

1) New syntax: added CHARACTER SET clause to the
  SELECT ... INTO OUTFILE (to complement the same clause in
  LOAD DATA INFILE).
  mysqldump is updated to use this in --tab mode.

2) ESCAPED BY/ENCLOSED BY field parameters are documented as
   accepting CHAR argument, however SELECT .. INTO OUTFILE
   silently ignored rests of multisymbol arguments.
   For the symmetrical behavior with LOAD DATA INFILE the
   server has been modified to fail with the same error:

     ERROR 42000: Field separator argument is not what is
                  expected; check the manual

3) Current LOAD DATA INFILE recognizes field/line separators
   "as is" without converting from client charset to data
   file charset. So, it is supposed, that input file of
   LOAD DATA INFILE consists of data in one charset and
   separators in other charset. For the compatibility with
   that [buggy] behaviour SELECT INTO OUTFILE implementation
   has been saved "as is" too, but the new warning message
   has been added:

     Non-ASCII separator arguments are not fully supported

   This message warns on field/line separators that contain
   non-ASCII symbols.


client/mysqldump.c:
  mysqldump has been updated to call SELECT ... INTO OUTFILE
  statement with a charset from the --default-charset command
  line parameter.
mysql-test/r/mysqldump.result:
  Added test case for bug #30946.
mysql-test/r/outfile_loaddata.result:
  Added test case for bug #30946.
mysql-test/t/mysqldump.test:
  Added test case for bug #30946.
mysql-test/t/outfile_loaddata.test:
  Added test case for bug #30946.
sql/field.cc:
  String conversion code has been moved from check_string_copy_error()
  to convert_to_printable() for reuse.
sql/share/errmsg.txt:
  New WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED message has been added.
sql/sql_class.cc:
  The select_export::prepare() method has been modified to:
  
    1) raise the ER_WRONG_FIELD_TERMINATORS error on multisymbol
       ENCLOSED BY/ESCAPED BY field arguments like LOAD DATA INFILE;
  
    2) warn with a new WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED
       message on non-ASCII field or line separators.
  
  The select_export::send_data() merhod has been modified to
  convert item data to output charset (see new SELECT INTO OUTFILE
  syntax). By default the BINARY charset is used for backward
  compatibility.
sql/sql_class.h:
  The select_export::write_cs field added to keep output
  charset.
sql/sql_load.cc:
  mysql_load has been modified to warn on non-ASCII field or
  line separators with a new WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED
  message.
sql/sql_string.cc:
  New global function has been added: convert_to_printable()
  (common code has been moved from check_string_copy_error()).
sql/sql_string.h:
  New String::is_ascii() method and new global convert_to_printable()
  function have been added.
sql/sql_yacc.yy:
  New syntax: added CHARACTER SET clause to the
  SELECT ... INTO OUTFILE (to complement the same clause in
  LOAD DATA INFILE). By default the BINARY charset is used for
  backward compatibility.
2009-07-31 22:14:52 +05:00
Davi Arnaut
7d8b967a86 Bug#46265: Can not disable warning about unsafe statements for binary logging
If using statement based replication (SBR), repeatedly calling
statements which are unsafe for SBR will cause a warning message
to be written to the error for each statement. This might lead
to filling up the error log and there is no way to disable this
behavior.

The solution is to only log these message (about statements unsafe
for statement based replication) if the log_warnings option is set.

For example:

SET GLOBAL LOG_WARNINGS = 0;
INSERT INTO t1 VALUES(UUID());
SET GLOBAL LOG_WARNINGS = 1;
INSERT INTO t1 VALUES(UUID());

In this case the message will be printed only once:

[Warning] Statement may not be safe to log in statement format.
          Statement: INSERT INTO t1 VALUES(UUID())

mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
  Add test case result for Bug#46265
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt:
  Make log_error value available.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
  Add test case for Bug#46265
sql/sql_class.cc:
  Print warning only if the log_warnings is enabled.
2009-07-31 10:00:35 -03:00
Tatiana A. Nurnberg
717d6054f5 Bug#40281, partitioning the general log table crashes the server
We disallow the partitioning of a log table. You could however
partition a table first, and then point logging to it. This is
not only against the docs, it also crashes the server.

We catch this case now.

mysql-test/r/partition.result:
  results for 40281
mysql-test/t/partition.test:
  test for 40281: show that trying to log to partitioned table fails rather
  to crash the server
sql/ha_partition.cc:
  Signal that we no longer support logging to partitioned tables,
  as per the docs.
sql/sql_partition.cc:
  Some commands like "USE ..." have no select, yet we may try
  to parse partition info after their execution if user set a
  partitioned table as log target. This shouldn't lead to a
  NULL-deref/crash.
2009-07-31 14:38:18 +02:00
Davi Arnaut
88780b03b9 Bug#43435: LOCK_open does not use MY_MUTEX_INIT_FAST
Initialize LOCK_open as a adapative mutex on platforms where the
PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP macro is available. The flag
indicates that a thread should spin (busy wait) for some time on a
locked adaptive mutex before blocking (sleeping). It's intended to
to alleviate performance problems due to LOCK_open being a highly
contended mutex.

sql/mysqld.cc:
  Initialize LOCK_open as a adapative mutex.
2009-07-30 17:52:42 -03:00
Davi Arnaut
c8e67f4a3f Manual merge. 2009-07-30 16:11:39 -03:00
Kristofer Pettersson
0497f0c2a9 auto-merge 2009-07-29 22:27:43 +02:00
Kristofer Pettersson
fc1acef6b2 Bug#44521 Executing a stored procedure as a prepared statement can sometimes cause
an assertion in a debug build.

The reason is that the C API doesn't support multiple result sets for prepared
statements and attempting to execute a stored routine which returns multiple result
sets sometimes lead to a network error. The network error sets the diagnostic area
prematurely which later leads to the assert when an attempt is made to set a second
server state.

This patch fixes the issue by changing the scope of the error code returned by
sp_instr_stmt::execute() to include any error which happened during the execution.
To assure that Diagnostic_area::is_sent really mean that the message was sent all
network related functions are checked for return status.

libmysqld/lib_sql.cc:
  * Changed prototype to return success/failure status on net_send_error_packet(),
    net_send_ok(), net_send_eof(), write_eof_packet().
mysql-test/r/sp_notembedded.result:
  * Added test case for bug 44521
mysql-test/t/sp_notembedded.test:
  * Added test case for bug 44521
sql/protocol.cc:
  * Changed prototype to return success/failure status on net_send_error_packet(),
    net_send_ok(), net_send_eof(), write_eof_packet().
sql/protocol.h:
  * Changed prototype to return success/failure status on net_send_error_packet(),
    net_send_ok(), net_send_eof(), write_eof_packet().
sql/sp_head.cc:
  * Changed prototype to return success/failure status on net_send_error_packet(),
    net_send_ok(), net_send_eof(), write_eof_packet().
2009-07-29 22:07:08 +02:00
Mikael Ronstrom
2c38ed0d1c Auto-merge latest changes from mysql-5.1-bugteam 2009-07-29 17:58:27 +02:00
Mikael Ronstrom
a8e7535e33 Bug#46354, when defining partitions without subpartition definition after defining it with the first partition and using list partition caused crash, fixed by more error checks in parser 2009-07-29 17:56:32 +02:00
Guilhem Bichot
79283b61ca removing unused array (compiler warning) 2009-07-29 16:58:31 +02:00
Guilhem Bichot
a58b887c17 Bug#45829 "CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing":
those keywords do nothing in 5.1 (they are meant for future versions, for example featuring the Maria engine)
so they are here removed from the syntax. Adding those keywords to future versions when needed is:
- WL#5034 "Add TRANSACTIONA=0|1 and PAGE_CHECKSUM=0|1 clauses to CREATE TABLE"
- WL#5037 "New ROW_FORMAT value for CREATE TABLE: PAGE"

mysql-test/r/create.result:
  test that syntax is not accepted
mysql-test/t/create.test:
  test that syntax is not accepted
sql/handler.cc:
  remove ROW_FORMAT=PAGE
sql/handler.h:
  Mark unused objects, but I don't remove them by fear of breaking any plugin which includes this file
  (see also table.h)
sql/lex.h:
  removing syntax
sql/sql_show.cc:
  removing output of noise keywords in SHOW CREATE TABLE and INFORMATION_SCHEMA.TABLES
sql/sql_table.cc:
  removing TRANSACTIONAL
sql/sql_yacc.yy:
  removing syntax
sql/table.cc:
  removing TRANSACTIONAL, PAGE_CHECKSUM. Their place in the frm file is not reclaimed,
  for compatibility with older 5.1.
sql/table.h:
  Mark unused objects, but I don't remove them by fear of breaking any plugin which includes this file
  (and there are several engines which use the content TABLE_SHARE and thus rely on a certain binary
  layout of this structure).
2009-07-29 10:54:20 +02:00
Alfranio Correia
d871bef758 auto-merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-07-28 23:39:58 +01:00
Alexey Kopytov
fd3b0066f9 Automerge. 2009-07-28 23:14:24 +04:00
Alexey Kopytov
f9437bd769 Manual merge. 2009-07-28 22:44:28 +04:00
Alexey Kopytov
baefaa1e58 Bug #45031: invalid memory reads in my_real_read using protocol
compression 
 
Since uint3korr() may read 4 bytes depending on build flags and 
platform, allocate 1 extra "safety" byte in the network buffer 
for cases when uint3korr() in my_real_read() is called to read
last 3 bytes in the buffer. 
 
It is practically hard to construct a reliable and reasonably 
small test case for this bug as that would require constructing 
input stream such that a certain sequence of bytes in a 
compressed packet happens to be the last 3 bytes of the network 
buffer. 


sql/net_serv.cc:
  Allocate 1 extra "safety" byte in the network buffer for cases 
  when uint3korr() is used to read last 3 bytes in the buffer.
2009-07-28 22:35:55 +04:00
Alfranio Correia
043e09b543 BUG#41166 stored function requires "deterministic" if binlog_format is "statement"
If the log_bin_trust_function_creators option is not defined, creating a stored
function requires either one of the modifiers DETERMINISTIC, NO SQL, or READS
SQL DATA. Executing a stored function should also follows the same rules if in
STATEMENT mode. However, this was not happening and a wrong error was being
printed out: ER_BINLOG_ROW_RBR_TO_SBR.

The patch makes the creation and execution compatible and prints out the correct
error ER_BINLOG_UNSAFE_ROUTINE when a stored function without one of the modifiers
above is executed in STATEMENT mode.
2009-07-28 18:44:38 +01:00
Davi Arnaut
e265609834 Bug#46385: [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted t
The maximum value of the max_join_size variable is set by converting
a signed type (long int) with negative value (-1) to a wider unsigned
type (unsigned long long), which yields the largest possible value of
the wider unsigned type -- as per the language conversion rules. But,
depending on build options, the type of the max_join_size might be a
shorter type (ha_rows - unsigned long) which causes the warning to be
thrown once the large value is truncated to fit.

The solution is to ensure that the maximum value of the variable is
always set to the maximum value of integer type of max_join_size.

Furthermore, it would be interesting to always have a fixed type for
this variable, but this would incur in a change of behavior which is
not acceptable for a GA version. See Bug#35346.

sql/mysqld.cc:
  Set max value for type.
2009-07-27 20:31:48 -03:00
Alexey Kopytov
bac18522e6 Automerge. 2009-07-28 23:14:04 +04:00
Satya B
2478d51032 merging with mysql-5.1-bugteam branch 2009-07-27 11:50:13 +05:30
Satya B
e8a97ae267 merging with mysql-5.0-bugteam 2009-07-27 11:49:28 +05:30
Luis Soares
cf505e4494 BUG#43046: mixed mode switch to row format with temp table lead
to wrong result
      
When using MIXED mode and issuing 'CREATE TEMPORARY TABLE t_tmp',
the statement is logged if the current binlogging mode is
STATEMENT. This causes the slave to replay the instruction and
create the temporary table as well. If there is no switch to ROW
mode, and later on a 'DROP TEMPORARY TABLE t_tmp' is issued, then
this statement will also be logged and the slave will
remove/close the temporary table.
      
However, if there is a switch to ROW mode between the CREATE and
DROP TEMPORARY table, the DROP statement will not be logged,
leaving the slave with a dangling temporary table.
      
This patch addresses this, by always logging a DROP TEMPORARY
TABLE IF EXISTS when in mixed mode and a drop statement is issued
for temporary table(s).

mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result:
  Updated result file.
mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test:
  Added test case.
sql/sql_table.cc:
  When dropping table(s) in mixed mode and current statement 
  logging is ROW, builds an extra DROP TEMPORARY TABLE IF 
  EXISTS for temporary tables that are being dropped. Later, 
  it logs the extra drop statement.
2009-07-26 22:48:24 +01:00
Davi Arnaut
8ec2f3d0d1 Bug#43587: Putting event_scheduler=1 in init SQL file crashes
mysqld

The problem was that enabling the event scheduler inside a init
file caused the server to crash upon start-up. The crash occurred
because the event scheduler wasn't being initialized before the
commands in the init-file are processed.

The solution is to initialize the event scheduler before the init
file is read. The patch also disables the event scheduler during
bootstrap and makes the bootstrap operation robust in the
presence of background threads.

mysql-test/std_data/init_file.dat:
  Add test case for Bug#43587
sql/event_scheduler.cc:
  Signal that the thread_count has been decremented.
sql/events.cc:
  Disable the event scheduler during bootstrap.
sql/mysql_priv.h:
  Export variable.
sql/mysqld.cc:
  Initialize the event scheduler before commands are executed.
sql/sql_parse.cc:
  Signal that the bootstrap thread is done.
2009-07-24 15:45:42 -03:00
Konstantin Osipov
b4bf7dd31e Code review for Bug#43587 Putting event_scheduler=1 in init SQL file crashes
mysqld
2009-07-24 20:20:46 +04:00
Gleb Shchepa
2bc6b6a800 Merge from 5.0
******
manual merge 5.0-bugteam --> 5.1-bugteam (bug 38816)
2009-07-24 21:04:55 +05:00
Gleb Shchepa
dc0a87fdc2 Bug #38816: kill + flush tables with read lock + stored
procedures causes crashes!

The problem of that bugreport was mostly fixed by the
patch for bug 38691.
However, attached test case focused on another crash or
valgrind warning problem: SHOW PROCESSLIST query accesses
freed memory of SP instruction that run in a parallel
connection.

Changes of thd->query/thd->query_length in dangerous
places have been guarded with the per-thread
LOCK_thd_data mutex (the THD::LOCK_delete mutex has been
renamed to THD::LOCK_thd_data).


sql/ha_myisam.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Modification of THD::query/query_length has been guarded
  with the a THD::set_query() method call/LOCK_thd_data
  mutex.
  Unnecessary locking with the global LOCK_thread_count
  mutex has been removed.
sql/log_event.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Modification of THD::query/query_length has been guarded
  with the THD::set_query()) method call/LOCK_thd_data
  mutex.
sql/slave.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Modification of THD::query/query_length has been guarded
  with the THD::set_query() method call/LOCK_thd_data mutex.
  
  The THD::LOCK_delete mutex has been renamed to
  THD::LOCK_thd_data.
sql/sp_head.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Modification of THD::query/query_length has been guarded
  with the a THD::set_query() method call/LOCK_thd_data
  mutex.
sql/sql_class.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  The new THD::LOCK_thd_data mutex and THD::set_query()
  method has been added to guard modifications of THD::query/
  THD::query_length fields, also the Statement::set_statement()
  method has been overloaded in the THD class.
  
  The THD::LOCK_delete mutex has been renamed to
  THD::LOCK_thd_data.
sql/sql_class.h:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  The new THD::LOCK_thd_data mutex and THD::set_query()
  method has been added to guard modifications of THD::query/
  THD::query_length fields, also the Statement::set_statement()
  method has been overloaded in the THD class.
  
  The THD::LOCK_delete mutex has been renamed to
  THD::LOCK_thd_data.
sql/sql_insert.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Modification of THD::query/query_length has been guarded
  with the a THD::set_query() method call/LOCK_thd_data
  mutex.
sql/sql_parse.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Modification of THD::query/query_length has been guarded
  with the a THD::set_query() method call/LOCK_thd_data mutex.
sql/sql_repl.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  The THD::LOCK_delete mutex has been renamed to
  THD::LOCK_thd_data.
sql/sql_show.cc:
  Bug #38816: kill + flush tables with read lock + stored
              procedures causes crashes!
  
  Inter-thread read of THD::query/query_length field has
  been protected with a new per-thread LOCK_thd_data
  mutex in the mysqld_list_processes function.
2009-07-24 20:58:58 +05:00
Alexey Kopytov
8b4352782a Automerge. 2009-07-24 16:14:14 +04:00
Alexey Kopytov
85c97e6c69 Automerge. 2009-07-24 16:13:31 +04:00
Alexey Kopytov
498dc4d32d Manual merge. 2009-07-24 16:09:35 +04:00
Alexey Kopytov
885292e424 Bug #46075: Assertion failed: 0, file .\protocol.cc, line 416
In create_myisam_from_heap() mark all errors as fatal except 
HA_ERR_RECORD_FILE_FULL for a HEAP table.

Not doing so could lead to problems, e.g. in a case when a
temporary MyISAM table gets overrun due to its MAX_ROWS limit
while executing INSERT/REPLACE IGNORE ... SELECT. 
The SELECT execution was aborted, but the error was 
converted to a warning due to IGNORE clause, so neither 'ok' 
nor 'error' packet could be sent back to the client. This 
condition led to hanging client when using 5.0 server, or 
assertion failure in 5.1.


mysql-test/r/insert_select.result:
  Added a test case for bug #46075.
mysql-test/t/insert_select.test:
  Added a test case for bug #46075.
sql/sql_select.cc:
  In create_myisam_from_heap() mark all errors as fatal except 
  HA_ERR_RECORD_FILE_FULL for a HEAP table.
2009-07-24 15:50:45 +04:00
Anurag Shekhar
0498988b48 Bug#30102: Rename table does corrupt tables with partition files on failure
Problem was that a failing rename just left the partitions at the state
it was at the failure.

Solution was to try to revert the started rename if a failure occured.

mysql-test/r/partition_not_embedded.result:
  Bug#30102: Rename table does corrupt tables with partition files on failure
  
  New result file
mysql-test/t/partition_not_embedded.test:
  Bug#30102: Rename table does corrupt tables with partition files on failure
  
  New test file
  (list_files does not report the files in embedded)
sql/ha_partition.cc:
  Bug#30102: Rename table does corrupt tables with partition files on failure
  
  Better error handling for rename partitions (reverting the started rename
  operation)
  
  Different order of files for delete.
sql/handler.cc:
  Bug#30102: Rename table does corrupt tables with partition files on failure
  
  Tries to remove as many table files as possible
  if the first delete succeeds.
2009-07-24 15:41:23 +05:30
Satya B
30441aeadf merge 5.0-bugteam to 5.1-bugteam 2009-07-24 12:15:06 +05:30
Satya B
559e2f1c1e merge to mysql-5.0-bugteam 2009-07-24 11:15:31 +05:30
Bjorn Munch
a80bd0b5d7 Bug #46212 safe_process: FATAL ERROR, Unknown option: --nocore
Also fixed mysqld.cc to avoid popup-boxes
2009-07-23 19:01:24 +02:00
Staale Smedseng
9c708fdf1e Merge from 5.0 2009-07-23 13:53:28 +02:00
Staale Smedseng
1e32574c65 Bug #45770 errors reading server SSL files are printed, but
not logged
        
Errors encountered during initialization of the SSL subsystem
are printed to stderr, rather than to the error log.
        
This patch adds a parameter to several SSL init functions to
report the error (if any) out to the caller. The function
init_ssl() in mysqld.cc is moved after the initialization of
the log subsystem, so that any error messages can be logged to
the error log. Printing of messages to stderr has been 
retained to get diagnostic output in a client context.


include/violite.h:
  Adding an enumeration for the various errors that can
  occur during initialization of the SSL module.
sql/mysqld.cc:
  Adding more logging of SSL init errors, and moving
  init_ssl() till after initialization of logging 
  subsystem.
vio/viosslfactories.c:
  Define error strings, provide an access method for these
  strings, and maintain an error parameter in several funcs
  to return the error (if any) to the caller.
2009-07-23 13:38:11 +02:00
Konstantin Osipov
2d716209e6 Add a comment for thd->proc_info. 2009-07-22 13:44:19 +04:00
Evgeny Potemkin
381ca8f58d auto-merge mysql-5.1-bugteam (local) -> mysql-5.1-bugteam. 2009-07-19 16:58:02 +04:00
Evgeny Potemkin
bc016c54ca Merged fix for the bug#46051. 2009-07-19 16:49:40 +04:00
Alfranio Correia
216b2fbf6a auto-merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-07-19 09:19:15 +01:00
Alfranio Correia
f16fe16db0 BUG#46129 Failing mixed stm (with trans and non-trans tables) causes wrong seq in
binlog
      
The fix for BUG 43929 introduced a regression issue. In a nutshell, when a
statement that changes a non-transactional table fails, it is written to the
binary log with the error code appended. Unfortunately, after BUG 43929, this
failure was flushing the transactional chace causing mismatch between execution
and logging histories. To fix this issue, we avoid flushing the transactional
cache when a commit or rollback is not issued.
2009-07-18 21:07:56 +01:00
Evgeny Potemkin
dbe855d0e3 Merged corrected fix for the bug#46051. 2009-07-18 18:11:33 +04:00
Evgeny Potemkin
5032380084 Bug#46051: Incorrectly market field caused wrong result.
When during the optimization an item is moved to the upper select
the item's context left unchanged. This caused wrong result in the 
PS/SP mode.
The Item_ident::remove_dependence_processor now sets the context
of the select to which the item is moved to.

mysql-test/r/subselect.result:
  The test case for the bug#46051 is adjusted.
mysql-test/t/subselect.test:
  The test case for the bug#46051 is adjusted.
sql/item.cc:
  Bug#46051: Incorrectly market field caused wrong result.
  The Item_ident::remove_dependence_processor now sets the context
  of the select to which the item is moved to.
2009-07-18 18:09:56 +04:00
Evgeny Potemkin
a50270a912 Merged fix for the bug#46051. 2009-07-17 18:45:32 +04:00
Satya B
342553252f Fix for BUG#18828 - If InnoDB runs out of undo slots,
it returns misleading 'table is full'

Innodb returns a misleading error message "table is full" 
when the number of active concurrent transactions is greater
than 1024.

Fixed by adding errorcode "ER_TOO_MANY_CONCURRENT_TRXS" to the
error codes. Innodb should return HA_TOO_MANY_CONCURRENT_TRXS
to mysql which is then mapped to ER_TOO_MANY_CONCURRENT_TRXS


Note: testcase is not written as this was reproducible only by
      changing innodb code.

extra/perror.c:
  Add error number and message for HA_ERR_TOO_MANY_CONCURRENT_TRXS
include/my_base.h:
  Add error number and message for HA_ERR_TOO_MANY_CONCURRENT_TRXS
sql/ha_innodb.cc:
  Return HA_ERR_TOO_MANY_CONCURRENT_TRXS to mysql server
sql/handler.cc:
  Add error number and message for HA_ERR_TOO_MANY_CONCURRENT_TRXS
sql/share/errmsg.txt:
  Add error message for ER_TOO_MANY_CONCURRENT_TRXS
2009-07-17 14:13:53 +05:30
unknown
b6b5689549 Bug #45214 get_master_version_and_clock does not report error when queries fail
Append the patch for resolving the problems, which have been brought by commiting bug#45214.
2009-07-17 13:07:43 +08:00
unknown
ba58eaf016 Auto merge 2009-07-17 10:59:17 +08:00
Evgeny Potemkin
63e6a59d73 Bug#46051: Incorrectly market field caused wrong result.
In a subselect all fields from outer selects are marked as dependent on
selects they are belong to. In some cases optimizer substitutes it for an
equivalent expression. For example "a_field IN (SELECT outer_field)" is
substituted with "a_field = outer_field". As we moved the outer_field to the
upper select it's not really outer anymore. But it was left marked as outer.
If exists an index over a_field optimizer choose wrong execution plan and thus
return wrong result.

Now the Item_in_subselect::single_value_transformer function removes dependent
marking from fields when a subselect is optimized away.

mysql-test/r/subselect.result:
  Added a test case for the bug#46051.
mysql-test/t/subselect.test:
  Added a test case for the bug#46051.
sql/item_subselect.cc:
  Bug#46051: Incorrectly market field caused wrong result.
  Now the Item_in_subselect::single_value_transformer function removes dependent
  marking from fields when a subselect is optimized away.
2009-07-16 19:43:46 +04:00
Georgi Kodinov
760efb5188 automerge 2009-07-16 16:17:47 +03:00
Georgi Kodinov
7a91bf8c91 Bug #46003 and bug #46034: backported the fixes from azalea. 2009-07-16 15:19:22 +03:00
Kristofer Pettersson
57a4275d5c Automerge 2009-07-16 10:03:51 +02:00
Georgi Kodinov
88408fabb9 automerge 2009-07-16 10:33:13 +03:00
Georgi Kodinov
473dfa6808 automerge 2009-07-16 10:31:00 +03:00
unknown
aa4b8939a0 Bug #45214 get_master_version_and_clock does not report error when queries fail
The "get_master_version_and_clock(...)" function in sql/slave.cc ignores 
error and passes directly when queries fail, or queries succeed 
but the result retrieved is empty.
  
The "get_master_version_and_clock(...)" function should try to reconnect master
if queries fail because of transient network problems, and fail otherwise.
The I/O thread should print a warning if the some system variables do not 
exist on master (very old master)

mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test:
  Added test file for bug #45214
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result:
  Added test result for bug #45214
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test:
  Added test file for bug #45214
sql/slave.cc:
  The 'is_network_error()' function is added for checking if the error is caused by network.
  Added a new return value (2) to 'get_master_version_and_clock()' function result set 
  to indicate transient network errors when queries fail, and the caller should 
  try to reconnect in this case.
2009-07-16 14:56:43 +08:00
Kristofer Pettersson
fae95a4933 Bug#45781 infinite hang/crash in "opening tables" after handler tries to open merge
table

The MERGE table storage engine does not support the HA_CAN_SQL_HANDLE feature
and any attempt to open the merge table will fail with ER_ILLEGAL_HA.

After an error occurred the tables that was opened must be closed again
or they will be left in an inconsistent state. However, the assumption
made in the code for closing and register handler tables was that only
one table will be opened, and this is not true for MERGE tables which
will cause multiple tables to open.

The next time a SELECT operation was issued on the merge table it
caused the system to freeze.

This patch fixes this issue by making sure that all tables which
are opened also are closed in the event of an error.


mysql-test/r/merge.result:
  Added test case for bug 45781
mysql-test/t/merge.test:
  Added test case for bug 45781
sql/sql_handler.cc:
  * mysql_ha_open() was never ment to open more than one table. If we encounter more tables, we should
    close all tables related to the current substatement and raise an exception.
2009-07-16 01:23:57 +02:00
Davi Arnaut
5f9440d2a6 Bug#44495: Prepared Statement: CALL p(<x>) - `thd->protocol == &thd->protocol_text' failed
Merge Konstantin's patch and add a test case.

tests/mysql_client_test.c:
  Add test case for Bug#44495
2009-07-15 15:22:50 -03:00