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

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

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            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()}}:
            {code:cpp}
              if (!(table= open_proc_table_for_update(thd)))
              {
                my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(type),sp->m_name.str); -- Via {{sp_head}}
                goto done;
              }
              else
              {
                /* Checking if the routine already exists */
                if (db_find_routine_aux(thd, type, lex->spname, table) == SP_OK) -- Via {{LEX}}
                {
            {cpp}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              if (check_db_name((LEX_STRING*) &lex->sphead->m_db)) -- Via {{sp_head}}
              {
              ...
              if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, -- Via {{LEX}}
                               NULL, NULL, 0, 0))
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            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()}}:
            {code:cpp}
              if (!(table= open_proc_table_for_update(thd)))
              {
                my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(type),sp->m_name.str); -- Via {{sp_head}}
                goto done;
              }
              else
              {
                /* Checking if the routine already exists */
                if (db_find_routine_aux(thd, type, lex->spname, table) == SP_OK) -- Via {{LEX}}
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              if (check_db_name((LEX_STRING*) &lex->sphead->m_db)) -- Via {{sp_head}}
              {
              ...
              if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, -- Via {{LEX}}
                               NULL, NULL, 0, 0))
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            bar Alexander Barkov made changes -
            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()}}:
            {code:cpp}
              if (!(table= open_proc_table_for_update(thd)))
              {
                my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(type),sp->m_name.str); -- Via {{sp_head}}
                goto done;
              }
              else
              {
                /* Checking if the routine already exists */
                if (db_find_routine_aux(thd, type, lex->spname, table) == SP_OK) -- Via {{LEX}}
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              if (check_db_name((LEX_STRING*) &lex->sphead->m_db)) -- Via {{sp_head}}
              {
              ...
              if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, -- Via {{LEX}}
                               NULL, NULL, 0, 0))
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            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()}}:
            {code:cpp}
              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)
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              if (check_db_name((LEX_STRING*) &lex->sphead->m_db))
              {
              ...
              if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str,
                               NULL, NULL, 0, 0))
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            bar Alexander Barkov made changes -
            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()}}:
            {code:cpp}
              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)
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              if (check_db_name((LEX_STRING*) &lex->sphead->m_db))
              {
              ...
              if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str,
                               NULL, NULL, 0, 0))
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            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()}}:
            {code:cpp}
              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)
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              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,
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            bar Alexander Barkov made changes -
            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()}}:
            {code:cpp}
              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)
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              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,
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            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()}}:
            {code:cpp}
              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)
                {
            {code}


            The function {{mysql_create_routine()}} uses the same style:
            {code:cpp}
              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,
              ...
            {code}


            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:
            {code:cpp}
                         if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
                                                             TYPE_ENUM_FUNCTION))
                           MYSQL_YYABORT;
                         Lex->spname= $2;
            {code}


            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}}.

            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2017-07-12 18:55:47.0 2017-07-12 18:55:47.707
            bar Alexander Barkov made changes -
            Fix Version/s 10.3.1 [ 22532 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 81647 ] MariaDB v4 [ 152470 ]

            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.