jsonb subscript operator returns null when key is fetched from table

exe-dealer <exe-dealer@yandex.ru>

From: exe-dealer <exe-dealer@yandex.ru>
To: "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2022-12-09T20:06:51Z
Lists: pgsql-bugs

Attachments

<div><div><div>jsonb subscript operator returns null when key is fetched from table.</div><div> </div></div><div>PostgreSQL 15.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit</div><div> </div><div><span style="font-family:'courier new' , monospace">WITH cte AS MATERIALIZED (SELECT 'foo' k, '{"foo":"bar"}'::jsonb j)</span></div><div><span style="font-family:'courier new' , monospace">SELECT j[k], j[k || ''] FROM cte;</span></div><div> </div><div>-- returns</div><div>-- null, "bar"</div><div> </div><div>-- expected</div><div>-- "bar", "bar"</div><div> </div></div>



Commits

  1. Fix jsonb subscripting to cope with toasted subscript values.