[tarantool-patches] Re: [PATCH 1/2] sql: fix tuple format leak
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Thu Apr 12 14:58:13 MSK 2018
Hello. Thank you for contributing! See below 3 comments.
> diff --git a/src/box/sql.c b/src/box/sql.c
> index a6713f1f0..dd0cfcc1a 100644
> --- a/src/box/sql.c
> +++ b/src/box/sql.c
> @@ -451,17 +451,13 @@ int tarantoolSqlite3EphemeralCreate(BtCursor *pCur, uint32_t field_count,
> *
> * @retval SQLITE_OK on success, SQLITE_TARANTOOL_ERROR otherwise.
> */
> -int tarantoolSqlite3EphemeralInsert(BtCursor *pCur)
> +int tarantoolSqlite3EphemeralInsert(struct space *space, char *tuple,
> + char *tuple_end)
1. Please, update the comment as well. And lets move it to a header, as
it is done in tarantool core.
> {
> - assert(pCur);
> - assert(pCur->curFlags & BTCF_TEphemCursor);
> - mp_tuple_assert(pCur->key, pCur->key + pCur->nKey);
> -
> - if (space_ephemeral_replace(pCur->space, pCur->key,
> - pCur->key + pCur->nKey) != 0) {
> - diag_log();
> + assert(space != NULL);
> + mp_tuple_assert(tuple, tuple_end);
> + if (space_ephemeral_replace(space, tuple, tuple_end) != 0)
> return SQL_TARANTOOL_INSERT_FAIL;
> - }
> return SQLITE_OK;
> }
>
> @@ -475,28 +471,29 @@ int tarantoolSqlite3EphemeralDrop(BtCursor *pCur)
> }
>
> static inline int
> -insertOrReplace(BtCursor *pCur, enum iproto_type type)
> +insertOrReplace(struct space *space, char *tuple, char *tuple_end,
> + enum iproto_type type)
2. Please, make a pointer be const, if it is not changed. Here it is
const. Const specifier helps compiler to do more accurate optimization.
> -int tarantoolSqlite3Insert(BtCursor *pCur)
> +int tarantoolSqlite3Insert(struct space *space, char *tuple, char *tuple_end)
> {
> - return insertOrReplace(pCur, IPROTO_INSERT);
> + return insertOrReplace(space, tuple, tuple_end, IPROTO_INSERT);
> }
>
> -int tarantoolSqlite3Replace(BtCursor *pCur)
> +int tarantoolSqlite3Replace(struct space *space, char *tuple, char *tuple_end)
3. Same.
More information about the Tarantool-patches
mailing list