Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, "n.pettik" <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 9/9] sql: run check constraint tests on space alter
Date: Tue, 16 Apr 2019 16:51:13 +0300	[thread overview]
Message-ID: <036f8814-67a1-916c-7935-32e50fa14b07@tarantool.org> (raw)
In-Reply-To: <121C5F34-691B-4FCC-A1C9-C995683D4A6A@tarantool.org>

> Mention that format is required condition to use check
> constraints: otherwise, name of field can’t be resolved.
> Now it leads to assertion fault:
> 
> s = box.schema.create_space('test’)
> s:create_index('pk’)
> box.space._ck_constraint:insert({'physics', s.id, 'X<Y’})
> Assertion failed: (space_def->field_count > 0), function lookupName, file tarantool/src/box/sql/resolve.c, line 242.
Thank you. Fixed it in previous patch.

> 
>> box.space._ck_constraint:insert({'physics', s.id, 'X<Y'})
>> box.space.test:insert({6, 5})
>> - error: 'Check constraint failed: physics’
> 
> To finish this patch-set I suggest to add Lua-wrapper to create
> check constraints on any space using NoSQL interface and introduce
> ALTER TABLE ADD CONSTRAINT CHECK().
> Last issue you can implement in a separate patch or delegate its
> implementation to smb else.
Consider my new commit.

>> +	vdbe_emit_ck_constraint(&parser, expr, ck_constraint->def->name,
>> +				new_tuple_reg);
>> +	sql_finish_coding(&parser);
> 
> Do we need to call this function at all?
Yes. I've tried to drop it.

> 
>> +	if (parser.is_aborted) {
>> +		diag_set(ClientError, ER_CREATE_CK_CONSTRAINT,
>> +			 ck_constraint->def->name,
>> +			 "can not compile expression”);
> 
> This error will re-set original parsing error. I suggest to
> concatenate them.
Done.


>> +	sql_reset(ck_constraint->stmt);
> 
> This function returns error code, don’t ignore it.
Now I use it's result to determine execution state at the end of trigger.

>> +	parser->ckBase = new_tuple_reg;
>> +	struct Vdbe *v = sqlGetVdbe(parser);
>> +	const char *ck_constraint_name = sqlDbStrDup(parser->db, name);
> 
> Where's this pointer released?
> 
>> +	VdbeNoopComment((v, "BEGIN: ck constraint %s test", name));
>> +	/* Skip check when it is turned off. */
Now this string is a part of VdbeNoopComment so VDBE must release it.
> When it can be turned off?
Outdated comment.

> Please, add descent set of tests verifying that check constraints
> work in any possible scenario.
> Make sure that check occurs before replace action.

Many new good tests are the part of previous patch now.

      reply	other threads:[~2019-04-16 13:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  8:59 [tarantool-patches] [PATCH v2 0/9] sql: Checks on server side Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 1/9] box: fix upgrade script for _fk_constraint space Kirill Shcherbatov
2019-03-11 18:44   ` [tarantool-patches] " n.pettik
2019-03-13 11:36   ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 2/9] box: fix _trigger and _ck_constraint access check Kirill Shcherbatov
2019-03-11 19:29   ` [tarantool-patches] " n.pettik
2019-03-22  9:29     ` Vladislav Shpilevoy
2019-03-26 10:59     ` Kirill Shcherbatov
2019-04-01 14:06       ` n.pettik
2019-03-13 11:38   ` Kirill Yukhin
2019-03-13 11:44     ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 3/9] box: fix Tarantool upgrade from 2.1.0 to 2.1.1 Kirill Shcherbatov
2019-03-12 11:45   ` [tarantool-patches] " n.pettik
2019-03-20 15:12     ` n.pettik
2019-03-20 15:38       ` Kirill Shcherbatov
2019-03-21 15:23         ` n.pettik
2019-03-21 15:36           ` Vladislav Shpilevoy
2019-03-22  9:28         ` Vladislav Shpilevoy
2019-03-22 10:18           ` Kirill Shcherbatov
2019-03-22 10:21             ` Vladislav Shpilevoy
2019-03-26  9:52   ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 4/9] box: fix on_replace_trigger_rollback routine Kirill Shcherbatov
2019-03-11 20:00   ` [tarantool-patches] " n.pettik
2019-03-13 11:39   ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 5/9] schema: add new system space for CHECK constraints Kirill Shcherbatov
2019-03-22  9:29   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-22  9:52     ` n.pettik
2019-03-26 10:59     ` Kirill Shcherbatov
2019-04-01 19:45       ` n.pettik
2019-04-16 13:51         ` Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 6/9] sql: disallow use of TYPEOF in Check Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-04-01 19:52     ` n.pettik
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 7/9] sql: refactor sqlite3_reset routine Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 8/9] box: exported sql_bind structure and API Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 9/9] sql: run check constraint tests on space alter Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-04-02 14:14     ` n.pettik
2019-04-16 13:51       ` Kirill Shcherbatov [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=036f8814-67a1-916c-7935-32e50fa14b07@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 9/9] sql: run check constraint tests on space alter' \
    /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