List:Commits« Previous MessageNext Message »
From:pem Date:February 1 2006 2:59pm
Subject:bk commit into 5.0 tree (pem:1.2009) BUG#15011
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2009 06/02/01 16:00:11 pem@stripped +1 -0
  Post-review fix for BUG#15011.
  Added comments.

  sql/sp_rcontext.cc
    1.40 06/02/01 16:00:08 pem@stripped +29 -0
    Added comments to sp_rcontext::find_handler()

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	pem
# Host:	pem.mysql.com
# Root:	/extern/mysql/work/bug15011/mysql-5.0

--- 1.39/sql/sp_rcontext.cc	2006-01-25 17:19:50 +01:00
+++ 1.40/sql/sp_rcontext.cc	2006-02-01 16:00:08 +01:00
@@ -164,6 +164,33 @@
 #define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2')
 #define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2')
 
+/*
+  Find a handler for the given errno.
+  This is called from all error message functions (e.g. push_warning,
+  net_send_error, et al) when a sp_rcontext is in effect. If a handler
+  is found, no error is sent, and the the SP execution loop will instead
+  invoke the found handler.
+  This might be called several times before we get back to the execution
+  loop, so m_hfound can be >= 0 if a handler has already been found.
+  (In which case we don't search again - the first found handler will
+   be used.)
+  Handlers are pushed on the stack m_handler, with the latest/innermost
+  one on the top; we then search for matching handlers from the top and
+  down.
+  We search through all the handlers, looking for the most specific one
+  (sql_errno more specific than sqlstate more specific than the rest).
+  Note that mysql error code handlers is a MySQL extension, not part of
+  the standard.
+
+  SYNOPSIS
+    sql_errno     The error code
+    level         Warning level
+
+  RETURN
+    1             if a handler was found, m_hfound is set to its index (>= 0)
+    0             if not found, m_hfound is -1
+*/
+
 bool
 sp_rcontext::find_handler(uint sql_errno,
                           MYSQL_ERROR::enum_warning_level level)
@@ -174,11 +201,13 @@
   const char *sqlstate= mysql_errno_to_sqlstate(sql_errno);
   int i= m_hcount, found= -1;
 
+  /* Search handlers from the latest (innermost) to the oldest (outermost) */
   while (i--)
   {
     sp_cond_type_t *cond= m_handler[i].cond;
     int j= m_ihsp;
 
+    /* Check active handlers, to avoid invoking one recursively */
     while (j--)
       if (m_in_handler[j] == m_handler[i].handler)
 	break;
Thread
bk commit into 5.0 tree (pem:1.2009) BUG#15011pem1 Feb