mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
SET TRANSACTION ISOLATION LEVEL ...
LOCK TABLE IN ... MODE ...implemented
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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; }
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user