From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id A95DB2EA27 for ; Sat, 25 May 2019 09:48:40 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rMcsA0fVc_F0 for ; Sat, 25 May 2019 09:48:40 -0400 (EDT) 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 turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id E41002E665 for ; Sat, 25 May 2019 09:48:39 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: make assertion to check only ephemeral spaces From: "n.pettik" In-Reply-To: <20190521150622.GA15451@tarantool.org> Date: Sat, 25 May 2019 16:48:36 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <91C455A6-F115-4C63-B28C-C484A38BE5F8@tarantool.org> References: <20190521150622.GA15451@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Imeev Mergen >=20 > =46rom 16309a0e955f32a866585eb71e429080f716d7bf Mon Sep 17 00:00:00 = 2001 > From: Mergen Imeev > Date: Fri, 17 May 2019 17:56:56 +0300 > Subject: [PATCH] sql: do not set is_temporary for ephemeral spaces >=20 > Up to this point, the is_temporary flag has been set in all > ephemeral spaces. >=20 > 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. >=20 > 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=20 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 =E2=80=98ephemeral=E2=80=99, 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 =E2=80=98is_temporary=E2=80=99 flag. I=E2=80=99ve force pushed my updates (commit message + code fixes). Message: sql: replace is_temprorary with is_ephemeral for surrogate defs =20 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). =20 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. =20 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 =3D space_new(def, key_list); if (space =3D=3D 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 =3D space_opts_default; + opts.is_temporary =3D true; opts.is_ephemeral =3D true; struct space_def *space_def =3D 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 =3D=3D 0); + assert(format->is_temporary); mh_int_t key =3D mh_tuple_format_find(tuple_formats_hash, = format, NULL); if (key !=3D 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 =3D=3D 0); + assert(format->is_temporary); mh_int_t key =3D mh_tuple_format_put(tuple_formats_hash, (const struct tuple_format = **)&format, NULL, NULL);