sql: introduce holder for prepared statemets
This patch introduces holder (as data structure) to handle prepared statements and a set of interface functions (insert, delete, find) to operate on it. Holder under the hood is implemented as a global hash (keys are values of hash function applied to the original string containing SQL query; values are pointer to wrappers around compiled VDBE objects) and GC queue. Each entry in hash has reference counter. When it reaches 0 value, entry is moved to GC queue. In case prepared statements holder is out of memory, it launches GC process: each entry in GC queue is deleted and all resources are released. Such approach allows to avoid workload spikes on session's disconnect (since on such event all statements must be deallocated). Each session is extended with local hash to map statement ids available for it. That is, session is allowed to execute and deallocate only statements which are previously prepared in scope of this session. On the other hand, global hash makes it possible to share same prepared statement object among different sessions. Size of cache is regulated via box.cfg{sql_cache_size} parameter. Part of #2592
Showing
- src/box/CMakeLists.txt 1 addition, 0 deletionssrc/box/CMakeLists.txt
- src/box/box.cc 26 additions, 0 deletionssrc/box/box.cc
- src/box/box.h 3 additions, 0 deletionssrc/box/box.h
- src/box/errcode.h 1 addition, 0 deletionssrc/box/errcode.h
- src/box/lua/cfg.cc 9 additions, 0 deletionssrc/box/lua/cfg.cc
- src/box/lua/load_cfg.lua 3 additions, 0 deletionssrc/box/lua/load_cfg.lua
- src/box/session.cc 35 additions, 0 deletionssrc/box/session.cc
- src/box/session.h 17 additions, 0 deletionssrc/box/session.h
- src/box/sql.c 3 additions, 0 deletionssrc/box/sql.c
- src/box/sql_stmt_cache.c 284 additions, 0 deletionssrc/box/sql_stmt_cache.c
- src/box/sql_stmt_cache.h 145 additions, 0 deletionssrc/box/sql_stmt_cache.h
- test/app-tap/init_script.result 19 additions, 18 deletionstest/app-tap/init_script.result
- test/box/admin.result 2 additions, 0 deletionstest/box/admin.result
- test/box/cfg.result 7 additions, 0 deletionstest/box/cfg.result
- test/box/cfg.test.lua 1 addition, 0 deletionstest/box/cfg.test.lua
- test/box/misc.result 1 addition, 0 deletionstest/box/misc.result
Loading
Please register or sign in to comment