Re: Proposal for resolving casting issues
От | Tom Lane |
---|---|
Тема | Re: Proposal for resolving casting issues |
Дата | |
Msg-id | 24357.1032277000@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Proposal for resolving casting issues (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Proposal for resolving casting issues
Re: Proposal for resolving casting issues |
Список | pgsql-hackers |
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 sourcedata type are converted into a value of a target data type according to the Syntax Rules and GeneralRules of Subclause 6.22, "<cast specification>". Data conversions between predefined data types andbetween constructed types are defined by the rules of this part of ISO/IEC 9075. Data conversions between one ormore 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 parameterwhose declared type is the same as the source data type and a result data type that is the targetdata type. A cast function may optionally be specified to be implicitly invoked whenever values are assignedto 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
В списке pgsql-hackers по дате отправления: