Commit graph

22440 commits

Author SHA1 Message Date
unknown
e638e60589 test suite for LP bug#694450 2012-03-14 12:09:03 +02:00
Alexey Botchkov
620d62ac3e plugin.result fixed. 2012-03-14 09:40:54 +04:00
Chaithra Gopalareddy
e48afab412 Bug#12626844 : WE ARE NOT CHECKING VIEW TABLE NAMES
ENOUGH - CONCAT() HACKS. ALSO WRONG
               ERROR MESSAGE WHILE TRYING TO CREATE
               A VIEW ON A NON EXISTING DATABASE

PROBLEM:
The first part of the problem is concluded as not a
bug, as 'concat' is not a reserved word and it is
completely valid to create a view with the name
'concat'.

The second issue is, while trying to create a view on
a non existing database, we are not giving a proper error
message.

FIX:
We have added a check for the database existence while
trying to create a view. This check would give an error
as 'unknown database' when the database does not exist.

This patch is a backport of the patch for Bug#13601606


mysql-test/r/view.result:
  Added test case result of Bug#12626844
mysql-test/t/view.test:
  Added test case for Bug#12626844
sql/sql_view.cc:
  Added a check for database existence in mysql_create_view
2012-03-14 06:27:03 +05:30
Igor Babaev
0f3b8ef28e Merge. 2012-03-13 13:49:18 -07:00
Igor Babaev
c1f5e25c04 Fixed LP bug #953649.
Do not call, directly or indirectly, SQL_SELECT::test_quick_select()
for derived materialized tables / views when optimizing joins referring
to these tables / views to get cost estimates of materialization.
The current code does not create B-tree indexes for materialized 
derived tables / views. So now it's not possible to get any estimates
for ranges conditions over the results of the materialization.

The function mysql_derived_create() must take into account the fact
that array of the KEY structures specifying the keys over a derived
table / view may be moved after the optimization phase if the
derived table / view  is materialized.
2012-03-13 13:34:20 -07:00
Michael Widenius
6f06cef02b Fixed bug lp:917689 "Archive table corruption crashing MariaDB signal 11"
Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
Change ha_archive::unpack_row() to detect wrong field lengths.
Replication code changed to detect wrong field information in events.


mysql-test/r/archive.result:
  dded test case for lp:917689
sql/field.cc:
  Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
  Removed not used 'unpack_key' functions.
sql/field.h:
  Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
  Removed not used 'unpack_key' functions.
  Removed some not needed unpack() functions.
sql/filesort.cc:
  Added buffer end parameter to unpack_addon_fields()
sql/log_event.h:
  Added end of buffer argument to unpack_row()
sql/log_event_old.cc:
  Added end of buffer argument to unpack_row()
sql/log_event_old.h:
  Added end of buffer argument to unpack_row()
sql/records.cc:
  Added buffer end parameter to unpack_addon_fields()
sql/rpl_record.cc:
  Added end of buffer argument to unpack_row()
  Added detection of wrong field information in events
sql/rpl_record.h:
  Added end of buffer argument to unpack_row()
sql/rpl_record_old.cc:
  Added end of buffer argument to unpack_row()
  Added detection of wrong field information in events
sql/rpl_record_old.h:
  Added end of buffer argument to unpack_row()
sql/table.h:
  Added buffer end parameter to unpack()
storage/archive/ha_archive.cc:
  Change ha_archive::unpack_row() to detect wrong field lengths.
  This fixes lp:917689
2012-03-13 16:38:43 +02:00
Sergey Petrunya
50ff30d892 Merge 2012-03-12 18:08:40 +04:00
Sergey Petrunya
d028d986a9 BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization
- The bug would show up 
   - when using PS (so that we get re-execution)
   - the left_expr of the subquery is a reference to viewname.column_name, so that it crashes
      when one tries to use it without having called fix_fields for it.
   - when using SJ-Materialization, which makes use of sj_subq_pred->left_expr expression

- The fix is to have setup_conds() fix sj_subq_pred->left_expr for semi-join nests it finds.
2012-03-12 17:41:22 +04:00
Norvald H. Ryeng
1a2e4afe35 Merge 5.1 => 5.5. 2012-03-12 09:24:59 +01:00
Norvald H. Ryeng
ad031d5110 Bug#13031606 VALUES() IN A SELECT STATEMENT CRASHES SERVER
Problem: Grouping results by VALUES(alias for string literal) causes
the server to crash.

Item_insert_values is not constructed to handle other types of
arguments than field and reference to field. In this case, the
argument is an Item_string, and this causes
Item_insert_values::fix_fields() to crash.

Fix: Issue an error message when the argument to Item_insert_values is
not a field or a reference to a field.

This is slightly in breach with documentation, which states that
VALUES should return NULL, but the error message is only issued in
cases where the server otherwise would crash, so there is no change in
behavior for queries that already work. Future versions will restrict
syntax so that using VALUES in this way is illegal.


mysql-test/r/errors.result:
  Add test case for bug #13031606.
mysql-test/t/errors.test:
  Add test case for bug #13031606.
sql/item.cc:
  Issue error message if argument is not field or reference to field.
2012-03-12 08:56:56 +01:00
unknown
ecbd868f58 Merged the implementation of MDEV-28 LIMIT ROWS EXAMINED into MariaDB 5.5. 2012-03-12 00:45:18 +02:00
unknown
8aebd44e0e Implementation of MDEV-28 LIMIT ROWS EXAMINED
https://mariadb.atlassian.net/browse/MDEV-28
  
This task implements a new clause LIMIT ROWS EXAMINED <num>
as an extention to the ANSI LIMIT clause. This extension
allows to limit the number of rows and/or keys a query
would access (read and/or write) during query execution.
2012-03-11 14:39:20 +02:00
Dmitry Lenev
d2e447d57c Merged fix for a test case into 5.5 tree. 2012-03-11 16:11:08 +04:00
Dmitry Lenev
c48233c61e Fixed test case for bug #13105873 "valgrind warning:possible
crash in foreign key handling on subsequent create table if
not exists".

Do not leave current database unassigned after the end of
the test case.
2012-03-11 16:05:42 +04:00
Georgi Kodinov
bc7d8dc623 Bug #12408412: GROUP_CONCAT + ORDER BY + INPUT/OUTPUT SAME
USER VARIABLE = CRASH

Moved the preparation of the variables that receive the output from 
SELECT INTO from execution time (JOIN:execute) to compile time 
(JOIN::prepare). This ensures that if the same variable is used in the
SELECT part of SELECT INTO it will be properly marked as non-const
for this query.
Test case added.
Used proper fast iterator.
2012-03-09 15:04:49 +02:00
Sergei Golubchik
4933d21e5d merge with mysql-5.5.21 2012-03-09 08:06:59 +01:00
Igor Babaev
af7213d5d4 Fixed LP bug #884175.
If in the where clause of the a query some comparison conditions on the
field under a MIN/MAX aggregate function contained constants whose sizes
exceeded the size of the field then the query could return a wrong result
when the optimizer had chosen to apply the MIN/MAX optimization.
With such conditions the MIN/MAX optimization still could be applied, yet
it would require a more thorough analysis of the keys built to find
the value of MIN/MAX aggregate functions with index look-ups.   
The current patch just prohibits using the MIN/MAX optimization in this
situation.
2012-03-08 22:33:01 -08:00
Georgi Kodinov
9c366f7921 merge mysql-5.5->mysql-5.5-security 2012-03-08 17:19:54 +02:00
Georgi Kodinov
4b5306fd6e merge mysql-5.1->mysql-5.1-security 2012-03-08 17:16:53 +02:00
Sergei Golubchik
18c51eee35 5.3 merge 2012-03-06 20:46:07 +01:00
Igor Babaev
f92cfdb8a9 Merge. 2012-03-05 22:33:46 -08:00
Igor Babaev
04ee30e75a Fixed LP bug #946055.
The function create_hj_key_for_table() that builds the descriptor of
the hash join key to access a table of a materialized subquery must
ignore any equi-join predicate depending on the tables not belonging
to the subquery.
2012-03-05 20:32:28 -08:00
Sergei Golubchik
1c530b36d1 mdev-20: INSTALL PLUGIN SONAME 2012-03-05 21:48:06 +01:00
Michael Widenius
4ab7a33e1e Automatic merge 2012-03-05 22:00:24 +02:00
Ramil Kalimullin
d371d53945 Auto-merge from mysql-5.1-security. 2012-03-05 22:36:56 +04:00
Ramil Kalimullin
30d32207e7 BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN GEOMETRY FUNCTION ARGUMENTS
A defect in the subquery substitution code may lead to a server crash:
setting substitution's name should be followed by setting its length
(to keep them in sync).


mysql-test/r/gis.result:
  BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN GEOMETRY FUNCTION ARGUMENTS
    test result.
mysql-test/t/gis.test:
  BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN GEOMETRY FUNCTION ARGUMENTS
    test case.
sql/item_subselect.cc:
  BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN GEOMETRY FUNCTION ARGUMENTS
    set substitution's name length as well as the name itself (to keep them in sync).
2012-03-05 22:15:23 +04:00
Ramil Kalimullin
8aea62fa8a Fix for BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
Problem:      
lack of incoming geometry data validation may 
lead to a server crash when ISCLOSED() function called.

Solution:
necessary incoming data check added.


mysql-test/r/gis.result:
  Fix for BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
    test result.
mysql-test/t/gis.test:
  Fix for BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS 
    test case.
sql/spatial.cc:
  Fix for BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS 
    check if a LINESTRING has at least one point as we 
  rely on that further.
2012-03-05 21:58:07 +04:00
unknown
8a5940c477 Fix for LP BUG#944504
Problem is that subquery execution can't be called during prepare/optimize phase.

Also small fix for subquery test suite.
2012-03-05 15:48:12 +02:00
Igor Babaev
6f3c39a057 Fixed LP bug #944782.
This bug in the function JOIN::drop_unused_derived_keys() could
leave the internal structures for a materialized derived table
in an inconsistent state. This led to a not quite correct EXPLAIN
output when no additional key had been created to access the table.
It also may lead to more serious consequences: so, the test case
added with this fix caused a crash in mariadb-5.5.20.
2012-03-04 22:38:17 -08:00
Igor Babaev
f9db747b83 Merge 2012-03-02 22:52:03 -08:00
Igor Babaev
8bc5045ea3 Merge MWL #247 from mariadb 5.3 -> mariadb 5.5. 2012-03-02 15:03:20 -08:00
unknown
5d6989ea71 Merge MWL#234: @@skip_replication, into latest MariaDB 5.5 for push 2012-03-02 07:45:06 +01:00
Igor Babaev
8b469eb515 Merge 5.3->5.5. 2012-03-01 14:22:22 -08:00
Sergei Golubchik
29b0b0b5de misc test/result fixes
mysql-test/include/have_xtradb.combinations:
  xtradb tests need this I_S table
mysql-test/lib/mtr_cases.pm:
  fix for .deb and .rpm installations
2012-03-01 17:04:57 +01:00
unknown
22a504f897 Merge MWL#234: @@skip_replication feature to MariaDB 5.5. 2012-03-01 12:41:49 +01:00
Igor Babaev
000deedf3b Fixed LP bug #943543.
This bug appeared after the patch for bug 939009 that in the
function merge_key_fields forgot to reset a proper value for
the val field in the result of the merge operation of the key
field created for a regular key access and  the key field
created to look for a NULL key.

Adjusted the results of the test case for bug 939009 that
actually were incorrect.
2012-02-29 23:28:16 -08:00
Sergei Golubchik
e4bfb6f161 pbxt suite is now a main-pbxt overlay 2012-02-29 21:55:04 +01:00
Mattias Jonsson
645bddecaf merge from mysql-5.1 2012-02-29 21:18:50 +01:00
Mattias Jonsson
937ee6b7a0 merge into mysql-5.1 2012-02-29 20:51:38 +01:00
Praveenkumar Hulakund
cf2f97800e Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION
Analysis:
========================
sql_mode "NO_BACKSLASH_ESCAPES": When user want to use backslash as character input,
instead of escape character in a string literal then sql_mode can be set to 
"NO_BACKSLASH_ESCAPES". With this mode enabled, backslash becomes an ordinary 
character like any other. 

SQL_MODE set applies to the current client session. And while creating the stored 
procedure, MySQL stores the current sql_mode and always executes the stored 
procedure in sql_mode stored with the Procedure, regardless of the server SQL 
mode in effect when the routine is invoked.  

In the scenario (for which bug is reported), the routine is created with 
sql_mode=NO_BACKSLASH_ESCAPES. And routine is executed with the invoker sql_mode
is "" (NOT SET) by executing statement "call testp('Axel\'s')".
Since invoker sql_mode is "" (NOT_SET), the '\' in 'Axel\'s'(argument to function)
is considered as escape character and column "a" (of table "t1") values are 
updated with "Axel's". The binary log generated for above update operation is as below,

  set sql_mode=XXXXXX (for no_backslash_escapes)
  update test.t1 set a= NAME_CONST('var',_latin1'Axel\'s' COLLATE 'latin1_swedish_ci');

While logging stored procedure statements, the local variables (params) used in
statements are replaced with the NAME_CONST(var_name, var_value) (Internal function) 
(http://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_name-const)

On slave, these logs are applied. NAME_CONST is parsed to get the variable and its
value. Since, stored procedure is created with sql_mode="NO_BACKSLASH_ESCAPES", the sql_mode
is also logged in. So that at slave this sql_mode is set before executing the statements
of routine.  So at slave, sql_mode is set to "NO_BACKSLASH_ESCAPES" and then while
parsing NAME_CONST of string variable, '\' is considered as NON ESCAPE character
and parsing reported error for "'" (as we have only one "'" no backslash). 

At slave, parsing was proper with sql_mode "NO_BACKSLASH_ESCAPES".
But above error reported while writing bin log, "'" (of Axel's) is escaped with
"\" character. Actually, all special characters (n, r, ', ", \, 0...) are escaped
while writing NAME_CONST for string variable(param, local variable) in bin log 
irrespective of "NO_BACKSLASH_ESCAPES" sql_mode. So, basically, the problem is 
that logging string parameter does not take into account sql_mode value.

Fix:
========================
So when sql_mode is set to "NO_BACKSLASH_ESCAPES", escaping  characters as 
(n, r, ', ", \, 0...) should be avoided. To do so, added a check to not to
escape such characters while writing NAME_CONST for string variables in bin 
log. 
And when sql_mode is set to NO_BACKSLASH_ESCAPES, quote character "'" is
represented as ''.
http://dev.mysql.com/doc/refman/5.6/en/string-literals.html (There are several 
ways to include quote characters within a string: )
2012-02-29 14:52:08 +05:30
Praveenkumar Hulakund
c22c9270fb Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION
Analysis:
========================
sql_mode "NO_BACKSLASH_ESCAPES": When user want to use backslash as character input,
instead of escape character in a string literal then sql_mode can be set to 
"NO_BACKSLASH_ESCAPES". With this mode enabled, backslash becomes an ordinary 
character like any other. 

SQL_MODE set applies to the current client session. And while creating the stored 
procedure, MySQL stores the current sql_mode and always executes the stored 
procedure in sql_mode stored with the Procedure, regardless of the server SQL 
mode in effect when the routine is invoked.  

In the scenario (for which bug is reported), the routine is created with 
sql_mode=NO_BACKSLASH_ESCAPES. And routine is executed with the invoker sql_mode
is "" (NOT SET) by executing statement "call testp('Axel\'s')".
Since invoker sql_mode is "" (NOT_SET), the '\' in 'Axel\'s'(argument to function)
is considered as escape character and column "a" (of table "t1") values are 
updated with "Axel's". The binary log generated for above update operation is as below,

  set sql_mode=XXXXXX (for no_backslash_escapes)
  update test.t1 set a= NAME_CONST('var',_latin1'Axel\'s' COLLATE 'latin1_swedish_ci');

While logging stored procedure statements, the local variables (params) used in
statements are replaced with the NAME_CONST(var_name, var_value) (Internal function) 
(http://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_name-const)

On slave, these logs are applied. NAME_CONST is parsed to get the variable and its
value. Since, stored procedure is created with sql_mode="NO_BACKSLASH_ESCAPES", the sql_mode
is also logged in. So that at slave this sql_mode is set before executing the statements
of routine.  So at slave, sql_mode is set to "NO_BACKSLASH_ESCAPES" and then while
parsing NAME_CONST of string variable, '\' is considered as NON ESCAPE character
and parsing reported error for "'" (as we have only one "'" no backslash). 

At slave, parsing was proper with sql_mode "NO_BACKSLASH_ESCAPES".
But above error reported while writing bin log, "'" (of Axel's) is escaped with
"\" character. Actually, all special characters (n, r, ', ", \, 0...) are escaped
while writing NAME_CONST for string variable(param, local variable) in bin log 
Airrespective of "NO_BACKSLASH_ESCAPES" sql_mode. So, basically, the problem is 
that logging string parameter does not take into account sql_mode value.

Fix:
========================
So when sql_mode is set to "NO_BACKSLASH_ESCAPES", escaping  characters as 
(n, r, ', ", \, 0...) should be avoided. To do so, added a check to not to
escape such characters while writing NAME_CONST for string variables in bin 
log. 
And when sql_mode is set to NO_BACKSLASH_ESCAPES, quote character "'" is
represented as ''.
http://dev.mysql.com/doc/refman/5.6/en/string-literals.html (There are several 
ways to include quote characters within a string: )



mysql-test/r/sql_mode.result:
  Added test case for Bug#12601974.
mysql-test/suite/binlog/r/binlog_sql_mode.result:
  Appended result of test cases added for Bug#12601974.
mysql-test/suite/binlog/t/binlog_sql_mode.test:
  Added test case for Bug#12601974.
mysql-test/t/sql_mode.test:
  Appended result of test cases added for Bug#12601974.
2012-02-29 12:23:15 +05:30
Michael Widenius
e4e85cd2ef Fixed lp:925377 "Querying myisam table metadata while 'alter table..enable keys' is running may corrupt the table"
Fixed wrong mutex order bug in Aria when flush_log_for_bitmap() was called when table is not yet marked for change.

include/my_base.h:
  Added flag that table is opened only for status
mysql-test/r/myisam-big.result:
  Test case for lp:925377
mysql-test/t/myisam-big.test:
  Test case for lp:925377
sql/sql_base.cc:
  If thd->version == 0 (happens only when we are opening a table that is flushed under  MYSQL_LOCK_IGNORE_FLUSH), open the table in HA_OPEN_FOR_STATUS mode
storage/maria/ma_bitmap.c:
  Fixed wrong mutex order bug in Aria when flush_log_for_bitmap() was called when table is not yet marked for change.
storage/maria/ma_dbug.c:
  Ignore last_version <= 1 as these are either flushed or only opened for status
storage/maria/ma_open.c:
  Use last_version=1 as a marker that table was opened with HA_OPEN_FOR_STATUS.
  In this case we just open a new version of the table in read only mode.
storage/myisam/mi_create.c:
  Update prototype
storage/myisam/mi_dbug.c:
  Ignore last_version <= 1 as these are either flushed or only opened for status
storage/myisam/mi_open.c:
  Use last_version=1 as a marker that table was opened with HA_OPEN_FOR_STATUS.
  If HA_OPEN_FOR_STATUS is used, we will not assert if there is an old not-to-be-used version of the table existing.
  In this case we just open a new version of the table in read only mode.
storage/myisam/myisamdef.h:
  Updated prototype
2012-02-28 23:18:52 +02:00
Sergei Golubchik
54f9fe6c8b lp:938977 - Query performance with join/index super slow on MariaDB 5.3.4RC
make sure that stored routines are evaluated (that is, de facto - cached) in convert_const_to_int().
revert the fix for lp:806943 because it cannot be repeated anymore.
add few tests for convert_const_to_int()
2012-02-28 15:41:55 +01:00
Manish Kumar
bc1e5e0646 BUG#13333431 - INCORRECT DEFAULT PORT IN 'SHOW SLAVE HOSTS' OUTPUT
This is a post commit patch for failing test on windows.
2012-02-28 19:43:09 +05:30
Sergei Golubchik
45faabf44f merge 2012-02-28 15:04:31 +01:00
Manish Kumar
a8fabaecaa BUG#13333431 - INCORRECT DEFAULT PORT IN 'SHOW SLAVE HOSTS' OUTPUT
This is a post commit patch for failing test on windows.
2012-02-28 16:25:13 +05:30
Praveenkumar Hulakund
a0b46059ee Merge from 5.1 to 5.5 2012-02-29 14:15:15 +05:30
Manish Kumar
9e048a6bc5 BUG#13333431 - INCORRECT DEFAULT PORT IN 'SHOW SLAVE HOSTS' OUTPUT
Problem - The default port number shown in SHOW SLAVE HOSTS is always 3306 
          though the slave is actually listening on a different port number.
          This is a problem as the user can not be sure whether this port 
          value can be trusted and so client trying to read replication 
          topology can get confused.

Fix - 3306 ceases to be the default value of report-port. Moreover report-port
      does not have a static default any longer.
      Instead we initialize report-port to 0 as the new default value and change
      it based on two checks :

      1) If report_port is not set, the slave reports the port number its listening 
         on. (i.e. if report-port is not set we get the actual value of the slave's 
         port number).

      2) If report-port is set, we show the value report-port is set to, as the slave's
         port number.

mysql-test/include/show_slave_hosts.inc:
  A .inc file is added to use show slave hosts in the new test added.
mysql-test/r/mysqld--help-notwin.result:
  Updated the result file to show the default value passed for report-port.
mysql-test/suite/rpl/r/rpl_report_port.result:
  The result file for the new test that is added.
mysql-test/suite/rpl/r/rpl_show_slave_hosts.result:
  Updated the result file to show the default value passed for report-port.
mysql-test/suite/rpl/t/rpl_report_port-slave.opt:
  Option file for the new test added.
mysql-test/suite/rpl/t/rpl_report_port.test:
  Added a test to check the correct functionality of report-port. 
  We check this by running the replication twice. 
          
  In the first run we do not set the value of report-port through the opt file 
  and get the actual port number of the slave's port.
          
  We then restart the server with report-port set to some value (in this case 9000)
  and check the value reported for the slave's port number.
mysql-test/suite/sys_vars/t/report_port_basic.test:
  Update the test file to show the value for report-port. It is replaced with
  SLAVE_PORT as the actual value of the report-port will change with each run.
sql/mysqld.cc:
  Changed the value reported by report port :
          
  1. If the value for report-port is not set we assign report-port to be the 
     actual port number of the slave (mysqld_port).
  
  2. If report-port is set we get the value set for the report-port.
sql/sys_vars.cc:
  Passed 0 as the default value of the report-port.
2012-02-28 14:02:27 +05:30
Igor Babaev
9db23c8280 Merge. 2012-02-27 21:23:12 -08:00
Vladislav Vaintroub
62dcaf8c29 merge 5.5 2012-02-27 19:32:44 +01:00
unknown
f0c682858f Merge MWL#192: non-blocking client library into MariaDB. 2012-02-26 16:11:44 +01:00
Igor Babaev
c92d8cba45 Merge 5.2->5.3 2012-02-26 02:42:45 -08:00
Igor Babaev
d2e3b33b8c Rolled back the patch for bug 791761.
A better fix for this bug will be pulled from mariadb-5.2.
2012-02-26 00:19:07 -08:00
Sergei Golubchik
1df16a171b make the test result independent from sizeof(void*) 2012-02-25 16:13:24 +01:00
unknown
6a72fbe396 Fix of LP bug:938518 (also LP bug:791761 and LP bug:806955)
Cause of the bug is uninitialized items before evaluation HAVING clasue in case of empty result.
2012-02-25 09:03:06 +02:00
Igor Babaev
b161b2e110 Merge. 2012-02-24 18:35:58 -08:00
Igor Babaev
841a74a4d6 Fixed LP bug #939009.
The result of materialization of the right part of an IN subquery predicate
is placed into a temporary table. Each row of the materialized table is
distinct. A unique key over all fields of the temporary table is defined and
created. It allows to perform key look-ups into the table.
The table created for a materialized subquery can be accessed by key as
any other table. The function best_access-path search for the best access
to join a table to a given partial join. With some where conditions this
function considers a possibility of a ref_or_null access. If such access
employs the unique key on the temporary table then when estimating
the cost this access the function tries to use the array rec_per_key. Yet,
such array is not built for this unique key. This causes a crash of the server.

Rows returned by the subquery that contain nulls don't have to be placed
into temporary table, as they cannot be match any row produced by the
left part of the subquery predicate. So all fields of the temporary table
can be defined as non-nullable. In this case any ref_or_null access
to the temporary table does not make any sense and it does not make sense
to estimate such an access.

The fix makes sure that the temporary table for a materialized IN subquery
is defined with columns that are all non-nullable. The also ensures that 
any row with nulls returned by the subquery is not placed into the
temporary table.
2012-02-24 16:50:22 -08:00
Sergey Petrunya
6400df6d71 Update test results. 2012-02-25 01:42:28 +04:00
Sergey Petrunya
8871806788 BUG#938131: Subquery materialization is not used in CREATE TABLE SELECT
- Enable subquery materialization for CREATE TABLE ... SELECT.
2012-02-24 22:42:37 +04:00
Sergey Petrunya
2256ecdd7c Merge 5.2->5.3 2012-02-24 20:07:12 +04:00
Sergei Golubchik
3f28115e0e 5.3 merge 2012-02-24 14:37:00 +01:00
Sergey Petrunya
d206480605 Merge fix for BUG#934597 2012-02-24 17:13:04 +04:00
Sergey Petrunya
914245ccd8 BUG#934597: Assertion `! is_set()' failed in Diagnostics_area::set_ok_status(THD...
- After the exec_const_cond->val_int() call, check for error and return.
  (if we don't do it, we will eventually hit an error when trying to set status OK in 
   the diagnostics area, which already has an error status).
2012-02-24 17:09:13 +04:00
Chaithra Gopalareddy
61fb45bc9a Merge from 5.1 to 5.5 2012-02-24 11:55:28 +05:30
Chaithra Gopalareddy
6a0d03fce7 Bug#13012483:EXPLAIN EXTENDED, PREPARED STATEMENT, CRASH IN
CHECK_SIMPLE_EQUALITY

PROBLEM:
Crash in "check_simple_equality" when using a subquery with "IN" and
"ALL" in prepare.

ANALYSIS:
Crash can be reproduced using a simplified query like this one:
prepare s from "select 1 from g1 where 1 < all (
                select @:=(1 in (select 1 from g1)) from g1)";

This bug is currently present only on 5.5.and 5.1. Its fixed as part
of work log(#1110) in 5.6. We are taking one change to fix this
in 5.5 and 5.1.

Problem seems to be present because we are trying to evaluate "is_null"
on an argument which is part of a subquery
(In Item_is_not_null_test::update_used_tables()).
But the condition to evaluate is only when we do not have a sub query
present, which means to say that "with_subselect" is not set.
With respect to the above query, we create an object of type
"Item_in_optimizer" which by definition is always associated with a
subquery. While in 5.6 we set "with_subselect" to true for
"Item_in_optimizer" object, we do not do the same in 5.5. This results in
the evaluation for "is_null" resulting in a coredump.
So, we are now setting "with_subselect" to true for "Item_in_optimizer"
in 5.1 and 5.5.


mysql-test/r/func_in.result:
  Result file changes for the test case added
mysql-test/t/func_in.test:
  Test case added for Bug#13012483
sql/item_cmpfunc.h:
  Changed Item_in_optimizer::Item_in_optimizer( ) to set "with_subselect"
  to true
2012-02-24 11:53:36 +05:30
Michael Widenius
6e1dac8f77 Automatic merge 2012-02-23 17:00:10 +02:00
Michael Widenius
d395d2514d Fixes for make_binary_distribution and mysql_config for OpenSuse 12.1
BUILD/SETUP.sh:
  By default, build also with innodb-plugin
mysql-test/mysql-test-run.pl:
  Also search in lib64 directory for plugins (This is used at least on OpenSuse 12.1 when using default build scripts)
mysql-test/r/lock_multi.result:
  Allow test to be re-run even if it crashed.
mysql-test/t/lock_multi.test:
  Allow test to be re-run even if it crashed.
scripts/make_binary_distribution.sh:
  Ensure that libexecdir is named libexec (was not on OpenSuse 12.1)
scripts/mysql_config.sh:
  Fixed detection of lib64 was used.
2012-02-23 16:51:58 +02:00
Sergei Golubchik
e293bdb2c1 instead of having win/notwin tests that only differ in results,
use one test with two combinations (win/unix), where only one is enabled.
Apply this technique to mysqld--help.
2012-02-23 09:24:11 +01:00
Sergei Golubchik
3cda92aece don't even try to run xtradb-only tests with innodb, use have_xtradb.combinations. 2012-02-23 09:18:48 +01:00
Sergei Golubchik
a19a4618e3 remove few .require files and one duplicate have_*inc file.
move variable tests from main to sys-vars
2012-02-23 07:52:27 +01:00
Sergei Golubchik
c39877071a overlay support for mysql-test-run and mysqltest
mysql-test-run auto-disables all optional plugins.


mysql-test/include/default_client.cnf:
  no @OPT.plugindir anymore
mysql-test/include/default_mysqld.cnf:
  don't disable plugins manually - mtr can do it better
mysql-test/suite/innodb/t/innodb_bug47167.test:
  mtr now uses suite-dir as an include path
mysql-test/suite/innodb/t/innodb_file_format.test:
  mtr now uses suite-dir as an include path
mysql-test/t/partition_binlog.test:
  this test uses partitions
storage/example/mysql-test/mtr/t/source.result:
  update results. as mysqltest includes the correct overlayed include
storage/innobase/handler/ha_innodb.cc:
  the assert is wrong
2012-02-23 07:50:11 +01:00
Mattias Jonsson
8325fe02b3 Bug#13694811: THE OPTIMIZER WRONGLY USES THE FIRST INNODB
PARTITION STATISTICS

Problem was the fix for bug#11756867; It always used the first
partitions, and stopped after it checked 10 [sub]partitions.
(or until it found a partition which would contain a match).

This results in bad statistics for tables where the first 10 partitions
don't represent the majority of the data (like when the first 10
partitions only contained a few rows in total).

The solution was to take statisics from the partitions containing
the most rows instead:

Added an array of partition ids which is sorted by number of records
in descending order.

this array is used in records_in_range to cover as many records as
possible in as few calls as possible.

Also changed the limit of how many partitions to use for the statistics
from a static max of 10 partitions, into a dynamic model:
Maximum number of partitions is now log2(total number of partitions)
taken from the ordered array.
It will continue calling partitions records_in_range until it has 
checked:
(total rows in matching partitions) * (maximum number of partitions)
/ (number of used partitions)

Also reverted the changes for ha_partition::scan_time() and
ha_partition::estimate_rows_upper_bound() to before
the fix of  bug#11756867. Since they are not as slow as
records_in_range.
2012-02-22 23:13:36 +01:00
Igor Babaev
90c26209ba Merge. 2012-02-22 13:04:58 -08:00
Sergey Petrunya
567d871ff0 Don't run test for BUG#933412 with embedded server, as it requires concurrent query
execution which mtr --embedded does not support
2012-02-22 17:38:24 +04:00
Sergey Petrunya
59b2bb9aca Added back MRR counters. The new names are: Handler_mrr_init,
Handler_mrr_key_refills, Handler_mrr_rowid_refills.
2012-02-22 16:48:29 +04:00
unknown
9305f2b52f Merge latest MariaDB 5.5 into MWL#192: Non-blocking client library. 2012-02-22 12:14:34 +01:00
Tor Didriksen
53ecb1702c Merge 5.1-security => 5.5-security 2012-02-22 11:20:52 +01:00
Tor Didriksen
f3eb021d5e Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
Backport of fix for:
Bug#53236 Segfault in DTCollation::set(DTCollation&)
2012-02-22 11:17:50 +01:00
unknown
c299e027ee Changed names of statistic variables and counting matches instaed of rejected rows. 2012-02-22 10:38:28 +02:00
Sergey Petrunya
925942e7af Merge fix for BUG#920132 2012-02-22 12:21:54 +04:00
Igor Babaev
e0a5319db3 Back-ported the fix and test cases for bugs #59487 and #43368 from
the mysql-5.6 code line.
2012-02-22 00:10:39 -08:00
unknown
f6b68a1070 Merge MWL#192: Non-blocking client library, into MariaDB 5.5. 2012-02-21 22:15:44 +01:00
Sergei Golubchik
c9fc9f7317 lp:923429 Crash in decimal_cmp on using UNIX_TIMESTAMP with a wrongly formatted timestamp
UNIX_TIMESTAMP() can be null, and returns null for invalid values
2012-02-21 21:18:41 +01:00
Sergei Golubchik
edab37cd68 5.3 merge 2012-02-21 20:51:56 +01:00
Mattias Jonsson
74374933c8 Bug#11761296: 53775: QUERY ON PARTITIONED TABLE RETURNS CACHED
RESULT FROM PREVIOUS TRANSACTION

The current Query Cache API is not fully compatible with
the partitioning engine.

There is no good way to implement support for QC due to:
1) a static callback for ha_partition would need to have access
to all partition names and call the underlying callback for each
[sub]partition with the correct name.
2) pruning would be impossible, even if one used the ulonglong
engine_data due to if engine_data is changed, the table is
invalidated by the QC.

So the only viable solution to avoid incorrect data is to not allow
caching of queries using partitioned tables.

(There are some extra changes, due to removal of \r as line break)
2012-02-20 22:59:11 +01:00
Sergey Petrunya
352e848f21 BUG#920132: Assert trx->n_active_thrs == 1 failed at que0que.c line 1050
- MySQL 5.5 introduced caching of constant items by means of 
  wrapping them in Item_cache_XXX objects. If a subquery was wrapped
  in this cache, it could end up being pushed down by ICP.
- The fix is to add Item_cache::walk() which lets ICP to see that 
  the cache item has a subquery inside it, and disable pushdown for this case.
2012-02-21 01:50:50 +04:00
Sergey Petrunya
0099593562 BUG#919878: Assertion `!eliminated_tables...
- In MySQL 5.5, print_join() was re-worked to print "FROM dual" when all
  tables are constant. This change didn't work together with table 
  elimination.
2012-02-21 01:08:22 +04:00
Michael Widenius
b2ce6e3cde Automatic merge 2012-02-21 09:43:36 +02:00
Michael Widenius
15c5a2686f Merge with MariaDB 5.2 2012-02-21 01:58:50 +02:00
Sergey Petrunya
c381e44050 BUG#933412: Server crashes in _mi_put_key_in_record on KILL QUERY with ICP, STRAIGHT_JOIN
- In mi_rkey(), do correct handling of case where mi_yield_and_check_if_killed() 
  detects that the thread was killed (all other similar functions in MyISAM/Aria have 
  slightly different code and do not have this problem).
- Also fixed assignment in DBUG_ASSERT
- this is 2nd variant of the fix:
   = make .result file smaller
   = run KILLable statements in a separate connection, otherwise we could end up trying to 
     KILL the final "DROP TABLE" statement
2012-02-20 20:38:05 +04:00
Michael Widenius
038b739c98 Merge with MariaDB 5.1 and MySQL 5.1.61 2012-02-20 17:49:21 +02:00
Michael Widenius
ae07ec6cbf Merge with MYSQL 5.1.61
Fixed README with link to source
Merged InnoDB change to XtraDB

README:
  Added information of where to find MariaDB code
storage/archive/ha_archive.cc:
  Removed memset() of rows, a MariaDB checksum's doesn't touch not used data.
2012-02-20 16:23:18 +02:00
Sergey Petrunya
bd86e37e9d Merge 2012-02-20 15:34:50 +04:00
Sergey Petrunya
fecad7c945 BUG#933407: Valgrind warnings in mark_as_null_row with materialization+semijoin, STRAIGHT_JOIN, impossible WHERE
- In return_zero_rows(), don't call mark_as_null_row() for semi-join 
  materialized tables, because 1) they may have been already freed, and 
  2)there is no real need to call mark_as_null_row() for them.
2012-02-20 15:30:54 +04:00
Vasil Dimov
86765941f7 Adjust .result files of mysqld--help-notwin and mysqld--help-win
mtr tests.

This is a followup to vasil.dimov@oracle.com-20120217130947-03319op732dsf4m2
which added a deprecation notice to ignore-builtin-innodb
2012-02-20 13:25:37 +02:00
Georgi Kodinov
a70fd51dfb addendum to the --builtin-innodb depreacation bug. Fixing test suite output. 2012-02-19 09:33:55 +02:00
Igor Babaev
3ef46370e9 Fixed bug #934348.
This bug is the result of an incomplete/inconsistent change introduced into
5.3 code when the cond_equal parameter were added to the function optimize_cond.
The change was made during a merge from 5.2 in October 2010.
The bug could affect only queries with HAVING.
2012-02-18 19:11:57 -08:00
Igor Babaev
cd81f57830 Fixed LP bug #934342.
An outer join query with a semi-join subquery could return a wrong result
if the optimizer chose to materialize the subquery.
It happened because when substituting for the best field into a ref item
used to build access keys not all COND_EQUAL objects that could be employed
at substitution were checked.

Also refined some code in the function check_join_cache_usage to make it
safer.
2012-02-18 16:06:38 -08:00
Georgi Kodinov
5dbdb4db99 Addendum to BUG#13586262 : fixed a wrong test suite output 2012-02-18 11:10:42 +02:00
Georgi Kodinov
9f18fc5a06 merged mysql-5.5->mysql-5.5-security 2012-02-17 11:55:36 +02:00
Igor Babaev
c563ea0717 Fixed LP bug #933117.
The bug was fixed with the code back-ported from the patch for LP bug 800184
pushed into mariadb-5.3.
2012-02-16 16:06:49 -08:00
Vladislav Vaintroub
02724621ca merge from 5.5 2012-02-16 17:33:37 +01:00
Sergey Petrunya
541334c5ac Backport of:
timestamp: Thu 2011-12-01 15:12:10 +0100
Fix for Bug#13430436 PERFORMANCE DEGRADATION IN SYSBENCH ON INNODB DUE TO ICP

When running sysbench on InnoDB there is a performance degradation due
to index condition pushdown (ICP). Several of the queries in sysbench
have a WHERE condition that the optimizer uses for executing these
queries as range scans. The upper and lower limit of the range scan
will ensure that the WHERE condition is fulfilled. Still, the WHERE
condition is part of the queries' condition and if ICP is enabled the
condition will be pushed down to InnoDB as an index condition. 

Due to the range scan's upper and lower limits ensure that the WHERE
condition is fulfilled, the pushed index condition will not filter out
any records. As a result the use of ICP for these queries results in a
performance overhead for sysbench. This overhead comes from using
resources for determining the part of the condition that can be pushed
down to InnoDB and overhead in InnoDB for executing the pushed index
condition.

With the default configuration for sysbench the range scans will use
the primary key. This is a clustered index in InnoDB. Using ICP on a
clustered index provides the lowest performance benefit since the
entire record is part of the clustered index and in InnoDB it has the
highest relative overhead for executing the pushed index condition.

The fix for removing the overhead ICP introduces when running sysbench
is to disable use of ICP when the index used by the query is a
clustered index.

When WL#6061 is implemented this change should be re-evaluated.
2012-02-16 20:15:57 +04:00
unknown
607aab9c1d Counters for Index Condition Pushdown added (MDEV-130). 2012-02-16 08:49:10 +02:00
Sergei Golubchik
25609313ff 5.3.4 merge 2012-02-15 18:08:08 +01:00
unknown
47a54a2e08 Merge MySQL 5.5.20 into MariaDB 5.5. 2012-02-14 16:06:41 +01:00
unknown
764eeeee74 Fix for LP BUG#910123 MariaDB 5.3.3 causes 1093 error on Drupal
Problem was that now we can merge derived table (subquery in the FROM clause).
Fix: in case of detected conflict and presence of derived table "over" the table which cased the conflict - try materialization strategy.
2012-02-14 16:52:56 +02:00
Sergey Petrunya
e41e56ae99 Merge fix for BUG#928048 2012-02-14 14:13:10 +04:00
Sergey Petrunya
c9355dc279 BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
- Make equality propagation work correctly when done inside the OR branches
2012-02-14 13:58:57 +04:00
Igor Babaev
c8bbe06ac7 Fixed LP bug #925985.
If the flag 'optimize_join_buffer_size' is set to 'off' and the value
of the system variable 'join_buffer_size' is greater than the value of
the system variable 'join_buffer_space_limit' than no join cache can
be employed to join tables of the executed query.
A bug in the function JOIN_CACHE::alloc_buffer allowed to use join
buffer even in this case while another bug in the function 
revise_cache_usage could cause a crash of the server in this case if the
chosen execution plan for the query contained outer join or semi-join
operation.
2012-02-13 23:46:57 -08:00
Tor Didriksen
6b7f9c0aec Bug#13633383 63183: SMALL SORT_BUFFER_SIZE CRASH IN MERGE_BUFFERS
This patch is a backport of some of the cleanups/refactorings that were done
as part of WL#1393 Optimizing filesort with small limit.


mysql-test/t/bug13633383.test:
  New test case.
mysql-test/valgrind.supp:
  Changed signature for find_all_keys
2012-02-14 08:11:28 +01:00
Rohit Kalhans
ba7d726c48 fixing test failure on pb2. 2012-02-13 15:37:50 +05:30
Rohit Kalhans
701cef2d35 BUG#11758263: Modification of indentation in the added code.
Fixed a typo in the comment.
              Fixing test cases which were previouslyno throwing  due
              disable warnings macro. 

sql/sql_base.cc:
  Change in indentation and fixing a typo in the comment.
2012-02-13 14:12:13 +05:30
unknown
f6cdddf51f Test case for bug lp:905353
The bug itself is fixed by the patch for bug lp:908269.
2012-02-09 23:35:26 +02:00
Rohit Kalhans
31c990ca57 BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFE
Problem: Statements that write to tables with auto_increment columns
         based on the selection from another table, may lead to master
         and slave going out of sync, as the order in which the rows
         are retrieved from the table may differ on master and slave.
            
Solution: We mark writing to a table with auto_increment table
          based on the rows selected from another table as unsafe. This
          will cause the execution of such statements to throw a warning
          and forces the statement to be logged in ROW if the logging
          format is mixed. 
            
Changes:
       1. All the statements that writes to a table with auto_increment 
          column(s) based on the rows fetched from another table, will now
          be unsafe.
       2. CREATE TABLE with SELECT will now be unsafe.

sql/share/errmsg-utf8.txt:
  Added new warning messages.
sql/sql_base.cc:
  -Created function to check statements that write to 
   tables with auto_increment column and has select.
  -Marked all the statements that write to a table
   with auto_increment column based on rows fetched
   from other table(s) as unsafe.
sql/sql_table.cc:
  mark CREATE TABLE[with auto_increment column] as unsafe.
2012-02-09 23:28:33 +05:30
unknown
6e9b06d90b Fix a number of problems in the test suite (no code bugs):
- mysql-test-run.pl --valgrind complains when all tests succeed.

 - perfschema.all_instances fail on non-linux, where ENABLE_TEMP_POOL
   is not set and therefore BITMAP mutex is not used.

 - MDEV-132: main.mysqldump fails because it depends on exact size of stdio
   buffers.

 - MDEV-99: rpl.rpl_cant_read_event_incident fails due to a race where the
   slave manages to connect while the test case is in the middle of setting up
   the master, causing the slave to replicate extra/wrong events.

 - MDEV-133: rpl.rpl_rotate_purge_deadlock fails because it issues a
   DEBUG_SYNC SIGNAL immediately followed by RESET; this means that sometimes
   the intended receipient has no time to see the signal before it is cleared
   by the RESET, causing wait to timeout.
2012-02-09 13:10:47 +01:00
Vladislav Vaintroub
8877fe7359 merge 2012-02-08 11:18:55 +01:00
Rohit Kalhans
b7430d73e4 Backout the patch for bug#11758263. 2012-02-08 12:10:55 +05:30
Rohit Kalhans
de85a60049 BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFE
Problem: Statements that write to tables with auto_increment columns
      based on the selection from another table, may lead to master
      and slave going out of sync, as the order in which the rows
      are retrived from the table may differ on master and slave.
      
      Solution: We mark writing to a table with auto_increment table
      as unsafe. This will cause the execution of such statements to
      throw a warning and forces the statement to be logged in ROW if
      the logging format is mixed. 
      
      Changes: 
      1. All the statements that writes to a table with auto_increment 
      column(s) based on the rows fetched from another table, will now
      be unsafe.
      2. CREATE TABLE with SELECT will now be unsafe.


sql/share/errmsg-utf8.txt:
  Added new Warning messages
sql/sql_base.cc:
  created a new function that checks for select + write on a autoinc table
  made all such statements to be unsafe.
sql/sql_parse.cc:
  made create autoincremnet tabble + select unsafe
2012-02-08 00:33:08 +05:30
Martin Hansson
bb9a3be632 Merge of fix for Bug#11765810. 2012-02-07 17:32:04 +01:00
Sergei Golubchik
2682a280c8 allow suite.pm to skip combinations that originate from test/include files.
storage/innobase/handler/handler0alter.cc:
  for NEWDATE key_type says unsigned, thus col->prtype says unsigned,
  but field->flags says signed. Use the same flag for value retrieval
  that was used for value storage.
2012-02-07 16:22:36 +01:00
Martin Hansson
9ada2f8ec5 Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY
IS EXECUTED TWICE FROM P

This bug is a duplicate of bug 12567331, which was pushed to the
optimizer backporting tree on 2011-06-11. This is just a back-port of
the fix. Both test cases are included as they differ somewhat.
2012-02-07 14:16:09 +01:00
Sergei Golubchik
2bcb4184ef remove few obscure, unused, or misused mtr features 2012-02-06 18:42:18 +01:00
Georgi Kodinov
91c1c93019 merge mysql-5.5->mysql-5.5-security 2012-02-06 18:26:36 +02:00
Georgi Kodinov
d29ae4918e merged mysql-5.1->mysql-5.1-security 2012-02-06 18:24:51 +02:00
Igor Babaev
3efc8d016f Made mrr related counters temporarily invisible until we agree upon their names. 2012-02-03 12:49:17 -08:00
unknown
79a04a2c9c Moving LP BUG#794005 to 5.3 + fixing INSERT of multi-table view. 2012-02-03 13:01:05 +02:00
unknown
52d4103ccc Fixed DELETE issues of view over view over table. 2012-02-03 12:24:55 +02:00
unknown
b9616d815d Added 5.2 test result delimiter 2012-02-03 10:31:30 +02:00
unknown
d6e1377ac2 Fix check of view updatability in case of underlying view changes its updatability.
For single table update/insert added deep check of single tables (single_table_updatable()).
For multi-table view insert added additional check of target table (check_view_single_update).
Multi-update was correct.

Test suite for all cases added.
2012-02-03 10:28:23 +02:00
Mattias Jonsson
7ebeb1433e Bug#13593865 - 64037: CRASH IN HA_PARTITION::CREATE_HANDLERS ON
ALTER TABLE AFTER DROP PARTITION
Bug#13608188 - 64038: CRASH IN HANDLER::HA_THD ON ALTER TABLE AFTER
                      REPAIR NON-EXISTING PARTITION

Backport of bug#13357766 from -trunk to -5.5.

The state of some partitions was not reset on failure, leading
to invalid states of partitions in consequent statements.

Fixed by reverting back to original state for all partitions
if not all partition names was resolved.

Also adding extra security by forcing tables to be reopened
in case of error in mysql_alter_table.

(There is also removal of \r at the end of some lines.)
2012-02-02 12:47:17 +01:00
Ashish Agarwal
a076427ffd BUG#11756869: Merge from mysql-5.1 to mysql-5.5 2012-02-02 14:25:43 +05:30
Ashish Agarwal
4e096d2a45 BUG#11756869 - 48848: MYISAMCHK DOING SORT RECOVER IN CERTAIN
CASES RESETS DATA POINTER TO SMAL

ISSUE: Myisamchk doing sort recover
       on a table reduces data_file_length.
       Maximum size of data file decreases,
       lesser number of rows are stored.

SOLUTION: Size of data_file_length is
          fixed to the original length.
2012-02-02 14:19:38 +05:30
Igor Babaev
51e4bf7356 Merge. 2012-02-01 17:48:45 -08:00
Igor Babaev
7b79d8a33f Merge 5.2->5.3 in preparation for the release of mariadb-5.3.4-rc. 2012-02-01 15:48:02 -08:00
unknown
b4643d75fe fix for LP BUG#921878.
Problem was in try to check/use Item_direct_ref of derived view when we have to use real Item_field under it.
2012-02-01 17:09:49 +02:00
Ashish Agarwal
52357198d0 BUG#11756869 - 48848: MYISAMCHK DOING SORT RECOVER IN CERTAIN
CASES RESETS DATA POINTER TO SMAL

ISSUE: Myisamchk doing sort recover
       on a table reduces data_file_length.
       Maximum size of data file decreases,
       lesser number of rows are stored.

SOLUTION: Size of data_file_length is
          fixed to the original length.
2012-02-01 11:19:53 +05:30
Sergei Golubchik
26f3c33792 a couple of fixes for tests 2012-01-31 17:12:44 +01:00
Sergey Petrunya
12bd3dfe29 BUG#923246: Loosescan reports different result than other semijoin methods
- If LooseScan is used with quick select, require that quick select produces 
  data in key order (this disables use of MRR, which can return data in arbitrary order).
2012-01-30 20:34:47 +04:00
unknown
7009bf411a Merge with main for BUG#12969301 2012-01-30 10:23:21 -05:00
Sergey Petrunya
9fce78a482 Merge fix for BUG#922254 2012-01-30 17:38:14 +04:00
Gopal Shankar
225f0cd53d Merged from mysql-5.1-security 2012-01-30 19:00:04 +05:30
Gopal Shankar
7f0f18cd6e Bug#13105873 :Valgrind Warning: CRASH IN FOREIGN
KEY HANDLING ON SUBSEQUENT CREATE TABLE IF NOT EXISTS
      
      PROBLEM:
      --------
      Consider a SP routine which does CREATE TABLE
      with REFERENCES clause. The first call to this routine
      invokes parser and the parsed items are cached, so as 
      to avoid parsing for the second execution of the routine.
      
      It is obsevered that valgrind reports a warning
      upon read of thd->lex->alter_info->key_list->Foreign_key object,
      which seem to be pointing to a invalid memory address
      during second time execution of the routine. Accessing this object
      theoretically could cause a crash.
      
      ANALYSIS:
      ---------
      The problem stems from the fact that for some reason
      elements of ref_columns list in thd->lex->alter_info->
      key_list->Foreign_key object are changed to point to
      objects allocated on runtime memory root.
      
      During the first execution of routine we create
      a copy of thd->lex->alter_info object.
      As part of this process we create a clones of objects in
      Alter_info::key_list and of Foreign_key object in particular.
      Then Foreign_key object is cloned for some reason we
      perform shallow copies of both Foreign_key::ref_columns
      and Foreign_key::columns list. So new instance of 
      Foreign_key object starts to SHARE contents of ref_columns
      and columns list with the original instance.
      After that as part of cloning process we call
      list_copy_and_replace_each_value() for elements of
      ref_columns list. As result ref_columns lists in both
      original and cloned Foreign_key object start to contain
      pointers to Key_part_spec objects allocated on runtime
      memory root because of shallow copy.
      
      So when we start copying of thd->lex->alter_info object
      during the second execution of stored routine we indeed
      encounter pointer to the Key_part_spec object allocated
      on runtime mem-root which was cleared during at the end
      of previous execution. This is done in sp_head::execute(), 
      by a call to free_root(&execute_mem_root,MYF(0));
      As result we get valgrind warnings about accessing 
      unreferenced memory.
      
      FIX:
      ----
      The safest solution to this problem is to 
      fix Foreign_key(Foreign_key, MEM_ROOT) constructor to do
      a deep copy of columns lists, similar to Key(Key, MEM_ROOT) 
      constructor.
2012-01-30 11:57:33 +05:30
Igor Babaev
56e1a6936b Fixed LP bug #923236.
When working on MWL#247 I forgot to adjust the function create_hj_key_for_table()
that created a key definition for hash join keys. The modified function must
set the values of the fields ext_key_parts, ext_key_flags, ext_key_part_map
added to the key definition structure in MWL#247.
2012-01-29 14:35:30 -08:00
Igor Babaev
5ca1dd8f0b Fixed LP bug #922971.
Applied the fix for bug #12546542 from the mysql-5.6 code line:
JOIN_CACHE::join_records forgot to reset JOIN_TAB::first_unmatched
in some cases.
2012-01-28 01:12:45 -08:00
Igor Babaev
d25f6bb3eb Merge. 2012-01-27 19:23:08 -08:00
Igor Babaev
4e2b6d45e0 Back-ported test cases for bug #59919 of mysql-5.6 code line. The bug could
not be reproduced in the latest release of mariadb-5.3 as it was was fixed
by Sergey Petrunia when working on the problems concerning outer joins within
in subqueries converted to semi-joins.
2012-01-27 19:01:26 -08:00
Sergey Petrunya
53fde5bb6f BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
Fixed Item* Item_equal::get_first(JOIN_TAB *context, Item *field_item) to work correctly in the case where:
- context!= NO_PARTICULAR_TAB, it points to a table within SJ-Materialization nest
- field_item points to an item_equal that has a constant Item_field but does not have any fields
  from tables that are within semi-join nests.
2012-01-27 17:35:26 +04:00
Tor Didriksen
166131c51a Merge 5.1-security => 5.5-security 2012-01-27 13:21:21 +01:00
Tor Didriksen
26c52659c9 Bug#13580775 ASSERTION FAILED: RECORD_LENGTH == M_RECORD_LENGTH
Bug#13011410 CRASH IN FILESORT CODE WITH GROUP BY/ROLLUP

The assert in 13580775 is visible in 5.6 only, 
but shows that all versions are vulnerable.
13011410 crashes in all versions.

filesort tries to re-use the sort buffer between invocations in order to save
malloc/free overhead.
The fix for Bug 11748783 - 37359: FILESORT CAN BE MORE EFFICIENT.
added an assert that buffer properties (num_records, record_length) are
consistent between invocations. Indeed, they are not necessarily consistent.
  
Fix: re-allocate the sort buffer if properties change.


mysql-test/r/partition.result:
  New tests.
mysql-test/t/partition.test:
  New tests.
sql/filesort.cc:
  If we already have allocated a sort buffer in a previous execution,
  then verify that it is big enough for the current one.
sql/table.h:
  Add sort_keys_size; Number of bytes allocated for the sort_keys buffer.
2012-01-27 11:13:13 +01:00
Guilhem Bichot
95646db77b merge from 5.1 2012-01-26 10:38:28 +01:00
Guilhem Bichot
9e0b69c0b7 Fixes for:
BUG#13519696 - 62940: SELECT RESULTS VARY WITH VERSION AND
WITH/WITHOUT INDEX RANGE SCAN
BUG#13453382 - REGRESSION SINCE 5.1.39, RANGE OPTIMIZER WRONG
RESULTS WITH DECIMAL CONVERSION
BUG#13463488 - 63437: CHAR & BETWEEN WITH INDEX RETURNS WRONG
RESULT AFTER MYSQL 5.1.
Those are all cases where the range optimizer got it wrong
with > and >=.

mysql-test/r/range.result:
  Without the code fix for DECIMAL, "select count(val) from t2 where val > 0.1155"
  (which uses a range scan) returned 127 instead of 128);
  Moreover, both
  select * from t1 force  index (primary) where a=1 and c>= 2.9;
  and
  select * from t1 force  index (primary) where a=1 and c> 2.9;
  would miss "1	1	3".
  Without the code fix for strings, both
  SELECT * FROM t1 WHERE F1 >= 'A    ';
  and
  SELECT * FROM t1 WHERE F1 BETWEEN 'A    ' AND 'AAAAA';
  would miss "A	A	A".
sql/item.cc:
  Preamble to the explanations below: opt_range.cc:get_mm_leaf() does
  this (this is not changed by the patch): changes
  column > value
  to
  column OP V
  where:
  * V is what is in "column" after we stored "value" in it
  (such store operation may have done rounding...)
  * OP is > or >=, depending on what's correct.
  For example, if c is an INT column,
  c > 2.9 is changed to
  c OP 3
  where OP is >= ('>' would not be correct).
  The bugs below are cases where we chose OP wrongly.
  Note that such transformations are visible in the optimizer trace.
  
  1) Fix for STRING. In the scenario with CHAR(5) in range.test, this happens,
  in get_mm_tree(), for the condition F1>='A    ':
  * value->save_in_field_no_warnings(field, 1) wants to store the right argument
  (named 'item') into the CHAR(5) field; this stores 'A    ' (the item's value)
  padded with spaces (which changes nothing: still 'A    ')
  * we come to
    case Item_func::GE_FUNC:
      /* Don't use open ranges for partial key_segments */
      if ((!(key_part->flag & HA_PART_KEY_SEG)) &&
          (stored_field_cmp_to_item(param->thd, field, value) < 0))
        tree->min_flag= NEAR_MIN;
      tree->max_flag=NO_MAX_RANGE;
  What this wants to do is: if the field's value is strictly smaller
  than the item's, then ">=" can be changed to ">" (this is an optimization,
  it can help pruning one useless partition).
  * stored_field_cmp_to_item() is called; it compares the field's
  and item's values: the item's value (Item_string::val_str()) is
  'A    ') and the field's value (Field_string::val_str()) is
  'A' (yes val_str() removes end spaces unless sql_mode='PAD_CHAR_TO_FULL_LENGTH');
  and the comparison is done with stringcmp() which considers
  end spaces as relevant; as end spaces differ, function returns a
  negative number, and ">='A    '" becomes ">'A'" (i.e. the NEAR_MIN
  flag is turned on).
  During execution the index range scan code will search for "A", find
  a match, but exclude it (because of ">"), wrongly.
  The badness is the string comparison done by stored_field_cmp_to_item():
  we use the reply of this function to determine where the index search
  should start, so it should do comparison like index search does
  comparisons; index search comparisons are ha_key_cmp() which uses
  a collation-aware comparison (in our case, my_strnncollsp_simple(),
  which ignores end spaces); so stored_field_cmp_to_item()
  needs to do the same. When this is fixed, condition becomes
  ">='A    '".
  
  2) Fix for DECIMAL: just like in other comparisons in stored_field_cmp_to_item(),
  we must first pass the field and then the item; otherwise expectations
  on what <0 and >0 mean (inferiority, superiority) get violated.
  In the test in range.test about c>2.9: c is an INT column, so 2.9
  gets stored as 3, then stored_field_cmp_to_item() compares 3
  and 2.9; because of the wrong order of arguments passed
  to my_decimal_cmp(), range optimizer
  thinks that 3 is < 2.9 and thus changes "c> 2.9" to "c> 3".
  After fixing the order, it changes to the correct "c>= 3".
  In the test in range.inc for val > 0.1155, it was changed to
  val > 0.116, now it is changed to val >= 0.116.
2012-01-26 10:25:23 +01:00
Tor Didriksen
2ed05e38ed Bug#11753187 post-push fix: fix .result file 2012-01-26 08:00:37 +01:00
Vladislav Vaintroub
57b6cb39aa Further review points and simplify Windows implementation 2012-01-26 04:35:54 +01:00
Sergey Petrunya
424f56b3ba BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
- Disable use of join cache when we're using FirstMatch strategy, and the join
  order is such that subquery's inner tables are interleaved with outer.  Join 
  buffering code is incapable of handling such join orders.

- The testcase requires use of @@debug_optimizer_prefer_join_prefix to hit the bug, 
  but I'm pushing it anyway (including the mention of the variable in .test file), 
  so that it can be found and enabled when/if we get something comparable in the 
  main tree.
2012-01-25 22:05:20 +04:00
Tor Didriksen
4172d5e9a9 Bug#13359121 LARGE NUMBERS, /STRINGS/DTOA.C:662
Bug#12985021 SIMPLE QUERY WITH DECIMAL NUMBERS TAKE AN

When parsing the fractional part of a string which
is to be converted to double, we can stop after a few digits:
the extra digits will not contribute to the actual result anyways.


mysql-test/r/func_str.result:
  New tests.
mysql-test/t/func_str.test:
  New tests.
strings/dtoa.c:
  The problem was s2b() multiplying and adding hundreds-of-thousands
  of ever smaller fractions.
2012-01-25 16:11:03 +01:00
Sergey Petrunya
364c07934c Merge 2012-01-25 18:36:57 +04:00
Sergey Petrunya
73cc529b51 BUG#920255: Wrong result (extra rows) with loosescan and IN subquery
The problem was that LooseScan execution code assumed that tab->key holds 
the index used for looseScan. This is only true when range or full index
scan are used. In case of ref access, the index is in tab->ref.key (and 
tab->index==0 which explains how LooseScan passed tests with ref access: they 
used one index)

Fixed by setting/using loosescan_key, which always the correct index#.
2012-01-25 18:33:57 +04:00
Sergey Petrunya
e10816118a Update handler status variables after the last commit. 2012-01-25 18:27:34 +04:00
Tor Didriksen
042bd1511d Bug#13463415 63502: INCORRECT RESULTS OF BIGINT AND DECIMAL COMPARISON
Bug#11758543 50756: BIGINT '100' MATCHES 1.001E2

Expressions of the form
      BIGINT_COL <compare> <non-integer constant>

      should be done either as decimal, or float.

      Currently however, such comparisons are done as int,
      which means that the constant may be truncated,
      and yield false positives/negatives for all queries
      where compare is '>' '<' '>=' '<=' '=' '!='.

      BIGINT_COL IN <list of contstants>
      and
      BIGINT_COL BETWEEN <constant> AND <constant>
      are also affected.



mysql-test/r/bigint.result:
  New tests.
mysql-test/r/func_in.result:
  BIGINT <=> string comparison should be done as float,
  so a warning for the value 'abc' is appropriate.
mysql-test/t/bigint.test:
  New tests.
sql/item_cmpfunc.cc:
  In convert_constant_item() we verify that the constant item
  can be stored in the given field.
  For BIGINT columns (MYSQL_TYPE_LONGLONG) we must verify that the
  stored constant value is actually comparable as int,
  i.e. that the value was not truncated.
  
  For between: compare as int only if both arguments convert correctly to int.
2012-01-25 10:36:25 +01:00
Dmitry Shulga
97883d3c04 Fixed bug#11753187 (formerly known as bug 44585): SP_CACHE BEHAVES AS
MEMORY LEAK.

Background:
 - There are caches for stored functions and stored procedures (SP-cache);
 - There is no similar cache for events;
 - Triggers are cached together with TABLE objects;
 - Those SP-caches are per-session (i.e. specific to each session);
 - A stored routine is represented by a sp_head-instance internally;
 - SP-cache basically contains sp_head-objects of stored routines, which
   have been executed in a session;
 - sp_head-object is added into the SP-cache before the corresponding
   stored routine is executed;
 - SP-cache is flushed in the end of the session.

The problem was that SP-cache might grow without any limit. Although this
was not a pure memory leak (the SP-cache is flushed when session is closed),
this is still a problem, because the user might take much memory by
executing many stored routines.

The patch fixes this problem in the least-intrusive way. A soft limit
(similar to the size of table definition cache) is introduced. To represent
such limit the new runtime configuration parameter 'stored_program_cache'
is introduced. The value of this parameter is stored in the new global
variable stored_program_cache_size that used to control the size of SP-cache
to overflow. 

The parameter 'stored_program_cache' limits number of cached routines for
each thread. It has the following min/default/max values given from support:
  min = 256, default = 256, max = 512 * 1024.
Also it should be noted that this parameter limits the size of 
each cache (for stored procedures and for stored functions) separately.

The SP-cache size is checked after top-level statement is parsed.
If SP-cache size exceeds the limit specified by parameter
'stored_program_cache' then SP-cache is flushed and memory allocated for
cache objects is freed. Such approach allows to flush cache safely 
when there are dependencies among stored routines.


sql/mysqld.cc:
  Added global variable stored_program_cache_size to store value of
  configuration parameter 'stored-program-cache'.
sql/mysqld.h:
  Added declaration of global variable stored_program_cache_size.
sql/sp_cache.cc:
  Extended interface for sp_cache by adding helper routine
  sp_cache_enforce_limit to control size of stored routines cache for
  overflow. Also added method enforce_limit into class sp_cache that
  implements control of cache size for overflow.
sql/sp_cache.h:
  Extended interface for sp_cache by adding standalone routine
  sp_cache_enforce_limit to control size of stored routines cache
  for overflow.
sql/sql_parse.cc:
  Added flush of sp_cache after processing of next sql-statement
  received from a client.
sql/sql_prepare.cc:
  Added flush of sp_cache after preparation/execution of next prepared
  sql-statement received from a client.
sql/sys_vars.cc:
  Added support for configuration parameter stored-program-cache.
2012-01-25 15:59:30 +06:00
Igor Babaev
51847a0fba Fixed LP bug #921167.
The fields ext_key_flags and ext_key_part_map must be initialized for any
key, even for a MyISAM key that never is considered by the optimizer as one
extended by hidden components.
2012-01-24 23:34:02 -08:00
Igor Babaev
507e1927e1 Merge. 2012-01-24 21:12:02 -08:00
Vladislav Vaintroub
398c935db3 further reduce diffs to 5.5, monty review 2012-01-24 19:18:22 +01:00
unknown
461e039a07 BUG#12969301 : mysql_plugin: enable is ignored if plugin exists
This patch changes the mechanism by which the client enables a 
plugin. Instead of using INSERT IGNORE to reload a plugin library,
it now uses REPLACE INTO. This allows users to load a library
multiple times replacing the existing values in the mysql.plugin
table. This allows users to replace the symbol reference to a
different dl name in the table. Thus permitting enabling of 
multiple versions of the same library without first disabling
the old version.

A regression test was added to ensure this feature works.
2012-01-24 11:08:57 -05:00
Alexander Barkov
3dbcc02080 Merging from mysql-5.1 2012-01-24 16:02:12 +04:00
Alexander Barkov
c0badf88c6 Merging BUG#13458237 from 5.1. 2012-01-24 13:24:05 +04:00
Alexander Barkov
f8e924b467 BUG#13458237 - INCONSISTENT HANDLING OF INVALIDE DATES WITH ZERO DAY. SIMILAR TO '2009-10-00'
- Reverting the patch for Bug # 12584302
  The patch will be reverted in 5.1 and 5.5.
  The patch will not be reverted in 5.6, the change will
  be properly documented in 5.6.
- Backporting DBUG_ASSERT not to crash on '0000-01-00'
  (already fixed in mysql-trunk (5.6))
2012-01-24 13:00:13 +04:00
Vladislav Vaintroub
b7cf6abe52 merge 2012-01-24 01:59:03 +01:00
Sergey Petrunya
2ae3fca465 Add MRR counters: Handler_mrr_init, Handler_mrr_extra_rowid_sorts,
Handler_mrr_extra_key_sorts.
2012-01-23 23:35:52 +04:00
Alexander Barkov
31a1f8ef54 Merging Bug#11752408 from mysql-5.1 2012-01-23 13:23:50 +04:00
Alexander Barkov
e449cf48af Bug#11752408 - 43593: DUMP/BACKUP/RESTORE/UPGRADE TOOLS FAILS BECAUSE OF UTF8_GENERAL_CI
Introducing new collations:
utf8_general_mysql500_ci and ucs2_general_mysql500_ci,
to reproduce behaviour of utf8_general_ci and ucs2_general_ci
from mysql-5.1.23 (and earlier).

The collations are added to simplify upgrade from mysql-5.1.23 and earlier.

Note: The patch does not make new server start over old data automatically.
Some manual upgrade procedures are assumed.

Paul: please get in touch with me to discuss upgrade procedures
when documenting this bug.

modified:
  include/m_ctype.h
  mysql-test/r/ctype_utf8.result
  mysql-test/t/ctype_utf8.test
  mysys/charset-def.c
  strings/ctype-ucs2.c
  strings/ctype-utf8.c
2012-01-23 13:07:10 +04:00
Igor Babaev
7bdbdb05ce Back-ported test cases for bugs #54437, #55955, #52329, #57623 from subquery_sj
of mysql-5.6 code line. The bugs could not be reproduced in the latest release
of mariadb-5.3 as they were fixed either when the code of subquery optimization
was back-ported from mysql-6.0 or later when some other bugs were fixed.
2012-01-22 12:54:30 -08:00
Igor Babaev
80009f5862 Back-ported test cases for bugs #53060, #53305, #50358, #49453 from subquery_sj
of mysql-5.6 code line. The bugs could not be reproduced in the latest release
of mariadb-5.3 as they were fixed either when the code of subquery optimization
was back-ported from mysql-6.0 or later when some other bugs were fixed.
2012-01-21 20:58:23 -08:00
Igor Babaev
bb4053afc3 Fixed LP bug #919427.
The function subselect_uniquesubquery_engine::copy_ref_key has to take into
account that when EXPLAIN is processed the array of store_key object created
for any TABLE_REF may contain elements for constant items. These items should
be ignored by thefunction.
2012-01-20 23:54:43 -08:00
Mattias Jonsson
cfbe0fe0cd Bug#13500478 63623: TEST CASE PARTITION_BINLOG_STMT
CREATES A FILE IN AN IMPROPER LOCATION.

Fixed by using $MYSQLTEST_VARDIR, as proposed by
Davi Arnaut.

Thank you Davi!
2012-01-20 14:19:39 +01:00
Dmitry Shulga
752496999e Patch for bug#13070308 - VALGRIND failure in XA test.
The issue is that xa.test failed sporadically on some platforms.
The reason for the test failure is a race condition in xa.test.
The race condition occures between connection that executes statement
INSERT INTO t2 SELECT FROM t1 and other connection that tries to run
statements DELETE FROM t1 and COMMIT. If COMMIT statement had been executed
before the statement INSERT INTO t2 SELECT FROM t1 was locked by lock
on table t1 (as a result of query from table t1) then the INSERT statement
is executed successfully and a following test for deadlock would failed.

This patch fixes this race condition by moving COMMIT statement after commit
of distributed transaction from concurrent session.
2012-01-20 16:03:39 +06:00
Sergey Petrunya
9f60aa27f7 BUG#912513: Wrong result (missing rows) with join_cache_hashed+materialization+semijoin=on
- equality substitution code was geared towards processing WHERE/ON clauses.
  that is, it assumed that it was doing substitions on the code that 
   = wasn't attached to any particular join_tab yet
   = was going to be fed to make_join_select() which would take the condition
     apart and attach various parts of it to tables inside/outside semi-joins.
- However, somebody added equality substition for ref access. That is, if 
  we have a ref access on TBL.key=expr, they would do equality substition in
  'expr'. This possibility wasn't accounted for.
- Fixed equality substition code by adding a mode that does equality 
  substition under assumption that the processed expression will be 
  attached to a certain particular table TBL.
2012-01-20 02:11:53 +04:00
Sergey Petrunya
8bedf1ea1c BUG#912538: Wrong result (missing rows) with semijoin=on, firstmatch=on, ...
- setup_semijoin_dups_elimination() would incorrectly set join_tab->do_firstmatch 
  when the join order had outer tables interleaved with inner.
2012-01-19 23:44:43 +04:00
Sergei Golubchik
e3e15687a0 update the test result 2012-01-19 14:12:16 +01:00
Igor Babaev
e63506af2b Added a test case for LP bug #915291.
The bug was fixed by the patch for bug 914560.
2012-01-18 19:38:03 -08:00
Igor Babaev
40e4d09c53 Merge 2012-01-18 14:19:28 -08:00
Igor Babaev
746dbbe583 Fixed LP bug #917990.
If the expression for a derived table of a query contained a LIMIT
clause the estimate of the number of rows in this derived table
returned by the EXPLAIN command could be badly off since the
optimizer ignored the limit number from the LIMIT clause when
getting the estimate. 
The call of the method SELECT_LEX_UNIT->set_limit added in the code
of mysql_derived_optimize() will be needed also in maria-5.5 where
parameters in the LIMIT clause are supported.
2012-01-18 03:31:20 -08:00
unknown
69327e2987 Adjust test results after Monty's push of the new
handler counter Handler_read_rnd_deleted.
2012-01-18 12:53:50 +02:00
Igor Babaev
7902a73d4c Fixed LP bug #914560.
The patch for MWL #247 forgot to initialize the TABLE::ext_key_parts and
TABLE::ext_key_flags of the temporary tables by a query. This could cause
crashes for queries the execution of which needed creation of temporary
tables.
2012-01-17 03:26:49 -08:00
Sergei Golubchik
38e3ae155d mysql-5.5 merge 2012-01-16 20:16:35 +01:00
Sergei Golubchik
4f435bddfd 5.3 merge 2012-01-13 15:50:02 +01:00
Michael Widenius
5438d57315 Added Handler_read_rnd_deleted, number of deleted rows found with ha_read_rnd_first. 2012-01-13 14:35:49 +02:00
Georgi Kodinov
b8cbc736d0 weave merge mysql-5.5->mysql-5.5-security 2012-01-12 16:44:37 +02:00
Georgi Kodinov
8aa1e57941 weave merge mysql-5.1->mysql-5.1-security 2012-01-12 16:42:23 +02:00
Vladislav Vaintroub
85fc94ec06 fix kill test, again 2012-01-12 13:40:09 +01:00
Alexander Barkov
1522923949 BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIME
Fixing the 5.5 part (the 5.6 part will go in a separate commit soon).

Problem:
  Item_direct_ref::get_date() incorrectly calculated its "null_value",
  which made UNIX_TIMESTAMP(view_column) incorrectly return NULL
  for a NOT NULL view_column.

Fix:
  Make Item_direct_ref::get_date() calculate null_value
  in the similar way with the other methods 
  (val_real,val_str,val_int,val_decimal):
  copy null_value from the referenced Item.

modified:
  mysql-test/r/func_time.result
  mysql-test/t/func_time.test
  sql/item.cc
2012-01-12 13:02:51 +04:00
Karen Langford
4b0d98b28c Merge from mysql-5.1.61-release 2012-01-11 18:51:42 +01:00
unknown
5e3a454755 Merge from mysql-5.5.20-release 2012-01-11 18:50:47 +01:00
Vladislav Vaintroub
6404fcbf9e merge 5.5 2012-01-11 14:56:19 +01:00
unknown
cf31ccc33c Fix for LP BUG#908269 Wrong result with subquery in select list, EXISTS, constant MyISAM/Aria table.
Problem: When building the condition for JOIN::outer_ref_cond the optimizer forgot to take into account
that this condition could depend on constant tables as well.
2012-01-10 23:26:00 +02:00
Sergey Petrunya
d21189d775 Merge fix for BUG#912510 2012-01-10 18:20:56 +04:00
Nirbhay Choubey
0306cde0a5 Merge of fix for bug#11760384 from mysql-5.1. 2012-01-10 16:10:48 +05:30
Nirbhay Choubey
99e462ab0b BUG#11760384 - 52792: mysqldump in XML mode does not dump
routines.

mysqldump in xml mode did not dump routines, events or
triggers.

This patch fixes this issue by fixing the if conditions
that disallowed the dump of above mentioned objects in
xml mode, and added the required code to enable dump
in xml format.


client/mysqldump.c:
  BUG#11760384 - 52792: mysqldump in XML mode does not dump
                        routines.
  
  Fixed some if conditions to allow execution of dump methods
  for xml and further added the relevant code at places to produce
  the dump in xml format.
mysql-test/r/mysqldump.result:
  Added a test case for Bug#11760384.
mysql-test/t/mysqldump.test:
  Added a test case for Bug#11760384.
2012-01-10 13:33:45 +05:30
Michael Widenius
a148cf7fb0 Fixed that --sorted-result in mysql-test-run also works for exec
mysql-test/r/information_schema_all_engines.result:
  Update result
mysql-test/t/information_schema_all_engines.test:
  Added --sorted-results as tables in information_schema are not sorted.
2012-01-09 13:49:47 +02:00
Jon Olav Hauglid
f621aa9020 Merge from mysql-5.1-security to mysql-5.5-security
Text conflict in sql/sql_yacc.yy
2012-01-09 11:33:26 +01:00
Jon Olav Hauglid
b8291e2b60 Backport from mysql-trunk of:
------------------------------------------------------------
revno: 3258
committer: Jon Olav Hauglid <jon.hauglid@oracle.com>
branch nick: mysql-trunk-bug12663165
timestamp: Thu 2011-07-14 10:05:12 +0200
message:
  Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS
  
  When stored routines are loaded, a simple optimizer tries to locate
  and remove dead code. The problem was that this dead code removal
  did not work correctly with CONTINUE handlers.
  
  If a statement triggers a CONTINUE handler, the following statement
  will be executed after the handler statement has completed. This
  means that the following statement is not dead code even if the
  previous statement unconditionally alters control flow. This fact
  was lost on the dead code removal routine, which ended up with
  removing instructions that could have been executed. This could
  then lead to assertions, crashes and generally bad behavior when
  the stored routine was executed.
  
  This patch fixes the problem by marking as live code all stored
  routine instructions that are in the same scope as a CONTINUE handler.
  
  Test case added to sp.test.
2012-01-09 11:28:02 +01:00
Sergey Petrunya
0b590282fc BUG#912510: Crash in do_copy_not_null with semijoin=ON, firstmatch=ON, aggregate ...
- Create/use do_copy_nullable_row_to_notnull() function for ref access, which is used 
  when copying from not-NULL field in table that can be NULL-complemented to not-NULL field.
2012-01-08 14:43:14 +04:00
Sergei Golubchik
8c2bcdf85f MDEV-76 5.5 memory overrun on main.select_jcl6.
geometry fields are blobs too.
2012-01-07 20:01:55 +01:00
unknown
17940b652d MWL#192: non-blocking client API, after-review fixes.
Main change is that non-blocking operation is now an option that must be
explicitly enabled with mysql_option(mysql, MYSQL_OPT_NONBLOCK, ...)
before any non-blocing operation can be used.

Also the CLIENT_REMEMBER_OPTIONS flag is now always enabled and thus
effectively ignored (it was not really useful anyway, and this simplifies
things when non-blocking mysql_real_connect() fails).
2012-01-06 12:43:18 +01:00
Sergei Golubchik
72c5d7a44d updated results for big tests 2012-01-05 00:02:57 +01:00
Igor Babaev
cd55894a52 Fixed LP bug #910083.
The patch for bug 685411 erroneously removed a call of engine->set_thd()
from Item_subselect::fix_fields().
2012-01-02 20:06:36 -08:00
Sergey Petrunya
b55a32788c Fix buildbot: update test results (2) 2012-01-02 21:31:17 +01:00
Vladislav Vaintroub
b2bbd30dee merge with 5.5 2012-01-02 12:03:49 +01:00
Tatjana Azundris Nuernberg
ed1ba992c1 manual up-merge of Bug#11755281 2012-01-02 06:50:05 +00:00
Tatjana Azundris Nuernberg
251fa88afa BUG#11755281/47032: ERROR 2006 / ERROR 2013 INSTEAD OF PROPER ERROR MESSAGE
If init_command was incorrect, we couldn't let users execute
queries, but we couldn't report the issue to the client either
as it does not expect error messages before even sending a
command. Thus, we simply disconnected them without throwing
a clear error.

We now go through the proper sequence once (without executing
any user statements) so we can report back what the problem
is. Only then do we disconnect the user.

As always, root remains unaffected by this as init_command is
(still) not executed for them.

mysql-test/r/init_connect.result:
  We now report a proper error if init_command fails.
  Expect as much.
mysql-test/t/init_connect.test:
  We now report a proper error if init_command fails.
  Expect as much.
sql/sql_connect.cc:
  If init_command fails, throw an error explaining this to
  the user.
2012-01-02 06:25:48 +00:00
Igor Babaev
ec2828e4f7 Merged MWL#247 into the latest 5.3. 2011-12-31 03:36:20 -08:00
Igor Babaev
b6b5f9fabe Implementation of the MWL#247: Make the optimizer use extended keys.
The main patch.
.
2011-12-31 02:25:57 -08:00
Sergey Petrunya
0346e25f07 Continuation of the efforts in previous cset. 2011-12-30 11:34:29 +01:00
Vladislav Vaintroub
f4f95c1723 Fix failing tests in the main suite 2011-12-30 11:22:27 +01:00
Igor Babaev
74fdbec68e Fixed LP bug #848652.
The cause of this bug was the same as for bug 902356 fixed for 5.3.
2011-12-29 21:55:17 -08:00
Igor Babaev
4b7919368e Back-ported the test case for bug #12616253 from mariadb-5.3 that
was actually a duplicate of LP bug #888456 fixed in mariadb-5.2.
2012-01-14 00:02:02 -08:00
Igor Babaev
4de7978a3f Back-ported the fix and the test case for bug #50257 from mariadb-5.3 code line.
Adjusted results for a few test cases.
2012-01-13 19:00:50 -08:00
Igor Babaev
6dfe0956d6 Back-ported the test cases for bug #12763207 from mysql-5.6 code line into 5.2
Completed the fix for this bug.
Note: in 5.3 the affected 'if' statement in Item_in_subselect::single_value_transformer()
starting with the  condition (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
should be removed altogether. The change from table.cc is not needed either.
This is because in 5.3
 - min/max transformation for subqueries are done at the optimization phase
 - evaluation of the expensive subqueries is done at the execution phase.

Added an EXPLAIN EXTENDED to the test case for bug #12329653.
2012-01-13 12:23:19 -08:00
unknown
d63fc00f35 Fix of LP BUG#793589 Wrong result with double ORDER BY
Problem was in caching 'eq_ref' dependency between calls of remove_const() for ORDER BY and GROUP BY lists.
2012-01-05 11:06:52 +02:00
Michael Widenius
98135fed0f Merge with 5.1 2012-01-04 17:22:06 +02:00
Sergey Petrunya
d9fcec5acd Make test results stable (they weren't, because filesort() used to read
from a heap temptable, which uses pointers to records (that is, byte*
pointers) as rowids.  
This meant that for rows with the same sort key value, the order 
was determined by memory layout.
2011-12-29 22:29:02 +01:00
Igor Babaev
5ab628e024 Fixed LP bug #777654.
The method Item_sum_num::fix_fields() calculated the value of
the flag Item_sum_num::maybe_null in some cases incorrectly.
2011-12-28 18:47:01 -08:00
Sergey Petrunya
3759df08eb Update test results. 2011-12-28 12:12:48 +04:00
Igor Babaev
31805e6214 Fixed LP bug #879860.
The MIN/MAX optimization cannot be applied to a subquery if its WHERE clause
contains a conjunctive condition depending on an outer reference.
2011-12-27 19:13:53 -08:00
Sergey Petrunya
679b7704c6 Merge 2011-12-28 03:37:34 +04:00
Igor Babaev
c9259f166b Fixed LP bug #904345.
The MIN/MAX optimizer code from the function opt_sum_query erroneously
did not take into account conjunctive conditions that did not depend on
any table, yet were not identified as constant items. These could be
items containing rand() or PS/SP parameters. These items are supposed
to be evaluated at the execution phase. That's why if such conditions
can be extracted from the WHERE condition the MIN/MAX optimization is
not applied as currently it is always done at the optimization phase.

(In 5.3 expensive subqueries are also evaluated only at the execution
phase. So, if a constant condition with such subquery can be extracted
from the WHERE clause the MIN/MAX optimization should not be applied 
in 5.3.)

IF an IN/ALL/SOME predicate with a constant left part is transformed
into an EXISTS subquery the resulting subquery should not be considered
uncacheable if the right part of the predicate is not uncacheable.

Backported the function dbug_print_item() from 5.3. The function is used
only for debugging.
2011-12-27 13:19:13 -08:00
Vladislav Vaintroub
27ef2fda98 fix test suite 2011-12-27 16:10:34 +01:00
Vladislav Vaintroub
305ae953db merge 2011-12-26 16:57:28 +01:00
Igor Babaev
c583aaf56b Changed a test case from join_cache.test to make it platform independent. 2011-12-25 18:03:03 -08:00
Igor Babaev
2b1f0b8757 Back-ported the patch of the mysql-5.6 code line that
fixed several defects in the greedy optimization:

1) The greedy optimizer calculated the 'compare-cost' (CPU-cost)
   for iterating over the partial plan result at each level in
   the query plan as 'record_count / (double) TIME_FOR_COMPARE'

   This cost was only used locally for 'best' calculation at each
   level, and *not* accumulated into the total cost for the query plan.

   This fix added the 'CPU-cost' of processing 'current_record_count'
   records at each level to 'current_read_time' *before* it is used as
   'accumulated cost' argument to recursive 
   best_extension_by_limited_search() calls. This ensured that the
   cost of a huge join-fanout early in the QEP was correctly
   reflected in the cost of the final QEP.

   To get identical cost for a 'best' optimized query and a
   straight_join with the same join order, the same change was also
   applied to optimize_straight_join() and get_partial_join_cost()

2) Furthermore to get equal cost for 'best' optimized query and a
   straight_join the new code substrcated the same '0.001' in
   optimize_straight_join() as it had been already done in
   best_extension_by_limited_search()

3) When best_extension_by_limited_search() aggregated the 'best' plan a
   plan was 'best' by the check :

   'if ((search_depth == 1) || (current_read_time < join->best_read))'

   The term '(search_depth == 1' incorrectly caused a new best plan to be
   collected whenever the specified 'search_depth' was reached - even if
   this partial query plan was more expensive than what we had already
   found.
2011-12-24 08:55:10 -08:00
Nirbhay Choubey
49d2790aff Bug#12809202 61854: MYSQLDUMP --SINGLE-TRANSACTION
--FLUSH-LOG BREAKS CONSISTENCY

Post-fix for some failing tests.
2011-12-24 15:08:59 +05:30
Nirbhay Choubey
5e487124aa Bug#12809202 61854: MYSQLDUMP --SINGLE-TRANSACTION
--FLUSH-LOG BREAKS CONSISTENCY

The transaction started by mysqldump gets committed
implicitly when flush-log is specified along with
single-transaction option, and hence can break
consistency.

This is because, COM_REFRESH is executed in order
to flush logs and starting from 5.5 this command
performs an implicit commit.

Fixed by making sure that COM_REFRESH is executed
before the transaction has started and not after it.

Note : This patch triggers following behavioral
       changes in mysqldump :

1) After this patch we no longer flush logs before
   dumping each database if --single-transaction
   option is given like it was done before (in the
   absence of --lock-all-tables and --master-data
   options).

2) Also, after this patch, we start acquiring
   FTWRL before flushing logs in cases when only
   --single-transaction and --flush-logs are given.
   It becomes safe to use mysqldump with these two
   options and without --master-data parameter for
   backups.


client/mysqldump.c:
  Bug#12809202 61854: MYSQLDUMP --SINGLE-TRANSACTION
               --FLUSH-LOG BREAKS CONSISTENCY
  
  Added logic to make sure that, if flush-log option
  is specified, mysql_refresh() is never executed after
  the transaction has started.
  
  Added verbose messages for all the executions of
  mysql_refresh() in order to track its invocation.
mysql-test/r/mysqldump.result:
  Added test case for Bug#12809202.
mysql-test/t/mysqldump.test:
  Added test case for Bug#12809202.
2011-12-23 23:05:00 +05:30
Sneha Modi
805989f6ce Bug#11754150: A TEST CASE FOR BUG#6857 IS DISABLED IN SP.TEST
unix_timestamp() is implemented in this part of the code in place of current_time().
Also, since the pb2 machines may be extremely fast, instead of looping through the code,
we use sleep(1.1) so that the variables t0 and t1 have different values.
2011-12-22 16:39:08 +05:30
Sneha Modi
11fd796f8d Bug#11754150: A TEST CASE FOR BUG#6857 IS DISABLED IN SP.TEST
Unix_timestamp for time comparison has some problems...Re-using current_time for 
time comparison.
2011-12-21 19:00:07 +05:30
Sneha Modi
8a8155f11f Bug#11754150: A TEST CASE FOR BUG#6857 IS DISABLED IN SP.TEST
The time comparison using current_time() stored in an int variable was giving wrong results as 
the current_time() format as an int implementation has been changed in mysql-trunk but not in mysql-5.5.

The time is stored in the format hh:mm:ss as 'time' datatype.But as an int, it is stored as hhmmss,
but only on the trunk. On mysql-5.5,as an int, it is stored as hh.
Hence, the current_time() function has been changed to unix_timestamp() function.
2011-12-21 15:14:55 +05:30
Vladislav Vaintroub
711d7452da Fix threadpool related test failures 2011-12-21 00:56:34 +01:00
Vladislav Vaintroub
96041f8e1d make sys_vars suite pass 2011-12-20 22:49:24 +01:00
Igor Babaev
27380e4fb5 Fixed LP bug #794005.
The function st_table::mark_virtual_columns_for_write() did not take into
account the fact that for any table the value of st_table::vfield is 0
when there are no virtual columns in the table definition.
2011-12-20 01:56:41 -08:00
Igor Babaev
bad3e4179c Fixed LP bug #906322.
If the sorted table belongs to a dependent subquery then the function
create_sort_index() should not clear TABLE:: select and TABLE::select
for this table after the sort of the table has been performed, because
these members are needed for the second execution of the subquery.
2011-12-19 14:55:30 -08:00
unknown
072073c09e Backport of WL#5953 from MySQL 5.6
The patch differs from the original MySQL patch as follows:
- All test case differences have been reviewed one by one, and
  care has been taken to restore the original plan so that each
  test case executes the code path it was designed for.
- A bug was found and fixed in MariaDB 5.3 in
  Item_allany_subselect::cleanup().
- ORDER BY is not removed because we are unsure of all effects,
  and it would prevent enabling ORDER BY ... LIMIT subqueries.
- ref_pointer_array.m_size is not adjusted because we don't do
  array bounds checking, and because it looks risky.

Original comment by Jorgen Loland:
-------------------------------------------------------------
WL#5953 - Optimize away useless subquery clauses
      
For IN/ALL/ANY/SOME/EXISTS subqueries, the following clauses are 
meaningless:
      
* ORDER BY (since we don't support LIMIT in these subqueries)
* DISTINCT
* GROUP BY if there is no HAVING clause and no aggregate 
  functions
      
This WL detects and optimizes away these useless parts of the
query during JOIN::prepare()
2011-12-19 23:05:44 +02:00
Sergey Petrunya
a05a566cf0 BUG#906357: Incorrect result with outer join and full text match
- The problem was that const-table-reading code would try to evaluate MATCH()
  before init_ftfuncs() was called. 
- Fixed by making MATCH function "expensive" so that nobody tries to evaluate it
  at optimization phase.
2011-12-20 00:55:32 +04:00
Sergey Petrunya
15ea7238e4 BUG#906385: EXPLAIN EXTENDED crashes in TABLE_LIST::print with limited max_join_size
- Take into account that subquery's optimization can fail because of @@max_join_size error.
2011-12-19 22:24:10 +04:00
Sergey Petrunya
be3e52984f BUG#904432: Wrong result with LEFT JOIN, constant table, semijoin=ON,materialization=ON
- Correct handling for SJ-Materialization + outer joins (details in the comments in the code)
2011-12-19 20:58:55 +04:00
Igor Babaev
7a1406f229 Fixed LP bug #904832.
Do not perform index condition pushdown for conditions containing subqueries
and stored functions.
2011-12-18 23:38:37 -08:00
Vladislav Vaintroub
2e4bde4c0f Fix pool_of_threads test case 2011-12-18 23:03:35 +01:00
Sergey Petrunya
a4073c1990 Update test results for previous push 2011-12-16 14:19:58 +04:00
Sergey Vojtovich
16036b5e61 Test case for BUG11763712 is intended for 5.1 only. 2011-12-16 12:17:13 +04:00
Igor Babaev
919f19110f Merge 2011-12-15 15:55:00 -08:00
Sergey Petrunya
04e9004fa3 BUG#901399: Wrong result (extra row) with semijoin=ON, materialization=OFF, optimizer_prune_level=0
- Correctly handle plan refinement stage for LooseScan plans: run create_ref_for_key() if LooseScan 
  plan includes a ref access, and if we don't have any fixed key components, switch to a full index scan.
2011-12-16 03:44:25 +04:00
Igor Babaev
a910e8ef5b Made join_cache_level == 2 by default. 2011-12-15 14:26:59 -08:00
Sergei Golubchik
1efdd5a572 rename debug variable to debug_dbug, to make test pass in release builds
(and to follow the naming conventons).
keep old debug variable, but mark it as deprecated.
2011-12-15 22:07:58 +01:00
Mattias Jonsson
41e46f3203 merge. Disabled the added test in merge.test from 5.1. 2011-12-15 17:12:04 +01:00
Mattias Jonsson
e5cb287933 Post push fix for merge.test and mysqlcheck.test on windows 2011-12-15 16:59:18 +01:00
Georgi Kodinov
d7bc26c464 merge mysql-5.5->mysql-5.5-security 2011-12-15 14:13:46 +02:00
Chaithra Gopalareddy
7615cb0890 Bug#13344643:Format function in view looses locale information
Problem description:
When a view is created using function FORMAT and if FORMAT function uses locale
option,definition of view saved into server doesn't contain that locale information,
Ex:
create  table test2 (bb decimal (10,2));
insert into test2 values (10.32),(10009.2),(12345678.21);
create view test3 as select format(bb,1,'sk_SK') as cc from test2;
select * from test3;
+--------------+
| cc           |
+--------------+
| 10.3         |
| 10,009.2     |
| 12,345,678.2 |
+--------------+
3 rows in set (0.02 sec)

show create view test3
                View: test3
         Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`
SQL SECURITY DEFINER VIEW `test3` AS select format(`test2`.`bb`,1) AS `cc`
from `test2`
character_set_client: latin1
collation_connection: latin1_swedish_ci
1 row in set (0.02 sec)

Problem Analysis:
The function Item_func_format::print() which prints the query string to create
the view does not print the third argument (i.e the locale information). Hence
 view is created without locale information. 

Problem Solution:
If argument count is more than 2 we now print the third argument onto the query string.

Files changed:
sql/item_strfunc.cc
Function call changes: Item_func_format::print()
mysql-test/t/select.test
Added test case to test the bug
mysql-test/r/select.result
Result of the test case appended here
2011-12-15 16:48:40 +05:30
unknown
a6c7c53b63 Merge XtraDB from Percona-server-5.5.17-rel22.1 into MariaDB 5.5 2011-12-15 10:34:14 +01:00
Igor Babaev
f5dac20f38 Made the optimizer switch flags 'outer_join_with_cache', 'semijoin_with_cache'
set to 'on' by default.
2011-12-15 00:21:15 -08:00
Mattias Jonsson
7e63c8ac0d merged bug#12361113.
Also added tests for partitions key caches.
2011-12-14 15:33:01 +01:00
Mattias Jonsson
52076824c9 merge 2011-12-14 14:41:40 +01:00
Mattias Jonsson
3ea35d31f0 merge 2011-12-14 14:05:22 +01:00
Georgi Kodinov
2b05ef11fc Addendum to the fix for bug #11754011: fixed a testcase result to include
the new --slow-start-timeout option's help output
2011-12-14 12:49:32 +02:00
Sergey Petrunya
efb57a8ebf Merge 2011-12-14 04:56:54 +04:00
Sergey Petrunya
05e0127478 BUG#901506: Crash in TABLE_LIST::print on EXPLAIN EXTENDED
- Let JTBM optimization code handle the case where the subquery is degenerate and doesn't have a 
  join query plan. Regular materialization would fall back to IN->EXISTS for such cases. Semi-Join
  materialization does not have such option, instead we introduce and use "constant JTBM join tabs".
2011-12-14 04:39:29 +04:00
Igor Babaev
7229af3034 Merge 2011-12-13 14:28:53 -08:00
Igor Babaev
d274e32c8c Fixed LP bug #902356.
A memory overwrite in the function test_if_skip_sort_order()
could cause a crash for some queries with subqueries.
2011-12-13 14:20:47 -08:00
Sergey Petrunya
190aa08557 BUG#902632: Crash or invalid read at st_join_table::cleanup, st_table::disable_keyread
- Do a "more thorough" cleanup of SJ-Materialization join tab in JOIN_TAB::cleanup. The bug
  was due to the fact that JOIN_TAB::cleanup() may be called multiple times for the same tab
  if the join has grouping.
2011-12-14 02:15:15 +04:00
Michael Widenius
76d852d425 Automatic merge 2011-12-13 14:11:08 +02:00
Michael Widenius
b653115c8e Fixed valgrind error when storing db_name_length in query_cache.
- Changed storage to be 2 bytes instead of sizeof(size_t) (simple optimization)
- Fixed bug when using query_cache_strip_comments and query that started with '('
- Fixed DBUG_PRINT() that used wrong (not initialized) variables.


mysql-test/mysql-test-run.pl:
  Added some space to make output more readable.
mysql-test/r/query_cache.result:
  Updated test results
mysql-test/t/query_cache.test:
  Added test with query_cache_strip_comments
sql/mysql_priv.h:
  Added QUERY_CACHE_DB_LENGTH_SIZE
sql/sql_cache.cc:
  Fixed bug when using query_cache_strip_comments and query that started with '('
  Store db length in 2 characters instead of size_t.
  Get db length from correct position (earlier we had an error when query started with ' ')
  Fixed DBUG_PRINT() that used wrong (not initialized) variables.
2011-12-13 14:00:20 +02:00
Sergei Golubchik
2ccf247e93 after merge changes:
* rename all debugging related command-line options
  and variables to start from "debug-", and made them all
  OFF by default.
* replace "MySQL" with "MariaDB" in error messages
* "Cast ... converted ... integer to it's ... complement"
  is now a note, not a warning
* @@query_cache_strip_comments now has a session scope,
  not global.
2011-12-12 23:58:40 +01:00
Sergei Golubchik
6cc9d0ffa0 move safemalloc out of dbug.
remeber a real backtrace for every allocation.
make safemalloc to tract C++ new/delete too.
collateral fixes to make the test suite pass.
2011-12-12 22:58:24 +01:00
Mattias Jonsson
beedf6b261 Bug#12361113: CRASH WHEN "LOAD INDEX INTO CACHE" WITH TOO
SMALL KEY CACHE

The server crashed on division by zero because the key cache was not
initialized and the block length was 0 which was used in a division.

The fix was to not allow CACHE INDEX if the key cache was not initiallized.
Thus never try LOAD INDEX INTO CACHE for an uninitialized key cache.

Also added some windows files/directories to .bzrignore.
2011-12-12 14:07:02 +01:00
Sergei Golubchik
745c53ec06 5.2->5.3 merge 2011-12-12 13:00:33 +01:00
unknown
6404504d0c Fixed bug lp:900375
The range optimizer incorrectly chose a loose scan for group by
when there is a correlated WHERE condition. This range access
method cannot be executed for correlated conditions also with the
"range checked for each record" because generally the range access
method can change for each outer record. Loose scan destructively
changes the query plan and removes the GROUP operation, which will
result in wrong query plans if another range access is chosen
dynamically.
2011-12-12 12:36:46 +02:00
Igor Babaev
63d32c115d Fixed LP bug #901709.
The cause of the reported assertion failure was a division of a double value by 0.
2011-12-11 19:41:53 -08:00
Igor Babaev
9b4cd1b0ae Merge 2011-12-11 14:38:14 -08:00
Igor Babaev
fa29f18ffb Fixed LP bug #901478.
If the duplicate elimination strategy is used for a semi-join and potentially
one of the block-based join algorithms can be employed to join the inner
tables of the semi-join then sorting of the head (first non-constant) table
for a query with ORDER BY / GROUP BY cannot be used.
2011-12-11 12:56:06 -08:00
Michael Widenius
24e452a208 Merge with 5.1 & fixes to IGNORE handling 2011-12-11 19:28:05 +02:00
Michael Widenius
6d4224a31c Merge with 5.2.
no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
2011-12-11 11:34:44 +02:00
Igor Babaev
8a09adb3ea Fixed LP bug #901312.
The function setup_sj_materialization_part1() forgot to set the value
of TABLE::map for any materialized IN subquery. 
This could lead to wrong results for queries with subqueries that were
converted to queries with semijoins.
2011-12-09 14:30:50 -08:00
unknown
314c377422 Fixed bug lp:888456
Analysis:
The class member QUICK_GROUP_MIN_MAX_SELECT::seen_first_key
was not reset between subquery re-executions. Thus each
subsequent execution continued from the group that was
reached by the previous subquery execution. As a result
loose scan reached end of file much earlier, and returned
empty result where it shouldn't.

Solution:
Reset seen_first_key before each re-execution of the
loose scan.
2011-12-08 12:05:52 +02:00
Sergey Petrunya
ae480437ce Small semi-join optimization improvement:
- if we're considering FirstMatch access with one inner table, and 
  @@optimizer_switch has semijoin_with_cache flag, calculate costs
  as if we used join cache (because we will be able to do so)
2011-12-08 04:22:38 +04:00
Sergey Petrunya
8e96081764 Merge fix for BUG#868908 2011-12-08 02:47:54 +04:00
Sergey Petrunya
49ecc88069 BUG#901032: Wrong result for MIN/MAX on an indexed column with materialization and semijoin
- opt_sum_query() should not assume that join tables from sj-materialization
  have known numbers of rows.
2011-12-08 02:12:48 +04:00
Igor Babaev
7414a0b6d6 Fixed LP bug #900469.
The execution plan cannot use sorting on the first table from the
sequence of the joined tables if it plans to employ the block-based
hash join algorithm.
2011-12-06 13:42:18 -08:00
Sergey Petrunya
8e25dcfcd7 BUG#868908: Crash in check_simple_equality() with semijoin + materialization + prepared statement
- Part 1 of the fix: for semi-join merged subqueries, calling child_join->optimize() until we're done with all
  PS-lifetime optimizations in the parent.
2011-12-07 01:03:00 +04:00
Igor Babaev
b4c9fa321d Fixed LP bug #899509.
The optimizer must ignore any possible hash join key when looking for the 
query execution plan with join_cache_level set to 0.
2011-12-06 02:46:42 -08:00
Igor Babaev
62e4c73ebb Merge 2011-12-05 18:52:50 -08:00
Igor Babaev
c28d7cbe70 Merge 2011-12-05 18:51:56 -08:00
Sergey Petrunya
136408b1cf Bug #899962: materialized subquery with join_cache_level=3
- Make create_tmp_table() set KEY_PART_INFO attributes for the keys it creates.
  This wasn't needed before but is needed now, when temp. tables that are 
  results of SJ-Materialization are being used for joins.
  This particular bug depended on HA_VAR_LENGTH_PART being set,
  but also added code to set HA_BLOB_PART and HA_NULL_PART when appropriate.
2011-12-06 01:04:27 +04:00
Igor Babaev
7d1f41265c Fixed LP bug #899777.
KEYUSE elements for a possible hash join key are not sorted by field
numbers of the second table T of the hash join operation. Besides
some of these KEYUSE elements cannot be used to build any key as their
key expressions depend on the tables that are planned to be accessed
after the table T. 
The code before the patch did not take this into account and, as a result,
execition of a query the employing block-based hash join algorithm could
cause a crash or return a wrong result set.
2011-12-05 09:50:24 -08:00
Tor Didriksen
0cd9228124 Bug#13013970 MORE CRASHES IN FIELD_BLOB::GET_KEY_IMAGE
The predicate is re-written from
((`test`.`g1`.`a` = geometryfromtext('')) or ...
to
((`test`.`g1`.`a` = <cache>(geometryfromtext(''))) or ...

The range optimizer calls save_in_field_no_warnings, in order to fetch keys.
save_in_field_no_warnings returns 0 because of the cache wrapper,
and get_mm_leaf() proceeded to call Field_blob::get_key_image() 
which accesses un-initialized data.




mysql-test/r/gis.result:
  New test case.
mysql-test/t/gis.test:
  New test case.
sql/item.cc:
  If we have cached a null_value, then verify that the Field can accept it.
2011-12-05 15:42:45 +01:00
Sergey Petrunya
255fd6c929 Make subquery Materialization, as well as semi-join Materialization be shown
in EXPLAIN as select_type==MATERIALIZED. 

Before, we had select_type==SUBQUERY and it was difficult to tell materialized
subqueries from uncorrelated scalar-context subqueries.
2011-12-05 01:31:42 +04:00
Igor Babaev
b5a05df61e Fixed LP bug #899696.
If has been decided that the first match strategy is to be used to join table T
from a semi-join nest while no buffer can be employed to join this table
then no join buffer can be used to join any table in the join sequence between
the first one belonging to the semi-join nest and table T.
2011-12-04 07:43:33 -08:00
Sergei Golubchik
d5fd757a42 1. add --plugin-dir and --default-auth to mysqltest.
2. dialog plugin now always returns mysql->password if non-empty and the first question is of password type
3. split get_tty_password into get_tty_password_buff and strdup.
4. dialog plugin now uses get_tty_password by default
5. dialog.test
6. moved small tests of individual plugins into a dedicated suite
2011-12-02 16:26:43 +01:00
Vladislav Vaintroub
1054de8699 Fix intermittently failing variables-notembedded test case.
After sending packet that is too large, clienrt can get either an error packet with 
ER_NET_PACKET_TOO_LARGE, or a socket error. Both cases are valid, since the
server does not ensure reply was fully read by client, before shutting down  and closing 
the socket.
2011-12-01 22:37:45 +01:00
Michael Widenius
efcfb195e3 Merge with 5.1 2011-11-30 22:57:18 +02:00
Igor Babaev
2f9734172f Fixed LP bug #898073.
The tables from the same semi-join or outer join nest cannot use
join buffers if in the join sequence of the query execution plan
they are separated by a table that is planned to be joined without
usage of a join buffer.
2011-11-30 10:22:53 -08:00
Michael Widenius
692fcba403 Fixed compiler warnings and other bugs found by buildbot.
client/mysqltest.cc:
  Free mutex after usage (fixes valgrind warnings in embedded server)
mysql-test/include/gis_keys.inc:
  Fixed failure in innodb.gis_test
mysql-test/r/gis.result:
  Updated result
mysql-test/suite/innodb/r/innodb_gis.result:
  Updated results
mysql-test/suite/innodb/t/innodb_bug38231.test:
  Added handling of timeouts (happend on some servers in buildbot)
mysql-test/suite/innodb_plugin/r/innodb_gis.result:
  Updated results
mysql-test/suite/innodb_plugin/t/innodb.test:
  Use error names instead of numbers
mysql-test/suite/innodb_plugin/t/innodb_misc1.test:
  This test requires utf8
mysql-test/suite/innodb_plugin/t/innodb_mysql.test:
  This test requires Xtradb
sql/sql_base.cc:
  Don't print table names for placeholders.
sql/sql_show.cc:
  Temporary fix:
  Save and restore db and table_name in mysqld_show_create (to get rid of valgrind warning)
  A better solution that needs to be investgated is to not change these fields in mysql_derived_prepare()
sql/sql_view.cc:
  Fixed valgrind warning
storage/xtradb/handler/ha_innodb.cc:
  Don't access THD directly
2011-11-30 18:44:51 +02:00
unknown
3a7f28793f Merge the fix of bug lp:825051 2011-11-30 08:28:40 +02:00