Re: INSERT ... ON CONFLICT DO SELECT [FOR ...] take 2

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: Joel Jacobson <joel(at)compiler(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Marko Tiikkaja <marko(at)joh(dot)to>
Subject: Re: INSERT ... ON CONFLICT DO SELECT [FOR ...] take 2
Date: 2025-03-10 13:05:22
Message-ID: CALdSSPiVBc66zqmMCA8oT9wa1rTEDVGCZ4tPQisruLF+iGzLVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 5 Mar 2025 at 07:33, Andreas Karlsson <andreas(at)proxel(dot)se> wrote:
>
> On 3/4/25 10:24 AM, Andreas Karlsson wrote:
> > Rebased the patch to add support for OLD.* and NEW.*.
>
> Apparently the CI did not like that version.
>
> Andreas

Hi!
Applied v6.

1) Should we answer INSERT 0 10 here?

```
reshke=# table tt ;
i
---
1
2
3
4
5
(5 rows)
reshke=# insert into tt values(5) on conflict (i) do select returning *;
i
---
5
(1 row)

INSERT 0 1
```

2) PostgreSQL fails with this query:

> reshke=*# insert into tt values(5) on conflict (i) do select for update returning *;
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
!?>

```
Program received signal SIGSEGV, Segmentation fault.
0x000055960508713e in assign_collations_walker ()
(gdb) bt
#0 0x000055960508713e in assign_collations_walker ()
#1 0x00005596052653c2 in expression_tree_walker_impl ()
#2 0x0000559605087619 in assign_collations_walker ()
#3 0x0000559605086f8b in assign_expr_collations ()
#4 0x0000559605086e99 in assign_query_collations_walker ()
#5 0x0000559605265a46 in query_tree_walker_impl ()
#6 0x0000559605086e2d in assign_query_collations ()
#7 0x0000559605042c22 in transformInsertStmt ()
#8 0x000055960504192f in transformStmt ()
#9 0x000055960504186b in transformOptionalSelectInto ()
#10 0x0000559605041798 in transformTopLevelStmt ()
#11 0x000055960504131e in parse_analyze_fixedparams ()
#12 0x000055960545b908 in pg_analyze_and_rewrite_fixedparams ()
#13 0x000055960545c124 in exec_simple_query ()
#14 0x0000559605461314 in PostgresMain ()
#15 0x00005596054585cb in BackendMain ()
#16 0x000055960537dee9 in postmaster_child_launch ()
#17 0x0000559605384286 in BackendStartup ()
#18 0x0000559605381c31 in ServerLoop ()
#19 0x0000559605381531 in PostmasterMain ()
#20 0x0000559605236d2c in main ()
(gdb) Quit
(gdb) quit
```

I tried to recompile with --enable-debug and issue stop reproducing...

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2025-03-10 13:05:32 Re: Wrong results with subquery pullup and grouping sets
Previous Message Florents Tselai 2025-03-10 12:43:15 Re: encode/decode support for base64url