public inbox for [email protected]  
help / color / mirror / Atom feed
An example in UPDATE documentation page is a bit outdated
2+ messages / 2 participants
[nested] [flat]

* An example in UPDATE documentation page is a bit outdated
@ 2026-03-07 11:54 PG Doc comments form <[email protected]>
  2026-03-07 20:45 ` Re: An example in UPDATE documentation page is a bit outdated David G. Johnston <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Doc comments form @ 2026-03-07 11:54 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/18/sql-update.html
Description:

There is an example on UPDATE documentation page --

BEGIN;
-- other operations
SAVEPOINT sp1;
INSERT INTO wines VALUES('Chateau Lafite 2003', '24');
-- Assume the above fails because of a unique key violation,
-- so now we issue these commands:
ROLLBACK TO sp1;
UPDATE wines SET stock = stock + 24 WHERE winename = 'Chateau Lafite 2003';
-- continue with other operations, and eventually
COMMIT;

Now we can use INSERT ... ON CONFLICT DO UPDATE command in this case.






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

* Re: An example in UPDATE documentation page is a bit outdated
  2026-03-07 11:54 An example in UPDATE documentation page is a bit outdated PG Doc comments form <[email protected]>
@ 2026-03-07 20:45 ` David G. Johnston <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2026-03-07 20:45 UTC (permalink / raw)
  To: [email protected]; [email protected]

On Sat, Mar 7, 2026 at 1:38 PM PG Doc comments form <[email protected]>
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/18/sql-update.html
> Description:
>
> There is an example on UPDATE documentation page --
>
> BEGIN;
> -- other operations
> SAVEPOINT sp1;
> INSERT INTO wines VALUES('Chateau Lafite 2003', '24');
> -- Assume the above fails because of a unique key violation,
> -- so now we issue these commands:
> ROLLBACK TO sp1;
> UPDATE wines SET stock = stock + 24 WHERE winename = 'Chateau Lafite 2003';
> -- continue with other operations, and eventually
> COMMIT;
>
> Now we can use INSERT ... ON CONFLICT DO UPDATE command in this case.
>
>
My second reaction was why would we put either variant on the update
command reference page.

Admittedly both of those examples are probably good to have somewhere, and
I'm not sure where would be the most discoverable place.

I'd rather remove the example and write a paragraph pointing the reader to
the savepoint and insert pages if they have a need to perform a conditional
insert/update pairing.

David J.


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


end of thread, other threads:[~2026-03-07 20:45 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-07 11:54 An example in UPDATE documentation page is a bit outdated PG Doc comments form <[email protected]>
2026-03-07 20:45 ` David G. Johnston <[email protected]>

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