Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH 0/6] Introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PK
@ 2019-01-09 12:13 Nikita Pettik
  2019-01-09 12:13 ` [tarantool-patches] [PATCH 1/6] sql: move constraint name to struct contraint_parse Nikita Pettik
                   ` (5 more replies)
  0 siblings, 6 replies; 24+ messages in thread
From: Nikita Pettik @ 2019-01-09 12:13 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2019-01-18  1:42 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09 12:13 [tarantool-patches] [PATCH 0/6] Introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PK Nikita Pettik
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox