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

Commit1f0b62e

Browse files
committed
Throw an appropriate error if ALTER COLUMN TYPE finds a dependent trigger.
Actually making this case work, if the column is used in the trigger'sWHEN condition, will take some new code that probably isn't appropriateto back-patch. For now, just throw a FEATURE_NOT_SUPPORTED error ratherthan allowing control to reach the "unexpected object" case. Per bug #5688from Daniel Grace. Back-patch to 9.0 where the possibility of such adependency was introduced.
1 parent50595b5 commit1f0b62e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6411,6 +6411,24 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
64116411
colName)));
64126412
break;
64136413

6414+
caseOCLASS_TRIGGER:
6415+
/*
6416+
* A trigger can depend on a column because the column is
6417+
* specified as an update target, or because the column is
6418+
* used in the trigger's WHEN condition. The first case would
6419+
* not require any extra work, but the second case would
6420+
* require updating the WHEN expression, which will take a
6421+
* significant amount of new code. Since we can't easily tell
6422+
* which case applies, we punt for both. FIXME someday.
6423+
*/
6424+
ereport(ERROR,
6425+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6426+
errmsg("cannot alter type of a column used in a trigger definition"),
6427+
errdetail("%s depends on column \"%s\"",
6428+
getObjectDescription(&foundObject),
6429+
colName)));
6430+
break;
6431+
64146432
caseOCLASS_DEFAULT:
64156433

64166434
/*
@@ -6431,7 +6449,6 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
64316449
caseOCLASS_OPFAMILY:
64326450
caseOCLASS_AMOP:
64336451
caseOCLASS_AMPROC:
6434-
caseOCLASS_TRIGGER:
64356452
caseOCLASS_SCHEMA:
64366453
caseOCLASS_TSPARSER:
64376454
caseOCLASS_TSDICT:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp