MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:June 7 2007 11:03am
Subject:bk commit into 5.1 tree (gluh:1.2506)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of gluh. When gluh 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@stripped, 2007-06-07 16:02:58+05:00, gluh@stripped +9 -0
  WL#2822 INFORMATION_SCHEMA.ROUTINES: Add missing columns
  WL#2003 INFORMATION_SCHEMA: PARAMETERS view
  (2nd version)

  mysql-test/r/information_schema.result@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +35 -1
    test result

  mysql-test/r/information_schema_db.result@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +1 -0
    result fix

  mysql-test/r/mysqlshow.result@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +2 -0
    result fix

  mysql-test/r/sp.result@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +24 -24
    result fix

  mysql-test/t/information_schema.test@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +19 -0
    test case

  mysql-test/t/sp.test@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +8 -8
    test fix

  sql/sp_head.h@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +1 -0
    added new method which returns SP context

  sql/sql_show.cc@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +404 -107
    WL#2822 INFORMATION_SCHEMA.ROUTINES: Add missing columns
    WL#2003 INFORMATION_SCHEMA: PARAMETERS view
    (2nd version)

  sql/table.h@stripped, 2007-06-07 16:02:56+05:00, gluh@stripped +1 -0
    WL#2822 INFORMATION_SCHEMA.ROUTINES: Add missing columns
    WL#2003 INFORMATION_SCHEMA: PARAMETERS view
    (2nd version)

# 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:	gluh
# Host:	eagle.(none)
# Root:	/home/gluh/MySQL/WL/5.1.2822

--- 1.398/sql/sql_show.cc	2007-03-14 18:42:50 +04:00
+++ 1.399/sql/sql_show.cc	2007-06-07 16:02:56 +05:00
@@ -22,6 +22,7 @@
 #include "repl_failsafe.h"
 #include "sp.h"
 #include "sp_head.h"
+#include "sp_pcontext.h"
 #include "sql_trigger.h"
 #include "authors.h"
 #include "contributors.h"
@@ -3020,6 +3021,113 @@ static int get_schema_tables_record(THD 
 }
 
 
+/**
+  @brief    Store field characteristics into appropriate I_S table columns
+
+  @details  Store field characteristics into appropriate I_S table columns
+
+  @param[in]      table             I_S table
+  @param[in]      field             processed field
+  @param[in]      cs                I_S table charset
+  @param[in]      offset            offset from beginning of table
+                                    to DATE_TYPE column in I_S table
+                                    
+  @return         void
+    @retval
+    @retval
+*/
+
+void store_column_type(TABLE *table, Field *field, CHARSET_INFO *cs,
+                       uint offset)
+{
+  bool is_blob;
+  int decimals, field_length;
+  const char *tmp_buff;
+  char tmp[MAX_FIELD_WIDTH];
+  String type(tmp,sizeof(tmp), system_charset_info);
+
+  field->sql_type(type);
+  table->field[offset + 7]->store(type.ptr(), type.length(), cs);
+  table->field[offset + 7]->set_notnull();
+  tmp_buff= strchr(type.ptr(), '(');
+  table->field[offset]->store(type.ptr(),
+                         (tmp_buff ? tmp_buff - type.ptr() :
+                          type.length()), cs);
+  is_blob= (field->type() == MYSQL_TYPE_BLOB);
+  if (field->has_charset() || is_blob ||
+      field->real_type() == MYSQL_TYPE_VARCHAR ||  // For varbinary type
+      field->real_type() == MYSQL_TYPE_STRING)     // For binary type
+  {
+    uint32 octet_max_length= field->max_display_length();
+    if (is_blob && octet_max_length != (uint32) 4294967295U)
+      octet_max_length /= field->charset()->mbmaxlen;
+    longlong char_max_len= is_blob ? 
+      (longlong) octet_max_length / field->charset()->mbminlen :
+      (longlong) octet_max_length / field->charset()->mbmaxlen;
+    table->field[offset + 1]->store(char_max_len, TRUE);
+    table->field[offset + 1]->set_notnull();
+    table->field[offset + 2]->store((longlong) octet_max_length, TRUE);
+    table->field[offset + 2]->set_notnull();
+  }
+
+  /*
+    Calculate field_length and decimals.
+    They are set to -1 if they should not be set (we should return NULL)
+  */
+
+  decimals= field->decimals();
+  switch (field->type()) {
+  case MYSQL_TYPE_NEWDECIMAL:
+    field_length= ((Field_new_decimal*) field)->precision;
+    break;
+  case MYSQL_TYPE_DECIMAL:
+    field_length= field->field_length - (decimals  ? 2 : 1);
+    break;
+  case MYSQL_TYPE_TINY:
+  case MYSQL_TYPE_SHORT:
+  case MYSQL_TYPE_LONG:
+  case MYSQL_TYPE_LONGLONG:
+  case MYSQL_TYPE_INT24:
+    field_length= field->max_display_length() - 1;
+    break;
+  case MYSQL_TYPE_BIT:
+    field_length= field->max_display_length();
+    decimals= -1;                             // return NULL
+    break;
+  case MYSQL_TYPE_FLOAT:  
+  case MYSQL_TYPE_DOUBLE:
+    field_length= field->field_length;
+    if (decimals == NOT_FIXED_DEC)
+      decimals= -1;                           // return NULL
+    break;
+  default:
+    field_length= decimals= -1;
+    break;
+  }
+
+  if (field_length >= 0)
+  {
+    table->field[offset + 3]->store((longlong) field_length, TRUE);
+    table->field[offset + 3]->set_notnull();
+  }
+  if (decimals >= 0)
+  {
+    table->field[offset + 4]->store((longlong) decimals, TRUE);
+    table->field[offset + 4]->set_notnull();
+  }
+
+  if (field->has_charset())
+  {
+    tmp_buff= field->charset()->csname;
+    table->field[offset + 5]->store(tmp_buff, strlen(tmp_buff), cs);
+    table->field[offset + 5]->set_notnull();
+    tmp_buff= field->charset()->name;
+    table->field[offset + 6]->store(tmp_buff, strlen(tmp_buff), cs);
+    table->field[offset + 6]->set_notnull();
+  }
+}
+
+
 static int get_schema_column_record(THD *thd, struct st_table_list *tables,
 				    TABLE *table, bool res,
 				    const char *base_name,
@@ -3062,21 +3170,14 @@ static int get_schema_column_record(THD 
 
   for (ptr=show_table->field; (field= *ptr) ; ptr++)
   {
-    const char *tmp_buff;
     byte *pos;
-    bool is_blob;
-    uint flags=field->flags;
     char tmp[MAX_FIELD_WIDTH];
-    char tmp1[MAX_FIELD_WIDTH];
-    String type(tmp,sizeof(tmp), system_charset_info);
     char *end;
-    int decimals, field_length;
 
     if (wild && wild[0] &&
         wild_case_compare(system_charset_info, field->field_name,wild))
       continue;
 
-    flags= field->flags;
     count++;
     /* Get default row, with all NULL fields set to NULL */
     restore_record(table, s->default_values);
@@ -3108,12 +3209,7 @@ static int get_schema_column_record(THD 
     table->field[3]->store(field->field_name, strlen(field->field_name),
                            cs);
     table->field[4]->store((longlong) count, TRUE);
-    field->sql_type(type);
-    table->field[14]->store(type.ptr(), type.length(), cs);		
-    tmp_buff= strchr(type.ptr(), '(');
-    table->field[7]->store(type.ptr(),
-                           (tmp_buff ? tmp_buff - type.ptr() :
-                            type.length()), cs);
+
     if (show_table->timestamp_field == field &&
         field->unireg_check != Field::TIMESTAMP_UN_FIELD)
     {
@@ -3124,8 +3220,9 @@ static int get_schema_column_record(THD 
              !field->is_null() &&
              !(field->flags & NO_DEFAULT_VALUE_FLAG))
     {
+      char tmp1[MAX_FIELD_WIDTH];
+      String type(tmp,sizeof(tmp), field->charset());
       String def(tmp1,sizeof(tmp1), cs);
-      type.set(tmp, sizeof(tmp), field->charset());
       field->val_str(&type);
       uint dummy_errors;
       def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
@@ -3141,83 +3238,11 @@ static int get_schema_column_record(THD 
       table->field[5]->store("",0, cs);
       table->field[5]->set_notnull();
     }
-    pos=(byte*) ((flags & NOT_NULL_FLAG) ?  "NO" : "YES");
+    pos=(byte*) ((field->flags & NOT_NULL_FLAG) ?  "NO" : "YES");
     table->field[6]->store((const char*) pos,
                            strlen((const char*) pos), cs);
-    is_blob= (field->type() == MYSQL_TYPE_BLOB);
-    if (field->has_charset() || is_blob ||
-        field->real_type() == MYSQL_TYPE_VARCHAR ||  // For varbinary type
-        field->real_type() == MYSQL_TYPE_STRING)     // For binary type
-    {
-      uint32 octet_max_length= field->max_display_length();
-      if (is_blob && octet_max_length != (uint32) 4294967295U)
-        octet_max_length /= field->charset()->mbmaxlen;
-      longlong char_max_len= is_blob ? 
-        (longlong) octet_max_length / field->charset()->mbminlen :
-        (longlong) octet_max_length / field->charset()->mbmaxlen;
-      table->field[8]->store(char_max_len, TRUE);
-      table->field[8]->set_notnull();
-      table->field[9]->store((longlong) octet_max_length, TRUE);
-      table->field[9]->set_notnull();
-    }
-
-    /*
-      Calculate field_length and decimals.
-      They are set to -1 if they should not be set (we should return NULL)
-    */
+    store_column_type(table, field, cs, 7);
 
-    decimals= field->decimals();
-    switch (field->type()) {
-    case MYSQL_TYPE_NEWDECIMAL:
-      field_length= ((Field_new_decimal*) field)->precision;
-      break;
-    case MYSQL_TYPE_DECIMAL:
-      field_length= field->field_length - (decimals  ? 2 : 1);
-      break;
-    case MYSQL_TYPE_TINY:
-    case MYSQL_TYPE_SHORT:
-    case MYSQL_TYPE_LONG:
-    case MYSQL_TYPE_LONGLONG:
-    case MYSQL_TYPE_INT24:
-      field_length= field->max_display_length() - 1;
-      break;
-    case MYSQL_TYPE_BIT:
-      field_length= field->max_display_length();
-      decimals= -1;                             // return NULL
-      break;
-    case MYSQL_TYPE_FLOAT:  
-    case MYSQL_TYPE_DOUBLE:
-      field_length= field->field_length;
-      if (decimals == NOT_FIXED_DEC)
-        decimals= -1;                           // return NULL
-    break;
-    default:
-      field_length= decimals= -1;
-      break;
-    }
-
-    if (field_length >= 0)
-    {
-      table->field[10]->store((longlong) field_length, TRUE);
-      table->field[10]->set_notnull();
-    }
-    if (decimals >= 0)
-    {
-      table->field[11]->store((longlong) decimals, TRUE);
-      table->field[11]->set_notnull();
-    }
-
-    if (field->has_charset())
-    {
-      pos=(byte*) field->charset()->csname;
-      table->field[12]->store((const char*) pos,
-                              strlen((const char*) pos), cs);
-      table->field[12]->set_notnull();
-      pos=(byte*) field->charset()->name;
-      table->field[13]->store((const char*) pos,
-                              strlen((const char*) pos), cs);
-      table->field[13]->set_notnull();
-    }
     pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
                  (field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
                  (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
@@ -3388,10 +3413,217 @@ int fill_schema_coll_charset_app(THD *th
 }
 
 
+/**
+  @brief    The function parses input string and returns SP stucture.
+
+  @details  The function parses input string and returns SP stucture.
+
+  @param[in]      table             I_S table
+  @param[in]      field             processed field
+  @param[in]      cs                I_S table charset
+                                    to DATE_TYPE column in I_S table
+                                    
+  @return     Pointer on sp_head struct
+    @retval   #                     Pointer on sp_head struct
+    @retval   0                     error
+*/
+
+static sp_head *proc_compile(THD *thd, const char *defstr, uint defstr_length)
+{
+  sp_head *sp;
+  LEX *old_lex= thd->lex, newlex;
+  ulong old_sql_mode= thd->variables.sql_mode;
+  ha_rows old_select_limit= thd->variables.select_limit;
+  sp_rcontext *old_spcont= thd->spcont;
+
+  thd->variables.sql_mode= 0;
+  thd->variables.select_limit= HA_POS_ERROR;
+
+  thd->lex= &newlex;
+  newlex.current_select= NULL;
+
+  lex_start(thd, (uchar*)defstr, defstr_length);
+
+  if (MYSQLparse(thd) || thd->is_fatal_error || newlex.sphead == NULL)
+  {
+    sp= newlex.sphead;
+    delete sp;
+    sp= 0;
+  }
+  else
+    sp= newlex.sphead;
+
+  lex_end(thd->lex);
+  thd->spcont= old_spcont;
+  thd->variables.sql_mode= old_sql_mode;
+  thd->variables.select_limit= old_select_limit;
+  thd->lex= old_lex;
+  return sp;
+}
+
+
+/**
+  @brief Store record into I_S.PARAMETERS table
+
+  @details Store record into I_S.PARAMETERS table
+
+  @param[in]      thd                   thread handler
+  @param[in]      table                 I_S table
+  @param[in]      proc_table            'mysql.proc' table
+  @param[in]      wild                  wild string, not used for now,
+                                        will be useful
+                                        if we add 'SHOW PARAMETERs'
+  @param[in]      full_access           if 1 user has privileges on the routine
+  @param[in]      sp_user               user in 'user@host' format
+
+  @return Operation status
+    @retval       0                     ok
+    @retval       1                     error
+*/
+
+bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
+                         const char *wild, bool full_access,
+                         const char *sp_user)
+{
+  TABLE_SHARE share;
+  TABLE tbl;
+  CHARSET_INFO *cs= system_charset_info;
+  char tmp1[MAX_FIELD_WIDTH], tmp2[MAX_FIELD_WIDTH],
+    tmp3[NAME_LEN], tmp4[NAME_LEN], path[FN_REFLEN],
+    tmp5[USERNAME_LENGTH + HOSTNAME_LENGTH + 1];
+  String tmp_string1(tmp1, sizeof(tmp1), cs);
+  String tmp_string2(tmp2, sizeof(tmp2), cs);
+  String sp_db(tmp3, sizeof(tmp3), cs);
+  String sp_name(tmp4, sizeof(tmp4), cs);
+  String definer(tmp5, sizeof(tmp5), cs);
+  sp_head *sp;
+  uint routine_type;
+  DBUG_ENTER("store_schema_params");
+
+  bzero((char*) &tbl, sizeof(TABLE));
+  (void) build_table_filename(path, sizeof(path), "", "", "", 0);
+  init_tmp_table_share(&share, "", 0, "", path);
+
+  get_field(thd->mem_root, proc_table->field[0], &sp_db);
+  get_field(thd->mem_root, proc_table->field[1], &sp_name);
+  get_field(thd->mem_root, proc_table->field[11], &definer);
+  routine_type= proc_table->field[2]->val_int();
+
+  if (!full_access)
+    full_access= !strcmp(sp_user, definer.ptr());
+  if (!full_access &&
+      check_some_routine_access(thd, sp_db.ptr(),sp_name.ptr(),
+                                routine_type == TYPE_ENUM_PROCEDURE))
+    return 0;
+
+  tmp_string1.length(0);
+  get_field(thd->mem_root, proc_table->field[8], &tmp_string1);
+  tmp_string2.length(0);
+  if (routine_type == TYPE_ENUM_FUNCTION)
+  {
+    tmp_string2.append("CREATE FUNCTION F(");
+    tmp_string2.append(tmp_string1.ptr());
+    tmp_string2.append(") RETURNS ");
+    tmp_string1.length(0);
+    get_field(thd->mem_root, proc_table->field[9], &tmp_string1);
+    tmp_string2.append(tmp_string1.ptr());
+    tmp_string2.append(" RETURN NULL");
+  }
+  else
+  {
+    tmp_string2.append("CREATE PROCEDURE F(");
+    tmp_string2.append(tmp_string1.ptr());
+    tmp_string2.append(") BEGIN END");
+  }
+
+  sp= proc_compile(thd, tmp_string2.ptr(), tmp_string2.length());
+  if (sp)
+  {
+    Field *field;
+    create_field *field_def;
+
+    if (routine_type == TYPE_ENUM_FUNCTION)
+    {
+      restore_record(table, s->default_values);
+      table->field[1]->store(sp_db.ptr(), sp_db.length(), cs);
+      table->field[2]->store(sp_name.ptr(), sp_name.length(), cs);
+      table->field[3]->store((longlong) 0, TRUE);
+      field_def= &sp->m_return_field_def;
+      field= make_field(&share, (char*) 0, field_def->length,
+                        (uchar*) "", 0, field_def->pack_flag,
+                        field_def->sql_type, field_def->charset,
+                        field_def->geom_type, Field::NONE,
+                        field_def->interval, "");
+
+      field->table= &tbl;
+      tbl.in_use= thd;
+      store_column_type(table, field, cs, 6);
+      if (schema_table_store_record(thd, table))
+      {
+        free_table_share(&share);
+        delete sp;
+        DBUG_RETURN(1);
+      }
+    }
+
+    sp_pcontext *spcont= sp->get_parse_context();
+    uint params= spcont->context_var_count();
+    for (uint i= 0 ; i < params ; i++)
+    {
+      const char *tmp_buff;
+      sp_variable_t *spvar= spcont->find_variable(i);
+      field_def= &spvar->field_def;
+      switch (spvar->mode) {
+      case sp_param_in:
+        tmp_buff= "IN";
+        break;
+      case sp_param_out:
+        tmp_buff= "OUT";
+        break;
+      case sp_param_inout:
+        tmp_buff= "INOUT";
+        break;
+      default:
+        tmp_buff= "";
+        break;
+      }  
+
+      restore_record(table, s->default_values);
+      table->field[1]->store(sp_db.ptr(), sp_db.length(), cs);
+      table->field[2]->store(sp_name.ptr(), sp_name.length(), cs);
+      table->field[3]->store((longlong) i + 1, TRUE);
+      table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
+      table->field[4]->set_notnull();
+      table->field[5]->store(spvar->name.str, spvar->name.length, cs);
+      table->field[5]->set_notnull();
+
+      field= make_field(&share, (char*) 0, field_def->length,
+                        (uchar*) "", 0, field_def->pack_flag,
+                        field_def->sql_type, field_def->charset,
+                        field_def->geom_type, Field::NONE,
+                        field_def->interval, spvar->name.str);
+
+      field->table= &tbl;
+      tbl.in_use= thd;
+      store_column_type(table, field, cs, 6);
+      if (schema_table_store_record(thd, table))
+      {
+        free_table_share(&share);
+        delete sp;
+        DBUG_RETURN(1);
+      }
+    }
+    delete sp;
+  }
+  free_table_share(&share);
+  DBUG_RETURN(0);
+}
+
+
 bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
                        const char *wild, bool full_access, const char *sp_user)
 {
-  String tmp_string;
+  String tmp_string, tmp_string2;
   String sp_db, sp_name, definer;
   TIME time;
   LEX *lex= thd->lex;
@@ -3426,35 +3658,63 @@ bool store_schema_proc(THD *thd, TABLE *
       table->field[4]->store(tmp_string.ptr(), tmp_string.length(), cs);
       if (proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION)
       {
+        sp_head *sp;
         get_field(thd->mem_root, proc_table->field[9], &tmp_string);
-        table->field[5]->store(tmp_string.ptr(), tmp_string.length(), cs);
-        table->field[5]->set_notnull();
+        tmp_string2.length(0);
+        tmp_string2.append("CREATE FUNCTION F(F INT) RETURNS ");
+        tmp_string2.append(tmp_string.ptr());
+        tmp_string2.append(" RETURN NULL");
+        sp= proc_compile(thd, tmp_string2.ptr(), tmp_string2.length());
+        if (sp)
+        {
+          char path[FN_REFLEN];
+          TABLE_SHARE share;
+          TABLE tbl;
+          Field *field;
+          create_field *field_def= &sp->m_return_field_def;
+
+          bzero((char*) &tbl, sizeof(TABLE));
+          (void) build_table_filename(path, sizeof(path), "", "", "", 0);
+          init_tmp_table_share(&share, "", 0, "", path);
+          field= make_field(&share, (char*) 0, field_def->length,
+                            (uchar*) "", 0, field_def->pack_flag,
+                            field_def->sql_type, field_def->charset,
+                            field_def->geom_type, Field::NONE,
+                            field_def->interval, "");
+
+          field->table= &tbl;
+          tbl.in_use= thd;
+          store_column_type(table, field, cs, 5);
+          free_table_share(&share);
+          delete sp;
+        }
       }
+
       if (full_access)
       {
         get_field(thd->mem_root, proc_table->field[10], &tmp_string);
-        table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
-        table->field[7]->set_notnull();
+        table->field[14]->store(tmp_string.ptr(), tmp_string.length(), cs);
+        table->field[14]->set_notnull();
       }
-      table->field[6]->store(STRING_WITH_LEN("SQL"), cs);
-      table->field[10]->store(STRING_WITH_LEN("SQL"), cs);
+      table->field[13]->store(STRING_WITH_LEN("SQL"), cs);
+      table->field[17]->store(STRING_WITH_LEN("SQL"), cs);
       get_field(thd->mem_root, proc_table->field[6], &tmp_string);
-      table->field[11]->store(tmp_string.ptr(), tmp_string.length(), cs);
-      table->field[12]->store(sp_data_access_name[enum_idx].str, 
+      table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
+      table->field[19]->store(sp_data_access_name[enum_idx].str, 
                               sp_data_access_name[enum_idx].length , cs);
       get_field(thd->mem_root, proc_table->field[7], &tmp_string);
-      table->field[14]->store(tmp_string.ptr(), tmp_string.length(), cs);
+      table->field[21]->store(tmp_string.ptr(), tmp_string.length(), cs);
       bzero((char *)&time, sizeof(time));
       ((Field_timestamp *) proc_table->field[12])->get_time(&time);
-      table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+      table->field[22]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
       bzero((char *)&time, sizeof(time));
       ((Field_timestamp *) proc_table->field[13])->get_time(&time);
-      table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+      table->field[23]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
       get_field(thd->mem_root, proc_table->field[14], &tmp_string);
-      table->field[17]->store(tmp_string.ptr(), tmp_string.length(), cs);
+      table->field[24]->store(tmp_string.ptr(), tmp_string.length(), cs);
       get_field(thd->mem_root, proc_table->field[15], &tmp_string);
-      table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
-      table->field[19]->store(definer.ptr(), definer.length(), cs);
+      table->field[25]->store(tmp_string.ptr(), tmp_string.length(), cs);
+      table->field[26]->store(definer.ptr(), definer.length(), cs);
       return schema_table_store_record(thd, table);
     }
   }
@@ -3472,6 +3732,8 @@ int fill_schema_proc(THD *thd, TABLE_LIS
   bool full_access;
   char definer[USER_HOST_BUFF_SIZE];
   Open_tables_state open_tables_state_backup;
+  enum enum_schema_tables schema_table_idx=
+    get_schema_table_idx(tables->schema_table);
   DBUG_ENTER("fill_schema_proc");
 
   strxmov(definer, thd->security_ctx->priv_user, "@",
@@ -3494,14 +3756,19 @@ int fill_schema_proc(THD *thd, TABLE_LIS
     res= (res == HA_ERR_END_OF_FILE) ? 0 : 1;
     goto err;
   }
-  if (store_schema_proc(thd, table, proc_table, wild, full_access, definer))
+
+  if (schema_table_idx == SCH_PROCEDURES ?
+      store_schema_proc(thd, table, proc_table, wild, full_access, definer) :
+      store_schema_params(thd, table, proc_table, wild, full_access, definer))
   {
     res= 1;
     goto err;
   }
   while (!proc_table->file->index_next(proc_table->record[0]))
   {
-    if (store_schema_proc(thd, table, proc_table, wild, full_access, definer))
+    if (schema_table_idx == SCH_PROCEDURES ?
+        store_schema_proc(thd, table, proc_table, wild, full_access, definer): 
+        store_schema_params(thd, table, proc_table, wild, full_access, definer))
     {
       res= 1;
       goto err;
@@ -4563,6 +4830,7 @@ get_referential_constraints_record(THD *
   DBUG_RETURN(0);
 }
 
+
 struct schema_table_ref 
 {
   const char *table_name;
@@ -4893,7 +5161,7 @@ int make_character_sets_old_format(THD *
 
 int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
 {
-  int fields_arr[]= {2, 3, 4, 19, 16, 15, 14, 18, -1};
+  int fields_arr[]= {2, 3, 4, 26, 23, 22, 21, 25, -1};
   int *field_num= fields_arr;
   ST_FIELD_INFO *field_info;
   Name_resolution_context *context= &thd->lex->select_lex.context;
@@ -5454,7 +5722,14 @@ ST_FIELD_INFO proc_fields_info[]=
   {"ROUTINE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"},
   {"ROUTINE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
   {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"},
-  {"DTD_IDENTIFIER", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+  {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"DTD_IDENTIFIER", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
   {"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0},
   {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
   {"EXTERNAL_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
@@ -5783,6 +6058,26 @@ ST_FIELD_INFO referential_constraints_fi
 };
 
 
+ST_FIELD_INFO parameters_fields_info[]=
+{
+  {"SPECIFIC_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"SPECIFIC_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+  {"SPECIFIC_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+  {"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
+  {"PARAMETER_MODE", 5, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"PARAMETER_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+  {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},
+  {"DTD_IDENTIFIER", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+};
+
+
 /*
   Description of ST_FIELD_INFO in table.h
 
@@ -5816,6 +6111,8 @@ ST_SCHEMA_TABLE schema_tables[]=
     get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
   {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
    fill_open_tables, make_old_format, 0, -1, -1, 1},
+  {"PARAMETERS", parameters_fields_info, create_schema_table,
+   fill_schema_proc, 0, 0, -1, -1, 0},
   {"PARTITIONS", partitions_fields_info, create_schema_table,
    get_all_tables, 0, get_schema_partitions_record, 1, 2, 0},
   {"PLUGINS", plugin_fields_info, create_schema_table,

--- 1.163/sql/table.h	2007-03-17 03:13:19 +04:00
+++ 1.164/sql/table.h	2007-06-07 16:02:56 +05:00
@@ -527,6 +527,7 @@ enum enum_schema_tables
   SCH_GLOBAL_VARIABLES,
   SCH_KEY_COLUMN_USAGE,
   SCH_OPEN_TABLES,
+  SCH_PARAMETERS,
   SCH_PARTITIONS,
   SCH_PLUGINS,
   SCH_PROCESSLIST,

--- 1.147/mysql-test/r/information_schema.result	2007-02-14 01:15:18 +04:00
+++ 1.148/mysql-test/r/information_schema.result	2007-06-07 16:02:56 +05:00
@@ -47,6 +47,7 @@ FILES
 GLOBAL_STATUS
 GLOBAL_VARIABLES
 KEY_COLUMN_USAGE
+PARAMETERS
 PARTITIONS
 PLUGINS
 PROCESSLIST
@@ -762,11 +763,13 @@ information_schema	COLUMNS	COLUMN_TYPE
 information_schema	EVENTS	EVENT_DEFINITION
 information_schema	EVENTS	SQL_MODE
 information_schema	GLOBAL_VARIABLES	VARIABLE_VALUE
+information_schema	PARAMETERS	DTD_IDENTIFIER
 information_schema	PARTITIONS	PARTITION_EXPRESSION
 information_schema	PARTITIONS	SUBPARTITION_EXPRESSION
 information_schema	PARTITIONS	PARTITION_DESCRIPTION
 information_schema	PLUGINS	PLUGIN_DESCRIPTION
 information_schema	PROCESSLIST	INFO
+information_schema	ROUTINES	DTD_IDENTIFIER
 information_schema	ROUTINES	ROUTINE_DEFINITION
 information_schema	ROUTINES	SQL_MODE
 information_schema	SESSION_VARIABLES	VARIABLE_VALUE
@@ -852,7 +855,7 @@ delete from mysql.db where user='mysqlte
 flush privileges;
 SELECT table_schema, count(*) FROM information_schema.TABLES where table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
 table_schema	count(*)
-information_schema	27
+information_schema	28
 mysql	22
 create table t1 (i int, j int);
 create trigger trg1 before insert on t1 for each row
@@ -1248,6 +1251,7 @@ FILES	TABLE_SCHEMA
 GLOBAL_STATUS	VARIABLE_NAME
 GLOBAL_VARIABLES	VARIABLE_NAME
 KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
+PARAMETERS	SPECIFIC_SCHEMA
 PARTITIONS	TABLE_SCHEMA
 PLUGINS	PLUGIN_NAME
 PROCESSLIST	ID
@@ -1290,6 +1294,7 @@ FILES	TABLE_SCHEMA
 GLOBAL_STATUS	VARIABLE_NAME
 GLOBAL_VARIABLES	VARIABLE_NAME
 KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
+PARAMETERS	SPECIFIC_SCHEMA
 PARTITIONS	TABLE_SCHEMA
 PLUGINS	PLUGIN_NAME
 PROCESSLIST	ID
@@ -1383,6 +1388,7 @@ FILES	information_schema.FILES	1
 GLOBAL_STATUS	information_schema.GLOBAL_STATUS	1
 GLOBAL_VARIABLES	information_schema.GLOBAL_VARIABLES	1
 KEY_COLUMN_USAGE	information_schema.KEY_COLUMN_USAGE	1
+PARAMETERS	information_schema.PARAMETERS	1
 PARTITIONS	information_schema.PARTITIONS	1
 PLUGINS	information_schema.PLUGINS	1
 PROCESSLIST	information_schema.PROCESSLIST	1
@@ -1409,3 +1415,31 @@ user	db
 user3148	test
 drop user user3148@localhost;
 End of 5.1 tests.
+create function f1 (p1 int, p2 datetime, p3 decimal(10,2))
+returns char(10) return null;
+create procedure p1 (p1 float(8,5), p2 char(32), p3 varchar(10)) begin end;
+create procedure p2 (p1 enum('c', 's'), p2 blob, p3 text) begin end;
+select * from information_schema.parameters;
+SPECIFIC_CATALOG	SPECIFIC_SCHEMA	SPECIFIC_NAME	ORDINAL_POSITION	PARAMETER_MODE	PARAMETER_NAME	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	DTD_IDENTIFIER
+NULL	test	f1	0	NULL	NULL	char	10	10	NULL	NULL	latin1	latin1_swedish_ci	char(10)
+NULL	test	f1	1	IN	p1	int	NULL	NULL	10	0	NULL	NULL	int(11)
+NULL	test	f1	2	IN	p2	datetime	NULL	NULL	NULL	NULL	NULL	NULL	datetime
+NULL	test	f1	3	IN	p3	decimal	NULL	NULL	10	2	NULL	NULL	decimal(10,2)
+NULL	test	p1	1	IN	p1	float	NULL	NULL	8	5	NULL	NULL	float(8,5)
+NULL	test	p1	2	IN	p2	char	32	32	NULL	NULL	latin1	latin1_swedish_ci	char(32)
+NULL	test	p1	3	IN	p3	varchar	10	10	NULL	NULL	latin1	latin1_swedish_ci	varchar(10)
+NULL	test	p2	1	IN	p1	enum	1	1	NULL	NULL	latin1	latin1_swedish_ci	enum('c','s')
+NULL	test	p2	2	IN	p2	blob	65535	65535	NULL	NULL	NULL	NULL	blob
+NULL	test	p2	3	IN	p3	text	65535	65535	NULL	NULL	latin1	latin1_swedish_ci	text
+select data_type, character_maximum_length,
+character_octet_length, numeric_precision,
+numeric_scale, character_set_name,
+collation_name, dtd_identifier
+from information_schema.routines;
+data_type	character_maximum_length	character_octet_length	numeric_precision	numeric_scale	character_set_name	collation_name	dtd_identifier
+char	10	10	NULL	NULL	latin1	latin1_swedish_ci	char(10)
+	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+drop procedure p1;
+drop procedure p2;
+drop function f1;

--- 1.94/mysql-test/t/information_schema.test	2007-02-13 13:34:32 +04:00
+++ 1.95/mysql-test/t/information_schema.test	2007-06-07 16:02:56 +05:00
@@ -1044,3 +1044,22 @@ drop user user3148@localhost;
 
 --echo End of 5.1 tests.
 
+#
+# WL#2003 INFORMATION_SCHEMA: PARAMETERS view
+# WL#2822 INFORMATION_SCHEMA.ROUTINES: Add missing columns
+#
+
+create function f1 (p1 int, p2 datetime, p3 decimal(10,2))
+returns char(10) return null;
+create procedure p1 (p1 float(8,5), p2 char(32), p3 varchar(10)) begin end;
+create procedure p2 (p1 enum('c', 's'), p2 blob, p3 text) begin end;
+select * from information_schema.parameters;
+select data_type, character_maximum_length,
+       character_octet_length, numeric_precision,
+       numeric_scale, character_set_name,
+       collation_name, dtd_identifier
+from information_schema.routines;
+
+drop procedure p1;
+drop procedure p2;
+drop function f1;

--- 1.19/mysql-test/r/information_schema_db.result	2007-03-06 21:29:51 +04:00
+++ 1.20/mysql-test/r/information_schema_db.result	2007-06-07 16:02:56 +05:00
@@ -16,6 +16,7 @@ FILES
 GLOBAL_STATUS
 GLOBAL_VARIABLES
 KEY_COLUMN_USAGE
+PARAMETERS
 PARTITIONS
 PLUGINS
 PROCESSLIST

--- 1.6/mysql-test/r/mysqlshow.result	2006-09-14 06:35:47 +05:00
+++ 1.7/mysql-test/r/mysqlshow.result	2007-06-07 16:02:56 +05:00
@@ -90,6 +90,7 @@ Database: information_schema
 | GLOBAL_STATUS                         |
 | GLOBAL_VARIABLES                      |
 | KEY_COLUMN_USAGE                      |
+| PARAMETERS                            |
 | PARTITIONS                            |
 | PLUGINS                               |
 | PROCESSLIST                           |
@@ -122,6 +123,7 @@ Database: INFORMATION_SCHEMA
 | GLOBAL_STATUS                         |
 | GLOBAL_VARIABLES                      |
 | KEY_COLUMN_USAGE                      |
+| PARAMETERS                            |
 | PARTITIONS                            |
 | PLUGINS                               |
 | PROCESSLIST                           |

--- 1.256/mysql-test/r/sp.result	2007-03-09 13:39:49 +04:00
+++ 1.257/mysql-test/r/sp.result	2007-06-07 16:02:56 +05:00
@@ -5087,26 +5087,26 @@ SHOW CREATE FUNCTION mysqltest2.bug16211
 Function	sql_mode	Create Function
 bug16211_f4		CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r
 RETURN ""
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
-dtd_identifier
-char(10) CHARSET utf8
-SELECT dtd_identifier
+dtd_identifier	character_set_name
+char(10)	utf8
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
-dtd_identifier
-char(10) CHARSET koi8r
-SELECT dtd_identifier
+dtd_identifier	character_set_name
+char(10)	koi8r
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
-dtd_identifier
-char(10) CHARSET utf8
-SELECT dtd_identifier
+dtd_identifier	character_set_name
+char(10)	utf8
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
-dtd_identifier
-char(10) CHARSET koi8r
+dtd_identifier	character_set_name
+char(10)	koi8r
 SELECT CHARSET(bug16211_f1())|
 CHARSET(bug16211_f1())
 utf8
@@ -5137,26 +5137,26 @@ SHOW CREATE FUNCTION mysqltest2.bug16211
 Function	sql_mode	Create Function
 bug16211_f4		CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r
 RETURN ""
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
-dtd_identifier
-char(10) CHARSET utf8
-SELECT dtd_identifier
+dtd_identifier	character_set_name
+char(10)	utf8
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
-dtd_identifier
-char(10) CHARSET koi8r
-SELECT dtd_identifier
+dtd_identifier	character_set_name
+char(10)	koi8r
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
-dtd_identifier
-char(10) CHARSET utf8
-SELECT dtd_identifier
+dtd_identifier	character_set_name
+char(10)	utf8
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
-dtd_identifier
-char(10) CHARSET koi8r
+dtd_identifier	character_set_name
+char(10)	koi8r
 SELECT CHARSET(bug16211_f1())|
 CHARSET(bug16211_f1())
 utf8

--- 1.223/mysql-test/t/sp.test	2007-03-09 13:39:37 +04:00
+++ 1.224/mysql-test/t/sp.test	2007-06-07 16:02:56 +05:00
@@ -6006,19 +6006,19 @@ SHOW CREATE FUNCTION bug16211_f2|
 SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
 SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
 
@@ -6041,19 +6041,19 @@ SHOW CREATE FUNCTION bug16211_f2|
 SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
 SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
 
-SELECT dtd_identifier
+SELECT dtd_identifier, character_set_name
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
 

--- 1.99/sql/sp_head.h	2007-03-08 03:02:32 +04:00
+++ 1.100/sql/sp_head.h	2007-06-07 16:02:56 +05:00
@@ -382,6 +382,7 @@ public:
       lex->binlog_row_based_if_mixed= TRUE;
   }
 
+  sp_pcontext *get_parse_context() { return m_pcont; }
 
 private:
 
Thread
bk commit into 5.1 tree (gluh:1.2506)gluh7 Jun