Unexpected behavior of updating domain array that is based on a composite

Поиск
Список
Период
Сортировка
От Japin Li
Тема Unexpected behavior of updating domain array that is based on a composite
Дата
Msg-id MEYP282MB1669BED5CEFE711E00C7421EB6BD9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
обсуждение исходный текст
Список pgsql-hackers
Hi, hackers

While reading the patch in [1], I found there is an unexpected behavior when
update the domain array that is based on a composite.

Steps to reproduce:

1)
CREATE TYPE two_ints as (if1 int, if2 int);
CREATE DOMAIN domain AS two_ints CHECK ((VALUE).if1 > 0);
CREATE TABLE domain_indirection_test (f1 int, f3 domain, domain_array domain[]);
INSERT INTO domain_indirection_test (f1,f3.if1) VALUES (0, 1);

2) The following test besed on patch in [1].
UPDATE domain_indirection_test SET domain_array[0].if2 = 5;
select * from domain_indirection_test;
 f1 |  f3  |  domain_array
----+------+----------------
  0 | (1,) | [0:0]={"(,5)"}

3)
UPDATE domain_indirection_test SET domain_array[0].if1 = 10;
select * from domain_indirection_test ;
 f1 |  f3  |  domain_array
----+------+-----------------
  0 | (1,) | [0:0]={"(10,)"}
(1 row)

4)
UPDATE domain_indirection_test SET domain_array[0].if1 = 10, domain_array[0].if2 =  5;
select * from domain_indirection_test ;
 f1 |  f3  |  domain_array
----+------+----------------
  0 | (1,) | [0:0]={"(,5)"}
(1 row)

5) 
UPDATE domain_indirection_test SET domain_array[0].if2 = 10, domain_array[0].if1 =  5;
select * from domain_indirection_test ;
 f1 |  f3  |  domain_array
----+------+----------------
  0 | (1,) | [0:0]={"(5,)"}
(1 row)

6) Work as expected.
UPDATE domain_indirection_test SET domain_array[0] = (10, 5);
select * from domain_indirection_test ;
 f1 |  f3  |   domain_array
----+------+------------------
  0 | (1,) | [0:0]={"(10,5)"}
(1 row)

[1]
https://www.postgresql.org/message-id/PH0PR21MB132823A46AA36F0685B7A29AD8BD9%40PH0PR21MB1328.namprd21.prod.outlook.com
-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: parallelizing the archiver
Следующее
От: Robert Haas
Дата:
Сообщение: Re: XTS cipher mode for cluster file encryption