1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +03:00

SET TRANSACTION ISOLATION LEVEL ...

LOCK TABLE IN ... MODE
...implemented
This commit is contained in:
Vadim B. Mikheev
1998-12-18 09:10:39 +00:00
parent c7da80bb9a
commit 3498d878cb
19 changed files with 6953 additions and 6516 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.34 1998/12/15 12:45:52 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.35 1998/12/18 09:10:18 vadim Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -39,6 +39,7 @@
#include "utils/mcxt.h"
#include "utils/portal.h"
#include "utils/syscache.h"
#include "miscadmin.h"
/* ----------------
* PortalExecutorHeapMemory stuff
@@ -492,3 +493,25 @@ PerformAddAttribute(char *relationName,
pfree(reltup);
heap_close(rel);
}
void
LockTableCommand(LockStmt *lockstmt)
{
Relation rel;
int aclresult;
rel = heap_openr(lockstmt->relname);
if (rel == NULL)
elog(ERROR, "LOCK TABLE: relation %s can't be openned", lockstmt->relname);
if (lockstmt->mode == AccessShareLock)
aclresult = pg_aclcheck(lockstmt->relname, GetPgUserName(), ACL_RD);
else
aclresult = pg_aclcheck(lockstmt->relname, GetPgUserName(), ACL_WR);
if (aclresult != ACLCHECK_OK)
elog(ERROR, "LOCK TABLE: permission denied");
LockRelation(rel, lockstmt->mode);
}

View File

@@ -818,8 +818,8 @@ GetTupleForTrigger(EState *estate, ItemPointer tid, bool before)
case HeapTupleUpdated:
ReleaseBuffer(buffer);
if (XactIsoLevel == XACT_SERIALIZED)
elog(ERROR, "Serialize access failed due to concurrent update");
if (XactIsoLevel == XACT_SERIALIZABLE)
elog(ERROR, "Can't serialize access due to concurrent update");
else
elog(ERROR, "Isolation level %u is not supported", XactIsoLevel);
return(NULL);

View File

@@ -2,7 +2,7 @@
* Routines for handling of 'SET var TO',
* 'SHOW var' and 'RESET var' statements.
*
* $Id: variable.c,v 1.17 1998/10/26 00:59:22 tgl Exp $
* $Id: variable.c,v 1.18 1998/12/18 09:10:20 vadim Exp $
*
*/
@@ -15,6 +15,7 @@
#include "commands/variable.h"
#include "utils/builtins.h"
#include "optimizer/internal.h"
#include "access/xact.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
@@ -44,6 +45,9 @@ static bool parse_geqo(const char *);
static bool show_ksqo(void);
static bool reset_ksqo(void);
static bool parse_ksqo(const char *);
static bool show_XactIsoLevel(void);
static bool reset_XactIsoLevel(void);
static bool parse_XactIsoLevel(const char *);
#ifdef QUERY_LIMIT
static bool show_query_limit(void);
static bool reset_query_limit(void);
@@ -669,6 +673,9 @@ struct VariableParsers
{
"ksqo", parse_ksqo, show_ksqo, reset_ksqo
},
{
"XactIsoLevel", parse_XactIsoLevel, show_XactIsoLevel, reset_XactIsoLevel
},
#ifdef QUERY_LIMIT
{
"query_limit", parse_query_limit, show_query_limit, reset_query_limit
@@ -773,3 +780,58 @@ reset_ksqo()
_use_keyset_query_optimizer = false;
return TRUE;
}
/* SET TRANSACTION */
static bool
parse_XactIsoLevel(const char *value)
{
if (value == NULL)
{
reset_XactIsoLevel();
return TRUE;
}
if (SerializableSnapshot != NULL)
{
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query");
return TRUE;
}
if (strcasecmp(value, "SERIALIZABLE") == 0)
XactIsoLevel = XACT_SERIALIZABLE;
else if (strcasecmp(value, "COMMITTED") == 0)
XactIsoLevel = XACT_READ_COMMITTED;
else
elog(ERROR, "Bad TRANSACTION ISOLATION LEVEL (%s)", value);
return TRUE;
}
static bool
show_XactIsoLevel()
{
if (XactIsoLevel == XACT_SERIALIZABLE)
elog(NOTICE, "TRANSACTION ISOLATION LEVEL is SERIALIZABLE");
else
elog(NOTICE, "TRANSACTION ISOLATION LEVEL is READ COMMITTED");
return TRUE;
}
static bool
reset_XactIsoLevel()
{
if (SerializableSnapshot != NULL)
{
elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query");
return TRUE;
}
XactIsoLevel = DefaultXactIsoLevel;
return TRUE;
}