Commit graph

182663 commits

Author SHA1 Message Date
Eugene Kosov
b5184c7efb MDEV-15947 ASAN heap-use-after-free in Item_ident::print or in my_strcasecmp_utf8 or unexpected ER_BAD_FIELD_ERROR upon call of stored procedure reading from versioned table
Closes #728
2018-06-30 16:12:36 +02:00
Eugene Kosov
133cfe39f1 MDEV-15645 Assertion `table->insert_values' failed in write_record upon REPLACE into a view with underlying versioned table
Right temporary storage for system versioning operations is table->record[2],
not table->insert_values

Closes #712
2018-06-30 16:12:28 +02:00
Sergei Golubchik
7d42135959 MDEV-16485 Insert rows unable to execute correctly on slave's System-Versioned Tables
RBR not versioned -> versioned

do it for all write_row events, not only for WRITE_ROWS_EVENT_V1
2018-06-30 16:12:18 +02:00
Sergei Golubchik
65f7473cf9 fix for ctags 2018-06-30 16:12:13 +02:00
Alexander Barkov
724a5105cb MDEV-16584 SP with a cursor inside a loop wastes THD memory aggressively
Problem:

push_handler() created sp_handler_entry instances on THD::main_mem_root,
which is freed only after the SP instructions execution.
So in case of a CONTINUE HANDLER inside a loop (e.g. WHILE) this approach
leaked thread memory on every loop iteration.

Changes:
- Removing sp_handler_entry declaration, it's not really needed.
- Fixing the data type of sp_rcontext::m_handlers from
  Dynamic_array<sp_handler_entry*> to Dynamic_array<sp_instr_hpush_jump*>
- Fixing sp_rcontext::push_handler() to push the pointer to
  an sp_instr_hpush_jump instance to the handler stack.
  This instance contains everything we need.
  There is no a need to allocate anything else.
2018-06-28 16:55:42 +04:00
Sergei Golubchik
445339feac compat/oracle.parser failed in --ps 2018-06-27 23:56:40 +02:00
Alexander Barkov
56145be295 MDEV-16584 SP with a cursor inside a loop wastes THD memory aggressively
Problem:

push_cursor() created sp_cursor instances on THD::main_mem_root,
which is freed only after the SP instructions loop.

Changes:
- Moving sp_cursor declaration from sp_rcontext.h to sql_class.h
- Deriving sp_instr_cpush from sp_cursor. So now sp_cursor is created
  only once (at the SP parse time) and then reused on all loop iterations
- Adding a new method reset() into sp_cursor (and its parent classes)
  to reset an sp_cursor instance before reuse.
- Moving former sp_cursor members m_fetch_count, m_row_count, m_found
  into a separate class sp_cursor_statistics. This helps to reuse
  the code in sp_cursor constructors, and in sp_cursor::reset()
- Adding a helper method sp_rcontext::pop_cursor().
- Adding "THD*" parameter to so_rcontext::pop_cursors() and pop_all_cursors()
- Removing "new" and "delete" from sp_rcontext::push_cursor() and
  sp_rconext::pop_cursor().
- Fixing sp_cursor not to derive from Sql_alloc, as it's now allocated
  only as a part of sp_instr_cpush (and not allocated separately).
- Moving lex_keeper->disable_query_cache() from sp_cursor::sp_cursor()
  to sp_instr_cpush::execute().
- Adding tests
2018-06-27 12:54:05 +04:00
Alexander Barkov
1d6bc0f01f Removing sp_head::is_stored_procedure. This code was dead after MDEV-15991 2018-06-26 17:53:11 +04:00
Thirunarayanan Balathandayuthapani
fe76e68e0e MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

- Fixed the test failure, assigned number of rows read to new table.
2018-06-26 14:10:58 +05:30
Alexander Barkov
f5b60857f4 A cleanup for 84c55a5668 (that implemented cursor FOR loops earlier):
MDEV-10581 sql_mode=ORACLE: Explicit cursor FOR LOOP
  MDEV-12098 sql_mode=ORACLE: Implicit cursor FOR loop

Cleanup changes:
- Removing sp_lex_cursor::m_cursor_name
- Adding sp_instr_cursor_copy_struct::m_cursor (the cursor global index)
- Fixing sp_instr_cursor_copy_struct::print() to access to the cursor
  name using m_ctx and m_cursor (like other cursor related instructions do)
  instead of m_cursor_name.

This change is needed to unify sp_assignment_lex and sp_cursor_lex later,
to fix this problem easier:
 MDEV-16558 Parenthesized expression does not work as a lower FOR loop bound
2018-06-25 19:20:36 +04:00
Thirunarayanan Balathandayuthapani
1ba5b38bfa MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

- Fixed typecasting failure for log->n_rows in row0log.cc
2018-06-25 20:49:22 +05:30
Oleksandr Byelkin
1ace3b3fad Mark embedded library as deinited. 2018-06-25 14:50:36 +02:00
Thirunarayanan Balathandayuthapani
69b9ed063b MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

- Post push fix for adding n_rows in row_log_t.
2018-06-25 18:16:29 +05:30
Oleksandr Byelkin
46fc864b90 MDEV-16478: mysql_real_connect() from libmariadbd.so always crash
Returned accidentally removed undefinition of MYSQL_SERVER in net_serv.cc inside embedded server
(embedded server uses real_net_read/write only as a client)

Prevented attempt to clean up embedded server if it was not initialized
2018-06-25 13:28:09 +02:00
Thirunarayanan Balathandayuthapani
88aaf590ac MDEV-16365 Setting a column NOT NULL fails to return error for
NULL values when there is no DEFAULT

Copy and inplace algorithm works similarly for
NULL to NOT NULL conversion for the following cases:
(1) strict sql mode - Should give error.
(2) non-strict sql mode - Should give warnings alone
(3) alter ignore table command. - Should give warnings alone.
2018-06-25 14:52:38 +05:30
Alexander Barkov
1abd877e2d MDEV-8049 name_const() is not consistent about its signess 2018-06-22 11:28:02 +04:00
Alexander Barkov
bcc2100f9d MDEV-16471 mysqldump throws "Variable 'sql_mode' can't be set to the value of 'NULL' (1231)" 2018-06-21 12:54:28 +04:00
Eugene Kosov
9dc81f7d38 MDEV-16330 Allow instant change of WITH SYSTEM VERSIONING column attribute
Changing columns WITH/WITHOUT SYSTEM VERSIONING doens't require to read data at
all. Thus it should be an instant operation.

Patch also fixes a bug when ALTER_COLUMN_UNVERSIONED wasn't passed to InnoDB
to change its internal structures.

change_field_versioning_try(): apply WITH/WITHOUT SYSTEM VERSIONING
change in SYS_COLUMNS for one field.

change_fields_versioning_try(): apply WITH/WITHOUT SYSTEM VERSIONING
change in SYS_COLUMNS for every changed field in a table.

change_fields_versioning_cache(): update cache for versioning property
of columns.
2018-06-20 19:23:48 +03:00
Alexander Barkov
ff09512e07 MDEV-16489 when lead() returns null on a datetime field, the result is treated as the literal string '[NULL]' 2018-06-20 19:36:37 +04:00
Alexander Barkov
9c53cbdd88 MDEV-15941 Explicit cursor FOR loop does not close the cursor 2018-06-20 13:29:11 +04:00
Oleksandr Byelkin
b534a7b89e Merge branch '10.3' into bb-10.3-fix_len_dec 2018-06-20 08:29:07 +02:00
Oleksandr Byelkin
083279f783 Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_dec 2018-06-19 14:51:50 +02:00
Igor Babaev
956b296248 MDEV-16420 View stop working after upgrade from 10.1.15 to 10.3.7
This bug happened for queries that used a materialized view that
renamed columns of the specifying query in an inner table of
an outer join. For such a query name resolution for a column
belonging the view could fail if the underlying column was
non-nullable.
When creating the defintion of the the temporary table for
the materialized view used in the inner part of an outer join
the definition of the non-nullable columns are created by the
function create_tmp_field_from_item() that names the columns
according to the names of the underlying columns. So these names
should be changed for the view column names.

This bug cannot be reproduced in 10.2 because there setup_fields()
called when preparing joins in the view specification effectively
renames the underlying columns in the function find_field_in_view().
In 10.3 this renaming was removed as improper
(see Monty's commit b478276b04).
2018-06-18 23:04:17 -07:00
Jacob Mathew
b27ec70935 MDEV-16319: Test for crash introduced by b4a2baffa8 fixed by 4968049799
Add a Spider test to ensure that a bug similar to MDEV-11084 is not
re-introduced.  Spider would crash if the first partition was not used first.

Author:
  Eric Herman.

First Reviewer:
  Jacob Mathew.

Second Reviewer:
  Kentoku Shiba.
2018-06-18 15:29:50 -07:00
Marko Mäkelä
0121d5a790 Merge 10.2 into 10.3 2018-06-18 15:43:59 +03:00
Sergei Golubchik
63027a5763 .gitignore
after 4461b0f9b3
2018-06-16 11:49:18 +02:00
Sergei Petrunia
f2c418079d Fix a typo in get_best_ror_intersect
cpk_scan should not be used if using it increases the cost of the query
plan.
2018-06-15 17:14:58 +03:00
Oleksandr Byelkin
6b8802e8dd MDEV-11071: Assertion `thd->transaction.stmt.is_empty()' failed in Locked_tables_list::unlock_locked_table
fix_length_and_dec now return result (error/OK)
2018-06-15 10:31:30 +02:00
Alexander Barkov
c55de8d40b MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result
When altering from DECIMAL to *INT UNIGNED or to BIT, go through val_decimal(),
to avoid truncation to the biggest possible signed integer
(0x7FFFFFFFFFFFFFFF / 9223372036854775807).
2018-06-15 10:11:51 +04:00
Alexander Barkov
f61909e19e MDEV-10182 Bad value when inserting COALESCE(CURRENT_TIMESTAMP) into a DECIMAL column
This problem was earlier fixed by the patch cb16d753b2
for MDEV-11337 Split Item::save_in_field() into virtual methods in Type_handler.

Adding tests only.
2018-06-15 06:33:34 +04:00
Galina Shalygina
ec4fdd5749 MDEV-16386: Wrong result when pushdown into the HAVING clause of the
materialized derived table/view that uses aliases is done

The problem appears when a column alias inside the materialized derived
table/view t1 definition coincides with the column name used in the
GROUP BY clause of t1. If the condition that can be pushed into t1
uses that ambiguous column name this column is determined as a column that
is used in the GROUP BY clause instead of the alias used in the projection
list of t1. That causes wrong result.
To prevent it resolve_ref_in_select_and_group() was changed.
2018-06-14 22:31:01 +02:00
Marko Mäkelä
a79b033b35 MDEV-16457 mariabackup 10.2+ should default to innodb_checksum_algorithm=crc32
Since MariaDB Server 10.2.2 (and MySQL 5.7), the default value of
innodb_checksum_algorithm is crc32 (CRC-32C), not the inefficient "innodb"
checksum. Change Mariabackup to use the same default, so that checksum
validation (when using the default algorithm on the server) will take less
time during mariabackup --backup. Also, mariabackup --prepare should be
a little faster, and the server should read backups faster, because the
page checksums would only be validated against CRC-32C.
2018-06-14 14:23:20 +03:00
Marko Mäkelä
2ca904f0ca MDEV-13103 Deal with page_compressed page corruption
fil_page_decompress(): Replaces fil_decompress_page().
Allow the caller detect errors. Remove
duplicated code. Use the "safe" instead of "fast" variants of
decompression routines.

fil_page_compress(): Replaces fil_compress_page().
The length of the input buffer always was srv_page_size (innodb_page_size).
Remove printouts, and remove the fil_space_t* parameter.

buf_tmp_buffer_t::reserved: Make private; the accessors acquire()
and release() will use atomic memory access.

buf_pool_reserve_tmp_slot(): Make static. Remove the second parameter.
Do not acquire any mutex. Remove the allocation of the buffers.

buf_tmp_reserve_crypt_buf(), buf_tmp_reserve_compression_buf():
Refactored away from buf_pool_reserve_tmp_slot().

buf_page_decrypt_after_read(): Make static, and simplify the logic.
Use the encryption buffer also for decompressing.

buf_page_io_complete(), buf_dblwr_process(): Check more failures.

fil_space_encrypt(): Simplify the debug checks.

fil_space_t::printed_compression_failure: Remove.

fil_get_compression_alg_name(): Remove.

fil_iterate(): Allocate a buffer for compression and decompression
only once, instead of allocating and freeing it for every page
that uses compression, during IMPORT TABLESPACE. Also, validate the
page checksum before decryption, and reduce the scope of some variables.

fil_page_is_index_page(), fil_page_is_lzo_compressed(): Remove (unused).

AbstractCallback::operator()(): Remove the parameter 'offset'.
The check for it in FetchIndexRootPages::operator() was basically
redundant and dead code since the previous refactoring.
2018-06-14 14:23:01 +03:00
Alexander Barkov
2cdb483bc4 MDEV-15352 AUTO_INCREMENT breaks after updating a column value to a negative number 2018-06-14 13:13:23 +04:00
Alexander Barkov
23ced2f846 MDEV-16311 Server crash when using a NAME_CONST() with a CURSOR
Problem:
The problem was most likely introduced by a fix for MDEV-11597
(commit 5f0c31f928) which removed
the assignment "killed= KILL_BAD_DATA" from THD::raise_condition().

Before MDEV-11597, sp_head::execute() tested thd->killed after
looping through the SP instructions and exited with an error
if thd->killed is set. After MDEV-11597, sp_head::execute()
stopped to notice errors and set the OK status on top of the
error status, which crashed on assert.

Fix:
Making sp_cursor::fetch() return -1 if server_side_cursor->fetch(1)
left an error in the diagnostics area. This makes the statement
"err_status= i->execute(thd, &ip)" in sp_head::execute() set the
error code and correctly break the SP instruction loop and
return on error without setting the OK status.
2018-06-13 23:37:09 +04:00
Sergei Petrunia
8662015c90 MDEV-15304: Server crash in print_keydup_error / key_unpack or unexpected ER_DUP_KEY
Adjust the patch to match the variant accepted into the upstream:
undo the changes in ha_rocksdb::load_hidden_pk_value().
2018-06-13 15:26:50 +03:00
Sergei Petrunia
931daaf79b MDEV-15319: [SQL Layer] Server crashes in Field::set_null / myrocks::ha_rocksdb ...
Added a testcase
2018-06-13 14:50:25 +03:00
Alexander Barkov
2412c15191 MDEV-15870 Using aggregate and window function in unexpected places can crash the server 2018-06-13 11:56:56 +04:00
Alexander Barkov
4787913db0 MDEV-16464 Oracle Comp.: Sql-Error on "SELECT name, comment FROM mysql.proc" 2018-06-13 08:25:16 +04:00
Alexander Barkov
ae0aefb1c5 MDEV-12060 Crash in EXECUTE IMMEDIATE with an expression returning a GRANT command
This problem was earlier fixed by MDEV-14603.
Only adding 10.2 specific tests.
2018-06-12 14:12:36 +04:00
Marko Mäkelä
b52bb6eb82 MDEV-16469 SET GLOBAL innodb_change_buffering has no effect
When type of the settable global variable innodb_change_buffering was
changed from string to ENUM in MDEV-12218, the "shadow" variable ibuf_use
stopped being updated as a result of SET GLOBAL innodb_change_buffering.
Only on InnoDB startup, the parameter innodb_change_buffering would
take effect.

ibuf_use: Remove, and use the global variable innodb_change_buffering.
2018-06-12 12:49:42 +03:00
Marko Mäkelä
8f5f0575ab MDEV-16456 InnoDB error "returned OS error 71" complains about wrong path
When attempting to rename a table to a non-existing database,
InnoDB would misleadingly report "OS error 71" when in fact the
error code is InnoDB's own (OS_FILE_NOT_FOUND), and not report
both pathnames. Errors on rename could occur due to reasons
connected to either pathname.

os_file_handle_rename_error(): New function, to report errors in
renaming files.
2018-06-12 10:25:23 +03:00
Vicențiu Ciorbaru
d54d067601 Undo wrong my_free overflow 2018-06-11 21:16:37 +03:00
Vicențiu Ciorbaru
ecd4c2b4a9 Add missed change from 7ffa82b03c 2018-06-11 20:24:41 +03:00
Vladislav Vaintroub
4461b0f9b3 MDEV-16424 replace cmake/bison.cmake with cmake's builtin FindBison module 2018-06-08 14:30:04 +01:00
Vladislav Vaintroub
aba2d7301f MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
Vladislav Vaintroub
ea70586282 MDEV-16300 : remove rocksdb checkpoint created by mariabackup.
Add variable rocksdb_remove_mariabackup_checkpoint.
If set, it will remove $rocksdb_datadir/mariabackup-checkpoint directory.
The variable is to be used by exclusively by mariabackup,
to remove temporary checkpoints.
2018-06-07 15:12:26 +01:00
Marko Mäkelä
62d21ddac1 Merge 10.2 into 10.3 2018-06-07 15:07:00 +03:00
Marko Mäkelä
dc9c555415 MDEV-16367 mariabackup: error: failed to copy enough redo log
log_copying_thread(): Keep copying redo log until the end has been
reached. (Previously, we would stop copying as soon as
the first batch of xtrabackup_copy_logfile() returned.)

log_copying: Remove. Use log_copying_running instead.

copy_logfile: Remove. Log copying will now only be invoked from
2 places: from xtrabackup_backup_func() for the initial batch,
and from log_copying_thread() until all of the log has been read.
Use the global variable metadata_to_lsn for determining if the
final part of the log is being copied.

xtrabackup_copy_log(): Add diagnostic messages for terminating
the copying. These messages should be dead code, because
log_group_read_log_seg() should be checking for the same.

xtrabackup_copy_logfile(): Correct the retrying logic.
If anything was successfully read, process the portion that
was read. On failure, let the caller close dst_log_file.

io_watching_thread(): Stop throttling during the last phase
of copying the log (metadata_to_lsn!=0). The final copying
of the log will now be performed in log_copying_thread().

stop_backup_threads(): Clean up the message about stopping
the log copying thread.

xtrabackup_backup_low(): Read metadata_to_lsn from the latest
checkpoint header page, even if it is the first page.
Let the log_copying_thread take care of copying all of
the redo log.
2018-06-07 14:29:35 +03:00
Marko Mäkelä
619c277a6c Mariabackup: Make some globals static 2018-06-07 14:11:55 +03:00