[MDEV-27704] Unclear error message when dropping a period defined using WITHOUT OVERLAPS Created: 2021-10-29  Updated: 2022-02-01

Status: Open
Project: MariaDB Server
Component/s: Versioned Tables
Affects Version/s: 10.6
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-16975 Application-time periods: ALTER TABLE Closed

 Description   

When dropping a period for an application-time period table defined using WITHOUT OVERLAPS, the associated index must be dropped as part of the same operation. If the index is not dropped, the operation results in an error.

This behavior probably makes sense, but the current error message is not very clear:

MariaDB [test]> ALTER TABLE coupons_wo_overlaps
    ->    DROP PERIOD FOR valid_period;
ERROR 4156 (HY000): Period `valid_period` is not found in table

I would think that a better error message might be something like:

Period %s cannot be dropped from table unless index %s is dropped

To reproduce:

CREATE TABLE coupons_wo_overlaps (
   id SERIAL PRIMARY KEY,
   name VARCHAR(255),
   type ENUM('Monthly Special', 'Seasonal Sale') DEFAULT 'Monthly Special',
   code VARCHAR(255),
   date_start DATETIME,
   date_end DATETIME,
   PERIOD FOR valid_period(date_start, date_end),
   UNIQUE KEY (name, valid_period WITHOUT OVERLAPS)
);
 
SHOW CREATE TABLE coupons_wo_overlaps\G
 
ALTER TABLE coupons_wo_overlaps
   DROP PERIOD FOR valid_period;
   
ALTER TABLE coupons_wo_overlaps
   DROP PERIOD FOR valid_period,
   DROP INDEX name;


Generated at Thu Feb 08 09:54:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.