From: Tom Lane Date: Sat, 1 Feb 2003 22:09:41 +0000 (+0000) Subject: Remove restriction that cast functions cannot be volatile. This X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=2e1cae35fb8465e3c11e43b34948d0273a9d5e84;p=users%2Fbernd%2Fpostgres.git Remove restriction that cast functions cannot be volatile. This restriction was debatable to begin with, but it has now become obvious that it breaks forward-porting of user-defined types; contrib/lo being the most salient example. --- diff --git a/doc/src/sgml/ref/create_cast.sgml b/doc/src/sgml/ref/create_cast.sgml index 02657bc336..4c0b83517b 100644 --- a/doc/src/sgml/ref/create_cast.sgml +++ b/doc/src/sgml/ref/create_cast.sgml @@ -143,7 +143,7 @@ SELECT 'The time is ' || CAST(now() AS text); be schema-qualified. If it is not, the function will be looked up in the path. The argument type must be identical to the source type, the result data type must match the target type of - the cast. Cast functions must be marked immutable or stable. + the cast. diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 0acd616649..51d9617dfb 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -745,8 +745,15 @@ CreateCast(CreateCastStmt *stmt) elog(ERROR, "argument of cast function must match source data type"); if (procstruct->prorettype != targettypeid) elog(ERROR, "return data type of cast function must match target data type"); + /* + * Restricting the volatility of a cast function may or may not be + * a good idea in the abstract, but it definitely breaks many old + * user-defined types. Disable this check --- tgl 2/1/03 + */ +#ifdef NOT_USED if (procstruct->provolatile == PROVOLATILE_VOLATILE) elog(ERROR, "cast function must not be volatile"); +#endif if (procstruct->proisagg) elog(ERROR, "cast function must not be an aggregate function"); if (procstruct->proretset)