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

Spider: add new query building helper function

Details

    Description

      We do see the following anywhere in the Spider codebase.

      if (str->reserve(SPIDER_SQL_WHERE_LEN))
        DBUG_RETURN(HA_ERR_OUT_OF_MEM);
      str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
      

      This is messy and makes the code less readable. It would be better if we could write like this:

      if (int err = str->append(SPIDER_SQL_WHERE_STR))
        DBUG_RETURN(err);
       
      // multiple string can be appended at once
      if (int err = str->append(SPIDER_SQL_IN_STR, SPIDER_SQL_OPEN_PAREN_STR))
        DBUG_RETURN(err);
      

      The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.

      Attachments

        Issue Links

          Activity

            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) created issue -
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Field Original Value New Value
            Description We do like the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable. It would be better if we could write like this:

            {code:cpp}
            if (int err = str->append(SPIDER_SQL_WHERE_STR))
              DBUG_RETURN(err);
            {code}

            The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.
            We do like the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable. It would be better if we could write like this:

            {code:cpp}
            if (int err = str->append(SPIDER_SQL_WHERE_STR))
              DBUG_RETURN(err);

            // multiple string can be appended at once
            if (int err = str->append(SPIDER_SQL_IN_STR, SPIDER_SQL_OPEN_PAREN_STR))
              DBUG_RETURN(err);
            {code}

            The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Summary Introduce new query building helper Add new query building helper function
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.8 [ 26121 ]
            Fix Version/s 10.7 [ 24805 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Assignee Nayuta Yanagisawa [ JIRAUSER47117 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Assignee Nayuta Yanagisawa [ JIRAUSER47117 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Description We do like the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable. It would be better if we could write like this:

            {code:cpp}
            if (int err = str->append(SPIDER_SQL_WHERE_STR))
              DBUG_RETURN(err);

            // multiple string can be appended at once
            if (int err = str->append(SPIDER_SQL_IN_STR, SPIDER_SQL_OPEN_PAREN_STR))
              DBUG_RETURN(err);
            {code}

            The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.
            We do see the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable. It would be better if we could write like this:

            {code:cpp}
            if (int err = str->append(SPIDER_SQL_WHERE_STR))
              DBUG_RETURN(err);

            // multiple string can be appended at once
            if (int err = str->append(SPIDER_SQL_IN_STR, SPIDER_SQL_OPEN_PAREN_STR))
              DBUG_RETURN(err);
            {code}

            The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.

            The spider_string class already has such a function but the function seems to be used in nowhere.

            bool spider_string::append(
              const char *s
            ) {
              DBUG_ENTER("spider_string::append");
              DBUG_PRINT("info",("spider this=%p", this));
              DBUG_ASSERT(mem_calc_inited);
              DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
                current_alloc_mem == str.alloced_length());
              bool res = str.append(s, strlen(s));
              SPIDER_STRING_CALC_MEM;
              DBUG_RETURN(res);
            }
            

            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - - edited The spider_string class already has such a function but the function seems to be used in nowhere. bool spider_string::append( const char *s ) { DBUG_ENTER( "spider_string::append" ); DBUG_PRINT( "info" ,( "spider this=%p" , this )); DBUG_ASSERT(mem_calc_inited); DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) || current_alloc_mem == str.alloced_length()); bool res = str.append(s, strlen (s)); SPIDER_STRING_CALC_MEM; DBUG_RETURN(res); }
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Fix Version/s N/A [ 14700 ]
            Fix Version/s 10.8 [ 26121 ]
            Resolution Won't Do [ 10201 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 124346 ] MariaDB v4 [ 134462 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Resolution Won't Do [ 10201 ]
            Status Closed [ 6 ] Stalled [ 10000 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Summary Add new query building helper function Use spider_string::append(const char *s ) rather than spider_string::q_append(const char *data, uint32 data_len)
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Summary Use spider_string::append(const char *s ) rather than spider_string::q_append(const char *data, uint32 data_len) Use spider_string::append(str) rather than spider_string::q_append(str, str_len)
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Description We do see the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable. It would be better if we could write like this:

            {code:cpp}
            if (int err = str->append(SPIDER_SQL_WHERE_STR))
              DBUG_RETURN(err);

            // multiple string can be appended at once
            if (int err = str->append(SPIDER_SQL_IN_STR, SPIDER_SQL_OPEN_PAREN_STR))
              DBUG_RETURN(err);
            {code}

            The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.
            We do see the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable.
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Description We do see the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable.
            We do see the following anywhere in the Spider codebase.

            {code:cpp}
            if (str->reserve(SPIDER_SQL_WHERE_LEN))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
            str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
            {code}

            This is messy and makes the code less readable. It would be better if we could write like this:

            {code:cpp}
            if (int err = str->append(SPIDER_SQL_WHERE_STR))
              DBUG_RETURN(err);

            // multiple string can be appended at once
            if (int err = str->append(SPIDER_SQL_IN_STR, SPIDER_SQL_OPEN_PAREN_STR))
              DBUG_RETURN(err);
            {code}

            The memory allocation should be automatically done in the append function. This automatic memory allocation should care about the performance. Possibly, it would allocate extra memory and reallocate memory only when it is necessary.
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Summary Use spider_string::append(str) rather than spider_string::q_append(str, str_len) Spider: add new query building helper function
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Resolution Fixed [ 1 ]
            Status Closed [ 6 ] Stalled [ 10000 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Resolution Won't Do [ 10201 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -

            People

              nayuta-yanagisawa Nayuta Yanagisawa (Inactive)
              nayuta-yanagisawa Nayuta Yanagisawa (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.