diff --git a/src/box/lua/call.cc b/src/box/lua/call.cc index b4a1ab2845043cc4cee07710bc523b770e8b9210..2fb66a5af8e815eb79f0655c30bfcb183ed32c0a 100644 --- a/src/box/lua/call.cc +++ b/src/box/lua/call.cc @@ -329,6 +329,23 @@ lbox_delete(lua_State *L) return lua_gettop(L) - 3; } +static int +lbox_commit(lua_State * /* L */) +{ + struct txn *txn = in_txn(); + /** + * COMMIT is like BEGIN or ROLLBACK + * a "transaction-initiating statement". + * Do nothing if transaction is not started, + * it's the same as BEGIN + COMMIT. + */ + if (txn) { + txn_commit(txn); + txn_finish(txn); + } + return 0; +} + /** * A helper to find a Lua function by name and put it * on top of the stack. @@ -655,6 +672,7 @@ lbox_snapshot(struct lua_State *L) static const struct luaL_reg boxlib[] = { {"snapshot", lbox_snapshot}, + {"commit", lbox_commit}, {NULL, NULL} }; diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index d4dd2afb0e6895a35c16bf07ee070b855ae8f9ff..410379e8b5b3cdcbc0ab5064e9526a6e0b17aa10 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -55,9 +55,6 @@ ffi.cdef[[ int boxffi_txn_begin(); - int - boxffi_txn_commit(); - void boxffi_txn_rollback(); ]] @@ -204,11 +201,8 @@ box.begin = function() box.error() end end -box.commit = function() - if ffi.C.boxffi_txn_commit() == -1 then - box.error() - end -end +-- box.commit yields, so it's defined in call.cc + box.rollback = ffi.C.boxffi_txn_rollback; box.schema.space = {} @@ -1044,7 +1038,7 @@ end box.schema.user.passwd = function(name, new_password) if name == nil then - error('Usage: box.schema.user.passwd([user,] password)') + box.error(box.error.PROC_LUA, "Usage: box.schema.user.passwd([user,] password)") end if new_password == nil then -- change password for current user diff --git a/src/box/txn.cc b/src/box/txn.cc index 93dd90075e7c33d5d809cad797053905a3d70a76..14119838f130bc1655b6ea1bf7e9122666aef45d 100644 --- a/src/box/txn.cc +++ b/src/box/txn.cc @@ -328,27 +328,6 @@ boxffi_txn_begin() return 0; } -int -boxffi_txn_commit() -{ - try { - struct txn *txn = in_txn(); - /** - * COMMIT is like BEGIN or ROLLBACK - * a "transaction-initiating statement". - * Do nothing if transaction is not started, - * it's the same as BEGIN + COMMIT. - */ - if (txn) { - txn_commit(txn); - txn_finish(txn); - } - } catch (Exception *e) { - return -1; /* pass exception through FFI */ - } - return 0; -} - void boxffi_txn_rollback() { diff --git a/src/box/txn.h b/src/box/txn.h index 51b9f1d18870622f5be112dc10895909b89a8bfd..1f2122c7677370a4c7dd9fb62d0bbc2890016e5c 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -160,13 +160,6 @@ extern "C" { int boxffi_txn_begin(); -/** - * @retval 0 - success - * @retval -1 - commit failed - */ -int -boxffi_txn_commit(); - void boxffi_txn_rollback(); diff --git a/test/big/big.lua b/test/big/big.lua index c17a78000894e2eb4d1da36d0fb507a0c5a793f6..717b7deaecff9ed41b4b5d590185fb2de10f3cf5 100644 --- a/test/big/big.lua +++ b/test/big/big.lua @@ -4,7 +4,7 @@ box.cfg{ listen = os.getenv("LISTEN"), slab_alloc_arena = 0.1, pid_file = "tarantool.pid", - rows_per_wal = 50 + rows_per_wal = 500000 } require('console').listen(os.getenv('ADMIN')) diff --git a/test/box/access.result b/test/box/access.result index de50fc73379b0322770745babd17f0108280d9b1..de2a8ba0829105467471bc429833f79f9ad84ad3 100644 --- a/test/box/access.result +++ b/test/box/access.result @@ -394,8 +394,7 @@ box.schema.user.passwd('invalid_user', 'some_password') ... box.schema.user.passwd() --- -- error: '[string "-- schema.lua (internal file)..."]:1047: Usage: box.schema.user.passwd([user,] - password)' +- error: 'Usage: box.schema.user.passwd([user,] password)' ... session.su('user1') ---