Re: time stops within transaction - Mailing list pgsql-hackers

From Mikheev, Vadim
Subject Re: time stops within transaction
Date
Msg-id 8F4C99C66D04D4118F580090272A7A23018D75@SECTORBASE1
Whole thread Raw
In response to time stops within transaction  (Alex Pilosov <alex@pilosoft.com>)
List pgsql-hackers
> > > Snapshot is made per top-level statement and functions/subqueries
> > > use the same snapshot as that of top-level statement.
> >
> > Not so.  SetQuerySnapshot is executed per querytree, not per top-level
> > statement --- for example, if a rule generates multiple queries from
> > a user statement, SetQuerySnapshot is called again for each query.

This is true. I just made it to work as it was in pre-6.5 times - each
query of *top level* query list uses own snapshot (in read committed mode
only) as if they were submitted by user one by one.

But functions/subqueries called while executing query uses same snapshot
as query itself.

> > With the current structure of pg_exec_query_string(), an operation
> > executed in the outer loop, rather than the inner, would more or less
> > correspond to one "top level" query --- if you want to assume that
> > pg_exec_query_string() is only called from PostgresMain.  That's
> > true today but hasn't always been true --- I believe it used to be
> > used to parse SPI commands, and someday it may be again.

It was never used in SPI. Just look at _SPI_execute. Same parent query
snapshot is used in SPI functions. *But* SPI' queries *see* changes
made by parent query - I never was sure about this and think I've asked
other opinions. No opinions - no changes -:)

> If there's no concept of top-level statement,there's no
> concept of read consistency and MVCC isn't needed.

Except of the fact that SPI' queries see changes made by parent same
snapshot is used all time while executing top-level query (single query,
not query list).

Vadim



pgsql-hackers by date:

Previous
From: "Mikheev, Vadim"
Date:
Subject: Re: SetQuerySnapshot() for utility statements
Next
From: Thomas Lockhart
Date:
Subject: Re: Re: pg_dump docs