From ad8e442d1298baaa1e0240c62db3d7ad97eaf534 Mon Sep 17 00:00:00 2001 From: Takayuki Tsunakawa Date: Mon, 7 Nov 2016 16:04:52 +0900 Subject: [PATCH] Change the default of UseDeclareFetch and rollback behavior. Change the default value of UseDeclareFetch to 1 to avoid using up all the client's memory. The current default behavior sometimes surprises users who migrate from other DBMSs, which retrieve a limited number of rows at a time. Also, change the default behavior upon error from statement rollback to transaction rollback. One reason is to eliminate two round trips for each SQL statement -- SAVEPOINT and RELEASE -- which cause performance problems. The other reason is to avoid out-of-memory errors on the server. This is because each subtransaction started by SAVEPOINT creates an 8KB of CurTransactionContext memory and retains it until the top transaction ends. --- dlg_specific.h | 2 +- execute.c | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/dlg_specific.h b/dlg_specific.h index ee0c0d0..d655db8 100644 --- a/dlg_specific.h +++ b/dlg_specific.h @@ -228,7 +228,7 @@ extern "C" { #define DEFAULT_READONLY 0 #define DEFAULT_PROTOCOL "7.4" /* the latest protocol is * the default */ -#define DEFAULT_USEDECLAREFETCH 0 +#define DEFAULT_USEDECLAREFETCH 1 #define DEFAULT_TEXTASLONGVARCHAR 1 #define DEFAULT_UNKNOWNSASLONGVARCHAR 0 #define DEFAULT_BOOLSASCHAR 1 diff --git a/execute.c b/execute.c index d568219..02f225e 100644 --- a/execute.c +++ b/execute.c @@ -556,12 +556,7 @@ inolog("%s:%p->internal=%d\n", func, stmt, stmt->internal); ci = &conn->connInfo; if (!ci || ci->rollback_on_error < 0) /* default */ - { - if (conn && PG_VERSION_GE(conn, 8.0)) - ret = 2; /* statement rollback */ - else - ret = 1; /* transaction rollback */ - } + ret = 1; /* transaction rollback */ else { ret = ci->rollback_on_error; -- 2.10.1