Re: [HACKERS] Cast jsonb to numeric, int, float, bool

2017-02-01 Thread Nikita Glukhov
On 02.02.2017 01:07, Jim Nasby wrote: On 2/1/17 8:26 AM, Nikita Glukhov wrote: Some comments about the code: I think it would be better to * add function for extraction of scalars from pseudo-arrays * iterate until WJB_DONE to pfree iterator I'm not sure what your intent here is, but if the

Re: [HACKERS] Cast jsonb to numeric, int, float, bool

2017-02-01 Thread Jim Nasby
On 2/1/17 8:26 AM, Nikita Glukhov wrote: If you find it useful, I can also add support of json and other types, such as smallint and bigint. Yes, I'd like to have support for other types and maybe for json. There's been previous discussion about something similar, which would be better

Re: [HACKERS] Cast jsonb to numeric, int, float, bool

2017-02-01 Thread Nikita Glukhov
On 01.02.2017 14:21,Anastasia Lubennikova wrote: Now the simplest way to extract booleans and numbers from json/jsonb is to cast it to text and then cast to the appropriate type: ... This patch implements direct casts from jsonb numeric (jbvNumeric) to numeric, int4 and float8, and from jsonb