SAVEPOINT
,
ROLLBACK TO SAVEPOINT
, and
RELEASE SAVEPOINT
, and Syntax
1114
• Data loading statements.
LOAD MASTER DATA
,
LOAD DATA INFILE
. Before MySQL 5.0.26,
LOAD DATA INFILE
caused an implicit commit for all storage engines. As of MySQL 5.0.26, it
causes an implicit commit only for tables using the
NDB
storage engine. For more information, see
Bug #11151.
13.3.4.
SAVEPOINT
,
ROLLBACK TO SAVEPOINT
, and
RELEASE SAVEPOINT
,
and Syntax
SAVEPOINT
identifier
ROLLBACK [WORK] TO [SAVEPOINT]
identifier
RELEASE SAVEPOINT
identifier
InnoDB
supports the SQL statements
SAVEPOINT
and
ROLLBACK TO SAVEPOINT
. Starting from
MySQL 5.0.3,
RELEASE SAVEPOINT
and the optional
WORK
keyword for
ROLLBACK
are supported as
well.
The
SAVEPOINT
statement sets a named transaction savepoint with a name of
identifier
. If the
current transaction has a savepoint with the same name, the old savepoint is deleted and a new one is
set.
The
ROLLBACK TO SAVEPOINT
statement rolls back a transaction to the named savepoint without
terminating the transaction. (The
SAVEPOINT
keyword is optional as of MySQL 5.0.3.) Modifications
that the current transaction made to rows after the savepoint was set are undone in the rollback, but
InnoDB
does not release the row locks that were stored in memory after the savepoint. (For a new
inserted row, the lock information is carried by the transaction ID stored in the row; the lock is not
separately stored in memory. In this case, the row lock is released in the undo.) Savepoints that were
set at a later time than the named savepoint are deleted.
If the
ROLLBACK TO SAVEPOINT
statement returns the following error, it means that no savepoint with
the specified name exists:
ERROR 1305 (42000): SAVEPOINT
identifier
does not exist
The
RELEASE SAVEPOINT
statement removes the named savepoint from the set of savepoints of the
current transaction. No commit or rollback occurs. It is an error if the savepoint does not exist.
All savepoints of the current transaction are deleted if you execute a
COMMIT
, or a
ROLLBACK
that does
not name a savepoint.
Beginning with MySQL 5.0.17, a new savepoint level is created when a stored function is invoked or
a trigger is activated. The savepoints on previous levels become unavailable and thus do not conflict
with savepoints on the new level. When the function or trigger terminates, any savepoints it created are
released and the previous savepoint level is restored.
13.3.5.
LOCK TABLES
and
UNLOCK TABLES
Syntax
LOCK TABLES
tbl_name
[[AS]
alias
]
lock_type
[,
tbl_name
[[AS]
alias
]
lock_type
] ...
lock_type
:
READ [LOCAL]
| [LOW_PRIORITY] WRITE
UNLOCK TABLES
MySQL enables client sessions to acquire table locks explicitly for the purpose of cooperating with
other sessions for access to tables, or to prevent other sessions from modifying tables during periods
when a session requires exclusive access to them. A session can acquire or release locks only for
itself. One session cannot acquire locks for another session or release locks held by another session.
Locks may be used to emulate transactions or to get more speed when updating tables. This is
explained in more detail later in this section.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...