[tarantool-patches] Re: [PATCH v1 1/1] sql: make assertion to check only ephemeral spaces

n.pettik korablev at tarantool.org
Sat May 25 16:48:36 MSK 2019


> 
> From 16309a0e955f32a866585eb71e429080f716d7bf Mon Sep 17 00:00:00 2001
> From: Mergen Imeev <imeevma at gmail.com>
> Date: Fri, 17 May 2019 17:56:56 +0300
> Subject: [PATCH] sql: do not set is_temporary for ephemeral spaces
> 
> Up to this point, the is_temporary flag has been set in all
> ephemeral spaces.
> 
> At some point, it became possible to use spaces created in Lua in
> SQL statements. Since it is allowed to create temporary spaces in
> Lua, not all temporary spaces in SQL are ephemeral. To separate
> the temporary and ephemeral spaces, is_ephemeral flag is now set
> in the ephemeral spaces and is_temporary flag is not set.
> 
> Close #4139

You slightly misunderstood my initial intention. There are two
kinds of what we call ephemeral spaces: first ones are real
ephemeral spaces which are created during VDBE runtime
to hold materialised intermediate results of query execution.
They are destroyed when query is finished. Second type 
consists of surrogate defs allocated using region and they
are used to keep meta-information during compilation of
DML queries. They are not real space object and I have
no idea why we call them ‘ephemeral’, I guess it is a big mess.
A while ago, we had to use some marked for such surrogate
spaces to process special clean-up operations. And it was
decided that we would use ‘is_temporary’ flag.

I’ve force pushed my updates (commit message + code fixes).

Message:

    sql: replace is_temprorary with is_ephemeral for surrogate defs
    
    Up to this point, the is_temporary flag has been set for surrogate space
    definitions used to transfer meta-information during compilation stage
    of DML queries (CREATE TABLE/INDEX etc).
    
    At some point, it became possible to use spaces created in Lua in
    SQL statements. Since it is allowed to create temporary spaces in
    Lua, not all temporary spaces in SQL are surrogate wrappers. To separate
    real temporary spaces (i.e. which came from space cache) from surrogate
    ones, is_ephemeral flag is now set in such spaces instead of
    is_temporary. Note that there can't be mess between these flags since
    ephemeral spaces can exist only during execution of VDBE bytecode.
    Also note that flag is required only for debugging facilities.
    
    Close #4139

Diff:

diff --git a/src/box/space.c b/src/box/space.c
index 6380a0af3..243e7da2f 100644
--- a/src/box/space.c
+++ b/src/box/space.c
@@ -194,6 +194,7 @@ space_new(struct space_def *def, struct rlist *key_list)
 struct space *
 space_new_ephemeral(struct space_def *def, struct rlist *key_list)
 {
+       assert(def->opts.is_temporary);
        assert(def->opts.is_ephemeral);
        struct space *space = space_new(def, key_list);
        if (space == NULL)
diff --git a/src/box/space_def.c b/src/box/space_def.c
index 0b9cc015c..d825def75 100644
--- a/src/box/space_def.c
+++ b/src/box/space_def.c
@@ -263,6 +263,7 @@ struct space_def*
 space_def_new_ephemeral(uint32_t field_count)
 {
        struct space_opts opts = space_opts_default;
+       opts.is_temporary = true;
        opts.is_ephemeral = true;
        struct space_def *space_def = space_def_new(0, 0, field_count,
                                                    "ephemeral",
diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c
index b5d55b2e4..9cdeb051b 100644
--- a/src/box/tuple_format.c
+++ b/src/box/tuple_format.c
@@ -711,6 +711,7 @@ tuple_format_reuse(struct tuple_format **p_format)
         * Make sure they're unset.
         */
        assert(format->dict->name_count == 0);
+       assert(format->is_temporary);
        mh_int_t key = mh_tuple_format_find(tuple_formats_hash, format,
                                            NULL);
        if (key != mh_end(tuple_formats_hash)) {
@@ -736,6 +737,7 @@ tuple_format_add_to_hash(struct tuple_format *format)
        if(!format->is_ephemeral)
                return 0;
        assert(format->dict->name_count == 0);
+       assert(format->is_temporary);
        mh_int_t key = mh_tuple_format_put(tuple_formats_hash,
                                           (const struct tuple_format **)&format,
                                           NULL, NULL);





More information about the Tarantool-patches mailing list