Re: What happens If a table changes during a query/procedure execution - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: What happens If a table changes during a query/procedure execution
Date
Msg-id AANLkTinzDh+ev25mWFE5gDEyg-cuqXaZkduftF5nPfSe@mail.gmail.com
Whole thread Raw
In response to Re: What happens If a table changes during a query/procedure execution  (Vlad Arkhipov <arhipov@dc.baikal.ru>)
List pgsql-hackers
2011/3/9 Vlad Arkhipov <arhipov@dc.baikal.ru>:
> 09.03.2011 18:54, Nicolas Barbier:
>>
>> 2011/3/9 Vlad Arkhipov<arhipov@dc.baikal.ru>:
>>
>>
>>>
>>> Let there are two transactions that were created with read commited
>>> isolation level. In the first one we're executing a SELECT query:
>>> SELECT * FROM t UNION ALL SELECT * FROM t;
>>>
>>> In the second transaction we're modifying the same table:
>>> INSERT INTO t DEFAULT VALUES;
>>> COMMIT;
>>>
>>> Is it possible that the last UNION part in the first query will retrieve
>>> not
>>> the same rows as the first one?
>>>
>>
>> No, because statements never see changes made by other transactions
>> while they are in flight.
>>
>>
>
> Is it also true if a statement contains subqueries or function calls? For
> instance,
>
> CREATE FUNCTION f() RETURNS NUMERIC AS $$
> BEGIN
>  RETURN (SELECT SUM(a) FROM t);
> END;
> $$ LANGUAGE 'plpgsql';
>
> SELECT a, f() FROM t;
>
> or
>
> SELECT a, (SELECT SUM(a) FROM t) FROM t;

yes, it is same

Regards

Pavel Stehule

>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


pgsql-hackers by date:

Previous
From: Vlad Arkhipov
Date:
Subject: Re: What happens If a table changes during a query/procedure execution
Next
From: Jan Urbański
Date:
Subject: pl/python - thanks!