Commit graph

183463 commits

Author SHA1 Message Date
Vladislav Vaintroub
98473a8399 Small refactoring in vio.
- remove function prototype for shared memory (no more used), and VIO
members that are unused
 - Do not call DisconnectNamedPipe on pipe handle. CloseHandle() is enough.
2018-10-05 09:36:02 +01:00
Vladislav Vaintroub
8f329e8d37 MDEV-10384 Windows : Refactor threading in mysqld startup.
Remove threads that are doing nothing but wait
- main thread now handles the connections
(if threadpool is used, also threadpool threads would wait for connections)
- thread for socket and pipe connections are removed
- shutdown thread is now removed, we wait for shutdown
notification in main thread as well
- kill_server() is also called inside the main thread, after connection
loop finished.
2018-10-05 09:29:22 +01:00
Alexander Barkov
25ad38abe5 MDEV-17288 Replace Item_func::get_arg0_date() to Date/Datetime methods 2018-09-25 10:07:45 +04:00
Alexander Barkov
50003a9508 MDEV-17274 Split Field_temporal_with_date::store*() for Field_date_common and Field_datetime 2018-09-22 18:33:07 +04:00
Marko Mäkelä
81ba90b59e Merge 10.3 into 10.4 2018-09-21 13:16:38 +03:00
Marko Mäkelä
bc7d40d032 Clean up some SPATIAL INDEX code
Clarify some comments about accessing an externally stored column
on which a spatial index has been defined. Add a TODO comment that
we should actually write the minimum bounding rectangle (MBR) to
the undo log record, so that we can avoid fetching BLOBs and recomputing
MBR.

row_build_spatial_index_key(): Split from row_build_index_entry_low().
2018-09-21 09:27:06 +03:00
Marko Mäkelä
45eaed0c4c Merge 10.3 into 10.4 2018-09-19 17:38:00 +03:00
Marko Mäkelä
90b292ce31 Follow-up to MDEV-16328: ALTER TABLE…page_compression_level should not rebuild table
Allow combination of non-instant, non-rebuilding operations with
changes of table options that do not require a rebuild.

For example, DROP INDEX or ADD INDEX can be performed with
ALGORITHM=NOCOPY together with changing such table options.
Changing the table options alone would be allowed with ALGORITHM=INSTANT.

INNOBASE_ALTER_NOCREATE: A new set of flags, for operations that
are refused for ALGORITHM=INSTANT and do not involve creating
index trees.

Move ALTER_RENAME_INDEX to the proper place (INNOBASE_ALTER_INSTANT).

innobase_need_rebuild(): Do not require a rebuild if
INNOBASE_ALTER_NOREBUILD operations are combined with ALTER_OPTIONS.

ha_innobase::prepare_inplace_alter_table(),
ha_innobase::inplace_alter_table(): Use the fast path if
ALTER_OPTIONS is combined with INNOBASE_ALTER_NOCREATE.
In this case, the actual changes would be deferred to
ha_innobase::commit_inplace_alter_table().
2018-09-19 17:29:25 +03:00
Marko Mäkelä
28ae79650d Terminology: 'metadata' not 'default rec'
This follows up to commit 755187c853.

TRX_UNDO_INSERT_METADATA: Renamed from TRX_UNDO_INSERT_DEFAULT

trx_undo_metadata: Renamed from trx_undo_default_rec
2018-09-19 09:12:58 +03:00
Marko Mäkelä
4a246fecbd Merge 10.3 into 10.4 2018-09-19 08:21:03 +03:00
Marko Mäkelä
755187c853 Terminology: 'metadata record' instead of 'default row'
For instant ALTER TABLE, we store a hidden metadata record at the
start of the clustered index, to indicate how the format of the
records differs from the latest table definition.

The term 'default row' is too specific, because it applies to
instant ADD COLUMN only, and we will be supporting more classes
of instant ALTER TABLE later on. For instant ADD COLUMN, we
store the initial default values in the metadata record.
2018-09-19 07:21:24 +03:00
Marko Mäkelä
043639f9b0 Simplify innobase_add_instant_try()
Remove some code duplication and dead code. If no 'default row'
record exists, the root page must be in the conventional format.
Should the page type already be FIL_PAGE_TYPE_INSTANT, we would
necessarily hit a debug assertion failure in page_set_instant().
2018-09-18 21:25:24 +03:00
Jacob Mathew
c9a5804e14 MDEV-17144: Sample of spider_direct_sql cause crash
The crash occurs when the Spider node server attempts to create an error
message stating that the temporary table is not found.  The function to
create the error message is called with incorrect parameters.

I fixed the crash by correcting the incorrect parameter values.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit e339616 on branch bb-10.3-mdev-17144
2018-09-18 11:05:53 -07:00
Jacob Mathew
159b41b869 MDEV-17144: Sample of spider_direct_sql cause crash
The crash occurs when the Spider node server attempts to create an error
message stating that the temporary table is not found.  The function to
create the error message is called with incorrect parameters.

I fixed the crash by correcting the incorrect parameter values.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Merged:
  Commit e339616 branch bb-10.3-mdev-17144
2018-09-18 10:49:03 -07:00
Igor Babaev
5ec144cfab MDEV-17211 Server crash on query
The function JOIN_TAB::choose_best_splitting() did not take into account
that for some tables whose fields were used in the GROUP BY list of
the specification of a splittable materialized derived there might exist
no elements in the array ext_keyuses_for_splitting.
2018-09-17 18:50:21 -07:00
Jacob Mathew
e33961611a MDEV-17144: Sample of spider_direct_sql cause crash
The crash occurs when the Spider node server attempts to create an error
message stating that the temporary table is not found.  The function to
create the error message is called with incorrect parameters.

I fixed the crash by correcting the incorrect parameter values.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.
2018-09-17 18:48:38 -07:00
Marko Mäkelä
21f310db30 Fix the Windows build 2018-09-17 18:10:37 +03:00
Marko Mäkelä
774a4cb547 Mroonga follow-up fix for MDEV-16328
Now that ha_innobase::prepare_inplace_alter_table() is accessing
ha_alter_info->create_info->option_struct, we must initialize it in
the Mroonga wrapper for ALTER TABLE based on the parsed table options
for the wrap_altered_table.
2018-09-17 17:50:56 +03:00
Marko Mäkelä
ac24289e66 MDEV-16328 ALTER TABLE…page_compression_level should not rebuild table
The table option page_compression_level is something that only
affects future writes, not actually the data format. Therefore,
we can allow instant changes of this option.

Similarly, the table option page_compressed can be set on a
previously uncompressed table without rebuilding the table,
because an uncompressed page would be considered valid when
reading a page_compressed table.

Removing the page_compressed option will continue to require
the table to be rebuilt.

ha_innobase_inplace_ctx::page_compression_level: The requested
page_compression_level at the start of ALTER TABLE, or 0 if
page_compressed=OFF.

alter_options_need_rebuild(): Renamed from
create_option_need_rebuild(). Allow page_compression_level and
page_compressed to be changed as above, without rebuilding the table.

ha_innobase::check_if_supported_inplace_alter(): Allow ALGORITHM=INSTANT
for ALTER_OPTIONS if the table is not to be rebuilt. If rebuild is
needed, set ha_alter_info->unsupported_reason.

innobase_page_compression_try(): Update SYS_TABLES.TYPE according
to the table flags, for an instant change of page_compression_level
or page_compressed.

commit_cache_norebuild(): Adjust dict_table_t::flags, fil_space_t::flags
and (if needed) FSP_SPACE_FLAGS if page_compression_level was specified.
2018-09-17 14:37:39 +03:00
Alexander Barkov
9e1a39aae4 Cleanup: Removing unused double_to_datetime(). 2018-09-17 12:56:03 +04:00
Alexander Barkov
4437b5bffb Fixing Windows compilation failure in MDEV-17203 (C4291 no matching operator delete found) 2018-09-16 19:24:08 +04:00
Alexander Barkov
d93399746d MDEV-17203 Move fractional second truncation from Item_xxx_typecast::get_date() to Time and Datetime constructors 2018-09-16 12:41:48 +04:00
Igor Babaev
c5a9a63293 MDEV-16917 Index affects query results
The optimizer erroneously allowed to use join cache when joining a
splittable materialized table together with splitting optimization.
As a consequence in some rare cases the server returned wrong result
sets for queries with materialized derived.

This patch allows to use either join cache without usage of splitting
technique for materialization of a splittable derived table or splitting
without usage of join cache when joining such table. The costs the these
alternatives are compared and the best variant is chosen.
2018-09-15 14:28:33 -07:00
Marko Mäkelä
171fbbb968 Merge 10.3 into 10.4 2018-09-14 15:23:34 +03:00
Marko Mäkelä
aba5c72be2 MDEV-17196 Crash during instant ADD COLUMN with long DEFAULT value
A debug assertion would fail if an instant ADD COLUMN operation
involves splitting the leftmost leaf page and storing a default
value off-page. Another debug assertion could fail if the
default value does not fit in an undo log page.

btr_cur_pessimistic_update(): Invoke rec_offs_make_valid()
in order to prevent rec_offs_validate() assertion failure.

innobase_add_instant_try(): Invoke btr_cur_pessimistic_update()
with the BTR_KEEP_POS_FLAG, which is the correct course of action
when BLOBs may need to be written. Whenever returning true,
ensure that my_error() will have been called.
2018-09-14 15:06:58 +03:00
Jacob Mathew
30d225698f MDEV-16912: Spider Order By column[datatime] limit 5 returns 3 rows
The problem occurs in 10.2 and earlier releases of MariaDB Server because the
Partition Engine was not pushing the engine conditions to the underlying
storage engine of each partition.  This caused Spider to return the first 5
rows in the table with the data provided by the customer.  2 of the 5 rows
did not qualify the WHERE clause, so they were removed from the result set by
the server.

To fix the problem, I have back-ported support for engine condition pushdown
in the Partition Engine from MariaDB Server 10.3 to 10.2 and 10.1.  In 10.3
and 10.4 I have merged the comments and the test case.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit ed49f9a on branch 10.3
2018-09-13 16:07:02 -07:00
Jacob Mathew
ed49f9aae2 MDEV-16912: Spider Order By column[datatime] limit 5 returns 3 rows
The problem occurs in 10.2 and earlier releases of MariaDB Server because the
Partition Engine was not pushing the engine conditions to the underlying
storage engine of each partition.  This caused Spider to return the first 5
rows in the table with the data provided by the customer.  2 of the 5 rows
did not qualify the WHERE clause, so they were removed from the result set by
the server.

To fix the problem, I have back-ported support for engine condition pushdown
in the Partition Engine from MariaDB Server 10.3 to 10.2 and 10.1.  In 10.3
and 10.4 I have merged the comments and the test case.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Merged:
  Commit eb2ca3d on branch bb-10.2-MDEV-16912
2018-09-13 14:55:46 -07:00
Alexander Barkov
61e8d21c77 MDEV-17182 Move fractional second truncation outside of Field_xxx::store_TIME_with_warn() 2018-09-12 21:53:02 +04:00
Ming Lin
87609324e0 MDEV-16768: fix blob key length
The blob key length could be shorter than the length of the entire blob,
for example,

CREATE TABLE t1 (b BLOB, i INT, KEY(b(8)));
INSERT INTO t1 VALUES (REPEAT('a',9),1);

The key length is 8, while the blob length is 9.
So we need to set the correct key length in Field_blob::sort_string().
2018-09-12 15:15:13 +03:00
Alexander Barkov
2fe51a6fdd MDEV-17175 Change Time/Datetime constructors to return warnings in MYSQL_TIME_STATUS 2018-09-12 09:06:27 +04:00
Marko Mäkelä
5567a8c936 MDEV-17138 Reduce redo log volume for undo tablespace initialization
Implement a 10.4 redo log format, which extends the 10.3 format
by introducing the MLOG_MEMSET record.

MLOG_MEMSET: A new redo log record type for filling an area with a byte.

mlog_memset(): Write the MLOG_MEMSET record.

mlog_parse_nbytes(): Handle MLOG_MEMSET as well.

trx_rseg_header_create(): Reduce the redo log volume by making use of
mlog_memset() and the zero-initialization that happens inside page
allocation.

fil_addr_null: Remove.

flst_init(): Create a variant that takes a zero-initialized
buf_block_t* as a parameter, and only writes the FIL_NULL using
mlog_memset().

flst_zero_addr(): A variant of flst_write_addr() that writes
a null address using mlog_memset() for the FIL_NULL.

The following fixes are replacing some use of MLOG_WRITE_STRING
with the more compact MLOG_MEMSET record, or eliminating
redundant redo log writes:

btr_store_big_rec_extern_fields(): Invoke mlog_memset() for
zero-initializing the tail of the ROW_FORMAT=COMPRESSED BLOB page.

trx_sysf_create(), trx_rseg_format_upgrade(): Invoke mlog_memset()
for zero-initializing the page trailer.

fsp_header_init(), trx_rseg_header_create():
Remove redundant zero-initializations.
2018-09-11 21:32:36 +03:00
Marko Mäkelä
09af00cbde MDEV-13564: Remove old crash-upgrade logic in 10.4
Stop supporting the additional *trunc.log files that were
introduced via MySQL 5.7 to MariaDB Server 10.2 and 10.3.

DB_TABLESPACE_TRUNCATED: Remove.

purge_sys.truncate: A new structure to track undo tablespace
file truncation.

srv_start(): Remove the call to buf_pool_invalidate(). It is
no longer necessary, given that we no longer access things in
ways that violate the ARIES protocol. This call was originally
added for innodb_file_format, and it may later have been necessary
for the proper function of the MySQL 5.7 TRUNCATE recovery, which
we are now removing.

trx_purge_cleanse_purge_queue(): Take the undo tablespace as a
parameter.

trx_purge_truncate_history(): Rewrite everything mostly in a
single function, replacing references to undo::Truncate.

recv_apply_hashed_log_recs(): If any redo log is to be applied,
and if the log_sys.log.subformat indicates that separately
logged truncate may have been used, refuse to proceed except if
innodb_force_recovery is set. We will still refuse crash-upgrade
if TRUNCATE TABLE was logged. Undo tablespace truncation would
only be logged in undo*trunc.log files, which we are no longer
checking for.
2018-09-11 21:32:15 +03:00
Marko Mäkelä
67fa97dc2c Merge 10.3 into 10.4 2018-09-11 21:31:47 +03:00
Marko Mäkelä
1bf3e8ab43 Merge 10.3 into 10.4 2018-09-11 21:31:03 +03:00
Jan Lindström
8dda6d797a
Merge pull request #850 from HeMan/10.3
Return code from starting MariaDB.
2018-09-11 12:05:47 +03:00
Jan Lindström
ffd583bb8b
Merge pull request #858 from codership/10.3-MDEV-16052
MDEV-16052 galera mtr galera_certification_double_failure fails with deadlock
2018-09-11 12:00:39 +03:00
Jan Lindström
4d93fea4e0
Merge pull request #857 from codership/10.3-MDEV-15845
MDEV-15845 Test failure on galera.galera_concurrent_ctas
2018-09-11 11:49:49 +03:00
Teodor Mircea Ionita
f5bebaf1d6 README.md: Break off long line 2018-09-10 22:41:27 +04:00
Teodor Mircea Ionita
b1addcd9d4 README.md: Update Travis CI badge to active branch 2018-09-10 22:41:27 +04:00
Marko Mäkelä
6b61f1bbad MDEV-17161 TRUNCATE TABLE fails after upgrade from 10.1 2018-09-10 16:15:23 +03:00
Marko Mäkelä
fc34e4c067 MDEV-17161 TRUNCATE TABLE fails after upgrade from 10.1
With the TRUNCATE by rename, create, drop (MDEV-13564),
old tables with invalid ROW_FORMAT attribute could not be
truncated. Introduce a sloppy mode for allowing the TRUNCATE.

create_table_info_t::prepare_create_table(): Add the parameter
strict=true.

ha_innobase::create(): Pass strict=false if trx!=NULL
(the create is part of TRUNCATE).
2018-09-10 16:10:26 +03:00
Marko Mäkelä
b02c722e7a MDEV-17158 TRUNCATE is not atomic after MDEV-13564 2018-09-10 15:40:11 +03:00
Marko Mäkelä
75f8e86f57 MDEV-17158 TRUNCATE is not atomic after MDEV-13564
It turned out that ha_innobase::truncate() would prematurely
commit the transaction already before the completion of the
ha_innobase::create(). All of this must be atomic.

innodb.truncate_crash: Use the correct DEBUG_SYNC point, and
tolerate non-truncation of the table, because the redo log
for the TRUNCATE transaction commit might be flushed due to
some InnoDB background activity.

dict_build_tablespace_for_table(): Merge to the function
dict_build_table_def_step().

dict_build_table_def_step(): If a table is being created during
an already started data dictionary transaction (such as TRUNCATE),
persistently write the table_id to the undo log header before
creating any file. In this way, the recovery of TRUNCATE will be
able to delete the new file before rolling back the rename of
the original table.

dict_table_rename_in_cache(): Add the parameter replace_new_file,
used as part of rolling back a TRUNCATE operation.

fil_rename_tablespace_check(): Add the parameter replace_new.
If the parameter is set and a file identified by new_path exists,
remove a possible tablespace and also the file.

create_table_info_t::create_table_def(): Remove some debug assertions
that no longer hold. During TRUNCATE, the transaction will already
have been started (and performed a rename operation) before the
table is created. Also, remove a call to dict_build_tablespace_for_table().

create_table_info_t::create_table(): Add the parameter create_fk=true.
During TRUNCATE TABLE, do not add FOREIGN KEY constraints to the
InnoDB data dictionary, because they will also not be removed.

row_table_add_foreign_constraints(): If trx=NULL, do not modify
the InnoDB data dictionary, but only load the FOREIGN KEY constraints
from the data dictionary.

ha_innobase::create(): Lock the InnoDB data dictionary cache only
if no transaction was passed by the caller. Unlock it in any case.

innobase_rename_table(): Add the parameter commit = true.
If !commit, do not lock or unlock the data dictionary cache.

ha_innobase::truncate(): Lock the data dictionary before invoking
rename or create, and let ha_innobase::create() unlock it and
also commit or roll back the transaction.

trx_undo_mark_as_dict(): Renamed from trx_undo_mark_as_dict_operation()
and declared global instead of static.

row_undo_ins_parse_undo_rec(): If table_id is set, this must
be rolling back the rename operation in TRUNCATE TABLE, and
therefore replace_new_file=true.
2018-09-10 14:59:58 +03:00
Marko Mäkelä
8618c58cc0 Disable an unstable test 2018-09-09 11:39:20 +03:00
Marko Mäkelä
5822d31696 Follow-up to MDEV-13407: Remove fil_wait_crypt_bg_threads() 2018-09-09 11:38:14 +03:00
Sergey Vojtovich
a0dfefb0f8 Fixed c++11 narrowing error
sql/table.cc:8561:42: error: non-constant-expression cannot be narrowed
                             from type 'uint' (aka 'unsigned int') to
                             '__darwin_suseconds_t' (aka 'int') in
                             initializer list [-Wc++11-narrowing]
  timeval end_time= {thd->query_start(), uint(thd->query_start_sec_part())};
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sql/table.cc:8561:42: note: insert an explicit cast to silence this issue
  timeval end_time= {thd->query_start(), uint(thd->query_start_sec_part())};
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                         static_cast<__darwin_suseconds_t>( )
2018-09-09 12:37:04 +04:00
Marko Mäkelä
99e36a7157 Follow-up to MDEV-13407: Remove fil_wait_crypt_bg_threads()
Tables whose reference count is not zero will be crash-safely
dropped in the background when the count reaches zero. Therefore,
it is no longer necessary to wait for all references to be released
before possibly adding the table to the background queue.
2018-09-09 11:35:02 +03:00
Sergey Vojtovich
d9613b750c Enable C++11 2018-09-09 10:05:56 +04:00
Vladislav Vaintroub
4c0d391c92 Windows : fix broken build with OpenSSL 2018-09-08 20:36:31 +01:00
Marko Mäkelä
5a1868b58d MDEV-13564 Mariabackup does not work with TRUNCATE
This is a merge from 10.2, but the 10.2 version of this will not
be pushed into 10.2 yet, because the 10.2 version would include
backports of MDEV-14717 and MDEV-14585, which would introduce
a crash recovery regression: Tables could be lost on
table-rebuilding DDL operations, such as ALTER TABLE,
OPTIMIZE TABLE or this new backup-friendly TRUNCATE TABLE.
The test innodb.truncate_crash occasionally loses the table due to
the following bug:

MDEV-17158 log_write_up_to() sometimes fails
2018-09-07 22:15:06 +03:00