Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: paulovieira(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string
Date: 2015-08-03 16:40:12
Message-ID: 9283.1438620012@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

paulovieira(at)gmail(dot)com writes:
> 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

> $$;

> ERROR: 22P02: invalid input syntax for type json
> DETAIL: Token "abc" is invalid.

This does not seem like a bug, because the value of the data field is
just abc, and that isn't JSON. You'd need something more like

input_data json := '{"id": 1, "data": "\"abc\""}';

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message lthompson 2015-08-03 18:23:38 BUG #13536: SQLParamData thows "Invalid Endian" error
Previous Message Francisco Olarte 2015-08-03 16:31:28 Re: BUG #13534: Pgadmin crash when changing font