[MDEV-6363] OLD_MODE and stored programs Created: 2014-06-19 Updated: 2014-06-21 Resolved: 2014-06-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Federico Razzoli | Assignee: | Michael Widenius |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | old-mode | ||
| Description |
|
As you know, when a procedure/function/trigger/event is executed, the current SQL_MODE is ignored: the routine runs using the SQL_MODE that was in effect at definition time. The same should happen with the OLD_MODE. The stored programs are unreliable, if they depend on current session's settings.
|
| Comments |
| Comment by Elena Stepanova [ 2014-06-19 ] |
|
It's the documented behavior: https://mariadb.com/kb/en/old_mode/ |
| Comment by Federico Razzoli [ 2014-06-19 ] |
|
Sorry, I didn't notice, so this is not a bug. But still, this difference between OLD_MODE and SQL_MODE confuses me. Maybe I'm missing something, but I want my procedure to always or never fail on division by zero (sql_mode), and similarly I want it to always/never generate duplicate key warnings (old_mode). |
| Comment by Elena Stepanova [ 2014-06-19 ] |
|
I will convert it into a feature request and assign to Monty (who added OLD_MODE), in case he wants to reconsider, or at least to comment on this. |
| Comment by Michael Widenius [ 2014-06-19 ] |
|
It's a bit complex storing all variables that may affect usage stored procedures. old_mode is especially problematic as this is used to emulate behavior from a few previous MySQL/MariaDB versions to allow easy upgrades. Over time we plan to deprecate options as applications has catched on to the new behavior. If this is very important for you, what we could do is consider moving NO_DUP_KEY_WARNINGS_WITH_IGNORE to SQL_MODE. Would that be an acceptable solution for you? Regards, |
| Comment by Sergei Golubchik [ 2014-06-20 ] |
|
f_razzoli, the difference between SQL_MODE and OLD_MODE is conceptual. Every value in the SQL_MODE tells you that a server can work in one of the two modes (e.g. ANSI_QUOTES and no-ANSI_QUOTES), and you can choose either way. Sometimes these modes affect stored routines, that's why a definition of the stored routine includes the active SQL_MODE at the moment of the routine creation. OLD_MODE, while similar, is nothing more than a glorified --old command line switch. Something that helps to upgrade but still have the old behavior temporarily, until you fix your application. Just like enabling or disabling --old might affect stored routines, so might OLD_MODE. Just like --old it is not stored per stored routine, and just like --old it's not replicated to slaves. You aren't really supposed to be using it on a permanent basis, it's like a small spare tire, it can get you going, but you should replace it as soon as possible. |
| Comment by Federico Razzoli [ 2014-06-21 ] |
|
I understand. Also, I didn't consider the possible upgrade problems is you add a field in mysql.proc. No, I don't really need NO_DUP_KEY_WARNINGS_WITH_IGNORE in SQL_MODE, I'll just modify my procedures to suppress the warnings. Thank you. |