I wrote: > I think we must extend pg_cast's castimplicit column to a three-way value: > * okay as implicit cast in expression (or in assignment) > * okay as implicit cast in assignment only > * okay only as explicit cast
> Question: what shall we call these alternatives in CREATE CAST? The SQL99 > phrase AS ASSIGNMENT looks like it should mean the second, but I think > the spec semantics require it to mean the first. Ugh. Perhaps AS > ASSIGNMENT ONLY for the second case? On looking more closely, SQL99 appears to define user-defined casts as invocable *only* in explicit cast and assignment contexts. Part 2 sez: 4.13 Data conversions Explicit data conversions can be specified by a CAST operator. A CAST operator defines how values of a source data type are converted into a value of a target data type according to the Syntax Rules and General Rules of Subclause 6.22, "<cast specification>". Data conversions between predefined data types and between constructed types are defined by the rules of this part of ISO/IEC 9075. Data conversions between one or more user-defined types are defined by a user-defined cast. A user-defined cast identifies an SQL-invoked function, called the cast function, that has one SQL parameter whose declared type is the same as the source data type and a result data type that is the target data type. A cast function may optionally be specified to be implicitly invoked whenever values are assigned to targets of its result data type. Such a cast function is called an implicitly invocable cast function. This seems to mean that we can get away with defining AS ASSIGNMENT to mean my second category (implicit in assignment only), and then picking some more natural term for my first category (implicit anywhere). I favor using IMPLICIT, which would make the syntax of CREATE CAST be CREATE CAST (sourcetype AS targettype) WITH FUNCTION funcname (argtype) [ AS ASSIGNMENT | IMPLICIT ] CREATE CAST (sourcetype AS targettype) WITHOUT FUNCTION [ AS ASSIGNMENT | IMPLICIT ] Or possibly it should be AS IMPLICIT? Comments? regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly