Commit graph

2047 commits

Author SHA1 Message Date
Monty
5e0b13d173 Fixed wrong arguments to printf and related functions
Other things, mainly to get
create_mysqld_error_find_printf_error tool to work:

- Added protection to not include mysqld_error.h twice
- Include "unireg.h" instead of "mysqld_error.h" in server
- Added protection if ER_XX messages are already defined
- Removed wrong calls to my_error(ER_OUTOFMEMORY) as
  my_malloc() and my_alloc will do this automatically
- Added missing %s to ER_DUP_QUERY_NAME
- Removed old and wrong calls to my_strerror() when using
  MY_ERROR_ON_RENAME (wrong merge)
- Fixed deadlock error message from Galera. Before the extra
  information given to ER_LOCK_DEADLOCK was missing because
  ER_LOCK_DEADLOCK doesn't provide any extra information.

I kept #ifdef mysqld_error_find_printf_error_used in sql_acl.h
to make it easy to do this kind of check again in the future
2018-01-04 16:24:09 +02:00
Monty
7e882a60bf Ensure that table->vcol_set is properly restored if used
Code in QUICK_RANGE_SELECT::init_ror_merged_scan() could theoretically
have caused crashes if this was ever called from an update or delete

This also found a bug in the vcol/range.result. file.
2018-01-01 14:44:20 +02:00
Monty
322c637c1c Fixed compiler warnings about possible uninitialized variables 2018-01-01 14:10:22 +02:00
Sergei Golubchik
e0a1c745ec Merge branch '10.1' into 10.2 2017-10-24 14:53:18 +02:00
Vladislav Vaintroub
4ec88ea9c3 Fix a warning on Win64 2017-10-23 22:01:19 +00:00
Sergei Golubchik
9d2e2d7533 Merge branch '10.0' into 10.1 2017-10-22 13:03:41 +02:00
Michael Widenius
98cc7a8eef Fixed compiler warnings 2017-10-18 17:10:49 +03:00
Vladislav Vaintroub
dc93ce8dea Windows : Fix truncation warnings in sql/ 2017-10-10 06:19:50 +00:00
Igor Babaev
dbeffabc83 Fixed the bug mdev-11574.
Do not build an index merge of two indexes when one index is
an infix of the other index.
2017-10-06 00:08:36 -07:00
Sergei Petrunia
ebc2f0dad3 Avoid using HA_POS_ERROR constant when passing around values of type double.
This is error-prone and causes warnings on Windows
2017-10-03 16:23:39 +03:00
Vladislav Vaintroub
157d130a87 Fix some conversion warnings. 2017-09-30 09:26:58 +00:00
Vladislav Vaintroub
ccf21c9962 fix some conversion warnings 2017-09-28 17:20:46 +00:00
Vladislav Vaintroub
eba44874ca MDEV-13844 : Fix Windows warnings. Fix DBUG_PRINT.
- Fix win64 pointer truncation warnings
(usually coming from misusing 0x%lx and long cast in DBUG)

- Also fix printf-format warnings

Make the above mentioned warnings fatal.

- fix pthread_join on Windows to set return value.
2017-09-28 17:20:46 +00:00
Sergei Golubchik
a4885dde4c MDEV-13535 Query on MyISAM table corrupts the table
don't assume that the table always has a primary key,
head->s->primary_key might be MAX_KEY, which won't start keyread.
2017-08-16 18:44:17 +02:00
Sergei Golubchik
8e8d42ddf0 Merge branch '10.0' into 10.1 2017-08-08 10:18:43 +02:00
Alexey Botchkov
a06f2f430f MDEV-12078 Using spatial index changes type from point to geometry
In get_mm_tree we have to change Field_geom::geom_type to
        GEOMETRY as we have to let storing all types of the spatial features
        in the field. So now we restore the original geom_type as it's
        done.
2017-07-11 23:27:19 +04:00
Marko Mäkelä
8f643e2063 Merge 10.1 into 10.2 2017-05-23 11:09:47 +03:00
Marko Mäkelä
b61700c221 Merge 10.0 into 10.1 2017-05-23 08:59:03 +03:00
Sergei Golubchik
7c03edf2fe MDEV-6262 analyze the coverity report on mariadb
uploaded 10.0, analyzed everything with the Impact=High
(and a couple of Medium)
2017-05-19 20:26:56 +02:00
Igor Babaev
00ab154d49 Fixed bug mdev-10454.
The patch actually fixes the old defect of the optimizer that
could not extract keys for range access from IN predicates
with row arguments.

This problem was resolved in the mysql-5.7 code. The patch
supersedes what was done there:
 - it can build range access when not all components of
 the first row argument are refer to the columns of the table
 for which the range access is constructed.
 - it can use equality predicates to build range access
 to the table that is not referred to in this argument.
2017-04-03 15:59:38 -07:00
Sergei Golubchik
da4d71d10d Merge branch '10.1' into 10.2 2017-03-30 12:48:42 +02:00
Alexey Botchkov
d0e8b427a1 MDEV-12078 Using spatial index changes type from point to geometry
In get_mm_tree we have to change Field_geom::geom_type to
        GEOMETRY as we have to let storing all types of the spatial features
        in the field. So now we restore the original geom_type as it's
        done.
2017-03-14 16:35:39 +04:00
Marko Mäkelä
ad0c218a44 Merge 10.0 into 10.1
Also, implement MDEV-11027 a little differently from 5.5 and 10.0:

recv_apply_hashed_log_recs(): Change the return type back to void
(DB_SUCCESS was always returned).

Report progress also via systemd using sd_notifyf().
2017-03-09 08:53:08 +02:00
Vicențiu Ciorbaru
1acfa942ed Merge branch '5.5' into 10.0 2017-03-03 01:37:54 +02:00
Oleksandr Byelkin
5ddfcb05ca MDEV-9455: [ERROR] mysqld got signal 11
Switch MEM_ROOT to non-prune_partitions() during optimizing subselect.
2017-02-20 15:49:38 +01:00
Sergei Golubchik
cff144a8ea cleanup: handler::key_read
* rename to "keyread" (to avoid conflicts with tokudb),
* change from bool to uint and store the keyread index number there
* provide a bool accessor to check if keyread is enabled
2017-02-13 18:12:05 +01:00
Sergei Golubchik
e46c42217f cleanup: TABLE::mark_columns_used_by_index()
mark_columns_used_by_index used to do
reset + mark_columns_used_by_index_no_reset + start keyread + set bitmaps

Now prepare_for_keyread does that, while mark_columns_used_by_index
does only reset + mark_columns_used_by_index_no_reset,
just as its name suggests.
2017-02-13 18:12:05 +01:00
Sergei Golubchik
bf8f70a47c cleanup: mark_columns_used_by_index_no_reset in opt_range.cc
use table->mark_columns_used_by_index, don't copy it
2017-02-13 18:12:05 +01:00
Sergei Golubchik
29ed440d44 MDEV-11836 vcol.vcol_keys_myisam fails in buildbot and outside
move TABLE::key_read into handler. Because in index merge and DS-MRR
there can be many handlers per table, and some of them use
key read while others don't. "keyread" is really per handler,
not per TABLE property.
2017-02-13 18:12:04 +01:00
Igor Babaev
f003cc8a35 Fixed bug mdev-8603.
When building different range and index-merge trees the range optimizer
could build an index-merge tree with an index scan containing less ranges
then needed. This index-merge could be chosen as the best. Following this
index-merge the executioner missed some rows in the result set.
The invalid index scan was built due to an inconsistency in the code
back-ported from mysql into 5.3 that fixed mysql bug #11765831:
the code added to key_or() could change shared keys of the second
ored tree. Partially the problem was fixed in the patch for mariadb
bug #823301, but it turned out that only partially.
2017-01-18 11:42:41 -08:00
Monty
135e144479 MDEV-11598 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
Found and fixed 2 problems:

- Filesort addon fields didn't mark virtual columns properly
- multi-range-read calculated vcol bitmap but was not using it.
  This caused wrong vcol field to be calculated on read, which caused the assert.
2017-01-11 09:19:45 +02:00
Sergei Golubchik
4a5d25c338 Merge branch '10.1' into 10.2 2016-12-29 13:23:18 +01:00
Varun Gupta
f41bd7e545 MDEV-11060 sql/protocol.cc:532: void Protocol::end_statement(): Assertion `0' failed
In file sql/opt_range.cc,when calculate_cond_selectivity_for_table() is called with optimizer_use_condition_selectivity=4 then
	- thd->no_errors is set to 1
	- the original value of thd->no_error is not restored to its original value
	- this is causing the assertion to fail in the subsequent queries

Fixed by restoring the original value of thd->no_errors
2016-12-14 12:45:50 +05:30
Sergei Golubchik
85416269c3 MDEV-11518 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in Field_long::val_int()
QUICK_RANGE_SELECT::init_ror_merged_scan() should
also set and restore TABLE::vcol_set
2016-12-12 20:44:46 +01:00
Sergei Petrunia
039bab2290 Undo the unfinished patch for MDEV-8359:
Patch b8b1b928ff was pushed by mistake
2016-11-20 00:26:40 +03:00
Sergei Golubchik
a98c85bb50 Merge branch '10.0-galera' into 10.1 2016-11-02 13:44:07 +01:00
Igor Babaev
d451d772fd Fixed bug mdev-9628.
In the function create_key_parts_for_pseudo_indexes()
the key part structures of pseudo-indexes created for
BLOB fields were set incorrectly.
Also the key parts for long fields must be 'truncated'
up to the maximum length acceptable for key parts.
2016-10-26 20:45:35 -07:00
Sergei Petrunia
b8b1b928ff MDEV-8359: WHERE condition referring to inner table of left join can be sargable
Implement a technique mentioned in the MDEV. Under certain conditions,
cond(inner_table.col) can be substituted for cond(outer_table.col) for
the purpose of range analysis.
2016-10-14 00:05:13 +03:00
Sergei Golubchik
06b7fce9f2 Merge branch '10.1' into 10.2 2016-09-09 08:33:08 +02:00
Sergei Golubchik
6b1863b830 Merge branch '10.0' into 10.1 2016-08-25 12:40:09 +02:00
Monty
a5051cd3b2 Minor cleanups
- Remove impossible test in test_quick_select
- Ensure that is_fatal_error is set if we run out of stack space
2016-08-22 10:19:07 +03:00
Sergei Golubchik
309c08c17c Merge branch '5.5' into 10.0 2016-08-10 19:19:05 +02:00
Sergei Petrunia
15ef38d2ea MDEV-10228: Delete missing rows with OR conditions
Fix get_quick_keys(): When building range tree from a condition
in form

  keypart1=const AND (keypart2 < 0 OR keypart2>=0)

the SEL_ARG for keypart2 represents an interval (-inf, +inf).
However, the logic that sets UNIQUE_RANGE flag fails to recognize
this, and sets UNIQUE_RANGE flag if (keypart1, keypart2) covered
a unique key.
As a result, range access executor assumes the interval can have
at most one row and only reads the first row from it.
2016-07-27 00:38:51 +03:00
Sergei Petrunia
95c286cedf MDEV-10324: Server crash in get_sel_arg_for_keypart or Assertion
The crash was caused by this problem:
get_best_group_min_max() tries to construct query plans for keys that
are not processed by the range optimizer. This wasn't a problem as long
as SEL_TREE::keys was an array of MAX_KEY elements.
However, now it is a Mem_root_array and only has elements for the used
keys, and get_best_group_min_max attempts to address beyond the end of
the array.

The obvious way to fix the crash was to port (and improve) a part of
96fcfcbd7b5120e8f64fd45985001eca8d36fbfb from mysql-5.7. This makes
get_best_group_min_max not to consider indexes that Mem_root_arrays
have no element for.

After that, I got non-sensical query plans (see MDEV-10325 for details).
Fixed that by making get_best_group_min_max to check if the index is in
table->keys_in_use_for_group_by bitmap.
2016-07-05 16:55:11 +03:00
Sergei Golubchik
932646b1ff Merge branch '10.1' into 10.2 2016-06-30 16:38:05 +02:00
Sergei Golubchik
ed77ee1aab cleanup: change Item::walk() to take void* not uchar*
and remove all related casts to uchar*
also remove a couple of unused methods
2016-06-30 11:43:02 +02:00
Sergei Golubchik
3361aee591 Merge branch '10.0' into 10.1 2016-06-28 22:01:55 +02:00
Sergei Petrunia
3e03b89b0a MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in
Make tree_or set correct SEL_TREE::keys_map for the result.
2016-06-22 23:20:41 +03:00
Alexander Barkov
a80dbe068c MDEV-10020 InnoDB NOT IN Query Crash When One Item Is NULL
The problem was that the loop in get_func_mm_tree()
accessed improperly initialized instances of String,
which resided in the bzero'ed part of the in_vector::base array.

Strings in in_vector::base are originally initialized
in Item_func_in::fix_length_and_dec(),
in in_vector::in_vector() using sql_calloc,
rather than using a String constructor, so their str_charset
members are originally equal to NULL.

Strings in in_vector::base are later initialized
to good values in Item_func_in::fix_length_and_dec(),
using array->set(), in this code:

      uint j=0;
      for (uint i=1 ; i < arg_count ; i++)
      {
        array->set(j,args[i]);
        if (!args[i]->null_value)                      // Skip NULL values
          j++;
        else
          have_null= 1;
      }
      if ((array->used_count= j))
        array->sort();

NULLs are not taken into account, so at the end
array->used_count can be smaller than array->count.

This patch fixes the loop in opt_range.cc, in get_func_mm_tree(),
to access only properly initialized elements in in_vector::base,
preventing access to its bzero'ed non-initialized tail.
2016-06-20 14:11:01 +04:00
Otto Kekäläinen
effbe7dd7b General spell fixing in comments and strings 2016-06-08 14:17:23 +03:00