Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZMHmD-0003zz-Kk for pgsql-bugs@arkaria.postgresql.org; Mon, 03 Aug 2015 15:35:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZMHmD-0001wK-5s for pgsql-bugs@arkaria.postgresql.org; Mon, 03 Aug 2015 15:35:45 +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) (envelope-from ) id 1ZM4mQ-0008TL-U0 for pgsql-bugs@postgresql.org; Mon, 03 Aug 2015 01:43:06 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZM4mO-00046B-FU for pgsql-bugs@postgresql.org; Mon, 03 Aug 2015 01:43:06 +0000 MIME-Version: 1.0 Subject: BUG #13533: jsonb_populate_record does not work when the value is a simple string To: pgsql-bugs@postgresql.org From: paulovieira@gmail.com Date: Mon, 03 Aug 2015 01:42:14 +0000 Message-ID: <20150803014214.1017.85098@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13533 Logged by: Paulo Vieira Email address: paulovieira@gmail.com PostgreSQL version: 9.5alpha1 Operating system: Linux Ubuntu 14.4 Description: 1) Reproduce the problem: --------------------------------------------------- drop table if exists temp_table; create table temp_table(id int, data json); do $$ declare input_data json := '{"id": 1, "data": "abc"}'; input_row temp_table%ROWTYPE; begin for input_row in (select * from json_populate_record(null::temp_table,input_data)) loop raise notice '%', input_row.data; end loop; end $$; --------------------------------------------------- 2) Output I got: ERROR: 22P02: invalid input syntax for type json DETAIL: Token "abc" is invalid. CONTEXT: JSON data, line 1: abc PL/pgSQL function inline_code_block line 8 at FOR over SELECT rows LOCATION: report_invalid_token, json.c:1178 3) Expected output: NOTICE: "abc" I expected this output because json_populate_record works well with all json values expect when the value is a simple string. I think this is an incoherent behaviour (a string is a valid json value). This bug affects also the jsonb_populate_record variant, as well as the *_populate_recordset. 4) PostgreSQL version: 9.5alpha1 and 9.4 (haven't tested in 9.3) 5) Platform information: Linux Ubuntu 14.4 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs