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/access/transam/varsup.c,v 1.17 1998/09/01 04:27:18 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.18 1998/12/18 09:10:17 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -311,6 +311,42 @@ GetNewTransactionId(TransactionId *xid)
SpinRelease(OidGenLockId);
}
/*
* Like GetNewTransactionId reads nextXid but don't fetch it.
*/
void
ReadNewTransactionId(TransactionId *xid)
{
/* ----------------
* during bootstrap initialization, we return the special
* bootstrap transaction id.
* ----------------
*/
if (AMI_OVERRIDE)
{
TransactionIdStore(AmiTransactionId, xid);
return;
}
SpinAcquire(OidGenLockId); /* not good for concurrency... */
if (ShmemVariableCache->xid_count == 0)
{
TransactionId nextid;
VariableRelationGetNextXid(&nextid);
TransactionIdStore(nextid, &(ShmemVariableCache->nextXid));
ShmemVariableCache->xid_count = VAR_XID_PREFETCH;
TransactionIdAdd(&nextid, VAR_XID_PREFETCH);
VariableRelationPutNextXid(nextid);
}
TransactionIdStore(ShmemVariableCache->nextXid, xid);
SpinRelease(OidGenLockId);
}
/* ----------------------------------------------------------------
* object id generation support
* ----------------------------------------------------------------

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.27 1998/12/16 11:53:44 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.28 1998/12/18 09:10:18 vadim Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@ -194,7 +194,8 @@ TransactionStateData CurrentTransactionStateData = {
TransactionState CurrentTransactionState =
&CurrentTransactionStateData;
int XactIsoLevel = XACT_SERIALIZED;
int DefaultXactIsoLevel = XACT_SERIALIZABLE;
int XactIsoLevel;
/* ----------------
* info returned when the system is disabled
@ -798,6 +799,7 @@ StartTransaction()
TransactionIdFlushCache();
FreeXactSnapshot();
XactIsoLevel = DefaultXactIsoLevel;
/* ----------------
* Check the current transaction state. If the transaction system

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;
}

View File

@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.61 1998/12/16 11:53:45 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.62 1998/12/18 09:10:21 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -1037,8 +1037,8 @@ ExecDelete(TupleTableSlot *slot,
break;
case HeapTupleUpdated:
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;
@ -1167,8 +1167,8 @@ ExecReplace(TupleTableSlot *slot,
break;
case HeapTupleUpdated:
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;

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.39 1998/12/13 04:37:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.40 1998/12/18 09:10:32 vadim Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -45,6 +45,7 @@
#include "catalog/catname.h"
#include "utils/elog.h"
#include "access/xact.h"
#include "storage/lmgr.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
@ -133,6 +134,8 @@ Oid param_type(int t); /* used in parse_expr.c */
%type <str> opt_database1, opt_database2, location, encoding
%type <str> opt_lmode
%type <pboolean> user_createdb_clause, user_createuser_clause
%type <str> user_passwd_clause
%type <str> user_valid_clause
@ -269,8 +272,8 @@ Oid param_type(int t); /* used in parse_expr.c */
ELSE, END_TRANS, EXECUTE, EXISTS, EXTRACT,
FALSE_P, FETCH, FLOAT, FOR, FOREIGN, FROM, FULL,
GRANT, GROUP, HAVING, HOUR_P,
IN, INNER_P, INSENSITIVE, INSERT, INTERVAL, INTO, IS,
JOIN, KEY, LANGUAGE, LEADING, LEFT, LIKE, LOCAL,
IN, INNER_P, INSENSITIVE, INSERT, INTERVAL, INTO, IS, ISOLATION,
JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
MATCH, MINUTE_P, MONTH_P, NAMES,
NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF, NULL_P, NUMERIC,
OF, ON, ONLY, OPTION, OR, ORDER, OUTER_P,
@ -539,6 +542,24 @@ VariableSetStmt: SET ColId TO var_value
n->value = $4;
$$ = (Node *) n;
}
| SET TRANSACTION ISOLATION LEVEL READ ColId
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "XactIsoLevel";
n->value = $6;
if (strcasecmp(n->value, "COMMITTED"))
elog(ERROR,"parser: syntax error at or near \"%s\"", n->value);
$$ = (Node *) n;
}
| SET TRANSACTION ISOLATION LEVEL ColId
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "XactIsoLevel";
n->value = $5;
if (strcasecmp(n->value, "SERIALIZABLE"))
elog(ERROR,"parser: syntax error at or near \"%s\"", n->value);
$$ = (Node *) n;
}
| SET NAMES encoding
{
#ifdef MB
@ -573,6 +594,12 @@ VariableShowStmt: SHOW ColId
n->name = "timezone";
$$ = (Node *) n;
}
| SHOW TRANSACTION ISOLATION LEVEL
{
VariableShowStmt *n = makeNode(VariableShowStmt);
n->name = "XactIsoLevel";
$$ = (Node *) n;
}
;
VariableResetStmt: RESET ColId
@ -587,6 +614,12 @@ VariableResetStmt: RESET ColId
n->name = "timezone";
$$ = (Node *) n;
}
| RESET TRANSACTION ISOLATION LEVEL
{
VariableResetStmt *n = makeNode(VariableResetStmt);
n->name = "XactIsoLevel";
$$ = (Node *) n;
}
;
@ -2473,28 +2506,77 @@ DeleteStmt: DELETE FROM relation_name
}
;
/*
* Total hack to just lock a table inside a transaction.
* Is it worth making this a separate command, with
* its own node type and file. I don't think so. bjm 1998/1/22
*/
LockStmt: LOCK_P opt_table relation_name
LockStmt: LOCK_P opt_table relation_name
{
DeleteStmt *n = makeNode(DeleteStmt);
A_Const *c = makeNode(A_Const);
c->val.type = T_String;
c->val.val.str = "f";
c->typename = makeNode(TypeName);
c->typename->name = xlateSqlType("bool");
c->typename->typmod = -1;
LockStmt *n = makeNode(LockStmt);
n->relname = $3;
n->whereClause = (Node *)c;
n->mode = AccessExclusiveLock;
$$ = (Node *)n;
}
| LOCK_P opt_table relation_name IN opt_lmode ROW IDENT IDENT
{
LockStmt *n = makeNode(LockStmt);
n->relname = $3;
if (strcasecmp($8, "MODE"))
elog(ERROR,"parser: syntax error at or near \"%s\"", $8);
if ($5 != NULL)
{
if (strcasecmp($5, "SHARE"))
elog(ERROR,"parser: syntax error at or near \"%s\"", $5);
if (strcasecmp($7, "EXCLUSIVE"))
elog(ERROR,"parser: syntax error at or near \"%s\"", $7);
n->mode = ShareRowExclusiveLock;
}
else
{
if (strcasecmp($7, "SHARE") == 0)
n->mode = RowShareLock;
else if (strcasecmp($7, "EXCLUSIVE") == 0)
n->mode = RowExclusiveLock;
else
elog(ERROR,"parser: syntax error at or near \"%s\"", $7);
}
$$ = (Node *)n;
}
| LOCK_P opt_table relation_name IN IDENT IDENT IDENT
{
LockStmt *n = makeNode(LockStmt);
n->relname = $3;
if (strcasecmp($7, "MODE"))
elog(ERROR,"parser: syntax error at or near \"%s\"", $7);
if (strcasecmp($5, "ACCESS"))
elog(ERROR,"parser: syntax error at or near \"%s\"", $5);
if (strcasecmp($6, "SHARE") == 0)
n->mode = AccessShareLock;
else if (strcasecmp($6, "EXCLUSIVE") == 0)
n->mode = AccessExclusiveLock;
else
elog(ERROR,"parser: syntax error at or near \"%s\"", $6);
$$ = (Node *)n;
}
| LOCK_P opt_table relation_name IN IDENT IDENT
{
LockStmt *n = makeNode(LockStmt);
n->relname = $3;
if (strcasecmp($6, "MODE"))
elog(ERROR,"parser: syntax error at or near \"%s\"", $6);
if (strcasecmp($5, "SHARE") == 0)
n->mode = ShareLock;
else if (strcasecmp($5, "EXCLUSIVE") == 0)
n->mode = ExclusiveLock;
else
elog(ERROR,"parser: syntax error at or near \"%s\"", $5);
$$ = (Node *)n;
}
;
opt_lmode: IDENT { $$ = $1; }
| /*EMPTY*/ { $$ = NULL; }
;
/*****************************************************************************
*

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.49 1998/12/04 15:34:29 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.50 1998/12/18 09:10:34 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -124,12 +124,14 @@ static ScanKeyword ScanKeywords[] = {
{"into", INTO},
{"is", IS},
{"isnull", ISNULL},
{"isolation", ISOLATION},
{"join", JOIN},
{"key", KEY},
{"lancompiler", LANCOMPILER},
{"language", LANGUAGE},
{"leading", LEADING},
{"left", LEFT},
{"level", LEVEL},
{"like", LIKE},
{"listen", LISTEN},
{"load", LOAD},

View File

@ -94,157 +94,159 @@ typedef union
#define INTERVAL 320
#define INTO 321
#define IS 322
#define JOIN 323
#define KEY 324
#define LANGUAGE 325
#define LEADING 326
#define LEFT 327
#define LIKE 328
#define LOCAL 329
#define MATCH 330
#define MINUTE_P 331
#define MONTH_P 332
#define NAMES 333
#define NATIONAL 334
#define NATURAL 335
#define NCHAR 336
#define NEXT 337
#define NO 338
#define NOT 339
#define NULLIF 340
#define NULL_P 341
#define NUMERIC 342
#define OF 343
#define ON 344
#define ONLY 345
#define OPTION 346
#define OR 347
#define ORDER 348
#define OUTER_P 349
#define PARTIAL 350
#define POSITION 351
#define PRECISION 352
#define PRIMARY 353
#define PRIOR 354
#define PRIVILEGES 355
#define PROCEDURE 356
#define PUBLIC 357
#define READ 358
#define REFERENCES 359
#define RELATIVE 360
#define REVOKE 361
#define RIGHT 362
#define ROLLBACK 363
#define SCROLL 364
#define SECOND_P 365
#define SELECT 366
#define SET 367
#define SUBSTRING 368
#define TABLE 369
#define THEN 370
#define TIME 371
#define TIMESTAMP 372
#define TIMEZONE_HOUR 373
#define TIMEZONE_MINUTE 374
#define TO 375
#define TRAILING 376
#define TRANSACTION 377
#define TRIM 378
#define TRUE_P 379
#define UNION 380
#define UNIQUE 381
#define UPDATE 382
#define USER 383
#define USING 384
#define VALUES 385
#define VARCHAR 386
#define VARYING 387
#define VIEW 388
#define WHEN 389
#define WHERE 390
#define WITH 391
#define WORK 392
#define YEAR_P 393
#define ZONE 394
#define TRIGGER 395
#define TYPE_P 396
#define ABORT_TRANS 397
#define AFTER 398
#define AGGREGATE 399
#define ANALYZE 400
#define BACKWARD 401
#define BEFORE 402
#define BINARY 403
#define CACHE 404
#define CLUSTER 405
#define COPY 406
#define CREATEDB 407
#define CREATEUSER 408
#define CYCLE 409
#define DATABASE 410
#define DELIMITERS 411
#define DO 412
#define EACH 413
#define ENCODING 414
#define EXPLAIN 415
#define EXTEND 416
#define FORWARD 417
#define FUNCTION 418
#define HANDLER 419
#define INCREMENT 420
#define INDEX 421
#define INHERITS 422
#define INSTEAD 423
#define ISNULL 424
#define LANCOMPILER 425
#define LISTEN 426
#define LOAD 427
#define LOCATION 428
#define LOCK_P 429
#define MAXVALUE 430
#define MINVALUE 431
#define MOVE 432
#define NEW 433
#define NOCREATEDB 434
#define NOCREATEUSER 435
#define NONE 436
#define NOTHING 437
#define NOTIFY 438
#define NOTNULL 439
#define OIDS 440
#define OPERATOR 441
#define PASSWORD 442
#define PROCEDURAL 443
#define RECIPE 444
#define RENAME 445
#define RESET 446
#define RETURNS 447
#define ROW 448
#define RULE 449
#define SEQUENCE 450
#define SERIAL 451
#define SETOF 452
#define SHOW 453
#define START 454
#define STATEMENT 455
#define STDIN 456
#define STDOUT 457
#define TRUSTED 458
#define UNLISTEN 459
#define UNTIL 460
#define VACUUM 461
#define VALID 462
#define VERBOSE 463
#define VERSION 464
#define IDENT 465
#define SCONST 466
#define Op 467
#define ICONST 468
#define PARAM 469
#define FCONST 470
#define OP 471
#define UMINUS 472
#define TYPECAST 473
#define ISOLATION 323
#define JOIN 324
#define KEY 325
#define LANGUAGE 326
#define LEADING 327
#define LEFT 328
#define LEVEL 329
#define LIKE 330
#define LOCAL 331
#define MATCH 332
#define MINUTE_P 333
#define MONTH_P 334
#define NAMES 335
#define NATIONAL 336
#define NATURAL 337
#define NCHAR 338
#define NEXT 339
#define NO 340
#define NOT 341
#define NULLIF 342
#define NULL_P 343
#define NUMERIC 344
#define OF 345
#define ON 346
#define ONLY 347
#define OPTION 348
#define OR 349
#define ORDER 350
#define OUTER_P 351
#define PARTIAL 352
#define POSITION 353
#define PRECISION 354
#define PRIMARY 355
#define PRIOR 356
#define PRIVILEGES 357
#define PROCEDURE 358
#define PUBLIC 359
#define READ 360
#define REFERENCES 361
#define RELATIVE 362
#define REVOKE 363
#define RIGHT 364
#define ROLLBACK 365
#define SCROLL 366
#define SECOND_P 367
#define SELECT 368
#define SET 369
#define SUBSTRING 370
#define TABLE 371
#define THEN 372
#define TIME 373
#define TIMESTAMP 374
#define TIMEZONE_HOUR 375
#define TIMEZONE_MINUTE 376
#define TO 377
#define TRAILING 378
#define TRANSACTION 379
#define TRIM 380
#define TRUE_P 381
#define UNION 382
#define UNIQUE 383
#define UPDATE 384
#define USER 385
#define USING 386
#define VALUES 387
#define VARCHAR 388
#define VARYING 389
#define VIEW 390
#define WHEN 391
#define WHERE 392
#define WITH 393
#define WORK 394
#define YEAR_P 395
#define ZONE 396
#define TRIGGER 397
#define TYPE_P 398
#define ABORT_TRANS 399
#define AFTER 400
#define AGGREGATE 401
#define ANALYZE 402
#define BACKWARD 403
#define BEFORE 404
#define BINARY 405
#define CACHE 406
#define CLUSTER 407
#define COPY 408
#define CREATEDB 409
#define CREATEUSER 410
#define CYCLE 411
#define DATABASE 412
#define DELIMITERS 413
#define DO 414
#define EACH 415
#define ENCODING 416
#define EXPLAIN 417
#define EXTEND 418
#define FORWARD 419
#define FUNCTION 420
#define HANDLER 421
#define INCREMENT 422
#define INDEX 423
#define INHERITS 424
#define INSTEAD 425
#define ISNULL 426
#define LANCOMPILER 427
#define LISTEN 428
#define LOAD 429
#define LOCATION 430
#define LOCK_P 431
#define MAXVALUE 432
#define MINVALUE 433
#define MOVE 434
#define NEW 435
#define NOCREATEDB 436
#define NOCREATEUSER 437
#define NONE 438
#define NOTHING 439
#define NOTIFY 440
#define NOTNULL 441
#define OIDS 442
#define OPERATOR 443
#define PASSWORD 444
#define PROCEDURAL 445
#define RECIPE 446
#define RENAME 447
#define RESET 448
#define RETURNS 449
#define ROW 450
#define RULE 451
#define SEQUENCE 452
#define SERIAL 453
#define SETOF 454
#define SHOW 455
#define START 456
#define STATEMENT 457
#define STDIN 458
#define STDOUT 459
#define TRUSTED 460
#define UNLISTEN 461
#define UNTIL 462
#define VACUUM 463
#define VALID 464
#define VERBOSE 465
#define VERSION 466
#define IDENT 467
#define SCONST 468
#define Op 469
#define ICONST 470
#define PARAM 471
#define FCONST 472
#define OP 473
#define UMINUS 474
#define TYPECAST 475
extern YYSTYPE yylval;

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.33 1998/12/16 11:53:46 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.34 1998/12/18 09:10:34 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -636,7 +636,7 @@ TransactionIdIsInProgress(TransactionId xid)
* Yet another strange func for this place... - vadim 07/21/98
*/
Snapshot
GetSnapshotData(void)
GetSnapshotData(bool serializable)
{
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
ShmemIndexEnt *result;
@ -648,8 +648,11 @@ GetSnapshotData(void)
Assert(ShmemIndex);
snapshot->xip = (TransactionId *) malloc(have * sizeof(TransactionId));
snapshot->xmax = cid;
snapshot->xmin = cid;
if (serializable)
snapshot->xmax = cid;
else
ReadNewTransactionId(&(snapshot->xmax));
SpinAcquire(ShmemIndexLock);

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.50 1998/09/25 13:47:27 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.51 1998/12/18 09:10:36 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -760,6 +760,13 @@ ProcessUtility(Node *parsetree,
RemoveUser(((DropUserStmt *) parsetree)->user);
break;
case T_LockStmt:
PS_SET_STATUS(commandTag = "LOCK TABLE");
CHECK_IF_ABORTED();
LockTableCommand((LockStmt *) parsetree);
break;
/*
* ******************************** default ********************************

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.22 1998/12/16 11:53:55 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.23 1998/12/18 09:10:39 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -30,7 +30,7 @@ SnapshotData SnapshotDirtyData;
Snapshot SnapshotDirty = &SnapshotDirtyData;
Snapshot QuerySnapshot = NULL;
static Snapshot SerializedSnapshot = NULL;
Snapshot SerializableSnapshot = NULL;
/*
* XXX Transaction system override hacks start here
@ -551,24 +551,24 @@ SetQuerySnapshot(void)
{
/* 1st call in xaction */
if (SerializedSnapshot == NULL)
if (SerializableSnapshot == NULL)
{
SerializedSnapshot = GetSnapshotData();
QuerySnapshot = SerializedSnapshot;
SerializableSnapshot = GetSnapshotData(true);
QuerySnapshot = SerializableSnapshot;
Assert(QuerySnapshot != NULL);
return;
}
if (QuerySnapshot != SerializedSnapshot)
if (QuerySnapshot != SerializableSnapshot)
{
free(QuerySnapshot->xip);
free(QuerySnapshot);
}
if (XactIsoLevel == XACT_SERIALIZED)
QuerySnapshot = SerializedSnapshot;
if (XactIsoLevel == XACT_SERIALIZABLE)
QuerySnapshot = SerializableSnapshot;
else
QuerySnapshot = GetSnapshotData();
QuerySnapshot = GetSnapshotData(false);
Assert(QuerySnapshot != NULL);
@ -578,7 +578,7 @@ void
FreeXactSnapshot(void)
{
if (QuerySnapshot != NULL && QuerySnapshot != SerializedSnapshot)
if (QuerySnapshot != NULL && QuerySnapshot != SerializableSnapshot)
{
free(QuerySnapshot->xip);
free(QuerySnapshot);
@ -586,12 +586,12 @@ FreeXactSnapshot(void)
QuerySnapshot = NULL;
if (SerializedSnapshot != NULL)
if (SerializableSnapshot != NULL)
{
free(SerializedSnapshot->xip);
free(SerializedSnapshot);
free(SerializableSnapshot->xip);
free(SerializableSnapshot);
}
SerializedSnapshot = NULL;
SerializableSnapshot = NULL;
}

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: transam.h,v 1.17 1998/12/16 11:52:10 vadim Exp $
* $Id: transam.h,v 1.18 1998/12/18 09:09:52 vadim Exp $
*
* NOTES
* Transaction System Version 101 now support proper oid
@ -160,6 +160,7 @@ extern void TransBlockNumberSetXidStatus(Relation relation,
/* in transam/varsup.c */
extern void VariableRelationPutNextXid(TransactionId xid);
extern void GetNewTransactionId(TransactionId *xid);
extern void ReadNewTransactionId(TransactionId *xid);
extern void GetNewObjectId(Oid *oid_return);
extern void CheckMaxObjectId(Oid assigned_oid);

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: xact.h,v 1.18 1998/12/15 12:46:47 vadim Exp $
* $Id: xact.h,v 1.19 1998/12/18 09:09:52 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -36,8 +36,9 @@ typedef struct TransactionStateData
#define XACT_DIRTY_READ 0 /* not implemented */
#define XACT_READ_COMMITTED 1
#define XACT_REPEATABLE_READ 2 /* not implemented */
#define XACT_SERIALIZED 3
#define XACT_SERIALIZABLE 3
extern int DefaultXactIsoLevel;
extern int XactIsoLevel;
/* ----------------

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: command.h,v 1.10 1998/09/01 04:35:25 momjian Exp $
* $Id: command.h,v 1.11 1998/12/18 09:09:52 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -44,4 +44,6 @@ extern void PortalCleanup(Portal portal);
extern void PerformAddAttribute(char *relationName, char *userName,
bool inh, ColumnDef *colDef);
extern void LockTableCommand(LockStmt *lockstmt);
#endif /* COMMAND_H */

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.32 1998/12/04 15:34:44 thomas Exp $
* $Id: nodes.h,v 1.33 1998/12/18 09:09:53 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -190,6 +190,7 @@ typedef enum NodeTag
T_CreateUserStmt,
T_AlterUserStmt,
T_DropUserStmt,
T_LockStmt,
T_A_Expr = 700,
T_Attr,

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.62 1998/12/04 15:34:44 thomas Exp $
* $Id: parsenodes.h,v 1.63 1998/12/18 09:09:54 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -574,6 +574,16 @@ typedef struct VariableResetStmt
char *name;
} VariableResetStmt;
/* ----------------------
* LOCK Statement
* ----------------------
*/
typedef struct LockStmt
{
NodeTag type;
char *relname; /* relation to lock */
int mode; /* lock mode */
} LockStmt;
/*****************************************************************************
* Optimizable Statements

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tqual.h,v 1.17 1998/12/16 11:52:11 vadim Exp $
* $Id: tqual.h,v 1.18 1998/12/18 09:09:55 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -31,6 +31,7 @@ typedef SnapshotData *Snapshot;
extern Snapshot SnapshotDirty;
extern Snapshot QuerySnapshot;
extern Snapshot SerializableSnapshot;
#define IsSnapshotNow(snapshot) ((Snapshot) snapshot == SnapshotNow)
#define IsSnapshotSelf(snapshot) ((Snapshot) snapshot == SnapshotSelf)
@ -99,7 +100,7 @@ extern int HeapTupleSatisfiesUpdate(HeapTuple tuple);
extern void setheapoverride(bool on);
extern Snapshot GetSnapshotData(void);
extern Snapshot GetSnapshotData(bool serializable);
extern void SetQuerySnapshot(void);
extern void FreeXactSnapshot(void);