Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZ3yu-0006gS-Ql for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2017 23:06:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cZ3yt-0001G8-Ns for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2017 23:06:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZ3xU-00083W-FB for pgsql-hackers@postgresql.org; Wed, 01 Feb 2017 23:05:00 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZ3xR-0005sE-6h for pgsql-hackers@postgresql.org; Wed, 01 Feb 2017 23:04:59 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 0704621C2A93; Thu, 2 Feb 2017 02:04:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from [10.100.236.30] (unknown [195.82.154.27]) by mail.postgrespro.ru (Postfix) with ESMTPSA id DCA2421C2A78; Thu, 2 Feb 2017 02:04:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1485990294; bh=rBT7up6Cb0bS2Rbo/CGwG59LRZXqWX2zboRLHdbqwfc=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=n+IhOJEBdErH00LmH/nfgNaK3koRSr1ZCKrneQ7tlRxZh49ySvUobdoVjkxgPVWdy QI6fNzeP7mGpW/pUXqvfk7PeVARVZBPEC/C79LeyBK1h26bqBN1TFmly71RGg6vbtn HSblN5tDvFpnqaC3MQTIcTdedDqLgTD2sZX3hWHU= Subject: Re: Cast jsonb to numeric, int, float, bool To: Jim Nasby , a.lubennikova@postgrespro.ru References: <0154d35a-24ae-f063-5273-9ffcdf1c7f2e@postgrespro.ru> <55137679-fd6b-baf0-bfbf-6558ce5cb409@postgrespro.ru> <6e36f08b-0fa5-445e-55bc-654b9afb7f04@BlueTreble.com> Cc: PostgreSQL mailing lists From: Nikita Glukhov Organization: Postgres Professional Message-ID: <8ad4288a-b6b4-d799-2887-c94e5c3c69f3@postgrespro.ru> Date: Thu, 2 Feb 2017 02:02:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <6e36f08b-0fa5-445e-55bc-654b9afb7f04@BlueTreble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers