BUG #9519: Allows storing scalar json, but fails when querying

From: alf(dot)kristian(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #9519: Allows storing scalar json, but fails when querying
Date: 2014-03-10 15:09:52
Message-ID: 20140310150952.398.53642@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 9519
Logged by: Alf Kristian Støyle
Email address: alf(dot)kristian(at)gmail(dot)com
PostgreSQL version: 9.3.2
Operating system: Red Hat 4.6.3-2
Description:

Steps to reproduce:
create table jtest (data json);
=> CREATE TABLE

insert into jtest (data) values ('1');
=> INSERT 0 1

select data->>'foo' from jtest;
=> ERROR: cannot extract element from a scalar

I think the insert should fail, since '1' is not valid JSON.

After the data is in the database every query using the ->> operator,
hitting the row containing '1' will fail.

Our database runs in Amazon RDS, 'select version();' returns:
PostgreSQL 9.3.2 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.6.3
20120306 (Red Hat 4.6.3-2), 64-bit

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marko Tiikkaja 2014-03-10 19:52:01 Re: BUG #9519: Allows storing scalar json, but fails when querying
Previous Message Mike Blackwell 2014-03-10 15:06:55 Re: BUG #9518: temporary login failure - "missing pg_hba entry"