pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15311: Incorrect comparison of the empty array with the value of the custom type from the table field
2+ messages / 2 participants
[nested] [flat]

* BUG #15311: Incorrect comparison of the empty array with the value of the custom type from the table field
@ 2018-08-07 09:59  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-08-07 09:59 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: vvvasilev93@gmail.com

The following bug has been logged on the website:

Bug reference:      15311
Logged by:          Виктор Васильев
Email address:      vvvasilev93@gmail.com
PostgreSQL version: 10.4
Operating system:   Ubuntu 16.04 LTS
Description:        

test_db=> select version()
PostgreSQL 10.4 (Ubuntu 10.4-2.pgdg16.04+1) on i686-pc-linux-gnu, compiled
by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 32-bit

test_db=> create type type_mnemonic as enum ('ex', 'in');
CREATE TYPE

test_db=> create table tbl_for_tst(id integer, type type_mnemonic[]);
CREATE TABLE

test_db=> insert into tbl_for_tst(id, type) values (1, '{ex}'), (2, '{in}'),
(3, '{ex}'), (4, '{in}');
INSERT 0 4

test_db=> select * from tbl_for_tst;
 id | type
----+------
  1 | {ex}
  2 | {in}
  3 | {ex}
  4 | {in}
(4 строки)

test_db=> do $$
declare
  r tbl_for_tst;
  vtbl_for_tst jsonb;
  adata jsonb := '{"type":[]}';
begin
  select to_jsonb(e)
    into vtbl_for_tst
    from tbl_for_tst e
   where e.id = 1;

  r := jsonb_populate_record(r, vtbl_for_tst || adata);

  update tbl_for_tst e
     set type = r.type
   where e.id = 1;
end;
$$;
DO

test_db=> select id, type, type = '{}' as res from tbl_for_tst;
 id | type | res
----+------+----------
  2 | {in} | f
  3 | {ex} | f
  4 | {in} | f
  1 | {}   | f
(4 строки)

test_db=> update tbl_for_tst set type = '{}' where id = 4;
UPDATE 1

test_db=> select id, type, type = '{}' as res from tbl_for_tst;
 id | type | res
----+------+----------
  2 | {in} | f
  3 | {ex} | f
  1 | {}   | f
  4 | {}   | t
(4 строки)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #15311: Incorrect comparison of the empty array with the value of the custom type from the table field
@ 2018-08-07 14:34  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-08-07 14:34 UTC (permalink / raw)
  To: vvvasilev93@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> [ bogus empty array can be created by jsonb_populate_record ]

I can reproduce this in 10.5, but not in v11 or HEAD.  I believe
it was fixed as a consequence of the patch for bug #14826:

https://postgr.es/m/flat/20170923125723.1448.39412@wrigleys.postgresql.org
https://postgr.es/m/20570.1506198383@sss.pgh.pa.us

The reasons for not back-patching still seem good to me.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-08-07 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-07 09:59 BUG #15311: Incorrect comparison of the empty array with the value of the custom type from the table field PG Bug reporting form <noreply@postgresql.org>
2018-08-07 14:34 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox