sql: rename instr to position & add collation usage
Before this patch we had instr() SQL function. After the patch it is renamed to position() for a better ANSI compatibility. Also a few things have been changed: arguments order, allowed arguments types and usage of collations. Note: after the patch position() syntax is still different from ANSI. The desirable syntax is POSITION(substring IN string). It is not possible to implement right now, because in our SQL grammar we lack expr types. We have only basic 'expr' type and it is not possible to write unambiguous rule for POSITION IN. To solve this we have to refactor grammar and add something like 'string_expr' (as it is done in other DBs grammars) Workaround for #3933 @TarantoolBot document Title: instr() is replaced with position() Name and order of the arguments has changed for a better ANSI compatibility: Before: instr(haystack, needle). After: position(needle, haystack). Type checking became more strict: before it was possible to call the function with INTEGER arguments or with arguments of different types. Now both arguments must have the same type and be either text or binary strings. Before the patch collations were not taken into consideration during the search. Now it is fixed, and both implicit (column) collations and explicit (using COLLATE expression) are used. Single collation which would be used in function is determined using ANSI “Type combination” rules.
Showing
- src/box/sql/func.c 126 additions, 46 deletionssrc/box/sql/func.c
- test/sql-tap/func.test.lua 5 additions, 5 deletionstest/sql-tap/func.test.lua
- test/sql-tap/func5.test.lua 2 additions, 2 deletionstest/sql-tap/func5.test.lua
- test/sql-tap/instr.test.lua 0 additions, 706 deletionstest/sql-tap/instr.test.lua
- test/sql-tap/position.test.lua 861 additions, 0 deletionstest/sql-tap/position.test.lua
- test/sql-tap/with1.test.lua 2 additions, 2 deletionstest/sql-tap/with1.test.lua
Loading
Please register or sign in to comment