diff --git a/src/box/box.cc b/src/box/box.cc index 08a19fc0936836badda0758c096befe82de9453e..8819327274d28660233bd5a4300d92b93773e284 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -307,8 +307,6 @@ box_process_rw(struct request *request, struct space *space, bool return_tuple = false; struct txn *txn = in_txn(); bool is_autocommit = txn == NULL; - struct result_processor res_proc; - int rc; if (is_autocommit && (txn = txn_begin()) == NULL) return -1; assert(iproto_type_is_dml(request->type)); @@ -317,19 +315,14 @@ box_process_rw(struct request *request, struct space *space, goto rollback; if (txn_begin_stmt(txn, space, request->type) != 0) goto rollback; - result_process_prepare(&res_proc, space); - rc = space_execute_dml(space, txn, request, &tuple); - if (result == NULL) - tuple = NULL; - result_process_perform(&res_proc, &rc, &tuple); - if (rc != 0) { + if (space_execute_dml(space, txn, request, &tuple) != 0) { txn_rollback_stmt(txn); goto rollback; } if (result != NULL) *result = tuple; - return_tuple = tuple != NULL; + return_tuple = result != NULL && tuple != NULL; if (return_tuple) { /* * Pin the tuple locally before the commit, diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c index 17d61e2f989f455d985e510c017495e9880b896d..1eac915fe22b6ab527ef426b321e3b69c7c5f992 100644 --- a/src/box/memtx_space.c +++ b/src/box/memtx_space.c @@ -45,6 +45,7 @@ #include "sequence.h" #include "memtx_tuple_compression.h" #include "schema.h" +#include "result.h" /* * Yield every 1K tuples while building a new index or checking @@ -437,8 +438,8 @@ memtx_space_execute_delete(struct space *space, struct txn *txn, if (memtx_space_replace_tuple(space, stmt, old_tuple, NULL, DUP_REPLACE_OR_INSERT) != 0) return -1; - *result = stmt->old_tuple; - return 0; + *result = result_process(space, stmt->old_tuple); + return *result == NULL ? -1 : 0; } static int diff --git a/src/box/result.h b/src/box/result.h index a443b36b7efb97b63c0794a8422c15dbe2124d52..9bb9cd9ae06837aebdab0a2568d7953b024e0314 100644 --- a/src/box/result.h +++ b/src/box/result.h @@ -60,6 +60,23 @@ result_process_perform(struct result_processor *p, int *rc, space_upgrade_unref(p->upgrade); } +/** + * A shortcut for + * + * int rc = 0; + * struct result_processor res_proc; + * result_process_prepare(&res_proc, space); + * result_process_perform(&res_proc, &rc, &tuple); + */ +static inline struct tuple * +result_process(struct space *space, struct tuple *tuple) +{ + if (unlikely(space->upgrade != NULL)) + return space_upgrade_apply(space->upgrade, tuple); + else + return tuple; +} + #if defined(__cplusplus) } /* extern "C" */ #endif /* defined(__cplusplus) */