summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2014-07-23 12:55:26 +0400
committerSergey Vojtovich <svoj@mariadb.org>2014-07-23 12:55:26 +0400
commitd466ed90fd90908998db565fd90ff6e4c2778bf9 (patch)
tree405d56b8bb65c8206c30a260416aede1ea8757ec
parenta1e41e325873bda2071f0d9c5b85778023435c0b (diff)
downloadmariadb-git-d466ed90fd90908998db565fd90ff6e4c2778bf9.tar.gz
MDEV-6473 - main.statistics fails on PPC64
mysql.column_stats wasn't stored/restored properly on big-endian with histogram_type=DOUBLE_PREC_HB. Store histogram values using int2store()/uint2korr(). Note that this patch invalidates previously calculated histogram values on big-endian.
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/sql_statistics.h6
2 files changed, 4 insertions, 4 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 79f4343ea70..bee1b600d8f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -602,7 +602,7 @@ String *Item_func_decode_histogram::val_str(String *str)
val= p[i] / ((double)((1 << 8) - 1));
break;
case DOUBLE_PREC_HB:
- val= ((uint16 *)(p + i))[0] / ((double)((1 << 16) - 1));
+ val= uint2korr(p + i) / ((double)((1 << 16) - 1));
i++;
break;
default:
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 331e3559203..c399951b828 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -147,7 +147,7 @@ private:
case SINGLE_PREC_HB:
return (uint) (((uint8 *) values)[i]);
case DOUBLE_PREC_HB:
- return (uint) (((uint16 *) values)[i]);
+ return (uint) uint2korr(values + i * 2);
}
return 0;
}
@@ -214,7 +214,7 @@ public:
((uint8 *) values)[i]= (uint8) (val * prec_factor());
return;
case DOUBLE_PREC_HB:
- ((uint16 *) values)[i]= (uint16) (val * prec_factor());
+ int2store(values + i * 2, val * prec_factor());
return;
}
}
@@ -226,7 +226,7 @@ public:
((uint8 *) values)[i]= ((uint8 *) values)[i-1];
return;
case DOUBLE_PREC_HB:
- ((uint16 *) values)[i]= ((uint16 *) values)[i-1];
+ int2store(values + i * 2, uint2korr(values + i * 2 - 2));
return;
}
}