private static string GetString(MyCatDataReader reader, int index)
 {
     if (reader.IsDBNull(index))
     {
         return(null);
     }
     return(reader.GetString(index));
 }
        private string GetProcedureParameterLine(MyCatSchemaRow isRow)
        {
            string sql = "SHOW CREATE {0} `{1}`.`{2}`";

            sql = String.Format(sql, isRow["ROUTINE_TYPE"], isRow["ROUTINE_SCHEMA"],
                                isRow["ROUTINE_NAME"]);
            MyCatCommand cmd = new MyCatCommand(sql, connection);

            using (MyCatDataReader reader = cmd.ExecuteReader())
            {
                reader.Read();

                // if we are not the owner of this proc or have permissions
                // then we will get null for the body
                if (reader.IsDBNull(2))
                {
                    return(null);
                }

                string sql_mode = reader.GetString(1);

                string         body      = reader.GetString(2);
                MyCatTokenizer tokenizer = new MyCatTokenizer(body);
                tokenizer.AnsiQuotes       = sql_mode.IndexOf("ANSI_QUOTES") != -1;
                tokenizer.BackslashEscapes = sql_mode.IndexOf("NO_BACKSLASH_ESCAPES") == -1;

                string token = tokenizer.NextToken();
                while (token != "(")
                {
                    token = tokenizer.NextToken();
                }
                int start = tokenizer.StartIndex + 1;
                token = tokenizer.NextToken();
                while (token != ")" || tokenizer.Quoted)
                {
                    token = tokenizer.NextToken();
                    // if we see another ( and we are not quoted then we
                    // are in a size element and we need to look for the closing paren
                    if (token == "(" && !tokenizer.Quoted)
                    {
                        while (token != ")" || tokenizer.Quoted)
                        {
                            token = tokenizer.NextToken();
                        }
                        token = tokenizer.NextToken();
                    }
                }
                return(body.Substring(start, tokenizer.StartIndex - start));
            }
        }