pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Brian Oki \(boki\) <boki@cisco.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Support for distributed transactions
Date: Thu, 11 Oct 2007 19:52:01 +0100
Message-ID: <470E70D1.2020906@enterprisedb.com> (raw)
In-Reply-To: <5FDF17E5F815DD429DBA1B1C2159DC0344E5A4@xmb-sjc-239.amer.cisco.com>
References: <5FDF17E5F815DD429DBA1B1C2159DC0344E5A4@xmb-sjc-239.amer.cisco.com>

Brian Oki (boki) wrote:
> It is unclear to me how SQL statements can be executed at remote nodes
> from a single coordinator and then use distributed two-phase commit (via
> 'prepare transaction tid' and 'commit prepared'). I worked at Oracle in
> the distributed database group and could do things like the following
> using PL/SQL, where we insert the same row into the same table on three
> different nodes, including the local one:
>     insert into foo ....
>     insert into foo@node2.acme.com <blocked::mailto:foo@node2.acme.com>
> ....
>     insert into foo@node3.acme.com <mailto:foo@node3.acme.com>  ....
>     COMMIT
> This sequence will insert a row into all three tables and do the
> distributed atomic commitment. 
>  
> My question is this: How does PostgreSQL 8.2.5 execute DML statements
> (insert, update, delete, select) on remote nodes as part of the same
> transaction? Where is the syntax specified?

Unfortunately PostgreSQL doesn't have remote or federated queries like
that. You can't reference tables in different nodes. PostgreSQL does
support two-phase commit, but what you're looking for is much more than
that.

There is, however, a contrib module called dblink, that you can use to
submit SQL queries to remote database, but it's not integrated so that
you could do "INSERT foo@remotenode". By using dblink in update rules on
a view you can emulate that to some extent. But dblink won't do
two-phase commit, so you'll find that the updates to remote tables are
committed as soon as the statement finishes.

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com



view thread (2+ messages)

Message-ID: <470E70D1.2020906@enterprisedb.com>
Permalink:  ../470E70D1.2020906@enterprisedb.com/
Also on:    postgresql.org/message-id/470E70D1.2020906@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: heikki@enterprisedb.com, boki@cisco.com
  Subject: Re: Support for distributed transactions
  In-Reply-To: <470E70D1.2020906@enterprisedb.com>
  References: <5FDF17E5F815DD429DBA1B1C2159DC0344E5A4@xmb-sjc-239.amer.cisco.com> <470E70D1.2020906@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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