1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-11 15:22:09 +03:00
Commit Graph

3075 Commits

Author SHA1 Message Date
32d88faec5 MDEV-25292 Refactoring: removed TABLEOP_HOOKS
TABLEOP_HOOKS is a strange interface: proxy interface calls virtual
interface. Since it is used only for select_create::prepare() such
complexity is overwhelming.
2022-08-31 11:55:03 +03:00
f02af1d229 MDEV-25292 Refactoring: moved select_field_count into Alter_info.
There is a need in MDEV-25292 to have both C_ALTER_TABLE and
select_field_count in one call. Semantically creation mode and field
count are two different things. Making creation mode negative
constants and field count positive variable into one parameter seems
to be a lazy hack for not making the second parameter.

select_count does not make sense without alter_info->create_list, so
the natural way is to hold it in Alter_info too. select_count is now
stored in member select_field_count.
2022-08-31 11:55:02 +03:00
c38b8f49b8 cleanup: consolidate binlog-related THD::*_used into one bitmap 2022-08-10 15:03:10 +02:00
22d455612b Merge branch '10.8' into 10.9 2022-08-09 09:57:13 +02:00
564d374704 Merge branch '10.8' into 10.9 2022-08-08 17:17:45 +02:00
1d48041982 Merge branch '10.6' into 10.7 2022-08-08 17:12:32 +02:00
3ebbfd88a0 MDEV-29159 Patch for MDEV-28918 introduces more inconsistency than it solves, breaks usability
1. Store assignment failures on incompatible data types now raise errors if:
- STRICT_ALL_TABLES or STRICT_TRANS_TABLES sql_mode is used, and
- IGNORE is not used

Otherwise, only a warning is raised and the statement continues.

2. Changing the error/warning test as follows:

-ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET'
+ERROR HY000: Cannot cast 'int' as 'inet6' in assignment of `db`.`t`.`col`

so in case of a big table it's easier to see which column has the problem.
The new error text is also applied to SP variables.
2022-08-05 22:23:40 +04:00
d2f1c3ed6c Merge branch '10.5' into bb-10.6-release 2022-08-03 12:19:59 +02:00
4e3728f038 MDEV-29225 make explicit_defaults_for_timestamps SESSION variable
make @@explicit_defaults_for_timestamp session variable
2022-08-02 18:05:32 +02:00
f53f64b7b9 Merge 10.8 into 10.9 2022-07-28 10:47:33 +03:00
742e1c727f Merge 10.6 into 10.7 2022-07-27 18:26:21 +03:00
30914389fe Merge 10.5 into 10.6 2022-07-27 17:52:37 +03:00
098c0f2634 Merge 10.4 into 10.5 2022-07-27 17:17:24 +03:00
3bb36e9495 Merge branch '10.3' into 10.4 2022-07-27 11:02:57 +02:00
8911823f65 MDEV-26546 SIGSEGV's in spider_db_connect on SHOW TABLE and spider_db… …_mbase::connect (and SIGSEGV's in check_vcol_forward_refs and inline_mysql_mutex_lock)
Not the SPIDER issue - happens to INSERT DELAYED.
the field::make_new_field does't copy the LONG_UNIQUE_HASH_FIELD
flag to the new field. Though the Delayed_insert::get_local_table
copies the field->vcol_info for this field. Ad a result
the parse_vcol_defs doesn't create the expression for that column
so the field->vcol_info->expr is NULL. Which leads to crash.
Backported fix for this from 10.5 - the flagg added in the
Delayed_insert::get_local_table.

Another problem with the USING HASH key is thst the
parse_vcol_defs modifies the table->keys content. Then the same
parse_vcol_defs is called on the table copy that has keys already
modified. Backported fix for that from 10.5 - key copying added
tot the Delayed_insert::get_local_table.

Finally - the created copy has to clear the expr_arena as
this table is not in the thd->open_tables list so won't be
cleared automatically.
2022-07-17 01:10:43 +04:00
49e14000ee MDEV-26427 MariaDB Server SEGV on INSERT .. SELECT
1. For INSERT..SELECT statements: don't include table/view the data
   is inserted into in the list of leaf tables
2. Remove duplicated and dead code related to table_count
2022-07-14 11:07:24 +07:00
404d4820af Merge 10.8 into 10.9 2022-06-28 10:59:01 +03:00
0bed4d72c0 MDEV-28918 Implicit cast from INET6 UNSIGNED works differently on UPDATE vs ALTER
Now INSERT, UPDATE, ALTER statements involving incompatible data type pairs, e.g.:

    UPDATE TABLE t1 SET col_inet6=col_int;
    INSERT INTO t1 (col_inet6) SELECT col_in FROM t2;
    ALTER TABLE t1 MODIFY col_inet6 INT;

consistently return an error at the statement preparation time:

    ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET'

and abort the statement before starting interating rows.

This error is the same with what is raised for queries like:
    SELECT col_inet6 FROM t1 UNION SELECT col_int FROM t2;
    SELECT COALESCE(col_inet6, col_int) FROM t1;

Before this change the error was caught only during the execution time,
when a Field_xxx::store_xxx() was called for the very firts row.
The behavior was not consistent between various statements and could do different things:
- abort the statement
- set a column to the data type default value (e.g. '::' for INET6)
- set a column to NULL

A typical old error was:

    ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`a` at row 1

EXCEPTION:

Note, there is an exception: a multi-row INSERT..VALUES, e.g.:
    INSERT INTO t1 (col_a,col_b) VALUES (a1,b1),(a2,b2);
checks assignment compability at the preparation time for the very first row only:
    (col_a,col_b) vs (a1,b1)

Other rows are still checked at the execution time and return the old warnings
or errors in case of a failure. This is done because catching all rows at the
preparation time would change behavior significantly. So it still works
according to the STRICT_XXX_TABLES sql_mode flags and the table transaction ability.

This is too late to change this behavior in 10.7.
There is no a firm decision yet if a multi-row INSERT..VALUES
behavior will change in later versions.
2022-06-27 12:49:40 +04:00
bf2bdd1a1a Merge branch '10.8' into 10.9 2022-05-19 14:07:55 +02:00
fd132be117 Merge branch '10.6' into 10.7 2022-05-11 11:25:33 +02:00
3bc98a4ec4 Merge branch '10.5' into 10.6 2022-05-10 14:01:23 +02:00
ef781162ff Merge branch '10.4' into 10.5 2022-05-09 22:04:06 +02:00
a70a1cf3f4 Merge branch '10.3' into 10.4 2022-05-08 23:03:08 +02:00
6f741eb6e4 Merge branch '10.2' into 10.3 2022-05-07 11:48:15 +02:00
a5dc12eefd MDEV-28310 Missing binlog data for INSERT .. ON DUPLICATE KEY UPDATE
MDEV-21810 MBR: Unexpected "Unsafe statement" warning for unsafe IODKU

MDEV-17614 fixes to replication unsafety for INSERT ON DUP KEY UPDATE
on two or more unique key table left a flaw. The fixes checked the
safety condition per each inserted record with the idea to catch a user-created
value to an autoincrement column and when that succeeds the autoincrement column
would become the source of unsafety too.
It was not expected that after a duplicate error the next record's
write_set may become different and the unsafe decision for that
specific record will be computed to screw the Query's binlogging
state and when @@binlog_format is MIXED nothing gets bin-logged.

This case has been already fixed in 10.5.2 by 91ab42a823 that
relocated/optimized THD::decide_logging_format_low() out of the record insert
loop. The safety decision is computed once and at the right time.
Pertinent parts of the commit are cherry-picked.

Also a spurious warning about unsafety is removed when MIXED
@@binlog_format; original MDEV-17614 test result corrected.
The original test of MDEV-17614 is extended and made more readable.
2022-05-06 22:16:42 +03:00
706a8232da MDEV-25477 Auto-create breaks replication when triggering event was not replicated
If UPDATE/DELETE does not change data it is skipped from
replication. We now force replication of such events when they trigger
partition auto-creation.

For ROLLBACK it is as simple as set OPTION_KEEP_LOG
flag. trans_cannot_safely_rollback() does the rest.

For UPDATE/DELETE .. LIMIT 0 we make additional binlog_query() calls
at the early points of return.

As a safety measure we also convert row format into statement if it is
needed. The condition is decided by
binlog_need_stmt_format(). Basically if there are some row events in
cache we don't need that: table open of row event will trigger
auto-creation anyway.

Multi-update/delete works via mysql_select(). There is no early points
of return, so binlogging is always checked by
send_eof()/abort_resultset(). But we must comply with the above
measure of converting into statement.
2022-05-06 15:11:02 +03:00
93e64d1f58 cleanup: log_current_statement and OPTION_KEEP_LOG
rename OPTION_KEEP_LOG -> OPTION_BINLOG_THIS_TRX.
    Meaning: transaction cache will be written to binlog even on rollback.

    convert log_current_statement to OPTION_BINLOG_THIS_STMT.
    Meaning: the statement will be written to binlog (or trx binlog cache)
    even if it normally wouldn't be.

    setting OPTION_BINLOG_THIS_STMT must always set OPTION_BINLOG_THIS_TRX,
    otherwise the statement won't be logged if the transaction is rolled back.
    Use OPTION_BINLOG_THIS to set both.
2022-05-06 10:45:17 +03:00
9ed8deb656 Merge branch '10.6' into 10.7 2022-02-04 14:11:46 +01:00
f5c5f8e41e Merge branch '10.5' into 10.6 2022-02-03 17:01:31 +01:00
cf63eecef4 Merge branch '10.4' into 10.5 2022-02-01 20:33:04 +01:00
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
d7af7bfc2b Merge 10.6 into 10.7 2021-10-28 09:14:51 +03:00
d8c6c53a06 Merge 10.5 into 10.6 2021-10-28 09:08:58 +03:00
a8ded39557 Merge 10.4 into 10.5 2021-10-28 08:48:36 +03:00
3a79e5fd31 Merge 10.3 into 10.4 2021-10-28 08:28:39 +03:00
657bcf928e Merge 10.2 into 10.3 2021-10-28 07:50:05 +03:00
e13dc7d0d0 MDEV-26830: Wrong ROW_NUMBER in diagnostics upon INSERT IGNORE with
CHECK violation

Analysis: When there is constraint fail we return non-zero value for
view_check_option(). So we continue the loop which doesn't increment the
counter because it increments at the end of the loop.
Fix: Increment m_current_row_for_warning() at the beginning of loop. This
will also fix similar bugs if any, about counter not incrementing
correctly because of continue.
2021-10-26 17:29:40 +02:00
797bd73cfa MDEV-26841: ROW_NUMBER is not set and differs from the message upon
ER_WRONG_VALUE_COUNT_ON_ROW for the 1st row

Analysis: Current row for warning does not increment for prepare phase
Fix: Increment current row for warning if number of fields in the table and
row values dont match and number of values in rows is greater than number
of fields
2021-10-26 17:29:40 +02:00
5c0b63458b MDEV-26693 ROW_NUMBER is wrong upon INSERT or UPDATE on Spider table
in case of a bulk insert the server sends all rows to the engine, and
then the engine replies that there was ER_DUP_ENTRY somewhere.

the exact number of the row that caused the error is unknown.
2021-10-26 17:29:40 +02:00
a398fcbff6 MDEV-26635 ROW_NUMBER is not 0 for errors not caused because of rows 2021-10-26 17:29:40 +02:00
6211c35549 MDEV-23391 Crash/assertion CREATE OR REPLACE TABLE AS SELECT under LOCK TABLE
Happens with Innodb engine.

Move unlock_locked_table() past drop_open_table(), and
rollback current statement, so that we can actually unlock the table.

Anything else results in assertions, in drop, or unlock, or in close_table.
2021-10-26 14:33:07 +02:00
b4911f5a34 Merge 10.6 into 10.7 2021-10-13 16:37:12 +03:00
a8379e53e8 Merge 10.5 into 10.6
The changes to galera.galear_var_replicate_myisam_on
in commit d9b933bec6
are omitted due to conflicts
with commit 27d66d644c.
2021-10-13 13:28:12 +03:00
99bb3fb656 Merge 10.4 into 10.5 2021-10-13 12:33:56 +03:00
a736a3174a Merge 10.3 into 10.4 2021-10-13 12:03:32 +03:00
4a7dfda373 Merge 10.2 into 10.3 2021-10-13 11:38:21 +03:00
8f04ec2885 MDEV-25925 Warning: Memory not freed: 32 on INSERT DELAYED
Also fixes MDEV-24467 Memory not freed after failed INSERT DELAYED

Description:

In case of an error (e.g. data truncation) during mysql_insert()
handling an INSERT DELAYED, the data type specific data in
fields (e.g. Field_blob::value) is not taken over by the delayed
writer thread.

All fields in table_list->table are freed by free_root()
immediately after mysql_insert(). To avoid a memory leak,
we need to free the specific data before exiting mysql_insert()
on error.
2021-10-11 18:03:42 +04:00
25921c997e Merge 10.6 into 10.7 2021-10-06 10:28:59 +03:00
41c66ef6f7 Merge 10.5 into 10.6 2021-10-06 10:28:07 +03:00
4eb7217ec3 Merge 10.4 into 10.5 2021-10-06 09:45:12 +03:00