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

Commita583675

Browse files
committed
Allow optional SAVEPOINT keyword in RELEASE and ROLLBACK TO, for greater
compliance with SQL2003 spec syntax.Oliver Jowett
1 parent10249ab commita583675

File tree

8 files changed

+118
-94
lines changed

8 files changed

+118
-94
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.60 2004/08/01 17:32:13 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.61 2004/08/12 19:12:21 tgl Exp $
33
PostgreSQL documentation
44
Complete list of usable sgml source files in this directory.
55
-->
@@ -88,7 +88,7 @@ Complete list of usable sgml source files in this directory.
8888
<!entity notify system "notify.sgml">
8989
<!entity prepare system "prepare.sgml">
9090
<!entity reindex system "reindex.sgml">
91-
<!entity releaseSavepoint system "release.sgml">
91+
<!entity releaseSavepoint system "release_savepoint.sgml">
9292
<!entity reset system "reset.sgml">
9393
<!entity revoke system "revoke.sgml">
9494
<!entity rollback system "rollback.sgml">

‎doc/src/sgml/ref/release.sgmlrenamed to‎doc/src/sgml/ref/release_savepoint.sgml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/release.sgml,v 1.1 2004/08/01 17:32:13 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/release_savepoint.sgml,v 1.1 2004/08/12 19:12:21 tgl Exp $
33
PostgreSQL documentation
44
-->
55

6-
<refentry id="SQL-RELEASE">
6+
<refentry id="SQL-RELEASE-SAVEPOINT">
77
<refmeta>
8-
<refentrytitle id="SQL-RELEASE-TITLE">RELEASE</refentrytitle>
8+
<refentrytitle id="SQL-RELEASE-SAVEPOINT-TITLE">RELEASE SAVEPOINT</refentrytitle>
99
<refmiscinfo>SQL - Language Statements</refmiscinfo>
1010
</refmeta>
1111

1212
<refnamediv>
13-
<refname>RELEASE</refname>
13+
<refname>RELEASE SAVEPOINT</refname>
1414
<refpurpose>destroy a previously defined savepoint</refpurpose>
1515
</refnamediv>
1616

17-
<indexterm zone="sql-release">
18-
<primary>RELEASE</primary>
17+
<indexterm zone="sql-release-savepoint">
18+
<primary>RELEASE SAVEPOINT</primary>
1919
</indexterm>
2020

21-
<indexterm zone="sql-release">
21+
<indexterm zone="sql-release-savepoint">
2222
<primary>savepoints</primary>
2323
<secondary>releasing</secondary>
2424
</indexterm>
2525

2626
<refsynopsisdiv>
2727
<synopsis>
28-
RELEASE <replaceable>savepoint_name</replaceable>
28+
RELEASE[ SAVEPOINT ]<replaceable>savepoint_name</replaceable>
2929
</synopsis>
3030
</refsynopsisdiv>
3131

3232
<refsect1>
3333
<title>Description</title>
3434

3535
<para>
36-
<command>RELEASE</command> destroys a savepoint previously defined
36+
<command>RELEASE SAVEPOINT</command> destroys a savepoint previously defined
3737
in the current transaction.
3838
</para>
3939

@@ -48,7 +48,7 @@ RELEASE <replaceable>savepoint_name</replaceable>
4848
</para>
4949

5050
<para>
51-
<command>RELEASE</command> also destroys all savepoints that were
51+
<command>RELEASE SAVEPOINT</command> also destroys all savepoints that were
5252
established after the named savepoint was established.
5353
</para>
5454
</refsect1>
@@ -97,7 +97,7 @@ BEGIN;
9797
INSERT INTO table VALUES (3);
9898
SAVEPOINT my_savepoint;
9999
INSERT INTO table VALUES (4);
100-
RELEASE my_savepoint;
100+
RELEASESAVEPOINTmy_savepoint;
101101
COMMIT;
102102
</programlisting>
103103
The above transaction will insert both 3 and 4.
@@ -108,7 +108,9 @@ COMMIT;
108108
<title>Compatibility</title>
109109

110110
<para>
111-
RELEASE is fully conforming to the SQL standard.
111+
The SQL2003 standard specifies that the keyword SAVEPOINT is mandatory.
112+
<productname>PostgreSQL</productname> allows the SAVEPOINT keyword to be
113+
omitted. Otherwise, this command is fully conforming.
112114
</para>
113115
</refsect1>
114116

‎doc/src/sgml/ref/rollback_to.sgml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/rollback_to.sgml,v 1.1 2004/08/01 17:32:13 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/rollback_to.sgml,v 1.2 2004/08/12 19:12:21 tgl Exp $
33
PostgreSQL documentation
44
-->
55

66
<refentry id="SQL-ROLLBACK-TO">
77
<refmeta>
8-
<refentrytitle id="SQL-ROLLBACK-TO-TITLE">ROLLBACK TO</refentrytitle>
8+
<refentrytitle id="SQL-ROLLBACK-TO-TITLE">ROLLBACK TO SAVEPOINT</refentrytitle>
99
<refmiscinfo>SQL - Language Statements</refmiscinfo>
1010
</refmeta>
1111

1212
<refnamediv>
13-
<refname>ROLLBACK TO</refname>
13+
<refname>ROLLBACK TO SAVEPOINT</refname>
1414
<refpurpose>roll back to a savepoint</refpurpose>
1515
</refnamediv>
1616

1717
<indexterm zone="sql-rollback-to">
18-
<primary>ROLLBACK TO</primary>
18+
<primary>ROLLBACK TO SAVEPOINT</primary>
1919
</indexterm>
2020

2121
<indexterm zone="sql-rollback-to">
@@ -25,7 +25,7 @@ PostgreSQL documentation
2525

2626
<refsynopsisdiv>
2727
<synopsis>
28-
ROLLBACKTO <replaceable>savepoint_name</replaceable>
28+
ROLLBACK[ WORK | TRANSACTION ] TO [ SAVEPOINT ] <replaceable>savepoint_name</replaceable>
2929
</synopsis>
3030
</refsynopsisdiv>
3131

@@ -39,7 +39,7 @@ ROLLBACK TO <replaceable>savepoint_name</replaceable>
3939
</para>
4040

4141
<para>
42-
<command>ROLLBACK TO</> implicitly destroys all savepoints that
42+
<command>ROLLBACK TO SAVEPOINT</> implicitly destroys all savepoints that
4343
were established after the named savepoint.
4444
</para>
4545
</refsect1>
@@ -63,9 +63,9 @@ ROLLBACK TO <replaceable>savepoint_name</replaceable>
6363
<title>Notes</title>
6464

6565
<para>
66-
Use <xref linkend="SQL-RELEASE" endterm="SQL-RELEASE-TITLE"> to
67-
destroy a savepoint without discarding the effects of commands executed
68-
after it was established.
66+
Use <xref linkend="SQL-RELEASE-SAVEPOINT"
67+
endterm="SQL-RELEASE-SAVEPOINT-TITLE"> todestroy a savepoint without
68+
discarding the effects of commands executedafter it was established.
6969
</para>
7070

7171
<para>
@@ -81,7 +81,7 @@ ROLLBACK TO <replaceable>savepoint_name</replaceable>
8181
left it pointing to (that is, <command>FETCH</> is not rolled back).
8282
A cursor whose execution causes a transaction to abort is put in a
8383
can't-execute state, so while the transaction can be restored using
84-
<command>ROLLBACK TO</>, the cursor can no longer be used.
84+
<command>ROLLBACK TO SAVEPOINT</>, the cursor can no longer be used.
8585
</para>
8686
</refsect1>
8787

@@ -92,7 +92,7 @@ ROLLBACK TO <replaceable>savepoint_name</replaceable>
9292
To undo the effects of the commands executed after <literal>my_savepoint</literal>
9393
was established:
9494
<programlisting>
95-
ROLLBACK TO my_savepoint;
95+
ROLLBACK TOSAVEPOINTmy_savepoint;
9696
</programlisting>
9797
</para>
9898

@@ -110,7 +110,7 @@ FETCH 1 FROM foo;
110110
----------
111111
1
112112

113-
ROLLBACK TO foo;
113+
ROLLBACK TOSAVEPOINTfoo;
114114

115115
FETCH 1 FROM foo;
116116
?column?
@@ -128,7 +128,13 @@ COMMIT;
128128
<title>Compatibility</title>
129129

130130
<para>
131-
This command is fully SQL standard conforming.
131+
The SQL2003 standard specifies that the keyword SAVEPOINT is mandatory.
132+
<productname>PostgreSQL</productname> and <productname>Oracle</productname>
133+
allow the SAVEPOINT keyword to be omitted. SQL2003 allows only
134+
WORK, not TRANSACTION, as a noise word after ROLLBACK. Also, SQL2003
135+
has an optional clause AND [ NO ] CHAIN which is not currently supported
136+
by <productname>PostgreSQL</productname>. Otherwise, this command is
137+
fully conforming.
132138
</para>
133139
</refsect1>
134140

@@ -139,7 +145,7 @@ COMMIT;
139145
<member><xref linkend="sql-begin" endterm="sql-begin-title"></member>
140146
<member><xref linkend="sql-commit" endterm="sql-commit-title"></member>
141147
<member><xref linkend="sql-savepoint" endterm="sql-savepoint-title"></member>
142-
<member><xref linkend="sql-release" endterm="sql-release-title"></member>
148+
<member><xref linkend="sql-release-savepoint" endterm="sql-release-savepoint-title"></member>
143149
<member><xref linkend="sql-rollback" endterm="sql-rollback-title"></member>
144150
</simplelist>
145151
</refsect1>

‎doc/src/sgml/ref/savepoint.sgml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/savepoint.sgml,v 1.1 2004/08/01 17:32:13 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/savepoint.sgml,v 1.2 2004/08/12 19:12:21 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -64,8 +64,8 @@ SAVEPOINT <replaceable>savepoint_name</replaceable>
6464

6565
<para>
6666
Use <xref linkend="SQL-ROLLBACK-TO" endterm="SQL-ROLLBACK-TO-TITLE"> to
67-
rollback to a savepoint. Use <xref linkend="SQL-RELEASE"
68-
endterm="SQL-RELEASE-TITLE"> to destroy a savepoint, keeping
67+
rollback to a savepoint. Use <xref linkend="SQL-RELEASE-SAVEPOINT"
68+
endterm="SQL-RELEASE-SAVEPOINT-TITLE"> to destroy a savepoint, keeping
6969
the effects of commands executed after it was established.
7070
</para>
7171

@@ -86,7 +86,7 @@ BEGIN;
8686
INSERT INTO table VALUES (1);
8787
SAVEPOINT my_savepoint;
8888
INSERT INTO table VALUES (2);
89-
ROLLBACK TO my_savepoint;
89+
ROLLBACK TOSAVEPOINTmy_savepoint;
9090
INSERT INTO table VALUES (3);
9191
COMMIT;
9292
</programlisting>
@@ -100,7 +100,7 @@ BEGIN;
100100
INSERT INTO table VALUES (3);
101101
SAVEPOINT my_savepoint;
102102
INSERT INTO table VALUES (4);
103-
RELEASE my_savepoint;
103+
RELEASESAVEPOINTmy_savepoint;
104104
COMMIT;
105105
</programlisting>
106106
The above transaction will insert both 3 and 4.
@@ -116,8 +116,8 @@ COMMIT;
116116
<productname>PostgreSQL</>, the old savepoint is kept, though only the more
117117
recent one will be used when rolling back or releasing. (Releasing the
118118
newer savepoint will cause the older one to again become accessible to
119-
<command>ROLLBACK TO</> and <command>RELEASE</>.)
120-
Other than that, <command>SAVEPOINT</command> is fully SQL conforming.
119+
<command>ROLLBACK TO SAVEPOINT</> and <command>RELEASE SAVEPOINT</>.)
120+
Otherwise, <command>SAVEPOINT</command> is fully SQL conforming.
121121
</para>
122122
</refsect1>
123123

@@ -128,7 +128,7 @@ COMMIT;
128128
<member><xref linkend="sql-begin" endterm="sql-begin-title"></member>
129129
<member><xref linkend="sql-rollback" endterm="sql-rollback-title"></member>
130130
<member><xref linkend="sql-rollback-to" endterm="sql-rollback-to-title"></member>
131-
<member><xref linkend="sql-release" endterm="sql-release-title"></member>
131+
<member><xref linkend="sql-release-savepoint" endterm="sql-release-savepoint-title"></member>
132132
<member><xref linkend="sql-commit" endterm="sql-commit-title"></member>
133133
</simplelist>
134134
</refsect1>

‎src/backend/parser/gram.y

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.469 2004/08/02 04:26:35 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.470 2004/08/12 19:12:21 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -3982,6 +3982,14 @@ TransactionStmt:
39823982
(Node *)makeString($2)));
39833983
$$ = (Node *)n;
39843984
}
3985+
| RELEASE SAVEPOINT ColId
3986+
{
3987+
TransactionStmt *n = makeNode(TransactionStmt);
3988+
n->kind = TRANS_STMT_RELEASE;
3989+
n->options = list_make1(makeDefElem("savepoint_name",
3990+
(Node *)makeString($3)));
3991+
$$ = (Node *)n;
3992+
}
39853993
| RELEASE ColId
39863994
{
39873995
TransactionStmt *n = makeNode(TransactionStmt);
@@ -3990,12 +3998,20 @@ TransactionStmt:
39903998
(Node *)makeString($2)));
39913999
$$ = (Node *)n;
39924000
}
3993-
| ROLLBACKTO ColId
4001+
| ROLLBACKopt_transaction TO SAVEPOINT ColId
39944002
{
39954003
TransactionStmt *n = makeNode(TransactionStmt);
39964004
n->kind = TRANS_STMT_ROLLBACK_TO;
39974005
n->options = list_make1(makeDefElem("savepoint_name",
3998-
(Node *)makeString($3)));
4006+
(Node *)makeString($5)));
4007+
$$ = (Node *)n;
4008+
}
4009+
| ROLLBACK opt_transaction TO ColId
4010+
{
4011+
TransactionStmt *n = makeNode(TransactionStmt);
4012+
n->kind = TRANS_STMT_ROLLBACK_TO;
4013+
n->options = list_make1(makeDefElem("savepoint_name",
4014+
(Node *)makeString($4)));
39994015
$$ = (Node *)n;
40004016
}
40014017
;

‎src/backend/tcop/utility.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.223 2004/08/02 01:30:45 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.224 2004/08/12 19:12:21 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -388,12 +388,12 @@ ProcessUtility(Node *parsetree,
388388
break;
389389

390390
caseTRANS_STMT_RELEASE:
391-
RequireTransactionChain((void*)stmt,"RELEASE");
391+
RequireTransactionChain((void*)stmt,"RELEASE SAVEPOINT");
392392
ReleaseSavepoint(stmt->options);
393393
break;
394394

395395
caseTRANS_STMT_ROLLBACK_TO:
396-
RequireTransactionChain((void*)stmt,"ROLLBACK TO");
396+
RequireTransactionChain((void*)stmt,"ROLLBACK TO SAVEPOINT");
397397
RollbackToSavepoint(stmt->options);
398398
/*
399399
* CommitTransactionCommand is in charge

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp