Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Do
-
None
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
- relates to
-
MDEV-27684 Spider: remove pattern str->reserve() then str->q_append()
-
- Stalled
-
Activity
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. |
Summary | Introduce new query building helper | Add new query building helper function |
Fix Version/s | 10.8 [ 26121 ] | |
Fix Version/s | 10.7 [ 24805 ] |
Assignee | Nayuta Yanagisawa [ JIRAUSER47117 ] |
Assignee | Nayuta Yanagisawa [ JIRAUSER47117 ] |
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. |
Fix Version/s | N/A [ 14700 ] | |
Fix Version/s | 10.8 [ 26121 ] | |
Resolution | Won't Do [ 10201 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 124346 ] | MariaDB v4 [ 134462 ] |
Resolution | Won't Do [ 10201 ] | |
Status | Closed [ 6 ] | Stalled [ 10000 ] |
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) |
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) |
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. |
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. |
Summary | Use spider_string::append(str) rather than spider_string::q_append(str, str_len) | Spider: add new query building helper function |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Resolution | Fixed [ 1 ] | |
Status | Closed [ 6 ] | Stalled [ 10000 ] |
Resolution | Won't Do [ 10201 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link | This issue relates to MDEV-27684 [ MDEV-27684 ] |
The spider_string class already has such a function but the function seems to be used in nowhere.
) {
DBUG_ASSERT(mem_calc_inited);
DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
current_alloc_mem == str.alloced_length());
SPIDER_STRING_CALC_MEM;
DBUG_RETURN(res);
}