[MDEV-25932] Error 1054 on DROP INDEX for tables having virtual column and view referencing it Created: 2021-06-15  Updated: 2021-06-15  Resolved: 2021-06-15

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - InnoDB
Affects Version/s: 10.2.38, 10.3.29, 10.4.19, 10.5.10
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Stefan Seide Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-25672 table alias from previous statement i... Closed

 Description   

To reproduce create an empty database with the following tables. The tables do not need to contain any data, empty tables are enough. It is important to create the view too, without this view its working.
After tables and the view are created the `DROP INDEX` statement fails with the following error:

SQL State  : 42S22
Error Code : 1054
Message    : (conn=63) Unknown column '`omega_label`.`du`.`sessionId`' in 'GENERATED ALWAYS'
Statement  : DROP INDEX uttUser ON dialog_utterances

minimum SQL statements to reproduce:

CREATE TABLE IF NOT EXISTS `dialog_utterances` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT,
   `sessionId` char(40) NOT NULL,
   `messageNo` smallint NOT NULL,
   `conversationUUID` varchar(50) AS (CONCAT(sessionId, '#', messageNo)) VIRTUAL,
   `uttUser` varchar(300) DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY (uttUser(191)),
   UNIQUE KEY (`sessionId`, `messageNo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
 
CREATE TABLE IF NOT EXISTS `dialog_tags` (
     `tagId` bigint(20) NOT NULL,
     `dialogId` bigint(20) NOT NULL,
     PRIMARY KEY (`tagId`, `dialogId`),
     FOREIGN KEY fk_dialog_tags__dialog_utterances (dialogId) references `dialog_utterances` (id) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
 
CREATE TABLE IF NOT EXISTS `tags` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tag` varchar(191) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci AUTO_INCREMENT=100;
 
CREATE OR REPLACE VIEW `dialog_tags_view` AS
select dt.*, du.uttUser, t.tag
from dialog_tags dt
     join dialog_utterances du
          on dt.dialogId = du.id
     join tags t
          on dt.tagId = t.id;
 
DROP INDEX uttUser ON dialog_utterances;

This error happens only with latest versions from the component tags. All versions before (tested 10.2.37 / 10.3.28 / 10.4.18) are not affected.

All versions tested with docker images from docker hub or local installation on Ubuntu linux.

I stripped down our own sql migration statements to this 5 steatements. With them i am able to reproduce it on every run.



 Comments   
Comment by Alice Sherepa [ 2021-06-15 ]

Thanks for the report!
It is the same bug as MDEV-25672

Comment by Stefan Seide [ 2021-06-15 ]

Thanks for looking into it - i was not able to correlate these two as there is no UPDATE involved here and no error code given there. Seemed to be to different from their user visible outcome.

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