Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v7 7/7] sql: remove Checks to server
Date: Wed, 30 May 2018 13:42:31 +0300	[thread overview]
Message-ID: <1E697F67-DF86-4DFD-BD2C-2112834D5302@tarantool.org> (raw)
In-Reply-To: <36da1e00-8787-91e0-c267-78c87836e4e3@tarantool.org>


> On 30 May 2018, at 11:32, Kirill Shcherbatov <kshcherbatov@tarantool.org> wrote:
> 
>> You can specify that ‘opt’ is output param by [out] tag:
>> @param[out] opt ...
> - * @param opt pointer to store parsing result.
> + * @param[out] opt pointer to store parsing result.
> 
>> Mb it would be better to rename this struct according to our codestyle?
> ExprList is a SQL structure not only for checks, so it's not a good idea to make a project-wide renaming. 

But sooner or later we will have to do it. Anyway, as you wish.

>> 
>>> +++ b/src/box/sql.c
>>> @@ -1500,22 +1500,47 @@ int tarantoolSqlite3MakeTableFormat(Table *pTable, void *buf)
>>> *
>>> * Ex: {"temporary": true, "sql": "CREATE TABLE student (name, grade)"}
>>> */
>>> -int tarantoolSqlite3MakeTableOpts(Table *pTable, const char *zSql, void *buf)
>>> +int
>>> +tarantoolSqlite3MakeTableOpts(Table *pTable, const char *zSql, char *buf)
>>> {
>>>       const struct Enc *enc = get_enc(buf);
>>> -       char *base = buf, *p;
>>> +       bool is_view = pTable != NULL && pTable->def->opts.is_view;
>>> +       bool has_checks = pTable != NULL && pTable->def->opts.checks != NULL;
>> 
>> In fact, it is incorrect since opts.checks may also contain aliases for VIEW
>> columns: CREATE VIEW V1(a, b, c) AS SELECT * FROM t1;
>> In this case, checks contain NULL exprs with names ‘A’, ‘B’ and ‘C’.
>> So you should add another one condition: && is_view.
> 
>> The same is here: you add checks for VIEW which are really aliases.
> The VIEW checks are also represented as ExprList with name pointers but lacks Expr pointer.
> So, this check is valid. 

I extremely dislike this original SQLite approach, since it is so confusing.
I suggest to rework it somehow. I have dived into this problem.
Now aliases are stored as checks only for
one reason: to tell whether SELECT of view is resolved or not.
If not, aliases are extracted from checks list and put into regular fields
array. Thus, if we store aliases as fields right after view creation,
we can’t point out whether we have resolved names for this view,
or it is just view with aliases.

But since point of this patch slightly different, lets leave it as it is.

> 
>> Why do we still need to create table wrappers?
>> Is it possible to change signatures and use straight space_def instead of fake tables?
> sql_resolve_self_reference initialize SrcList field pTab; 
> Unfortunately sql_resolve_self_reference is not the only way of usage  SrcList and at least Table field pIndex is required in other scenarios.

Well, l see now. Seems it can be fixed after introducing index_def in struct Index.

  reply	other threads:[~2018-05-30 10:42 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 14:05 [tarantool-patches] [PATCH v7 0/7] " Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 1/7] sql: remove parser construct, destruct to sql.h Kirill Shcherbatov
2018-05-23 17:46   ` [tarantool-patches] " Konstantin Osipov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 12:05     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 2/7] box: introduce OPT_ARRAY opt_type to decode arrays Kirill Shcherbatov
2018-05-23 17:53   ` [tarantool-patches] " Konstantin Osipov
2018-05-24  7:32     ` Kirill Shcherbatov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:54     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 3/7] sql: introduce expr_len for sql_expr_compile Kirill Shcherbatov
2018-05-24 19:26   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-25 11:54     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 4/7] sql: rename sql_expr_free to sql_expr_delete Kirill Shcherbatov
2018-05-23 18:00   ` [tarantool-patches] " Konstantin Osipov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:54     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 5/7] sql: change sqlite3AddCheckConstraint signature Kirill Shcherbatov
2018-05-23 18:01   ` [tarantool-patches] " Konstantin Osipov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:53     ` Kirill Shcherbatov
2018-05-29 11:51   ` n.pettik
2018-05-30  8:32     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 6/7] sql: export funcs defined on Expr, ExprList to sql.h Kirill Shcherbatov
2018-05-23 18:15   ` [tarantool-patches] " Konstantin Osipov
2018-05-24  7:33     ` Kirill Shcherbatov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:53     ` Kirill Shcherbatov
2018-05-28 11:19       ` Vladislav Shpilevoy
2018-05-28 14:59         ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 7/7] sql: remove Checks to server Kirill Shcherbatov
2018-05-24 19:26   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-25 11:53     ` Kirill Shcherbatov
2018-05-28 11:19       ` Vladislav Shpilevoy
2018-05-28 14:59         ` Kirill Shcherbatov
2018-05-28 18:50           ` Vladislav Shpilevoy
2018-05-29 11:49   ` n.pettik
2018-05-30  8:32     ` Kirill Shcherbatov
2018-05-30 10:42       ` n.pettik [this message]
2018-05-25 12:04 ` [tarantool-patches] Re: [PATCH v7 0/7] " Kirill Shcherbatov
2018-05-28 11:19   ` Vladislav Shpilevoy
2018-05-30 11:03 ` n.pettik
2018-05-31 17:44   ` Kirill Yukhin

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=1E697F67-DF86-4DFD-BD2C-2112834D5302@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v7 7/7] sql: remove Checks to server' \
    /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