1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-32203 Raise notes when an index cannot be used on data type mismatch

Raise notes if indexes cannot be used:
- in case of data type or collation mismatch (diferent error messages).
- in case if a table field was replaced to something else
  (e.g. Item_func_conv_charset) during a condition rewrite.

Added option to write warnings and notes to the slow query log for
slow queries.

New variables added/changed:

- note_verbosity, with is a set of the following options:
  basic            - All old notes
  unusable_keys    - Print warnings about keys that cannot be used
                     for select, delete or update.
  explain          - Print unusable_keys warnings for EXPLAIN querys.

The default is 'basic,explain'. This means that for old installations
the only notable new behavior is that one will get notes about
unusable keys when one does an EXPLAIN for a query. One can turn all
of all notes by either setting note_verbosity to "" or setting sql_notes=0.

- log_slow_verbosity has a new option 'warnings'. If this is set
  then warnings and notes generated are printed in the slow query log
  (up to log_slow_max_warnings times per statement).

- log_slow_max_warnings   - Max number of warnings written to
                            slow query log.

Other things:
- One can now use =ALL for any 'set' variable to set all options at once.
  For example using "note_verbosity=ALL" in a config file or
  "SET @@note_verbosity=ALL' in SQL.
- mysqldump will in the future use @@note_verbosity=""' instead of
  @sql_notes=0 to disable notes.
- Added "enum class Data_type_compatibility" and changing the return type
  of all Field::can_optimize*() methods from "bool" to this new data type.

Reviewer & Co-author: Alexander Barkov <bar@mariadb.com>
- The code that prints out the notes comes mainly from Alexander
This commit is contained in:
Monty
2023-09-20 15:46:55 +03:00
parent 4c8d2410b6
commit 4e9322e2ff
79 changed files with 4328 additions and 310 deletions

View File

@@ -210,6 +210,7 @@ The following specify which files/extra groups are read (specified before remain
Default flags for the regex library. Any combination of:
DOTALL, DUPNAMES, EXTENDED, EXTENDED_MORE, EXTRA,
MULTILINE, UNGREEDY
Use 'ALL' to set all combinations.
--default-storage-engine=name
The default storage engine for new tables
--default-time-zone=name
@@ -484,12 +485,14 @@ The following specify which files/extra groups are read (specified before remain
--log-disabled-statements=name
Don't log certain types of statements to general log. Any
combination of: slave, sp
Use 'ALL' to set all combinations.
--log-error[=name] Log errors to file (instead of stdout). If file name is
not specified then 'datadir'/'log-basename'.err or the
'pid-file' path with extension .err is used
--log-isam[=name] Log all MyISAM changes to file.
--log-output=name How logs should be written. Any combination of: NONE,
FILE, TABLE
Use 'ALL' to set all combinations.
--log-queries-not-using-indexes
Log queries that are executed without benefit of any
index to the slow log if it is open. Same as
@@ -508,15 +511,20 @@ The following specify which files/extra groups are read (specified before remain
--log-slow-disabled-statements=name
Don't log certain types of statements to slow log. Any
combination of: admin, call, slave, sp
Use 'ALL' to set all combinations.
--log-slow-filter=name
Log only certain types of queries to the slow log. If
variable empty alll kind of queries are logged. All
types are bound by slow_query_time, except
'not_using_index' which is always logged if enabled. Any
combination of: admin, filesort, filesort_on_disk,
variable empty all kind of queries are logged. All types
are bound by slow_query_time, except 'not_using_index'
which is always logged if enabled. Any combination of:
admin, filesort, filesort_on_disk,
filesort_priority_queue, full_join, full_scan,
not_using_index, query_cache, query_cache_miss, tmp_table,
tmp_table_on_disk
Use 'ALL' to set all combinations.
--log-slow-max-warnings=#
Max numbers of warnings printed to slow query log per
statement
--log-slow-rate-limit=#
Write to slow log every #th slow query. Set to 1 to log
everything. Increase it to reduce the size of the slow or
@@ -528,7 +536,8 @@ The following specify which files/extra groups are read (specified before remain
(Defaults to on; use --skip-log-slow-slave-statements to disable.)
--log-slow-verbosity=name
Verbosity level for the slow log. Any combination of:
innodb, query_plan, explain, engine, full
innodb, query_plan, explain, engine, warnings, full
Use 'ALL' to set all combinations.
--log-tc=name Path to transaction coordinator log (used for
transactions that affect more than one storage engine,
when binary log is disabled).
@@ -646,6 +655,7 @@ The following specify which files/extra groups are read (specified before remain
Specifies how corrupted tables should be automatically
repaired. Any combination of: DEFAULT, BACKUP, FORCE,
QUICK, BACKUP_ALL, OFF
Use 'ALL' to set all combinations.
--myisam-repair-threads=#
If larger than 1, when repairing a MyISAM table all
indexes will be created in parallel, with one thread per
@@ -674,6 +684,11 @@ The following specify which files/extra groups are read (specified before remain
--net-write-timeout=#
Number of seconds to wait for a block to be written to a
connection before aborting the write
--note-verbosity=name
Verbosity level for note-warnings given to the user. See
also @@sql_notes.. Any combination of: basic,
unusable_keys, explain
Use 'ALL' to set all combinations.
--old Use compatible behavior from previous MariaDB version.
See also --old-mode
--old-alter-table[=name]
@@ -684,6 +699,7 @@ The following specify which files/extra groups are read (specified before remain
MySQL versions. Any combination of:
NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO,
ZERO_DATE_TIME_CAST, UTF8_IS_UTF8MB3
Use 'ALL' to set all combinations.
--old-passwords Use old password encryption method (needed for 4.0 and
older clients)
--old-style-user-limits
@@ -1284,6 +1300,7 @@ The following specify which files/extra groups are read (specified before remain
variable is empty, no conversions are allowed and it is
expected that the types match exactly. Any combination
of: ALL_LOSSY, ALL_NON_LOSSY
Use 'ALL' to set all combinations.
--slow-launch-time=#
If creating the thread takes longer than this value (in
seconds), the Slow_launch_threads counter will be
@@ -1314,6 +1331,7 @@ The following specify which files/extra groups are read (specified before remain
NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH,
EMPTY_STRING_IS_NULL, SIMULTANEOUS_ASSIGNMENT,
TIME_ROUND_FRACTIONAL
Use 'ALL' to set all combinations.
--sql-safe-updates If set to 1, UPDATEs and DELETEs need either a key in the
WHERE clause, or a LIMIT clause, or else they will
aborted. Prevents the common mistake of accidentally
@@ -1421,6 +1439,7 @@ The following specify which files/extra groups are read (specified before remain
--time-format=name The TIME format (ignored)
--tls-version=name TLS protocol version for secure connections.. Any
combination of: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3
Use 'ALL' to set all combinations.
--tmp-disk-table-size=#
Max size for data for an internal temporary on-disk
MyISAM or Aria table.
@@ -1601,6 +1620,7 @@ log-slave-updates FALSE
log-slow-admin-statements TRUE
log-slow-disabled-statements sp
log-slow-filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
log-slow-max-warnings 10
log-slow-rate-limit 1
log-slow-slave-statements TRUE
log-slow-verbosity
@@ -1655,6 +1675,7 @@ net-buffer-length 16384
net-read-timeout 30
net-retry-count 10
net-write-timeout 60
note-verbosity basic,explain
old FALSE
old-alter-table DEFAULT
old-mode UTF8_IS_UTF8MB3