Commit 2c0bcfff authored by Alexander Barkov's avatar Alexander Barkov

MDEV-8693 Tests connect.bin connect.endian fail on armhf (on Debian build system)

parent d546d1cc
......@@ -511,29 +511,29 @@ void BINCOL::ReadColumn(PGLOBAL g)
switch (Fmt) {
case 'X': // Standard not converted values
if (Eds && IsTypeChar(Buf_Type))
Value->SetValue(*(longlong*)p);
Value->SetValueNonAligned<longlong>(p);
else
Value->SetBinValue(p);
break;
case 'S': // Short integer
Value->SetValue(*(short*)p);
Value->SetValueNonAligned<short>(p);
break;
case 'T': // Tiny integer
Value->SetValue(*p);
break;
case 'I': // Integer
Value->SetValue(*(int*)p);
Value->SetValueNonAligned<int>(p);
break;
case 'G': // Large (great) integer
Value->SetValue(*(longlong*)p);
Value->SetValueNonAligned<longlong>(p);
break;
case 'F': // Float
case 'R': // Real
Value->SetValue((double)*(float*)p);
Value->SetValueNonAligned<float>(p);
break;
case 'D': // Double
Value->SetValue(*(double*)p);
Value->SetValueNonAligned<double>(p);
break;
case 'C': // Text
if (Value->SetValue_char(p, Long)) {
......
......@@ -116,6 +116,26 @@ class DllExport VALUE : public BLOCK {
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual bool FormatValue(PVAL vp, char *fmt) = 0;
/**
Set value from a non-aligned in-memory value in the machine byte order.
TYPE can be either of:
- int, short, longlong
- uint, ushort, ulonglong
- float, double
@param - a pointer to a non-aligned value of type TYPE.
*/
template<typename TYPE>
void SetValueNonAligned(const char *p)
{
#if defined(__i386__) || defined(__x86_64__)
SetValue(*((TYPE*) p)); // x86 can cast non-aligned memory directly
#else
TYPE tmp; // a slower version for non-x86 platforms
memcpy(&tmp, p, sizeof(tmp));
SetValue(tmp);
#endif
}
protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
const char *GetXfmt(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment