On Wed, Jun 13, 2007 at 02:12:37AM -0400, Chuck McDevitt wrote: > So, where x = '(1,2)' might be legal for comparing to x, but a field of > type varchar(5) might not be, as in where x = y, where y is type > varchar(5) containing '(1,2)'.
Normally, just about every type can be converted to or from text. So if postgres converted to varchar first you have problems with the statement x='const' where x is type "foo". It's now ambiguous since you either convert x to varchar or the constant to "foo". Instead, postgres marks the constant as unknown and now it always gets converted because nothing can convert to unknown. Thus far this system has worked excellently, though not perfectly obviously. It matches people's expectations well, which is the most important part. > I find PostgreSQL's handling of this strange, as I come from systems > where 'xxx' is either a varchar or char type, in all contexts, and > implicit casts handle any needed conversions. > But now I understand why it does things this way. User-defined types makes for lots of interesting choices, but they are by far the most powerful feature of postgres and we don't want to mess with that. Have a nice day, -- Martijn van Oosterhout <[EMAIL PROTECTED]> http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to > litigate.
Description: Digital signature