Commit graph

1021 commits

Author SHA1 Message Date
Marko Mäkelä
2719cc4925 Merge 10.11 into 11.4 2024-12-02 11:35:34 +02:00
Marko Mäkelä
3d23adb766 Merge 10.6 into 10.11 2024-11-29 13:43:17 +02:00
Marko Mäkelä
7d4077cc11 Merge 10.5 into 10.6 2024-11-29 12:37:46 +02:00
Brandon Nesterenko
840fe316d4 MDEV-34348: my_hash_get_key fixes
Partial commit of the greater MDEV-34348 scope.
MDEV-34348: MariaDB is violating clang-16 -Wcast-function-type-strict

Change the type of my_hash_get_key to:
 1) Return const
 2) Change the context parameter to be const void*

Also fix casting in hash adjacent areas.

Reviewed By:
============
Marko Mäkelä <marko.makela@mariadb.com>
2024-11-23 08:14:22 -07:00
Alexander Barkov
c4bf4ce948 Merge remote-tracking branch 'origin/11.2' into 11.4 2024-06-17 15:46:39 +04:00
Marko Mäkelä
22ba7e4ff8 Merge 10.6 into 10.11 2024-05-30 16:04:00 +03:00
Marko Mäkelä
5ba542e9ee Merge 10.5 into 10.6 2024-05-30 14:27:07 +03:00
Alexander Barkov
310fd6ff69 Backporting bugs fixes fixed by MDEV-31340 from 11.5
The patch for MDEV-31340 fixed the following bugs:

MDEV-33084 LASTVAL(t1) and LASTVAL(T1) do not work well with lower-case-table-names=0
MDEV-33085 Tables T1 and t1 do not work well with ENGINE=CSV and lower-case-table-names=0
MDEV-33086 SHOW OPEN TABLES IN DB1 -- is case insensitive with lower-case-table-names=0
MDEV-33088 Cannot create triggers in the database `MYSQL`
MDEV-33103 LOCK TABLE t1 AS t2 -- alias is not case sensitive with lower-case-table-names=0
MDEV-33108 TABLE_STATISTICS and INDEX_STATISTICS are case insensitive with lower-case-table-names=0
MDEV-33109 DROP DATABASE MYSQL -- does not drop SP with lower-case-table-names=0
MDEV-33110 HANDLER commands are case insensitive with lower-case-table-names=0
MDEV-33119 User is case insensitive in INFORMATION_SCHEMA.VIEWS
MDEV-33120 System log table names are case insensitive with lower-cast-table-names=0

Backporting the fixes from 11.5 to 10.5
2024-05-21 14:58:01 +04:00
Oleksandr Byelkin
fecd78b837 Merge branch '10.10' into 10.11 2023-11-08 16:46:47 +01:00
Oleksandr Byelkin
04d9a46c41 Merge branch '10.6' into 10.10 2023-11-08 16:23:30 +01:00
Oleksandr Byelkin
b83c379420 Merge branch '10.5' into 10.6 2023-11-08 15:57:05 +01:00
Oleksandr Byelkin
6cfd2ba397 Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
Alexander Barkov
179424db5f MDEV-32025 Crashes in MDL_key::mdl_key_init with lower-case-table-names=2
Backporting a part of MDEV-32026 (which also fixed MDEV-32025 in 11.3)
from 11.3 to 10.4.

The reported crash happened with --lower-case-table-names=2
on statements like:

ALTER DATABASE Db1 DEFAULT CHARACTER SET utf8;
ALTER DATABASE `#mysql50#D+b1` UPGRADE DATA DIRECTORY NAME;

lock_schema_name() expects a normalized database name
and assert if a non-normalized name comes.

mysql_alter_db_internal() and mysql_upgrade_db() get
a non-normalized database name in the parameter.
Fixing them to normalize the database name before passing
it to lock_schema_name().
2023-10-23 09:20:42 +04:00
Alexander Barkov
9cb75f333f MDEV-32026 lowercase_table2.test failures in 11.3
Also fixes MDEV-32025 Crashes in MDL_key::mdl_key_init with lower-case-table-names=2

Change overview:
- In changes made in MDEV-31948, MDEV-31982 the code path
  which originaly worked only in case of lower-case-table-names==1
  also started to work in case of lower-case-table-names==2 in a mistake.

  Restoring the original check_db_name() compatible behavior
  (but without re-using check_db_name() itself).
- MDEV-31978 erroneously added a wrong DBUG_ASSERT. Removing.

Details:

- In mysql_change_db() the database name should be lower-cased only
  in case of lower_case_table_names==1. It should not be lower-cased
  for lower_case_table_names==2. The problem was caused by MDEV-31948.
  The new code version restored the pre-MDEV-31948 behavior, which
  used check_db_name() behavior.

- Passing lower_case_table_names==1 instead of just lower_case_table_names
  to the "casedn" parameter to DBNameBuffer constructor in sql_parse.cc
  The database name should not be lower-cased for lower_case_table_names==2.
  This restores pre-MDEV-31982 behavioir which used check_db_name() here.

- Adding a new data type Lex_ident_db_normalized, it stores database
  names which are both checked and normalized to lower case
  in case lower_case_table_names==1 and lower_case_table_names==2.

- Changing the data type for the "db" parameter to Lex_ident_db_normalized in
  lock_schema_name(), lock_db_routines(), find_db_tables_and_rm_known_files().

  This is to avoid incorrectly passing a non-normalized name in the future.

- Restoring the database name normalization in mysql_create_db_internal()
  and mysql_rm_db_internal() before calling lock_schema_name().
  The problem was caused MDEV-31982.

- Adding database name normalization in mysql_alter_db_internal()
  and mysql_upgrade_db(). This fixes MDEV-32026.

- Removing a wrong assert in Create_sp_func::create_with_db() was incorrect:

    DBUG_ASSERT(Lex_ident_fs(*db).ok_for_lower_case_names());

  The database name comes to here checked, but not normalized
  to lower case with lower-case-table-names=2.
  The assert was erroneously added by MDEV-31978.

- Recording lowercase_tables2.results and lowercase_tables4.results
  according to
    MDEV-29446 Change SHOW CREATE TABLE to display default collations
  These tests are skipped on buildbot on all platforms, so this change
  was forgotten in the patch for MDEV-29446.
2023-08-29 14:19:38 +04:00
Alexander Barkov
d15e290285 MDEV-31982 Remove check_db_name() from prepare_db_action()
- Adding a new class Lex_ident_db, to store normalized database names:
  lower-cased if lower-case-table-name says so,
  and checked to be a valid database name using Lex_ident_fs::check_db_name()

- Reusing the new class in parameters to functions:
    prepare_db_action()
    mysql_create_db()
    mysql_alter_db()
    mysql_rm_db()
    mysql_upgrade_db()

This change removed two old-style check_db_name() calls.
2023-08-22 16:41:04 +04:00
Alexander Barkov
ebbf5662ef MDEV-31978 Turn ok_for_lower_case_names() to a method in Lex_ident_fs
- Changing the global function ok_for_lower_case_names()
  into a method in class Lex_ident_fs.

- Changing a few functions/methods to get the database name
  as a "const LEX_CSTRING" instead of a "const char *".
  All these functions/methods use ok_for_lower_case_names()
  inside. This change helps to avoid new strlen() calls, and also
  removes a few old strlen() calls.
2023-08-22 13:42:42 +04:00
Alexander Barkov
7a7296bd1e MDEV-31974 Remove global function normalize_db_name()
The function normalize_db_name() fully repeated the functionality
of the class DBNameBuffer. This patch  removes normalize_db_name()
and replaces it to a DBNameBuffer based code.
2023-08-21 15:56:29 +04:00
Alexander Barkov
b956a6a259 MDEV-31948 Add class DBNameBuffer, split check_db_name() into stages
- Adding a class Lex_ident_fs, to store identifiers for on-disk
  database objects, such as databases, tables, triggers.

- Moving the validation code from check_db_name()
  to non-modifying methods in Lex_ident_fs:

    Lex_ident_fs::check_body()
    Lex_ident_fs::check_db_name()

  Adding a new method Lex_ident_fs::check_db_name_with_error(),
  which performs validation and raises an error on validation failure.

  Unlike the old function check_db_name(), the new class Lex_ident_fs
  does not lower-case the identifier during the validation.
  Lower-casing must be done before calling Lex_ident_fs validation methods.

- Adding a low level helper template class CharBuffer which can:
  * store exact or lower-cased strings with a short fixed maximum length
  * return the value as a LEX_CSTRING efficiently

- Adding a helper template class DBNameBuffer (deriving from CharBuffer), to
  allocate optionally lower-cased database identifiers on stack when relevant.
  Useful for temporary values which don't need to be allocated on MEM_ROOT.

- Using DBNameBuffer in mysql_change_db()

- Using DBNameBuffer in show_create_db()
2023-08-18 16:36:15 +04:00
Oleksandr Byelkin
b0325bd6d6 MDEV-5215 Granted to PUBLIC 2022-11-01 22:15:14 +01:00
Sergei Golubchik
2bd41fc5bf Revert MDEV-25292 Atomic CREATE OR REPLACE TABLE
Specifically:

Revert "MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection"
This reverts commit ba875e9396.

Revert "MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock"
This reverts commit aa08a7442a.

Revert "MDEV-29628 Memory leak after CREATE OR REPLACE with foreign key"
This reverts commit c579d66ba6.

Revert "MDEV-29609 create_not_windows test fails with different result"
This reverts commit cb583b2f1b.

Revert "MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables"
This reverts commit dcd66c3814.

Revert "MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name"
This reverts commit cf6c517632.

Revert "MDEV-28933 Moved RENAME_CONSTRAINT_IDS to include/sql_funcs.h"
This reverts commit f1e1c1335b.

Revert "MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES"
This reverts commit a228ec80e3.

Revert "MDEV-25292 gcol.gcol_bugfixes --ps fix"
This reverts commit 24fff8267d.

Revert "MDEV-25292 Disable atomic replace for slave-generated or-replace"
This reverts commit 2af15914cb.

Revert "MDEV-25292 backup_log improved"
This reverts commit 34398a20b5.

Revert "MDEV-25292 Atomic CREATE OR REPLACE TABLE"
This reverts commit 93c8252f02.

Revert "MDEV-25292 Table_name class for (db, table_name, alias)"
This reverts commit d145dda9c7.

Revert "MDEV-25292 ha_table_exists() cleanup and improvement"
This reverts commit 409b8a86de.

Revert "MDEV-25292 Cleanups"
This reverts commit 595dad83ad.

Revert "MDEV-25292 Refactoring: moved select_field_count into Alter_info."
This reverts commit f02af1d229.
2022-10-27 23:13:41 +02:00
Aleksey Midenkov
409b8a86de MDEV-25292 ha_table_exists() cleanup and improvement
Removed default values for arguments, added flags argument to specify
filename flags (FN_TO_IS_TMP, FN_FROM_IS_TMP).
2022-08-31 11:55:03 +03:00
Aleksey Midenkov
65e0d0ea66 MDEV-25292 Removed thd argument in ddl_log functions 2022-08-31 11:55:03 +03:00
Alexander Barkov
208addf484 Main patch MDEV-27896 Wrong result upon COLLATE latin1_bin CHARACTER SET latin1 on the table or the database level
Also fixes
MDEV-27782 Wrong columns when using table level `CHARACTER SET utf8mb4 COLLATE DEFAULT`
MDEV-28644 Unexpected error on ALTER TABLE t1 CONVERT TO CHARACTER SET utf8mb3, DEFAULT CHARACTER SET utf8mb4
2022-05-24 09:36:15 +04:00
Eric Herman
401ff6994d MDEV-26221: DYNAMIC_ARRAY use size_t for sizes
https://jira.mariadb.org/browse/MDEV-26221
my_sys DYNAMIC_ARRAY and DYNAMIC_STRING inconsistancy

The DYNAMIC_STRING uses size_t for sizes, but DYNAMIC_ARRAY used uint.
This patch adjusts DYNAMIC_ARRAY to use size_t like DYNAMIC_STRING.

As the MY_DIR member number_of_files is copied from a DYNAMIC_ARRAY,
this is changed to be size_t.

As MY_TMPDIR members 'cur' and 'max' are copied from a DYNAMIC_ARRAY,
these are also changed to be size_t.

The lists of plugins and stored procedures use DYNAMIC_ARRAY,
but their APIs assume a size of 'uint'; these are unchanged.
2021-10-19 16:00:26 +03: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
83e529eced MDEV-18465 Logging of DDL statements during backup
Many of the changes was needed to be able to collect and print engine
name and table version id's in the ddl log.
2021-05-19 22:54:13 +02:00
Monty
496a14e187 Move debug_crash_here to it's own source files 2021-05-19 22:54:13 +02:00
Monty
7a588c30b1 MDEV-24408 Crash-safe DROP DATABASE
Description of how DROP DATABASE works after this patch

- Collect list of tables
- DDL log tables as they are dropped
- DDL log drop database
- Delete db.opt
- Delete data directory
- Log either DROP TABLE or DROP DATABASE to binary log
- De active ddl log entry

This is in line of how things where before (minus ddl logging) except that
we delete db.opt file last to not loose it if DROP DATABASE fails.

On recovery we have to ensure that all dropped tables are logged in
binary log and that they are properly dropped (as with atomic drop
table).
No new tables be dropped as part of recovery.

Recovery of active drop database ddl log entry:

- If drop database was logged to ddl log but was not found in the binary
  log:
  - drop the db.opt file and database directory.
  - Log DROP DATABASE to binary log
- If drop database was not logged to ddl log
  - Update binary log with DROP TABLE of the dropped tables. If table list
    is longer than max_allowed_packet, then the query will be split into
    multiple DROP TABLE/VIEW queries.

Other things:
- Added DDL_LOG_STATE and 'current database' as arguments to
  mysql_rm_table_no_locks(). This was needed to be able to combine
  ddl logging of DROP DATABASE and DROP TABLE and make the generated
  DROP TABLE statements shorter.
- To make the DROP TABLE statement created by ddl log shorter, I changed
  the binlogged query to use current directory and omit the directory
  part for all tables in the current directory.
- Merged some DROP TABLE and DROP VIEW code in ddl logger.  This was done
  to be able get separate DROP VIEW and DROP TABLE statements in the binary
  log.
- Added a 'recovery_state' variable to remember the state of dropped
  tables and views.
- Moved out code that drops database objects (stored procedures) from
  mysql_rm_db_internal() to drop_database_objects() for better code reuse.
- Made mysql_rm_db_internal() global so that could be used by the ddl
  recovery code.
2021-05-19 22:54:13 +02:00
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
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
Monty
cccc96d66c Fixed wrong initializations of Dynamic_array
Other things:
- Added size() function to Dynamic_array()
2021-03-20 21:17:32 +02:00
Vladislav Vaintroub
1a2b494100 MDEV-23124 Eliminate the overhead of system call access() on every USE(or connection)
Make check_db_dir_existence() use a cache of existing directories
clear the cache whenever any directory is removed.

With this, the cost of check_db_dir_existence() will usually be a cost of
acquiring/releasing a non-contended readwrite lock in shared mode,
much less than going to the kernel and filesystem to check for file existence
2020-07-14 11:16:24 +02:00
Monty
bff79492c5 Added IF EXISTS to RENAME TABLE and ALTER TABLE 2020-03-24 20:47:41 +02:00
Sergei Golubchik
c1c5222cae cleanup: PSI key is *always* the first argument 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
83e75b39b3 MDEV-21702 Add a data type for privileges 2020-02-11 08:10:26 +04:00
Marko Mäkelä
28c89b7151 Merge 10.4 into 10.5 2019-12-16 07:47:17 +02:00
Oleksandr Byelkin
a15234bf4b Merge branch '10.3' into 10.4 2019-12-09 15:09:41 +01:00
Faustin Lammler
2df2238cb8 Lintian complains on spelling error
The lintian check complains on spelling error:
https://salsa.debian.org/mariadb-team/mariadb-10.3/-/jobs/95739
2019-12-02 12:41:13 +02:00
Sergey Vojtovich
092834cd2c Removed kill_delayed_threads_for_table()
After 7fb9d64 it is used only by ALTER/DROP SERVER, which most probably
wasn't intentional as Federated never supported delayed inserts anyway.

If delayed inserts will ever become an issue with ALTER/DROP SERVER, we
should kill them by acquiring X-lock instead.

Part of MDEV-17882 - Cleanup refresh version
2019-11-25 18:49:51 +04:00
Sergey Vojtovich
ad77e3ac09 Cleanup session tracker
- call current_schema::mark_as_changed() directly
- call state_change::mark_as_changed() directly
- replaced SESSION_TRACKER_CHANGED with dummy tracker
- replaced Session_tracker::mark_as_changed() with
  State_tracker::mark_as_changed()
- hide and devirtualize original State_tracker::mark_as_changed(),
  rename it to set_changed()
- all implementations of mark_as_changed() now check is_enabled() for
  consistency
- no argument casts anymore
2019-09-24 15:49:35 +04:00
Marko Mäkelä
826f9d4f7e Merge 10.4 into 10.5 2019-05-23 10:32:21 +03:00
Robert Bindar
042f5165e3 MDEV-307 review minor edits, add yacc_ora support 2019-05-21 09:33:30 +03:00
Gagan Goel
e9c6d5a1e8 MDEV-307 Add functionality for database comments
This commit adds a new feature to the server to add comments at the database
level. 1024 bytes is the maximum comment length allowed. If the comment length
exceeds this limit, a new error/warning code 4144 is thrown, based on whether
thd->is_strict_mode() is true/false. The database comment is also added to the
db.opt file, as well as to the information_schema.schemata table.
2019-05-21 09:33:17 +03:00
Oleksandr Byelkin
c07325f932 Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Oleksandr Byelkin
c51f85f882 Merge branch '10.2' into 10.3 2019-05-12 17:20:23 +02:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00