← Back to team overview

maria-developers team mailing list archive

Re: [Commits] c132349bc79: MDEV-11846: ERROR 1114 (HY000) table full when performing GROUP BY

 

Hi Varun,

Ok to push.

On Fri, Sep 15, 2017 at 01:28:53PM +0530, Varun wrote:
> revision-id: c132349bc79d987947c8659e71601914cfec71e8 (mariadb-10.1.23-156-gc132349bc79)
> parent(s): fa2701c6f7b028782cf231565f578b2fc0f10d51
> author: Varun Gupta
> committer: Varun Gupta
> timestamp: 2017-09-15 13:27:11 +0530
> message:
> 
> MDEV-11846: ERROR 1114 (HY000) table full when performing GROUP BY
> 
> The problem is there is an overflow for the key_file_length.
> Added the maximum limit for the key_file_length
> 
> ---
>  storage/maria/ma_create.c | 41 +++++++++++++++++++++++++++++++++--------
>  1 file changed, 33 insertions(+), 8 deletions(-)
> 
> diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
> index 0ddd8b226e2..79e60a76abc 100644
> --- a/storage/maria/ma_create.c
> +++ b/storage/maria/ma_create.c
> @@ -660,11 +660,24 @@ int maria_create(const char *name, enum data_file_type datafile_type,
>  
>      if (length > max_key_length)
>        max_key_length= length;
> -    tot_length+= ((max_rows/(ulong) (((uint) maria_block_size -
> +
> +    if (tot_length == ULLONG_MAX)
> +      continue;
> +
> +    ulonglong tot_length_part= (max_rows/(ulong) (((uint) maria_block_size -
>                                        MAX_KEYPAGE_HEADER_SIZE -
>                                        KEYPAGE_CHECKSUM_SIZE)/
> -                                     (length*2))) *
> -                  maria_block_size);
> +                                     (length*2)));
> +    if (tot_length_part >=  (ULLONG_MAX / maria_block_size +
> +                            ULLONG_MAX % maria_block_size))
> +      tot_length= ULLONG_MAX;
> +    else
> +    {
> +      if (tot_length > ULLONG_MAX - tot_length_part * maria_block_size)
> +        tot_length= ULLONG_MAX;
> +      else
> +        tot_length+= tot_length_part * maria_block_size;
> +    }
>    }
>  
>    unique_key_parts=0;
> @@ -673,11 +686,24 @@ int maria_create(const char *name, enum data_file_type datafile_type,
>      uniquedef->key=keys+i;
>      unique_key_parts+=uniquedef->keysegs;
>      share.state.key_root[keys+i]= HA_OFFSET_ERROR;
> -    tot_length+= (max_rows/(ulong) (((uint) maria_block_size -
> +
> +    if (tot_length == ULLONG_MAX)
> +      continue;
> +     ulonglong tot_length_part= (max_rows/(ulong) (((uint) maria_block_size -
>                                       MAX_KEYPAGE_HEADER_SIZE -
>                                       KEYPAGE_CHECKSUM_SIZE) /
> -                         ((MARIA_UNIQUE_HASH_LENGTH + pointer)*2)))*
> -                         (ulong) maria_block_size;
> +                         ((MARIA_UNIQUE_HASH_LENGTH + pointer)*2)));
> +
> +    if (tot_length_part >=  (ULLONG_MAX / maria_block_size +
> +                            ULLONG_MAX % maria_block_size))
> +      tot_length= ULLONG_MAX;
> +    else
> +    {
> +      if (tot_length > ULLONG_MAX - tot_length_part * maria_block_size)
> +        tot_length= ULLONG_MAX;
> +      else
> +        tot_length+= tot_length_part * maria_block_size;
> +    }
>    }
>    keys+=uniques;				/* Each unique has 1 key */
>    key_segs+=uniques;				/* Each unique has 1 key seg */
> @@ -746,8 +772,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
>      Get estimate for index file length (this may be wrong for FT keys)
>      This is used for pointers to other key pages.
>    */
> -  tmp= (tot_length + maria_block_size * keys *
> -	MARIA_INDEX_BLOCK_MARGIN) / maria_block_size;
> +  tmp= (tot_length / maria_block_size + keys * MARIA_INDEX_BLOCK_MARGIN);
>  
>    /*
>      use maximum of key_file_length we calculated and key_file_length value we
> _______________________________________________
> commits mailing list
> commits@xxxxxxxxxxx
> https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits

-- 
BR
 Sergei
-- 
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog