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

Commitfc76958

Browse files
committed
Prevent a rowtype from being included in itself via a range.
We probably should have thought of this case when ranges were added,but we didn't. (It's not the fault of commiteb51af7, becauseranges didn't exist then.)It's an old bug, so back-patch to all supported branches.Discussion:https://postgr.es/m/7782.1577051475@sss.pgh.pa.us
1 parent0fd8cfb commitfc76958

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

‎src/backend/catalog/heap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,15 @@ CheckAttributeType(const char *attname,
655655

656656
containing_rowtypes=list_delete_last(containing_rowtypes);
657657
}
658+
elseif (att_typtype==TYPTYPE_RANGE)
659+
{
660+
/*
661+
* If it's a range, recurse to check its subtype.
662+
*/
663+
CheckAttributeType(attname,get_range_subtype(atttypid),attcollation,
664+
containing_rowtypes,
665+
flags);
666+
}
658667
elseif (OidIsValid((att_typelem=get_element_type(atttypid))))
659668
{
660669
/*

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,9 @@ select *, row_to_json(upper(t)) as u from
13751375
["(5,6)","(7,8)") | {"a":7,"b":8}
13761376
(2 rows)
13771377

1378+
-- this must be rejected to avoid self-inclusion issues:
1379+
alter type two_ints add attribute c two_ints_range;
1380+
ERROR: composite type two_ints cannot be made a member of itself
13781381
drop type two_ints cascade;
13791382
NOTICE: drop cascades to type two_ints_range
13801383
--

‎src/test/regress/sql/rangetypes.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ select *, row_to_json(upper(t)) as u from
463463
(values (two_ints_range(row(1,2), row(3,4))),
464464
(two_ints_range(row(5,6), row(7,8)))) v(t);
465465

466+
-- this must be rejected to avoid self-inclusion issues:
467+
altertype two_ints add attribute c two_ints_range;
468+
466469
droptype two_ints cascade;
467470

468471
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp