mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Prevent segfault in expand_tuple with no missing values
Commit 16828d5c
forgot to check that it had a set of missing values
before trying to retrieve a value from it.
An additional query to add coverage for this code is added to the
regression test.
Per bug report from Andreas Seltenreich.
This commit is contained in:
@ -981,7 +981,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
|
|||||||
|
|
||||||
Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
|
Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
|
||||||
|
|
||||||
if (attrmiss[attnum].ammissingPresent)
|
if (attrmiss && attrmiss[attnum].ammissingPresent)
|
||||||
{
|
{
|
||||||
fill_val(attr,
|
fill_val(attr,
|
||||||
nullBits ? &nullBits : NULL,
|
nullBits ? &nullBits : NULL,
|
||||||
|
@ -505,6 +505,41 @@ SELECT comp();
|
|||||||
Unchanged
|
Unchanged
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- query to exercise expand_tuple function
|
||||||
|
CREATE TABLE t1 AS
|
||||||
|
SELECT 1::int AS a , 2::int AS b
|
||||||
|
FROM generate_series(1,20) q;
|
||||||
|
ALTER TABLE t1 ADD COLUMN c text;
|
||||||
|
SELECT a,
|
||||||
|
stddev(cast((SELECT sum(1) FROM generate_series(1,20) x) AS float4))
|
||||||
|
OVER (PARTITION BY a,b,c ORDER BY b)
|
||||||
|
AS z
|
||||||
|
FROM t1;
|
||||||
|
a | z
|
||||||
|
---+---
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
1 | 0
|
||||||
|
(20 rows)
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
DROP TABLE T;
|
DROP TABLE T;
|
||||||
DROP FUNCTION set(name);
|
DROP FUNCTION set(name);
|
||||||
DROP FUNCTION comp();
|
DROP FUNCTION comp();
|
||||||
|
@ -347,6 +347,20 @@ SELECT c_text FROM T WHERE c_int = -1;
|
|||||||
|
|
||||||
SELECT comp();
|
SELECT comp();
|
||||||
|
|
||||||
|
-- query to exercise expand_tuple function
|
||||||
|
CREATE TABLE t1 AS
|
||||||
|
SELECT 1::int AS a , 2::int AS b
|
||||||
|
FROM generate_series(1,20) q;
|
||||||
|
|
||||||
|
ALTER TABLE t1 ADD COLUMN c text;
|
||||||
|
|
||||||
|
SELECT a,
|
||||||
|
stddev(cast((SELECT sum(1) FROM generate_series(1,20) x) AS float4))
|
||||||
|
OVER (PARTITION BY a,b,c ORDER BY b)
|
||||||
|
AS z
|
||||||
|
FROM t1;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
DROP TABLE T;
|
DROP TABLE T;
|
||||||
DROP FUNCTION set(name);
|
DROP FUNCTION set(name);
|
||||||
DROP FUNCTION comp();
|
DROP FUNCTION comp();
|
||||||
|
Reference in New Issue
Block a user