From: Nikita Pettik <korablev@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 5/6] sql: extend result set with autoincrement Date: Thu, 5 Dec 2019 14:51:06 +0300 [thread overview] Message-ID: <20191205115106.GA449@tarantool.org> (raw) In-Reply-To: <9229bfa1-f516-5072-320b-9ab197a03da0@tarantool.org> On 28 Nov 23:41, Vladislav Shpilevoy wrote: > Thanks for the patch! > > On 27/11/2019 13:15, Nikita Pettik wrote: > > If result set contains column which features attached sequence > > (AUTOINCREMENT in terms of SQL) then meta-information will contain > > corresponding field ('autoicrement' : boolean) in response. > > 1. Please, lets name all booleans values with 'is_' prefix: > is_autoincrement, IPROTO_FIELD_IS_AUTOINCREMENT. > > > diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h > > index 0e54e42a5..63afb8777 100644 > > --- a/src/box/sql/vdbeInt.h > > +++ b/src/box/sql/vdbeInt.h > > @@ -355,6 +355,8 @@ struct sql_column_metadata { > > * columns: all other expressions are nullable by default. > > */ > > int8_t nullable : 2; > > + /** True if column features autoincrement property. */ > > + int8_t actoincrement : 1; > > 2. Lets make it bool, and name is_autoincrement. Both points are fixed: diff --git a/src/box/execute.c b/src/box/execute.c index 92f0f8ef7..0f18b3e5f 100644 --- a/src/box/execute.c +++ b/src/box/execute.c @@ -286,7 +286,7 @@ metadata_map_sizeof(const char *name, const char *type, const char *coll, } if (is_autoincrement) { members_count++; - map_size += mp_sizeof_uint(IPROTO_FIELD_AUTOINCREMENT); + map_size += mp_sizeof_uint(IPROTO_FIELD_IS_AUTOINCREMENT); map_size += mp_sizeof_bool(true); } map_size += mp_sizeof_uint(IPROTO_FIELD_NAME); @@ -355,7 +355,7 @@ sql_get_metadata(struct sql_stmt *stmt, struct obuf *out, int column_count) pos = mp_encode_bool(pos, nullable); } if (is_autoincrement) { - pos = mp_encode_uint(pos, IPROTO_FIELD_AUTOINCREMENT); + pos = mp_encode_uint(pos, IPROTO_FIELD_IS_AUTOINCREMENT); pos = mp_encode_bool(pos, true); } } diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index abfb279d0..30d1af4cb 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -133,7 +133,7 @@ enum iproto_metadata_key { IPROTO_FIELD_TYPE = 1, IPROTO_FIELD_COLL = 2, IPROTO_FIELD_IS_NULLABLE = 3, - IPROTO_FIELD_AUTOINCREMENT = 4, + IPROTO_FIELD_IS_AUTOINCREMENT = 4, }; enum iproto_ballot_key { diff --git a/src/box/lua/execute.c b/src/box/lua/execute.c index d7dd9432f..86192b728 100644 --- a/src/box/lua/execute.c +++ b/src/box/lua/execute.c @@ -47,7 +47,7 @@ lua_sql_get_metadata(struct sql_stmt *stmt, struct lua_State *L, } if (is_autoincrement) { lua_pushboolean(L, true); - lua_setfield(L, -2, "autoincrement"); + lua_setfield(L, -2, "is_autoincrement"); } lua_rawseti(L, -2, i + 1); } diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c index e67c14bed..a312f6cca 100644 --- a/src/box/lua/net_box.c +++ b/src/box/lua/net_box.c @@ -656,10 +656,10 @@ decode_metadata_optional(struct lua_State *L, const char **data, lua_pushboolean(L, is_nullable); lua_setfield(L, -2, "is_nullable"); } else { - assert(key == IPROTO_FIELD_AUTOINCREMENT); + assert(key == IPROTO_FIELD_IS_AUTOINCREMENT); bool autoincrement = mp_decode_bool(data); lua_pushboolean(L, autoincrement); - lua_setfield(L, -2, "autoincrement"); + lua_setfield(L, -2, "is_autoincrement"); } } } diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 22e7d96a5..57991e1b1 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -1844,7 +1844,7 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList, int afno = pTabList->a[j].space->sequence_fieldno; if (afno == iCol) - vdbe_set_metadata_col_autoincrement(v, i); + vdbe_metadata_set_col_autoincrement(v, i); } } else { const char *z = NULL; diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h index e19d4cdfa..da9a311b8 100644 --- a/src/box/sql/vdbe.h +++ b/src/box/sql/vdbe.h @@ -261,7 +261,7 @@ void vdbe_metadata_set_col_nullability(struct Vdbe *p, int idx, int nullable); void -vdbe_set_metadata_col_autoincrement(struct Vdbe *p, int idx); +vdbe_metadata_set_col_autoincrement(struct Vdbe *p, int idx); void sqlVdbeCountChanges(Vdbe *); sql *sqlVdbeDb(Vdbe *); diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index bccb4feb7..d79635b14 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -356,7 +356,7 @@ struct sql_column_metadata { */ int8_t nullable : 2; /** True if column features autoincrement property. */ - int8_t actoincrement : 1; + bool is_actoincrement; }; /* diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 34d189e00..8b97f7320 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -766,7 +766,7 @@ sql_column_is_autoincrement(sql_stmt *stmt, int n) { struct Vdbe *p = (struct Vdbe *) stmt; assert(n < sql_column_count(stmt) && n >= 0); - return p->metadata[n].actoincrement; + return p->metadata[n].is_actoincrement; } /******************************* sql_bind_ ************************** diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 4a8bba7f7..384e985fb 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -1912,10 +1912,10 @@ vdbe_metadata_set_col_nullability(struct Vdbe *p, int idx, int nullable) } void -vdbe_set_metadata_col_autoincrement(struct Vdbe *p, int idx) +vdbe_metadata_set_col_autoincrement(struct Vdbe *p, int idx) { assert(idx < p->nResColumn); - p->metadata[idx].actoincrement = 1; + p->metadata[idx].is_actoincrement = 1; }
next prev parent reply other threads:[~2019-12-05 11:51 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-27 12:15 [Tarantool-patches] [PATCH 0/6] sql: extend response metadata Nikita Pettik 2019-11-27 12:15 ` [Tarantool-patches] [PATCH 1/6] sql: refactor resulting set metadata Nikita Pettik 2019-11-28 22:41 ` Vladislav Shpilevoy 2019-12-05 11:39 ` Nikita Pettik 2019-12-05 23:58 ` Vladislav Shpilevoy 2019-12-06 12:48 ` Nikita Pettik 2019-12-17 13:23 ` Sergey Ostanevich 2019-11-27 12:15 ` [Tarantool-patches] [PATCH 2/6] sql: fix possible null dereference in sql_expr_coll() Nikita Pettik 2019-11-28 22:42 ` Vladislav Shpilevoy 2019-12-05 11:40 ` Nikita Pettik 2019-12-05 23:59 ` Vladislav Shpilevoy 2019-12-06 12:48 ` Nikita Pettik 2019-12-17 13:30 ` Sergey Ostanevich 2019-12-17 14:44 ` Nikita Pettik 2019-12-17 19:53 ` Nikita Pettik 2019-11-27 12:15 ` [Tarantool-patches] [PATCH 3/6] sql: extend result set with collation Nikita Pettik 2019-11-28 22:41 ` Vladislav Shpilevoy 2019-12-05 11:50 ` Nikita Pettik 2019-12-18 11:08 ` Sergey Ostanevich 2019-12-24 0:44 ` Nikita Pettik 2019-11-27 12:15 ` [Tarantool-patches] [PATCH 4/6] sql: extend result set with nullability Nikita Pettik 2019-11-28 22:41 ` Vladislav Shpilevoy 2019-12-05 11:50 ` Nikita Pettik 2019-12-06 0:00 ` Vladislav Shpilevoy 2019-12-06 12:49 ` Nikita Pettik 2019-12-18 13:31 ` Sergey Ostanevich 2019-11-27 12:15 ` [Tarantool-patches] [PATCH 5/6] sql: extend result set with autoincrement Nikita Pettik 2019-11-28 22:41 ` Vladislav Shpilevoy 2019-12-05 11:51 ` Nikita Pettik [this message] 2019-12-18 15:17 ` Sergey Ostanevich 2019-12-24 0:47 ` Nikita Pettik 2019-11-27 12:15 ` [Tarantool-patches] [PATCH 6/6] sql: extend result set with alias Nikita Pettik 2019-11-28 22:41 ` Vladislav Shpilevoy 2019-12-05 11:51 ` Nikita Pettik 2019-12-06 0:02 ` Vladislav Shpilevoy 2019-12-06 12:50 ` Nikita Pettik 2019-12-06 21:52 ` Vladislav Shpilevoy 2019-12-19 15:17 ` Sergey Ostanevich 2019-12-24 0:27 ` Nikita Pettik 2019-11-28 22:55 ` [Tarantool-patches] [PATCH 0/6] sql: extend response metadata 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=20191205115106.GA449@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 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