Re: Casting INT4 to BOOL...
От | Stephan Szabo |
---|---|
Тема | Re: Casting INT4 to BOOL... |
Дата | |
Msg-id | 20041011225149.I37114@megazone.bigpanda.com обсуждение исходный текст |
Ответ на | Re: Casting INT4 to BOOL... (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-patches |
On Mon, 11 Oct 2004, Tom Lane wrote: > Stephan Szabo <sszabo@megazone.bigpanda.com> writes: > > On Mon, 11 Oct 2004, Sean Chittenden wrote: > >> I would posit that this is the desired behavior as it's consistent with > >> every language I can think of. > > > However, AFAIK it's inconsitent with the type input function which > > supports '1' and '0' but not other integers. > [strawman snipped] > The question for an integer-to-bool conversion is what is useful and > expected behavior for that conversion; I don't think that's necessarily > the same as what the textual conversion should do. > > A possibly useful analogy is that real-to-integer coercion rounds off > fractions; it doesn't error out, even though the integer input function > won't take a string that includes a decimal point. Well, technically AFAICS, a string to integer conversion has to follow the same general rules as numeric to integer by SQL99. So a varchar value of '2.5' cast to int should work and give you the same value as 2.5 cast to int (or at least, I can't see any other way to read 6.22GR6b). But since we do odd things with quoted literals, it makes the case anyway and I withdraw the comment.
В списке pgsql-patches по дате отправления: