Hi, Alexander,

Just one comment below

On Jan 06, Alexander Barkov wrote:
> revision-id: c50eed1e904 (mariadb-10.4.30-318-gc50eed1e904)
> parent(s): 28cdbab1637
> author: Alexander Barkov
> committer: Alexander Barkov
> timestamp: 2023-11-13 11:18:16 +0400
> message:
> 
> MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol
> 
> Item_float::neg() did not preserve the "presentation" from "this".
> So
>   CAST(-1e0 AS UNSIGNED)  -- cast from double to unsigned
> changes its meaning to:
>   CAST(-1 AS UNSIGNED)  -- cast signed to undigned
> 
> Fixing Item_float::neg() to construct the new value for
> Item_float::presentation as minus sign followed by its old value:
>   '1e0'  -> '-1e0'
> 
> diff --git a/sql/item.cc b/sql/item.cc
> index 259c4bf8f4d..b88f78fbb59 100644
> --- a/sql/item.cc
> +++ b/sql/item.cc
> @@ -6896,7 +6896,17 @@ Item *Item_float::neg(THD *thd)
>    else if (value < 0 && max_length)
>      max_length--;
>    value= -value;
> -  presentation= 0;
> +  if (presentation)
> +  {

may be, still

  if (*presentation == '-')
    presentation++
  else

> +    size_t presentation_length= strlen(presentation);
> +    if (char *tmp= (char*) thd->alloc(presentation_length + 2))
> +    {
> +      tmp[0]= '-';
> +      // Copy with the trailing '\0'
> +      memcpy(tmp + 1, presentation, presentation_length + 1);
> +      presentation= tmp;
> +    }
> +  }
>    name= null_clex_str;
>    return this;
>  }
> 
Regards,
Sergei
Chief Architect, MariaDB Server
and secur...@mariadb.org
_______________________________________________
developers mailing list -- developers@lists.mariadb.org
To unsubscribe send an email to developers-le...@lists.mariadb.org

Reply via email to