From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 2/2] sql: refactor cursor closing routine
Date: Thu, 12 Apr 2018 16:28:44 +0300 [thread overview]
Message-ID: <0c626bc2-a3c0-c4b9-e2ab-cee9ac481051@tarantool.org> (raw)
In-Reply-To: <7410c7c9cec4772039931a8086fa1bb60b24d705.1523468339.git.korablev@tarantool.org>
See below a pair of comments.
> diff --git a/src/box/sql/cursor.c b/src/box/sql/cursor.c
> index 533bfb587..c38629f3b 100644
> --- a/src/box/sql/cursor.c
> +++ b/src/box/sql/cursor.c
> @@ -31,18 +31,26 @@
>
> #include "sqliteInt.h"
> #include "tarantoolInt.h"
> +#include "box/tuple.h"
>
> -/*
> - * Clear the current cursor position.
> +/**
> + * Release tuple, free iterator, invalidate cursor's state.
> + * Note that this routine doesn't nullify space and index:
> + * it is also used during OP_NullRow opcode to refresh given
> + * cursor.
> */
> void
> -sqlite3ClearCursor(BtCursor * pCur)
> +sql_cursor_cleanup(struct BtCursor *cursor)
> {
> - free(pCur->key);
> - pCur->key = 0;
> - pCur->iter = NULL;
> - pCur->last_tuple = NULL;
> - pCur->eState = CURSOR_INVALID;
> + if (cursor->iter)
> + box_iterator_free(cursor->iter);
1. If you use internal structures like struct iterator, then lets
manage them using internal API - iterator_delete(). I know, that
box_iterator_t is the same as struct iterator, but lets be
consistent.
> diff --git a/src/box/sql/cursor.h b/src/box/sql/cursor.h
> index 5b8e7c29d..e5d2aae3a 100644
> --- a/src/box/sql/cursor.h
> +++ b/src/box/sql/cursor.h
> @@ -72,14 +72,16 @@ struct BtCursor {
> void sqlite3CursorZero(BtCursor *);
> void sqlite3CursorHintFlags(BtCursor *, unsigned);
>
> -int sqlite3CloseCursor(BtCursor *);
> +void
> +sql_cursor_close(struct BtCursor *cursor);
2. Lets store comments near to function declarations rather
than implementations.
prev parent reply other threads:[~2018-04-12 13:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-11 19:35 [tarantool-patches] [PATCH 0/2] sql: SQL bindings refactoring Nikita Pettik
2018-04-11 19:35 ` [tarantool-patches] [PATCH 1/2] sql: fix tuple format leak Nikita Pettik
2018-04-12 11:58 ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-13 8:39 ` n.pettik
2018-04-11 19:35 ` [tarantool-patches] [PATCH 2/2] sql: refactor cursor closing routine Nikita Pettik
2018-04-12 13:28 ` Vladislav Shpilevoy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0c626bc2-a3c0-c4b9-e2ab-cee9ac481051@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH 2/2] sql: refactor cursor closing routine' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox