From 6462238f0d7b7c15eb3f54c2108573cee8fb24ba Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 27 Mar 2017 14:52:19 -0300 Subject: Fix uninitialized memory propagation mistakes Valgrind complains that some uninitialized bytes are being passed around by the extended statistics code since commit 7b504eb282ca2f, as reported by Andres Freund. Silence it. Tomas Vondra submitted a patch which he verified to fix the complaints in his machine; however I messed with it a bit before pushing, so any remaining problems are likely my (Álvaro's) fault. Author: Tomas Vondra Discussion: https://postgr.es/m/20170325211031.4xxoptigqxm2emn2@alap3.anarazel.de --- src/include/statistics/statistics.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/include') diff --git a/src/include/statistics/statistics.h b/src/include/statistics/statistics.h index a15e39e1a30..91645bff4b0 100644 --- a/src/include/statistics/statistics.h +++ b/src/include/statistics/statistics.h @@ -27,6 +27,9 @@ typedef struct MVNDistinctItem double ndistinct; /* ndistinct value for this combination */ Bitmapset *attrs; /* attr numbers of items */ } MVNDistinctItem; +/* size of the struct, excluding attribute list */ +#define SizeOfMVNDistinctItem \ + (offsetof(MVNDistinctItem, ndistinct) + sizeof(double)) /* A MVNDistinct object, comprising all possible combinations of columns */ typedef struct MVNDistinct @@ -37,6 +40,10 @@ typedef struct MVNDistinct MVNDistinctItem items[FLEXIBLE_ARRAY_MEMBER]; } MVNDistinct; +/* size of the struct excluding the items array */ +#define SizeOfMVNDistinct (offsetof(MVNDistinct, nitems) + sizeof(uint32)) + + extern MVNDistinct *statext_ndistinct_load(Oid mvoid); extern void BuildRelationExtStatistics(Relation onerel, double totalrows, -- cgit v1.2.3