[tarantool-patches] Re: [PATCH] sql: disallow to rename space if it is referenced by view
Konstantin Osipov
kostja at tarantool.org
Tue Dec 11 10:02:18 MSK 2018
* Nikita Pettik <korablev at tarantool.org> [18/12/09 20:53]:
> Before this patch it was allowed to rename space which is referenced by
> a view. In turn, view contains SELECT statement in a raw form (i.e. as a
> string) and it is not modified during renaming routine. Hence, after
> renaming space still has referencing counter > 0, but no usage of view
> is allowed (since execution of SELECT results in "Space does not
> exist"). To avoid such situations, lets ban renaming space if its view
> reference counter > 0.
>
> Note that RENAME is ANSI extension, so different DBs behave in this case
> in different ways - some of them allow to rename tables referenced by a
> view (PostgreSQL), others - don't (Oracle).
>
> Closes #3746
> ---
> Branch: https://github.com/tarantool/tarantool/tree/np/gh-3746-view-rename
> Issue: https://github.com/tarantool/tarantool/issues/3746
>
> src/box/alter.cc | 6 ++++++
> test/sql/view.result | 6 ++++++
> test/sql/view.test.lua | 3 +++
> 3 files changed, 15 insertions(+)
>
> diff --git a/src/box/alter.cc b/src/box/alter.cc
> index 029da029e..f3b267401 100644
> --- a/src/box/alter.cc
> +++ b/src/box/alter.cc
> @@ -1823,6 +1823,12 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event)
> space_name(old_space),
> "can not convert a space to "
> "a view and vice versa");
> + if (strcmp(def->name, old_space->def->name) != 0 &&
> + old_space->def->view_ref_count > 0)
> + tnt_raise(ClientError, ER_ALTER_SPACE,
> + space_name(old_space),
> + "can not rename space which is referenced by "
> + "view");
Please specify which view is referencing this space in the error
message.
--
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov
More information about the Tarantool-patches
mailing list