Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19e0e35

Browse files
committed
The attached patch implements START TRANSACTION, per SQL99. The
functionality of the command is basically identical to that ofBEGIN; it just accepts a few extra options (only one of whichPostgreSQL currently implements), and is standards-compliant.The patch includes a simple regression test and documentation.[ Regression tests removed, per Peter.]Neil Conway
1 parentfecc04f commit19e0e35

File tree

10 files changed

+71
-46
lines changed

10 files changed

+71
-46
lines changed

‎doc/src/sgml/ref/allfiles.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.43 2002/07/29 22:14:10 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.44 2002/08/04 04:31:44 momjian Exp $
33
PostgreSQL documentation
44
Complete list of usable sgml source files in this directory.
55
-->
@@ -113,6 +113,7 @@ Complete list of usable sgml source files in this directory.
113113
<!entity setSessionAuth system "set_session_auth.sgml">
114114
<!entity setTransaction system "set_transaction.sgml">
115115
<!entity show system "show.sgml">
116+
<!entity startTransactionsystem "start_transaction.sgml">
116117
<!entity truncate system "truncate.sgml">
117118
<!entity unlisten system "unlisten.sgml">
118119
<!entity update system "update.sgml">

‎doc/src/sgml/ref/begin.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/begin.sgml,v 1.17 2002/04/21 19:02:39 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/begin.sgml,v 1.18 2002/08/04 04:31:44 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -21,7 +21,7 @@ PostgreSQL documentation
2121
<refsynopsisdivinfo>
2222
<date>1999-07-20</date>
2323
</refsynopsisdivinfo>
24-
<synopsis>
24+
<synopsis>
2525
BEGIN [ WORK | TRANSACTION ]
2626
</synopsis>
2727

‎doc/src/sgml/ref/set_transaction.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/set_transaction.sgml,v 1.8 2002/01/20 22:19:57 petere Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/set_transaction.sgml,v 1.9 2002/08/04 04:31:44 momjian Exp $ -->
22
<refentry id="SQL-SET-TRANSACTION">
33
<docinfo>
44
<date>2000-11-24</date>
@@ -97,11 +97,11 @@ SET default_transaction_isolation = '<replaceable>value</replaceable>'
9797
<title>SQL92, SQL99</title>
9898

9999
<para>
100-
SERIALIZABLE is the default level in <acronym>SQL</acronym>.
101-
<productname>PostgreSQL</productname> does not provide the
102-
isolation levels <option>READ UNCOMMITTED</option>
103-
and <option>REPEATABLE READ</option>. Because
104-
of multiversionconcurrency control, theserializable level is not
100+
<option>SERIALIZABLE</option> is the default level in
101+
<acronym>SQL</acronym>. <productname>PostgreSQL</productname> does
102+
not provide theisolation levels <option>READ UNCOMMITTED</option>
103+
and <option>REPEATABLE READ</option>. Because of multiversion
104+
concurrency control, the<option>SERIALIZABLE</option> level is not
105105
truly serializable. See the <citetitle>User's Guide</citetitle> for
106106
details.
107107
</para>

‎doc/src/sgml/reference.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- reference.sgml
2-
$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.32 2002/07/29 22:14:10 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.33 2002/08/04 04:31:44 momjian Exp $
33

44
PostgreSQL Reference Manual
55
-->
@@ -122,6 +122,7 @@ PostgreSQL Reference Manual
122122
&setSessionAuth;
123123
&setTransaction;
124124
&show;
125+
&startTransaction;
125126
&truncate;
126127
&unlisten;
127128
&update;

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.198 2002/07/29 22:14:10 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.199 2002/08/04 04:31:44 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -2226,6 +2226,7 @@ _copyTransactionStmt(TransactionStmt *from)
22262226
TransactionStmt*newnode=makeNode(TransactionStmt);
22272227

22282228
newnode->command=from->command;
2229+
Node_Copy(from,newnode,options);
22292230

22302231
returnnewnode;
22312232
}

‎src/backend/nodes/equalfuncs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
2222
* IDENTIFICATION
23-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.145 2002/07/29 22:14:10 tgl Exp $
23+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.146 2002/08/04 04:31:44 momjian Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -1055,6 +1055,8 @@ _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
10551055
{
10561056
if (a->command!=b->command)
10571057
return false;
1058+
if (!equal(a->options,b->options))
1059+
return false;
10581060

10591061
return true;
10601062
}

‎src/backend/parser/gram.y

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.352 2002/07/31 17:19:51 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.353 2002/08/04 04:31:44 momjian Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -195,7 +195,7 @@ static void doNegateFloat(Value *v);
195195

196196
%type<str>opt_id,all_Op,MathOp,opt_name,SpecialRuleRelation
197197

198-
%type<str>opt_level,opt_encoding
198+
%type<str>iso_level,opt_encoding
199199
%type<node>grantee
200200
%type<list>grantee_list
201201
%type<ival>privilege
@@ -218,7 +218,7 @@ static void doNegateFloat(Value *v);
218218
target_list,update_target_list,insert_column_list,
219219
insert_target_list,def_list,opt_indirection,
220220
group_clause,TriggerFuncArgs,select_limit,
221-
opt_select_limit,opclass_item_list
221+
opt_select_limit,opclass_item_list,trans_options
222222

223223
%type<range>into_clause,OptTempTableName
224224

@@ -847,14 +847,14 @@ set_rest: ColId TO var_list_or_default
847847
n->args = makeList1($3);
848848
$$ = n;
849849
}
850-
|TRANSACTIONISOLATIONLEVELopt_levelopt_mode
850+
|TRANSACTIONISOLATIONLEVELiso_levelopt_mode
851851
{
852852
VariableSetStmt *n = makeNode(VariableSetStmt);
853853
n->name ="TRANSACTION ISOLATION LEVEL";
854854
n->args = makeList1(makeStringConst($4,NULL));
855855
$$ = n;
856856
}
857-
|SESSIONCHARACTERISTICSASTRANSACTIONISOLATIONLEVELopt_level
857+
|SESSIONCHARACTERISTICSASTRANSACTIONISOLATIONLEVELiso_level
858858
{
859859
VariableSetStmt *n = makeNode(VariableSetStmt);
860860
n->name ="default_transaction_isolation";
@@ -902,7 +902,7 @@ var_value:opt_boolean
902902
{$$ = makeAConst($1); }
903903
;
904904

905-
opt_level:READCOMMITTED{$$ ="read committed"; }
905+
iso_level:READCOMMITTED{$$ ="read committed"; }
906906
|SERIALIZABLE{$$ ="serializable"; }
907907
;
908908

@@ -3445,67 +3445,60 @@ TransactionStmt:
34453445
{
34463446
TransactionStmt *n = makeNode(TransactionStmt);
34473447
n->command = ROLLBACK;
3448+
n->options = NIL;
34483449
$$ = (Node *)n;
34493450
}
34503451
|BEGIN_TRANSopt_trans
34513452
{
34523453
TransactionStmt *n = makeNode(TransactionStmt);
34533454
n->command = BEGIN_TRANS;
3455+
n->options = NIL;
34543456
$$ = (Node *)n;
34553457
}
3456-
|COMMITopt_trans
3458+
|STARTTRANSACTIONtrans_options
34573459
{
34583460
TransactionStmt *n = makeNode(TransactionStmt);
3459-
n->command = COMMIT;
3461+
n->command = START;
3462+
n->options =$3;
34603463
$$ = (Node *)n;
34613464
}
3462-
|COMMITopt_transopt_chain
3465+
|COMMITopt_trans
34633466
{
34643467
TransactionStmt *n = makeNode(TransactionStmt);
34653468
n->command = COMMIT;
3469+
n->options = NIL;
34663470
$$ = (Node *)n;
34673471
}
34683472
|END_TRANSopt_trans
34693473
{
34703474
TransactionStmt *n = makeNode(TransactionStmt);
34713475
n->command = COMMIT;
3476+
n->options = NIL;
34723477
$$ = (Node *)n;
34733478
}
34743479
|ROLLBACKopt_trans
34753480
{
34763481
TransactionStmt *n = makeNode(TransactionStmt);
34773482
n->command = ROLLBACK;
3478-
$$ = (Node *)n;
3479-
}
3480-
|ROLLBACKopt_transopt_chain
3481-
{
3482-
TransactionStmt *n = makeNode(TransactionStmt);
3483-
n->command = ROLLBACK;
3483+
n->options = NIL;
34843484
$$ = (Node *)n;
34853485
}
34863486
;
34873487

3488+
trans_options:ISOLATIONLEVELiso_level
3489+
{$$ = makeList1(makeStringConst($3,NULL)); }
3490+
|/* EMPTY*/{$$ = NIL; }
3491+
;
3492+
34883493
opt_trans:WORK{}
34893494
|TRANSACTION{}
34903495
|/*EMPTY*/{}
34913496
;
34923497

3493-
opt_chain:ANDNOCHAIN{}
3494-
|ANDCHAIN
3495-
{
3496-
/* SQL99 asks that conforming dbs reject AND CHAIN
3497-
* if they don't support it. So we can't just ignore it.
3498-
* - thomas 2000-08-06
3499-
*/
3500-
elog(ERROR,"COMMIT/AND CHAIN not yet supported");
3501-
}
3502-
;
3503-
3504-
35053498
/*****************************************************************************
35063499
*
35073500
*QUERY:
3508-
*define view <viewname> '('target-list ')'[where <quals> ]
3501+
*create view <viewname> '('target-list ')'AS <query>
35093502
*
35103503
*****************************************************************************/
35113504

‎src/backend/tcop/postgres.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.276 2002/07/30 16:55:45 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.277 2002/08/04 04:31:44 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1693,7 +1693,7 @@ PostgresMain(int argc, char *argv[], const char *username)
16931693
if (!IsUnderPostmaster)
16941694
{
16951695
puts("\nPOSTGRES backend interactive interface ");
1696-
puts("$Revision: 1.276 $ $Date: 2002/07/30 16:55:45 $\n");
1696+
puts("$Revision: 1.277 $ $Date: 2002/08/04 04:31:44 $\n");
16971697
}
16981698

16991699
/*
@@ -2160,6 +2160,10 @@ CreateCommandTag(Node *parsetree)
21602160
tag="BEGIN";
21612161
break;
21622162

2163+
caseSTART:
2164+
tag="START TRANSACTION";
2165+
break;
2166+
21632167
caseCOMMIT:
21642168
tag="COMMIT";
21652169
break;

‎src/backend/tcop/utility.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.167 2002/07/30 16:55:45 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.168 2002/08/04 04:31:44 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -205,6 +205,28 @@ ProcessUtility(Node *parsetree,
205205
BeginTransactionBlock();
206206
break;
207207

208+
/*
209+
* START TRANSACTION, as defined by SQL99: Identical to BEGIN,
210+
* except that it takes a few additional options.
211+
*/
212+
caseSTART:
213+
{
214+
BeginTransactionBlock();
215+
216+
/*
217+
* Currently, the only option that can be set is
218+
* the transaction isolation level by START
219+
* TRANSACTION.
220+
*/
221+
if (stmt->options)
222+
{
223+
SetPGVariable("TRANSACTION ISOLATION LEVEL",
224+
stmt->options,
225+
false);
226+
}
227+
}
228+
break;
229+
208230
caseCOMMIT:
209231
EndTransactionBlock();
210232
break;

‎src/include/nodes/parsenodes.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: parsenodes.h,v 1.196 2002/07/30 16:55:45 momjian Exp $
10+
* $Id: parsenodes.h,v 1.197 2002/08/04 04:31:44 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1387,13 +1387,14 @@ typedef struct UnlistenStmt
13871387
}UnlistenStmt;
13881388

13891389
/* ----------------------
1390-
*{Begin|Abort|End} Transaction Statement
1390+
*{Begin|Commit|Rollback} Transaction Statement
13911391
* ----------------------
13921392
*/
13931393
typedefstructTransactionStmt
13941394
{
13951395
NodeTagtype;
1396-
intcommand;/* BEGIN|END|ABORT */
1396+
intcommand;/* BEGIN_TRANS|START|COMMIT|ROLLBACK */
1397+
List*options;
13971398
}TransactionStmt;
13981399

13991400
/* ----------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp