List:Commits« Previous MessageNext Message »
From:sayantan.dutta Date:June 14 2012 11:58am
Subject:bzr push into mysql-trunk branch (sayantan.dutta:4011 to 4013)
View as plain text  
 4013 sayantan.dutta@stripped	2012-06-14 [merge]
      null merge 13946716

 4012 sayantan.dutta@stripped	2012-06-14
      Bug #14112682 : MYSQLTEST: PROVIDE ACCESS TO ERROR NAMES THROUGH NUMERIC CODES AND VICE VERSA
     @ client/mysqltest.cc
        Bug #14112682 : MYSQLTEST: PROVIDE ACCESS TO ERROR NAMES THROUGH NUMERIC CODES AND VICE VERSA
     @ mysql-test/t/mysqltest.test
        Bug #14112682 : MYSQLTEST: PROVIDE ACCESS TO ERROR NAMES THROUGH NUMERIC CODES AND VICE VERSA

    modified:
      client/mysqltest.cc
      mysql-test/r/mysqltest.result
      mysql-test/t/mysqltest.test
 4011 Mattias Jonsson	2012-06-14
      bug#13783690
      
      Requiring --big-test for some of the long running tests in the parts test suite.

    modified:
      mysql-test/suite/parts/t/partition_alter1_1_innodb.test
      mysql-test/suite/parts/t/partition_basic_innodb.test
      mysql-test/suite/parts/t/partition_debug_innodb.test
      mysql-test/suite/parts/t/rpl_partition.test
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2012-06-04 15:35:18 +0000
+++ b/client/mysqltest.cc	2012-06-14 11:51:32 +0000
@@ -2567,6 +2567,84 @@ do_result_format_version(struct st_comma
   dynstr_free(&ds_version);
 }
 
+/* List of error names to error codes */
+typedef struct
+{
+  const char *name;
+  uint        code;
+  const char *text;
+} st_error;
+
+static st_error global_error_names[] =
+{
+  { "<No error>", -1, "" },
+#include <mysqld_ername.h>
+  { 0, 0, 0 }
+};
+
+uint get_errcode_from_name(char *, char *);
+
+/*
+
+  This function is useful when one needs to convert between error numbers and  error strings
+
+  SYNOPSIS
+  var_set_convert_error(struct st_command *command,VAR *var)
+
+  DESCRIPTION
+  let $var=convert_error(ER_UNKNOWN_ERROR); 
+  let $var=convert_error(1234); 
+  
+  The variable var will be populated with error number if the argument is string.
+  The variable var will be populated with error string if the argument is number.
+
+*/
+void var_set_convert_error(struct st_command *command,VAR *var)
+{
+  char *last;
+  char *first=command->query;
+  const char *err_name;
+    
+  DBUG_ENTER("var_set_query_get_value");
+
+  DBUG_PRINT("info", ("query: %s", command->query));
+
+  /* the command->query contains the statement convert_error(1234) */ 
+  first=strchr(command->query,'(') + 1;
+  last=strchr(command->query,')');
+
+
+  if( last == first )  /* denoting an empty string */
+  {
+    eval_expr(var,"0",0);
+    DBUG_VOID_RETURN;
+  }
+  
+
+  /* if the string is an error string , it starts with 'E' as is the norm*/
+  if ( *first == 'E')    
+  {
+    char str[100];
+    uint num;
+    num=get_errcode_from_name(first, last);
+    sprintf(str,"%i",num);
+    eval_expr(var,str,0);
+  }
+  else  if (my_isdigit(charset_info, *first ))/* if the error is a number */
+  {
+    long int err;
+
+    err=strtol(first,&last,0);
+    err_name = get_errname_from_code(err);
+    eval_expr(var,err_name,0);
+  }
+  else
+  {
+    die("Invalid error in input");
+  }
+
+  DBUG_VOID_RETURN;
+}
 
 /*
   Set variable from the result of a field in a query
@@ -2772,6 +2850,20 @@ void eval_expr(VAR *v, const char *p, co
       var_set_query_get_value(&command, v);
       DBUG_VOID_RETURN;
     }
+    /* Check if this is a "let $var= convert_error()" */
+    const char* get_value_str1= "convert_error";
+    const size_t len1= strlen(get_value_str1);
+    if (strncmp(p, get_value_str1, len1)==0)
+    {
+      struct st_command command;
+      memset(&command, 0, sizeof(command));
+      command.query= (char*)p;
+      command.first_word_len= len;
+      command.first_argument= command.query + len;
+      command.end= (char*)*p_end;
+      var_set_convert_error(&command, v);
+      DBUG_VOID_RETURN;
+    }
   }
 
  NO_EVAL:
@@ -4764,20 +4856,6 @@ void do_shutdown_server(struct st_comman
 }
 
 
-/* List of error names to error codes */
-typedef struct
-{
-  const char *name;
-  uint        code;
-  const char *text;
-} st_error;
-
-static st_error global_error_names[] =
-{
-  { "<No error>", -1, "" },
-#include <mysqld_ername.h>
-  { 0, 0, 0 }
-};
 
 uint get_errcode_from_name(char *error_name, char *error_end)
 {

=== modified file 'mysql-test/r/mysqltest.result'
--- a/mysql-test/r/mysqltest.result	2011-12-09 21:08:37 +0000
+++ b/mysql-test/r/mysqltest.result	2012-06-14 11:51:32 +0000
@@ -186,6 +186,14 @@ xyz
  is empty
  is empty
 "Yes it's empty"
+ER_FORBID_SCHEMA_CHANGE
+1105
+mysqltest: At line 1: Invalid error in input
+<Unknown>
+<Unknown>
+
+0
+0
 hello
 hello
 ;;;;;;;;

=== modified file 'mysql-test/t/mysqltest.test'
--- a/mysql-test/t/mysqltest.test	2011-12-09 21:08:37 +0000
+++ b/mysql-test/t/mysqltest.test	2012-06-14 11:51:32 +0000
@@ -458,6 +458,37 @@ if (!`SELECT foo from bar`) {
 }
 
 # ----------------------------------------------------------------------------
+#test to check conversion between error numbers and error strings
+# ----------------------------------------------------------------------------
+let $var=convert_error(1450);
+let $var1=convert_error($var);
+let $var2=convert_error($var1);
+echo $var2;
+
+let $var=convert_error(ER_UNKNOWN_ERROR);
+let $var1=convert_error($var);
+let $var2=convert_error($var1);
+echo $var2;
+
+--error 1
+--exec echo "let \$var= convert_error(NOT_A_VALID_ERROR);" | $MYSQL_TEST 2>&1
+
+let $var=convert_error(9999999);
+echo $var;
+
+let $var=convert_error(9ABC9);
+echo $var;
+
+let $var=convert_error(0);
+echo $var;
+
+let $var=convert_error();
+echo $var;
+
+let $var=;
+let $var1=convert_error($var);
+echo $var1;
+# ----------------------------------------------------------------------------
 # Test comments
 # ----------------------------------------------------------------------------
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (sayantan.dutta:4011 to 4013) sayantan.dutta14 Jun