[MDEV-28902] Error while add a primary key on an empty created table on MariadDB 10.6.1 Created: 2022-06-20  Updated: 2022-08-08  Resolved: 2022-08-08

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.6
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Francesco Rossi Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: None


 Description   

In MariaDB 10.6.1 and other versions when I created a new empty table and tried to add a PK I got this exception:

`> add primary key on table_1 (date, id_a, id_b) ...Exception: SQLSTATE[HY000]: General error: 1194 Table 'table_1' is marked as crashed and should be repaired`

If I do the same thing on a table already created and populated nothing go wrong.

MariaDB runs on a docker container.



 Comments   
Comment by Daniel Black [ 2022-06-21 ]

What is the sequence of statements that ./yii migrate generates that occurs on table_1?

What is the original show create table table_1?

Can you show the container logs?

Comment by Francesco Rossi [ 2022-06-22 ]

if I do the same operation manually I get the same error

Comment by Sergei Golubchik [ 2022-07-03 ]

do you have the table structure? like, what does show create table say?

Comment by Francesco Rossi [ 2022-07-04 ]

CREATE TABLE `table_1` (
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`id_a` int(11) NOT NULL DEFAULT 0,
`id_b` int(11) NOT NULL DEFAULT 0,,
PRIMARY KEY (`id_a`),
) ENGINE=InnoDB DEFAULT CHARSET=latin1

show create table command not work because the execution of creation returns error SQLSTATE[HY000] so the table is not created.

Comment by Sergei Golubchik [ 2022-07-08 ]

Few thoughts:

  • according to last your comment, the table table_1 already has a primary key: PRIMARY KEY (`id_a`), adding a second primary key cannot succeed (although, of course, it should not corrupt the table).
  • 10.6.1 is beta, please try the latest 10.6.8
Generated at Thu Feb 08 10:04:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.