Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20642

Orphan procedure remains in mysql.proc after dropping database

    XMLWordPrintable

    Details

      Description

      The test below runs DROP DATABASE and kills the connection which runs it. Then it runs DROP DATABASE again, to ensure it is really dropped if it hadn't been yet. However, a procedure which was previously created within the dropped database survives and stays in mysql.proc.

      The test is non-deterministic, run with --repeat=N. It currently fails for me every time, but it can vary on different machines and builds.

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (a INT) ENGINE=MEMORY;
      CREATE SCHEMA db;
      CREATE PROCEDURE db.pr() SELECT * FROM test.t1; 
       
      --connect (con1,localhost,root,,test)
      --let $con1_id= `SELECT CONNECTION_ID()`
      --send
        DROP DATABASE db;
       
      --connection default
      SELECT * FROM t1;
      --eval KILL $con1_id
       
      --error 0,ER_BAD_DB_ERROR,ER_SP_DOES_NOT_EXIST
       
      --connection con1
      --error 0,2013
      --reap
      --disconnect con1
      --connection default
      DROP DATABASE IF EXISTS db;
       
      if (`SELECT 1 FROM mysql.proc WHERE db = 'db' AND name = 'pr'`)
      {
        --die # Found orphan procedure db.pr in mysql.proc
      }
       
      # Cleanup
      DROP TABLE test.t1;
      

      10.4 71c57bcf

      DROP DATABASE IF EXISTS db;
      Warnings:
      Note    1008    Can't drop database 'db'; database doesn't exist
      bug.find4 'innodb'                       [ 2 fail ]
              Test ended at 2019-09-21 16:18:44
       
      CURRENT_TEST: bug.find4
      mysqltest: At line 27: # Found orphan procedure db.pr in mysql.proc
      

      Reproducible on all of MariaDB and at least on MySQL 5.7 (8.0 doesn't seem to have mysql.proc).

        Attachments

          Activity

            People

            Assignee:
            sanja Oleksandr Byelkin
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: