Commit 98e62e63 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

Better declaration of the buffer size

parent 1f51d6c0
...@@ -843,13 +843,13 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum, ...@@ -843,13 +843,13 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum,
swap_alg= 0; swap_alg= 0;
if (wrong_checksum) 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); DBUG_RETURN(HA_ADMIN_FAILED);
} }
view->calc_md5(const_cast<char*>(view->md5.str)); 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; view->mariadb_version= MYSQL_VERSION_ID;
...@@ -972,13 +972,13 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, ...@@ -972,13 +972,13 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
view->file_version= 2; view->file_version= 2;
view->mariadb_version= MYSQL_VERSION_ID; view->mariadb_version= MYSQL_VERSION_ID;
view->calc_md5(md5); 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)); my_error(ER_OUT_OF_RESOURCES, MYF(0));
error= -1; error= -1;
goto err; goto err;
} }
view->md5.length= 32; view->md5.length= VIEW_MD5_LEN;
can_be_merged= lex->can_be_merged(); can_be_merged= lex->can_be_merged();
if (lex->create_view->algorithm == VIEW_ALGORITHM_MERGE && if (lex->create_view->algorithm == VIEW_ALGORITHM_MERGE &&
!lex->can_be_merged()) !lex->can_be_merged())
...@@ -2093,10 +2093,10 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view) ...@@ -2093,10 +2093,10 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
int view_checksum(THD *thd, TABLE_LIST *view) int view_checksum(THD *thd, TABLE_LIST *view)
{ {
char md5[MD5_BUFF_LENGTH]; 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; return HA_ADMIN_NOT_IMPLEMENTED;
view->calc_md5(md5); 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_WRONG_CHECKSUM :
HA_ADMIN_OK); HA_ADMIN_OK);
} }
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include "filesort_utils.h" #include "filesort_utils.h"
#include "parse_file.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 */ /* Structs that defines the TABLE */
class Item; /* Needed by ORDER */ class Item; /* Needed by ORDER */
...@@ -64,6 +67,8 @@ struct Name_resolution_context; ...@@ -64,6 +67,8 @@ struct Name_resolution_context;
*/ */
typedef ulonglong nested_join_map; typedef ulonglong nested_join_map;
#define VIEW_MD5_LEN 32
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */ #define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
#define tmp_file_prefix_length 4 #define tmp_file_prefix_length 4
...@@ -2460,7 +2465,7 @@ struct TABLE_LIST ...@@ -2460,7 +2465,7 @@ struct TABLE_LIST
/* TABLE_TYPE_UNKNOWN if any type is acceptable */ /* TABLE_TYPE_UNKNOWN if any type is acceptable */
Table_type required_type; Table_type required_type;
handlerton *db_type; /* table_type for handler */ 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 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. used for implicit LOCK TABLES only and won't be used in real statement.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment