From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 AB859445320 for ; Mon, 27 Jul 2020 15:24:32 +0300 (MSK) Date: Mon, 27 Jul 2020 15:24:29 +0300 From: Mergen Imeev Message-ID: <20200727122429.GA49280@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Subject: [Tarantool-discussions] The result type and argument types of the built-in SQL functions. List-Id: Tarantool development process List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pgulutzan@ocelot.ca, korablev@tarantool.org, v.shpilevoy@tarantool.org, tsafin@tarantool.org, sergos@tarantool.org, tarantool-discussions@dev.tarantool.org Hi, Peter! I would like to ask you a few questions about the result type and argument types of the SQL built-in functions. I suggest changing the result types of some functions. A table with the current result type and the suggested result type is below. FUNCTION NAME CURRENT SUGGESTED abs number number avg number double char string string character_length integer unsigned char_length integer unsigned coalesce scalar scalar count integer unsigned greatest scalar scalar group_concat string string hex string string ifnull integer scalar least scalar scalar length integer unsigned like integer boolean likelihood boolean scalar likely boolean scalar lower string string max scalar scalar min scalar scalar nullif scalar scalar position integer unsigned printf string string quote string string random integer integer randomblob varbinary varbinary replace string string round integer number row_count integer unsigned soundex string string substr string string sum number number total number double trim string string typeof string string unicode string unsigned unlikely boolean scalar upper string string version string string zeroblob varbinary varbinary The second question is about the types of arguments to built-in functions. I suggest this: FUNCTION NAME TYPES OF ARGUMENTS abs number avg number char* unsigned character_length string char_length string coalesce scalar count scalar greatest scalar group_concat scalar, scalar hex scalar ifnull scalar, scalar least* scalar length string like string, string, string likelihood scalar, double likely scalar lower string max scalar min scalar nullif scalar, scalar position string, string printf* scalar quote scalar randomblob unsigned replace string, string, string round double, unsigned soundex string substr string, integer, integer sum number total number trim* string typeof scalar unicode string unlikely scalar upper string zeroblob unsigned * - all arguments must be of this type. Also, we have to decide on BLOB instead of STRING. Last time you wrote that we should allow BLOB instead of STRING, but I think it will be rather inconvenient, because in this case we have to write SCALAR instead of STRING in function definition and check the type of the argument inside the function. Because of this, it will be a little incompatible with the definition of a function that will be placed in the '_func' system space. I mean, the definition will state that it accepts SCALAR, but in reality it will only accept STRING and BLOB. So, I think we should disallow BLOB instead of STRING, or decide in which functions we allow BLOB instead of STRING. And one more question. I think we are going to add MAP and ARRAY types in SQL in the near future, so it might be a good idea to write ANY instead of SCALAR for some of these functions. What do you think about this?