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

Commit2c20ba1

Browse files
committed
Tweak find_composite_type_dependencies API a bit more.
Per discussion with Noah Misch, the previous coding, introduced bymy commit65377e0 on 2011-02-06,was really an abuse of RELKIND_COMPOSITE_TYPE, since the caller intypecmds.c is actually passing the name of a domain. So go backhaving a type name argument, but make the first argument a Relationrather than just a string so we can tell whether it's a table ora foreign table and emit the proper error message.
1 parent61cf7bc commit2c20ba1

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,8 +3422,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
34223422
*/
34233423
if (newrel)
34243424
find_composite_type_dependencies(oldrel->rd_rel->reltype,
3425-
oldrel->rd_rel->relkind,
3426-
RelationGetRelationName(oldrel));
3425+
oldrel,NULL);
34273426

34283427
/*
34293428
* Generate the constraint and default execution states
@@ -3891,8 +3890,8 @@ ATTypedTableRecursion(List **wqueue, Relation rel, AlterTableCmd *cmd,
38913890
* to reject the ALTER. (How safe is this really?)
38923891
*/
38933892
void
3894-
find_composite_type_dependencies(OidtypeOid,charorigRelkind,
3895-
constchar*origRelname)
3893+
find_composite_type_dependencies(OidtypeOid,RelationorigRelation,
3894+
constchar*origTypeName)
38963895
{
38973896
RelationdepRel;
38983897
ScanKeyDatakey[2];
@@ -3936,16 +3935,20 @@ find_composite_type_dependencies(Oid typeOid, char origRelkind,
39363935
if (rel->rd_rel->relkind==RELKIND_RELATION)
39373936
{
39383937
constchar*msg;
3939-
if (origRelkind==RELKIND_COMPOSITE_TYPE)
3938+
3939+
if (origTypeName
3940+
||origRelation->rd_rel->relkind==RELKIND_COMPOSITE_TYPE)
39403941
msg=gettext_noop("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it");
3941-
elseif (origRelkind==RELKIND_FOREIGN_TABLE)
3942+
elseif (origRelation->rd_rel->relkind==RELKIND_FOREIGN_TABLE)
39423943
msg=gettext_noop("cannot alter foreign table \"%s\" because column \"%s\".\"%s\" uses its rowtype");
39433944
else
39443945
msg=gettext_noop("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype");
3946+
39453947
ereport(ERROR,
39463948
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
39473949
errmsg(msg,
3948-
origRelname,
3950+
origTypeName ?origTypeName
3951+
:RelationGetRelationName(origRelation),
39493952
RelationGetRelationName(rel),
39503953
NameStr(att->attname))));
39513954
}
@@ -3956,7 +3959,7 @@ find_composite_type_dependencies(Oid typeOid, char origRelkind,
39563959
* recursively check for indirect dependencies via its rowtype.
39573960
*/
39583961
find_composite_type_dependencies(rel->rd_rel->reltype,
3959-
origRelkind,origRelname);
3962+
origRelation,origTypeName);
39603963
}
39613964

39623965
relation_close(rel,AccessShareLock);
@@ -3972,7 +3975,7 @@ find_composite_type_dependencies(Oid typeOid, char origRelkind,
39723975
*/
39733976
arrayOid=get_array_type(typeOid);
39743977
if (OidIsValid(arrayOid))
3975-
find_composite_type_dependencies(arrayOid,origRelkind,origRelname);
3978+
find_composite_type_dependencies(arrayOid,origRelation,origTypeName);
39763979
}
39773980

39783981

@@ -6573,9 +6576,7 @@ ATPrepAlterColumnType(List **wqueue,
65736576
* For composite types, do this check now. Tables will check
65746577
* it later when the table is being rewritten.
65756578
*/
6576-
find_composite_type_dependencies(rel->rd_rel->reltype,
6577-
rel->rd_rel->relkind,
6578-
RelationGetRelationName(rel));
6579+
find_composite_type_dependencies(rel->rd_rel->reltype,rel,NULL);
65796580
}
65806581

65816582
ReleaseSysCache(tuple);

‎src/backend/commands/typecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode)
21962196
*/
21972197
if (OidIsValid(rel->rd_rel->reltype))
21982198
find_composite_type_dependencies(rel->rd_rel->reltype,
2199-
RELKIND_COMPOSITE_TYPE,
2199+
NULL,
22002200
format_type_be(domainOid));
22012201

22022202
/* Otherwise we can ignore views, composite types, etc */

‎src/include/commands/tablecmds.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ extern void RenameRelationInternal(Oid myrelid,
5353
OidnamespaceId);
5454

5555
externvoidfind_composite_type_dependencies(OidtypeOid,
56-
charorigRelkind,constchar*origRelname);
56+
RelationorigRelation,
57+
constchar*origTypeName);
5758

5859
externAttrNumber*varattnos_map(TupleDescolddesc,TupleDescnewdesc);
5960
externAttrNumber*varattnos_map_schema(TupleDescold,List*schema);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp