Skip to content
Snippets Groups Projects
Commit 1c80ce2d authored by Mergen Imeev's avatar Mergen Imeev Committed by Vladimir Davydov
Browse files

sql: correctly calculate argument types

This patch fixes an issue where collation could change the computed
type of a built-in function argument when choosing a function
implementation.

Closes #7992

NO_DOC=bugfix
parent 60a2ee11
No related branches found
No related tags found
No related merge requests found
## bugfix/sql
* Collation no longer mangles the type of built-in function argument (gh-7992).
......@@ -2098,6 +2098,8 @@ find_compatible(struct Expr *expr, struct sql_func_dictionary *dict,
bool is_match = true;
for (int j = 0; j < n && is_match; ++j) {
struct Expr *e = expr->x.pList->a[j].pExpr;
while (e->op == TK_COLLATE)
e = e->pLeft;
enum field_type a = types[argc != -1 ? j : 0];
enum field_type b = sql_expr_type(e);
switch (check) {
......
local server = require('luatest.server')
local t = require('luatest')
local g = t.group()
g.before_all(function()
g.server = server:new({alias = 'gh_7992'})
g.server:start()
end)
g.after_all(function()
g.server:stop()
end)
g.test_ignore_collate_for_builtins = function()
g.server:exec(function()
local t = require('luatest')
local res = box.execute([[select abs(NULL collate "unicode_ci");]])
t.assert_equals(res.rows, {{box.NULL}})
end)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment