Tarantool development patches archive
 help / color / mirror / Atom feed
From: Konstantin Osipov <kostja@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org, korablev@tarantool.org
Subject: [tarantool-patches] Re: [PATCH v2 09/12] box: introduce Lua persistent functions
Date: Wed, 10 Jul 2019 22:26:38 +0300	[thread overview]
Message-ID: <20190710192638.GK5619@atlas> (raw)
In-Reply-To: <2f63c2c9773c448399d5b8fac08e282dabf57619.1562756438.git.kshcherbatov@tarantool.org>

* Kirill Shcherbatov <kshcherbatov@tarantool.org> [19/07/10 14:02]:
> diff --git a/src/box/func.c b/src/box/func.c
> index 8227527ec..8d93a83b2 100644
> --- a/src/box/func.c
> +++ b/src/box/func.c
> @@ -34,7 +34,9 @@
>  #include "assoc.h"
>  #include "lua/utils.h"
>  #include "lua/call.h"
> +#include "lua/lua_sql.h"
>  #include "error.h"
> +#include "sql.h"

Why do you need these includes? Please watch for unnecessary
includes when you do a self-review.

>  #include "diag.h"
>  #include "port.h"
>  #include "schema.h"
> @@ -385,11 +387,18 @@ struct func *
>  func_new(struct func_def *def)
>  {
>  	struct func *func;
> -	if (def->language == FUNC_LANGUAGE_C) {
> +	switch (def->language) {
> +	case FUNC_LANGUAGE_C:
>  		func = func_c_new(def);
> -	} else {
> -		assert(def->language == FUNC_LANGUAGE_LUA);
> +		break;
> +	case FUNC_LANGUAGE_LUA:
>  		func = func_lua_new(def);
> +		break;
> +	case FUNC_LANGUAGE_SQL_BUILTIN:
> +		func = func_sql_builtin_new(def);
> +		break;
> +	default:
> +		unreachable();
>  	}
>  	if (func == NULL)
>  		return NULL;
> @@ -416,8 +425,13 @@ static struct func_vtab func_c_vtab;
>  static struct func *
>  func_c_new(struct func_def *def)
>  {
> -	(void) def;
>  	assert(def->language == FUNC_LANGUAGE_C);
> +	if (def->body != NULL || def->is_sandboxed) {
> +		diag_set(ClientError, ER_CREATE_FUNCTION, def->name,
> +			 "body and is_sandboxed options are not compatible "
> +			 "with C language");
> +		return NULL;
> +	}
>  	struct func_c *func = (struct func_c *) malloc(sizeof(struct func_c));
>  	if (func == NULL) {
>  		diag_set(OutOfMemory, sizeof(*func), "malloc", "func");
> diff --git a/src/box/func_def.c b/src/box/func_def.c
> index 2b135e2d7..fb9f77df8 100644
> --- a/src/box/func_def.c
> +++ b/src/box/func_def.c
> +static int
> +func_persistent_lua_load(struct func_lua *func)
> +{
> +	int rc = -1;
> +	int top = lua_gettop(tarantool_L);
> +	struct region *region = &fiber()->gc;
> +	size_t region_svp = region_used(region);
> +	const char *load_pref = "return ";

load_prefix, pref is ambiguous

The patch is LGTM. I would take another couple of hours to review
it carefully and tidy up - including the comments. 
Unfortunately I don't have them the moment. I hope Vova can take
the patch from here.

-- 
Konstantin Osipov, Moscow, Russia

  reply	other threads:[~2019-07-10 19:26 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10 11:00 [tarantool-patches] [PATCH v2 00/12] sql: uniform SQL and Lua functions subsystem Kirill Shcherbatov
2019-07-10 11:00 ` [tarantool-patches] [PATCH v2 01/12] sql: get rid of SOUNDEX, MATCH Kirill Shcherbatov
2019-07-10 18:45   ` [tarantool-patches] " Konstantin Osipov
2019-07-12  8:44   ` Kirill Yukhin
2019-07-10 11:00 ` [tarantool-patches] [PATCH v2 10/12] sql: refactor builtins signatures with port Kirill Shcherbatov
2019-07-10 18:47   ` [tarantool-patches] " Konstantin Osipov
2019-07-11  7:33     ` Kirill Shcherbatov
2019-07-10 11:00 ` [tarantool-patches] [PATCH v2 11/12] box: use own vtab per each function object Kirill Shcherbatov
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 12/12] sql: use schema's func hash instead of FuncDef hash Kirill Shcherbatov
2019-07-10 20:22   ` [tarantool-patches] " Konstantin Osipov
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 02/12] sql: get rid of LIKELY, UNLIKELY and LIKEHOOD Kirill Shcherbatov
2019-07-10 19:02   ` [tarantool-patches] " Konstantin Osipov
2019-07-11  7:38     ` Kirill Shcherbatov
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 03/12] sql: put analyze helpers to FuncDef cache Kirill Shcherbatov
2019-07-10 19:04   ` [tarantool-patches] " Konstantin Osipov
2019-07-12  8:47   ` Kirill Yukhin
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 04/12] sql: rework LIKE case-insensitive mode Kirill Shcherbatov
2019-07-10 19:09   ` [tarantool-patches] " Konstantin Osipov
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 05/12] sql: replace bool is_derived_coll marker with flag Kirill Shcherbatov
2019-07-10 19:10   ` [tarantool-patches] " Konstantin Osipov
2019-07-12  8:48   ` Kirill Yukhin
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 06/12] sql: remove SQL_PreferBuiltin flag Kirill Shcherbatov
2019-07-10 19:11   ` [tarantool-patches] " Konstantin Osipov
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 07/12] sql: move LIKE UConverter object to collation library Kirill Shcherbatov
2019-07-12  8:49   ` [tarantool-patches] " Kirill Yukhin
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 08/12] sql: rfc for SQL and Lua functions Kirill Shcherbatov
2019-07-10 19:17   ` [tarantool-patches] " Konstantin Osipov
2019-07-10 19:18     ` Konstantin Osipov
2019-07-11  7:40       ` Kirill Shcherbatov
2019-07-11 13:59   ` Kirill Yukhin
2019-07-10 11:01 ` [tarantool-patches] [PATCH v2 09/12] box: introduce Lua persistent functions Kirill Shcherbatov
2019-07-10 19:26   ` Konstantin Osipov [this message]
2019-07-12 21:49   ` [tarantool-patches] " Konstantin Osipov
2019-07-13 13:55     ` Kirill Yukhin
2019-07-13 14:17       ` Kirill Yukhin

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=20190710192638.GK5619@atlas \
    --to=kostja@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 09/12] box: introduce Lua persistent functions' \
    /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