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

Wrong default value for foreign_key_checks variable

    XMLWordPrintable

Details

    Description

      Reproduce

      select @@foreign_key_checks;
      set foreign_key_checks= default;
      select @@foreign_key_checks;
      

      Result

      select @@foreign_key_checks;
      @@foreign_key_checks
      1
      set foreign_key_checks= default;
      select @@foreign_key_checks;
      @@foreign_key_checks
      0
      

      Expected

      foreign_key_checks has default value of 1

      Tests affected

      innodb.foreign_key

      Cause

      session_save_default() ignores reverse_semantics setting:

      ++
      1852      void session_save_default(THD *thd, set_var *var)
      1853      { var->save_result.ulonglong_value= global_var(ulonglong) & bitmask; }
      

      global_var(ulonglong) has OPTION_NO_FOREIGN_KEY_CHECKS bit 0.
      var->save_result.ulonglong_value has foreign_key_checks semantics!

      Then:

      ++
      1809    class Sys_var_bit: public Sys_var_typelib
      1810    {
      1811      ulonglong bitmask;
      1812      bool reverse_semantics;
      1813      void set(uchar *ptr, ulonglong value)
      1814      {
      1815        if ((value != 0) ^ reverse_semantics)
      1816          (*(ulonglong *)ptr)|= bitmask;
      1817        else
      1818          (*(ulonglong *)ptr)&= ~bitmask;
      1819      }
      

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              midenok Aleksey Midenkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.