Robert Haas <robertmh...@gmail.com> writes: > So I think the answer to your question is probably no, purely on the > grounds that we have set a new world record for byzantine casting > systems. A more fair comparison might be to look at what other SQL > systems allow. Oracle, MySQL, and SQL Server all permit implicit > casting between integer and text, and a call to LPAD with an integer > first argument works just fine in both Oracle and MySQL. It doesn't > work in SQL server, but that's only because SQL server doesn't have it > as a built-in function. FWICT, there's no general problem with > passing an integer to a function that expects varchar in any > mainstream RDBMS other than PostgreSQL.
I think this is ignoring the fact that we have an extensible type system, and thus a lot more room for problems if we allow too many implicit casts. It might also be worth noting that some of this complexity comes from the SQL standard. It is at least arguable that the three-way coercion distinction exists in the standard: they have got different rules for what happens in an explicit CAST, in an assignment context, and in plain expressions. So it's not that relevant whether other mainstream programming languages have comparable constructs. Having said that, though, I think you could make an argument that there's some support for this idea in the SQL standard. In SQL99 10.4 <routine invocation>, it appears that once you've identified a target routine to be called, you're supposed to use the "store assignment" rules to decide how to convert the supplied expression(s) to the parameter data type(s). However, it's not clear to me that that should be taken as conclusive, because the $64 question here is exactly how sure you are in your identification of the target routine. SQL99 doesn't seem to allow anywhere near as much function overloading as we do --- and of course they have no notion of overloaded or user-defined operators at all. As far as I can tell from 10.4, you are supposed to be able to identify the target routine without any consideration of the actual parameters' types. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers