Skip to content

Commit b4888b8

Browse files
author
Bogdan Degtyariov
committed
Documentation update on row/document locking
1 parent 2d95dc4 commit b4888b8

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

include/devapi/collection_crud.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,12 +900,24 @@ DIAGNOSTIC_POP
900900
return fields(rest...);
901901
}
902902

903+
/**
904+
Set a shared mode lock on any rows/documents that are read.
905+
906+
Other sessions can read, but not modify locked rows/documents.
907+
*/
903908
CollectionGroupBy& lockShared()
904909
{
905910
get_impl()->set_locking(internal::Lock_mode::SHARED);
906911
return *this;
907912
}
908913

914+
/**
915+
Set an exclusive mode lock on any rows/documents that are read.
916+
917+
Other sessions are blocked from modifying, locking, or reading the data
918+
in certain transaction isolation levels. The lock is released
919+
when the transaction is committed or rolled back.
920+
*/
909921
CollectionGroupBy& lockExclusive()
910922
{
911923
get_impl()->set_locking(internal::Lock_mode::EXCLUSIVE);

include/devapi/statement.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,24 @@ class Statement
191191

192192
Statement(Statement &&other) : Executable<Res,Op>(std::move(other)) {}
193193

194+
/**
195+
Set a shared mode lock on any rows/documents that are read.
196+
197+
Other sessions can read, but not modify locked rows/documents.
198+
*/
194199
Executable<Res, Op> &lockShared()
195200
{
196201
get_impl()->set_locking(internal::Lock_mode::SHARED);
197202
return *this;
198203
}
199204

205+
/**
206+
Set an exclusive mode lock on any rows/documents that are read.
207+
208+
Other sessions are blocked from modifying, locking, or reading the data
209+
in certain transaction isolation levels. The lock is released
210+
when the transaction is committed or rolled back.
211+
*/
200212
Executable<Res, Op> &lockExclusive()
201213
{
202214
get_impl()->set_locking(internal::Lock_mode::EXCLUSIVE);

include/mysql_xapi.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ typedef enum mysqlx_view_check_option_enum
444444
*/
445445
typedef enum mysqlx_row_locking_enum
446446
{
447-
LOCK_NONE = 0,
448-
LOCK_SHARED = 1,
449-
LOCK_EXCLUSIVE = 2
447+
LOCK_NONE = 0, /**< No locking */
448+
LOCK_SHARED = 1, /**< Locking in Shared mode */
449+
LOCK_EXCLUSIVE = 2 /**< Locking in Exclusive mode */
450450
} mysqlx_row_locking_t;
451451

452452
/*
@@ -2151,7 +2151,7 @@ PUBLIC_API int
21512151
mysqlx_set_limit_and_offset(mysqlx_stmt_t *stmt, uint64_t row_count,
21522152
uint64_t offset);
21532153

2154-
/*
2154+
/**
21552155
Set row locking mode for a statement.
21562156
21572157
Set row locking mode for statement operations working on ranges of
@@ -2166,21 +2166,22 @@ mysqlx_set_limit_and_offset(mysqlx_stmt_t *stmt, uint64_t row_count,
21662166
@param stmt statement handle
21672167
@param locking the integer mode identifier (see `mysqlx_row_locking_t`).
21682168
Possible values:
2169-
ROW_LOCK_NONE - no row locking is set
21702169
2171-
ROW_LOCK_SHARED - Sets a shared mode lock on any rows that
2170+
LOCK_NONE - Sets no row locking
2171+
2172+
LOCK_SHARED - Sets a shared mode lock on any rows that
21722173
are read. Other sessions can read the rows,
21732174
but cannot modify them until your transaction
21742175
commits. If any of these rows were changed by
21752176
another transaction that has not yet committed,
21762177
your query waits until that transaction ends
21772178
and then uses the latest values.
21782179
2179-
ROW_LOCK_EXCLUSIVE - For index records the search encounters,
2180+
LOCK_EXCLUSIVE - For index records the search encounters,
21802181
locks the rows and any associated index entries, the same
21812182
as if you issued an UPDATE statement for those rows. Other
21822183
transactions are blocked from updating those rows,
2183-
from doing locking in ROW_LOCK_SHARED, or from reading
2184+
from doing locking in LOCK_SHARED, or from reading
21842185
the data in certain transaction isolation levels.
21852186
21862187
@return `RESULT_OK` - on success; `RESULT_ERR` - on error

0 commit comments

Comments
 (0)