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

Commitaff97b1

Browse files
committed
Handle domains when checking for recursive inclusion of composite types.
We need this now because we allow domains over arrays, and we'll probablyallow domains over composites pretty soon, which makes the problem evenmore obvious.Although domains over arrays also exist in previous versions, this does notneed to be back-patched, because the coding used in older versionssuccessfully "looked through" domains over arrays. The problem is exposedby not treating a domain as having a typelem.Problem identified by Noah Misch, though I did not use his patch, sinceit would require additional work to handle domains over composites thatway. This approach is more future-proof.
1 parent680ea6a commitaff97b1

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

‎src/backend/catalog/heap.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,19 @@ CheckAttributeType(const char *attname,
485485
errmsg("column \"%s\" has pseudo-type %s",
486486
attname,format_type_be(atttypid))));
487487
}
488+
elseif (att_typtype==TYPTYPE_DOMAIN)
489+
{
490+
/*
491+
* If it's a domain, recurse to check its base type.
492+
*/
493+
CheckAttributeType(attname,getBaseType(atttypid),attcollation,
494+
containing_rowtypes,
495+
allow_system_table_mods);
496+
}
488497
elseif (att_typtype==TYPTYPE_COMPOSITE)
489498
{
490499
/*
491-
* For a composite type, recurse into its attributes. You might think
492-
* this isn't necessary, but since we allow system catalogs to break
493-
* the rule, we have to guard against the case.
500+
* For a composite type, recurse into its attributes.
494501
*/
495502
Relationrelation;
496503
TupleDesctupdesc;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,9 @@ alter table recur1 add column f2 recur1; -- fails
15161516
ERROR: composite type recur1 cannot be made a member of itself
15171517
alter table recur1 add column f2 recur1[]; -- fails
15181518
ERROR: composite type recur1 cannot be made a member of itself
1519+
create domain array_of_recur1 as recur1[];
1520+
alter table recur1 add column f2 array_of_recur1; -- fails
1521+
ERROR: composite type recur1 cannot be made a member of itself
15191522
create temp table recur2 (f1 int, f2 recur1);
15201523
alter table recur1 add column f2 recur2; -- fails
15211524
ERROR: composite type recur1 cannot be made a member of itself

‎src/test/regress/sql/alter_table.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,8 @@ alter table tab1 alter column b type varchar; -- fails
11281128
create temp table recur1 (f1int);
11291129
altertable recur1 add column f2 recur1;-- fails
11301130
altertable recur1 add column f2 recur1[];-- fails
1131+
createdomainarray_of_recur1as recur1[];
1132+
altertable recur1 add column f2 array_of_recur1;-- fails
11311133
create temp table recur2 (f1int, f2 recur1);
11321134
altertable recur1 add column f2 recur2;-- fails
11331135
altertable recur1 add column f2int;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp