Commit graph

1762 commits

Author SHA1 Message Date
Nikita Malyavin
c16a54c02e MDEV-16429: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' fails upon attempt to update virtual column on partitioned versioned table
When using buffered sort in `UPDATE`, keyread is used. In this case,
`TABLE::update_virtual_field` should be aborted, but it actually isn't,
because it is called not with a top-level handler, but with the one that
is actually going to access the disk. Here the problemm is issued with
partitioning, so the solution is to recursively mark for keyread all the
underlying partition handlers.

* ha_partition: update keyread state for child partitions

Closes #800
2018-09-21 15:05:54 +02:00
Anel Husakovic
d526679efd MDEV-14474 information_schema.check_constraints
Implement according to standard SQL specification 2008.
The check_constraints table is used for fetching metadata about
the constraints defined for tables in all databases.
2018-08-25 17:03:20 +03:00
Marko Mäkelä
05459706f2 Merge 10.2 into 10.3 2018-08-03 15:57:23 +03:00
Marko Mäkelä
814ae57daf Merge 10.1 into 10.2 2018-08-03 13:02:56 +03:00
Marko Mäkelä
769f6d2db7 Fix -Wclass-memaccess in WSREP,InnoDB,XtraDB 2018-08-03 12:21:13 +03:00
Jacob Mathew
813b739850 MDEV-16246: insert timestamp into spider table from mysqldump gets wrong time zone.
The problem occurred because the Spider node was incorrectly handling
timestamp values sent to and received from the data nodes.

The problem has been corrected as follows:
- Added logic to set and maintain the UTC time zone on the data nodes.
  To prevent timestamp ambiguity, it is necessary for the data nodes to use
  a time zone such as UTC which does not have daylight savings time.
- Removed the spider_sync_time_zone configuration variable, which did not
  solve the problem and which interfered with the solution.
- Added logic to convert to the UTC time zone all timestamp values sent to
  and received from the data nodes.  This is done for both unique and
  non-unique timestamp columns.  It is done for WHERE clauses, applying to
  SELECT, UPDATE and DELETE statements, and for UPDATE columns.
- Disabled Spider's use of direct update when any of the columns to update is
  a timestamp column.  This is necessary to prevent false duplicate key value
  errors.
- Added a new test spider.timestamp to thoroughly test Spider's handling of
  timestamp values.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit 97cc9d3 on branch bb-10.3-MDEV-16246
2018-07-09 16:09:20 -07:00
Sergei Golubchik
36e59752e7 Merge branch '10.2' into 10.3 2018-06-30 16:39:20 +02:00
Marko Mäkelä
31c950cca8 Merge 10.1 into 10.2 2018-06-26 18:16:49 +03:00
Marko Mäkelä
c6392d52ee Merge 10.0 into 10.1 2018-06-26 17:34:44 +03:00
Andrei Elkin
28e1f1453f MDEV-15242 Poor RBR update performance with partitioned tables
Observed and described
partitioned engine execution time difference
between master and slave was caused by excessive invocation
of base_engine::rnd_init which was done also for partitions
uninvolved into Rows-event operation.
The bug's slave slowdown therefore scales with the number of partitions.

Fixed with applying an upstream patch.

References:
----------
https://bugs.mysql.com/bug.php?id=73648
Bug#25687813 REPLICATION REGRESSION WITH RBR AND PARTITIONED TABLES
2018-06-25 16:45:00 +03:00
Marko Mäkelä
682e7b8ff4 MDEV-16334 Incorrect ALTER TABLE for changing column option
commit 2dbeebdb16 accidentally changed
ALTER_COLUMN_OPTION and ALTER_COLUMN_STORAGE_TYPE to be separate flags.
InnoDB and Mroonga are only checking for the latter;
the example storage engine is checking for the former only.

The impact of this bug should be incorrect operation of Mroonga when
the column options GROONGA_TYPE, FLAGS are changed.

InnoDB does not define any column options, only table options,
so the flag ALTER_COLUMN_OPTION should never have been set.

Also, remove the unused flag ALTER_DROP_HISTORICAL.
2018-05-30 14:35:34 +03:00
Sergei Golubchik
b1a6d2826a cleanup: versioning style fixes
rename LString/XString classes, remove unused ones
2018-05-12 10:16:45 +02:00
Thirunarayanan Balathandayuthapani
85cc6b70bd MDEV-13134 Introduce ALTER TABLE attributes ALGORITHM=NOCOPY and ALGORITHM=INSTANT
Introduced new alter algorithm type called NOCOPY & INSTANT for
inplace alter operation.

NOCOPY - Algorithm refuses any alter operation that would
rebuild the clustered index. It is a subset of INPLACE algorithm.

INSTANT - Algorithm allow any alter operation that would
modify only meta data. It is a subset of NOCOPY algorithm.

Introduce new variable called alter_algorithm. The values are
DEFAULT(0), COPY(1), INPLACE(2), NOCOPY(3), INSTANT(4)

Message to deprecate old_alter_table variable and make it alias
for alter_algorithm variable.

alter_algorithm variable for slave is always set to default.
2018-05-07 14:58:11 +05:30
Marko Mäkelä
7396dfcca7 Merge 10.2 into 10.3 2018-04-24 20:59:57 +03:00
Marko Mäkelä
4cd7979c56 Merge 10.1 into 10.2 2018-04-24 09:39:45 +03:00
Marko Mäkelä
9c34a4124d Merge 10.0 into 10.1 2018-04-24 09:26:40 +03:00
Sergei Golubchik
587568b72a Merge branch '5.5' into 10.0 2018-04-20 14:33:24 +02:00
Sergei Golubchik
9bd3af97df MDEV-15413 Unexpected errors upon CREATE TABLE .. WITH SYSTEM VERSIONING AS SELECT ...
numerous fixes for CREATE ... SELECT with system versioning:
In CREATE ... SELECT the table is created based on the result set,
field properties do not count. That is
* field invisibility is *not* copied over
* AS ROW START/END is *not* copied over
* the history is *not* copied over
* system row_start/row_end fields can *not* be created from the SELECT part
2018-04-10 13:12:36 +02:00
Aleksey Midenkov
689f83d0ce MDEV-14790 System versioning for system tables does not work as expected
disallow system versioning for tables in mysql database
2018-04-10 13:12:36 +02:00
Sergei Golubchik
dba43f4bec fix comparison of row_start/row_end 2018-04-10 13:12:36 +02:00
Sergei Golubchik
35678c9572 dead code - related to vtmd
(will be added back when it'll be used)
2018-04-10 13:12:36 +02:00
Monty
ab1941266c Move alter partition flags to alter_info->partition_flags
This is done to get more free flag bits for alter_info->flags

Renamed all ALTER PARTITION defines to start with ALTER_PARTITION_
Renamed ALTER_PARTITION to ALTER_PARTITION_INFO
Renamed ALTER_TABLE_REORG to ALTER_PARTITION_TABLE_REORG

Other things:
- Shifted some ALTER_xxx defines to get empty bits at end
2018-03-29 13:59:41 +03:00
Monty
2dbeebdb16 Changed static const in Alter_info and Alter_online_info to defines
Main reason was to make it easier to print the above structures in
a debugger. Additional benefits is that I was able to use same
defines for both structures, which simplifes some code.

Most of the code is just removing Alter_info:: and Alter_inplace_info::
from alter table flags.

Following renames was done:
HA_ALTER_FLAGS        -> alter_table_operations
CHANGE_CREATE_OPTION  -> ALTER_CHANGE_CREATE_OPTION
Alter_info::ADD_INDEX -> ALTER_ADD_INDEX
DROP_INDEX            -> ALTER_DROP_INDEX
ADD_UNIQUE_INDEX      -> ALTER_ADD_UNIQUE_INDEX
DROP_UNIQUE_INDEx     -> ALTER_DROP_UNIQUE_INDEX
ADD_PK_INDEX          -> ALTER_ADD_PK_INDEX
DROP_PK_INDEX         -> ALTER_DROP_PK_INDEX
Alter_info:ALTER_ADD_COLUMN    -> ALTER_PARSE_ADD_COLUMN
Alter_info:ALTER_DROP_COLUMN   -> ALTER_PARSE_DROP_COLUMN
Alter_inplace_info::ADD_INDEX  -> ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX
Alter_inplace_info::DROP_INDEX -> ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX

Other things:
- Added typedef alter_table_operatons for alter table flags
- DROP CHECK CONSTRAINT can now be done online
- Added checks for Aria tables in alter_table_online.test
- alter_table_flags now takes an ulonglong as argument.
- Don't support online operations if checksum option is used.
- sql_lex.cc doesn't add ALTER_ADD_INDEX if index is not created
2018-03-29 13:59:40 +03:00
Monty
c3f37c070c Fixed alter online table for Aria tables
fill_alter_table() always thought that index was changed because of
of a wrong check of block_size. Some engines had code to correct this
that should not be needed, Aria didn't and because of this some online
operations didn't work.

This code fixes the comparision of block_size to only compare if it's set.
2018-03-29 13:59:40 +03:00
Sergei Golubchik
485325e7e3 don't allow TIMESTAMP(6) versioning and FK with CASCADE or SET NULL 2018-02-24 01:28:50 +01:00
Sergei Golubchik
7e2c686b3f remove partition-specific methods from the base handler class 2018-02-23 15:33:23 +01:00
Sergei Golubchik
9fa715b84d MDEV-14798 Add, drop system versioning semantic and syntax
SQL: DROP PERIOD FOR SYSTEM_TIME syntax

and remove ER_VERS_SYS_FIELD_EXISTS

originally by: Eugene Kosov
2018-02-23 15:33:22 +01:00
Marko Mäkelä
b006d2ead4 Merge bb-10.2-ext into 10.3 2018-02-15 10:22:03 +02:00
Monty
54db0be3be Added Max_index_length and Temporary to SHOW TABLE STATUS
- Max_index_length is supported by MyISAM and Aria tables.
- Temporary is a placeholder to signal that a table is a
  temporary table. For the moment this is always "N", except
  "Y" for generated information_schema tables and NULL for
  views. Full temporary table support will be done in another task.
  (No reason to have to update a lot of result files twice in a row)
2018-02-12 17:17:26 +02:00
Monty
a7e352b54d Changed database, tablename and alias to be LEX_CSTRING
This was done in, among other things:
- thd->db and thd->db_length
- TABLE_LIST tablename, db, alias and schema_name
- Audit plugin database name
- lex->db
- All db and table names in Alter_table_ctx
- st_select_lex db

Other things:
- Changed a lot of functions to take const LEX_CSTRING* as argument
  for db, table_name and alias. See init_one_table() as an example.
- Changed some function arguments from LEX_CSTRING to const LEX_CSTRING
- Changed some lists from LEX_STRING to LEX_CSTRING
- threads_mysql.result changed because process list_db wasn't always
  correctly updated
- New append_identifier() function that takes LEX_CSTRING* as arguments
- Added new element tmp_buff to Alter_table_ctx to separate temp name
  handling from temporary space
- Ensure we store the length after my_casedn_str() of table/db names
- Removed not used version of rename_table_in_stat_tables()
- Changed Natural_join_column::table_name and db_name() to never return
  NULL (used for print)
- thd->get_db() now returns db as a printable string (thd->db.str or "")
2018-01-30 21:33:55 +02:00
Alexey Botchkov
b4a2baffa8 MDEV-11084 Select statement with partition selection against MyISAM table opens all partitions.
Now we don't open partitions if it was explicitly cpecified.
        ha_partition::m_opened_partition bitmap added to track
        partitions that were actually opened.
2018-01-29 11:01:14 +04:00
Eugene Kosov
f96b1a4e39 MDEV-14798 Add, drop system versioning semantic and syntax 2018-01-12 21:20:23 +01:00
Aleksey Midenkov
5c0a19c873 System Versioning 1.0 pre7
Merge branch '10.3' into trunk
2017-12-21 11:16:42 +03:00
Eugene Kosov
4bc268d406
MDEV-14632 Assertion `!((new_col->prtype ^ col->prtype) & ~256U)' failed in row_log_table_apply_convert_mrec
SQL, IB: proper fix is to disable unimplemented Online DDL for system-versioned tables inside InnoDB
2017-12-20 19:42:15 +03:00
Marko Mäkelä
0436a0ff3c Merge bb-10.2-ext into 10.3 2017-12-19 17:28:22 +02:00
Marko Mäkelä
028e91f380 Merge 10.2 into bb-10.2-ext 2017-12-19 17:12:14 +02:00
Marko Mäkelä
8d70097c21 Merge 10.1 to 10.2
Follow-up fix to MDEV-14008: Let Field_double::val_uint() silently
return 0 on error
2017-12-19 16:48:28 +02:00
Marko Mäkelä
09c5bbf471 Merge 10.0 into 10.1 2017-12-18 20:05:50 +02:00
Aleksey Midenkov
b55a149194
Timestamp-based versioning for InnoDB [closes #209]
* Removed integer_fields check
* Reworked Vers_parse_info::check_sys_fields()
* Misc renames
* versioned as vers_sys_type_t

* Removed versioned_by_sql(), versioned_by_engine()

versioned() works as before;
versioned(VERS_TIMESTAMP) is versioned_by_sql();
versioned(VERS_TRX_ID) is versioned_by_engine().

* create_tmp_table() fix
* Foreign constraints for timestamp-based
* Range auto-specifier fix
* SQL: 1-row partition rotation fix [fixes #260]
* Fix 'drop system versioning, algorithm=inplace'
2017-12-18 19:03:51 +03:00
Sergei Golubchik
03e91ce324 MDEV-14641 Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine
make sure that mysql_create_frm_image() and fast_alter_partition_table()
use the same code to derive HA_OPTION_PACK_RECORD from
create_info->row_type.
2017-12-18 16:16:42 +01:00
Alexey Botchkov
0acac4fe5f MDEV-14593 human-readable XA RECOVER.
The 'data' field in the XA RECOVER resultset changed
        to be charset_bin. It seems to me right and also
        --binary-as-hex starts working.  The XA RECOVER FORMAT='SQL' option
        implemented.  It returns the XID string that fits to be an argument for the
        XA ... statements.
2017-12-18 01:55:40 +04:00
Eugene Kosov
9b55cc73f1
SQL, IB: unversioned fields with ALTER TABLE [fixes #401] 2017-12-15 20:37:36 +03:00
Aleksey Midenkov
459f40a232
SQL: create..select revisited [closes #370] 2017-12-12 21:30:49 +03:00
Aleksey Midenkov
79dd77e6ae System Versioning 1.0 pre3
Merge branch '10.3' into trunk
2017-12-11 15:43:41 +03:00
Sergei Golubchik
d3845132fc remove 'vers_auto_decrement'
Do not generate fake values when adding an auto-inc column to a versioned
table. This is not a auto-inc issue, but a more general case of adding
a not nullalble unique column to a table with history. We don't support
it yet, not even with a special auto-inc hack. As a workaround, one
can use a nullable unique column, that works.
2017-12-05 18:01:43 +03:00
Kentoku SHIBA
e53ef202bd Adding direct update/delete to the server and to the partition engine.
Add support for direct update and direct delete requests for spider.
A direct update/delete request handles all qualified rows in a single
operation rather than one row at a time.

Contains Spiral patches:
006_mariadb-10.2.0.direct_update_rows.diff      MDEV-7704
008_mariadb-10.2.0.partition_direct_update.diff MDEV-7706
010_mariadb-10.2.0.direct_update_rows2.diff     MDEV-7708
011_mariadb-10.2.0.aggregate.diff               MDEV-7709
027_mariadb-10.2.0.force_bulk_update.diff       MDEV-7724
061_mariadb-10.2.0.mariadb-10.1.8.diff          MDEV-12870

- The differences compared to the original patches:
  - Most of the parameters of the new functions are unnecessary.  The
    unnecessary parameters have been removed.
  - Changed bit positions for new handler flags upon consideration of
    handler flags not needed by other Spiral patches and handler flags
    merged from MySQL.
  - Added info_push() (Was originally part of bulk access patch)
  - Didn't include code related to handler socket
  - Added HA_CAN_DIRECT_UPDATE_AND_DELETE

Original author: Kentoku SHIBA
First reviewer:  Jacob Mathew
Second reviewer: Michael Widenius
2017-12-03 13:58:36 +02:00
Monty
f26e14e2d8 Adding option to tell that cmp_ref handler call is expensive
- In Spider, calling cmp_ref() can be very expensive. In ha_partition.cc
  we don't anymore sort rows according to position for the Spider
  engine.
- Removed Spider specific call info(HA_EXTRA_STARTING_ORDERED_INDEX_SCAN)
  from handle_ordered_index_scan(). It's caused performance issues and
  does not change results for queries with ORDER BY.
- The visible effect of this patch is that for some storage engines,
  rows may be returned in a different order if there is no ORDER BY clause.

- Based in Spiral Patch 052:
  052_mariadb-10.2.0.add_partition_skip_pk_sort_for_non_clustered_index
  MDEV-7748
- The major difference from original patch is that there is no variable to
  get the old behaviour.

Other things:
- Optimized ha_partition::cmp_ref() and cmp_part_ids() to make them
  simpler and faster.
- Changed arguments to cmp_key_part_id() to be same as
  cmp_key_rowid_part_id to simplify code.

Original author: Kentoku SHIBA
First reviewer:  Jacob Mathew
Second reviewer: Michael Widenius
2017-12-03 13:58:35 +02:00
Monty
dc17ac1638 Adding support for auto_increment in the partition engine.
Contains Spiral patches:
022_mariadb-10.2.0.auto_increment.diff               MDEV-7720
030: 030_mariadb-10.2.0.partition_auto_inc_init.diff MDEV-7726

These patches have the following differences compared to the original
patches:
- Added the new #defines for the feature in spd_environ.h instead of in
  handler.h because these #defines are needed by Spider and are not needed
  by the server.
- Cleaned up code related to the removed variable m_need_info_for_auto_inc
. Changed variable assignment in lock_auto_increment() and
  unlock_auto_increment() so that the assignments are done under locks.
- Added a test case.
- Added test result changes resulting from a bug that was fixed by these
  patches.

Original author: Kentoku SHIBA
First reviewer:  Jacob Mathew
Second reviewer: Michael Widenius
2017-12-03 13:58:35 +02:00
Monty
2f09b28e0f Adding Full Text Search support to partitions
Contains Spiral patches:
007_mariadb-10.2.0.partition_fulltext.diff  MDEV-7705
038_mariadb-10.2.0.partition_fulltext2.diff MDEV-7734

This commit has the following differences compared to the original
patches:

- Added necessary full text search cleanup at the storage engine layer
  that was omitted in the original patch.
- Added test case.
- A lot of code cleanups to make the code notable smaller.
- Changed SQL code to use ha_ft_end() instead of ft_end()

Original author: Kentoku SHIBA
First reviewer:  Jacob Mathew
Second reviewer: Michael Widenius
2017-12-03 13:58:35 +02:00
Monty
da26d16dd1 Add direct aggregates
Spider patches 026 (MDEV-7723), 031 (MDEV-7727) and 058 (MDEV-12532)

This allows the storage engine to internally compute sum and count
operations.

- Enhance sum items to be able to store the sum value directly.
- return_record_by_parent() is enabled in spider as
  HANDLER_HAS_DIRECT_AGGREGATE is defined
- Added spd_environ.h to spider. This is loaded first to ensure that all
  MariaDB specific defines that are used by include files are properly
  defined.
- This code is tested by the existing spider tests direct_aggregate.test
  and direct_aggregate_part.test and also partition.test
2017-12-03 13:58:35 +02:00