Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: imeevma@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v1 00/10] Check types of SQL built-in functions arguments
Date: Thu, 19 Aug 2021 14:49:55 +0300	[thread overview]
Message-ID: <20210819114955.lf3nzcbwi3vxpd34@esperanza> (raw)
In-Reply-To: <cover.1628824421.git.imeevma@gmail.com>

Since moving the function matching to the parser didn't work out
(because this would turn builtin function names, such as 'count', into
reserved keywords, forcing the user to quote them), I think we should
stick with this approach.

LGTM, but I think the function hash is messy:

 - I don't like the two-level structure of the builtin function hash:
   name -> sql_func_dictionary with array of func_sql_builtin, one
           array entry per argument set

   because all builtin functions share the same implementation and this
   is probably never going to change:

	{"MAX", 1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_INTEGER, minmaxStep,
	 minMaxFinalize},
	{"MAX", 1, {FIELD_TYPE_DOUBLE}, FIELD_TYPE_DOUBLE, minmaxStep,
	 minMaxFinalize},
	{"MAX", 1, {FIELD_TYPE_NUMBER}, FIELD_TYPE_NUMBER, minmaxStep,
	 minMaxFinalize},
	{"MAX", 1, {FIELD_TYPE_VARBINARY}, FIELD_TYPE_VARBINARY, minmaxStep,
	 minMaxFinalize},
	{"MAX", 1, {FIELD_TYPE_UUID}, FIELD_TYPE_UUID, minmaxStep,
	 minMaxFinalize},
	{"MAX", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_STRING, minmaxStep,
	 minMaxFinalize},
	{"MAX", 1, {FIELD_TYPE_SCALAR}, FIELD_TYPE_SCALAR, minmaxStep,
	 minMaxFinalize},

   I think we'd better have a separate hash:
   name -> builtin func

   The builtin func struct should contain a list or accepted argumented
   and the corresponding return value. Or maybe a callback, which would
   take arguments from an SQL expression list and return the expected
   return value and argument types. This could be more efficient,
   because we wouldn't have to scan the list of arguments on resolve.

 - Builtin funcs shouldn't refer to struct func or func_def, because
   they don't use any information from those structures (permissions,
   id, is_sandboxed, etc).

We should consider reworking the implementation accordingly in the
future.

      parent reply	other threads:[~2021-08-19 11:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  3:17 Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 01/10] sql: modify signature of TRIM() Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 02/10] sql: rework SQL built-in functions hash table Mergen Imeev via Tarantool-patches
2021-08-16 13:53   ` Vladimir Davydov via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 03/10] sql: check number of arguments during parsing Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 04/10] sql: static type check for SQL built-in functions Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 05/10] sql: runtime " Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 06/10] sql: enable types checking for some functions Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 07/10] sql: fix result type of min() and max() functions Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 08/10] sql: check argument types of sum(), avg(), total() Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 09/10] sql: fix quote() function Mergen Imeev via Tarantool-patches
2021-08-13  3:17 ` [Tarantool-patches] [PATCH v1 10/10] sql: arguments check for string value functions Mergen Imeev via Tarantool-patches
2021-08-19 11:49 ` Vladimir Davydov via Tarantool-patches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210819114955.lf3nzcbwi3vxpd34@esperanza \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=vdavydov@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1 00/10] Check types of SQL built-in functions arguments' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox