Commit graph

788 commits

Author SHA1 Message Date
Alexander Barkov
fe844c16b6 Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
Marko Mäkelä
18795f5512 Merge 10.3 into 10.4 2022-09-13 16:36:38 +03:00
Alexander Barkov
f1544424de MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
Nayuta Yanagisawa
70021737f5 MDEV-27172 fixup: spider/bugfix.mdev_27172 failed with --ps-protocol 2022-09-08 21:06:55 +09:00
Marko Mäkelä
1985204044 Merge 10.5 into 10.6 2022-09-07 08:47:20 +03:00
Marko Mäkelä
38d36b59f9 Merge 10.4 into 10.5 2022-09-07 08:26:21 +03:00
Marko Mäkelä
c7ba237793 Merge 10.3 into 10.4 2022-09-07 08:08:59 +03:00
Nayuta Yanagisawa
e4cffc92c7 MDEV-27172 Prefix indices on Spider tables may lead to wrong query results
Spider converts HA_READ_KEY_EXACT to the equality (=) in the
function spider_db_append_key_where_internal() but the conversion
is not necessarily correct for tables with prefix indices.

We fix the bug by converting HA_READ_KEY_EXACT to 'LIKE "foo%"' when
a target key is a prefix key. The fix is partly inspired by FEDERATED.
See ha_federated::create_where_from_key() for more details.
2022-09-01 18:32:40 +09:00
Nayuta Yanagisawa
03726a36b8 Merge 10.5 into 10.6 2022-08-23 21:58:45 +09:00
Nayuta Yanagisawa
720fa05e5b Merge 10.4 into 10.5 2022-08-23 20:59:34 +09:00
Nayuta Yanagisawa
e404315258 Fix wrong diff introduced by merge commit
Many Spider tests were broken by the merge commit, 36d173e.
2022-08-23 19:59:30 +09:00
Marko Mäkelä
d65a2b7bde Merge 10.5 into 10.6 2022-08-22 14:02:43 +03:00
Marko Mäkelä
1d90d6874d Merge 10.4 into 10.5 2022-08-22 13:38:40 +03:00
Marko Mäkelä
36d173e523 Merge 10.3 into 10.4 2022-08-22 12:34:42 +03:00
Nayuta Yanagisawa
c208006080 MDEV-29008 Server crash or assertion `field' failed in spider_db_open_item_ident / group by handler
ha_spider::field_exchange() returns NULL and that results in a crash
or a assertion failure in spider_db_open_item_ident().

In the first place, there seems to be no need to call field_exchange()
for printing an identity (column name with alias). Thus, we simply
remove the call.
2022-08-16 16:36:44 +09:00
Oleksandr Byelkin
48e35b8cf6 Merge branch '10.3' into 10.4 2022-08-02 14:15:39 +02:00
Marko Mäkelä
4b77d38c26 Fix GCC -Og -Wmaybe-uninitialized 2022-07-28 08:51:19 +03:00
Marko Mäkelä
30914389fe Merge 10.5 into 10.6 2022-07-27 17:52:37 +03:00
Marko Mäkelä
098c0f2634 Merge 10.4 into 10.5 2022-07-27 17:17:24 +03:00
Oleksandr Byelkin
3bb36e9495 Merge branch '10.3' into 10.4 2022-07-27 11:02:57 +02:00
Nayuta Yanagisawa
2f3f1cd05b MDEV-26544 Assertion `part_share->auto_inc_initialized' failed in ha_partition::get_auto_increment on INSERT
The partition storage engine ignores return (error) values of
handler::info(). As a result, a query that should be aborted is
not aborted and then the server violates the assertion.
2022-07-05 23:07:49 +09:00
Nayuta Yanagisawa
4bc7c03b5f MDEV-29011 Server crash in spider_db_open_item_cond with XOR operator
Item_func_xor and Item_cond are both derived class of Item_bool_func.
Spider converts *Item_func_xor to *Item_cond and then calls the member
function argument_list(), which Item_func_xor does not implement.
2022-07-05 23:02:19 +09:00
Marko Mäkelä
62a20f8047 Merge 10.5 into 10.6 2022-07-01 15:24:50 +03:00
Marko Mäkelä
f09687094c Merge 10.4 into 10.5 2022-07-01 14:42:02 +03:00
Marko Mäkelä
90792e4a43 Merge 10.5 into 10.6 2022-06-30 19:41:07 +03:00
Nayuta Yanagisawa
dbd562787a MDEV-24343 Spider Left join failed Unknown column 't0.ID' in 'on clause'
The Spider mixes the comma join with other join types, and thus
ERROR 1054 occurs. This is well-known issue caused by the higher
precedence of JOIN over the comma (,).

We can fix the problem simply by using JOINs instead of commas.
2022-06-28 05:23:14 +09:00
Nayuta Yanagisawa
a26700cca5 MDEV-28352 Spider: heap-use-after-free in ha_spider::lock_tables(), heap freed by spider_commit()
The heap-use-after-free is caused by the following mechanism:

  * In the execution of FLUSH TABLE WITH READ LOCK, the function
    spider_free_trx_conn() is called and the connections held by
    SPIDER_TRX::trx_conn_hash are freed.

  * Then, an instance of ha_spider maintains the freed connections
    because they are also referenced from ha_spider::conns.
    The ha_spider instance is kept in a lock structure until the
    corresponding table is unlocked.

  * Spider accesses ha_spider::conns on the implicit UNLOCK TABLE
    issued by BEGIN.

In the first place, when the connections have been freed, it means
that there are really no remote table locked by Spider.
Thus, there is no need for Spider to access ha_spider::cons on the
implicit UNLOCK TABLE.

We can fix the bug by removing the above mentioned access to
ha_spider::conns. We also modified spider_free_trx_conn() so that it
frees the connections only when no table is locked to reduce the
chance of another heap-use-after-free on ha_spider::conns.
2022-06-28 01:03:33 +09:00
Marko Mäkelä
87bd79b1e7 Merge 10.5 into 10.6 2022-06-27 10:59:31 +03:00
Marko Mäkelä
ea847cbeaf Merge 10.4 into 10.5 2022-06-27 10:51:20 +03:00
Marko Mäkelä
03174cabd7 Fix GCC -Og -Wmaybe-uninitialized 2022-06-27 10:49:15 +03:00
Marko Mäkelä
dd7e9fb38a MDEV-28854 after-merge fix: Remove a test for MDEV-26583 2022-06-27 10:47:05 +03:00
Marko Mäkelä
01d757036f Merge 10.3 into 10.4 2022-06-27 10:14:37 +03:00
Hirokazu Hata
2c1aaa6664
MDEV-28854 Disallow INSERT DELAYED on Spider table
Spider supports (or at least allows) INSERT DELAYED but the
documentation does not specify spider as a storage engine that supports
"INSERT DELAYED".
Also, although not mentioned in the documentation, "INSERT DELAYED" is
not intended to be executed inside a transaction, as can be seen from
the list of supported storage engines.
The current implementation allows executing a delayed insert on a
remote transactional table and this breaks the consistency ensured by
the transaction.

We too remove "internal_delayed", one of the Spider table parameters.
Documentation says,

> Whether to transmit existence of delay to remote servers when
> executing an INSERT DELAYED statement on local server.

This table parameter is only used for "INSERT DELAYED".

Reviewed by: Nayuta Yanagisawa
2022-06-27 14:58:18 +09:00
Marko Mäkelä
e11b82f8f5 Merge 10.5 into 10.6 2022-06-09 13:34:52 +03:00
Daniel Black
e8b0894dc8 MDEV-28243: AIX missing my_gethwaddr implementation
and failing spider partition test.

With some small datatype changes to the Linux/Solaris my_gethwaddr implementation
the hardware address of AIX can be returned. This is an important aspect
in Spider (and UUID).

Spider test change reviewed by Nayuta Yanagisawa.

my_gethwaddr review by Monty in #2081
2022-06-08 17:13:51 +10:00
Marko Mäkelä
05d049bdbe Merge 10.5 into 10.6 2022-05-25 14:39:42 +03:00
Michael Widenius
734f10f601 Fix that spider test doesn't crash if my_gethwaddr() fails
This can happen if one doesn't have a working network connection when running
spider tests
2022-05-24 14:10:34 +03:00
Sergei Golubchik
b2187662bc Merge branch '10.5' into 10.6 2022-05-18 10:30:47 +02:00
Sergei Golubchik
7970ac7fe8 Merge branch '10.4' into 10.5 2022-05-18 09:50:26 +02:00
Sergei Golubchik
23ddc3518f Merge branch '10.3' into 10.4 2022-05-18 01:25:30 +02:00
Nayuta Yanagisawa
8c28b27f00 MDEV-28301 Spider: Fix GCC warnings, comparing the result of pointer addition ... and NULL
The condition of the if statements are always true.
2022-05-13 21:32:49 +09:00
Marko Mäkelä
fae0ccad6e Merge 10.5 into 10.6 2022-04-21 17:46:40 +03:00
Marko Mäkelä
620c55e708 Merge 10.4 into 10.5 2022-04-21 15:33:50 +03:00
Marko Mäkelä
394784095e Merge 10.3 into 10.4 2022-04-21 11:33:59 +03:00
Marko Mäkelä
7da351d804 Merge 10.5 into 10.6 2022-04-15 21:02:10 +03:00
Nayuta Yanagisawa
4abb023ba5 Spider: disable spider/bugfix.mdev_27239 2022-04-15 18:53:51 +09:00
Alexander Barkov
9d734cdd61 Merge remote-tracking branch 'origin/10.2' into 10.3 2022-04-14 11:50:34 +04:00
Marko Mäkelä
ca3bbf4c0c Merge 10.5 into 10.6 2022-04-12 09:26:02 +03:00
KiyoshiTakeda
4d1955d348
MDEV-28225 Disallow user to create Spider temporary table
Creating a temporary table with Spider is non-sense because a Spider
table cannot hold any physical data and it requires an additional
effort to manage even if it is configured correctly.

Set HTON_TEMPORARY_NOT_SUPPORTED to spider_hton->flags.  

Reviewed-by: nayuta.yanagisawa@hey.com
Co-authored-by: d8sk4ueun@gmail.com
2022-04-11 23:02:38 +09:00
Nayuta Yanagisawa
d8463b64b3 MDEV-27239 Spider: Assertion `thd->transaction->stmt.ha_list == __null || trans == &thd->transaction->stmt' failed in ha_commit_trans on BEGIN WORK after FTWRL
The check on the SQL command type, in ha_spider::external_lock() is deleted
by e954d9de. This resulted in the wrong call of spider_internal_start_trx()
(and thus Ha_trx_info::register_ha()).

I reverted the check and refactored ha_spider::external_lock().
2022-04-08 17:59:50 +09:00
Nayuta Yanagisawa
4194f7b605 MDEV-25116 Spider: IF(COUNT( trigger SQL Error (1054)_ Unknown column '' in field list
The original query "SELECT IF(COUNT(a.`id`)>=0,'Y','N') FROM t" is
transformed to "SELECT COUNT(a.`id`), IF(ref >= 0, 'Y', 'N') FROM t",
where ref is Item_ref to "COUNT(a.`id`)", by split_sum_func().

Spider walks the item list twice, invoking spider_db_print_item_type().
The first invocation is in spider_create_group_by_handler() with
str == NULL. The second one is in spider_group_by_handler::init_scan()
with str != NULL.

spider_db_print_item_type() prints nothing at the first invocation,
and it prints item at the second invocation. However, at the second
invocation, the above mentioned ref to "COUNT(a.`id`)" points to
a field in a temporary table where the result will be stored. Thus,
to look behind the item_ref, Spider need to generate the query earlier.

A possible fix would be to generate a query to send in
spider_create_group_by_handler(). However, the fix requires a
considerable amount of changes of the Spider's GROUP BY handler.
I'd like to avoid that.

So, I fix the problem by not to use the GROUP BY handler when a
query contains Item_ref whose table_name, name, and alias_name_used
are not set.
2022-04-08 15:27:33 +09:00
Oleksandr Byelkin
f5c5f8e41e Merge branch '10.5' into 10.6 2022-02-03 17:01:31 +01:00
Oleksandr Byelkin
cf63eecef4 Merge branch '10.4' into 10.5 2022-02-01 20:33:04 +01:00
Oleksandr Byelkin
a576a1cea5 Merge branch '10.3' into 10.4 2022-01-30 09:46:52 +01:00
Alexey Botchkov
466d81709b MDEV-26768 Spider table crashes the server after the mysql_list_fields() client's call and produces weird result for SHOW FIELDS.
Suppress errors in ha_spider::info() called from mysqld_show_fields()
2022-01-20 14:44:56 +04:00
Nayuta Yanagisawa
f8c3d59274 MDEV-26583 SIGSEGV's in spider_get_select_limit_from_select_lex when DELAYED INSERT is used
Spider dereferences a freed select_lex and then results in SIGSEGV.
2022-01-19 18:58:47 +09:00
Marko Mäkelä
1abc476f0b Merge 10.5 into 10.6 2022-01-18 12:59:50 +02:00
Nayuta Yanagisawa
b7e4dc121a MDEV-27240 fixup: remove dead code 2022-01-15 21:24:25 +09:00
Nayuta Yanagisawa
64f844b611 MDEV-27240 fixup: remove #ifdef in macro call
Windows builds failed due to the following error:
'#': invalid character: possibly the result of a macro expansion
2022-01-15 17:33:48 +09:00
Nayuta Yanagisawa
2ecd39c983 MDEV-27240 SIGSEGV in ha_spider::store_lock on LOCK TABLE
The commit e954d9de gave different lifetime to wide_share and
partition_handler_share. This introduced the possibility that
partition_handler_share could be accessed even after it was freed.

We stop sharing partitoiin_handler_share and make it belong to
a single wide_handler to fix the problem.
2022-01-15 13:25:09 +09:00
Nayuta Yanagisawa
7b0c2a9980 Revert "MDEV-26345 SELECT MIN on Spider table returns more rows than expected"
This reverts commit b9730226dc.
2022-01-14 15:58:38 +09:00
Nayuta Yanagisawa
b9730226dc MDEV-26345 SELECT MIN on Spider table returns more rows than expected
The Spider storage engine ignored the implicit grouping when
aggregation was converted to constant by the query optimizer.
As a result, the Spider SE returned rows more than expected.

To fix the problem, we notify the Spider SE of the existence of
the implicit grouping via Query::distinct.
2022-01-11 14:08:55 +09:00
Andrei
30b917d34a MDEV-27039 Trying to lock mutex ... when the mutex was already locked
The reason of the double lock was an extraneous ha_flush_logs().
Unlike the upstream it is unnecessary in Mariadb that exploits a binlog
checkpoint mechanism for not letting PURGE or RESET-MASTER to trouble
transaction recovery. That is in case should a trx
be prepared but its binlog file gone, the trx then is committed on disk too.
Those facts have been always verified by existing tests of

  binlog.binlog_{checkpoint,xa_recover}.test.

A regression test for the bug is included though.
2022-01-03 13:24:50 +02:00
Marko Mäkelä
c9db50b585 Merge 10.4 into 10.5 2022-01-03 07:23:49 +02:00
Nayuta Yanagisawa
5045509b72 MDEV-27184 Assertion (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed, Assertion str.alloced_length() >= str.length() + data_len' failed
Spider crashes on a query that inserts some rows including float.
This is because Spider allocates a string of insufficient length.
2021-12-27 11:49:12 +09:00
Nayuta Yanagisawa
dc74d23482 MDEV-27184 Assertion (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed, Assertion str.alloced_length() >= str.length() + data_len' failed
Spider crashes on a query that inserts some rows including float.
This is because Spider allocates a string of insufficient length.
2021-12-24 00:12:44 +09:00
Marko Mäkelä
73f5cbd0b6 Merge 10.5 into 10.6 2021-10-21 16:06:34 +03:00
Nayuta Yanagisawa
e7208bd934 MDEV-26158 SIGSEGV in spider_free_mem from ha_spider::open on INSERT
The server crashes due to passing NULL to spider_free().

In some cases, this == pt_handler_share_handlers[0] at the label
error_get_share in ha_spider::open().

In such cases, to nullify pt_handler_share_handlers[0]->wide_handler
is nothing but to nullify this->wide_handler. We should not do this
before freeing this->wide_handler.
2021-10-19 19:04:05 +09:00
Marko Mäkelä
59fe6a8a01 Merge 10.5 into 10.6 2021-10-18 17:47:31 +03:00
Nayuta Yanagisawa
edde9084c2 MDEV-26582 SIGSEGV in spider_db_bulk_insert and spider_db_connect and spider_db_before_query, and hang in "End of update loop" / "Reset for next command" query states
Spider accesses a freed connection in ha_spider::end_bulk_insert()
and results in SIGSEGV.

The cause of the bug is that ha_spider::is_bulk_insert_exec_period()
wrongly returns TRUE when the bulk insertion has not yet started.

Spider decides whether it is during the bulk insertion or not by
the value of insert_pos, but the variable is not reset in a case,
and this result in the bug.
2021-10-18 23:18:42 +09:00
Marko Mäkelä
9c5835e067 Merge 10.5 into 10.6 2021-10-18 16:36:24 +03:00
Nayuta Yanagisawa
9068020efe MDEV-26539 SIGSEGV in spider_check_and_set_trx_isolation and I_P_List_iterator from THD::drop_temporary_table (10.5.3 opt only) on ALTER
The server crashes if ALTER TABLE, which accesses physical data
placed at data nodes, is performed on a Spider table.

The cause of the bug is that spider_check_trx_and_get_conn() does
not allocate connections if sql_command == SQLCOM_ALTER_TABLE.
Some ALTER TABLE statements, like ALTER TABLE ... CHECK PARTITION,
access data nodes. So, we need to allocate a new connection before
performing ALTER TABLEs.
2021-10-18 13:23:48 +09:00
Nayuta Yanagisawa
39f6315612 MDEV-19866 follow-up
Cherry-picking the fix for MDEV-19866 changes the behavior of
the Spider slightly. So, I modified a existing test to match
the new behavior.
2021-10-18 13:19:03 +09:00
Kentoku SHIBA
a46665090b MDEV-19866 With a Spider table, a SELECT with WHERE involving primary key breaks following SELECTs (#1356)
Change checking scanning partitions from part_spec to part_info->read_partitions
2021-10-18 13:19:03 +09:00
Marko Mäkelä
d95361107c Merge 10.5 into 10.6 2021-09-24 14:38:52 +03:00
Marko Mäkelä
7e2b42324c Merge 10.4 into 10.5 2021-09-24 08:42:23 +03:00
Marko Mäkelä
9024498e88 Merge 10.3 into 10.4 2021-09-22 18:26:54 +03:00
Daniel Ye
9fc1ef932f
MDEV-26545 Spider does not correctly handle UDF and stored function in where conds
- Handle stored function conditions correctly, with the same logic as with UDFs.
- When running queries on Spider SE, by default, we do not push down WHERE conditions containing usage of UDFs/stored functions to remote data nodes, unless the user demands (by setting spider_use_pushdown_udf).
- Disable direct update/delete when a udf condition is skipped.
2021-09-22 18:55:05 +09:00
Daniel Ye
ac1c6738f9
MDEV-26545 Spider does not correctly handle UDF and stored function in where conds
- Handle stored function conditions correctly, with the same logic as with UDFs.
- When running queries on Spider SE, by default, we do not push down WHERE conditions containing usage of UDFs/stored functions to remote data nodes, unless the user demands (by setting spider_use_pushdown_udf).
2021-09-22 18:54:22 +09:00
Marko Mäkelä
7730dd392b Merge 10.5 into 10.6 2021-09-06 10:31:32 +03:00
Nayuta Yanagisawa
1fda0544b9 MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table created
The server crashed when SPIDER_DIRECT_SQL UDF was called with
non-existing temporary table.

The bug has been introduced by 91ffdc8. The commit removed
the check, from THD::open_temporary_table(), which ensure that
the target temporary tables exist.

We can fix the bug by adding the check before the call of
THD::open_temporary_table().
2021-09-06 05:00:22 +00:00
Vladislav Vaintroub
ae85835cc7 Fix warnings from -DPLUGIN_PARTITION=NO, portably.
Also fix Spider's cmake.
2021-09-05 20:00:13 +02:00
Marko Mäkelä
f3fcf5f45c Merge 10.5 to 10.6 2021-08-19 12:25:00 +03:00
Marko Mäkelä
4a25957274 Merge 10.4 into 10.5 2021-08-18 18:22:35 +03:00
Marko Mäkelä
f84e28c119 Merge 10.3 into 10.4 2021-08-18 16:51:52 +03:00
Yongxin Xu
fa6eaead21
MDEV-24523 Execution of JSON_REPLACE failed on Spider
JSON_REPLACE() function executed with an error on Spider SE.
This patch fixes the problem, and it also fixes the MDEV-24541.

The problem is that Item_func_json_insert::func_name() returns
the wrong function name "json_update". 
The Spider SE reconstructs a query based on the return value
in some cases. Thus, if the return value is wrong, the Spider SE
may generate a wrong query.
2021-08-05 12:21:59 +09:00
Oleksandr Byelkin
6efb5e9f5e Merge branch '10.5' into 10.6 2021-08-02 10:11:41 +02:00
Oleksandr Byelkin
ae6bdc6769 Merge branch '10.4' into 10.5 2021-07-31 23:19:51 +02:00
Oleksandr Byelkin
7841a7eb09 Merge branch '10.3' into 10.4 2021-07-31 22:59:58 +02:00
Yongxin Xu
43099af95b
MDEV-24020: Trim with remove_str Fails on Spider
This patch fixes the bug that TRIM(BOTH ... FROM $str), TRIM(LEADING ... FROM $str),
and TRIM(TRAILING ... FROM $str) failed with errors when executing on Spider.
2021-07-29 00:19:36 +09:00
Sergei Golubchik
389f5cf76f disable spider/bugfix.wait_timeout 2021-07-26 12:38:52 +00:00
Nayuta Yanagisawa
f52d39369a MDEV-24517 follow-up: Fix for test with --ps-protocol
Tests for the Spider storage engine often use the following idiom:

--let $command=CREATE TABLE t1 (...);CREATE TABLE t2 (...); ...
--eval $command

However, the idiom seems to work in the normal protocol, but fails
in the prepared statement (ps) protocol.
As testing CREATE TABLE statements in the ps protocol, we wrap the
idiom by --disable_ps_protocol and --enable_ps_protocol.
2021-07-25 18:01:09 +00:00
Sergei Golubchik
8d3d802c54 fix spider/bugfix.delete_with_float_column_mysql --ps
as always, multi-commands don't work in --ps
2021-07-25 19:24:11 +02:00
Yongxin Xu
73d32cc100
MDEV-24517: JSON_EXTRACT as conditions triggers syntax error on Spider (#1839)
The `item_func::JSON_EXTRACT_FUNC` was not handled correctly in the previous
versions on the Spider storage engine, which makes queries like
`SELECT * FROM t1 WHERE json_extract(jdoc, '$.Age')=20`
failed with syntax error.

This patch writes specific code to handle JSON_EXTRACT in the Spider Storage
Engine and fix that bug.
2021-07-23 23:36:27 +09:00
Nayuta Yanagisawa
aafb888657 MDEV-26013 distinct not work properly in some cases for spider tables
The bug is caused by the following reasons:

* spider_group_by_handler::init_scan() generates a query for a data node.
* The function adds DISTINCT if and only if
  spider_group_by_handler::query::distinct is TRUE.
* spider_group_by_handler::query::distinct is set to the value of
  JOIN::select_distinct in JOIN::make_aggr_tables_info().
* In the test case, DISTINCT is not added because JOIN::select_distinct
  is FALSE at the call of JOIN::make_aggr_tables_info().

Why JOIN::select_distinct is set to FALSE? That is because the function
JOIN::optimize_stage2() convert DISTINCT into GROUP BY and then optimizes
away GROUP BY.
2021-07-22 10:05:46 +00:00
Sergei Golubchik
6190a02f35 Merge branch '10.2' into 10.3 2021-07-21 20:11:07 +02:00
Marko Mäkelä
eb9a28478f Merge 10.5 into 10.6 2021-07-20 10:54:17 +03:00
Marko Mäkelä
b4ec3313f6 Merge 10.4 into 10.5 2021-07-20 09:32:11 +03:00
Nayuta Yanagisawa
cf6d83e7d6 MDEV-24760 SELECT..CASE statement syntax error at Spider Engine table
The root cause of the bug is in `spider_db_mbase_util::open_item_func()`.
The function handles an instance of the `Item_func` class based on its
`Item_func::Functype`.
The `Functype` of `CASE WHEN ... THEN` is `CASE_SEARCHED_FUNC`.
However, the Spider SE doesn't recognize this `Functype` because
`CASE_SEARCHED_FUNC` is newly added by 4de0d92. This results in the wrong
handling of `CASE WHEN ... THEN`.

The above also applies to `CASE_SIMPLE_FUNC`.
2021-07-19 15:16:25 +00:00
Nayuta Yanagisawa
0f6e170c34 MDEV-25985 Spider handle ">=" as ">" in some cases
The function spider_db_append_key_where_internal() converts
HA_READ_AFTER_KEY to '>'. The conversion seems to be correct for
single-column indexes because HA_READ_AFTER_KEY means "read the
key after the provided value."

However, how about multi-column indexes? Assume that there is a
multi-column index on c1 and c2 and we search with the condition
'c1 >= 100 AND c2 > 200'. The key_range.flag corresponds to the
search condition could be HA_READ_AFTER_KEY. In such a case,
we could not simply convert HA_READ_AFTER_KEY to '>'.

The correct conversion is to convert HA_READ_AFTER_KEY to '>'
only for the last column in key_part_map and to convert
HA_READ_AFTER_KEY to '>=' for the other column.

The similar discussion also applies to the conversion from
key_range.flag to a sign of inequality.
2021-07-14 12:08:37 +00:00
Nayuta Yanagisawa
e3814a74ee MDEV-26139 Spider crashes with segmentation fault (signal 11) on CREATE TABLE when COMMENT does not contain embedded double quotes
The root cause of the bug MDEV-26139 is the lack of NULL checking
on the variable `dq`.

Comments on if (dq && (!sq || sq > dq)) {...} else {...}:

  * The if block corresponds to the case where parameters are
    quoted by double quotes. In that case, a single quote doesn't
    appear at all or only appears in the middle of double quotes.

  * The else block corresponds to the case where parameters are
    quoted by single quotes. In that case, a double quote doesn't
    appear at all or only appears in the middle of single quotes.

  * If the program reaches the if-else statement, `sq || dq` holds.
    Thus, the negation of `dq && (!sq || sq > dq)` is equivalent to
    `sq && (!dq || sq <= dq)`.
2021-07-14 11:32:21 +00:00
Sergei Golubchik
6fab256bc8 disable spider/bugfix.wait_timeout 2021-06-30 09:34:26 +02:00
Sergei Golubchik
fa5c314377 fix spider tests for --ps in 10.6
see also c3a1ba0fd9, 068246c006, 690ae1de45
2021-06-30 09:34:26 +02:00
Marko Mäkelä
4dfec8b230 Merge 10.5 into 10.6 2021-06-21 17:49:33 +03:00
Marko Mäkelä
a42c80bd48 Merge 10.4 into 10.5 2021-06-21 14:22:22 +03:00
Marko Mäkelä
d3e4fae797 Merge 10.3 into 10.4 2021-06-21 12:38:25 +03:00
Sergei Golubchik
c3a1ba0fd9 fix spider tests for --ps in 10.5
see also 068246c006 and 690ae1de45
2021-06-19 14:06:11 +02:00
Sergei Golubchik
690ae1de45 fix spider tests for --ps in 10.4
see also 068246c006
2021-06-19 13:46:11 +02:00
Sergei Golubchik
a4f485917e spider tests aren't big in 10.4
see also a5f6eca50d
2021-06-19 13:46:11 +02:00
Sergei Golubchik
068246c006 fix spider tests for --ps
spider tests use

--let $var= many;sql;statements
--eval $var

and this doesn't work in ps
2021-06-19 00:45:49 +02:00
Sergei Golubchik
a5f6eca50d spider tests aren't big
and *never* disable tests in suite.pm based on $::opt_big_test,
this will make the test skipped both as too big (for ./mtr)
and as too small (for ./mtr --big --big).
2021-06-19 00:22:15 +02:00
Vladislav Vaintroub
3d6eb7afcf MDEV-25602 get rid of __WIN__ in favor of standard _WIN32
This fixed the MySQL bug# 20338 about misuse of double underscore
prefix __WIN__, which was old MySQL's idea of identifying Windows
Replace it by _WIN32 standard symbol for targeting Windows OS
(both 32 and 64 bit)

Not that connect storage engine is not fixed in this patch (must be
fixed in "upstream" branch)
2021-06-06 13:21:03 +02:00
Monty
cf9e4c8b16 Fixed result set change in spider/bugfix/r/slave_trx_isolation.result 2021-05-24 21:04:40 +03:00
Rucha Deodhar
4e19539c14 MDEV-22189: Change error messages inside code to have mariadb instead of
mysql

Fix: Changed error messages, rerecorded results and changed other relevant
files.
2021-05-24 11:38:13 +05:30
Monty
a206658b98 Change CHARSET_INFO character set and collaction names to LEX_CSTRING
This change removed 68 explict strlen() calls from the code.

The following renames was done to ensure we don't use the old names
when merging code from earlier releases, as using the new variables
for print function could result in crashes:
- charset->csname renamed to charset->cs_name
- charset->name renamed to charset->coll_name

Almost everything where mechanical changes except:
- Changed to use the new Protocol::store(LEX_CSTRING..) when possible
- Changed to use field->store(LEX_CSTRING*, CHARSET_INFO*) when possible
- Changed to use String->append(LEX_CSTRING&) when possible

Other things:
- There where compiler issues with ensuring that all character set names
  points to the same string: gcc doesn't allow one to use integer constants
  when defining global structures (constant char * pointers works fine).
  To get around this, I declared defines for each character set name
  length.
2021-05-19 22:54:07 +02:00
Monty
b6ff139aa3 Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
  uses 'const char *' without a length:
  - String::append(const char*)
  - Binary_string(const char *str)
  - String(const char *str, CHARSET_INFO *cs)
  - append_for_single_quote(const char *)
  All usage of append(const char*) is changed to either use
  String::append(char), String::append(const char*, size_t length) or
  String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
  String::append()
- Added overflow argument to escape_string_for_mysql() and
  escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
  This was needed as most usage of the above functions never tested the
  result for -1 and would have given wrong results or crashes in case
  of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
  Changed all Item_func::func_name()'s to func_name_cstring()'s.
  The old Item_func_or_sum::func_name() is now an inline function that
  returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
  LEX_CSTRING.
- Changed for some functions the name argument from const char * to
  to const LEX_CSTRING &:
  - Item::Item_func_fix_attributes()
  - Item::check_type_...()
  - Type_std_attributes::agg_item_collations()
  - Type_std_attributes::agg_item_set_converter()
  - Type_std_attributes::agg_arg_charsets...()
  - Type_handler_hybrid_field_type::aggregate_for_result()
  - Type_handler_geometry::check_type_geom_or_binary()
  - Type_handler::Item_func_or_sum_illegal_param()
  - Predicant_to_list_comparator::add_value_skip_null()
  - Predicant_to_list_comparator::add_value()
  - cmp_item_row::prepare_comparators()
  - cmp_item_row::aggregate_row_elements_for_comparison()
  - Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
  could be simplified to not use String_space(), thanks to the fixed
  my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
  - NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
  clarify what the function really does.
- Rename of protocol function:
  bool store(const char *from, CHARSET_INFO *cs) to
  bool store_string_or_null(const char *from, CHARSET_INFO *cs).
  This was done to both clarify the difference between this 'store' function
  and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.

Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
  in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
  append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
  inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
  case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2021-05-19 22:27:48 +02:00
Michael Widenius
3105c9e7a5 Change bitfields in Item to an uint16
The reason for the change is that neither clang or gcc can do efficient
code when several bit fields are change at the same time or when copying
one or more bits between identical bit fields.
Updated bits explicitely with & and | is MUCH more efficient than what
current compilers can do.
2021-05-19 22:27:28 +02:00
Michael Widenius
451c4ae548 Renamed 'flags' variables in Item_class
This is a preparation for adding a flags variable to Item class
2021-05-19 22:27:28 +02:00
Michael Widenius
189d03dac5 Revert MDEV-14517 Cleanup for Item::with_subselect
Added back variable 'with_subquery' to Item class as a bit field.

This made the code shorter, faster (removed some virtual methods,
less code to create an initialized item etc) and made many Item's 7 bytes
smaller.

This is the last set of my patches the decreases the size of Item.

Some examples from gdb:
sizeof(Item):        144 -> 120
sizeof(Item_func)    208 -> 184
sizeof(Item_sum_max) 368 -> 344
2021-05-19 22:27:28 +02:00
Rucha Deodhar
2fdb556e04 MDEV-8334: Rename utf8 to utf8mb3
This patch changes the main name of 3 byte character set from utf8 to
utf8mb3. New old_mode UTF8_IS_UTF8MB3 is added and set TRUE by default,
so that utf8 would mean utf8mb3. If not set, utf8 would mean utf8mb4.
2021-05-19 06:48:36 +02:00
Kentoku SHIBA
982290fe9b Fix the following valgrind error on Spider
==22532== Conditional jump or move depends on uninitialised value(s)
==22532==    at 0x9EEDFA: String::append(char const*, unsigned long, charset_info_st const*) (sql_string.cc:587)
==22532==    by 0x17C12BA7: spider_string::append(char const*, unsigned int, charset_info_st const*) (spd_malloc.cc:913)
==22532==    by 0x17C68BD0: spider_db_mysql_util::append_column_value(ha_spider*, spider_string*, Field*, unsigned char const*, charset_info_st const*) (spd_db_mysql.cc:4573)
==22532==    by 0x17B7D298: spider_db_append_key_where_internal(spider_string*, spider_string*, spider_string*, st_key_range const*, st_key_range const*, ha_spider*, bool, unsigned long, unsigned int) (spd_db_conn.cc:1978)
==22532==    by 0x17C81A7C: spider_mbase_handler::append_key_where(spider_string*, spider_string*, spider_string*, st_key_range const*, st_key_range const*, unsigned long, bool) (spd_db_mysql.cc:11146)
==22532==    by 0x17C819B7: spider_mbase_handler::append_key_where_part(st_key_range const*, st_key_range const*, unsigned long) (spd_db_mysql.cc:11130)
==22532==    by 0x17C4B0F0: ha_spider::append_key_where_sql_part(st_key_range const*, st_key_range const*, unsigned long) (ha_spider.cc:15012)
==22532==    by 0x17B7FC8F: spider_db_append_key_where(st_key_range const*, st_key_range const*, ha_spider*) (spd_db_conn.cc:2707)
==22532==    by 0x17C28DF6: ha_spider::multi_range_read_next_first(void**) (ha_spider.cc:4559)
==22532==    by 0x17C2E0F5: ha_spider::multi_range_read_next(void**) (ha_spider.cc:5879)
==22532==    by 0xE27019: QUICK_RANGE_SELECT::get_next() (opt_range.cc:12647)

Conflicts:
	storage/spider/spd_malloc.cc
2021-05-13 02:37:33 +09:00
Marko Mäkelä
1e1073b810 Merge 10.5 into 10.6 2021-05-04 07:37:38 +03:00
Marko Mäkelä
c6846757ac Merge 10.4 into 10.5 2021-05-03 14:34:48 +03:00
Kentoku SHIBA
42cdc37ff9 MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions.
Fix length for getting default table name.
2021-04-30 19:18:27 +09:00
Kentoku SHIBA
cec8ea3ab5 MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions.
Fix length for getting default table name.
2021-04-29 18:46:49 +09:00
Kentoku SHIBA
b3d963fee4 MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions.
Fix length for getting default table name.
2021-04-28 16:27:15 +09:00
Alexey Botchkov
5bc12ca9c2 MDEV-22265 Connect string character limit too small for full 64 character InnoDB table-name limit when using ad-hoc Spider server definitions.
The name of the table sent as an argument to the handler::init() has the
database name in front of it. So we should use
table_share->table_name.length.
2021-04-27 11:12:47 +04:00
Vicențiu Ciorbaru
13cf8f5e9a cleanup: Refactor select_limit in select lex
Replace
  * select_lex::offset_limit
  * select_lex::select_limit
  * select_lex::explicit_limit
with select_lex::Lex_select_limit

The Lex_select_limit already existed with the same elements and was used in
by the yacc parser.

This commit is in preparation for FETCH FIRST implementation, as it
simplifies a lot of the code.

Additionally, the parser is simplified by making use of the stack to
return Lex_select_limit objects.

Cleanup of init_query() too. Removes explicit_limit= 0 as it's done a bit later
in init_select() with limit_params.empty()
2021-04-21 14:08:58 +03:00
Marko Mäkelä
4930f9c94b Merge 10.5 into 10.6 2021-04-21 11:45:00 +03:00
Monty
0620ccf3ea Fixed failing test spider/bugfix.mdev_22246
This was caused by MDEV-23634, which disabled index optimization for
index != constant.
2021-04-19 14:31:57 +03:00
Varun Gupta
f691d9865b MDEV-7317: Make an index ignorable to the optimizer
This feature adds the functionality of ignorability for indexes.
Indexes are not ignored be default.

To control index ignorability explicitly for a new index,
use IGNORE or NOT IGNORE as part of the index definition for
CREATE TABLE, CREATE INDEX, or ALTER TABLE.

Primary keys (explicit or implicit) cannot be made ignorable.

The table INFORMATION_SCHEMA.STATISTICS get a new column named IGNORED that
would store whether an index needs to be ignored or not.
2021-03-04 22:50:00 +05:30
Marko Mäkelä
94b4578704 Merge 10.5 into 10.6 2021-02-17 19:39:05 +02:00
Sergei Golubchik
25d9d2e37f Merge branch 'bb-10.4-release' into bb-10.5-release 2021-02-15 16:43:15 +01:00
Sergei Golubchik
00a313ecf3 Merge branch 'bb-10.3-release' into bb-10.4-release
Note, the fix for "MDEV-23328 Server hang due to Galera lock conflict resolution"
was null-merged. 10.4 version of the fix is coming up separately
2021-02-12 17:44:22 +01:00
Nikita Malyavin
21809f9a45 MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.

This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
 bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
 sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
 directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.

The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.

To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
 orig_*, all_set bitmaps are never substituted already.

This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
 to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
 MY_BITMAP* instead of my_bitmap_map*

These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2021-01-27 00:50:55 +10:00
Kentoku SHIBA
de5e5ab210 MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
Add test cases.
2021-01-12 10:25:03 +01:00
Kentoku SHIBA
69c86abb64 MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
When executing a query like "select id, 0 as const, val from ...", there are 3 columns(items) in Query->select at handlerton->create_group_by(). After that, MariaDB makes a temporary table with 2 columns. The skipped items are const item, so fixing Spider to skip const items for items at Query->select.
2021-01-12 10:25:03 +01:00
Nikita Malyavin
e25623e78a MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.

This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
 bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
 sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
 directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.

The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.

To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
 orig_*, all_set bitmaps are never substituted already.

This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
 to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
 MY_BITMAP* instead of my_bitmap_map*

These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2021-01-08 16:04:29 +10:00
Kentoku SHIBA
2f6970ef1c MDEV-24424 Unnecessary usage of to_float() for INSERT into the Spider table with float column
Change default wrapper from mysql to mariadb.
2020-12-22 08:02:08 +09:00
Marko Mäkelä
09a1f0075a Merge 10.5 into 10.6 2020-11-02 12:49:19 +02:00
Sergei Golubchik
05bd281697 SPIDER storage engine plugin -> Stable 2020-10-29 10:03:15 +01:00
Kentoku SHIBA
e6f95b23f4 MDEV-20100 MariaDB 13.3.9 Crash "[ERROR] mysqld got signal 11 ;"
Some functions on ha_partition call functions on all partitions, but handler->reset() is only called that pruned by m_partitions_to_reset. So Spider didn't clear pointer on unpruned partitions, if the unpruned partitions are used by next query, Spider reference the pointer that is already freed.
2020-10-22 05:29:03 +09:00
Kentoku SHIBA
b30ad01d40 MDEV-20100 MariaDB 13.3.9 Crash "[ERROR] mysqld got signal 11 ;"
Some functions on ha_partition call functions on all partitions, but handler->reset() is only called that pruned by m_partitions_to_reset. So Spider didn't clear pointer on unpruned partitions, if the unpruned partitions are used by next query, Spider reference the pointer that is already freed.
2020-10-22 05:25:53 +09:00
Kentoku SHIBA
ac8d205795 MDEV-20100 MariaDB 13.3.9 Crash "[ERROR] mysqld got signal 11 ;"
Some functions on ha_partition call functions on all partitions, but handler->reset() is only called that pruned by m_partitions_to_reset. So Spider didn't clear pointer on unpruned partitions, if the unpruned partitions are used by next query, Spider reference the pointer that is already freed.
2020-10-22 05:21:35 +09:00
Kentoku SHIBA
88d22f0e65 MDEV-20100 MariaDB 13.3.9 Crash "[ERROR] mysqld got signal 11 ;"
Some functions on ha_partition call functions on all partitions, but handler->reset() is only called that pruned by m_partitions_to_reset. So Spider didn't clear pointer on unpruned partitions, if the unpruned partitions are used by next query, Spider reference the pointer that is already freed.
2020-10-20 22:32:12 +09:00
Kentoku SHIBA
9dedba16ab MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to unlock mutex conn->mta_conn_mutex that wasn't locked at storage/spider/spd_db_conn.cc, line 671 2020-09-07 10:18:43 +09:00
Kentoku SHIBA
e976f461d8 MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to unlock mutex conn->mta_conn_mutex that wasn't locked at storage/spider/spd_db_conn.cc, line 671 2020-09-07 10:09:44 +09:00
Kentoku SHIBA
9b68847127 MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to unlock mutex conn->mta_conn_mutex that wasn't locked at storage/spider/spd_db_conn.cc, line 671 2020-09-07 10:07:55 +09:00
Kentoku SHIBA
2cc9e45693 MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to unlock mutex conn->mta_conn_mutex that wasn't locked at storage/spider/spd_db_conn.cc, line 671 2020-09-07 09:56:52 +09:00
Kentoku SHIBA
46fab5b32a MDEV-7098 spider/bg.spider_fixes failed in buildbot with safe_mutex: Trying to unlock mutex conn->mta_conn_mutex that wasn't locked at storage/spider/spd_db_conn.cc, line 671 2020-09-07 09:54:09 +09:00
Kentoku SHIBA
05aa7ae7ba Fix a compiler warning 2020-08-26 22:26:51 +09:00
Kentoku SHIBA
72f0f0db9c Fix a compiler warning 2020-08-26 22:25:26 +09:00
Kentoku SHIBA
8f8f2aea93 MDEV-23561 Spider doesn't work with ps protocol 2020-08-26 06:54:00 +09:00
Kentoku SHIBA
e1a9b7ca7b Fix indents of Spider 2020-08-26 06:53:48 +09:00
Kentoku SHIBA
75b7aef2c0 MDEV-23561 Spider doesn't work with ps protocol 2020-08-26 06:52:33 +09:00
Kentoku SHIBA
2b113185c0 Fix indents of Spider 2020-08-26 06:52:20 +09:00
Kentoku SHIBA
2000d05c2e MDEV-22246 Result rows duplicated by spider engine
fix the following type mrr scan
(select 0,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`)union all(select 1,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`) order by `id`
2020-08-24 06:12:15 +09:00
Kentoku SHIBA
65ee216c35 MDEV-22246 Result rows duplicated by spider engine
fix the following type mrr scan
(select 0,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`)union all(select 1,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`) order by `id`
2020-08-24 06:11:01 +09:00
Kentoku SHIBA
1a09081d19 MDEV-22246 Result rows duplicated by spider engine
fix the following type mrr scan
(select 0,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`)union all(select 1,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`) order by `id`
2020-08-24 06:09:40 +09:00
Kentoku SHIBA
5c8a1249dd MDEV-20827 Wrong param parsing in spider_direct_sql() when param contain comma 2020-08-17 21:04:02 +09:00
Kentoku SHIBA
314a90e12b MDEV-20827 Wrong param parsing in spider_direct_sql() when param contain comma 2020-08-17 21:02:09 +09:00
Kentoku SHIBA
07d57e0e1d MDEV-20827 Wrong param parsing in spider_direct_sql() when param contain comma 2020-08-17 20:56:29 +09:00
Kentoku SHIBA
303212d4b6 MDEV-19794 Spider crash with XA 2020-08-14 01:54:24 +09:00
Kentoku SHIBA
ad1a3ce418 MDEV-19794 Spider crash with XA 2020-08-14 01:47:48 +09:00
Kentoku SHIBA
582290dacd MDEV-19794 Spider crash with XA 2020-08-14 01:39:17 +09:00
Marko Mäkelä
0e34bb3e97 Merge 10.5 into 10.6 2020-08-12 14:39:53 +03:00
Kentoku SHIBA
1ddff751eb MENT-807 Crash with CREATE TEMPORARY TABLE .. ENGINE=SPIDER .. wrapper "odbc" 2020-08-11 23:01:58 +09:00
Kentoku SHIBA
09be96ff08 [Spider] Add add checking default_value for default_file, host, port 2020-08-07 03:21:56 +09:00
Kentoku SHIBA
5585c9f984 add a table parameter "driver" to Spider 2020-08-07 03:21:42 +09:00
Kentoku SHIBA
0dffe33c93 add a table parameter "filedsn" to Spider 2020-08-07 03:21:27 +09:00
Michael Widenius
58e759a939 Added 'final' to some classes to improve generated code
Final added to:
- All reasonable classes inhereted from Field
- All classes inhereted from Protocol
- Almost all Handler classes
- Some important Item classes

The stripped size of mariadbd is just 4K smaller, but several object files
showed notable improvements in common execution paths.
- Checked field.o and item_sum.o

Other things:
- Added 'override' to a few class functions touched by this patch.
- Removed 'virtual' from a new class functions that had/got 'override'
- Changed Protocol_discard to inherit from Protocol instad of Protocol_text
2020-08-04 17:27:32 +02:00
Marko Mäkelä
9a7948e3f6 Merge 10.5 into 10.6 2020-08-04 07:55:16 +03:00
Otto Kekäläinen
842da858b6 Unify config syntax in default files
- Include a link to the relevant KB article for more info
- Use spaced around the equal sign for better readability and so that
  the examples are more aligned with the general style in the KB
- Load plugins with just the base name, the .so is optional and excess
2020-08-01 10:31:41 +10:00
Monty
61c15ebe32 Remove String::lex_string() and String::lex_cstring()
- Better to use 'String *' directly.
- Added String::get_value(LEX_STRING*) for the few cases where we want to
  convert a String to LEX_CSTRING.

Other things:
- Use StringBuffer for some functions to avoid mallocs
2020-07-23 10:54:32 +03:00
Kentoku SHIBA
d2ca5e4811 change version for spider_rewrite to 10.7 2020-07-15 20:30:00 +09:00
Vladislav Vaintroub
b0d2a59d9a MDEV-21612 - remove COM_MULTI from server and C/C
The COM_MULTI did not take off. No connector is using it.
Remove related code from server, and client.
If anything it is a step simplification of already-bloated
dispatch_command(), and related code.
2020-07-14 11:16:24 +02:00
Sergei Golubchik
6c52931680 replace HTON_AUTOMATIC_DELETE_TABLE with return -1 from drop_table() 2020-07-04 01:44:47 +02:00
Kentoku SHIBA
c032c2ef66 MDEV-18993 The keep-alive connection (set spider_conn_recycle_mode = 1) in spider would cause cash in MariaDB (#1269)
Fix the following valgrind error.

==94390== Thread 29:
==94390== Invalid read of size 8
==94390== at 0x78389D: thd_increment_bytes_sent (sql_class.cc:4265)
==94390== by 0xC8EC46: net_real_write (net_serv.cc:730)
==94390== by 0xC8E0C8: net_flush (net_serv.cc:383)
==94390== by 0xC8E4D0: net_write_command (net_serv.cc:521)
==94390== by 0xADCE61: cli_advanced_command (client.c:468)
==94390== by 0xAE3CAF: mysql_close_slow_part (client.c:3671)
==94390== by 0xAE3D28: mysql_close (client.c:3683)
==94390== by 0x149E69A8: spider_db_mbase::disconnect() (spd_db_mysql.cc:2217)
==94390== by 0x1491EA26: spider_db_disconnect(st_spider_conn*) (spd_db_conn.cc:297)
==94390== by 0x14948EBE: spider_free_conn_alloc(st_spider_conn*) (spd_conn.cc:196)
==94390== by 0x1494B26A: spider_free_conn(st_spider_conn*) (spd_conn.cc:1251)
==94390== by 0x1494941F: spider_free_conn_from_trx(st_spider_transaction*, st_spider_conn*, bool, bool, int*) (spd_conn.cc:315)
==94390== Address 0x1f0e0990 is 4,832 bytes inside a block of size 25,728 free'd
==94390== at 0x4C2ACBD: free (vg_replace_malloc.c:530)
==94390== by 0x13F5545: my_free (my_malloc.c:222)
==94390== by 0x6C75B7: ilink::operator delete(void*, unsigned long) (sql_list.h:618)
==94390== by 0x77B9F6: THD::~THD() (sql_class.cc:1724)
==94390== by 0x1494FCE0: spider_bg_conn_action(void*) (spd_conn.cc:2580)
==94390== by 0x4E3DDD4: start_thread (in /usr/lib64/libpthread-2.17.so)
==94390== by 0x5FBFEAC: clone (in /usr/lib64/libc-2.17.so)
==94390== Block was alloc'd at
==94390== at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==94390== by 0x13F4DFA: my_malloc (my_malloc.c:101)
==94390== by 0x1491CF06: ilink::operator new(unsigned long) (sql_list.h:614)
==94390== by 0x1494F7FD: spider_bg_conn_action(void*) (spd_conn.cc:2501)
==94390== by 0x4E3DDD4: start_thread (in /usr/lib64/libpthread-2.17.so)
==94390== by 0x5FBFEAC: clone (in /usr/lib64/libc-2.17.so)
==94390== Invalid write of size 8
==94390== at 0x7838AF: thd_increment_bytes_sent (sql_class.cc:4265)
==94390== by 0xC8EC46: net_real_write (net_serv.cc:730)
==94390== by 0xC8E0C8: net_flush (net_serv.cc:383)
==94390== by 0xC8E4D0: net_write_command (net_serv.cc:521)
==94390== by 0xADCE61: cli_advanced_command (client.c:468)
==94390== by 0xAE3CAF: mysql_close_slow_part (client.c:3671)
==94390== by 0xAE3D28: mysql_close (client.c:3683)
==94390== by 0x149E69A8: spider_db_mbase::disconnect() (spd_db_mysql.cc:2217)
==94390== by 0x1491EA26: spider_db_disconnect(st_spider_conn*) (spd_db_conn.cc:297)
==94390== by 0x14948EBE: spider_free_conn_alloc(st_spider_conn*) (spd_conn.cc:196)
==94390== by 0x1494B26A: spider_free_conn(st_spider_conn*) (spd_conn.cc:1251)
==94390== by 0x1494941F: spider_free_conn_from_trx(st_spider_transaction*, st_spider_conn*, bool, bool, int*) (spd_conn.cc:315)
==94390== Address 0x1f0e0990 is 4,832 bytes inside a block of size 25,728 free'd
==94390== at 0x4C2ACBD: free (vg_replace_malloc.c:530)
==94390== by 0x13F5545: my_free (my_malloc.c:222)
==94390== by 0x6C75B7: ilink::operator delete(void*, unsigned long) (sql_list.h:618)
==94390== by 0x77B9F6: THD::~THD() (sql_class.cc:1724)
==94390== by 0x1494FCE0: spider_bg_conn_action(void*) (spd_conn.cc:2580)
==94390== by 0x4E3DDD4: start_thread (in /usr/lib64/libpthread-2.17.so)
==94390== by 0x5FBFEAC: clone (in /usr/lib64/libc-2.17.so)
==94390== Block was alloc'd at
==94390== at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==94390== by 0x13F4DFA: my_malloc (my_malloc.c:101)
==94390== by 0x1491CF06: ilink::operator new(unsigned long) (sql_list.h:614)
==94390== by 0x1494F7FD: spider_bg_conn_action(void*) (spd_conn.cc:2501)
==94390== by 0x4E3DDD4: start_thread (in /usr/lib64/libpthread-2.17.so)
==94390== by 0x5FBFEAC: clone (in /usr/lib64/libc-2.17.so)
2020-06-27 14:42:36 +09:00
Kentoku SHIBA
71e8183e41 MDEV-22979 "mysqld --bootstrap" / mysql_install_db hangs when Spider is installed 2020-06-26 04:49:54 +09:00
Sergei Golubchik
bf2df461a2 MDEV-22967 Spider does not load in 10.5 with default settings
increase spider maturity accordingly
2020-06-21 23:49:45 +02:00
Kentoku SHIBA
bd62a636a4 fix a compiler warning on GCC 9.3.0 2020-06-14 18:40:07 +09:00
Monty
5bcb1d6532 MDEV-11412 Ensure that table is truly dropped when using DROP TABLE
The used code is largely based on code from Tencent

The problem is that in some rare cases there may be a conflict between .frm
files and the files in the storage engine. In this case the DROP TABLE
was not able to properly drop the table.

Some MariaDB/MySQL forks has solved this by adding a FORCE option to
DROP TABLE. After some discussion among MariaDB developers, we concluded
that users expects that DROP TABLE should always work, even if the
table would not be consistent. There should not be a need to use a
separate keyword to ensure that the table is really deleted.

The used solution is:
- If a .frm table doesn't exists, try dropping the table from all storage
  engines.
- If the .frm table exists but the table does not exist in the engine
  try dropping the table from all storage engines.
- Update storage engines using many table files (.CVS, MyISAM, Aria) to
  succeed with the drop even if some of the files are missing.
- Add HTON_AUTOMATIC_DELETE_TABLE to handlerton's where delete_table()
  is not needed and always succeed. This is used by ha_delete_table_force()
  to know which handlers to ignore when trying to drop a table without
  a .frm file.

The disadvantage of this solution is that a DROP TABLE on a non existing
table will be a bit slower as we have to ask all active storage engines
if they know anything about the table.

Other things:
- Added a new flag MY_IGNORE_ENOENT to my_delete() to not give an error
  if the file doesn't exist. This simplifies some of the code.
- Don't clear thd->error in ha_delete_table() if there was an active
  error. This is a bug fix.
- handler::delete_table() will not abort if first file doesn't exists.
  This is bug fix to handle the case when a drop table was aborted in
  the middle.
- Cleaned up mysql_rm_table_no_locks() to ensure that if_exists uses
  same code path as when it's not used.
- Use non_existing_Table_error() to detect if table didn't exists.
  Old code used different errors tests in different position.
- Table_triggers_list::drop_all_triggers() now drops trigger file if
  it can't be parsed instead of leaving it hanging around (bug fix)
- InnoDB doesn't anymore print error about .frm file out of sync with
  InnoDB directory if .frm file does not exists. This change was required
  to be able to try to drop an InnoDB file when .frm doesn't exists.
- Fixed bug in mi_delete_table() where the .MYD file would not be dropped
  if the .MYI file didn't exists.
- Fixed memory leak in Mroonga when deleting non existing table
- Fixed memory leak in Connect when deleting non existing table

Bugs fixed introduced by the original version of this commit:
MDEV-22826 Presence of Spider prevents tables from being force-deleted from
           other engines
2020-06-14 19:39:42 +03:00
Sergei Golubchik
07d1c8567c post-fix for #1504 2020-06-12 01:17:57 +02:00
Kentoku SHIBA
0af1b0bd21 Add information_schema.spider_wrapper_protocols for knowing available wrappers of Spider 2020-06-11 16:41:14 +09:00
Otto Kekäläinen
ba4148698f MDEV-19917: Install Spider with a simple spider.cnf
To install Spider one can simply drop a /etc/mysql/conf.d/spider.cnf like

  [mariadb]
  plugin-load-add=ha_spider.so

This is automatically generated and installed when plugin is correctly
registered to plugin.cmake with its own component name. Many other plugins
such as Connect and RocksDB install in the same way.

This solved MDEV-19917 as the mere adding and removing of spider.cnf
automatically installs and uninstalls it.

Remove the overly complex and uncecessary install.sql from Spider,
if should not be needed in modern times anymore.

With this change there is no need for a uninstall.sql either.
2020-06-10 13:24:21 +03:00
Sergei Golubchik
89a33303c4 remove dead code
reduce the amount of engine-specific code in the server,
particularly as it does not serve any purpose now.

may be needed for VP engine,
to be reconsidered in MDEV-7795
2020-06-09 14:32:43 +02:00
Kentoku SHIBA
d88870e6cc MENT-805 ODBC login fails with with Spider from bb-10.5-MENT-30 if password contains a semicolon 2020-06-05 17:30:04 +09:00
Kentoku SHIBA
b3250ab3b2 MENT-787 Server from bb-10.5-MENT-30 crashes upon Spider installation
It looks buffer over flow of spider_unique_id_buf. It requires to analyze on reproducing environment, but I extend this first.
2020-06-05 17:30:03 +09:00
Kentoku SHIBA
0b7fe26e9d Change Spider's plugin maturity to BETA 2020-06-05 17:30:03 +09:00
Kentoku SHIBA
a756d54704 Fix issue caused by using spider_bgs_mode = 2 when Spider use limit_mode = 1 internally for data nodes. 2020-06-05 17:30:03 +09:00
Kentoku SHIBA
9ba56c072c Add a parameter spider_strict_group_by for supporting ONLY_FULL_GROUP_BY 2020-06-05 17:30:02 +09:00
Kentoku SHIBA
bbb1140d47 add pointer of ha_spider to Spider's use_result function 2020-06-05 17:30:02 +09:00
Kentoku SHIBA
f16633c175 fix evaluating bitmap issue in spider 2020-06-05 17:30:02 +09:00
Kentoku SHIBA
18f32f2cd2 fix issue for escape charcters in table parameters of Spider 2020-06-05 17:30:01 +09:00
Kentoku SHIBA
793b84b817 add a table parameter "dsn" to Spider 2020-06-05 17:30:01 +09:00
Kentoku SHIBA
932baa9410 fix build errors on windows environments 2020-06-05 17:30:00 +09:00
Kentoku SHIBA
6c3180bed9 add test result of spider.bugfix insert_select 2020-06-05 17:30:00 +09:00
Kentoku SHIBA
94861b83f4 prepare for adding new connectors for Spider
Conflicts:
	storage/spider/spd_conn.cc
2020-06-05 17:30:00 +09:00
Kentoku SHIBA
23c8adda74 MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever
Add looping check

Conflicts:
	sql/table.h
2020-06-05 17:29:59 +09:00
Kentoku SHIBA
272625d92a fix Spider executing one by one commands before SQL 2020-06-05 17:29:59 +09:00
Kentoku SHIBA
c34deb4cd2 fix memory calculate for spider_mon_table_cache 2020-06-05 17:29:58 +09:00
Kentoku SHIBA
d3a6ed0550 fix divided lock table issue of Spider 2020-06-05 17:29:58 +09:00
Kentoku SHIBA
418f16116f use ifdef for unused attributes for Spider 2020-06-05 17:29:58 +09:00
Kentoku SHIBA
e954d9de88 MDEV-19002 Spider performance optimization with partition
Change the following function for batch call instead of each partition
- store_lock
- external_lock
- start_stmt
- extra
- cond_push
- info_push
- top_table
2020-06-05 17:29:57 +09:00
Kentoku
132d5822e2 MENT-458 MTR Big test "spider/bugfix.sql_mode_mariadb & myself" are both failing on Azure MTR pipeline
Support the dash number of MariaDB versions by Spider's tests
2020-06-01 12:04:34 +09:00
Kentoku
1d393fed71 MENT-456 MTR Big test "spider.show_system_tables" is failing on Azure MTR pipeline
Support the dash number of MariaDB versions by Spider's install sequence
2020-06-01 12:04:34 +09:00
Monty
4102f1589c Aria will now register it's transactions
MDEV-22531 Remove maria::implicit_commit()
MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in
           MYSQL_BIN_LOG::unlog_xa_prepare

From the handler point of view, Aria now looks like a transactional
engine. One effect of this is that we don't need to call
maria::implicit_commit() anymore.

This change also forces the server to call trans_commit_stmt() after doing
any read or writes to system tables.  This work will also make it easier
to later allow users to have system tables in other engines than Aria.

To handle the case that Aria doesn't support rollback, a new
handlerton flag, HTON_NO_ROLLBACK, was added to engines that has
transactions without rollback (for the moment only binlog and Aria).

Other things
- Moved freeing of MARIA_SHARE to a separate function as the MARIA_SHARE
  can be still part of a transaction even if the table has closed.
- Changed Aria checkpoint to use the new MARIA_SHARE free function. This
  fixes a possible memory leak when using S3 tables
- Changed testing of binlog_hton to instead test for HTON_NO_ROLLBACK
- Removed checking of has_transaction_manager() in handler.cc as we can
  assume that as the transaction was started by the engine, it does
  support transactions.
- Added new class 'start_new_trans' that can be used to start indepdendent
  sub transactions, for example while reading mysql.proc, using help or
  status tables etc.
- open_system_tables...() and open_proc_table_for_Read() doesn't anymore
  take a Open_tables_backup list. This is now handled by 'start_new_trans'.
- Split thd::has_transactions() to thd::has_transactions() and
  thd::has_transactions_and_rollback()
- Added handlerton code to free cached transactions objects.
  Needed by InnoDB.

squash! 2ed35999f2a2d84f1c786a21ade5db716b6f1bbc
2020-05-23 12:29:10 +03:00
Monty
d1d472646d Change THD->transaction to a pointer to enable multiple transactions
All changes (except one) is of type
thd->transaction.  -> thd->transaction->

thd->transaction points by default to 'thd->default_transaction'
This allows us to 'easily' have multiple active transactions for a
THD object, like when reading data from the mysql.proc table
2020-05-23 12:29:10 +03:00
Sergei Golubchik
67aaf51cf9 cleanup: ha_external_unlock() helper
as mentioned in f9f33b85be and generally to make it
easier to talk about
2020-05-05 19:41:12 +02:00
Eugene Kosov
89ff4176c1 MDEV-22437 make THR_THD* variable thread_local
Now all access goes through _current_thd() and set_current_thd()
functions.

Some functions like THD::store_globals() can not fail now.
2020-05-05 18:13:31 +03:00
Kentoku SHIBA
90aad47dd9 MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
Add test cases.
2020-05-05 22:45:17 +09:00
Kentoku SHIBA
69925c0d2e MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
Add test cases.
2020-05-05 22:43:45 +09:00
Kentoku SHIBA
498c5e2be1 MDEV-21884 MariaDB with Spider crashes on a query
Fix a test result.
2020-04-23 00:03:54 +09:00
Kentoku SHIBA
1b81e96593 MDEV-21884 MariaDB with Spider crashes on a query
Fix a test result.
2020-04-22 04:44:28 +09:00
Kentoku SHIBA
181f17c3cd MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
When executing a query like "select id, 0 as const, val from ...", there are 3 columns(items) in Query->select at handlerton->create_group_by(). After that, MariaDB makes a temporary table with 2 columns. The skipped items are const item, so fixing Spider to skip const items for items at Query->select.
2020-04-17 11:52:42 +09:00
Kentoku SHIBA
68ceb4b460 MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
When executing a query like "select id, 0 as const, val from ...", there are 3 columns(items) in Query->select at handlerton->create_group_by(). After that, MariaDB makes a temporary table with 2 columns. The skipped items are const item, so fixing Spider to skip const items for items at Query->select.
2020-04-17 11:51:14 +09:00
Kentoku SHIBA
b4dd996dc1 MDEV-21884 MariaDB with Spider crashes on a query 2020-04-17 10:32:57 +09:00
Kentoku SHIBA
00db9c6b40 MDEV-21884 MariaDB with Spider crashes on a query 2020-04-17 10:31:17 +09:00
Kentoku SHIBA
619a2ccd67 MDEV-21884 MariaDB with Spider crashes on a query 2020-04-17 01:49:46 +09:00
Vladislav Vaintroub
93efbc390d MDEV-22214 mariadbd.exe calls function mysqld.exe, and crashes
Stop linking plugins to the server executable on Windows.
Instead, extract whole server functionality into a large DLL, called
server.dll. Link both plugins, and small server "stub" exe to it.

This eliminates plugin dependency on the name of the server executable.
It also reduces the size of the packages (since tiny mysqld.exe
and mariadbd.exe are now both linked to one big DLL)

Also, simplify the functionality of exporing all symbols from selected
static libraries. Rely on WINDOWS_EXPORT_ALL_SYMBOLS, rather than old
self-backed solution.

fix compile error

replace GetProcAddress(GetModuleHandle(NULL), "variable_name")
for server exported data with actual variable names.

Runtime loading was never required,was error prone
, since symbols could be missing at runtime, and now it actually failed,
because we do not export symbols from executable anymore, but from a shared
library

This did require a MYSQL_PLUGIN_IMPORT decoration for the plugin,
but made the code more straightforward, and avoids missing symbols at
runtime (as mentioned before).

The audit plugin is still doing some dynamic loading, as it aims to work
cross-version. Now it won't work cross-version on Windows, as it already
uses some symbols that are *not* dynamically loaded, e.g fn_format
and those symbols now exported from server.dll , when earlier they were
exported by mysqld.exe

Windows, fixes for storage engine plugin loading
after various rebranding stuff

Create server.dll containing functionality of the whole server
make mariadbd.exe/mysqld.exe a stub that is only  calling mysqld_main()

fix build
2020-04-10 19:05:26 +02:00
Marko Mäkelä
37c14690fc Merge 10.4 into 10.5 2020-03-30 19:07:25 +03:00
Marko Mäkelä
e2f1f88fa6 Merge 10.3 into 10.4 2020-03-30 14:50:23 +03:00
Marko Mäkelä
67f2782413 Fix GCC -Wstringop-truncation 2020-03-30 12:16:07 +03:00
Monty
eb483c5181 Updated optimizer costs in multi_range_read_info_const() and sql_select.cc
- multi_range_read_info_const now uses the new records_in_range interface
- Added handler::avg_io_cost()
- Don't calculate avg_io_cost() in get_sweep_read_cost if avg_io_cost is
  not 1.0.  In this case we trust the avg_io_cost() from the handler.
- Changed test_quick_select to use TIME_FOR_COMPARE instead of
  TIME_FOR_COMPARE_IDX to align this with the rest of the code.
- Fixed bug when using test_if_cheaper_ordering where we didn't use
  keyread if index was changed
- Fixed a bug where we didn't use index only read when using order-by-index
- Added keyread_time() to HEAP.
  The default keyread_time() was optimized for blocks and not suitable for
  HEAP. The effect was the HEAP prefered table scans over ranges for btree
  indexes.
- Fixed get_sweep_read_cost() for HEAP tables
- Ensure that range and ref have same cost for simple ranges
  Added a small cost (MULTI_RANGE_READ_SETUP_COST) to ranges to ensure
  we favior ref for range for simple queries.
- Fixed that matching_candidates_in_table() uses same number of records
  as the rest of the optimizer
- Added avg_io_cost() to JT_EQ_REF cost. This helps calculate the cost for
  HEAP and temporary tables better. A few tests changed because of this.
- heap::read_time() and heap::keyread_time() adjusted to not add +1.
  This was to ensure that handler::keyread_time() doesn't give
  higher cost for heap tables than for normal tables. One effect of
  this is that heap and derived tables stored in heap will prefer
  key access as this is now regarded as cheap.
- Changed cost for index read in sql_select.cc to match
  multi_range_read_info_const(). All index cost calculation is now
  done trough one function.
- 'ref' will now use quick_cost for keys if it exists. This is done
  so that for '=' ranges, 'ref' is prefered over 'range'.
- scan_time() now takes avg_io_costs() into account
- get_delayed_table_estimates() uses block_size and avg_io_cost()
- Removed default argument to test_if_order_by_key(); simplifies code
2020-03-27 03:58:32 +02:00
Monty
f36ca142f7 Added page_range to records_in_range() to improve range statistics
Prototype change:
-  virtual ha_rows records_in_range(uint inx, key_range *min_key,
-                                   key_range *max_key)
+  virtual ha_rows records_in_range(uint inx, const key_range *min_key,
+                                   const key_range *max_key,
+                                   page_range *res)

The handler can ignore the page_range parameter. In the case the handler
updates the parameter, the optimizer can deduce the following:
- If previous range's last key is on the same block as next range's first
  key
- If the current key range is in one block
- We can also assume that the first and last block read are cached!
  This can be used for a better calculation of IO seeks when we
  estimate the cost of a range index scan.

The parameter is fully implemented for MyISAM, Aria and InnoDB.
A separate patch will update handler::multi_range_read_info_const() to
take the benefits of this change and also remove the double
records_in_range() calls that are not anymore needed.
2020-03-27 03:54:45 +02:00
Kentoku SHIBA
497a4169df change from to for adding defaults-file in Spider tests 2020-03-25 22:46:01 +09:00
Kentoku SHIBA
12d59fabe2 change from to for adding defaults-file in Spider tests 2020-03-25 22:40:14 +09:00
Marko Mäkelä
5f5c63e0fe Merge 10.4 into 10.5 2020-03-24 09:54:08 +02:00
Marko Mäkelä
efc97eff31 Fix clang -Wsometimes-uninitialized 2020-03-24 09:35:59 +02:00
Marko Mäkelä
8b647d6960 MDEV-22020: Fix spider/bugfix.return_found_rows_update
The test failed to specify default-character-set when
invoking the client. The compile-time default parameters of the
client could be overridden by configuration files in /etc/mysql.
Let us explicitly specify --default-character-set.
2020-03-24 09:35:36 +02:00
Marko Mäkelä
2559075bda Correct a result 2020-03-21 12:36:55 +02:00
Monty
305cffebab merge 10.4 to 10.5 2020-03-18 12:00:38 +02:00
Monty
1242eb3d32 Removed double records_in_range calls from multi_range_read_info_const
This was to remove a performance regression between 10.3 and 10.4
In 10.5 we will have a better implementation of records_in_range
that will enable us to get more statistics.
This change was not done in 10.4 because the 10.5 will be part of
a larger change that is not suitable for the GA 10.4 version

Other things:
- Changed default handler block_size to 8192 to fix things statistics
  for engines that doesn't set the block size.
- Fixed a bug in spider when using multiple part const ranges
  (Patch from Kentoku)
2020-03-17 02:16:48 +02:00
Kentoku SHIBA
5929e222e4 fix evaluating bitmap issue in spider 2020-03-16 08:39:49 +09:00
Alexander Barkov
a1e330de5a MDEV-21743 Split up SUPER privilege to smaller privileges 2020-03-10 23:49:47 +04:00
Sergei Golubchik
cbede21d0d cleanup: pass trxid by value 2020-03-10 19:24:23 +01:00
Sergei Golubchik
c1c5222cae cleanup: PSI key is *always* the first argument 2020-03-10 19:24:23 +01:00
Sergei Golubchik
81cffda2e6 perfschema transaction instrumentation related changes 2020-03-10 19:24:23 +01:00
Sergei Golubchik
05779bc6f1 perfschema mdl related instrumentation changes 2020-03-10 19:24:22 +01:00
Sergei Golubchik
7c58e97bf6 perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
Alexander Barkov
f1e13fdc8d MDEV-21581 Helper functions and methods for CHARSET_INFO 2020-01-28 12:29:23 +04:00
Kentoku
f5b76d8c40 fix compiler warnings 2019-12-06 05:10:01 +09:00
Kentoku
1b040ce570 fix compiler warnings 2019-12-06 04:59:22 +09:00
Oleksandr Byelkin
008ee867a4 Merge branch '10.2' into 10.3 2019-12-04 17:46:28 +01:00
Jan Lindström
9d9a2253c6 Merge remote-tracking branch 10.2 into 10.3
Conflicts:
	mysql-test/suite/galera/t/galera_binlog_event_max_size_max-master.opt
	mysql-test/suite/innodb/r/innodb-mdev-7513.result
	mysql-test/suite/innodb/t/innodb-mdev-7513.test
	mysql-test/suite/wsrep/disabled.def
	storage/innobase/ibuf/ibuf0ibuf.cc
2019-12-02 14:35:10 +02:00
Aleksey Midenkov
8ed646f071 Merge 10.4 into 10.5 2019-12-02 13:35:54 +03:00
Kentoku
e066723a41 MDEV-18973 CLIENT_FOUND_ROWS wrong in spider
Get count from last_used_con->info
Contributed by willhan at Tencent Games
2019-11-29 23:23:57 +09:00
willhan
3551cd32a8 MDEV-17508 Fix bug for spider when using "not like"
fix bug for spider where using "not like" (#890)

test case:
t1 is a spider engine table;
  CREATE TABLE `t1` (
  `id` int(11) NOT NULL DEFAULT '0',
  `name` char(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=SPIDER

query: "select * from t1 where name  not like 'x%' " would dispatch "select xxx name name like 'x%' " to remote mysqld, is wrong
2019-11-25 15:40:01 +01:00
Marko Mäkelä
c99470b366 Merge 10.4 into 10.5 2019-11-13 20:38:14 +02:00
Kentoku SHIBA
83a0eaec08
MDEV-18987 bug in "load data local infile xxx replace into " (#1408)
It's just added regression tests.
2019-11-13 00:32:27 +09:00