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

Turn Field::flags from a member to a method

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Do
    • N/A
    • Data types
    • None

    Description

      Note: this patch was reverted from 10.5 on Monty's request.
      It makes the engine code incompatible between 10.5 and earlier versions.

      Old description

      We should eventually split numeric type handlers into separate signed and unsigned variants. This is needed for function collection plugins, to define function prototypes easier.

      For example, instead of Type_handler_longlong there should be Type_handler_slonglong and Type_handler_ulonglong.

      In order to do this easier, let's change Field::flags and Column_definition::flags from a member to:

      uint32 flags;
      

      a method:

      uint32 flags() const;
      

      To share the code between Field and Column_definition, let's add a new class:

      class Column_cached_flags
      {
        uint32 m_flags;
      public:
        Column_cached_flags(uint32 flags)
         :m_flags(flags)
        { }
        void set_flags(uint32 flags) { m_flags= flags; }
        void add_flags(uint32 flags) { m_flags|= flags; }
        void clear_flags(uint32 flags) { m_flags&= ~flags; }
        void mask_flags(uint32 flags) { m_flags&= flags; }
        void swap_flags(Column_cached_flags *other)
        {
          swap_variables(uint32, m_flags, other->m_flags);
        }
        uint32 cached_flags() const { return m_flags; }
      };
      

      and derive Field and Column definition from it.

      Field::flags() and Column_definition::flags() will do something like this:

      uint32 flags() cosnst
      {
        return Cached_column_flags::cached_flags() | type_handler()->flags();
      }
      

      where type_handler()->flags() will be a new method in Type_handler:

      virtual uint32 flags() const { return 0; }
      

      Type_handler descendants will override the default implementation and will return data type specific flags:

      • ENUM_FLAG
      • SET_FLAG
      • BLOB_FLAG
      • UNSIGNED_FLAG

      or their combination when necessary.

      Note, under terms of this task will change only ENUM_FLAG, SET_FLAG and BLOB_FLAG to Type_handler::flags().

      UNSIGNED_FLAG will be moved to Type_handler::flags() later, under terms of a separate task.

      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.