Commit graph

196800 commits

Author SHA1 Message Date
Dave Gosselin
e9c71f3a25 MDEV-34814 mysqld hangs on startup when --init-file target does not exist
Set select_thread_in_use only when we're about to enter into the polling
loop, not sooner, allowing early proces aborts to exist cleanly: the
process won't be waiting for a polling loop that isn't yet polling.
2024-10-15 09:22:31 -04:00
Oleksandr Byelkin
7038382e1b Fix grant5.test with view protocol 2024-10-15 12:44:24 +02:00
Oleksandr Byelkin
44804c667e MDEV-18151 pam test result fix
Fix result due to the new error message.
2024-10-15 12:44:24 +02:00
Yuchen Pei
d797c9879e
[fixup] Restore the Chinese error translation of ER_SET_PASSWORD_AUTH_PLUGIN
It was removed in MDEV-18151
2024-10-15 20:35:55 +11:00
Thirunarayanan Balathandayuthapani
6aaae4c03b MDEV-35122 Incorrect NULL value handling for instantly dropped BLOB columns
Problem:
=======
- Redundant table fails to insert into the table after
instant drop blob column. Instant drop column only marking
the column as hidden and consecutive insert statement tries
to insert NULL value for the dropped BLOB column and returns
the fixed length of the blob type as 65535. This lead to
row size too large error.

Fix:
====
 For redundant table, if the non-fixed dropped column can be null
then set the length of the field type as 0.
2024-10-15 12:04:37 +05:30
Yuchen Pei
77ed235d50
MDEV-26345 Spider GBH should execute original queries on the data node
Stop skipping const items when selecting but skip them when storing
their results to spider row to avoid storing in mismatching temporary
table fields.

Skip auxiliary fields in SELECTing, and do not store
the (non-existing) results to the corresponding temporary table
accordingly.

When there are BOTH auxiliary fields AND const items in the auxiliary
field items, do not use the spider GBH. This is a rare occasion if it
happens at all and not worth the added complexity to cover it.

Use the original item (item_ptr) in constructing GROUP BY and ORDER
BY, which also means using item->name instead of field->field_name as
aliases in constructing SELECT items. This fixes spurious regressions
caused by the above changes in some tests using ORDER BY, such as
mdev_24517.test. As a by-product, this also fixes MDEV-29546.
Therefore we update mdev_29008.test to include the MDEV-29546 case.
2024-10-15 15:36:12 +11:00
Yuchen Pei
e6daff40e4
MDEV-32524 [fixup] Fixup of spider mem alloc enums missed in a previous merge
The merge was 10.4.34->10.5.25
2024-10-15 14:30:40 +11:00
Nayuta Yanagisawa
6080e3af19
MDEV-26912 Spider: Remove dead code related to Oracle OCI
Remove the dead-code, in Spider, which is related to the Spider's
Oracle OCI support. The code has been disabled for a long time and
it is unlikely that the code will be enabled.
2024-10-15 14:30:40 +11:00
Yuchen Pei
03a5c683f9
MDEV-27650 Spider: remove #ifdef SPIDER_HAS_GROUP_BY_HANDLER 2024-10-15 14:30:39 +11:00
Yuchen Pei
0a59aafc5f
MDEV-34659 Bound check in spider cast function query construction
During spider query construction of certain cast functions, it
locates the last occurrence of a keyword in the output of the
Item::print() function and append from there to the constructed query
so far. For example, consider the following query

SELECT * FROM t2 ORDER BY CAST(c AS INET6);

It constructs the following query and executes it at the data
node (assuming the data node table is called t0).

select cast(t0.`c` as inet6) ``,t0.`c` `c` from `test`.`t1` t0 order by ``

When the construction has completed the initial part

select cast(t0.`c`

It then attempts to construct the " as inet6" part. To that end, it
calls print() on the Item_typecast_fbt corresponding to the cast item,
and obtains

cast(`test`.`t2`.`c` as inet6)

It then looks for " as ", and places cursor there for appending:

cast(`test`.`t2`.`c` as inet6)
                    ^

In this patch, if the search fails, i.e. there's no " as ...", we
make sure that the cursor is not placed before the beginning of the
string (out of bound).

We also relax the search from " as char" to " as " in the case of
CHAR_TYPECAST_FUNC, since there is more than one Item type with this
func type. For example, "AS INET6" is an Item_typecast_fbt which has
this func type.
2024-10-15 14:30:30 +11:00
Yuchen Pei
98a9c75ea3
MDEV-34659 Use evalp in CREATE SERVER's in init_spider.inc
This was already fixed in higher versions.
2024-10-15 14:18:12 +11:00
Yuchen Pei
d3b84ff10d
MDEV-30067 Remove some overly enthusiastic asserts when deleting from a partitioned table
When an DDL statement results in a local partition table with
partitions not covering all values in the table, a failure is emitted.
However, when the table in question is a spider table, the issue does
not surface until some future statements (DELETE in the test examples
in this commit) are executed. This is consistent with the design of
spider which aims to minimise connections with the data node. The
resulting error is legitimate and should not result in an assertion
failure. Similarly, a partitioned spider table could have misplaced
rows, so we remove the other assertion as well.
2024-10-15 14:18:10 +11:00
Yuchen Pei
8a52639ede
MDEV-34716 spider: some trivial cleanups and documentation
- document tmp_share, which are temporary spider shares with only one
link (no ha)
- simplify spider_get_sys_tables_connect_info() where link_idx is
always 0
2024-10-15 11:04:27 +11:00
Sergei Golubchik
d5f5062a48 our release packages on rhel8 use bundled readline
for historical reasons, but we keep doing it for compatibility
2024-10-14 13:09:20 +02:00
Thirunarayanan Balathandayuthapani
5777d9f282 MDEV-35116 InnoDB fails to set error index for HA_ERR_NULL_IN_SPATIAL
- InnoDB fails to set the index information or index number
for the spatial index error HA_ERR_NULL_IN_SPATIAL.

row_build_spatial_index_key(): Initialize the tmp_mbr array completely.

check_if_supported_inplace_alter(): Fix the spelling mistake of alter
2024-10-14 14:28:24 +05:30
Oleksandr Byelkin
b138f428ea MDEV-18151 Skipped error returning for GRANT/SET PASSWORD
Make message of error not warning.
2024-10-09 15:48:14 +02:00
Oleksandr Byelkin
cc59fbfffa MDEV-18151 Skipped error returning for GRANT/SET PASSWORD
Make error issueing for GRANT and SET PASSWORD the same.
Report errors wich were skipped before.
2024-10-09 13:29:59 +02:00
Oleksandr Byelkin
9cd9c3cf16 fix grant5 test to return to the original database. 2024-10-09 13:29:46 +02:00
Marko Mäkelä
8981ee238a MDEV-33106 innodb.innodb-lock-inherit-read_commited times out
Sometimes, in MariaDB Server 10.5 but apparently not in later branches,
the test would hang because con1 and con2 would be blocked in
debug_sync (for example, lock_wait_suspend_thread_enter and
row_ins_sec_index_entry_dup_locks_created) and therefore blocking
the purge of transactions from completing.

To prevent an occasional DEBUG_SYNC induced hang in the test, we will
wait for everything to be purged, except the last 2 transactions.

This change should be null-merged to 10.6, because the test is not
failing in 10.6 or later major versions.
2024-10-09 11:26:12 +03:00
Thirunarayanan Balathandayuthapani
23820f1d79 MDEV-34392 Inplace algorithm violates the foreign key constraint
- Fixing the compilation issue for the compiler lesser than gcc-6

Reviewed-by : Marko Mäkelä <marko.makela@mariadb.com>
2024-10-09 10:14:29 +05:30
Sergei Golubchik
4281e0068b MDEV-35082 HANDLER with FULLTEXT keys is not always rejected
need to check for index capabilities also for HANDLER READ NEXT
2024-10-08 18:20:13 +02:00
Sergei Golubchik
23d7dc1ea1 MDEV-35086 Trying to lock mutex when the mutex was already locked (session_tracker.cc), server hangs
followup for 9021f40b8e
2024-10-08 15:31:02 +02:00
Sergei Golubchik
3ea71a2c8e MDEV-16699 heap-use-after-free in group_concat with compressed or GIS columns
Field_blob::store() has special code for GROUP_CONCAT temporary table
(to store blob values in Blob_mem_storage - this prevents them
from being freed/overwritten when a next row is read).

Field_geom and Field_blob_compressed inherit from Field_blob but they
have their own ::store() method without this special Blob_mem_storage
support.

Considering that non-grouping CONCAT() of such fields converts
them to plain BLOB, let's do the same for GROUP_CONCAT. To do it,
Item_func_group_concat::setup will signal that it's creating
a temporary table for GROUP_CONCAT, and Field_blog::make_new_field()
override will create base Field_blob when under group concat.
2024-10-08 15:31:02 +02:00
Thirunarayanan Balathandayuthapani
65418ca9ad MDEV-34392 Inplace algorithm violates the foreign key constraint
- Fix the compilation error in gcc-5
2024-10-08 16:43:57 +05:30
Aleksey Midenkov
706a8bcb5b MDEV-33470 Unique hash index is broken on DML for system-versioned table
Hash index is vcol-based wrapper (MDEV-371). row_end is added to
unique index. So when row_end is updated unique hash index must be
recalculated via vcol_update_fields(). DELETE did not update virtual
fields, so DELETE HISTORY was getting wrong hash value.

The fix does update_virtual_fields() on vers_update_end() so in every
case row_end is updated virtual fields are updated as well.
2024-10-08 13:08:10 +03:00
Aleksey Midenkov
d37bb140b1 MDEV-31297 Create table as select on system versioned tables do not
work consistently on replication

Row-based replication does not execute CREATE .. SELECT but instead
CREATE TABLE. CREATE .. SELECT creates implict system fields on
unusual place: in-between declared fields and select fields. That was
done because select_field_pos logic requires select fields go last in
create_list.

So, CREATE .. SELECT on master and CREATE TABLE on slave create system
fields on different positions and replication gets field mismatch.

To fix this we've changed CREATE .. SELECT to create implicit system
fields on usual place in the end and updated select_field_pos for
handling this case.
2024-10-08 13:08:10 +03:00
Aleksey Midenkov
4e4c7dd4f5 MDEV-28288 System versioning doesn't support correct work for
engine=connect and doesn't always give any warnings/errors

Disabled system versioning for connect due to unsupported
microseconds (MDEV-15967).
2024-10-08 13:08:10 +03:00
Aleksey Midenkov
5b940bdcfc MDEV-25060 Freeing overrun buffer, various crashes, ASAN
heap-buffer-overflow in _mi_put_key_in_record

Rec buffer size depends on vreclength like this:

  length= MY_MAX(length, info->s->vreclength);

The problem is rec buffer is allocated before vreclength is
calculated. The fix reallocates rec buffer if vreclength changed.

1. Rec buffer allocated

  f0  mi_alloc_rec_buff (...) at ../src/storage/myisam/mi_open.c:738
  f1  0x00005f4928244516 in mi_open (...) at ../src/storage/myisam/mi_open.c:671
  f2  0x00005f4928210b98 in ha_myisam::open (...)
      at ../src/storage/myisam/ha_myisam.cc:847
  f3  0x00005f49273aba41 in handler::ha_open (...) at ../src/sql/handler.cc:3105
  f4  0x00005f4927995a65 in open_table_from_share (...)
      at ../src/sql/table.cc:4320
  f5  0x00005f492769f084 in open_table (...) at ../src/sql/sql_base.cc:2024
  f6  0x00005f49276a3ea9 in open_and_process_table (...)
      at ../src/sql/sql_base.cc:3819
  f7  0x00005f49276a29b8 in open_tables (...) at ../src/sql/sql_base.cc:4303
  f8  0x00005f49276a6f3f in open_and_lock_tables (...)
      at ../src/sql/sql_base.cc:5250
  f9  0x00005f49275162de in open_and_lock_tables (...)
      at ../src/sql/sql_base.h:509
  f10 0x00005f4927a30d7a in open_only_one_table (...)
      at ../src/sql/sql_admin.cc:412
  f11 0x00005f4927a2c0c2 in mysql_admin_table (...)
      at ../src/sql/sql_admin.cc:603
  f12 0x00005f4927a2fda8 in Sql_cmd_optimize_table::execute (...)
      at ../src/sql/sql_admin.cc:1517
  f13 0x00005f49278102e3 in mysql_execute_command (...)
      at ../src/sql/sql_parse.cc:6180
  f14 0x00005f49278012d7 in mysql_parse (...) at ../src/sql/sql_parse.cc:8236

2. vreclength calculated

  f0  ha_myisam::setup_vcols_for_repair (...)
      at ../src/storage/myisam/ha_myisam.cc:1002
  f1  0x00005f49282138b4 in ha_myisam::optimize (...)
      at ../src/storage/myisam/ha_myisam.cc:1250
  f2  0x00005f49273b4961 in handler::ha_optimize (...)
      at ../src/sql/handler.cc:4896
  f3  0x00005f4927a2d254 in mysql_admin_table (...)
      at ../src/sql/sql_admin.cc:875
  f4  0x00005f4927a2fda8 in Sql_cmd_optimize_table::execute (...)
      at ../src/sql/sql_admin.cc:1517
  f5  0x00005f49278102e3 in mysql_execute_command (...)
      at ../src/sql/sql_parse.cc:6180
  f6  0x00005f49278012d7 in mysql_parse (...) at ../src/sql/sql_parse.cc:8236

FYI backtrace was done with

  set print frame-info location
  set print frame-arguments presence
  set width 80
2024-10-08 13:08:10 +03:00
Sergei Petrunia
5673cbe094 MDEV-35074: selectivity_notembedded fails with --view-protocol
Make the test view-protocol proof: save the contents of optimizer_trace
and then we can do many queries against it.

Also removed end-of-line spaces.
2024-10-04 12:49:37 +03:00
Yuchen Pei
e9c999caf4
MDEV-34915 Sort output of session track system variable in mysqltest
Updated the output format too.

Before:

-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- autocommit
-- ON
-- time_zone
-- SYSTEM
-- character_set_client
-- latin1
-- character_set_connection
-- latin1
-- redirect_url
--

After:

-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- autocommit: ON
-- character_set_client: latin1
-- character_set_connection: latin1
-- redirect_url:
-- time_zone: SYSTEM
2024-10-04 10:32:02 +10:00
Sergei Golubchik
ab15628bbc MDEV-35050 fix for embedded 2024-10-03 10:09:24 +02:00
Marko Mäkelä
6878c9d591 MDEV-35050 fixup: ./mtr --embedded 2024-10-03 10:40:58 +03:00
Marko Mäkelä
170e4555e2 MDEV-35040: Fix std::unique deleter for clang++-20 -stdlib=libc++
Thanks to Khem Raj for reporting this.
2024-10-03 08:15:48 +03:00
Marko Mäkelä
23debf214f MDEV-28091 fixup: Fix another pfs_malloc() stub
In commit 0f56e21efa
only one pfs_malloc() stub was fixed to return aligned memory.
Also, the MSVC _aligned_malloc() pairs with _aligned_free().
2024-10-03 08:15:17 +03:00
Daniel Black
1f7898f686 mroonga: remove -Wunused-but-set-variable warnings
There where unused variable. They were not conditional
on defines, so removed them.

Added an error handing in proc_object if there was no db
as subsequent operations would have failed.
2024-10-03 15:05:09 +10:00
Daniel Black
3723fd1573 MDEV-35007 mroonga should modify source files during build
CMake rewriting the tests causes Mroonga to be un-buildable
on build environments where there source directory is read
only.

In the test results, the version wasn't particularly important.

Remove the version dependence of tests.
2024-10-03 15:05:09 +10:00
Sergei Petrunia
1cda4726ca MDEV-34993, part2: backport optimizer_adjust_secondary_key_costs
...and make the fix for MDEV-34993 switchable. It is enabled by default
and controlled with @optimizer_adjust_secondary_key_costs=fix_card_multiplier
2024-10-02 10:52:09 +03:00
Sergei Petrunia
8166a5d33d MDEV-34993: Incorrect cardinality estimation causes poor query plan
When calculate_cond_selectivity_for_table() takes into account multi-
column selectivities from range access, it tries to take-into account
that selectivity for some columns may have been already taken into account.

For example, for range access on IDX1 using {kp1, kp2}, the selectivity
of restrictions on "kp2" might have already been taken into account
to some extent.
So, the code tries to "discount" that using rec_per_key[] estimates.

This seems to be wrong and unreliable: the "discounting" may produce a
rselectivity_multiplier number that hints that the overall selectivity
of range access on IDX1 was greater than 1.

Do a conservative fix: if we arrive at conclusion that selectivity of
range access on condition in IDX1 >1.0, clip it down to 1.
2024-10-02 10:52:09 +03:00
Sergei Golubchik
9021f40b8e MDEV-35050 Found wrong usage of mutex upon setting plugin session variables 2024-10-01 18:29:11 +02:00
Sergei Golubchik
b1bbdbab9e cleanup: remove redundant if()
likely, a result of auto-merge of two fixes in different versions
2024-10-01 18:29:11 +02:00
Sergei Golubchik
813e592763 compilation failure in CONNECT
storage/connect/tabfmt.cpp:419:24: error: '%.3d' directive writing between 3 and 10 bytes into a region of size 5 [-Werror=format-overflow=]
  419 |       sprintf(buf, "COL%.3d", i+1);
2024-10-01 18:29:11 +02:00
Sergei Golubchik
5bf543fd43 MDEV-24193 UBSAN: sql/sql_acl.cc:9985:29: runtime error: member access within null pointer of type 'struct TABLE' , ASAN: use-after-poison in handle_grant_table
privilege tables do not always have to exist
2024-10-01 18:29:11 +02:00
Sergei Golubchik
2cdcfb644c MDEV-26314 ST_EQUALS listed twice in information_schema.SQL_FUNCTIONS 2024-10-01 18:29:11 +02:00
Marko Mäkelä
464055fe65 MDEV-34078 Memory leak in InnoDB purge with 32-column PRIMARY KEY
row_purge_reset_trx_id(): Reserve large enough offsets for accomodating
the maximum width PRIMARY KEY followed by DB_TRX_ID,DB_ROLL_PTR.

Reviewed by: Thirunarayanan Balathandayuthapani
2024-10-01 18:35:39 +03:00
Oleksandr Byelkin
8d810e9426 MDEV-29537 Creation of view with UNION and SELECT ... FOR UPDATE in definition is failed with error
lock_type is writen in the last SELECT of the unit even if it parsed last,
so it should be printed last from the last select of the unit.
2024-10-01 11:07:45 +02:00
Thirunarayanan Balathandayuthapani
cc810e64d4 MDEV-34392 Inplace algorithm violates the foreign key constraint
Don't allow the referencing key column from NULL TO NOT NULL
when

 1) Foreign key constraint type is ON UPDATE SET NULL
 2) Foreign key constraint type is ON DELETE SET NULL
 3) Foreign key constraint type is UPDATE CASCADE and referenced
 column declared as NULL

Don't allow the referenced key column from NOT NULL to NULL
when foreign key constraint type is UPDATE CASCADE
and referencing key columns doesn't allow NULL values

get_foreign_key_info(): InnoDB sends the information about
nullability of the foreign key fields and referenced key fields.

fk_check_column_changes(): Enforce the above rules for COPY
algorithm

innobase_check_foreign_drop_col(): Checks whether the dropped
column exists in existing foreign key relation

innobase_check_foreign_low() : Enforce the above rules for
INPLACE algorithm

dict_foreign_t::check_fk_constraint_valid(): This is used
by CREATE TABLE statement to check nullability for foreign
key relation.
2024-10-01 09:41:56 +05:30
Max Kellermann
45298b730b sql/handler: referenced_by_foreign_key() returns bool
The method was declared to return an unsigned integer, but it is
really a boolean (and used as such by all callers).

A secondary change is the addition of "const" and "noexcept" to this
method.

In ha_mroonga.cpp, I also added "inline" to the two helper methods of
referenced_by_foreign_key().  This allows the compiler to flatten the
method.
2024-09-30 16:33:25 +03:00
Sergei Golubchik
b88f1267e4 MDEV-33373 part 2: Unexpected ER_FILE_NOT_FOUND upon reading from logging table after crash recovery
CSV engine shoud set my_errno if use it.
2024-09-30 13:50:51 +02:00
Oleksandr Byelkin
20f57a8529 MDEV-33373 part 1: Unexpected ER_FILE_NOT_FOUND upon reading from logging table after crash recovery
We have found that my_errno can be "passed" to the next commad in some cases.

It is practically impossible to check/fix all cases of my_errno in the server,
plugins and engines so we will reset it as we reset other errors.

The test case will be fixed by CSV engine fix so will be added with it
(see part2).
2024-09-30 12:53:07 +02:00
Yuchen Pei
282b92f0a2
MDEV-34589 Do not execute before queries in spider_db_mbase::rollback()
Rollback is not supposed to fail. This prevents false failures in
spider rollback.
2024-09-30 16:16:27 +10:00