[tarantool-patches] Re: [PATCH v9] sql: add index_def to struct Index

n.pettik korablev at tarantool.org
Wed Jul 4 12:17:09 MSK 2018


> 
>>> +	      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 = table->def;
>>> +	size_t sql_size = 0;
>>> +	struct index_opts opts;
>>> +	index_opts_create(&opts);
>>> +	index->def = NULL;
>>> +	opts.is_unique = is_unique;
>>> +	int rc = -1;
>> You don’t use this variable and in the end just reassign it:
> 
> 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 = sqlite3NameFromToken(db, token);
-		if (zName == 0)
+	if (token != NULL) {
+		name = sqlite3NameFromToken(db, token);
+		if (name == NULL)
			goto exit_create_index;
-		assert(token->z != 0);
+		assert(token->z != NULL);
		if (!db->init.busy) {
-			if (sqlite3HashFind(&db->pSchema->tblHash, zName) !=
+			if (sqlite3HashFind(&db->pSchema->tblHash, name) !=
			    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.





More information about the Tarantool-patches mailing list