Beispiel #1
0
        private DataTable CachedLoadProgrammable(NameWithSchema obj)
        {
            var res = AnalyserCache.GetProgrammable(obj);

            if (res != null)
            {
                return(res);
            }
            res = AnalyserCache.GetProgrammable(null);
            if (res != null)
            {
                return(FilterProgrammable(res, obj));
            }
            if (LoadMoreSpecificObjects)
            {
                res = LoadProgrammableTable(null);
                AnalyserCache.PutProgrammable(null, res);
                return(FilterProgrammable(res, obj));
            }
            else
            {
                res = LoadProgrammableTable(obj);
                AnalyserCache.PutProgrammable(obj, res);
                return(res);
            }
        }
Beispiel #2
0
        private TableAnalyser GetRefsTA()
        {
            var res = AnalyserCache.GetTableAnalyser("refs");

            if (res != null)
            {
                return(res);
            }
            var ta = new TableAnalyser();

            foreach (var row in CachedQueryRows(SqlScripts.getrefs))
            {
                var key = new TableAnalyser.Key();
                key.keytype = "FOREIGN KEY";

                key.deleterule = row.SafeString("DELETE_RULE");

                key.keyname   = row["FK_CONSTRAINT"].ToString();
                key.tblname   = row["FK_TABLE"].ToString();
                key.tblschema = row["FK_OWNER"].ToString();

                key.dstpkschema = row["R_OWNER"].ToString();
                key.dstpkname   = row["R_CONSTRAINT"].ToString();

                key.dsttblschema = row["R_OWNER"].ToString();
                key.dsttblname   = row["R_TABLE"].ToString();

                ta.keys.Add(key);
            }

            foreach (var row in CachedQueryRows(SqlScripts.getrefcols))
            {
                var col = new TableAnalyser.Col();
                col.keytype = "FOREIGN KEY";

                col.keyname   = row["FK_CONSTRAINT"].ToString();
                col.tblname   = row["FK_TABLE"].ToString();
                col.tblschema = row["FK_OWNER"].ToString();
                col.colname   = row["FK_COLUMN_NAME"].ToString();

                col.dstcolname = row["R_COLUMN_NAME"].ToString();

                ta.cols.Add(col);
            }

            AnalyserCache.PutTableAnalyser("refs", ta);
            return(ta);
        }
Beispiel #3
0
        private TableAnalyser GetIndexesTA()
        {
            var res = AnalyserCache.GetTableAnalyser("indexes");

            if (res != null)
            {
                return(res);
            }
            var ta = new TableAnalyser();

            ta.AllowDeduceFromColumns = false;
            foreach (var row in CachedQueryRows(SqlScripts.getindexes))
            {
                var key = new TableAnalyser.Key();
                key.keytype = "INDEX";

                key.keyname   = row["INDEX_NAME"].ToString();
                key.keyschema = row["TABLE_OWNER"].ToString();

                key.tblname   = row["TABLE_NAME"].ToString();
                key.tblschema = row["TABLE_OWNER"].ToString();

                key.keyisunique = row["UNIQUENESS"].SafeToString() == "UNIQUE";

                ta.keys.Add(key);
            }

            foreach (var row in CachedQueryRows(SqlScripts.getindexcols))
            {
                var col = new TableAnalyser.Col();
                col.keytype = "INDEX";

                col.keyschema = row["USERNAME"].ToString();
                col.keyname   = row["INDEX_NAME"].ToString();
                col.colname   = row["COLUMN_NAME"].ToString();

                col.ordinal = row["COLUMN_POSITION"].ToString();

                ta.cols.Add(col);
            }

            AnalyserCache.PutTableAnalyser("indexes", ta);
            return(ta);
        }
Beispiel #4
0
        private string CachedGetShowTable(string table)
        {
            string data = AnalyserCache.GetShowTable(table);

            if (data == null)
            {
                using (DbCommand cmd = GetDbConn().CreateCommand())
                {
                    cmd.CommandText = String.Format("SHOW CREATE TABLE `{0}`", table);
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            throw new InternalError("DAE-00056 Error reading MySQL table, empty result of SHOW CREATE TABLE");
                        }
                        data = reader[1].SafeToString();
                        AnalyserCache.PutShowTable(table, data);
                    }
                }
            }
            return(data);
        }