Commit graph

65853 commits

Author SHA1 Message Date
Alexey Botchkov
76f6c1e1ed MDEV-12262 Assertion `!null_value' failed in virtual bool Item::send on
JSON_REMOVE.

        null_value wasn't properly set in Item_json_func_remove::val_str.
2017-03-20 15:18:06 +04:00
Vladislav Vaintroub
6c5cfbbf33 Fix crash (race condition) in DBUG in connect2 test case.
When "simulate_failed_connection_1"  DBUG keyword is set, current thread's
DBUG stack points to global variable in dbug (init_settings).
This global variable could be overriden while current THD is still active,
producing crash in worst scenario.

Added DBUG_SET()so that the current thread own dbug
context that cannot concurrently modified by anyone else.
2017-03-17 19:20:08 +00:00
Vladislav Vaintroub
66905f6dcb Fix several compile warnings on Windows 2017-03-17 08:56:57 +00:00
Varun Gupta
6ac754163c MDEV-10766: Queries which start with WITH clause do not get inserted into query cache
Added conditions so that the WITH queries are also added to the query cache
2017-03-15 20:15:31 +05:30
Oleksandr Byelkin
122d0701f7 MDEV-11761: CLIENT_DEPRECATE_EOF : Client must identify a "stored procedure output resultset"
fix proposed by Diego
2017-03-15 13:45:14 +01:00
Alexey Botchkov
af6eee1fc5 MDEV-11833 JSON functions don't seem to respect max_allowed_packet.
Now let's check JSON length to fit the max_allowed packet.
2017-03-14 17:31:14 +04: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
Alexey Botchkov
7c7c0696e7 MDEV-11856 json_search doesn't search for values with double quotes
character (").

        The my_wildcmp function doesn't expect the string parameter to
        have escapements, only the template. So the string
        should be unescaped if necessary.
2017-03-14 15:25:02 +04:00
Vladislav Vaintroub
a8715884a4 MDEV-11903 Windows : Support innodb page sizes in the installer/mysql_install_db.exe
- add PAGESIZE property to the MSI installer
- add combobox  to the MSI UI to select innodb page size
- add new parameter --innodb_page_size for mysql_install_db.exe.
this is passed down to bootstrap and also stored in my.ini.

MSI will call mysql_install_db.exe with --innodb_page_size set to the
PAGESIZE property
2017-03-13 18:39:11 +00:00
Oleksandr Byelkin
c0fb7b458b MDEV-10555: Server crashes in mysql_admin_table upon killing ANALYZE
Take into acount result of open table operation in mysql_admin_table.
2017-03-13 15:31:12 +01:00
Vladislav Vaintroub
f2fe5cb282 Fix several compile warnings on Windows 2017-03-10 19:07:07 +00:00
Oleksandr Byelkin
8e05953dad MDEV-11363: Assertion `!derived->first_sel ect()->first_inner_unit() || derived->first_select()->first_inner_unit()->first_select()-> exclude_from_table_unique_test' failed in TABLE_LIST::set_check_materialized()
Do not try to materialize derived table which already merged (irreversebly).
2017-03-09 19:24:17 +01:00
Oleksandr Byelkin
24cbc8dae3 MDEV-11966: Impossible to execute prepared ANALYZE SELECT
Prepare os ANALYZE now respond as EXPLAIN.
2017-03-09 11:04:51 +01:00
Daniel Black
8c3b98fe5a Whitespace correction to avoid compile warning
Introduced 2f63e2e2a

Compiler error was:

sql/log_event.cc: In function ‘size_t log_event_print_value(IO_CACHE*, const uchar*, uint, uint, char*, size_t)’:
sql/log_event.cc:2897:7: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
       if (!ptr)
       ^~
sql/log_event.cc:2900:9: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
         int32 i32= uint2korr(ptr);
         ^~~~~

Added in 950abd526

Error was:

sql/item_sum.cc:3478:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if ((!args[i]->fixed &&
     ^~
/sql/item_sum.cc:3482:7: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
       with_subselect|= args[i]->with_subselect;
       ^~~~~~~~~~~~~~

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2017-03-08 11:31:20 +04:00
Igor Babaev
2d948ebd19 Fixed bug mdev-12185.
The bug was caused by a wrong order of statements in With_clause::print().
As a result any view definition containing WITH clause with several
CTE specifications was put the frm file in a syntactically incorrect
form.
2017-03-07 21:12:59 -08:00
Marko Mäkelä
89d80c1b0b Fix many -Wconversion warnings.
Define my_thread_id as an unsigned type, to avoid mismatch with
ulonglong.  Change some parameters to this type.

Use size_t in a few more places.

Declare many flag constants as unsigned to avoid sign mismatch
when shifting bits or applying the unary ~ operator.

When applying the unary ~ operator to enum constants, explictly
cast the result to an unsigned type, because enum constants can
be treated as signed.

In InnoDB, change the source code line number parameters from
ulint to unsigned type. Also, make some InnoDB functions return
a narrower type (unsigned or uint32_t instead of ulint;
bool instead of ibool).
2017-03-07 19:07:27 +02:00
Daniel Black
c23e0fe532 whitespace - fix indenting after commit 7450cb7f6
This caused gcc-6.3.1 errors:7450cb7f6

mariadb-server/sql/sql_base.cc: In function ‘bool fix_all_session_vcol_exprs(THD*, TABLE_LIST*)’:
mariadb-server/sql/sql_base.cc:4821:7: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
       for (Field **df= t->default_field; df && *df; df++)
       ^~~
mariadb-server/sql/sql_base.cc:4826:9: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
         for (Virtual_column_info **cc= t->check_constraints; cc && *cc; cc++)
         ^~~

It was obvious from 7450cb7f6 that the indenting should of been removed

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
2017-03-01 11:32:18 +04:00
Igor Babaev
37925c6ccc Fixed bug mdev-9924.
Supported queries with window functions when GROUP BY could be
optimized away.
2017-02-15 22:41:45 -08:00
Sergei Petrunia
e688d81444 MDEV-10694 - SIGFPE and/or huge memory allocation in maria_create ...
The issue was that JOIN::rollup_write_data() used
JOIN::tmp_table_param::[start_]recinfo, which had uninitialized data.

These fields have uninitialized data, because JOIN::tmp_table_param
currently only stores some grouping-related data fields.  The data about
the work (temporary) tables themselves is stored in
join->join_tab[...].tmp_table_param.

The fix is to make JOIN::rollup_write_data follow this convention
and look at the right TMP_TABLE_PARAM object
2017-02-15 13:47:41 -08:00
Vicențiu Ciorbaru
d06a44e027 MDEV-11868: min ( distinct ) over ( ) returns wrong value
The bug was not visible in current HEAD. Introduced test case to catch
regressions. Also improve error messages regarding distinct usage in
window functions.
2017-02-15 14:09:27 +02:00
Vicențiu Ciorbaru
d474642254 MDEV-10092: Server crashes in in ha_heap::rnd_pos / Table_read_cursor::get_next
The bug was caused by several issues.
2 problems in seek_io_cache. Due to wrong offsets used, we would end up
seeking way too much (first change), or over the intended seek point
(second change). Fixing it requires correctly detecting available data
in buffer (first change), and not using "IO_SIZE alligned" reads. The
second is needed because _my_b_cache_read adjusts the pos_in_file itself
based on read_pos and read_end. Pretending buffer is empty when we want
to force a read will aleviate this problem.

Secondly, the big-table cursors didn't repect the interface definitions
of always returning the rownumber that Table_read_cursor::fetch() would activate.

At the same time, next(), prev() and move_to() should not perform any
row activation.
2017-02-15 14:09:27 +02:00
Vicențiu Ciorbaru
9fe9fb68ac MDEV-10859: Wrong result of aggregate window function in query with HAVING and no ORDER BY
Window functions need to be computed after applying the HAVING clause.
An optimization that we have for regular, non-window function, cases is
to apply having only during sending of the rows to the client. This
allows rows that should be filtered from the temporary table used to
store aggregation results to be stored there.

This behaviour is undesireable for window functions, as we have to
compute window functions on the result-set after HAVING is applied.
Storing extra rows in the table leads to wrong values as the frame
bounds might capture those -to be filtered afterwards- rows.
2017-02-15 14:09:27 +02:00
Sergei Golubchik
41f42dff06 cleanup: mtr startup warning
options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set

1. s/--log_slow_queries/--log-slow-queries/
2. disable log-slow-admin-statement/etc in mytr when doing mysqld --help
2017-02-14 20:43:41 +01:00
Sergei Golubchik
6f6d0531dc MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to work
Use JSON_COMPACT(X) instead of CAST(X AS JSON).
Bonus - X is validated to be a valid JSON.
Fix a typo in the error message.
2017-02-14 20:43:41 +01:00
Sergei Golubchik
e0fa2ce40f bugfix: uninitialized variable
fixes crashes on win32-debug
2017-02-14 20:43:41 +01:00
Alexey Botchkov
f76d5fefb8 MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to
work.

        json_detailed() fixed
2017-02-14 17:51:03 +04:00
Vicențiu Ciorbaru
d731ce21a7 MDEV-11170: MariaDB 10.2 cannot start on MySQL 5.7 datadir
PART 2 of the fix adds the logic of not using password column, unless it
exists. If password column is missing we attempt to use plugin &&
authentication_string columns.
2017-02-14 07:46:58 +02:00
Vicențiu Ciorbaru
5ab93737be MDEV-11170: MariaDB 10.2 cannot start on MySQL 5.7 datadir
PART 1 of the fix requires a bit of refactoring to not use hard-coded
field indices any more. Create classes that express the grant tables structure,
without exposing the underlying field indices.

Most of the code is converted to use these classes, except parts which
are not directly affected by the MDEV-11170. These however are TODO
items for subsequent refactoring.
2017-02-14 07:46:58 +02:00
Vicențiu Ciorbaru
dc90e24978 Define a helper class to allow for saving sql_mode using RAII
On construction the Sql_mode_save class stores the current THD's
sql_mode. On destruction, the THD's mode is restored.
2017-02-14 07:46:58 +02:00
Vicențiu Ciorbaru
bdca350f59 Allow READ_RECORD to make use of RAII and free itself on destruction 2017-02-14 07:46:58 +02:00
Vicențiu Ciorbaru
5bf338435a MDEV-11746: Wrong result upon using FIRST_VALUE with a window frame
The same approach is needed for LAST_VALUE, otherwise the LAST_VALUE sum
functions are not cleared correctly. Now LAST_VALUE behaves as NTH_VALUE
with 0 offset, only that the frame that it is examining is the bottom bound,
not the top bound.
2017-02-14 07:46:58 +02:00
Vicențiu Ciorbaru
57341852b5 MDEV-11746: Wrong result upon using FIRST_VALUE with a window frame
Reimplement FIRST_VALUE to act as NTH_VALUE with 0 offset. The previous
implementation was flawed when the window frame would remove values.
2017-02-14 07:46:58 +02:00
Vicențiu Ciorbaru
f675eab7dc MDEV-10122: MariaDB does not support group functions in some contexts where MySQL does
The problematic queries involve unions. For unions we have an
optimization where we skip the ORDER BY clause in a query from one side
of the union if it will be performed later due to UNION.
EX:
(SELECT a from t1 ORDER BY a) ORDER BY b;
The first ordering by a is not necessary and it gets removed.

The problem is that we still need to resolve the Items before removing the
ORDER BY list from the
SELECT_LEX structure. During this final resolve step however, we forgot to
allow SET functions within the ORDER BY clause. This caused us to return
an "Invalid use of group function" error during the checking performed
by fix_fields in Item_sum::init_sum_func_check.
2017-02-14 07:46:58 +02:00
Sergei Golubchik
e1f0f0dd06 Revert "MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to work"
This reverts commit 1f372cf1de.
Wasn't supposed to be pushed just yet.
2017-02-13 18:37:06 +01:00
Sergei Golubchik
1f372cf1de MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to work
remove CAST(... AS JSON) from the grammar for 10.2.4
2017-02-13 18:19:02 +01:00
Sergei Golubchik
87075e7f87 MDEV-11704 InnoDB: Failing assertion: dfield_is_null(dfield2) || dfield2->data
relax innodb assertion, because Field_blob::store() clearly says
that a data pointer can be zero if the length is zero.
2017-02-13 18:12:16 +01:00
Sergei Golubchik
239790d92f MDEV-11604 Assertion `!check_datetime_range(ltime)' failed in TIME_to_longlong_datetime_packed 2017-02-13 18:12:16 +01:00
Sergei Golubchik
1afb11074e MDEV-11582 InnoDB: Failing assertion: !((field)->vcol_info && !(field)->stored_in_db())
change the parser not to allow SERIAL as a normal data type.
make a special rule for it, where it could be used for define
fields, but not generated fields, not return type of a stored function, etc.
2017-02-13 18:12:15 +01:00
Sergei Golubchik
0df39e6037 bugfix: uninit variable 2017-02-13 18:12:15 +01:00
Sergei Golubchik
8d99166c69 MDEV-11640 gcol.gcol_select_myisam fails in buildbot on Power
JOIN_CACHE's were initialized in  check_join_cache_usage()
from make_join_readinfo(). After that make_join_readinfo() was looking
whether it's possible to use keyread. Later, after make_join_readinfo(),
optimizer decided whether to use filesort. And even later, at the
execution time, from join_read_first(), keyread was actually enabled.

The problem is, that if a query uses a vcol, base columns that it
depends on are automatically added to the read_set - because they're
needed to calculate the vcol. But if we're doing keyread, vcol is taken
from the index, not calculated, and base columns do not need to  be
in the read set (even should not be - as they aren't getting values).

The bug was that JOIN_CACHE used read_set with base columns,
they were not read because of keyread, so it was caching garbage.

So read_set is only known after the keyread was decided. And after the
filesort was decided, as filesort doesn't use keyread. But
check_join_cache_usage() needs to be done in make_join_readinfo(),
as the code below depends on these checks,

Fix: keep JOIN_CACHE checks where they were, but move initialization
down to the very end of JOIN::optimize_inner. If keyread was enabled,
update the read_set to include only columns that are part of the index.
Copy the keyread logic from join_read_first() to happen at optimize time.
2017-02-13 18:12:14 +01:00
Sergei Golubchik
0e5230e12d support keyread in READ_RECORD
make init_read_record() to detect enabled keyread
and use index_* access methods, not rnd_*

this makes MariaDB to use keyread a lot more often than before
2017-02-13 18:12:05 +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
dafb507e3e find_all_keys: add an assert, remove current_thd
Filesort temporarily changes read_set to be tmp_set and marks only
fields needed for filesort. Add an assert to ensure that it doesn't
overwrite the old value of tmp_set, that is that read_set was *not*
already tmp_set when filesort was invoked.

Fix sql_update.cc that was was doing exactly that - changing read_set to
tmp_set, configuring tmp_set for keyread, and then invoking filesort.
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
460ff39871 bugfix: don't calculate vcols if doing keyread
old code didn't calculate vcols that were part of keyread,
but calculated other vcols. It was wrong - there was no guarantee
that vcol's base columns were part of keyread.

Technically it's possible for the vcol not be a part of keyread,
but all its base columns being part of keyread. But currently the
optimizer doesn't do that, keyread is only used if it covers
all columns used in the query.

This fixes crashes of vcol.vcol_trigger_sp_innodb
2017-02-13 18:12:05 +01:00
Sergei Golubchik
3cae225b0f cleanup: remove TABLE::add_read_columns_used_by_index
TABLE::add_read_columns_used_by_index() is conceptually wrong,
it *adds* columns used by index to the bitmap, without clearing
it first. But it also enables keyread, meaning that *only* columns
from the index will be read. It is supposed to be used to
add columns used by an index to a bitmap that already has columns
of a primary key - for engines where a primary key is part of every
index.

The correct fix is to change mark_columns_used_by_index() to
take into account extended keys.

this reverts 1d0acc7754 and cf97cbd1db
2017-02-13 18:12:05 +01:00
Sergei Golubchik
9fa6589f64 bugfix: TABLE::mark_columns_used_by_index_no_reset
it should not mark base columns that a vcol depends on, because
keyread (on a vcol) will not read them
2017-02-13 18:12:05 +01:00
Sergei Golubchik
4dd7e11332 cleanup: mark_columns_used_by_index_no_reset in handler::get_auto_increment
use table->mark_columns_used_by_index, don't copy it
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
0254f1a6e0 bugfix: TABLE::mark_columns_used_by_index
Do *not* modify write_set.
keyread only affects what columns are *read*, UPDATE statement can
*write* into columns that aren't part of the keyread.
2017-02-13 18:12:04 +01:00