two bugs

From: zhxpgh <zhxpgh(at)foxmail(dot)com>
To: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: two bugs
Date: 2023-02-25 01:43:22
Message-ID: tencent_7294503D958856DB8D18599B2CF2C0AA4406@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The first:
zhxp(at)THINKPAD-E14:~/repositories/postgres/postgres$ psql
psql (12.14)
Type&nbsp;"help"&nbsp;for help.

postgres=# create&nbsp;table&nbsp;trigtest(i serial&nbsp;primary key);
CREATE&nbsp;TABLE
postgres=# create&nbsp;table&nbsp;trigtestfk(i int&nbsp;references&nbsp;trigtest(i) on delete cascade);
CREATE&nbsp;TABLE
postgres=# insert into&nbsp;trigtest default&nbsp;values;
INSERT&nbsp;0&nbsp;1
postgres=# insert into&nbsp;trigtest default&nbsp;values;
INSERT&nbsp;0&nbsp;1
postgres=# insert into&nbsp;trigtest default&nbsp;values;
INSERT&nbsp;0&nbsp;1
postgres=# select&nbsp;* from&nbsp;trigtest;
&nbsp;i
---
&nbsp;1
&nbsp;2
&nbsp;3
(3&nbsp;rows)

postgres=# insert into&nbsp;trigtestfk values&nbsp;(1);
INSERT&nbsp;0&nbsp;1
postgres=# alter&nbsp;table&nbsp;trigtest disable&nbsp;trigger all;
ALTER&nbsp;TABLE
postgres=# delete&nbsp;from&nbsp;trigtest where&nbsp;i = 1;
DELETE&nbsp;1
postgres=# select&nbsp;* from&nbsp;trigtest;
&nbsp;i
---
&nbsp;2
&nbsp;3
(2&nbsp;rows)

postgres=# select&nbsp;* from&nbsp;trigtestfk;
&nbsp;i
---
&nbsp;1
(1&nbsp;row)

postgres=# \q
zhxp(at)THINKPAD-E14:~/release/pg$ bin/pg_dump &gt; trigtets.sql
zhxp(at)THINKPAD-E14:~/release/pg$ bin/createdb trigtest
zhxp(at)THINKPAD-E14:~/release/pg$ psql trigtest
psql (12.14)
Type&nbsp;"help"&nbsp;for help.

trigtest=# \i /home/zhxp/release/pg/trigtets.sql
SET
SET
SET
SET
SET
&nbsp;set_config
------------

(1&nbsp;row)

SET
SET
SET
SET
SET
SET
CREATE&nbsp;TABLE
ALTER&nbsp;TABLE
CREATE&nbsp;SEQUENCE
ALTER&nbsp;TABLE
ALTER&nbsp;SEQUENCE
CREATE&nbsp;TABLE
ALTER&nbsp;TABLE
ALTER&nbsp;TABLE
COPY&nbsp;2
COPY&nbsp;1
&nbsp;setval
--------
&nbsp; &nbsp; &nbsp; 4
(1&nbsp;row)

ALTER&nbsp;TABLE
psql:/home/zhxp/release/pg/trigtets.sql:113: ERROR: &nbsp;insert&nbsp;or&nbsp;update&nbsp;on&nbsp;table&nbsp;"trigtestfk"&nbsp;violates foreign key&nbsp;constraint&nbsp;"trigtestfk_i_fkey"
DETAIL: &nbsp;Key&nbsp;(i)=(1) is&nbsp;not&nbsp;present in&nbsp;table&nbsp;"trigtest".
trigtest=#

and the second:
zhxp(at)THINKPAD-E14:~/release/pg$ psql
psql (12.14)
Type&nbsp;"help"&nbsp;for help.

postgres=# create&nbsp;table&nbsp;t1(i int);
CREATE&nbsp;TABLE
postgres=# insert into&nbsp;t1 values&nbsp;(1);
INSERT&nbsp;0&nbsp;1
postgres=# create&nbsp;materialized view mv_t1 as&nbsp;select&nbsp;* from&nbsp;t1;
SELECT&nbsp;1
postgres=# create&nbsp;unique&nbsp;index&nbsp;on&nbsp;mv_t1(i);
CREATE&nbsp;INDEX
postgres=# insert into&nbsp;t1 values&nbsp;(1);
INSERT&nbsp;0&nbsp;1
postgres=# select&nbsp;* from&nbsp;t1;
&nbsp;i
---
&nbsp;1
&nbsp;1
(2&nbsp;rows)

postgres=# select&nbsp;* from&nbsp;mv_t1;
&nbsp;i
---
&nbsp;1
(1&nbsp;row)

postgres=# \q
zhxp(at)THINKPAD-E14:~/release/pg$ bin/pg_dump &gt; mvtest.sql
zhxp(at)THINKPAD-E14:~/release/pg$ bin/createdb mvtest
zhxp(at)THINKPAD-E14:~/release/pg$ psql mvtest
psql (12.14)
Type&nbsp;"help"&nbsp;for help.

mvtest=# \i /home/zhxp/release/pg/mvtest.sql
SET
SET
SET
SET
SET
&nbsp;set_config
------------

(1&nbsp;row)

SET
SET
SET
SET
SET
SET
CREATE&nbsp;TABLE
ALTER&nbsp;TABLE
CREATE&nbsp;MATERIALIZED VIEW
ALTER&nbsp;TABLE
COPY&nbsp;2
CREATE&nbsp;INDEX
psql:/home/zhxp/release/pg/mvtest.sql:67: ERROR: &nbsp;could not&nbsp;create&nbsp;unique&nbsp;index&nbsp;"mv_t1_i_idx"
DETAIL: &nbsp;Key&nbsp;(i)=(1) is&nbsp;duplicated.
mvtest=#

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2023-02-25 03:39:11 Re: BUG #17744: Fail Assert while recoverying from pg_basebackup
Previous Message Andres Freund 2023-02-24 23:57:04 Re: BUG #17800: ON CONFLICT DO UPDATE fails to detect incompatible fields that leads to a server crash