Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Mergen Imeev <imeevma@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v1 1/2] sql: properly check bind variable names
Date: Mon, 13 Dec 2021 22:47:44 +0100	[thread overview]
Message-ID: <6d11ad7b-89d6-551c-2a14-2a53b8b0be3c@tarantool.org> (raw)
In-Reply-To: <20211213073440.GA41198@tarantool.org>

Hi! Thanks for the fixes!

>>>>>>> diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
>>>>>>> index eb169aeb8..74a98c550 100644
>>>>>>> --- a/src/box/sql/expr.c
>>>>>>> +++ b/src/box/sql/expr.c
>>>>>>> @@ -1314,6 +1314,52 @@ sqlExprAssignVarNumber(Parse * pParse, Expr * pExpr, u32 n)
>>>>>>>  	}
>>>>>>>  }
>>>>>>>  
>>>>>>> +struct Expr *
>>>>>>> +expr_variable(struct Parse *parse, struct Token *spec, struct Token *id)
>>>>>>
>>>>>> 1. You might want to call it expr_new_variable(). Or sql_expr_new_variable().
>>>>>> To be consistent with our naming policy for constructors allocating memory
>>>>>> and for consistency with with sql_expr_new_column(), sql_expr_new(),
>>>>>> sql_expr_new_dequoted(), sql_expr_new_named(), sql_expr_new_anon().
>>>>>>
>>>>> Thank you! I renamed it to expr_new_variable(). I believe we should drop 'sql_'
>>>>> prefix for functions that only accessible in SQL.
>>>>
>>>> It would work for static functions. But if a function is visible in other
>>>> modules as a symbol, then you would get a conflict during linking if we
>>>> ever introduce another 'struct expr' somewhere. Even if they do not interest
>>>> anywhere in the code. However I don't mind leaving it as is. It can be fixed
>>>> later if ever needed.
>>>>
>>> I agree. However, I think we need to rework all the places where BOX uses
>>> internal SQL functions and structures. In this case, the struct expr should
>>> never be available in the BOX, so there should be no conflicts.
>>
>> It is a misunderstanding. It does not matter if you use a function in box or
>> not. If it is not static and is defined in 2 places - you will get a conflict
>> during link stage. Try to add a function with the same name to any file in
>> sql and to any file in box. Something like
>>
>> 	void
>> 	link_test123(void)
>> 	{
>> 		printf("in link test\n");
>> 	}
>>
>> (in a .cc file you would need to add 'extern "C"' for it). It will raise an
>> error during build. I added it to expr.c and to box.cc (with 'extern "C"'):
>>
>> 	duplicate symbol '_link_test123' in:
>> 	    ../../src/box/libbox.a(box.cc.o)
>> 	    ../../src/box/libbox.a(expr.c.o)
>> 	ld: 1 duplicate symbol for architecture x86_64
>>
> Got it, thanks for the explanation. It might be better to rename "struct Expr"
> to "struct sql_expr", in which case we will naturally use the sql_expr_ * prefix
> for such functions. How do you think?

Sounds good to me.

  reply	other threads:[~2021-12-13 21:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 14:08 [Tarantool-patches] [PATCH v1 0/2] Introduce syntax for MAP values is SQL Mergen Imeev via Tarantool-patches
2021-11-18 14:08 ` [Tarantool-patches] [PATCH v1 1/2] sql: properly check bind variable names Mergen Imeev via Tarantool-patches
2021-11-20  0:45   ` Vladislav Shpilevoy via Tarantool-patches
2021-11-25  8:33     ` Mergen Imeev via Tarantool-patches
2021-11-30 22:02       ` Vladislav Shpilevoy via Tarantool-patches
2021-12-02  8:32         ` Mergen Imeev via Tarantool-patches
2021-12-09  0:31           ` Vladislav Shpilevoy via Tarantool-patches
2021-12-13  7:34             ` Mergen Imeev via Tarantool-patches
2021-12-13 21:47               ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-11-18 14:08 ` [Tarantool-patches] [PATCH v1 2/2] sql: introduce syntax for MAP values Mergen Imeev via Tarantool-patches
2021-11-20  0:46   ` Vladislav Shpilevoy via Tarantool-patches
2021-11-25  8:55     ` Mergen Imeev via Tarantool-patches
2021-11-30 22:04       ` Vladislav Shpilevoy via Tarantool-patches
2021-12-02  8:38         ` Mergen Imeev via Tarantool-patches
2021-12-09  0:31           ` Vladislav Shpilevoy via Tarantool-patches
2021-12-13  7:42             ` Mergen Imeev via Tarantool-patches
2021-12-13 21:48               ` Vladislav Shpilevoy via Tarantool-patches

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=6d11ad7b-89d6-551c-2a14-2a53b8b0be3c@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1 1/2] sql: properly check bind variable names' \
    /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