Bug #48615 | A function with now() may be declared deterministic | ||
---|---|---|---|
Submitted: | 7 Nov 2009 21:37 | Modified: | 21 May 2010 18:36 |
Reporter: | Peter Laursen (Basic Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 5.0 + | OS: | Any |
Assigned to: | Paul DuBois | CPU Architecture: | Any |
Tags: | qc |
[7 Nov 2009 21:37]
Peter Laursen
[7 Nov 2009 21:50]
Peter Laursen
Also this very much deterministic function can be defined NOT DETERMINISTIC: DELIMITER $$ CREATE FUNCTION `test`.`test2`(a INTEGER) RETURNS INTEGER NOT DETERMINISTIC BEGIN RETURN a+1; END$$ DELIMITER ; .. so when and how is DETERMINISTIC | NOT DETERMINISTIC used by the server? Obviously not at create-time. But by the optimizer maybe?
[7 Nov 2009 22:37]
Peter Laursen
A clarification: I understand and accept of course that checking for 'determinism' at create-time is probably hopeless with non-trivial examples - except for routines using now(), synonymns of now(), and rand(). But if this flag is used by the server at all it should be made *very clear* that it is user's own responsibility to set the flag correctly. If the information is not used at all, it should be made equally clear that this information may (or may not) be entered by user for clarity - and for no other purpose.
[8 Nov 2009 11:34]
Davi Arnaut
Quoting from the manual: "Assessment of the nature of a function is based on the “honesty” of the creator: MySQL does not check that a function declared DETERMINISTIC is free of statements that produce nondeterministic results."
[8 Nov 2009 12:24]
Peter Laursen
@davi .. can you please provide a link to the page with this? Also: do you think it is properly explained how the server makes use of determinism as defined by user? I understand: 1) if a non-deterministic routine is declared DETERMINISTIC it may lead to unexpected results (as the optimizer may not execute routines for every call()). 2) if a deterministic routine is declared NOT DETERMINISTIC it may degrade performance (as unnessary call(s) may be executed). .. Correct? If so I think it is very important to *pin it out*
[8 Nov 2009 13:01]
Davi Arnaut
> @davi .. can you please provide a link to the page with this? http://dev.mysql.com/doc/refman/5.1/en/stored-programs-logging.html > Also: do you think it is properly explained how the server makes use of determinism > as defined by user? It certainly could be improved. > I understand: > 1) if a non-deterministic routine is declared DETERMINISTIC it may lead to > unexpected results (as the optimizer may not execute routines for every call()). I suppose so. For example, could cause problems with constant propagation. > 2) if a deterministic routine is declared NOT DETERMINISTIC it may degrade > performance (as unnessary call(s) may be executed). Yes as it might prohibit some optimizations from being applied. > .. Correct? If so I think it is very important to *pin it out* I agree.
[8 Nov 2009 13:20]
Valeriy Kravchuk
So, I think, we have a valid documentation request here.
[21 May 2010 18:36]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.