Re: row_to_json bug with index only scans: empty keys!

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Ross Reedstrom <reedstrm(at)rice(dot)edu>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: row_to_json bug with index only scans: empty keys!
Date: 2014-11-07 16:17:48
Message-ID: 545CF0AC.9040809@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 11/07/2014 10:51 AM, Ross Reedstrom wrote:
> This is a serious bug in 9.3.5 and 9.4 beta3:
>
> row_to_json() yields empty strings for json keys if the data is
> fulfilled by an index only scan.
>
> Example:
>
> testjson=# select count(*) from document_acl;
> count
> -------
> 426
> (1 row)
>
> testjson=# SELECT row_to_json(combined_rows) FROM (
> SELECT uuid, user_id AS uid, permission
> FROM document_acl_text AS acl
> WHERE uuid = '8f774048-8936-4d7f-aa38-1974c91bbef2'
> ORDER BY user_id ASC, permission ASC
> ) as combined_rows;
> row_to_json
> ---------------------------------------------------------------------
> {"":"8f774048-8936-4d7f-aa38-1974c91bbef2","":"admin","":"publish"}

That seems odd. Here's what the relevant code does:

td = DatumGetHeapTupleHeader(composite);

/* Extract rowtype info and find a tupdesc */
tupType = HeapTupleHeaderGetTypeId(td);
tupTypmod = HeapTupleHeaderGetTypMod(td);
tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);

...
for (i = 0; i < tupdesc->natts; i++)
...

attname = NameStr(tupdesc->attrs[i]->attname);
escape_json(result, attname);

Could this be a bug in lookup_rowtype_tupdesc()?

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Atri Sharma 2014-11-07 16:31:53 Re: Representing a SRF return column in catalogs
Previous Message Robert Haas 2014-11-07 16:12:37 Re: recovery_target_time and standby_mode