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 65B692144C for ; Wed, 4 Jul 2018 05:17:17 -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 yPdOL8CyX-EI for ; Wed, 4 Jul 2018 05:17:17 -0400 (EDT) Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (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 A9D9921282 for ; Wed, 4 Jul 2018 05:17:16 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH v9] sql: add index_def to struct Index From: "n.pettik" In-Reply-To: <82d4d235-c105-b6b4-dad1-7ae42c23f0ea@tarantool.org> Date: Wed, 4 Jul 2018 12:17:09 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <2D725625-B171-4451-B1F4-B174CFE679EE@tarantool.org> References: <9A0A687D-2E0B-4AB9-B223-1A1287817824@tarantool.org> <8900ae2a-59e8-d69a-7f5d-95436b23214a@tarantool.org> <0e795fb5-1ee8-e7e6-65e4-7347787f3248@tarantool.org> <898ec1ac-51b9-13a6-6298-3a20eeac5b2b@tarantool.org> <76c1ec30-4f33-bc91-8845-72a99fc4ef0f@tarantool.org> <6fbc3849-a204-6cd9-82cd-2fb22769ccf0@tarantool.org> <2d4908aa-0243-8dc3-e109-707cb482b7f6@tarantool.org> <82d4d235-c105-b6b4-dad1-7ae42c23f0ea@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: Ivan Koptelov , Vladislav Shpilevoy >=20 >>> + uint32_t iid, const char *name, uint32_t name_len, bool = is_unique, >>> + struct ExprList *expr_list, u8 idx_type) >>> +{ >>> + struct space_def *space_def =3D table->def; >>> + size_t sql_size =3D 0; >>> + struct index_opts opts; >>> + index_opts_create(&opts); >>> + index->def =3D NULL; >>> + opts.is_unique =3D is_unique; >>> + int rc =3D -1; >> You don=E2=80=99t use this variable and in the end just reassign it: >=20 > This variable is reassigned on success only. On any error we > go to cleanup or tnt_error and rc remains -1. Oh, well, then it is OK. Another one remark (after got approve from team): @@ -2731,42 +2765,38 @@ sql_create_index(struct Parse *parse, struct = Token *token, * primary key or UNIQUE constraint. We have to invent * our own name. */ - if (token) { - zName =3D sqlite3NameFromToken(db, token); - if (zName =3D=3D 0) + if (token !=3D NULL) { + name =3D sqlite3NameFromToken(db, token); + if (name =3D=3D NULL) goto exit_create_index; - assert(token->z !=3D 0); + assert(token->z !=3D NULL); if (!db->init.busy) { - if (sqlite3HashFind(&db->pSchema->tblHash, = zName) !=3D + if (sqlite3HashFind(&db->pSchema->tblHash, name) = !=3D NULL) { - sqlite3ErrorMsg(parse, - "there is already a = table named %s", - zName); + sqlite3ErrorMsg(parse, "there is already = a "\ + "table named %s", name); goto exit_create_index; There is no need to prohibit creating index with table name, since index name is local for given table. And most of other DBs also allow to create index with table name.