Re: how to call sql code without function

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Medi Montaseri" <montaseri(at)gmail(dot)com>
Cc: giuseppe(dot)derossi(at)email(dot)it, pgsql-admin(at)postgresql(dot)org
Subject: Re: how to call sql code without function
Date: 2007-08-20 18:03:10
Message-ID: dcc563d10708201103t743f17a2s9678b916a387c378@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 8/20/07, Medi Montaseri <montaseri(at)gmail(dot)com> wrote:
> You can think of a database as a filesystem as well. That is do some
> processing, store the result in temp table, do some more, etc,etc then merge
> and process temp tables to arrive at some result.
>
> Just as in the case of filesystem, if you are operating in a concurrent
> evironment, you need to fence against that. That is it is possible that at a
> given time two sessions will arrive at the same processing point where they
> need to create such temp tables.

Each session will get it's own temp table, even if they have the same name.

The real issue is what they do with the data in that temp table to
make sure that they're committing changes that make sense given the
current state of data in the database.

> The other solution which I prefer is to write a stored procedure to solve
> this. Or get creative with nested and complex SQL queries.

Note that nested queries still have some race conditions (such as with
aggregate functions) in postgresql.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Juliann Meyer 2007-08-20 18:33:52 vacuum questions
Previous Message Medi Montaseri 2007-08-20 17:29:03 Re: how to call sql code without function