Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Alex Ignatov
> On 04 Mar 2016, at 21:08, Tom Lane wrote: > > Alex Ignatov writes: >> Why string literal like 'Hello world!' doesnt automagicaly cast to text >> type? > > Because it's not necessarily a string. It might be meant to be point, > or json, or any number of other types. > >> Sure we can creat

Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Alex Ignatov
> On 04 Mar 2016, at 20:59, David G. Johnston > 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. >

Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Tom Lane
Alex Ignatov writes: > Why string literal like 'Hello world!' doesnt automagicaly cast to text > type? Because it's not necessarily a string. It might be meant to be point, or json, or any number of other types. > Sure we can create our cast: > postgres=# create cast (unknown as text) with ino

Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread David G. Johnston
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 > wrote: > >> Hello! >> W

Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Alex Ignatov
Oh! Great answer! Thats what i want to know!!! Thank you Pavel about explanation!!! Alex Ignatov Postgres Professional: http://www.postgrespro.com Russian Postgres Company > On 04 Mar 2016, at 20:45, Pavel Stehule wrote: > > Hi > > 2016-03-04 18:29 GMT+01:00 Melvin Davidson : >> Probably beca

Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Pavel Stehule
Hi 2016-03-04 18:29 GMT+01:00 Melvin Davidson : > Probably because pg_typeof() returns the OID of a COLUMN in a table def.. > Strings literals do not have oid's. > no this is not a reason. String literal has fictive "unknown" type. Real type is derivated from context - operators, function param

Re: [GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Melvin Davidson
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 o

[GENERAL] String literal doesn't autocast to text type

2016-03-04 Thread Alex Ignatov
Hello! Why string literal like 'Hello world!' doesnt automagicaly cast to text type? postgres=# select pg_typeof('Hello world'); pg_typeof --- unknown (1 row) But for example literal like 1.1 automagically cast to numeric( not float8, float4, whatever) postgres=# select pg_typeof(1