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

Rework MDL enum constants values

    XMLWordPrintable

Details

    Description

      MDL constants values of 0 assign some default values (MDL_INTENTION_EXCLUSIVE, BACKUP) before MDL_REQUEST_INIT(). That does not make sense if MDL_REQUEST_INIT() was not called. Please rework the values of 0 into (MDL_NOT_INITIALIZED, NOT_INITIALIZED). Described by these comments in the code:

      --- sql/mdl.h
      +++ sql/mdl.h
      @@ -125,6 +125,11 @@ class MDL_context_owner
       
       enum enum_mdl_type {
         /* This means that the MDL_request is not initialized */
      +  /*
      +    TODO (newbie): should be MDL_NOT_INITIALIZED= 0, as it is strange
      +    that not-inited request has MDL_INTENTION_EXCLUSIVE.
      +    Must fix tests, as at least mysql_rm_table_no_locks() depends on this.
      +  */
         MDL_NOT_INITIALIZED= -1,
         /*
           An intention exclusive metadata lock (IX). Used only for scoped locks.
      @@ -381,6 +386,10 @@ struct MDL_key
           Note that although there isn't metadata locking on triggers,
           it's necessary to have a separate namespace for them since
           MDL_key is also used outside of the MDL subsystem.
      +
      +    TODO (newbie): NOT_INITIALIZED=0 as default bzero() sets wrongly type to
      +    BACKUP. But dozens switch() cases for NOT_INITIALIZED must be added to
      +    pacify the compiler.
         */
         enum enum_mdl_namespace { BACKUP=0,
                                   SCHEMA,
      

      Also after fix this hunk should be reverted:

      --- sql/sql_parse.cc
      +++ sql/sql_parse.cc
      @@ -8509,6 +8509,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
           MDL_REQUEST_INIT(&ptr->mdl_request, MDL_key::TABLE, ptr->db.str,
                            ptr->table_name.str, mdl_type, MDL_TRANSACTION);
         }
      +  else
      +    ptr->mdl_request.type= MDL_NOT_INITIALIZED;
         DBUG_RETURN(ptr);
       }
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              midenok Aleksey Midenkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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