diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-10-02 18:21:41 -0400 | 
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-10-02 18:22:08 -0400 | 
| commit | 8178d9480aeedfa20157bb98e21b5f3b6eb8a957 (patch) | |
| tree | 46d0b6b7ba18b6c873b9a66783054327d2f93ab0 /src/backend/commands | |
| parent | a0ccae7ed41201251c0da51a91b84eb9d13c4ab1 (diff) | |
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's
WHEN condition, will take some new code that probably isn't appropriate
to back-patch.  For now, just throw a FEATURE_NOT_SUPPORTED error rather
than allowing control to reach the "unexpected object" case.  Per bug #5688
from Daniel Grace.  Back-patch to 9.0 where the possibility of such a
dependency was introduced.
Diffstat (limited to 'src/backend/commands')
| -rw-r--r-- | src/backend/commands/tablecmds.c | 19 | 
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index c4d81bb4fec..ab9c6a5191d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -6148,6 +6148,24 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,  								   colName)));  				break; +			case OCLASS_TRIGGER: +				/* +				 * A trigger can depend on a column because the column is +				 * specified as an update target, or because the column is +				 * used in the trigger's WHEN condition.  The first case would +				 * not require any extra work, but the second case would +				 * require updating the WHEN expression, which will take a +				 * significant amount of new code.  Since we can't easily tell +				 * which case applies, we punt for both.  FIXME someday. +				 */ +				ereport(ERROR, +						(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), +						 errmsg("cannot alter type of a column used in a trigger definition"), +						 errdetail("%s depends on column \"%s\"", +								   getObjectDescription(&foundObject), +								   colName))); +				break; +  			case OCLASS_DEFAULT:  				/* @@ -6168,7 +6186,6 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,  			case OCLASS_OPFAMILY:  			case OCLASS_AMOP:  			case OCLASS_AMPROC: -			case OCLASS_TRIGGER:  			case OCLASS_SCHEMA:  			case OCLASS_TSPARSER:  			case OCLASS_TSDICT:  | 
