From: Nikita Pettik <korablev@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 5/6] sql: extend result set with autoincrement Date: Tue, 24 Dec 2019 03:26:21 +0300 [thread overview] Message-ID: <20191224002621.GA31231@tarantool.org> (raw) In-Reply-To: <33e3b5df-45c3-83ff-3d0b-cbc1af6a1bae@tarantool.org> On 18 Dec 01:29, Vladislav Shpilevoy wrote: > Thanks for the patch! > > See 3 comments below. > > On 11/12/2019 14:44, Nikita Pettik wrote: > > If result set contains column which features attached sequence > > (AUTOINCREMENT in terms of SQL) then meta-information will contain > > corresponding field ('is_autoicrement' : boolean) in response. > > > > Part of #4407 > > --- > > diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c > > index 644b373c9..88ef4ff78 100644 > > --- a/src/box/lua/net_box.c > > +++ b/src/box/lua/net_box.c > > @@ -651,11 +651,15 @@ decode_metadata_optional(struct lua_State *L, const char **data, > > const char *coll = mp_decode_str(data, &len); > > lua_pushlstring(L, coll, len); > > lua_setfield(L, -2, "collation"); > > - } else { > > - assert(key == IPROTO_FIELD_IS_NULLABLE); > > + } else if (key == IPROTO_FIELD_IS_NULLABLE) { > > bool is_nullable = mp_decode_bool(data); > > lua_pushboolean(L, is_nullable); > > lua_setfield(L, -2, "is_nullable"); > > + } else { > > + assert(key == IPROTO_FIELD_IS_AUTOINCREMENT); > > + bool autoincrement = mp_decode_bool(data); > > 1. autoincrement -> is_autoincrement. Fixed. > > diff --git a/src/box/sql/select.c b/src/box/sql/select.c > > index 73ce95eba..d92da4d8e 100644 > > --- a/src/box/sql/select.c > > +++ b/src/box/sql/select.c > > @@ -1845,6 +1845,12 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList, > > space_def->fields[iCol].is_nullable; > > vdbe_metadata_set_col_nullability(v, i, > > is_nullable); > > + if (pTabList->a[j].space->sequence != NULL) { > > + int afno = > > + pTabList->a[j].space->sequence_fieldno; > > + if (afno == iCol) > > + vdbe_metadata_set_col_autoincrement(v, i); > > + } > > } > > } else { > > const char *z = NULL; > > 2. Consider this refactoring to make it more accurate: > > ============================================================================ > > @@ -1822,7 +1822,8 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList, > break; > } > assert(j < pTabList->nSrc); > - struct space_def *space_def = pTabList->a[j].space->def; > + struct space *space = pTabList->a[j].space; > + struct space_def *space_def = space->def; > assert(iCol >= 0 && iCol < (int)space_def->field_count); > zCol = space_def->fields[iCol].name; > const char *name = NULL; > @@ -1845,12 +1846,9 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList, > space_def->fields[iCol].is_nullable; > vdbe_metadata_set_col_nullability(v, i, > is_nullable); > - if (pTabList->a[j].space->sequence != NULL) { > - int afno = > - pTabList->a[j].space->sequence_fieldno; > - if (afno == iCol) > - vdbe_metadata_set_col_autoincrement(v, i); > - } > + if (space->sequence != NULL && > + space->sequence_fieldno == iCol) > + vdbe_metadata_set_col_autoincrement(v, i); > } > } else { > const char *z = NULL; > Applied. > ============================================================================ > > > diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c > > index 2de41a70a..e3672097c 100644 > > --- a/src/box/sql/vdbeaux.c > > +++ b/src/box/sql/vdbeaux.c > > @@ -1911,6 +1911,13 @@ vdbe_metadata_set_col_nullability(struct Vdbe *p, int idx, int nullable) > > p->metadata[idx].nullable = nullable; > > } > > > > +void > > +vdbe_metadata_set_col_autoincrement(struct Vdbe *p, int idx) > > +{ > > + assert(idx < p->nResColumn); > > + p->metadata[idx].is_actoincrement = 1; > > 3. Why 1 instead of true? Idk, replaced with boolean.
next prev parent reply other threads:[~2019-12-24 0:26 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-11 13:44 [Tarantool-patches] [PATCH v2 0/6] sql: extended metadata Nikita Pettik [not found] ` <cover.1576071711.git.korablev@tarantool.org> 2019-12-11 13:44 ` [Tarantool-patches] [PATCH v2 1/6] sql: refactor resulting set metadata Nikita Pettik 2019-12-11 13:44 ` [Tarantool-patches] [PATCH v2 2/6] sql: fix possible null dereference in sql_expr_coll() Nikita Pettik 2019-12-11 13:44 ` [Tarantool-patches] [PATCH v2 3/6] sql: extend result set with collation Nikita Pettik 2019-12-18 0:29 ` Vladislav Shpilevoy 2019-12-24 0:26 ` Nikita Pettik 2019-12-24 15:30 ` Vladislav Shpilevoy 2019-12-11 13:44 ` [Tarantool-patches] [PATCH v2 4/6] sql: extend result set with nullability Nikita Pettik 2019-12-18 0:29 ` Vladislav Shpilevoy 2019-12-24 0:26 ` Nikita Pettik 2019-12-11 13:44 ` [Tarantool-patches] [PATCH v2 5/6] sql: extend result set with autoincrement Nikita Pettik 2019-12-18 0:29 ` Vladislav Shpilevoy 2019-12-24 0:26 ` Nikita Pettik [this message] 2019-12-24 15:30 ` Vladislav Shpilevoy 2019-12-25 12:17 ` Nikita Pettik 2019-12-25 15:40 ` Vladislav Shpilevoy 2019-12-25 23:18 ` Nikita Pettik 2019-12-11 13:44 ` [Tarantool-patches] [PATCH v2 6/6] sql: extend result set with alias Nikita Pettik 2019-12-18 0:29 ` Vladislav Shpilevoy 2019-12-24 0:26 ` Nikita Pettik 2019-12-24 15:34 ` Vladislav Shpilevoy 2019-12-26 11:24 ` Nikita Pettik 2019-12-27 11:53 ` Vladislav Shpilevoy 2019-12-27 23:44 ` Nikita Pettik 2019-12-28 9:29 ` Vladislav Shpilevoy
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=20191224002621.GA31231@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 5/6] sql: extend result set with autoincrement' \ /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