Skip to content

Commit 98e62e6

Browse files
committed
Better declaration of the buffer size
1 parent 1f51d6c commit 98e62e6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

sql/sql_view.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -843,13 +843,13 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum,
843843
swap_alg= 0;
844844
if (wrong_checksum)
845845
{
846-
if (view->md5.length != 32)
846+
if (view->md5.length != VIEW_MD5_LEN)
847847
{
848-
if ((view->md5.str= (char *)thd->alloc(32 + 1)) == NULL)
848+
if ((view->md5.str= (char *)thd->alloc(VIEW_MD5_LEN + 1)) == NULL)
849849
DBUG_RETURN(HA_ADMIN_FAILED);
850850
}
851851
view->calc_md5(const_cast<char*>(view->md5.str));
852-
view->md5.length= 32;
852+
view->md5.length= VIEW_MD5_LEN;
853853
}
854854
view->mariadb_version= MYSQL_VERSION_ID;
855855

@@ -972,13 +972,13 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
972972
view->file_version= 2;
973973
view->mariadb_version= MYSQL_VERSION_ID;
974974
view->calc_md5(md5);
975-
if (!(view->md5.str= (char*) thd->memdup(md5, 32)))
975+
if (!(view->md5.str= (char*) thd->memdup(md5, VIEW_MD5_LEN)))
976976
{
977977
my_error(ER_OUT_OF_RESOURCES, MYF(0));
978978
error= -1;
979979
goto err;
980980
}
981-
view->md5.length= 32;
981+
view->md5.length= VIEW_MD5_LEN;
982982
can_be_merged= lex->can_be_merged();
983983
if (lex->create_view->algorithm == VIEW_ALGORITHM_MERGE &&
984984
!lex->can_be_merged())
@@ -2093,10 +2093,10 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
20932093
int view_checksum(THD *thd, TABLE_LIST *view)
20942094
{
20952095
char md5[MD5_BUFF_LENGTH];
2096-
if (!view->view || view->md5.length != 32)
2096+
if (!view->view || view->md5.length != VIEW_MD5_LEN)
20972097
return HA_ADMIN_NOT_IMPLEMENTED;
20982098
view->calc_md5(md5);
2099-
return (strncmp(md5, view->md5.str, 32) ?
2099+
return (strncmp(md5, view->md5.str, VIEW_MD5_LEN) ?
21002100
HA_ADMIN_WRONG_CHECKSUM :
21012101
HA_ADMIN_OK);
21022102
}

sql/table.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include "filesort_utils.h"
3333
#include "parse_file.h"
3434

35+
/* buffer for timestamp (19+1) */
36+
#define VIEW_TIME_STAMP_BUFFER_SIZE (PARSE_FILE_TIMESTAMPLENGTH + 1)
37+
3538
/* Structs that defines the TABLE */
3639

3740
class Item; /* Needed by ORDER */
@@ -64,6 +67,8 @@ struct Name_resolution_context;
6467
*/
6568
typedef ulonglong nested_join_map;
6669

70+
#define VIEW_MD5_LEN 32
71+
6772

6873
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
6974
#define tmp_file_prefix_length 4
@@ -2460,7 +2465,7 @@ struct TABLE_LIST
24602465
/* TABLE_TYPE_UNKNOWN if any type is acceptable */
24612466
Table_type required_type;
24622467
handlerton *db_type; /* table_type for handler */
2463-
char timestamp_buffer[MAX_DATETIME_WIDTH + 1];
2468+
char timestamp_buffer[VIEW_TIME_STAMP_BUFFER_SIZE];
24642469
/*
24652470
This TABLE_LIST object is just placeholder for prelocking, it will be
24662471
used for implicit LOCK TABLES only and won't be used in real statement.

0 commit comments

Comments
 (0)