diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-13 20:10:13 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-13 20:10:13 +0000 |
commit | b2c4071299e02ed96d48d3c8e776de2fab36f88c (patch) | |
tree | ff0db14826870f1c3fe46d94ea3a1e1697c658a7 /src/backend/tcop/postgres.c | |
parent | d69528881ab72eac5a9f154f23dbf549789c264d (diff) | |
download | postgresql-b2c4071299e02ed96d48d3c8e776de2fab36f88c.tar.gz postgresql-b2c4071299e02ed96d48d3c8e776de2fab36f88c.zip |
Redesign query-snapshot timing so that volatile functions in READ COMMITTED
mode see a fresh snapshot for each command in the function, rather than
using the latest interactive command's snapshot. Also, suppress fresh
snapshots as well as CommandCounterIncrement inside STABLE and IMMUTABLE
functions, instead using the snapshot taken for the most closely nested
regular query. (This behavior is only sane for read-only functions, so
the patch also enforces that such functions contain only SELECT commands.)
As per my proposal of 6-Sep-2004; I note that I floated essentially the
same proposal on 19-Jun-2002, but that discussion tailed off without any
action. Since 8.0 seems like the right place to be taking possibly
nontrivial backwards compatibility hits, let's get it done now.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 50364bd79d3..85fcc49c839 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.431 2004/09/10 18:39:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.432 2004/09/13 20:07:05 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -700,7 +700,7 @@ pg_plan_queries(List *querytrees, ParamListInfo boundParams, { if (needSnapshot) { - SetQuerySnapshot(); + ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); needSnapshot = false; } plan = pg_plan_query(query, boundParams); @@ -883,7 +883,7 @@ exec_simple_query(const char *query_string) /* * Start the portal. No parameters here. */ - PortalStart(portal, NULL); + PortalStart(portal, NULL, InvalidSnapshot); /* * Select the appropriate output format: text unless we are doing @@ -1539,7 +1539,7 @@ exec_bind_message(StringInfo input_message) pstmt->plan_list, pstmt->context); - PortalStart(portal, params); + PortalStart(portal, params, InvalidSnapshot); /* * Apply the result format requests to the portal. @@ -3027,6 +3027,9 @@ PostgresMain(int argc, char *argv[], const char *username) /* switch back to message context */ MemoryContextSwitchTo(MessageContext); + /* set snapshot in case function needs one */ + ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); + if (HandleFunctionRequest(&input_message) == EOF) { /* lost frontend connection during F message input */ |