mirror of
https://github.com/postgres/postgres.git
synced 2025-05-24 00:03:23 -04:00
Allow default transaction isolation level (a.k.a. set session
characteristics) to be set through GUC.
This commit is contained in:
parent
e4a40cc353
commit
10e9cd2299
@ -1,4 +1,4 @@
|
|||||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/set_transaction.sgml,v 1.3 2000/11/24 20:16:38 petere Exp $ -->
|
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/set_transaction.sgml,v 1.4 2001/06/30 22:03:25 petere Exp $ -->
|
||||||
<refentry id="SQL-SET-TRANSACTION">
|
<refentry id="SQL-SET-TRANSACTION">
|
||||||
<docinfo>
|
<docinfo>
|
||||||
<date>2000-11-24</date>
|
<date>2000-11-24</date>
|
||||||
@ -74,6 +74,18 @@ SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL { READ COMMITTED | SE
|
|||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Notes</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The session default transaction isolation level can also be set
|
||||||
|
with the command <literal>SET default_transaction_isolation =
|
||||||
|
'<replaceable>value</replaceable>'</literal> and in the
|
||||||
|
configuration file. Consult the <citetitle>Administrator's
|
||||||
|
Guide</citetitle> for more information.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-SET-TRANSACTION-3">
|
<refsect1 id="R1-SQL-SET-TRANSACTION-3">
|
||||||
<title>Compatibility</title>
|
<title>Compatibility</title>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.71 2001/06/30 21:15:57 darcy Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.72 2001/06/30 22:03:25 petere Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Chapter Id="runtime">
|
<Chapter Id="runtime">
|
||||||
@ -996,6 +996,29 @@ env PGOPTIONS='-c geqo=off' psql
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<indexterm>
|
||||||
|
<primary>transaction isolation level</primary>
|
||||||
|
</indexterm>
|
||||||
|
|
||||||
|
<term>DEFAUL_TRANSACTION_ISOLATION (<type>string</type>)</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Each SQL transaction has an isolation level, which can be
|
||||||
|
either <quote>read committed</quote> or
|
||||||
|
<quote>serializable</quote>. This parameter controls what the
|
||||||
|
isolation level of each new transaction is set to. The
|
||||||
|
default is read committed.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Consult the <citetitle>PostgreSQL User's Guide</citetitle> and
|
||||||
|
the command <command>SET TRANSACTION</command> for more
|
||||||
|
information.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>DYNAMIC_LIBRARY_PATH (<type>string</type>)</term>
|
<term>DYNAMIC_LIBRARY_PATH (<type>string</type>)</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -1051,9 +1074,9 @@ dynamic_library_path = '/usr/local/lib:/home/my_project/lib:$libdir:$libdir/cont
|
|||||||
will use the <function>fsync()</> system call in several
|
will use the <function>fsync()</> system call in several
|
||||||
places to make sure that updates are physically written to
|
places to make sure that updates are physically written to
|
||||||
disk and do not hang around in the kernel buffer cache. This
|
disk and do not hang around in the kernel buffer cache. This
|
||||||
increases the chance that a database installation will still
|
increases the chance by a large amount that a database
|
||||||
be usable after an operating system or hardware crash by a
|
installation will still be usable after an operating system or
|
||||||
large amount. (Crashes of the database server itself do
|
hardware crash. (Crashes of the database server itself do
|
||||||
<emphasis>not</> affect this consideration.)
|
<emphasis>not</> affect this consideration.)
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.50 2001/06/12 22:54:05 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.51 2001/06/30 22:03:25 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,9 +46,6 @@ static bool show_timezone(void);
|
|||||||
static bool reset_timezone(void);
|
static bool reset_timezone(void);
|
||||||
static bool parse_timezone(char *);
|
static bool parse_timezone(char *);
|
||||||
|
|
||||||
static bool show_DefaultXactIsoLevel(void);
|
|
||||||
static bool reset_DefaultXactIsoLevel(void);
|
|
||||||
static bool parse_DefaultXactIsoLevel(char *);
|
|
||||||
static bool show_XactIsoLevel(void);
|
static bool show_XactIsoLevel(void);
|
||||||
static bool reset_XactIsoLevel(void);
|
static bool reset_XactIsoLevel(void);
|
||||||
static bool parse_XactIsoLevel(char *);
|
static bool parse_XactIsoLevel(char *);
|
||||||
@ -448,69 +445,6 @@ reset_timezone(void)
|
|||||||
|
|
||||||
/* SET TRANSACTION */
|
/* SET TRANSACTION */
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_DefaultXactIsoLevel(char *value)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
TransactionState s = CurrentTransactionState;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (value == NULL)
|
|
||||||
{
|
|
||||||
reset_DefaultXactIsoLevel();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (s->state != TRANS_DEFAULT)
|
|
||||||
{
|
|
||||||
elog(ERROR, "ALTER SESSION/SET TRANSACTION ISOLATION LEVEL"
|
|
||||||
" can not be called within a transaction");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (strcasecmp(value, "SERIALIZABLE") == 0)
|
|
||||||
DefaultXactIsoLevel = XACT_SERIALIZABLE;
|
|
||||||
else if (strcasecmp(value, "COMMITTED") == 0)
|
|
||||||
DefaultXactIsoLevel = XACT_READ_COMMITTED;
|
|
||||||
else
|
|
||||||
elog(ERROR, "Bad TRANSACTION ISOLATION LEVEL (%s)", value);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
show_DefaultXactIsoLevel(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (DefaultXactIsoLevel == XACT_SERIALIZABLE)
|
|
||||||
elog(NOTICE, "Default TRANSACTION ISOLATION LEVEL is SERIALIZABLE");
|
|
||||||
else
|
|
||||||
elog(NOTICE, "Default TRANSACTION ISOLATION LEVEL is READ COMMITTED");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
reset_DefaultXactIsoLevel(void)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
TransactionState s = CurrentTransactionState;
|
|
||||||
|
|
||||||
if (s->state != TRANS_DEFAULT)
|
|
||||||
{
|
|
||||||
elog(ERROR, "ALTER SESSION/SET TRANSACTION ISOLATION LEVEL"
|
|
||||||
" can not be called within a transaction");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DefaultXactIsoLevel = XACT_READ_COMMITTED;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_XactIsoLevel(char *value)
|
parse_XactIsoLevel(char *value)
|
||||||
{
|
{
|
||||||
@ -530,7 +464,7 @@ parse_XactIsoLevel(char *value)
|
|||||||
|
|
||||||
if (strcasecmp(value, "SERIALIZABLE") == 0)
|
if (strcasecmp(value, "SERIALIZABLE") == 0)
|
||||||
XactIsoLevel = XACT_SERIALIZABLE;
|
XactIsoLevel = XACT_SERIALIZABLE;
|
||||||
else if (strcasecmp(value, "COMMITTED") == 0)
|
else if (strcasecmp(value, "READ COMMITTED") == 0)
|
||||||
XactIsoLevel = XACT_READ_COMMITTED;
|
XactIsoLevel = XACT_READ_COMMITTED;
|
||||||
else
|
else
|
||||||
elog(ERROR, "Bad TRANSACTION ISOLATION LEVEL (%s)", value);
|
elog(ERROR, "Bad TRANSACTION ISOLATION LEVEL (%s)", value);
|
||||||
@ -711,8 +645,6 @@ SetPGVariable(const char *name, const char *value)
|
|||||||
parse_datestyle(mvalue);
|
parse_datestyle(mvalue);
|
||||||
else if (strcasecmp(name, "timezone") == 0)
|
else if (strcasecmp(name, "timezone") == 0)
|
||||||
parse_timezone(mvalue);
|
parse_timezone(mvalue);
|
||||||
else if (strcasecmp(name, "DefaultXactIsoLevel") == 0)
|
|
||||||
parse_DefaultXactIsoLevel(mvalue);
|
|
||||||
else if (strcasecmp(name, "XactIsoLevel") == 0)
|
else if (strcasecmp(name, "XactIsoLevel") == 0)
|
||||||
parse_XactIsoLevel(mvalue);
|
parse_XactIsoLevel(mvalue);
|
||||||
else if (strcasecmp(name, "client_encoding") == 0)
|
else if (strcasecmp(name, "client_encoding") == 0)
|
||||||
@ -737,8 +669,6 @@ GetPGVariable(const char *name)
|
|||||||
show_datestyle();
|
show_datestyle();
|
||||||
else if (strcasecmp(name, "timezone") == 0)
|
else if (strcasecmp(name, "timezone") == 0)
|
||||||
show_timezone();
|
show_timezone();
|
||||||
else if (strcasecmp(name, "DefaultXactIsoLevel") == 0)
|
|
||||||
show_DefaultXactIsoLevel();
|
|
||||||
else if (strcasecmp(name, "XactIsoLevel") == 0)
|
else if (strcasecmp(name, "XactIsoLevel") == 0)
|
||||||
show_XactIsoLevel();
|
show_XactIsoLevel();
|
||||||
else if (strcasecmp(name, "client_encoding") == 0)
|
else if (strcasecmp(name, "client_encoding") == 0)
|
||||||
@ -752,7 +682,6 @@ GetPGVariable(const char *name)
|
|||||||
ShowAllGUCConfig();
|
ShowAllGUCConfig();
|
||||||
show_datestyle();
|
show_datestyle();
|
||||||
show_timezone();
|
show_timezone();
|
||||||
show_DefaultXactIsoLevel();
|
|
||||||
show_XactIsoLevel();
|
show_XactIsoLevel();
|
||||||
show_client_encoding();
|
show_client_encoding();
|
||||||
show_server_encoding();
|
show_server_encoding();
|
||||||
@ -772,8 +701,6 @@ ResetPGVariable(const char *name)
|
|||||||
reset_datestyle();
|
reset_datestyle();
|
||||||
else if (strcasecmp(name, "timezone") == 0)
|
else if (strcasecmp(name, "timezone") == 0)
|
||||||
reset_timezone();
|
reset_timezone();
|
||||||
else if (strcasecmp(name, "DefaultXactIsoLevel") == 0)
|
|
||||||
reset_DefaultXactIsoLevel();
|
|
||||||
else if (strcasecmp(name, "XactIsoLevel") == 0)
|
else if (strcasecmp(name, "XactIsoLevel") == 0)
|
||||||
reset_XactIsoLevel();
|
reset_XactIsoLevel();
|
||||||
else if (strcasecmp(name, "client_encoding") == 0)
|
else if (strcasecmp(name, "client_encoding") == 0)
|
||||||
@ -784,8 +711,6 @@ ResetPGVariable(const char *name)
|
|||||||
reset_random_seed();
|
reset_random_seed();
|
||||||
else if (strcasecmp(name, "all") == 0)
|
else if (strcasecmp(name, "all") == 0)
|
||||||
{
|
{
|
||||||
reset_DefaultXactIsoLevel();
|
|
||||||
reset_XactIsoLevel();
|
|
||||||
reset_random_seed();
|
reset_random_seed();
|
||||||
/* reset_server_encoding(); */
|
/* reset_server_encoding(); */
|
||||||
reset_client_encoding();
|
reset_client_encoding();
|
||||||
@ -793,7 +718,8 @@ ResetPGVariable(const char *name)
|
|||||||
reset_timezone();
|
reset_timezone();
|
||||||
|
|
||||||
ResetAllOptions(false);
|
ResetAllOptions(false);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
SetConfigOption(name, NULL,
|
SetConfigOption(name, NULL,
|
||||||
superuser() ? PGC_SUSET : PGC_USERSET,
|
superuser() ? PGC_SUSET : PGC_USERSET,
|
||||||
false);
|
false);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.232 2001/06/23 00:07:34 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.233 2001/06/30 22:03:25 petere Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -752,7 +752,7 @@ VariableSetStmt: SET ColId TO var_value
|
|||||||
| SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL opt_level
|
| SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL opt_level
|
||||||
{
|
{
|
||||||
VariableSetStmt *n = makeNode(VariableSetStmt);
|
VariableSetStmt *n = makeNode(VariableSetStmt);
|
||||||
n->name = "DefaultXactIsoLevel";
|
n->name = "default_transaction_isolation";
|
||||||
n->value = $8;
|
n->value = $8;
|
||||||
$$ = (Node *) n;
|
$$ = (Node *) n;
|
||||||
}
|
}
|
||||||
@ -772,7 +772,7 @@ VariableSetStmt: SET ColId TO var_value
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_level: READ COMMITTED { $$ = "committed"; }
|
opt_level: READ COMMITTED { $$ = "read committed"; }
|
||||||
| SERIALIZABLE { $$ = "serializable"; }
|
| SERIALIZABLE { $$ = "serializable"; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Support for grand unified configuration scheme, including SET
|
* Support for grand unified configuration scheme, including SET
|
||||||
* command, configuration file, and command line options.
|
* command, configuration file, and command line options.
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.43 2001/06/27 23:31:39 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.44 2001/06/30 22:03:26 petere Exp $
|
||||||
*
|
*
|
||||||
* Copyright 2000 by PostgreSQL Global Development Group
|
* Copyright 2000 by PostgreSQL Global Development Group
|
||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||||
@ -51,6 +51,11 @@ extern char *Syslog_ident;
|
|||||||
static bool check_facility(const char *facility);
|
static bool check_facility(const char *facility);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static char *default_iso_level_string;
|
||||||
|
|
||||||
|
static bool check_defaultxactisolevel(const char *value);
|
||||||
|
static void assign_defaultxactisolevel(const char *value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Debugging options
|
* Debugging options
|
||||||
*/
|
*/
|
||||||
@ -355,6 +360,9 @@ static struct config_real
|
|||||||
static struct config_string
|
static struct config_string
|
||||||
ConfigureNamesString[] =
|
ConfigureNamesString[] =
|
||||||
{
|
{
|
||||||
|
{"default_transaction_isolation", PGC_USERSET, &default_iso_level_string,
|
||||||
|
"read committed", check_defaultxactisolevel, assign_defaultxactisolevel},
|
||||||
|
|
||||||
{"dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
|
{"dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
|
||||||
"$libdir", NULL, NULL},
|
"$libdir", NULL, NULL},
|
||||||
|
|
||||||
@ -1092,3 +1100,25 @@ check_facility(const char *facility)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
check_defaultxactisolevel(const char *value)
|
||||||
|
{
|
||||||
|
return (strcasecmp(value, "read committed") == 0
|
||||||
|
|| strcasecmp(value, "serializable") == 0)
|
||||||
|
? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
assign_defaultxactisolevel(const char *value)
|
||||||
|
{
|
||||||
|
if (strcasecmp(value, "serializable") == 0)
|
||||||
|
DefaultXactIsoLevel = XACT_SERIALIZABLE;
|
||||||
|
else if (strcasecmp(value, "read committed") == 0)
|
||||||
|
DefaultXactIsoLevel = XACT_READ_COMMITTED;
|
||||||
|
else
|
||||||
|
elog(ERROR, "bogus transaction isolation level");
|
||||||
|
}
|
||||||
|
@ -166,6 +166,7 @@
|
|||||||
#
|
#
|
||||||
# Misc
|
# Misc
|
||||||
#
|
#
|
||||||
|
#default_transaction_isolation = 'read committed'
|
||||||
#sql_inheritance = true
|
#sql_inheritance = true
|
||||||
#australian_timezones = false
|
#australian_timezones = false
|
||||||
#deadlock_timeout = 1000
|
#deadlock_timeout = 1000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user