From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 0/6] Introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PK Date: Wed, 9 Jan 2019 14:13:14 +0200 [thread overview] Message-ID: <cover.1547035183.git.korablev@tarantool.org> (raw) Branch: https://github.com/tarantool/tarantool/tree/np/gh-3914-fix-create-index Issues: https://github.com/tarantool/tarantool/issues/3097 https://github.com/tarantool/tarantool/issues/3914 It turns out that if space is created from Lua and has no indexes, simply CREATE INDEX statement executed from SQL will raise strange error "Wrong space id". It appears due to fetch of new index id from _index space. However, in case it containts no entries with given space id it doesn't really mean that there is no space with given id. It only implies that space with given id lacks any indexes. This issue is resovled by using correct error message. However, we still need way to primary key on already existing table. Hence, lets introduce ALTER TABLE ADD CONSTRAINT PRIMARY KEY, which would create index with id == 0. Note that CREATE INDEX is not suitable for creating PK owing to the following scenario: Create table with no indexes Create index (it implicitly becomes PK since it is the first index) Create constraint PK (fails since index with id == 0 already exists) Indexes are out of ANSI specification, so example above must not fail (all vendors I've checked don't fail). Nikita Pettik (6): sql: move constraint name to struct contraint_parse sql: rework ALTER TABLE grammar sql: remove start token from sql_create_index args sql: refactor getNewIid() function sql: fix error message for improperly created index sql: introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PRIMARY KEY src/box/sql/alter.c | 4 +- src/box/sql/build.c | 141 +++++++++++++++++++++++++------------------ src/box/sql/parse.y | 76 ++++++++++++++++------- src/box/sql/prepare.c | 11 ++++ src/box/sql/sqliteInt.h | 37 ++++++------ test/sql-tap/alter.test.lua | 58 +++++++++++++++++- test/sql-tap/index1.test.lua | 28 ++++++++- 7 files changed, 254 insertions(+), 101 deletions(-) -- 2.15.1
next reply other threads:[~2019-01-09 12:13 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-09 12:13 Nikita Pettik [this message] 2019-01-09 12:13 ` [tarantool-patches] [PATCH 1/6] sql: move constraint name to struct contraint_parse Nikita Pettik 2019-01-14 14:04 ` [tarantool-patches] " Vladislav Shpilevoy 2019-01-16 20:06 ` n.pettik 2019-01-16 20:54 ` Vladislav Shpilevoy 2019-01-17 10:56 ` Konstantin Osipov 2019-01-17 17:14 ` n.pettik 2019-01-09 12:13 ` [tarantool-patches] [PATCH 2/6] sql: rework ALTER TABLE grammar Nikita Pettik 2019-01-14 14:05 ` [tarantool-patches] " Vladislav Shpilevoy 2019-01-16 20:06 ` n.pettik 2019-01-16 20:54 ` Vladislav Shpilevoy 2019-01-17 11:51 ` Konstantin Osipov 2019-01-17 17:14 ` n.pettik 2019-01-18 1:42 ` Konstantin Osipov 2019-01-09 12:13 ` [tarantool-patches] [PATCH 3/6] sql: remove start token from sql_create_index args Nikita Pettik 2019-01-09 12:13 ` [tarantool-patches] [PATCH 4/6] sql: refactor getNewIid() function Nikita Pettik 2019-01-14 14:05 ` [tarantool-patches] " Vladislav Shpilevoy 2019-01-09 12:13 ` [tarantool-patches] [PATCH 5/6] sql: fix error message for improperly created index Nikita Pettik 2019-01-14 14:06 ` [tarantool-patches] " Vladislav Shpilevoy 2019-01-16 20:06 ` n.pettik 2019-01-09 12:13 ` [tarantool-patches] [PATCH 6/6] sql: introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PRIMARY KEY Nikita Pettik 2019-01-14 14:06 ` [tarantool-patches] " Vladislav Shpilevoy 2019-01-16 20:06 ` n.pettik 2019-01-16 20:54 ` Vladislav Shpilevoy
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=cover.1547035183.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 0/6] Introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PK' \ /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