Esempio n. 1
0
        public virtual List <MyCatError> ReportWarnings(MyCatConnection connection)
        {
            List <MyCatError> warnings = new List <MyCatError>();

            MyCatCommand cmd = new MyCatCommand("SHOW WARNINGS", connection);

            cmd.InternallyCreated = true;
            using (MyCatDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    warnings.Add(new MyCatError(reader.GetString(0),
                                                reader.GetInt32(1), reader.GetString(2)));
                }
            }

            MyCatInfoMessageEventArgs args = new MyCatInfoMessageEventArgs();

            args.errors = warnings.ToArray();
            if (connection != null)
            {
                connection.OnInfoMessage(args);
            }
            return(warnings);
        }
        public virtual MyCatSchemaCollection GetUDF(string[] restrictions)
        {
            string sql = "SELECT name,ret,dl FROM mysql.func";

            if (restrictions != null)
            {
                if (restrictions.Length >= 1 && !String.IsNullOrEmpty(restrictions[0]))
                {
                    sql += String.Format(" WHERE name LIKE '{0}'", restrictions[0]);
                }
            }

            MyCatSchemaCollection dt = new MyCatSchemaCollection("User-defined Functions");

            dt.AddColumn("NAME", typeof(string));
            dt.AddColumn("RETURN_TYPE", typeof(int));
            dt.AddColumn("LIBRARY_NAME", typeof(string));

            MyCatCommand cmd = new MyCatCommand(sql, connection);

            try
            {
                using (MyCatDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        MyCatSchemaRow row = dt.AddRow();
                        row[0] = reader.GetString(0);
                        row[1] = reader.GetInt32(1);
                        row[2] = reader.GetString(2);
                    }
                }
            }
            catch (MyCatException ex)
            {
                if (ex.Number != (int)MyCatErrorCode.TableAccessDenied)
                {
                    throw;
                }
                throw new MyCatException(Resources.UnableToEnumerateUDF, ex);
            }

            return(dt);
        }