From a471389d0706760029c39ebfb7ba4c8ed482e4db Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 21 Sep 2024 11:57:19 +0200 Subject: [PATCH] MDEV-34970 Vector search fails to compile on s390x add missing casts to float4store/float8store for bigendian. fix a typo in float4store() usage remove unnecessary one-byte-at-time appends --- include/big_endian.h | 4 ++-- sql/item_vectorfunc.cc | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/big_endian.h b/include/big_endian.h index 6487f82924e..4ca11ee8a6f 100644 --- a/include/big_endian.h +++ b/include/big_endian.h @@ -16,7 +16,7 @@ /* Data in big-endian format. */ -#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\ +#define float4store(T,A) do { *((T)+0)=(char) ((uchar *) &A)[3];\ *((T)+1)=(char) ((uchar *) &A)[2];\ *((T)+2)=(char) ((uchar *) &A)[1];\ *((T)+3)=(char) ((uchar *) &A)[0]; } while(0) @@ -28,7 +28,7 @@ ((uchar*) &def_temp)[3]=(M)[0];\ (V)=def_temp; } while(0) -#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\ +#define float8store(T,V) do { *((T)+0)=(char) ((uchar *) &V)[7];\ *((T)+1)=(char) ((uchar *) &V)[6];\ *((T)+2)=(char) ((uchar *) &V)[5];\ *((T)+3)=(char) ((uchar *) &V)[4];\ diff --git a/sql/item_vectorfunc.cc b/sql/item_vectorfunc.cc index 3b468d1726e..8b9ea188490 100644 --- a/sql/item_vectorfunc.cc +++ b/sql/item_vectorfunc.cc @@ -179,11 +179,8 @@ String *Item_func_vec_fromtext::val_str(String *buf) goto error_format; char f_bin[4]; - float4store(&f_bin, f); - buf->append(f_bin[0]); - buf->append(f_bin[1]); - buf->append(f_bin[2]); - buf->append(f_bin[3]); + float4store(f_bin, f); + buf->append(f_bin, sizeof(f_bin)); break; } default: