[MDEV-25733] Select with table name alias prevents foreign key deletion Created: 2021-05-19  Updated: 2021-05-20  Resolved: 2021-05-19

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

Type: Bug Priority: Major
Reporter: Niels Buwen Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

fresh docker container maradb:10.3.29 or dbfiddle with mariadb 10.3


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

 Description   

This is a minimal example that triggers the error

    CREATE TABLE A (
      id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY
    );
    
    CREATE TABLE B (
      what tinyint NOT NULL,
    
      a bigint NOT NULL,
    
      CONSTRAINT x FOREIGN KEY (a) REFERENCES A(id),
      CONSTRAINT y CHECK (what > 0)
    );
    
    
    SELECT b.a FROM B b;
    
    ALTER TABLE B DROP CONSTRAINT x;}}

When i run this in a fresh MariaDB instance (docker mariadb:10.3.28) everything works fine.

When MariaDB 10.3.29 was released the query suddenly broke. So, when i run this in a fresh MariaDB instance (docker mariadb:10.3.29) i get the following error message for the last statement:

[42S22][1054] (conn=8) Unknown column '`db`.`b`.`what`' in 'CHECK'

Some weird observations:

  • if i delete the y check and add it after dropping x everything works
  • if i remove the SELECT everything works
  • if i remove the alias `b` from the `SELECT` statement everything works
  • the b from the error message changes with the table alias from the SELECT statement
  • running the last statement again shows the same error
  • the error message makes no sense at all

I initially posted this on stackexchange https://dba.stackexchange.com/questions/291842/mariddb-10-3-29-prevents-me-from-deleting-a-foreign-key



 Comments   
Comment by Alice Sherepa [ 2021-05-19 ]

This is the same bug as MDEV-25672, so I will close this one for now. please use FLUSH TABLES as a temporary workaround

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