sql: make GREATEST/LEAST built-ins accept at least two args
Before a46b5200 SQL implementation featured min()/max() functions overloading: if one argument was passed, then aggregate version would be invoked; otherwise - scalar one. We decided to get rid of it and rename scalar version to LEAST()/GREATEST() correspondingly. However, assertion inside their implementations has been remained: it verifies that number of passed arguments is greater than 1. On the other hand, now one can pass literally any number of arguments to this function, including one (which results in fired mentioned assertion) and zero (which leads to NULL dereference in expr.c: these functions are marked with SQL_FUNC_NEEDCOLL flag, and as a consequence they are assumed to have at least one argument). Firstly, let's place check that number of passed arguments more than one. Secondly, let's not assume that functions with SQL_FUNC_NEEDCOLL must have any arguments. Closes #4453
Showing
- src/box/errcode.h 1 addition, 0 deletionssrc/box/errcode.h
- src/box/sql/expr.c 2 additions, 1 deletionsrc/box/sql/expr.c
- src/box/sql/func.c 6 additions, 1 deletionsrc/box/sql/func.c
- test/box/misc.result 1 addition, 0 deletionstest/box/misc.result
- test/sql-tap/func5.test.lua 22 additions, 1 deletiontest/sql-tap/func5.test.lua
Loading
Please register or sign in to comment