Code cleanup patch submission for extended_stats.c

From: Mark Dilger <hornschnorter(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Code cleanup patch submission for extended_stats.c
Date: 2017-11-25 19:57:08
Message-ID: 9A193A1B-6A05-459F-9FA5-65754C83AECA@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hackers, Alvaro,

In src/backend/statistics/extended_stats.c, in statext_store, there is a section:

Datum values[Natts_pg_statistic_ext];
bool nulls[Natts_pg_statistic_ext];
bool replaces[Natts_pg_statistic_ext];

memset(nulls, 1, Natts_pg_statistic_ext * sizeof(bool));
memset(replaces, 0, Natts_pg_statistic_ext * sizeof(bool));
memset(values, 0, Natts_pg_statistic_ext * sizeof(Datum));

It looks to me like Alvaro introduced this in the original version of the file which
was created in commit 7b504eb282ca2f5104b5c00b4f05a3ef6bb1385b. Grep'ing
through the code base, it seems the following would be more consistent with
how these initializations are handled elsewhere:

Datum values[Natts_pg_statistic_ext];
bool nulls[Natts_pg_statistic_ext];
bool replaces[Natts_pg_statistic_ext];

memset(nulls, 1, sizeof(nulls));
memset(replaces, 0, sizeof(replaces));
memset(values, 0, sizeof(values));

Patch attached as 0001_extended_stats_sizeof.patch.1

mark

Attachment Content-Type Size
0001_extended_stats_sizeof.patch.1 application/octet-stream 751 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2017-11-25 20:23:17 Re: [HACKERS] PATCH: multivariate histograms and MCV lists
Previous Message Dmitry Shalashov 2017-11-25 18:59:40 Re: Query became very slow after 9.6 -> 10 upgrade