sql: introduce structs assembling DDL arguments during parsing
Parser's rules implementing DDL have a lot in common. For instance, to drop any entity it is enough to know its name and name of table it is related to. Thus, it was suggested to arrange arguments of DDL rules into hierarchical structure. The root of chain always includes name of table to be altered: all existing entities are related to some table. Then comes one of drop/create/rename rules. Indeed, each DDL operation can be classified in these terms, at least until we introduce ALTER TABLE ALTER CONSTRAINT statement. Drop is represented by single structure (as it was mentioned); rename can be applied only to table; create can be applied to CONSTRAINT (indexes are considered as constraints) and TRIGGER, which in turn are different in arguments required to create those objects. And so forth. What is more, we are going to introduce ALTER TABLE ADD CONSTRAINT UNIQUE With new hierarchy we can extend ALTER TABLE statement with ease: basic structures (alter -> create entity -> create constraint) are the same for .. FOREIGN KEY/UNIQUE, but the last one will be different. Finally, during refactoring we've managed to rework syntax for named constraint, so that now only real constraints (i.e. UNIQUE, PRIMARY KEY, CHECK and FOREIGN KEY) can have names; others column attributes like DEFAULT or COLLATE can't. Needed for #3097 Closes #3820
Showing
- src/box/sql/CMakeLists.txt 1 addition, 0 deletionssrc/box/sql/CMakeLists.txt
- src/box/sql/alter.c 6 additions, 3 deletionssrc/box/sql/alter.c
- src/box/sql/build.c 168 additions, 139 deletionssrc/box/sql/build.c
- src/box/sql/global.c 0 additions, 8 deletionssrc/box/sql/global.c
- src/box/sql/parse.y 86 additions, 45 deletionssrc/box/sql/parse.y
- src/box/sql/parse_def.c 45 additions, 0 deletionssrc/box/sql/parse_def.c
- src/box/sql/parse_def.h 464 additions, 0 deletionssrc/box/sql/parse_def.h
- src/box/sql/prepare.c 1 addition, 4 deletionssrc/box/sql/prepare.c
- src/box/sql/resolve.c 2 additions, 2 deletionssrc/box/sql/resolve.c
- src/box/sql/sqlInt.h 38 additions, 141 deletionssrc/box/sql/sqlInt.h
- src/box/sql/tokenize.c 3 additions, 2 deletionssrc/box/sql/tokenize.c
- src/box/sql/trigger.c 31 additions, 27 deletionssrc/box/sql/trigger.c
- src/box/sql/util.c 0 additions, 10 deletionssrc/box/sql/util.c
- test/sql-tap/index7.test.lua 1 addition, 1 deletiontest/sql-tap/index7.test.lua
- test/sql/misc.result 16 additions, 0 deletionstest/sql/misc.result
- test/sql/misc.test.lua 6 additions, 0 deletionstest/sql/misc.test.lua
Loading
Please register or sign in to comment