pgsql: Fix bogus code for extracting extended-statistics data from sysc

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix bogus code for extracting extended-statistics data from sysc
Date: 2018-05-02 16:23:19
Message-ID: E1fDuXH-0003cu-TS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix bogus code for extracting extended-statistics data from syscache.

statext_dependencies_load and statext_ndistinct_load were not up to snuff,
in addition to being randomly different from each other. In detail:

* Deserialize the fetched bytea value before releasing the syscache
entry, not after. This mistake causes visible regression test failures
when running with -DCATCACHE_FORCE_RELEASE. Since it's not exposed by
-DCLOBBER_CACHE_ALWAYS, I think there may be no production hazard here
at present, but it's at least a latent bug.

* Use DatumGetByteaPP not DatumGetByteaP to save a detoasting cycle
for short stats values; the deserialize function has to be, and is,
prepared for short-header values since its other caller uses PP.

* Use a test-and-elog for null stats values in both functions, rather
than a test-and-elog in one case and an Assert in the other. Perhaps
Asserts would be sufficient in both cases, but I don't see a good
argument for them being different.

* Minor cosmetic changes to make these functions more visibly alike.

Backpatch to v10 where this code came in.

Amit Langote, minor additional hacking by me

Discussion: https://postgr.es/m/1349aabb-3a1f-6675-9fc0-65e2ce7491dd@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/447dbf7aa7909bca76048042d6734ee8f5249d0f

Modified Files
--------------
src/backend/statistics/dependencies.c | 13 ++++++++++---
src/backend/statistics/mvdistinct.c | 11 +++++++----
2 files changed, 17 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-05-02 19:53:14 pgsql: Fix assorted compiler warnings seen in the buildfarm.
Previous Message Peter Eisentraut 2018-05-02 16:08:33 pgsql: doc: Correct update on limitations of partitions