Skip to content

Commit d466ed9

Browse files
committed
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.
1 parent a1e41e3 commit d466ed9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sql/item_strfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ String *Item_func_decode_histogram::val_str(String *str)
602602
val= p[i] / ((double)((1 << 8) - 1));
603603
break;
604604
case DOUBLE_PREC_HB:
605-
val= ((uint16 *)(p + i))[0] / ((double)((1 << 16) - 1));
605+
val= uint2korr(p + i) / ((double)((1 << 16) - 1));
606606
i++;
607607
break;
608608
default:

sql/sql_statistics.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Histogram
147147
case SINGLE_PREC_HB:
148148
return (uint) (((uint8 *) values)[i]);
149149
case DOUBLE_PREC_HB:
150-
return (uint) (((uint16 *) values)[i]);
150+
return (uint) uint2korr(values + i * 2);
151151
}
152152
return 0;
153153
}
@@ -214,7 +214,7 @@ class Histogram
214214
((uint8 *) values)[i]= (uint8) (val * prec_factor());
215215
return;
216216
case DOUBLE_PREC_HB:
217-
((uint16 *) values)[i]= (uint16) (val * prec_factor());
217+
int2store(values + i * 2, val * prec_factor());
218218
return;
219219
}
220220
}
@@ -226,7 +226,7 @@ class Histogram
226226
((uint8 *) values)[i]= ((uint8 *) values)[i-1];
227227
return;
228228
case DOUBLE_PREC_HB:
229-
((uint16 *) values)[i]= ((uint16 *) values)[i-1];
229+
int2store(values + i * 2, uint2korr(values + i * 2 - 2));
230230
return;
231231
}
232232
}

0 commit comments

Comments
 (0)