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

Commit8178d94

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 parenta0ccae7 commit8178d94

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
@@ -6148,6 +6148,24 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
61486148
colName)));
61496149
break;
61506150

6151+
caseOCLASS_TRIGGER:
6152+
/*
6153+
* A trigger can depend on a column because the column is
6154+
* specified as an update target, or because the column is
6155+
* used in the trigger's WHEN condition. The first case would
6156+
* not require any extra work, but the second case would
6157+
* require updating the WHEN expression, which will take a
6158+
* significant amount of new code. Since we can't easily tell
6159+
* which case applies, we punt for both. FIXME someday.
6160+
*/
6161+
ereport(ERROR,
6162+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
6163+
errmsg("cannot alter type of a column used in a trigger definition"),
6164+
errdetail("%s depends on column \"%s\"",
6165+
getObjectDescription(&foundObject),
6166+
colName)));
6167+
break;
6168+
61516169
caseOCLASS_DEFAULT:
61526170

61536171
/*
@@ -6168,7 +6186,6 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
61686186
caseOCLASS_OPFAMILY:
61696187
caseOCLASS_AMOP:
61706188
caseOCLASS_AMPROC:
6171-
caseOCLASS_TRIGGER:
61726189
caseOCLASS_SCHEMA:
61736190
caseOCLASS_TSPARSER:
61746191
caseOCLASS_TSDICT:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp