Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10142 PL/SQL parser
  3. MDEV-13302

Avoid using LEX::spname during CREATE PROCEDURE and CREATE FUNCTION

    XMLWordPrintable

Details

    • 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

    Description

      The code in sp_create_routine() uses two ways to access the routine name:

      • Via sp_head: sp->m_db and sp->m_name
      • Via LEX: lex->spname

      This is a fragment from sp_create_routine():

        if (!(table= open_proc_table_for_update(thd)))
        {
          my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(type),sp->m_name.str)
          goto done;
        }
        else
        {   
          /* Checking if the routine already exists */
          if (db_find_routine_aux(thd, type, lex->spname, table) == SP_OK)
          {
      

      The function mysql_create_routine() uses the same style:

        if (check_db_name((LEX_STRING*) &lex->sphead->m_db))  
        {
        ...
          if (lex->create_info.or_replace())
        {
          if (check_routine_access(thd, ALTER_PROC_ACL, lex->spname->m_db.str,
        ...
      

      In the above code, both LEX::sp_name and sp_sphead point to copies of the same qualified routine name. Copying is done in sql_yacc.yy:

                   if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                       TYPE_ENUM_FUNCTION))
                     MYSQL_YYABORT;
                   Lex->spname= $2;
      

      We're going to reuse sp_head to store Oracle-style packages soon (see MDEV-10591).
      To avoid duplicating of this redundancy, we should get rid of it before implementing packages.

      Under terms of this task we will:
      1. Fix the code responsible for CREATE PROCEDURE and CREATE FUNCTION not to use lex->spname, and to use sphead instead. This includes functions:

      • mysql_create_routine()
      • sp_create_routine()

      2. Remove copying of the routine name to LEX::spname. The latter should stay NULL during CREATE PROCEDURE and CREATE FUNCTION.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.