Search Postgresql Archives

Re: String literal doesn't autocast to text type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 04 Mar 2016, at 20:59, David G. Johnston <david.g.johnston@xxxxxxxxx> wrote:

It would be nice if you'd follow the list convention of bottom-posting.  Not doing that is much more annoying than the omission of version and o/s - especially the later since PostgreSQL purports to be generally o/s agnostic.

On Fri, Mar 4, 2016 at 12:17 PM, Alex Ignatov <a.ignatov@xxxxxxxxxxxxxx> wrote:
Hello!
Why string literal like 'Hello world!' doesnt automagicaly cast to text type?


But why we don't have this type cast by default in Postgres? Is there any fundamental restriction on that or there is some reasons for that?


On Friday, March 4, 2016, Melvin Davidson <melvin6925@xxxxxxxxx> wrote:
Probably because pg_typeof() returns the OID of a COLUMN in a table def.. Strings literals do not have oid's.

http://www.postgresql.org/docs/9.4/interactive/functions-info.html

"pg_typeof returns the OID of the data type of the value that is passed to it. This can be helpful for troubleshooting or dynamically constructing SQL queries. The function is declared as returning regtype, which is an OID alias type (see Section 8.18); this means that it is the same as an OID for comparison purposes but displays as a type name. For example:"

While true this doesn't actually answer the question - that being what's the motiviation for not implicitly casting away from unknown.  I suspect that the main reason is that in an extensible system like PostgreSQL it is deemed risky to have too many implicit casts.  Having one from unknown required the system to make decisions that could result in unexpected results that would be hard to catch without careful review of queries and results.  It is an issue of some contention in the community but so far no one has convinced the committees to change how this works.
 
Please in the future, ALWAYS specify your PostgreSQL version and O/S, regardless of whether or not you thinnk it is pertinent.

But don't feel too bad if you forget...
 
David J.
 
Oops! Sorry about top posting. My phone from 21th century  doesnt handle this good but I got you about it!
Deeply sorry once again!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux