From: Nikita Pettik <korablev@tarantool.org>
To: Roman Khabibov <roman.habibov@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v4 5/5] sql: support column addition
Date: Wed, 18 Nov 2020 16:15:19 +0000 [thread overview]
Message-ID: <20201118161519.GA23479@tarantool.org> (raw)
In-Reply-To: <8AFFA6D9-CCF7-4134-9018-0C6389542ADE@tarantool.org>
On 10 Nov 15:18, Roman Khabibov wrote:
> >> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> >> index fd8e7ed1e..597608bea 100644
> >> --- a/src/box/sql/build.c
> >> +++ b/src/box/sql/build.c
> >> @@ -285,48 +285,110 @@ sql_field_retrieve(Parse *parser, struct space_def *space_def, uint32_t id)
> >> return field;
> >> }
> >>
> >> +static struct space *
> >> +sql_shallow_space_copy(struct Parse *parse, struct space *space)
> >> +{
> >> + assert(space->def != NULL);
> >> + struct space *ret = sql_ephemeral_space_new(parse, space->def->name);
> >> + if (ret == NULL)
> >> + goto error;
> >> + ret->index_count = space->index_count;
> >> + ret->index_id_max = space->index_id_max;
> >> + size_t size = 0;
> >> + ret->index = region_alloc_array(&parse->region, typeof(struct index *),
> >> + ret->index_count, &size);
> >> + if (ret->index == NULL) {
> >> + diag_set(OutOfMemory, size, "region_alloc_array", "ret->index");
> >> + goto error;
> >> + }
> >
> >
> > You don't need all indexes from space..What you only need from space -
> > count of indexes (to generate name if it is required). The same for
> > field defs. Mb it is worth avoiding copying space at all - just
> > store in create_column_def list of ck/fk constraints, single
> > field_def, index/field count - these objects seem to be enough.
> > Please consider this suggestion.
> Yes, I understand that. But unfortunately, the current code, namely
> the functions for creating indexes, fk, and ck constraints, are written
> in such a way that they cannot be called without struct space (ephemeral
> or not). Vlad and I discussed this and came to the conclusion that it is
> better to go in the direction of reusing the code, rather than rewriting
> a significant part of build.c.
>
> https://lists.tarantool.org/pipermail/tarantool-patches/2020-July/018460.html
> https://lists.tarantool.org/pipermail/tarantool-patches/2020-August/019003.html
Oh, ok, I won't insist on this refactoring. But could you please
copy-paste referenced anwers from mailing list? Those letters quite
large so navigating through them takes a lot of time.
> >> + /*
> >> + * If it is an <ALTER TABLE ADD COLUMN>, then we have to
> >> + * create all indexes added by this statement. These
> >
> > AFAIK only one index (corresponding to unique constraint).
> I can write any number of named unique constraints. They should be
> created.
> ALTER TABLE t ADD COLUMN a INT CONSTRAINT c_1 UNIQUE, CONSTRAINT c_2 UNIQUE …
Well, ok. Just wondering why somebody might want to create several unique
constraints over the same field..
Otherwise LGTM
next prev parent reply other threads:[~2020-11-18 16:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 13:45 [Tarantool-patches] [PATCH v4 0/5] Support " Roman Khabibov
2020-10-09 13:45 ` [Tarantool-patches] [PATCH v4 1/5] sql: rename TK_COLUMN to TK_COLUMN_REF Roman Khabibov
2020-11-05 22:17 ` Nikita Pettik
2020-10-09 13:45 ` [Tarantool-patches] [PATCH v4 2/5] sql: refactor create_table_def and parse Roman Khabibov
2020-11-05 22:17 ` Nikita Pettik
2020-11-10 12:17 ` Roman Khabibov
2020-11-17 20:23 ` Nikita Pettik
2020-11-15 11:51 ` roman
2020-10-09 13:45 ` [Tarantool-patches] [PATCH v4 3/5] schema: add box_space_field_MAX Roman Khabibov
2020-11-05 22:18 ` Nikita Pettik
2020-10-09 13:45 ` [Tarantool-patches] [PATCH v4 4/5] sql: use parser's region of "index" array Roman Khabibov
2020-11-05 22:26 ` Nikita Pettik
2020-11-10 12:18 ` Roman Khabibov
2020-11-17 20:35 ` Nikita Pettik
[not found] ` <20201009134529.13212-6-roman.habibov@tarantool.org>
2020-11-06 15:57 ` [Tarantool-patches] [PATCH v4 5/5] sql: support column addition Nikita Pettik
2020-11-10 12:18 ` Roman Khabibov
2020-11-18 16:15 ` Nikita Pettik [this message]
2020-11-15 11:51 ` roman
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=20201118161519.GA23479@tarantool.org \
--to=korablev@tarantool.org \
--cc=roman.habibov@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v4 5/5] sql: support column addition' \
/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