Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c44c46

Browse files
committed
Prevent segfault in expand_tuple with no missing values
Commit16828d5 forgot to check that it had a set of missing valuesbefore trying to retrieve a value from it.An additional query to add coverage for this code is added to theregression test.Per bug report from Andreas Seltenreich.
1 parent8bf358c commit7c44c46

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

‎src/backend/access/common/heaptuple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
981981

982982
Form_pg_attributeattr=TupleDescAttr(tupleDesc,attnum);
983983

984-
if (attrmiss[attnum].ammissingPresent)
984+
if (attrmiss&&attrmiss[attnum].ammissingPresent)
985985
{
986986
fill_val(attr,
987987
nullBits ?&nullBits :NULL,

‎src/test/regress/expected/fast_default.out

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,41 @@ SELECT comp();
505505
Unchanged
506506
(1 row)
507507

508+
-- query to exercise expand_tuple function
509+
CREATE TABLE t1 AS
510+
SELECT 1::int AS a , 2::int AS b
511+
FROM generate_series(1,20) q;
512+
ALTER TABLE t1 ADD COLUMN c text;
513+
SELECT a,
514+
stddev(cast((SELECT sum(1) FROM generate_series(1,20) x) AS float4))
515+
OVER (PARTITION BY a,b,c ORDER BY b)
516+
AS z
517+
FROM t1;
518+
a | z
519+
---+---
520+
1 | 0
521+
1 | 0
522+
1 | 0
523+
1 | 0
524+
1 | 0
525+
1 | 0
526+
1 | 0
527+
1 | 0
528+
1 | 0
529+
1 | 0
530+
1 | 0
531+
1 | 0
532+
1 | 0
533+
1 | 0
534+
1 | 0
535+
1 | 0
536+
1 | 0
537+
1 | 0
538+
1 | 0
539+
1 | 0
540+
(20 rows)
541+
542+
DROP TABLE t1;
508543
DROP TABLE T;
509544
DROP FUNCTION set(name);
510545
DROP FUNCTION comp();

‎src/test/regress/sql/fast_default.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,20 @@ SELECT c_text FROM T WHERE c_int = -1;
347347

348348
SELECT comp();
349349

350+
-- query to exercise expand_tuple function
351+
CREATETABLEt1AS
352+
SELECT1::intAS a ,2::intAS b
353+
FROM generate_series(1,20) q;
354+
355+
ALTERTABLE t1 ADD COLUMN ctext;
356+
357+
SELECT a,
358+
stddev(cast((SELECTsum(1)FROM generate_series(1,20) x)AS float4))
359+
OVER (PARTITION BY a,b,cORDER BY b)
360+
AS z
361+
FROM t1;
362+
363+
DROPTABLE t1;
350364
DROPTABLE T;
351365
DROPFUNCTIONset(name);
352366
DROPFUNCTION comp();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp