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

Change Send_field::type from enum_field_types to Type_handler*

    XMLWordPrintable

Details

    Description

      protocol.cc has various tests for MYSQL_TYPE_XXX, for example:

      bool Protocol_text::store(const char *from, size_t length,
                                CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
      {
      #ifndef DBUG_OFF
        DBUG_ASSERT(field_types == 0 ||
      	      field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
                    field_types[field_pos] == MYSQL_TYPE_BIT ||
                    field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL ||
      	      (field_types[field_pos] >= MYSQL_TYPE_ENUM &&
      	       field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
        field_pos++;
      #endif
        return store_string_aux(from, length, fromcs, tocs);
      }
      

      This is not friendly to new/pluggable data types.

      To fix this problem, we'll do the following changes:

      • change Send_field::type from enum_field_type to const Type_handler *
      • add a new enum:

        enum protocol_send_type_t
        {
          PROTOCOL_SEND_STRING,
          PROTOCOL_SEND_FLOAT,
          PROTOCOL_SEND_DOUBLE,
          PROTOCOL_SEND_TINY,
          PROTOCOL_SEND_SHORT,
          PROTOCOL_SEND_LONG,
          PROTOCOL_SEND_LONGLONG,
          PROTOCOL_SEND_DATETIME,
          PROTOCOL_SEND_DATE,
          PROTOCOL_SEND_TIME
        };
        

      • add a new virtual method in Type_handler:

        virtual protocol_send_type_t protocol_send_type() const= 0;
        

      So the ::store() method implementations will simplify to something like:

      bool Protocol_text::store(const char *from, size_t length,
                                CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
      {
      #ifndef DBUG_OFF
        DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING));
        field_pos++;
      #endif
        return store_string_aux(from, length, fromcs, tocs);
      }
      

      New data types will just need to implement a proper virtual implementation of Type_handler_xxx::protocol_send_type().

      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.