From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rhino.ch-server.com (rhino.ch-server.com [209.59.190.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1C13D469719 for ; Sun, 27 Sep 2020 23:56:29 +0300 (MSK) References: <66362762-8791-bea3-745f-afc1e3eaa199@tarantool.org> From: Peter Gulutzan Message-ID: <9a788a90-f558-fc6c-1d28-2813e8b721f8@ocelot.ca> Date: Sun, 27 Sep 2020 14:56:22 -0600 MIME-Version: 1.0 In-Reply-To: <66362762-8791-bea3-745f-afc1e3eaa199@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [Tarantool-discussions] SQL built-in functions position List-Id: Tarantool development process List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mergen Imeev , Vladislav Shpilevoy , Nikita Pettik , kyukhin@tarantool.org, tsafin@tarantool.org, sergos@tarantool.org Cc: tarantool-discussions@dev.tarantool.org Hi, On 2020-09-27 9:18 a.m., Mergen Imeev wrote: > Hi all. I have a question that I would like to discuss. > > The question is about SQL built-in functions. At the moment these functions are > partially described in _func and partially in src/box/sql/func.c. I received two > completely different suggestions from my reviewers on what to do with these > functions: > 1) Move definitions completely to _func. Remove definitions from func.c. > 2) Move definitions completely to func.c. Remove definitions from _func. > > In the first case, users will be able to see the function definitions. Also, in > the future, we may allow these functions to be called from Lua (although not > sure if this is necessary). The main idea is 'all functions have the same > interface'. > > In the second case, the implementation is simpler, and we can more easily > implement some features, such as "virtual" functions. For users, the definition > can only be seen in the documentation. The main idea is 'SQL built-in functions > are part of SQL'. > > Which of these approaches do you think is more beneficial to us? > I hope you will say _func. The current built-in functions are harmless, except perhaps for RANDOMBLOB with a huge value. However, in future maybe there will be built-in functions that should require privileges. In that case, I believe, they will have to be in _func (and someday in _vfunc) so that grant() will work for them. I have tried to redirect the UPPER() function in order to violate security, thus: " tarantool> function UPPER(x) return x end --- ... tarantool> box.schema.func.create('UPPER') --- - error: Function 'UPPER' already exists ... tarantool> box.schema.func.drop('UPPER') --- - error: 'Can''t drop function 1: function is SQL built-in' ... " This is good behaviour and I think it works because UPPER() is in _func. I did not document in the manual's SQL section that built-in functions will be in _func, so removing them is not a regression from documented behaviour. Also I acknowledge that they don't exist in MySQL/MariaDB information_schema.routines. But I think users benefit from being able to see them. Peter Gulutzan