From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id DFE5B4696C3 for ; Fri, 1 May 2020 22:35:54 +0300 (MSK) References: <20200309150258.32584-1-roman.habibov@tarantool.org> <6B917D0D-6B5F-4CC3-A7ED-43B0768B2537@tarantool.org> <83e93b75-de08-865d-a8c2-9e899e27cc09@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Fri, 1 May 2020 21:35:52 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH] sql: use unify pattern for column names List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Khabibov Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the fixes! >>> diff --git a/src/box/sql/select.c b/src/box/sql/select.c >>> index 65e41f219..f39983761 100644 >>> --- a/src/box/sql/select.c >>> +++ b/src/box/sql/select.c >>> @@ -1946,14 +1946,13 @@ sqlColumnsFromExprList(Parse * parse, ExprList * expr_list, >>> } else if (pColExpr->op == TK_ID) { >>> assert(!ExprHasProperty(pColExpr, EP_IntValue)); >>> zName = pColExpr->u.zToken; >>> - } else { >>> - /* Use the original text of the column expression as its name */ >>> - zName = expr_list->a[i].zSpan; >>> } >>> } >>> - if (zName == NULL) >>> - zName = "_auto_field_"; >>> - zName = sqlMPrintf(db, "%s", zName); >>> + if (zName == NULL) { >>> + uint32_t idx = ++parse->autoname_i; >>> + zName = (char *) sql_generate_column_name(idx); >> >> 2. Wait, I remember I asked to keep it const. I even provided a mini patch >> how to keep it without casts. Why did you leave non-const char here? > I know, but now I do uint32_t idx = ++parse->autoname_i;, so I need if else > and your construction is not suitable already. In that case you could provide your own construction. After all, I am not the author of the patch. In that particular case it can be solved by just making zName declared as 'const char *' instead of 'char *'. In your second commit.