[MDEV-29727] ALTER and CREATE with default partitioning differently react to SQL_MODE => unusable SHOW CREATE Created: 2022-10-06  Updated: 2023-08-01  Resolved: 2023-07-27

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
causes MDEV-31822 ALTER TABLE ENGINE=x started failing ... Closed

 Description   

With default SQL_MODE (which includes STRICT_TRANS_TABLES in all affected versions):

--source include/have_partition.inc
 
create table t (a int) with system versioning;
alter table t partition by system_time partitions 3;
 
show create table t;
--let $show= query_get_value(show create table t, 'Create Table', 1)
 
drop table t;
--eval $show
 
# Cleanup
drop table if exists t;

10.5

MariaDB [test]> create table t (a int) with system versioning;
Query OK, 0 rows affected (0.033 sec)
 
MariaDB [test]> alter table t partition by system_time partitions 3;
Query OK, 0 rows affected, 1 warning (0.084 sec)   
Records: 0  Duplicates: 0  Warnings: 1
 
MariaDB [test]> show warnings;
+---------+------+----------------------------------------------------------------------------------+
| Level   | Code | Message                                                                          |
+---------+------+----------------------------------------------------------------------------------+
| Warning | 4115 | Maybe missing parameters: no rotation condition for multiple HISTORY partitions. |
+---------+------+----------------------------------------------------------------------------------+
1 row in set (0.000 sec)

So, ALTER produces a warning, but still partitions the table:

MariaDB [test]> show create table t;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                        |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
 PARTITION BY SYSTEM_TIME 
PARTITIONS 3 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.023 sec)

Attempt to re-run this CREATE TABLE however leads to an error:

MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.040 sec)
 
MariaDB [test]> CREATE TABLE `t` (
    ->   `a` int(11) DEFAULT NULL
    -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
    ->  PARTITION BY SYSTEM_TIME 
    -> PARTITIONS 3;
ERROR 4115 (HY000): Maybe missing parameters: no rotation condition for multiple HISTORY partitions.

Unsetting strict SQL mode makes it a warning again (notoriously, STRICT_TRANS_TABLES affects it, regardless whether it's InnoDB or MyISAM).



 Comments   
Comment by Aleksey Midenkov [ 2023-07-24 ]

Please review bb-10.5-midenok

Comment by Nikita Malyavin [ 2023-07-26 ]

ok to push

Generated at Thu Feb 08 10:10:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.