pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
Date: Mon, 20 Jan 2020 08:41:50 +0000
Message-ID: <E1itSd4-00033J-9X@gemulon.postgresql.org> (raw)

Fix crash in BRIN inclusion op functions, due to missing datum copy.

The BRIN add_value() and union() functions need to make a longer-lived
copy of the argument, if they want to store it in the BrinValues struct
also passed as argument. The functions for the "inclusion operator
classes" used with box, range and inet types didn't take into account
that the union helper function might return its argument as is, without
making a copy. Check for that case, and make a copy if necessary. That
case arises at least with the range_union() function, when one of the
arguments is an 'empty' range:

CREATE TABLE brintest (n numrange);
CREATE INDEX brinidx ON brintest USING brin (n);
INSERT INTO brintest VALUES ('empty');
INSERT INTO brintest VALUES (numrange(0, 2^1000::numeric));
INSERT INTO brintest VALUES ('(-1, 0)');

SELECT brin_desummarize_range('brinidx', 0);
SELECT brin_summarize_range('brinidx', 0);

Backpatch down to 9.5, where BRIN was introduced.

Discussion: https://www.postgresql.org/message-id/e6e1d6eb-0a67-36aa-e779-bcca59167c14%40iki.fi
Reviewed-by: Emre Hasegeli, Tom Lane, Alvaro Herrera

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e96f30d898d8c8cde44e625b888e839f707dcc60

Modified Files
--------------
src/backend/access/brin/brin_inclusion.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1itSd4-00033J-9X@gemulon.postgresql.org>
Permalink:  ../E1itSd4-00033J-9X@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1itSd4-00033J-9X@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
  In-Reply-To: <E1itSd4-00033J-9X@gemulon.postgresql.org>
  References: <E1itSd4-00033J-9X@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox