MySQL Forums
Forum List  »  Stored Procedures

Re: Dynamic Sql Statement in SP
Posted by: Ming Yeung
Date: January 10, 2006 06:51AM

> No, this should not be a problem. User variables
> exist in the session scope: one session can see
> all the user variables it has created - not the
> ones created in other sessions.

I tested this with Java Struts & DBCP (Connection Pool). It seems to me there might be a serious matter when using user variables. I added the code to my SP for the test:
...
IF @SqlString IS NOT NULL THEN
SELECT @SqlString as sqlStatement;
LEAVE SP_MAIN;
END IF;
...
PREPARE STMT FROM @SqlString;
...

I believe the sessions of the MySql user are not being released, the connections are all being returned to the Pool. Therefore, user variables are accessed by different web users(All web users use the same MySql account 'ming').

I haven't tested it without connection pooling. But as I have seen that it is really a matter to web applications when using connection pooling. Web user 'A' might get the result of web user 'B', and user 'B' might get errors as the result is being free, etc.

Please prove that I'm wrong, I really want to continue using SP with MySql.

> This is dangerous! A user can, either knowingly or
> unknowlingly, inject it's own SQL inside your
> statement. Suppose your user passes this value for
> inUsername:

Oh yes, Thank for reminding me.

Thanks.
Ming



Edited 1 time(s). Last edit at 01/10/2006 06:52AM by Ming Yeung.

Options: ReplyQuote


Subject
Views
Written By
Posted
2756
January 09, 2006 06:22AM
1481
January 09, 2006 08:06AM
1219
January 09, 2006 02:10PM
1800
January 09, 2006 08:02PM
1685
January 10, 2006 12:24AM
1459
January 10, 2006 03:07AM
Re: Dynamic Sql Statement in SP
1672
January 10, 2006 06:51AM
1397
January 10, 2006 01:49PM
1742
January 10, 2006 06:35PM
1546
January 10, 2006 07:22PM
1631
January 10, 2006 10:33PM
1628
January 11, 2006 03:10AM
2200
January 11, 2006 04:27AM
1656
January 11, 2006 06:54AM
1485
January 11, 2006 03:34PM
1649
January 11, 2006 03:56PM
1637
January 12, 2006 03:20AM
1445
January 12, 2006 04:44AM
1418
January 11, 2006 09:08PM
1666
January 12, 2006 03:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.