Bug #21795 SP: sp_head::is_not_allowed_in_function() contains erroneous check
Submitted: 23 Aug 2006 16:01 Modified: 31 Aug 2006 10:20
Reporter: Andrey Hristov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0, 5.1 OS:Any (All)
Assigned to: Andrey Hristov CPU Architecture:Any

[23 Aug 2006 16:01] Andrey Hristov
Description:
  bool is_not_allowed_in_function(const char *where)
contains

which is a bug
    else if (m_type != TYPE_ENUM_PROCEDURE &&
             (m_flags & sp_head::HAS_COMMIT_OR_ROLLBACK))

How to repeat:
See the source
[25 Aug 2006 9:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/10871

ChangeSet@1.2245, 2006-08-25 11:28:45+02:00, andrey@example.com +8 -0
  Fix for bug#21795: SP: sp_head::is_not_allowed_in_function() contains
  erroneous check
  
  Problem: Actually there were two problems in the server code. The check
  for SQLCOM_FLUSH in SF/Triggers were not according to the existing
  architecture which uses sp_get_flags_for_command() from sp_head.cc .
  This function was also missing a check for SQLCOM_FLUSH which is a 
  command implying a COMMIT. This fixes both of these deficiencies as
  well as the erroneous check in sp_head::is_not_allowed_in_function() which
  was a copy&paste error.
  
  CHANGE OF BEHAVIOR: The error which will be emitted now from the server
  when there is a FLUSH inside a SF/Trigger or a SP which contains FLUSH
  is called from an SF or a Trigger is not anymore
  ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
  eng "%s is not allowed in stored function or trigger"
  but
  ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
  eng "Explicit or implicit commit is not allowed in stored function or trigger."
[25 Aug 2006 11:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/10875

ChangeSet@1.2245, 2006-08-25 13:29:47+02:00, andrey@example.com +8 -0
  Fix for bug#21795: SP: sp_head::is_not_allowed_in_function() contains
  erroneous check
  
  Problem: Actually there were two problems in the server code. The check
  for SQLCOM_FLUSH in SF/Triggers were not according to the existing
  architecture which uses sp_get_flags_for_command() from sp_head.cc .
  This function was also missing a check for SQLCOM_FLUSH which is a 
  command implying a COMMIT. This fixes both of these deficiencies as
  well as the erroneous check in sp_head::is_not_allowed_in_function() which
  was a copy&paste error.
  
  CHANGE OF BEHAVIOR: The error which will be emitted now from the server
  when there is a FLUSH inside a SF/Trigger or a SP which contains FLUSH
  is called from an SF or a Trigger is not anymore
  ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
  eng "%s is not allowed in stored function or trigger"
  but
  ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
  eng "Explicit or implicit commit is not allowed in stored function or trigger."
[25 Aug 2006 13:41] Konstantin Osipov
Asked for another version of the patch.
[25 Aug 2006 13:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/10884

ChangeSet@1.2245, 2006-08-25 15:51:29+02:00, andrey@example.com +8 -0
  Fix for bug#21795: SP: sp_head::is_not_allowed_in_function() contains
  erroneous check
  
  Problem: Actually there were two problems in the server code. The check
  for SQLCOM_FLUSH in SF/Triggers were not according to the existing
  architecture which uses sp_get_flags_for_command() from sp_head.cc .
  This function was also missing a check for SQLCOM_FLUSH which has a
  problem combined with prelocking. This changeset fixes both of these
  deficiencies as well as the erroneous check in
  sp_head::is_not_allowed_in_function() which was a copy&paste error.
[25 Aug 2006 15:08] Konstantin Osipov
Second version of the patch is approved by email.
[31 Aug 2006 10:20] Konstantin Osipov
Pushed into 5.0.25 and 5.1.12.
No documentation note is needed.