Skip to content

Commit

Permalink
Better declaration of the buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Sep 30, 2022
1 parent 1f51d6c commit 98e62e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 7 additions & 7 deletions sql/sql_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 6 additions & 1 deletion sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 98e62e6

Please sign in to comment.