[Tarantool-patches] [PATCH] sql: use unify pattern for column names
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Fri May 1 22:35:52 MSK 2020
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.
More information about the Tarantool-patches
mailing list