Currently I'm working with Stored Procedures in MySQL and I'm using in some procedures user-defined variables and I've seen that type of variables are initialized in the current session and keep their value until the session ends.
I was also working with statements like select into @user_defined_variable
but I realized that doing that is very risky, specially on logins/authentications.
So the solution in this case was to use the statement set @user_defined_variable
instead of select into
.
But I'm really not sure if it's enough using the set
, because that type of variables will keep their value while the session is not finished.
Now imagine that the server receives several requests at same time on the Stored Procedures that are using the same @user_defined_variable
, can exist a collision of values in this case? For example, if the stored procedure called login
uses the user defined variables @uuidUser
and the stored procedure called home
also uses the @uuidUser
, does exist the risk that the home
procedure uses the value of @uuidUser
assigned inside the login
procedure?
Note: I'm working with Node.js and I only have one connection to the MySQL instance,I don't create a connection for every request. So the @user_defined_variables
will always exist.