[MDEV-30001] mariadb-dump --lock-tables doesn't work with tables that are using sequences. Created: 2022-11-11  Updated: 2022-11-14

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.5
Fix Version/s: 10.5

Type: Bug Priority: Major
Reporter: Michael Widenius Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

mariadb-dump --lock-tables doesn't work with tables that uses sequences.

Here is an example of a dump that one cannot restore:

--
-- Sequence structure for `seq_audittrail`
--
 
DROP SEQUENCE IF EXISTS `seq_audittrail`;
CREATE SEQUENCE `seq_audittrail` start with 0 minvalue 0 maxvalue 9223372036854775806 increment by 1 cache 1 nocycle ENGINE=InnoDB;
SELECT SETVAL(`seq_audittrail`, 3, 0);
 
--
-- Table structure for table `audittrail`
--
 
DROP TABLE IF EXISTS `audittrail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `audittrail` (
  `audittrail_key` bigint(20) unsigned NOT NULL DEFAULT nextval(`foo`.`seq_audittrail`),
  `message` text DEFAULT NULL,
  PRIMARY KEY (`audittrail_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
 
--
-- Dumping data for table `audittrail`
--
 
LOCK TABLES `audittrail` WRITE;
/*!40000 ALTER TABLE `audittrail` DISABLE KEYS */;
INSERT INTO `audittrail` VALUES
(0,'FOO'),
(1,'BAR'),
(2,'BAZ');
/*!40000 ALTER TABLE `audittrail` ENABLE KEYS */;
UNLOCK TABLES;

The fix is to also add any used sequences to the LOCK TABLE


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