[tarantool-patches] Re: [PATCH 3/3] sql: implement point where for DELETE stmts
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Mon Jun 18 15:40:06 MSK 2018
Thanks for the fixes! See 2 comments below.
>> 2. As I proposed in the review, why can not we use stack struct Table here?
>> Just declare it at the beginning of the function and here save its pointer.
>
> Well, OK it is possible:
>
> +++ b/src/box/sql/delete.c
> @@ -111,9 +111,12 @@ sql_table_delete_from(struct Parse *parse, struct SrcList *tab_list,
> * wrapper around space_def to support interface.
> */
> space = space_by_id(space_id);
> - tab_list->a[0].pTab = sql_table_construct_from_space(space);
> - if (tab_list->a[0].pTab == NULL)
> - goto delete_from_cleanup;
> + struct Table tmp_tab;
> + memset(&tmp_tab, 0, sizeof(tmp_tab));
> + tmp_tab.def = space->def;
> + /* Prevent from freeing memory in DeleteTable. */
> + tmp_tab.nTabRef = 2;
> + tab_list->a[0].pTab = &tmp_tab;
1. Are you sure you can save the pointer to the stack value and then
use it out of the declaration context?
Here tmp_tab is declared inside {} block, but pointer on it is
used out the former.
>>> 11 files changed, 256 insertions(+), 253 deletions(-)
>>>> diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
>>> index 23e16189a..e7d9723fa 100644
>>> --- a/src/box/sql/resolve.c
>>> +++ b/src/box/sql/resolve.c
>>> @@ -39,6 +39,9 @@
>>> #include <stdlib.h>
>>> #include <string.h>
>>> +#include "box/box.h"
>>> +#include "box/schema.h"
>>
>> 4. Why do you need these headers?
>
> Looks like I forgot to remove them. Anyway, in your fixes you removed them. Thx.
>
>>> */
>>> static int
>>> -sql_where_shortcut(struct WhereLoopBuilder *builder)
>>> +where_assign_loop_terms(struct WhereLoop *loop, struct WhereClause *where,
>>> + int cursor, struct space_def *space_def,
>>> + struct index_def *idx_def)
>>
>> 5. Why WhereClause new method has prefix 'sql_where_', but WhereLoop method has prefix
>> 'where_'? Lets make it 'where_clause_find_term' and 'where_loop_assign_terms’.
>
> -sql_where_find_term(struct WhereClause *where_clause, int cursor, int column,
> - Bitmask is_ready, u32 op, struct space_def *space_def,
> - struct key_def *key_def)
> +where_clase_find_term(struct WhereClause *where_clause, int cursor, int column,
2. clase - clause. Else the patch can not be built.
> + Bitmask is_ready, u32 op, struct space_def *space_def,
> + struct key_def *key_def)
>
More information about the Tarantool-patches
mailing list