Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v7 7/7] sql: remove Checks to server
Date: Mon, 28 May 2018 14:19:11 +0300	[thread overview]
Message-ID: <ab54fc78-b9b8-c537-9885-2c96c7b9a3ce@tarantool.org> (raw)
In-Reply-To: <6b860615-cd91-414a-3948-32600b69e05f@tarantool.org>

Thanks for the fixes! See my 3 comments below.

And I have pushed several review fix commits. Look at them
and squash.

> 
> 
>> box.cfg{}
>> opts = {checks = {{exp = 'X<5'}}}
>> format = {{name = 'X', type = 'unsigned'}}
>> t = {513, 1, 'test', 'memtx', 0, opts, format}
>> box.space._space:insert(t)

1. I do not see a test on it.
> 
>> 10. deleteTable leaks with the same reason: you delete space_def only when
>> opts.is_temporary flag is set. Including checks, that are on malloc.
>> 11. Why do you space->def->opts.checks here? I scanned sql_view_column_names,
>> and looks like it does not require compiled check. It needs only check names
>> and check span. Table.def has both, it is not?
>>> +	/*
>>> +	 * As rebuild creates a new ExpList tree and old_def
>>> +	 * is allocated on region release old tree manually.
>>> +	 */
>>> +	struct ExprList *old_checks = p->def->opts.checks;
>>>    	if (sql_table_def_rebuild(db, p) != 0)
>>>    		return;
> 
>>> +	/* Get server checks. */
>>> +	ExprList *checks = space_checks_expr_list(table->def->id);
>>
> We don't replicate checks in SQL. At the end of sqlite3EndTable checks are released and the only checks collection present on the server side.

2. Are you sure? I added assert(def->checks == NULL) in deleteTable() and it fails:

box.sql.execute("CREATE TABLE t1(x INTEGER CHECK( x<5 ), y REAL CHECK( y>x ), z primary key, invalid:parameter);")

Assertion failed: (pTable->def->opts.checks == NULL), function deleteTable, file /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/build.c, line 414.
Process 24676 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
     frame #0: 0x00007fff5eed8b6e libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff5eed8b6e <+10>: jae    0x7fff5eed8b78            ; <+20>
     0x7fff5eed8b70 <+12>: movq   %rax, %rdi
     0x7fff5eed8b73 <+15>: jmp    0x7fff5eecfb00            ; cerror_nocancel
     0x7fff5eed8b78 <+20>: retq

> I've wrote comments about this in  sqlite3EndTable:
> 
> /*
> * As rebuild creates a new ExpList tree and old_def
> * allocated on region release old tree manually.
> */
> /*
> * Checks are useless for now as all operations process with
>   * the server checks instance. Remove to do not consume extra memory,
>   * don't require make a copy on space_def_dup and to improve
>   * debuggability.
>   */
>>
>> 12. Please, write tests on checks insertion from Lua. I know such checks will
>> not work, but at least you should do sanity test. You should test, that a user
>> can insert a check with no name, that a check can be compiled even if no SQL
>> Table, that a check expr can not be number or bool and the same about name.
>> In the same tests you can check errors on non-existing column names.

3. One test is not enough. You did not test my example with 'exp' above, you did not test 'expr'
type mismatch, unexpected options in a check (expr + name + some unexpected one) etc.

  reply	other threads:[~2018-05-28 11:19 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 [this message]
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
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=ab54fc78-b9b8-c537-9885-2c96c7b9a3ce@tarantool.org \
    --to=v.shpilevoy@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