diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2018-11-13 09:12:55 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-09-30 12:11:37 +0200 |
commit | 98e62e631706f982a6b0e3a63909fa96f98aac5a (patch) | |
tree | d445f4a2d951c3b0c03dc31e9761aa90c6b3f00c | |
parent | 1f51d6c0f6527324dfe7c066fc60fc2292ea7e11 (diff) | |
download | mariadb-git-98e62e631706f982a6b0e3a63909fa96f98aac5a.tar.gz |
Better declaration of the buffer size
-rw-r--r-- | sql/sql_view.cc | 14 | ||||
-rw-r--r-- | sql/table.h | 7 |
2 files changed, 13 insertions, 8 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index d8b68725f3e..b0b4b075046 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -843,13 +843,13 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum, swap_alg= 0; if (wrong_checksum) { - if (view->md5.length != 32) + if (view->md5.length != VIEW_MD5_LEN) { - if ((view->md5.str= (char *)thd->alloc(32 + 1)) == NULL) + if ((view->md5.str= (char *)thd->alloc(VIEW_MD5_LEN + 1)) == NULL) DBUG_RETURN(HA_ADMIN_FAILED); } view->calc_md5(const_cast<char*>(view->md5.str)); - view->md5.length= 32; + view->md5.length= VIEW_MD5_LEN; } view->mariadb_version= MYSQL_VERSION_ID; @@ -972,13 +972,13 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, view->file_version= 2; view->mariadb_version= MYSQL_VERSION_ID; view->calc_md5(md5); - if (!(view->md5.str= (char*) thd->memdup(md5, 32))) + if (!(view->md5.str= (char*) thd->memdup(md5, VIEW_MD5_LEN))) { my_error(ER_OUT_OF_RESOURCES, MYF(0)); error= -1; goto err; } - view->md5.length= 32; + view->md5.length= VIEW_MD5_LEN; can_be_merged= lex->can_be_merged(); if (lex->create_view->algorithm == VIEW_ALGORITHM_MERGE && !lex->can_be_merged()) @@ -2093,10 +2093,10 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view) int view_checksum(THD *thd, TABLE_LIST *view) { char md5[MD5_BUFF_LENGTH]; - if (!view->view || view->md5.length != 32) + if (!view->view || view->md5.length != VIEW_MD5_LEN) return HA_ADMIN_NOT_IMPLEMENTED; view->calc_md5(md5); - return (strncmp(md5, view->md5.str, 32) ? + return (strncmp(md5, view->md5.str, VIEW_MD5_LEN) ? HA_ADMIN_WRONG_CHECKSUM : HA_ADMIN_OK); } diff --git a/sql/table.h b/sql/table.h index 097deca46b2..6036afd3750 100644 --- a/sql/table.h +++ b/sql/table.h @@ -32,6 +32,9 @@ #include "filesort_utils.h" #include "parse_file.h" +/* buffer for timestamp (19+1) */ +#define VIEW_TIME_STAMP_BUFFER_SIZE (PARSE_FILE_TIMESTAMPLENGTH + 1) + /* Structs that defines the TABLE */ class Item; /* Needed by ORDER */ @@ -64,6 +67,8 @@ struct Name_resolution_context; */ typedef ulonglong nested_join_map; +#define VIEW_MD5_LEN 32 + #define tmp_file_prefix "#sql" /**< Prefix for tmp tables */ #define tmp_file_prefix_length 4 @@ -2460,7 +2465,7 @@ struct TABLE_LIST /* TABLE_TYPE_UNKNOWN if any type is acceptable */ Table_type required_type; handlerton *db_type; /* table_type for handler */ - char timestamp_buffer[MAX_DATETIME_WIDTH + 1]; + char timestamp_buffer[VIEW_TIME_STAMP_BUFFER_SIZE]; /* This TABLE_LIST object is just placeholder for prelocking, it will be used for implicit LOCK TABLES only and won't be used in real statement. |