Re: Cast jsonb to numeric, int, float, bool

From: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>, a(dot)lubennikova(at)postgrespro(dot)ru
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cast jsonb to numeric, int, float, bool
Date: 2017-02-01 23:02:17
Message-ID: 8ad4288a-b6b4-d799-2887-c94e5c3c69f3@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 idea is that a json array
> would magically cast to a bool or a number data type I think that's a bad idea.

My idea, of course, is not about casting any json array to a scalar. It is only
about helper subroutine for extraction of top-level jsonb scalars that are always
stored as one-element pseudo-arrays with special flag F_SCALAR in the array header.

--
Nikita Glukhov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2017-02-01 23:09:03 TRAP: FailedAssertion("!(hassrf)", File: "nodeProjectSet.c", Line: 180)
Previous Message Claudio Freire 2017-02-01 22:55:16 Re: Vacuum: allow usage of more than 1GB of work mem