pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marco Colombo <marco@esi.it>
To: reiner peterke <zedaardv@drizzle.com>
Cc: pgsql-php@postgresql.org
Subject: Re: [0.2] getting transactions to work
Date: Fri, 06 Aug 2004 12:02:13 +0200
Message-ID: <41135725.70304@esi.it> (raw)
In-Reply-To: <AFAD701E-E242-11D8-8EE0-000A95984CA6@drizzle.com>
References: <018301c47648$db231990$0301a8c0@Mesa.com>
	<AFAD701E-E242-11D8-8EE0-000A95984CA6@drizzle.com>

reiner peterke wrote:
> well i've read about this thing called persistent connection,
> i think it is supposed to exist in mysql also.  the idea sound like what 
> i want. i've tried it but i didn't get any different results.  but then 
> i'm not convinced i did it right either.

You have to face the fact that HTTP is _stateless_. Any common HTTP server
will obey to that, thus destroying any resource related to the request it
just served, _or_ making it appear as if it was destroyed. You really need to
think hard of the implications here.

Persistent connections are no exception: they are just a way to boost
perfermance, but there should be no visible difference at application
level. That is, you should be able to change pg_connect()'s with
pg_pconnect()'s (and vice versa) without changing anything else in your
PHP scripts. Persistent connections add _no_ extra functionality to your
PHP application.

Transactions exist at SQL session level. A "session" is inherently
statefull, and will be destroyed (or made appear as destroyed) at the end
for each HTTP request, because it _has_ to appear stateless. The request
for the 'next' page may be served by a different process, or a even a
different host, so no state can be shared. There's simply no way you can
control this.

Sessions/cookies alone won't let you use transactions, they'll just
emulate them. You can delay the transaction till the final page, but
it's just not the same.

Of course, you can write your own HTTP server (there are simple-to-use Perl
or Python modules to do that) that deliberately fails to adhere to the
HTTP model, and keeps some state. If you control all the environment, that
may even work.

One possible solution is to write proxy application (a server), which talks
on one side to the SQL db and on the other to the PHP frontend.

.TM.
-- 
       ____/  ____/   /
      /      /       /			Marco Colombo
     ___/  ___  /   /		      Technical Manager
    /          /   /			 ESI s.r.l.
  _____/ _____/  _/		       Colombo@ESI.it



view thread (18+ messages)  latest in thread

Message-ID: <41135725.70304@esi.it>
Permalink:  ../41135725.70304@esi.it/
Also on:    postgresql.org/message-id/41135725.70304@esi.it

 · 

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-php@postgresql.org
  Cc: marco@esi.it, zedaardv@drizzle.com
  Subject: Re: [0.2] getting transactions to work
  In-Reply-To: <41135725.70304@esi.it>
  References: <018301c47648$db231990$0301a8c0@Mesa.com> <AFAD701E-E242-11D8-8EE0-000A95984CA6@drizzle.com> <41135725.70304@esi.it>

* 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