Commit graph

184371 commits

Author SHA1 Message Date
Marko Mäkelä
c913cd2b66 MDEV-17885 TRUNCATE on temporary table causes ER_GET_ERRNO
ha_innobase::truncate(): Because CREATE TEMPORARY TABLE
allows invalid table options when innodb_file_per_table=1,
do allow them also in TRUNCATE for temporary tables.
2018-12-12 16:31:34 +02:00
Julius Goryavsky
d48ac8b414 MDEV-17848: Galera test failure on galera_sst_xtrabackup-v2[_data_dir]
The mariabackup SST script was incorrectly processes
innodb_data_home_dir parameter if it is specified in
the configuration file for one of the cluster nodes.
Therefore, a corresponding revision of the mariabackup
SST script was made, which provides reading of the
corresponding parameter from the configuration file
or from the command line.

https://jira.mariadb.org/browse/MDEV-17848
2018-12-12 13:44:58 +01:00
Marko Mäkelä
c64265f3f9 Merge 10.3 into 10.4 2018-12-12 14:09:48 +02:00
Marko Mäkelä
b6a44b4c24 row_undo_mod_clust(): Fix stack-use-after-scope
This is fixing a regression that was introduced in MDEV-15562
commit 0e5a4ac253.

On rollback of UPDATE or DELETE of a ROW_FORMAT=COMPRESSED table,
page_zip_write_trx_id_and_roll_ptr() was accessing
offsets=offsets_ after offsets_ went out of scope.
2018-12-12 13:49:13 +02:00
Marko Mäkelä
839cf16bb2 Merge 10.2 into 10.3 2018-12-12 13:46:06 +02:00
Jiaye Wu
9eadef013e Fix UNICODE issue of dlerror
Current implementation is conflicting. If UNICODE is defined, FormatMessage() will be FormatMessageW(), and variable win_errormsg with type char can not be passed to it, which should be changed to TCHAR instead. Since we don't use UNICODE here, we can use FormatMessageA() directly to avoid conversion error.
```
my_global.h(1092): error C2664: 'DWORD FormatMessageW(D
WORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list *)' : cannot convert argument 5 from 'char [2048]' to 'LPWSTR'
```
2018-12-12 12:36:28 +01:00
Marko Mäkelä
91173f9863 fts_is_charset_cjk(): Avoid referencing global symbols
References to global symbols prevent InnoDB from being built as a
dynamic plugin on Windows.

Refer to CHARSET_INFO::number, because that is what InnoDB is already
persistently storing in its data dictionary.
2018-12-12 13:30:40 +02:00
Marko Mäkelä
e0aebf5cf1 MDEV-17815 Assertion failed in btr_node_ptr_max_size for CHAR(0)
btr_node_ptr_max_size(): Treat CHAR(0) from SQL as a special case.
The InnoDB internal SQL parser maps the type "CHAR" to DATA_VARCHAR,
but MariaDB does allow CHAR(0) with an empty value, and does enforce
the length limitation.
2018-12-12 13:21:05 +02:00
Sergei Golubchik
dce2cc1c6a fix handler test failures on s390x
keyinfo->name is a LEX_CSTRING

also, fix the location comment (that applied to ext_key_part_map)
2018-12-12 11:35:21 +01:00
Marko Mäkelä
c1e695c90e MDEV-17763 Assertion `len == 20U' failed in rec_convert_dtuple_to_rec_comp on DROP COLUMN
btr_cur_pessimistic_insert(): Convert the metadata field of the metadata
record into BLOB before inserting, just like btr_cur_optimistic_insert()
does.
2018-12-12 12:15:40 +02:00
Marko Mäkelä
db1210f939 Merge 10.1 into 10.2 2018-12-12 12:13:43 +02:00
Alexander Barkov
2681ca04f2 The last commit was pushed with a wrong title:
MDEV-17968 Error 174 "Fatal error during initialization of handler" from storage engine Aria upon DELETE from partitioned table

The correct title is:
MDEV-17972 Assertion `is_valid_value_slow()' failed in Datetime::Datetime
2018-12-12 14:10:45 +04:00
Alexander Barkov
c8774408cb MDEV-17968 Error 174 "Fatal error during initialization of handler" from storage engine Aria upon DELETE from partitioned table 2018-12-12 14:07:27 +04:00
Sergei Golubchik
56d3a0e73b MDEV-17967 Add a solution of the 8 queens problem to the regression test for CTE 2018-12-12 10:39:17 +01:00
Marko Mäkelä
f77f8f6d1a Merge 10.0 into 10.1 2018-12-12 10:48:53 +02:00
Alexander Barkov
c353b2a8fc --echo #
--echo # MDEV-17979 Assertion `0' failed in Item::val_native upon SELECT with timestamp, NULLIF, GROUP BY
--echo #
2018-12-12 10:39:06 +04:00
Sergei Golubchik
4abb8216a0 MDEV-17658 change the structure of mysql.user table
Implement User_table_json.
Fix scripts to use mysql.global_priv.
Fix tests.
2018-12-12 00:31:44 +01:00
Sergei Golubchik
d68d7e50f9 json helpers 2018-12-12 00:31:43 +01:00
Sergei Golubchik
a76aadf7bc MDEV-17658 change the structure of mysql.user table
Introduce User_table_tabular(mysql.user) and User_table_json(mysql.global_priv).
The latter is not implemented.
Automatic fallback to the old implementation works.

Results change because privilege tables are opened in a different
order now.
2018-12-12 00:31:04 +01:00
Sergei Golubchik
9887d2e881 cleanup: simplify opening of priv tables
prepare TABLE_LIST in a loop and just before opening
don't store TABLE_LIST inside Grant_table_base.
2018-12-12 00:31:04 +01:00
Sergei Golubchik
a701426b43 cleanup: refactor grant table classes in sql_acl.cc
move all backward compatibility related code into User_table,
the caller should not know or care anymore.

Other tables (Db_table, etc) are *not* refactored.

For consistency with other updates, setting a default role
no longer errors out when the mysql.user table is too old.
2018-12-12 00:31:04 +01:00
Sergei Golubchik
3df7287d21 fix the test for the empty password hash string
because the first byte of a _binary hash_ can be 0x00 too.

This fixes main.connect test on centos73-ppc64
2018-12-12 00:31:04 +01:00
Sergei Golubchik
1db6c3a207 extend the test case to better emulate 5.7 user table 2018-12-12 00:31:04 +01:00
Sergei Golubchik
07e9b13898 mysqld: ignore SIGHUP sent by the kernel
SIGHUP causes debug info in the error log and reload of
logs/privileges/tables/etc. The server should only do it when
a user intentionally sends SUGHUP, not when a parent terminal gets
disconnected or something.

In particular, not ignoring kernel SIGHUP causes FLUSH PRIVILEGES
at some random point during non-systemd Debian upgrades (Debian
restarts mysqld, debian-start script runs mysql_upgrade in the background,
postinit script ends and kernel sends SIGHUP to all background processes
it has started). And during mysql_upgrade privilege tables aren't
necessarily ready to be reloaded.
2018-12-12 00:31:04 +01:00
Sergei Golubchik
97dbb3562b simplify usage of logger.set_handlers() 2018-12-12 00:31:04 +01:00
Sergei Golubchik
a4ac987cbc more tests for mysql_install_db.exe 2018-12-12 00:31:04 +01:00
Sergei Golubchik
7af62f8a03 MDEV-17926 FederatedX TODO is obsolete 2018-12-12 00:31:04 +01:00
Alexey Botchkov
b1527ef51c MDEV-5313 Improving audit api.
Service added to handle json.
2018-12-12 01:49:39 +04:00
Eugene Kosov
d956709b4b MDEV-17833 ALTER TABLE is not enforcing prefix index size limit
ha_innobase::prepare_inplace_alter_table(): check max column length for every
index in a table, not just added in this particular ALTER TABLE with ADD INDEX ones.
2018-12-11 22:03:44 +03:00
Marko Mäkelä
dc6ad59765 MDEV-17901 Crash after instant DROP COLUMN of AUTO_INCREMENT column
We failed to reset the dict_table_t::persistent_autoinc after
instantly dropping an AUTO_INCREMENT column, causing a bogus
call to row_parse_int() on a subsequent insert.
2018-12-11 20:50:22 +02:00
Jiaye Wu
8dc460b844 Fix UNICODE issue of dlerror()
Current implementation is conflicting. If `UNICODE` is defined, `FormatMessage()` will be `FormatMessageW()`, and variable `win_errormsg` with type `char` can not be passed to it, which should be changed to `TCHAR` instead. Since we don't use UNICODE here, we can use `FormatMessageA()` directly to avoid conversion error.
```
my_global.h(1092): error C2664: 'DWORD FormatMessageW(D
WORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list *)' : cannot convert argument 5 from 'char [2048]' to 'LPWSTR'
```
2018-12-11 17:01:18 +01:00
Marko Mäkelä
1b31d8852c MDEV-17899: Fix a regression from MDEV-17793
The fix of MDEV-17793 was updating SYS_INDEXES.TABLE_ID in order
to make the table invisible to purge (lazily delete old undo log
records).

By design of InnoDB, an update of TABLE_ID cannot be rolled back,
because the rollback would effectively drop all indexes of the table
due to the internal 'trigger' on SYS_INDEXES modifications.

So, we revert the code change of MDEV-17793 and instead fix
MDEV-17793 in a different way: by tweaking the undo log parsing
during purge.

The MDEV-17793 bug scenario is that a table becomes empty and
a third instant ALTER TABLE is executed before purge processes
the undo log record for the second instant ALTER TABLE. After
this point, when purge sees the record, the table could have
a mismatching number of rows.

The test case works with this alternative fix. But what about
a scenario where a fourth instant ALTER TABLE arrives before
purge processes the second one? Could anything bad happen?

Purge is only doing two things: First, free any BLOBs that
were affected by the update record, and then, reset the
DB_TRX_ID,DB_ROLL_PTR if a matching record is found.
For the hidden metadata record, the only BLOB that we update
is the hidden metadata BLOB that was introduced by MDEV-15562.
Any other BLOBs (for the initial default values of instantly
added columns) are never updated.

So, in our scenario, the metadata BLOB that was created by
the first instant ALTER TABLE (if it involved dropping or
permuting columns) would be freed by purge when it is processing
the undo record of the second ALTER TABLE. The BLOB value that
was written by the second ALTER TABLE should be freed when
the table is emptied. This is currently not done: MDEV-17383
should fix that. There is no possibility of double-free, because
purge would only free old values of BLOBs.

What about MVCC and other callers of trx_undo_update_rec_get_update()?
The answer is simple: they should never be accessing the hidden
metadata record in the first place.

dict_table_t::reassign_id(): Remove.

btr_cur_pessimistic_delete(): Clarify a comment.

row_mysql_table_id_reassign(), row_discard_tablespace_for_mysql():
Add comments explaining that the operation cannot be rolled back.

trx_undo_update_rec_get_update(): Avoid out-of-bounds access when
parsing a metadata record. Avoid unnecessary memory allocation when
filtering out fields from the update vector.
2018-12-11 13:45:24 +02:00
Vladislav Vaintroub
ac31ff6275 MDEV-15760 - don't build mariabackup with -DPLUGIN_INNOBASE=DYNAMIC 2018-12-10 23:31:54 +01:00
Sergey Vojtovich
1c53aeff58 Fixed sporadic main.mdl_sync failure
When update finishes, MDL_context::release_transactional_locks() first
releases MDL_STATEMENT locks (MDL_BACKUP_DML and MDL_BACKUP_TRANS_DML
in this particular cases), which allows FTWRL connection to proceed.
Then MDL_TRANSACTION locks get released (MDL_SHARED_WRITE in this case).
metadata_lock_info query may sporadically hit this gap and observe
these otherwise unexpected locks.
2018-12-10 22:59:46 +04:00
Sergey Vojtovich
0fcb141fbd Fixed main.create-big failure
After MDEV-17772 table existence check is performed much earlier, so
create_table_select_before_check_if_exists debug sync point is not
reachable when table exists.

Moved debug sync point to appropriate place.
2018-12-10 22:59:46 +04:00
Vladislav Vaintroub
8049160936 MDEV-17946 : Unsorted acl_dbs after RENAME USER 2018-12-10 17:23:03 +01:00
Alexander Barkov
34eb98387f MDEV-13995 MAX(timestamp) returns a wrong result near DST change 2018-12-10 19:25:12 +04:00
Varun Gupta
5b3db87134 Updated the result for innodb.innodb_mysql
The result is updated here because by changing the defaults for use_stat_tables
EITs statistcs are providing more accurate statistics than INNODB statistics.
2018-12-10 19:37:36 +05:30
Marko Mäkelä
f69879baca MDEV-17899 Assertion failures on rollback of instant ADD/DROP
row_undo_ins_remove_clust_rec(): When rolling back the insert
of a metadata record, also reset the root page state within the
same mini-transaction.

dict_table_t::rollback_instant(): Do not allow index->n_core_fields
to be larger than index->n_fields. This logic exists in the 10.3
branch but was incorrectly removed as part of MDEV-15562 in 10.4.0.
2018-12-10 15:58:32 +02:00
Vladislav Vaintroub
3efed7533c Fix lock_ddl_per_table handling in mariabackup.
mariabackup.lock_ddl_per_table was broken, after MDEV-17772 got fixed.
Fix removes MDL waiter killer, it is is not needed anymore.
2018-12-10 14:03:52 +01:00
Varun Gupta
8aef7f2bb9 MDEV-17778: Alter table leads to a truncation warning with ANALYZE command
Alter statement changed the THD structure by setting the value to FIELD_CHECK_WARN
and then not resetting it back. This led ANALYZE to throw a warning which previously
it didn't.
2018-12-10 18:27:13 +05:30
Marko Mäkelä
fcb6bb4bcc Merge 10.3 into 10.4 2018-12-10 13:16:03 +02:00
Marko Mäkelä
a72516348b MDEV-17938: ALTER TABLE error handling accesses freed memory
This regression was introduced in MDEV-11369 instant ADD COLUMN.

prepare_inplace_alter_table_dict(): Avoid dereferencing ctx->new_table
after row_create_table_for_mysql() returns a failure code, because
it will have freed the memory.
2018-12-10 13:02:04 +02:00
Marko Mäkelä
1d18665e0b Merge 10.2 into 10.3 2018-12-10 12:28:31 +02:00
Marko Mäkelä
0d7cf06af5 MDEV-17938 ALTER TABLE reports ER_TABLESPACE_EXISTS after failed ALTER TABLE
There was a race condition in the error handling of ALTER TABLE when
the table contains FULLTEXT INDEX.

During the error handling of an erroneous ALTER TABLE statement,
when InnoDB would drop the internally created tables for FULLTEXT INDEX,
it could happen that one of the hidden tables was being concurrently
accessed by a background thread. Because of this, InnoDB would defer
the drop operation to the background.

However, related to MDEV-13564 backup-safe TRUNCATE TABLE and its
prerequisite MDEV-14585, we had to make the background drop table queue
crash-safe by renaming the table to a temporary name before enqueueing it.
This renaming was introduced in a follow-up of the MDEV-13407 fix.
As part of this rename operation, we were unnecessarily parsing the
current SQL statement, because the same rename operation could also be
executed as part of ALTER TABLE via ha_innobase::rename_table().

If an ALTER TABLE statement was being refused due to incorrectly formed
FOREIGN KEY constraint, then it could happen that the renaming of the hidden
internal tables for FULLTEXT INDEX could also fail, triggering a host of
error log messages, and causing a subsequent table-rebuilding ALTER TABLE
operation to fail due to the tablespace already existing.

innobase_rename_table(), row_rename_table_for_mysql(): Add the parameter
use_fk for suppressing the parsing of FOREIGN KEY constraints. It
will only be passed as use_fk=true by ha_innobase::rename_table(),
which can be invoked as part of ALTER TABLE...ALGORITHM=COPY.
2018-12-10 11:44:39 +02:00
Alexander Barkov
e5144f4bad Cleanup: Datetime() constructors accepting Longlong_hybrid/Sec6 do not need THD
Removing the unused THD* parameter.
2018-12-10 13:07:42 +04:00
Sergey Vojtovich
8cf7e3459d Moved early check for table existance to mysql_execute_command()
MDEV-17772 - 3 way lock : ALTER, MDL, BACKUP STAGE BLOCK_DDL

While waiting for a (potentially long) RO transaction or SELECT, DDL and
LOCK TABLES ... WRITE hold protection against FTWRL and BACKUP STAGE.

This effectively makes FTWRL/BACKUP STAGE indirectly wait for this RO
transaction or SELECT to finish. Which is not great, as otherwise we
could do something useful meanwhile.

With this patch BACKUP lock is attempted to be acquired after TABLE/SCHEMA
locks. If this attempt fails, TABLE/SCHEMA locks gets released and we
start waiting for BACKUP lock. When wait finishes, BACKUP lock is released
(to avoid deadlocks) and we attempt to acquire all locks once again.

Other changes:
- Take MDL lock before testing if table exists as part of
  CREATE TABLE ... IF EXISTS.  This change was an effect of changes in
  lock_table_name and removes an inconsistency where one could get
  different error messages from CREATE TABLE .. IF EXISTS depending on
  active mdl locks.
  One effect of this change is that we don't binary log CREATE TABLE IF
  EXISTS if the table exists.  This was done because old code was sometimes
  behaving inconsistenly (it was logged some time and not other times)
  and sending the query to the slave could make the slave even more
  inconsistent as there is not guarantee that the new table will have
  the same definition as the old table on the master.
2018-12-09 22:12:28 +02:00
Vladislav Vaintroub
c0ca164b1c MDEV-17308 mariabackup to use the BACKUP statement instead of FTWRL 2018-12-09 22:12:27 +02:00
Monty
c53aab974b Added syntax and implementation for BACKUP STAGE's
Part of MDEV-5336 Implement LOCK FOR BACKUP

- Changed check of Global_only_lock to also include BACKUP lock.
- We store latest MDL_BACKUP_DDL lock in thd->mdl_backup_ticket to be able
  to downgrade lock during copy_data_between_tables()
2018-12-09 22:12:27 +02:00
Monty
965311ee8b Added new MDL_BACKUP locks for all backup stages
Part of MDEV-5336 Implement LOCK FOR BACKUP

- Added new locks to MDL_BACKUP for all stages of backup locks and
  a new MDL lock needed for backup stages.
- Renamed MDL_BACKUP_STMT to MDL_BACKUP_DDL
- flush_tables() takes a new parameter that decides what should be flushed.
- InnoDB, Aria (transactional tables with checksums), Blackhole, Federated
  and Federatedx tables are marked to be safe for online backup. We are
  using MDL_BACKUP_TRANS_DML instead of MDL_BACKUP_DML locks for these
  which allows any DML's to proceed for these tables during the whole
  backup process until BACKUP STAGE COMMIT which will block the final
  commit.
2018-12-09 22:12:27 +02:00