pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
7+ messages / 2 participants
[nested] [flat]
* pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-20 08:41 Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Heikki Linnakangas @ 2020-01-20 08:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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
------
REL_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ff0c567cbfb7aeca479f5c087d17c85ffb5b2bf7
Modified Files
--------------
src/backend/access/brin/brin_inclusion.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-20 08:41 Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Heikki Linnakangas @ 2020-01-20 08:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-20 08:41 Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Heikki Linnakangas @ 2020-01-20 08:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4c87010981f3a9a41751e5550f6eb889ab5667e8
Modified Files
--------------
src/backend/access/brin/brin_inclusion.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-20 08:41 Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Heikki Linnakangas @ 2020-01-20 08:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/da7abcf0f475bfacc064210d15be9e6e31e873f9
Modified Files
--------------
src/backend/access/brin/brin_inclusion.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-20 08:41 Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 1 reply; 7+ messages in thread
From: Heikki Linnakangas @ 2020-01-20 08:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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_5_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/98f0d283774b68895bc41413d7dd9c19e5608231
Modified Files
--------------
src/backend/access/brin/brin_inclusion.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-20 08:41 Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Heikki Linnakangas @ 2020-01-20 08:41 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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
------
REL_12_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/fd436bba01f6df843a9f421669c02e2b970fdc7a
Modified Files
--------------
src/backend/access/brin/brin_inclusion.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c
@ 2020-01-22 21:45 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Alvaro Herrera @ 2020-01-22 21:45 UTC (permalink / raw)
To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-hackers@lists.postgresql.org
On 2020-Jan-20, Heikki Linnakangas wrote:
> 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);
I noticed that this test increases line-wise coverage of
brin_inclusion.c by a few percentage points, so I added it.
Again, thanks
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2020-01-22 21:45 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 08:41 pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c Heikki Linnakangas <heikki.linnakangas@iki.fi>
2020-01-20 08:41 pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c Heikki Linnakangas <heikki.linnakangas@iki.fi>
2020-01-20 08:41 pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c Heikki Linnakangas <heikki.linnakangas@iki.fi>
2020-01-20 08:41 pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c Heikki Linnakangas <heikki.linnakangas@iki.fi>
2020-01-20 08:41 pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c Heikki Linnakangas <heikki.linnakangas@iki.fi>
2020-01-20 08:41 pgsql: Fix crash in BRIN inclusion op functions, due to missing datum c Heikki Linnakangas <heikki.linnakangas@iki.fi>
2020-01-22 21:45 ` Alvaro Herrera <alvherre@2ndquadrant.com>
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