Commit graph

66124 commits

Author SHA1 Message Date
Sergei Golubchik
da4d71d10d Merge branch '10.1' into 10.2 2017-03-30 12:48:42 +02:00
Jacob Mathew
3c422e60bb MDEV-11115 CHECK constraints are not shown in I_S.TABLE_CONSTRAINTS
Added CHECK constraints to I_S.TABLE_CONSTRAINTS.
Fixed a bug regarding virtual column definitions whose name is the field name.
Added test case: check_constraint_show
2017-03-29 12:07:33 -07:00
Igor Babaev
4ebdef2bcd Fixed bug mdev-12336.
The function Item::split_sum_func2() incorrectly processed the function
items with window functions that were not window functions themselfes
and were used as arguments of other functions.
2017-03-29 08:46:00 -07:00
Igor Babaev
f381e73f7d Fixed bug mdev-11907.
With the current design the function copy_funcs() should ignore
the items with window functions from the array **func_ptr.
2017-03-29 08:46:00 -07:00
Alexander Barkov
c5520a37d6 MDEV-12390 Wrong error line numbers reported with sql_mode=IGNORE_SPACE 2017-03-29 07:21:34 +04:00
Sergei Golubchik
7a1b0582d6 MDEV-11114 Cannot drop column referenced by CHECK constraint: Unknown column 'a' in 'virtual column function'
clarify the error message
2017-03-29 00:40:21 +02:00
Sergei Golubchik
33ec445975 MDEV-10370 Check constraints on virtual columns fails on INSERT when column not specified
add columns needed for CHECK constraints not only to read_set,
but also to vcol_set.
2017-03-29 00:40:21 +02:00
Sergei Golubchik
98a5ee9d75 MDEV-12105 MySQL 5.7 and MariaDB 10.2 error codes are out of sync 2017-03-29 00:40:21 +02:00
Sergei Golubchik
bf40e8069c MDEV-11059 don't build the server with jemalloc
don't build the server with jemalloc.
only build tokudb with it.
move tokudb into a separate package, because it brings a new dependency
2017-03-29 00:40:21 +02:00
Alexey Botchkov
da5c3e03f6 MDEV-9255 Add generation_expression to information_schema.columns.
Added IS_GENERATED and GENERATION_EXPRESSION columns required by
        the SQL standard
2017-03-28 23:36:33 +04:00
Igor Babaev
93dd70ced8 Fixed bug mdev-12375.
The function st_select_lex_unit::exec_recursive() incorrectly determined
that a CTE mutually recursive with some others was stabilized in the case
when the non-recursive part of the CTE returned an empty set. As a result
the server fell into an infinite loop when executing a query using
this CTE.
2017-03-27 14:41:17 -07:00
Igor Babaev
ad7da60ded Fixed bug mdev-12368.
Mutually recursive CTE could cause a crash of the server in the case
when they were not Standard compliant. The crash happened in
mysql_derived_prepare(), because the destructor the derived_result
object created for a CTE that was mutually recursive with some others
was called twice. Yet this destructor should not be called for resursive
references.
2017-03-26 23:00:28 -07:00
Igor Babaev
5a4537f092 Fixed bug mdev-12360.
The method With_element::check_unrestricted_recursive() icorrectly performed
the check that no recursive reference is not encountered in inner parts of
outer joins. As a result the server reported errors for valid specifications
with outer joins.
2017-03-26 23:00:28 -07:00
Vladislav Vaintroub
716188f1d4 Fix some warnings on Windows compilation
- silence warnings in ed25519 reference implementation
- fix signed/unsigned warning in popular header item_func.h
2017-03-24 10:10:36 +01:00
Vladislav Vaintroub
e5b67a46bc MDEV-12345 Performance : replace calls to clock() inside trx_start_low() by THD::start_utime 2017-03-23 11:50:22 +00:00
Alexey Botchkov
92f18bdede MDEV-11177 mysqlbinlog exits silently without error when another
instance connects to server.

        New thread kill status added KILL_SLAVE_SAME_ID, and the related
        error message.
2017-03-22 01:48:22 +04:00
Sergei Golubchik
09a2107b1b Merge branch '10.0' into 10.1 2017-03-21 19:20:44 +01:00
Sergei Golubchik
0d622bed4f Merge branch '5.5' into 10.0 2017-03-21 11:35:50 +01:00
Sachin Setiya
9cf499724f Merge branch '10.0' into bb-10.0-galera 2017-03-20 18:11:56 +05:30
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
8efdf89e42 MDEV-12126 Correct German error message. 2017-03-17 20:07:39 +00: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
Sachin Setiya
f66395f7c0 Merge tag 'mariadb-10.0.30' into bb-sachin-10.0-galera-merge
Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
2017-03-17 02:05:20 +05:30
Monty
2d0c579a86 Wait for slave threads to start during startup
- Before this patch during startup all slave threads was started without
  any check that they had started properly.
- If one did a START SLAVE, STOP SLAVE or CHANGE MASTER as first command to the server
  there was a chance that server could access structures that where not
  properly  initialized which could lead to crashes in
  Log_event::read_log_event
- Fixed by waiting for slave threads to start up properly also during
  server startup, like we do with START SLAVE.
2017-03-16 14:21:33 +02:00
Monty
e7f55fde88 Removed wrong assert
The following is an updated commit message for the following commit
that was pushed before I had a chance to update the commit message:
c5e25c8b40

Fixed dead locks when doing stop slave while slave was starting.

- Added a separate lock for protecting start/stop/reset of a specific slave.
  This solves some possible dead locks when one calls stop slave while
  the slave is starting as the old run_locks was over used for other things.
- Set hash->records to 0 before calling free of all hash elements.
  This was set to stop concurrent threads to loop over hash elements and
  access members that was already freed.
  This was a problem especially in start_all_slaves/stop_all_slaves
  as the mutex protecting the hash was temporarily released while a slave
  was started/stopped.
- Because of change to hash->records during hash_reset(),
  any_slave_sql_running() will return 1 during shutdown as one can't
  loop over master_info_index->master_info_hash while hash_reset() of it
  is in progress.
  This also fixes a potential old bug in any_slave_sql_running() where
  during shutdown and ~Master_info_index(), my_hash_free() we could
  potentially try to access elements that was already freed.
2017-03-16 14:21:32 +02:00
Sachin Setiya
5bb7653667 Fix wsrep_affected_rows.
The value of wsrep_affected_rows were not reseted properly for
slave. Now we also wsrep_affected_rows in Xid_log_event::do_apply_event
also , apart from THD::cleanup_after_query().

Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
2017-03-16 02:13:31 +05:30
Sergei Golubchik
2c2bd8c155 MDEV-12261 build failure without P_S
restore mysql_file_delete_with_symlink() but let it use
new my_handler_delete_with_symlink() mysys helper.
2017-03-15 17:48:30 +01: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
Varun Gupta
adbe1c5fe9 MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
failed with SELECT SQ, TEXT field

The functon find_all_keys does call Item_subselect::walk, which calls walk() for the subquery
The issue is that when a field is represented by Item_outer_ref(Item_direct_ref(Item_copy_string( ...))).
Item_copy_string does have a pointer to an Item_field in Item_copy::item but does not implement Item::walk method, so we are not
able to set the bitmap for that field. This is the reason why the assert fails.

Fixed by adding the walk method to Item_copy class.
2017-03-14 17:31:29 +05:30
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
Sachin Setiya
00f1ed6655 Galera MTR Tests: fix variable output in galera_as_slave_gtid_replicate_do_db.result
Signed-off-by: Sachin Setiya <sachinsetia1001@gmail.com>
2017-03-14 14:44:53 +05:30
sjaakola
471dd11381 refs: MW-319
* silenced the WSREP_ERROR, this fires for all replication filtered DDL,
  and is false positive
2017-03-14 11:49:45 +05:30
Daniele Sciascia
9dda6cb08d MW-313 Enforce wsrep_max_ws_rows also when binlog is enabled 2017-03-14 11:11:18 +05:30
Vladislav Vaintroub
98be67266d Fix truncation of affected rows and insert id in select_insert::send_ok_packet 2017-03-13 23:13:24 +00:00
Vicențiu Ciorbaru
06f1f1aa6e Make ELOOP be considered a File Not Found error when it comes from handlerton
Fix symlink-aria && symlink-myisam to account for this possibility.
2017-03-14 00:25:26 +02: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
Sachin Setiya
9be994ba69 MW-309 Fix wsrep_max_ws_rows so that it does not affect queries
Option wsrep_max_ws_rows is intended to limit the maximum number of rows
in a writeset. To enforce this limit, we increment THD::wsrep_affected_rows
on every INSERT, UPDATE or DELETE. The problem is that we do so even on
insertion to internal temporary tables used for SELECTs and such.
THD::wsrep_affected_rows is now incremented only for rows that are actually
replicated.

Signed-off-by: Sachin Setiya <sachinsetia1001@gmail.com>
2017-03-13 05:30:02 +05:30
Sergei Petrunia
5b30c7896e Merge branch '10.2' of github.com:MariaDB/server into bb-10.2-mariarocks 2017-03-11 20:12:15 +00:00
Vladislav Vaintroub
f2fe5cb282 Fix several compile warnings on Windows 2017-03-10 19:07:07 +00:00
iangilfillan
f0ec34002a Correct FSF address 2017-03-10 18:21:29 +01:00
Sergei Golubchik
227f63db3b cleanup: sort various lists of services 2017-03-10 18:21:28 +01:00
Sergei Golubchik
0877eff401 thd_rnd service 2017-03-10 18:21:27 +01:00
Sergei Golubchik
6305533de2 Auth Plugin API: add THD to MYSQL_SERVER_AUTH_INFO
so that auth plugins could use various thd services
2017-03-10 18:21:27 +01:00
Sergei Golubchik
051851b9a6 base64 service 2017-03-10 18:21:27 +01:00
Sergei Golubchik
70a2efde03 remove old API for SHA2 2017-03-10 18:21:27 +01:00
Sergei Golubchik
d6a7aece08 my_sha2 service 2017-03-10 18:21:26 +01:00
Sergei Golubchik
bd1139ad27 cleanup: generalize my_sha1.cc
move most of the code into my_sha.ic, making it independent
from the actual SHAx variant.
2017-03-10 18:21:26 +01:00
Sergei Golubchik
6cddd12ad6 make sql_udf.cc to shorten dlerror() messages
just as sql_plugin.cc does
2017-03-10 18:21:26 +01:00
Sergei Golubchik
8f1ca5e311 MDEV-11943 I_S.TABLES inconsistencies with tables with unknown storage engine
Try harder to show the table's engine.

If the table's engine is not loaded, the table won't open.
But we can still read the engine name from frm as a string.
2017-03-10 18:21:24 +01:00
Sergei Golubchik
48b1d17534 MDEV-11943 I_S.TABLES inconsistencies with tables with unknown storage engine
Make SELECT <columns> FROM I_S.TABLES behave identically independently
from whether <columns> require opening the table in engine or
<columns> can be filled with only opening the frm.

In particular, fill_schema_table_from_frm() should not silently skip
frms with unknown engine, but should fill the I_S.TABLES row
with NULLs just like fill_schema_table_by_open() does.
2017-03-10 18:21:24 +01:00
Sergei Golubchik
25c32c89f1 trivial cleanup 2017-03-10 18:21:24 +01:00
Sergei Golubchik
8eb66bc382 cleanup: change dd_frm_type() to return the engine name, not legacy_db_type
this simplifies the code and avoids unnecessary conversions back and forth.
and it works even if the engine is not installed.
2017-03-10 18:21:23 +01:00
Sergei Golubchik
5fa04aae9e MDEV-11842 Fail to insert on a table where a field has no default
has_no_default_value() should only fail the insert in the strict mode.

Additionally, don't check for "all fields are given values" twice,
it'll produce duplicate warnings.
2017-03-10 18:21:23 +01:00
Marko Mäkelä
0094b6581d Merge 10.0 into 10.1 2017-03-10 15:16:13 +02: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
Sergei Petrunia
2abc313c37 Use correct function name in DEBUG_ENTER 2017-03-09 12:34:06 +03:00
Marko Mäkelä
8805fe0d5c Use %pure-parser instead of the deprecated %pure_parser. 2017-03-09 11:27:24 +02:00
Marko Mäkelä
2158de8865 Remove unused variables. 2017-03-09 11:26:36 +02: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
Marko Mäkelä
47396ddea9 Merge 5.5 into 10.0
Also, implement MDEV-11027 a little differently from 5.5:

recv_sys_t::report(ib_time_t): Determine whether progress should
be reported.

recv_apply_hashed_log_recs(): Rename the parameter to last_batch.
2017-03-08 11:40:43 +02:00
Marko Mäkelä
6860a4b556 MDEV-12206 Query_cache::send_result_to_client() may corrupt THD::query_plan_flags
This is essentially a backport of the 10.0
commit 203f4d4193
that fixes a bug and silences a GCC 6.3.0 warning
about a left shift of a signed integer.

Missing parenthesis in a macro definition caused wrong operation
in the Query_cache::send_result_to_client() statement
   thd->query_plan_flags= (thd->query_plan_flags & ~QPLAN_QC_NO) | QPLAN_QC;

This would expand to
   thd->query_plan_flags= (thd->query_plan_flags & ~1) << 6 | 1 << 5;

which would shift the flags by 6 and clear an unrelated flag, instead
of clearing the flag (1 << 6).
2017-03-08 10:31:06 +02: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
Sergey Vojtovich
19629ebf81 MDEV-10646 - System Unit File After network-online
Bind to an address even if it is not yet configured.
2017-03-07 22:28:33 +04: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
Vicențiu Ciorbaru
c4f3e64c23 Merge branch 'bb-10.0-vicentiu' into 10.0 2017-03-06 21:50:42 +02:00
Tor Didriksen
e823023e4b Bug#18411494 WRONG COMPARSION ON BIG DECIMAL VALUES
Problem: integer literals may be converted to floats for
comparison with decimal data. If the integers are large,
we may lose precision, and give wrong results.

Fix: for
  <non-const decimal expression> <cmp> <const string expression>
  or
  <const string expression> <cmp> <non-const decimal expression>
we override the compare_type chosen by item_cmp_type(), and
do comparison as decimal rather than float.

(cherry picked from commit 1cf3489ba4 and edited by Johannes Weißl <jargon@molb.org>)
2017-03-06 23:36:48 +04:00
Varun Gupta
43903745e5 MDEV-11078: NULL NOT IN (non-empty subquery) should never return results
Disabling the cond guards during the creation of Tricond Item for
constant and NULL left expression items
2017-03-05 10:58:05 +05:30
Vicențiu Ciorbaru
f4806772d3 Add missing DBUG_RETURN 2017-03-03 20:16:16 +02:00
Marko Mäkelä
adc91387e3 Merge 10.0 into 10.1 2017-03-03 13:27:12 +02:00
Vicențiu Ciorbaru
1acfa942ed Merge branch '5.5' into 10.0 2017-03-03 01:37:54 +02:00
Sergey Vojtovich
c1c5b7a8d2 Fixed missing DBUG_RETURN 2017-03-01 11:41:48 +04:00
Sergey Vojtovich
e9ad4bdb42 MDEV-11221 - main.events_restart failed in bb
Applied lost in a merge revision 7f38a07:

MDEV-10043 - main.events_restart fails sporadically in buildbot (crashes upon
             shutdown)

There was race condition between shutdown thread and event worker threads.

Shutdown thread waits for thread_count to become 0 in close_connections(). It
may happen so that event worker thread was started but didn't increment
thread_count by this time. In this case shutdown thread may miss wait for this
working thread and continue deinitialization. Worker thread in turn may continue
execution and crash on deinitialized data.

Fixed by incrementing thread_count before thread is actually created like it is
done for connection threads.

Also let event scheduler not to inc/dec running threads counter for symmetry
with other "service" threads.
2017-03-01 11:35:24 +04: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
Oleksandr Byelkin
75f6067e89 MDEV-9635: Server crashes in part_of_refkey or assertion `!created && key_to_save < (int)s->keys' failed in TABLE::use_index(int) or with join_cache_level>2
Do not try to create index where ref is for hash join.
2017-02-28 20:52:26 +01:00
Sergei Golubchik
370cf70136 MDEV-11757 KEY_BLOCK_SIZE strangeness when UNCOMPRESSing COMPRESSed InnoDB tables
in ALTER TABLE ... DROP KEY, ADD KEY, don't forget to compare old
and new keys' block sizes. If they differ - the key definition has changed.
2017-02-28 16:19:44 +01:00
Monty
6a12c05347 Fixed wrong arguments to sql_print_error() 2017-02-28 16:10:47 +01:00
Monty
84ed5e1d5f Fixed hang doing FLUSH TABLES WITH READ LOCK and parallel replication
The problem was that waiting for pause_for_ftwrl was done before
event_group was completed. This caused rpl_pause_for_ftwrl() to wait
forever during FLUSH TABLES WITH READ LOCK.
Now we only wait for FLUSH TABLES WITH READ LOCK when we are changing
to a new event group.
2017-02-28 16:10:47 +01:00
Monty
f3c65ce951 Add protection to not access is_open() without LOCK_log mutex
Protection added to reopen_file() and new_file_impl().

Without this we could get an assert in fn_format() as name == 0,
because the file was closed and name reset, atthe same time
new_file_impl() was called.
2017-02-28 16:10:47 +01:00
Monty
b624b41abb Don't allow one to kill START SLAVE while the slaves IO_THREAD or SQL_THREAD
is starting.

This is needed as if we kill the START SLAVE thread too early during
shutdown then the IO_THREAD or SQL_THREAD will not have time to properly
initlize it's replication or THD structures and clean_up() will try to
delete master_info structures that are still in use.
2017-02-28 16:10:47 +01:00
Monty
4bad74e139 Added error checking for all calls to flush_relay_log_info() and stmt_done() 2017-02-28 16:10:47 +01:00
Monty
a2de378c00 Add protection for reinitialization of mutex in parallel replaction
Added mutex_lock/mutex_unlock of mutex that is to be destroyed in
wait_for_commit::reinit() in a similar fashion that we do in
~wait_for_commit
2017-02-28 16:10:47 +01:00
Monty
c5e25c8b40 Added a separate lock for start/stop/reset slave.
This solves some possible dead locks when one calls stop slave while slave
is starting.
2017-02-28 16:10:46 +01:00
Monty
e65f667bb6 MDEV-9573 'Stop slave' hangs on replication slave
The reason for this is that stop slave takes LOCK_active_mi over the
whole operation while some slave operations will also need LOCK_active_mi
which causes deadlocks.

Fixed by introducing object counting for Master_info and not taking
LOCK_active_mi over stop slave or even stop_all_slaves()

Another benefit of this approach is that it allows:
- Multiple threads can run SHOW SLAVE STATUS at the same time
- START/STOP/RESET/SLAVE STATUS on a slave will not block other slaves
- Simpler interface for handling get_master_info()
- Added some missing unlock of 'log_lock' in error condtions
- Moved rpl_parallel_inactivate_pool(&global_rpl_thread_pool) to end
  of stop_slave() to not have to use LOCK_active_mi inside
  terminate_slave_threads()
- Changed argument for remove_master_info() to Master_info, as we always
  have this available
- Fixed core dump when doing FLUSH TABLES WITH READ LOCK and parallel
  replication. Problem was that waiting for pause_for_ftwrl was not done
  when deleting rpt->current_owner after a force_abort.
2017-02-28 16:10:46 +01:00
iangilfillan
ce903428a8 Update MariaDB Foundation sponsors 2017-02-28 17:15:36 +04:00
Vladislav Vaintroub
d4baeca441 Windows : Fix server compile errors when compile with /Zc:strictStrings option 2017-02-28 12:57:33 +00:00
Igor Babaev
5a0fff50f8 Fixed bug mdev-12099.
The function mysql_derived_merge() erroneously did not mark newly formed
AND formulas in ON conditions with the flag abort_on_null. As a result
not_null_tables() calculated incorrectly for these conditions. This
could prevent conversion of embedded outer joins into inner joins.

Changed a test case from table_elim.test to preserve the former execution
plan.
2017-02-27 09:02:41 -08:00
Sergei Golubchik
199f88cb9c MDEV-5999 MySQL Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY - REQUIRES FLUSH PRIVILEGES
use update_hostname() to update the hostname.
test case comes from

  commit 0abdeed1d6d
  Author: gopal.shankar@oracle.com <>
  Date:   Thu Mar 29 00:20:54 2012 +0530

    Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY -
                          REQUIRES FLUSH PRIVILEGES
2017-02-27 12:35:10 +01:00
Dmitry Lenev
494a94158a Fix for bug#11759114 - '51401: GRANT TREATS NONEXISTENT
FUNCTIONS/PRIVILEGES DIFFERENTLY'.

The problem was that attempt to grant EXECUTE or ALTER
ROUTINE privilege on stored procedure which didn't exist
succeed instead of returning an appropriate error like
it happens in similar situation for stored functions or
tables.

The code which handles granting of privileges on individual
routine calls sp_exist_routines() function to check if routine
exists and assumes that the 3rd parameter of the latter
specifies whether it should check for existence of stored
procedure or function. In practice, this parameter had
completely different meaning and, as result, this check was
not done properly for stored procedures.

This fix addresses this problem by bringing sp_exist_routines()
signature and code in line with expectation of its caller.
2017-02-27 12:35:10 +01:00
Sergei Golubchik
d72dbb4122 bugfix: remove my_delete_with_symlink()
it was race condition prone. instead use either a pair of my_delete()
calls with already resolved paths, or a safe high-level function
my_handler_delete_with_symlink(), like MyISAM and Aria already do.
2017-02-27 12:35:10 +01:00
Sergei Golubchik
955f2f036d race-condition safe implementation of test_if_data_home_dir()
don't realpath() twice
2017-02-27 12:35:10 +01:00
Sergei Golubchik
f2d24ea68b compilation failure
At least it would be a compilation failure with -DDONT_ALLOW_SHOW_COMMANDS.
Otherwise it only confuses ctags to ignore ~75% of sql_parse.cc
2017-02-27 12:35:10 +01:00
Sergei Golubchik
b27fd90ad3 MDEV-11902 mi_open race condition
TOCTOU bug. The path is checked to be valid, symlinks are resolved.
Then the resolved path is opened. Between the check and the open,
there's a window when one can replace some path component with a
symlink, bypassing validity checks.

Fix: after we resolved all symlinks in the path, don't allow open()
to resolve symlinks, there should be none.

Compared to the old MyISAM/Aria code:
* fastpath. Opening of not-symlinked files is just one open(),
  no fn_format() and lstat() anymore.
* opening of symlinked tables doesn't do fn_format() and lstat() either.
  it also doesn't to realpath() (which was lstat-ing every path
  component), instead if opens every path component with O_PATH.
* share->data_file_name stores realpath(path) not readlink(path). So,
  SHOW CREATE TABLE needs to do lstat/readlink() now (see ::info()),
  and certain error messages (cannot open file "XXX") show the real
  file path with all symlinks resolved.
2017-02-27 12:35:10 +01:00
Sergei Golubchik
c826ac9d53 cleanup: mysys_test_invalid_symlink
Remove maria_test_invalid_symlink() and myisam_test_invalid_symlink(),
introduce mysys_test_invalid_symlink(). Other engines might need it too
2017-02-27 12:35:10 +01:00
Sergei Golubchik
3cba74e032 cleanup: fn_format, remove dead code
my_realpath() ignores MY_xxx flags anyway
2017-02-27 12:35:10 +01:00
Sergei Golubchik
924a81a548 bugfix: DEBUG_SYNC() invoked with no THD
While DEBUG_SYNC doesn't make sense without a valid THD, it might
be put in the code that's invoked both within and outside of a
THD context (e.g. in maria_open(), there is no THD during recovery).
2017-02-27 12:35:10 +01:00
Sergei Golubchik
8897b50dca MDEV-11525 Assertion `cp + len <= buff + buff_size' failed in JOIN_CACHE::write_record_data
Workaround for join_cache + index on vcols + keyread bug.
Initialize the record to avoid caching garbage in non-read fields.

A proper fix (do not cache non-read fields at all) is done in 10.2
in commits 5d7607f340f..8d99166c697
2017-02-27 12:35:10 +01:00
Oleksandr Byelkin
e5b877ce27 MDEV-11935: Queries in stored procedures with and EXISTS(SELECT * FROM VIEW) crashes and closes hte conneciton.
Use correct start point even for taken out from subselect items in process of exists2in conversion.
2017-02-27 10:12:17 +01:00
Alexey Botchkov
fdeeab01c0 MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
ALTER_CONVERT flag removed and replaced for ALTER_OPTIONS
        for the CONVERT TO CHARACTER SET command.
2017-02-26 23:01:23 +04:00
Igor Babaev
ac78927aef Fixed bug mdev-7992.
'Not exists' optimization can be used for nested outer joins
only if IS NULL predicate from the WHERE condition is activated.
So we have to check that all guards that wrap this predicate
are in the 'open' state.
This patch supports usage of 'Not exists' optimization for any
outer join, no matter how it's nested in other outer joins.

This patch is also considered as a proper fix for bugs
#49322/#58490 and LP #817360.
2017-02-24 09:40:53 -08:00
Dyre Tjeldvoll
7849a27cfb Bug#25514146: DB_NAME IS IGNORED WHEN CREATING TABLE WITH DATA DIRECTORY
Problem: CREATE TABLE using a fully qualified name with INDEX DIR/DATA DIR
option reports an error when the current database is not SET.

check_access() was incorrectly called with NULL as the database
argument in a situation where the database name was not needed for
the particular privilege being checked. This will cause the current
database to be used, or an error to be reported if there is no current
database.

Fix: Call check_access() with any_db as the database argument in this situation.
2017-02-23 14:48:25 +01:00
Ajo Robert
b21a0212e4 Bug#23195404 EXCESSIVE MEMORY CAN BE USED BY THE QUOTE()
STRING FUNCTION

Fix:
=======
Added code in QUOTE string function to honor max_allowed_packet.
2017-02-23 18:27:09 +05:30
Alexey Botchkov
cf673adee2 MDEV-10418 Assertion `m_extra_cache' failed in
ha_partition::late_extra_cache(uint).

        m_extra_prepare_for_update should be cleaned in
        ha_partition::reset()
2017-02-22 01:36:16 +04: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
Igor Babaev
f49375fddf Fixed bug mdev-9028.
This patch is actually a complement for the fix of bug mdev-6892.
The procedure create_tmp_table() now must take into account
Item_direct_refs that wrap up constant fields of derived tables/views
that are used as inner tables in outer join operations.
2017-02-16 23:44:54 -08:00
Alexander Kuleshov
29d78dbb44 minor typo in a description of mysql_parse() 2017-02-16 17:55:57 +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
Sergei Golubchik
5d7607f340 cleanup: style fixes, sql_join_cache.cc 2017-02-13 18:12:04 +01:00
Sergei Golubchik
8246b0ac50 cleanup: TABLE::non_determinstic_insert
move the check where it make sense, remove incorrect comment
2017-02-13 18:12:04 +01:00
Sergei Golubchik
d2f84ab978 MDEV-10352 Server crashes in Field::set_default on CREATE TABLE
fix Item_default_value not to pretend being const_item
if the field's default_value expression isn't parsed yet
2017-02-13 18:12:04 +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
Sergei Golubchik
eda2ebefba MDEV-11784 View is created with invalid definition which causes ERROR 1241 (21000): Operand should contain 1 column(s)
set the correct print precedence for IN subqueries
2017-02-13 18:12:04 +01:00
Sergei Golubchik
cf00393378 Race condition in DEFAULT() with expressions
Item_default_value::calculate was updating table->s->default_values,
but it is supposed to be read-only
2017-02-13 18:12:04 +01:00
Sergei Golubchik
cd4dd2b62d MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4)
Optionally do table->update_default_fields() even for INSERT
that supposedly provides values for all column. Because these
"values" might be DEFAULT, which would need table->update_default_fields()
at the end.

Also set Item_default_value::used_tables() from the default expression.
Non-zero used_field() means that mysql_insert() will initialize all
fields to their default values (with restore_record()) even if
all columns are later provided with values. Because default expressions
may refer to other columns and they must be initialized.
2017-02-13 18:12:04 +01:00
Igor Babaev
d35aea5407 Fixed bugs mdev-12051, mdev-10885.
These are different bugs, but the fixing code is the same:
if window functions are used over implicit grouping then
now the execution should follow the general path calling
the function set in JOIN::first_select.
2017-02-12 15:50:14 -08:00
Sergei Golubchik
f3914d10b6 Merge branch 'bb-10.2-serg-merge' into 10.2 2017-02-11 09:45:34 +01:00
Igor Babaev
5593458062 Fixed bug mdev-12015.
Corrected an assertion in JOIN::create_postjoin_aggr_table():
JOIN::join_tab[0] can be the first aggregation table if
the query uses window functions.
2017-02-10 17:21:45 -08:00
Sergei Golubchik
2195bb4e41 Merge branch '10.1' into 10.2 2017-02-10 17:01:45 +01:00
Vladislav Vaintroub
1b4f694adf MDEV-10291 : Fix race condition in bootstrap
main thread may destroy mutexes that bootstrap is using in
THD destructor.
2017-02-10 14:17:19 +00:00
Nirbhay Choubey
c0209f8736 MDEV-11908: New default configuration produces warnings about itself upon startup
Print the message as a note instead of warning.
2017-02-10 06:30:42 -05:00
Nirbhay Choubey
616f4a773a MDEV-7635: Reset sync_binlog back to 0 2017-02-10 06:30:42 -05:00
Nirbhay Choubey
f556aa9b5f MDEV-7635: SET shouldn't fail for invalid values in strict trans mode 2017-02-10 06:30:42 -05:00
Nirbhay Choubey
04b52a0745 MDEV-7635: Part 2
New default sql_mode includes:
* STRICT_TRANS_TABLES
* ERROR_FOR_DIVISION_BY_ZERO
* NO_ENGINE_SUBSTITUTION
* NO_AUTO_CREATE_USER
2017-02-10 06:30:42 -05:00
Nirbhay Choubey
f8aa54f1bc MDEV-11685: sql_mode can't be set with non-ascii connection charset
The supplied sql_mode(s) should be converted to ASCII first,
before comparing it with the sql_mode set.
2017-02-10 06:30:42 -05:00
Nirbhay Choubey
3435e8a515 MDEV-7635: Part 1
innodb_autoinc_lock_mode            = 2
innodb_buffer_pool_dump_at_shutdown = ON
innodb_buffer_pool_dump_pct         = 25
innodb_buffer_pool_load_at_startup  = ON
innodb_checksum_algorithm           = CRC32
innodb_file_format                  = Barracuda
innodb_large_prefix                 = ON
innodb_log_compressed_pages         = ON
innodb_purge_threads                = 4
innodb_strict_mode                  = ON
binlog_annotate_row_events          = ON
binlog_format                       = MIXED
binlog-row-event-max-size           = 8192
group_concat_max_len                = 1M
lock_wait_timeout                   = 86400
log_slow_admin_statements           = ON
log_slow_slave_statements           = ON
log_warnings                        = 2
max_allowed_packet                  = 16M
replicate_annotate_row_events       = ON
slave_net_timeout                   = 60
sync_binlog                         = 1
aria_recover                        = BACKUP,QUICK
myisam_recover_options              = BACKUP,QUICK
2017-02-10 06:30:42 -05:00
Nirbhay Choubey
185d140f19 MDEV-7635: Renamed standards_compliant_cte to standard_compliant_cte 2017-02-10 06:30:42 -05:00
Oleksandr Byelkin
25f6d1dad7 Unused code removed. 2017-02-10 10:22:03 +01:00
Oleksandr Byelkin
ae3072c0af MDEV-10554: Assertion `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed in TABLE_LIST::set_check_merged()
Mark and check excluded because of merging derived tables and views.
2017-02-10 10:22:03 +01:00
Oleksandr Byelkin
ee51f58236 MDEV-10340: support COM_RESET_CONNECTION 2017-02-10 09:56:33 +01:00
Igor Babaev
78b5e8d6ca Fixed bug mdev-11745.
Due to this bug many queries that contained a window function
with MIN/MAX aggregation returned wrong results.

Calculation of a MIN/MAX aggregate function uses cache objects
and a comparator object that are created and set up in
Item_sum_hybrid::fix_fields () by a call of Item_sum_hybrid::setup_hybrid().
The latter binds the objects to the first argument of the
MIN/MAX function. Meanwhile window function perform aggregation
over fields of a temporary table. So binding must be done rather to
these fields. The earliest moment when setup the objects used in
MIN/max functions can be done is after all calls of the method
split_sum_func().

This patch introduces this late setup, but only for aggregate
functions used in window functions.
Probably it makes sense to use this late setup for all MIN/MAX
objects.
2017-02-09 19:34:01 -08:00
Alexey Botchkov
25aaecb240 MDEV-11858 json_merge() concatenates instead of merging.
Fix json_merge implementation.
2017-02-10 01:05:27 +04:00
Varun Gupta
c2b217e243 MDEV-10731: Wrong NULL match results in "Subquery returns more than 1 row" (error code 1242)
NOT NULL predicate was not added to tables in case of an update query having a subquery.
2017-02-09 23:49:23 +05:30
Sergei Golubchik
ddb284afaa MDEV-11601 Out-of-bounds string access in create_schema_table()
in Item_partition_func_safe_string(THD *thd, const char *name_arg,
uint length, CHARSET_INFO *cs= NULL), the 'name_arg' is the value
of the string constant and 'length' is the length of this constant,
so length == strlen(name_arg).
2017-02-09 16:03:56 +02:00
Marko Mäkelä
5ffbd084f5 Revert an accidental commit to work around MDEV-11601. 2017-02-09 16:02:57 +02:00
Alexey Botchkov
0e6968c244 MDEV-11857 json_search() shows "Out of memory" with empty key.
We should be ready for an empty key.
2017-02-09 17:38:53 +04:00
Marko Mäkelä
66c6188a4b Relax assertions on shutdown after aborted startup.
A proper InnoDB shutdown after aborted startup was introduced
in commit 81b7fe9d38.

Also related to this is MDEV-11985, making read-only shutdown more robust.

If startup was aborted, there may exist recovered transactions that were
not rolled back. Relax the assertions accordingly.
2017-02-09 10:18:46 +02:00
Oleksandr Byelkin
a75633b5bd MDEV-11681: PARTITION BY LIST COLUMNS with default partition: Assertion `part_info->num_list_values' failed in get_part_iter_for_interval_cols_via_map
process adge case with only default partition
2017-02-08 10:22:42 +01:00
Nirbhay Choubey
6da2adfaa2 MDEV-12005: GET_LOCK: Fractional part of timeout is ignored
In order to include the fractional part, convert lock_wait_timeout
(in secs) to nanoseconds before calculating the absolute time for
timeout.
2017-02-07 13:54:46 -05:00
Igor Babaev
c16c9e8e76 Fixed bug mdev-11999.
This patch complements the patch for bug 11138.
Without this patch some table-less queries with window functions
could cause crashes due to a memory overwrite.
2017-02-06 22:12:53 -08:00
Alexey Botchkov
abf7582112 MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
Fixes for issues found.
2017-02-06 06:47:48 +04:00
Igor Babaev
e51b015fc3 Fixed bug mdev-11138.
Supported usage of expressions with window functions
in SELECTs without tables.
2017-02-04 21:51:40 -08:00
Igor Babaev
20aae56efa Fixed bug mdev-10660.
The method Item_sum::print did not print opening '(' after the name
of simple window functions (like rank, dense_rank etc).
As a result the view definitions with such window functions
were formed invalid in .frm files.
2017-02-03 15:50:25 -08:00
Igor Babaev
fd7accabbb Fixed bug mdev-9923.
Partition and order lists of a window specification cannot
use constant integer to refer to select list elements.
2017-02-03 00:10:36 -08:00
Igor Babaev
5606f878bf Fixed bug mdev-11594.
Using window functions over results of implicit groupings
required special handling in JOIN::make_aggr_tables_info.
The patch made sure that the result of implicit grouping
was written into a temporary table properly.
2017-02-02 18:01:35 -08:00
Alexey Botchkov
d123ed852a MDEV-11938 json.json_no_table crashes or fails with valgrind warnings in json_find_path / Item_func_json_length::val_int.
Paths with quoted keynames handled improperly.
2017-02-02 18:56:15 +04:00
Igor Babaev
8481c70ede Fixed bug mdev-11867.
If a window function with aggregation is over the result
set of a grouping query then the argument of the aggregate
function from the window function is allowed to be an
aggregate function itself.
2017-02-01 19:15:28 -08:00
Igor Babaev
9073f9fd7d Fixed bug mdev-9976.
This bug happens due to a conflict in the construct window_spec.
(win_ref conflicts with the non-reserved key word ROWS).
The standard SQL-2003 says that ROWS is a reserved key word.
Made this key word reserved in our grammar and removed
the conflict.
2017-01-31 20:37:26 -08:00
Igor Babaev
81c1abe8cf Fixed bug mdev-10875.
Now, after the implementation of mdev-8646
"Re-engineer the code for post-join operations"
create_sort_index() can be called for subqueries.
2017-01-31 20:37:25 -08:00
Alexander Barkov
1d96b09890 MDEV-9979 Keywords UNBOUNDED, PRECEDING, FOLLOWING, TIES, OTHERS should be non-reserved
Adding keywords the following keywords into the "keyword" rules:
- EXCLUDE
- UNBOUNDED
- PRECEDING
- FOLLOWING
- TIES
- OTHERS

They are non-reserved words in the SQL standard (checked in a SQL-2011 draft),
and they don't cause any conflicts in sql_yacc.yy.
2017-01-31 23:41:10 +04:00
Nirbhay Choubey
cd8482c19e MDEV-11945: Fix description for "max_statement_time" in --help
max_statement_time also applies to non-SELECT queries.
2017-01-31 12:28:09 -05:00
Nirbhay Choubey
aa9db4c162 MDEV-11817: Altering a table with more rows than ..
.. wsrep_max_ws_rows causes cluster to break when running
Galera cluster in TOI mode

Problem:
While copying records to temporary table during ALTER TABLE,
if there are more than wsrep_max_wsrep_rows records, the
command fails.

Fix:
Since, the temporary table records are not placed into the
binary log, wsrep_affected_rows must not be incremented.
Added a test.
2017-01-31 12:28:09 -05:00
Sachin Setiya
41997d148d MDEV-10812 WSREP causes responses being sent to protocol commands
that must not send a response

Problem:- When using wsrep (w/ galera) and issuing commands that can
cause deadlocks, deadlock exception errors are sent in responses to
commands such as close prepared statement and close connection which,
by spec, must not send a response.

Solution:- In dispatch_command, we will handle COM_QUIT and COM_STMT_CLOSE
commands even in case of error.

Patch Credit:- Jaka Močnik
2017-01-31 13:34:49 +05:30
Thayumanavar S
35809da207 WL#10287 - Backport WL#7195 to MySQL - 5.5
This is backport of WL#7195 to MySQL-5.5. In 5.5, we
offload connection authentication from the acceptor
thread to tp worker threads.

Connection authentication happens in the acceptor thread that
accepts the connection for thread pool plugin. Connection authentication
involves exchanging packets with client and disk I/O
which is time consuming. This can cause other client
connections to starve and wait in the queue possibly increasing the
connect latency and decreasing throughput. In the worst case, some
connections could be dropped. n addition, SSL handshakes are quite
expensive and can stall connections in the accept queue.

This patch offloads connection authentication when thread pool
plugin is used for client connection. Each thread group
shall have a queue of connection_context objects, which represents
new connections that need to be processed by thread group threads.
The connection context is composed of THD object & list pointers
for intrusive queue implementation. Whenever a new connection
arrives, connection context object is created and added to the
queue. A new connect handler thread is created or woken up to handle
the authentication task. The worker thread loop is modified to
process connection events on connect handler threads in addition to
checking for query processing events. The initial number of connect
handler threads is one per thread group and it is restricted to
a maximum of 4 threads per thread group.
2017-01-30 03:16:09 +01:00
Igor Babaev
abfcdb8fbc Fixed bug mdev-10773.
The temporary tables created for recursive table references
should be closed in close_thread_tables(), because they might
be used in the statements like ANALYZE WITH r AS (...) SELECT * from r
where r is defined through recursion.
2017-01-28 15:47:11 -08:00
Marko Mäkelä
f1f8ebc325 Merge 10.0 into 10.1 2017-01-26 23:40:11 +02:00
Vladislav Vaintroub
def258061b increase default for max threads in the pool to max allowed value (64K) currently 2017-01-26 17:39:36 +00:00
Alexey Botchkov
d96ee168a1 MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
paths ending on [0]..[0] should be handled in conforming manner.
2017-01-26 16:35:05 +04:00
Sachin Setiya
86ca1357b0 Revert "MDEV-7409 On RBR, extend the PROCESSLIST info to include at least the name of the recently used table"
This reverts commit 15f46d5174.
2017-01-25 17:15:14 +05:30
Igor Babaev
423b7da36f Fixed bug mdev-11820.
The fields st_select_lex::cond_pushed_into_where and
st_select_lex::cond_pushed_into_having should be re-initialized
for the unit specifying a derived table at every re-execution
of the query that uses this derived table, because the result
of condition pushdown may be different for different executions.
2017-01-24 13:12:20 -08:00
Alexey Botchkov
35760c0000 MDEV-11557 Port MySQL-5.7 JSON tests to MariaDB.
more fixes.
2017-01-25 00:13:15 +04:00
Sergei Petrunia
13c7839ba7 MariaRocks port: Fix for the previous cset (MariaRocks port: put back the assert)
- Put back the assert on SQL layer at the right location
- Adjust rdb_pack_with_make_sort_key to work around the assert (like
  it is done at other palaces):  MyRocks may need to pack a column
  value even when the column is not in the read set.
2017-01-24 21:51:57 +03:00
Alexey Botchkov
1782102d97 MDEV-11042 Implement GeoJSON functions.
Typenames made into proper character case.
2017-01-24 22:39:55 +04:00