Thread: possible small contribution to the PostgreSQL manual? Example for two-phase commit section.

Hi.  We're trying to implement two-phase commit and did not find a
complete working example in the manual.  We found examples of the
separate pieces, but not the sequence in which to put them together.


Then we found this text,

  "PREPARE TRANSACTION is used in place of regular COMMIT to perform
the 1st phase, COMMIT PREPARED and ROLLBACK PREPARED perform the final
2nd phase commit or abort."

I'd like to offer two examples to illustrate that, for possible
inclusion in the manual:

1. Here's the sequence that two-phase commits:

  BEGIN;
  update mytable set a_col='something' where red_id=1000;
  PREPARE TRANSACTION 'foobar';
  COMMIT PREPARED 'foobar';

2. Here's the sequence that rolls back, leaving the table unchanged:

  BEGIN;
  update mytable set a_col='something' where red_id=1000;
  PREPARE TRANSACTION 'foobar';
  ROLLBACK PREPARED 'foobar';


If there is somebody on this list involved with editing the manual, this message
is for you.  :)    Examples make new things clearer, and easier to learn.

Just a suggestion.  :)

Best,
Aleksey

Aleksey Tsalolikhin wrote:
> Hi.  We're trying to implement two-phase commit and did not find a
> complete working example in the manual.  We found examples of the
> separate pieces, but not the sequence in which to put them together.

[snip]

> If there is somebody on this list involved with editing the manual, this message
> is for you.  :)    Examples make new things clearer, and easier to learn.
>
> Just a suggestion.  :)

You might want to add this as a comment on the interactive version of
the online documentation, too, so it's not lost when revising the docs
for 8.4 / 8.5 .

--
Craig Ringer

On Thu, Apr 2, 2009 at 1:23 AM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
>
> You might want to add this as a comment on the interactive version of the
> online documentation, too, so it's not lost when revising the docs for 8.4 /
> 8.5 .

Done, sir.  Thanks!

Aleksey


--
Aleksey Tsalolikhin
UNIX System Administrator
"I get stuff done!"
http://www.verticalsysadmin.com/
LinkedIn - http://www.linkedin.com/in/atsaloli