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

Remove the THD parameter from sp_head::init_sp_name()

Details

    • Technical task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 10.3.1
    • Stored routines
    • None
    • 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

    Description

      sp_head has its own member MEM_ROOT main_mem_root.
      The caller of sp_head::init_sp_name() currently makes sure to set THD::mem_root to &sphead::main_mem_root, by calling sphead::reset_thd_mem_root(THD*). So the name is effectively created on main_mem_root anyway.

      There is no a need to pass a pointer to THD to init_sp_name(). It's much safer to create the name by allocating memory directly on sp_head::main_mem_root, instead of using its alias THD::mem_root.

      Under terms of this task we'll do the following:

      • Change:

        void init_sp_name(THD *thd, const sp_name *spname);
        

        to

        void init_sp_name(const sp_name *spname);
        

      • Change:

        bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
        

        to

        bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
        

      After this change, the code will be more flexible, as it will be possible to call init_sp_name() without prior call for sp->reset_thd_mem_root(thd).

      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 {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            There is no a need to pass "THD" to init_sp_name().

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass "THD" to init_sp_name(). It's much safer to create name by allocating memory directly on {{&main_mem_root}}, instead of using the alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            bar Alexander Barkov made changes -
            Description {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass "THD" to init_sp_name(). It's much safer to create name by allocating memory directly on {{&main_mem_root}}, instead of using the alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller of {{sp_head::init_sp_name()}} currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}, by calling {{sphead::reset_thd_mem_root(THD*)}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass "THD" to init_sp_name(). It's much safer to create name by allocating memory directly on {{&main_mem_root}}, instead of using the alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            bar Alexander Barkov made changes -
            Description {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller of {{sp_head::init_sp_name()}} currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}, by calling {{sphead::reset_thd_mem_root(THD*)}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass "THD" to init_sp_name(). It's much safer to create name by allocating memory directly on {{&main_mem_root}}, instead of using the alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller of {{sp_head::init_sp_name()}} currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}, by calling {{sphead::reset_thd_mem_root(THD*)}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass a pointer to {{THD}} to {{init_sp_name()}}. It's much safer to create name by allocating memory directly on {{&main_mem_root}}, instead of using the alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            bar Alexander Barkov made changes -
            Description {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller of {{sp_head::init_sp_name()}} currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}, by calling {{sphead::reset_thd_mem_root(THD*)}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass a pointer to {{THD}} to {{init_sp_name()}}. It's much safer to create name by allocating memory directly on {{&main_mem_root}}, instead of using the alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            {{sp_head}} has its own member {{MEM_ROOT main_mem_root}}.
            The caller of {{sp_head::init_sp_name()}} currently makes sure to set {{THD::mem_root}} to {{&sphead::main_mem_root}}, by calling {{sphead::reset_thd_mem_root(THD*)}}. So the name is effectively created on {{main_mem_root}} anyway.

            There is no a need to pass a pointer to {{THD}} to {{init_sp_name()}}. It's much safer to create the name by allocating memory directly on {{sp_head::main_mem_root}}, instead of using its alias {{THD::mem_root}}.

            Under terms of this task we'll do the following:
            - Change:
            {code:cpp}
            void init_sp_name(THD *thd, const sp_name *spname);
            {code}
            to
            {code:cpp}
            void init_sp_name(const sp_name *spname);
            {code}

            - Change:
            {code:cpp}
            bool Database_qualified_name::make_qname(THD *thd, LEX_CSTRING *dst) const;
            {code}
            to
            {code:cpp}
            bool make_qname(MEM_ROOT *mem_root, LEX_CSTRING *dst) const;
            {code}

            After this change, the code will be more flexible, as it will be possible to call {{init_sp_name()}} without prior call for {{sp->reset_thd_mem_root(thd)}}.
            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]

            Pushed to bb-10.2-ext and 10.3

            bar Alexander Barkov added a comment - Pushed to bb-10.2-ext and 10.3
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2017-08-15 13:26:53.0 2017-08-15 13:26:53.447
            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 ]
            bar Alexander Barkov made changes -
            Parent MDEV-10764 [ 57940 ]
            Issue Type Task [ 3 ] Technical task [ 7 ]
            alvinr Alvin Richards (Inactive) made changes -
            Parent MDEV-10764 [ 57940 ] MDEV-10142 [ 56873 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 82097 ] MariaDB v4 [ 152623 ]

            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.