Thread: snapshots

snapshots

From
Kovacs Baldvin
Date:
Hello.

Could somebody explain me the mechanism in the backend,
which is responsible for the followings. (I tried to
look around snapshots, but couldnt figure out th answer).

In a transaction, isol. read comitted, a select from a
table can see the comitted changes by others, but
a previously declared cursor can not.

A few lines in src/backend/tcop/pquery.c runs when
a DECLARE cursor is issued:

>        if (isRetrieveIntoPortal)
>        {
>                PortalExecutorHeapMemory = NULL;
>
>                ProcessPortal(intoName,
>   [...]
>              return;
>     } 
, but I cannot see neither in these, nor in ProcessPortal that
where does it fix the set of rows being visible.

Please help to find it out.

Thanks,
Baldvin






Re: snapshots

From
Tom Lane
Date:
Kovacs Baldvin <kb136@hszk.bme.hu> writes:
> Could somebody explain me the mechanism in the backend,
> which is responsible for the followings. (I tried to
> look around snapshots, but couldnt figure out th answer).

> In a transaction, isol. read comitted, a select from a
> table can see the comitted changes by others, but
> a previously declared cursor can not.

Yup.  The snapshot used for a particular query is nailed down when
ExecutorStart() is called.  Look around for uses of QuerySnapshot
and estate->es_snapshot.
        regards, tom lane