Exemplo n.º 1
0
        private ITableStructure CreateTargetStructure()
        {
            TableStructure table = new TableStructure();

            foreach (DataGridViewRow row in lbtarget.Rows)
            {
                var type = GetExprType(row);
                if (type == null)
                {
                    continue;
                }
                if (type is GenericTransform.ColumnColExprType)
                {
                    string oldcol = row.Cells[2].Value.ToString();
                    if (m_srcformat.Columns.GetIndex(oldcol) < 0)
                    {
                        throw new IncorrectObjectReferenceError("DAE-00185", "s_column", oldcol);
                    }
                    var coldef = new ColumnStructure(m_srcformat.Columns[oldcol]);
                    coldef.ColumnName = row.Cells[0].Value.ToString();
                    table.AddColumn(coldef, true);
                }
                else if (type is GenericTransform.RowNumberColExprType)
                {
                    var col = new ColumnStructure();
                    col.ColumnName = row.Cells[0].Value.ToString();
                    col.DataType   = new DbTypeInt();
                    table._Columns.Add(col);
                    if (table.FindConstraint <IPrimaryKey>() == null && table.FindAutoIncrementColumn() == null)
                    {
                        var pk = new PrimaryKey();
                        pk.Columns.Add(new ColumnReference(col.ColumnName));
                        table._Constraints.Add(pk);
                    }
                }
                else
                {
                    var col = new ColumnStructure();
                    col.ColumnName = row.Cells[0].Value.ToString();
                    col.DataType   = new DbTypeString(250);
                    table._Columns.Add(col);
                }
            }
            return(table);
        }
Exemplo n.º 2
0
        public QueryDesignTableFrame(XmlElement xml, QueryDesignFrame frame)
        {
            InitializeComponent();
            Translating.TranslateControl(this);
            m_frame = frame;
            var tbl = new TableStructure(xml.FindElement("Structure"));

            tbl.Parent = new DatabaseStructure();
            foreach (XmlElement rx in xml.SelectNodes("Reference"))
            {
                var fk = new ForeignKey(rx.FindElement("ForeignKey"));
                fk.SetDummyTable(NameWithSchema.LoadFromXml(rx));
                tbl.AddReference(fk);
            }
            m_table = tbl;
            this.LoadPropertiesCore(xml);
            FillData();
        }
Exemplo n.º 3
0
        public override void AddLogicalDependencies(AlterProcessorCaps caps, DbDiffOptions opts, List <AlterOperation> before, List <AlterOperation> after, AlterPlan plan, IDatabaseSource targetDb)
        {
            ParentTable.LoadStructure(TableStructureMembers.ReferencedFrom, targetDb);
            var oldcol = OldObject as ColumnStructure;
            var newcol = NewObject as ColumnStructure;

            List <IForeignKey> recreateFks = new List <IForeignKey>();
            var changeCols = new List <Tuple <IColumnStructure, IColumnStructure> >();

            foreach (ForeignKey fk in ParentTable.GetReferencedFrom())
            {
                for (int i = 0; i < fk.PrimaryKeyColumns.Count; i++)
                {
                    if (fk.PrimaryKeyColumns[i].ColumnName == oldcol.ColumnName)
                    {
                        //plan.RecreateObject(fk, null);
                        TableStructure table = (TableStructure)fk.Table;
                        table.LoadStructure(TableStructureMembers.Columns, targetDb);
                        ColumnStructure othercol = table.Columns[fk.Columns[i].ColumnName] as ColumnStructure;

                        // compare types with ignoring autoincrement flag
                        // HACK: ignore specific attributes
                        var opts2 = opts.Clone();
                        opts2.IgnoreSpecificData = true;
                        DbTypeBase dt1 = othercol.DataType.Clone(), dt2 = newcol.DataType.Clone();
                        dt1.SetAutoincrement(false);
                        dt2.SetAutoincrement(false);
                        if (!DbDiffTool.EqualTypes(dt1, dt2, opts2))
                        {
                            after.Add(new AlterOperation_ChangeColumn
                            {
                                ParentTable = table,
                                OldObject   = othercol,
                                NewObject   = new ColumnStructure(othercol)
                                {
                                    DataType = dt2
                                }
                            });
                        }
                        opts.AlterLogger.Warning(Texts.Get("s_changed_referenced_column$table$column", "table", fk.Table.FullName, "column", othercol.ColumnName));
                    }
                }
            }
        }
Exemplo n.º 4
0
 public override void LoadFromXml(XmlElement xml, ITableStructure source, ITableStructure target)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source", "DAE-00226 source is null");
     }
     m_inputFormat  = new TableStructure(source);
     m_outputFormat = target != null ? new TableStructure(target) : m_inputFormat;
     if (target != null)
     {
         int colcount = Math.Min(m_inputFormat.Columns.Count, m_outputFormat.Columns.Count);
         while (m_inputFormat.Columns.Count > colcount)
         {
             m_inputFormat._Columns.RemoveAt(m_inputFormat.Columns.Count - 1);
         }
         while (m_outputFormat.Columns.Count > colcount)
         {
             m_outputFormat._Columns.RemoveAt(m_outputFormat.Columns.Count - 1);
         }
     }
 }
Exemplo n.º 5
0
 public override void LoadFromXml(XmlElement xml, ITableStructure source, ITableStructure target)
 {
     m_source = source;
     m_target = target;
     if (m_target == null)
     {
         var t = new TableStructure();
         foreach (XmlElement e in xml.SelectNodes("Column"))
         {
             int colindex = m_source.Columns.GetIndex(e.GetAttribute("src"));
             m_dstIndexes.Add(colindex);
             var newcol = new ColumnStructure(m_source.Columns[colindex]);
             newcol.ColumnName = e.GetAttribute("dst");
             t.AddColumn(newcol, true);
         }
         m_target = t;
     }
     else
     {
         var t = new TableStructure();
         foreach (XmlElement e in xml.SelectNodes("Column"))
         {
             string colname    = e.GetAttribute("src");
             string dstcolname = e.GetAttribute("dst");
             int    pos        = m_source.Columns.GetIndex(colname);
             if (pos < 0)
             {
                 throw new InternalError(String.Format("DAE-00025 Error transforming column {0}, column not found in source table", colname));
             }
             IColumnStructure dstcol = m_target.Columns.FirstOrDefault(col => col.ColumnName == dstcolname);
             if (dstcol == null)
             {
                 throw new InternalError(String.Format("DAE-00026 Error transforming column {0}, column not found in destination table", dstcolname));
             }
             m_dstIndexes.Add(pos);
             t.AddColumn(dstcol, true);
         }
         m_target = t;
     }
 }
Exemplo n.º 6
0
 private void PrepareMembers()
 {
     if (m_members.TableMembers != TableStructureMembers.None && !m_members.TableList)
     {
         if (m_members.TableFilter != null)
         {
             foreach (var tname in m_members.TableFilter)
             {
                 TableStructure ts    = new TableStructure();
                 var            name2 = tname;
                 if (m_dialect.DefaultSchema != null && name2.Schema == null)
                 {
                     name2 = NewNameWithSchema(m_dialect.DefaultSchema, name2.Name);
                 }
                 ts.FullName = name2;
                 m_db.Tables.Add(ts);
             }
         }
         else
         {
             m_members.TableList = true;
         }
     }
     if (m_members.SpecificObjectDetails)
     {
         m_members.SpecificObjectList = true;
     }
     if (m_members.SpecificObjectOverride != null)
     {
         foreach (var v in m_members.SpecificObjectOverride.Values)
         {
             if (v.ObjectDetail && v.ObjectFilter == null)
             {
                 v.ObjectList = true;
             }
         }
     }
 }
Exemplo n.º 7
0
        public virtual void MigrateTable(TableStructure table, IMigrationProfile profile, IProgressInfo progress)
        {
            foreach (ColumnStructure col in table.Columns)
            {
                // character and collation is not portable
                col.Collation    = "";
                col.CharacterSet = "";
                col.DataType     = MigrateDataType(col, col.DataType, profile, progress);
                List <string> todel = new List <string>();
                foreach (string attr in col.SpecificData.Keys)
                {
                    if (!attr.StartsWith(DialectName + "."))
                    {
                        todel.Add(attr);
                    }
                }
                foreach (string d in todel)
                {
                    col.SpecificData.Remove(d);
                }
            }
            var newConstraints = new List <Constraint>();

            foreach (Constraint cnt in table.Constraints)
            {
                var newcnt = MigrateConstraintOrIndex(cnt, profile, progress);
                if (newcnt != null)
                {
                    newConstraints.Add(newcnt);
                }
            }
            table._Constraints.Clear();
            foreach (var cnt in newConstraints)
            {
                table._Constraints.Add(cnt);
            }
        }
Exemplo n.º 8
0
 public IdentityTransform(ITableStructure rowFormat)
 {
     m_outputFormat = m_inputFormat = new TableStructure(rowFormat);
 }
Exemplo n.º 9
0
        protected override void DoRead(IDataQueue queue)
        {
            try
            {
                TableStructure s = CreateStructure();

                Dictionary <string, int> colPos = new Dictionary <string, int>();
                for (int i = 0; i < m_columnNames.Count; i++)
                {
                    colPos[m_columnNames[i]] = i;
                    colPos[XmlTool.NormalizeIdentifier(m_columnNames[i])] = i;
                }

                using (XmlReader xr = new XmlTextReader(GetWorkingFileName()))
                {
                    xr.MoveToContent();
                    if (xr.Name != m_rootElementName)
                    {
                        Logging.Warning("Root element has different name");
                    }
                    xr.Read();
                    while (xr.NodeType == XmlNodeType.Element)
                    {
                        // process one row

                        object[] values = new object[m_columnNames.Count];
                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = DBNull.Value;
                        }


                        if (xr.Name == m_rowElementName)
                        {
                            switch (m_storageType)
                            {
                            case XmlDataStorageType.Attribute:
                                for (int i = 0; i < xr.AttributeCount; i++)
                                {
                                    xr.MoveToAttribute(i);
                                    string name = xr.Name;
                                    if (colPos.ContainsKey(name))
                                    {
                                        values[colPos[name]] = xr.Value;
                                    }
                                }
                                xr.MoveToElement();
                                xr.Read();
                                break;

                            case XmlDataStorageType.ColumnNamedElement:
                                xr.Read();
                                xr.MoveToContent();
                                while (xr.NodeType == XmlNodeType.Element)
                                {
                                    string name  = xr.Name;
                                    string value = xr.ReadElementContentAs(typeof(string), null).ToString();
                                    if (colPos.ContainsKey(name))
                                    {
                                        values[colPos[name]] = value;
                                    }
                                }
                                xr.MoveToContent();
                                if (xr.NodeType == XmlNodeType.EndElement)
                                {
                                    xr.Read();
                                }
                                break;

                            case XmlDataStorageType.InvariantNamedElement:
                                xr.Read();
                                xr.MoveToContent();
                                while (xr.NodeType == XmlNodeType.Element)
                                {
                                    string name  = xr.GetAttribute(m_columnAttributeName);
                                    string value = xr.ReadElementContentAs(typeof(string), null).ToString();
                                    if (colPos.ContainsKey(name))
                                    {
                                        values[colPos[name]] = value;
                                    }
                                }
                                xr.MoveToContent();
                                if (xr.NodeType == XmlNodeType.EndElement)
                                {
                                    xr.Read();
                                }
                                break;
                            }
                        }
                        else
                        {
                            xr.Skip();
                        }

                        queue.PutRecord(new ArrayDataRecord(s, values));
                    }
                }
            }
            finally
            {
                queue.PutEof();
            }
            FinalizeBulkCopy();
        }
Exemplo n.º 10
0
 public virtual void AssignFrom(AlterOperation src)
 {
     ParentTable = src.ParentTable;
 }
Exemplo n.º 11
0
 protected virtual void LoadTableRowDetails(DataRow row, TableStructure tbl)
 {
 }
Exemplo n.º 12
0
 public DataArchiveTable(IDatabaseSource database, DataArchiveConnection conn, TableStructure table)
     : base(conn)
 {
     m_table    = table;
     m_database = database;
 }
Exemplo n.º 13
0
        public virtual void CreateDatabaseObjects(IDatabaseStructure db, CreateDatabaseObjectsProps props)
        {
            if (Dialect.DialectCaps.Domains && props.CreateDomains)
            {
                foreach (var domain in db.Domains)
                {
                    try
                    {
                        CreateDomain(domain);
                    }
                    catch (Exception err)
                    {
                        ProgressInfo.RaiseErrorEx(err, "DAE-00244 " + Texts.Get("s_error_creating$domain", "domain", domain.FullName), "DOMAIN");
                    }
                }
            }
            if (Dialect.DialectCaps.MultipleSchema && props.CreateSchemata)
            {
                foreach (var schema in db.Schemata)
                {
                    try
                    {
                        CreateSchema(schema);
                    }
                    catch (Exception err)
                    {
                        ProgressInfo.RaiseErrorEx(err, "DAE-00245 " + Texts.Get("s_error_creating$schema", "schema", schema.SchemaName), "SCHEMA");
                    }
                }
            }
            var refsToCreate = new List <IForeignKey>();

            if (props.CreateTables)
            {
                foreach (var tbl in db.Tables)
                {
                    ITableStructure tbl2 = tbl;
                    if (!Dialect.DialectCaps.UncheckedReferences)
                    {
                        var newtbl = new TableStructure(tbl);
                        foreach (ForeignKey fk in new List <ForeignKey>(newtbl.GetConstraints <ForeignKey>()))
                        {
                            newtbl._Constraints.Remove(fk);
                            fk.SetDummyTable(tbl.FullName);
                            refsToCreate.Add(fk);
                        }
                        tbl2 = newtbl;
                    }

                    Logging.Debug("Creating table {0}", tbl2.FullName);
                    SetCurWork(String.Format("{0} {1}", Texts.Get("s_creating_table"), tbl2.FullName));
                    if (m_props.DumpWriterConfig != null && m_props.DumpWriterConfig.IncludeDropStatement)
                    {
                        DropTable(tbl2, DropFlags.TestIfExist);
                    }
                    try
                    {
                        CreateTable(tbl2);
                    }
                    catch (Exception err)
                    {
                        ProgressInfo.RaiseErrorEx(err, "DAE-00246 " + Texts.Get("s_error_creating$table", "table", tbl2.FullName), "TABLE");
                    }
                }
            }
            if (props.CreateFixedData)
            {
                foreach (var tbl in db.Tables)
                {
                    this.UpdateData(tbl, DbDiffTool.AlterFixedData(null, tbl.FixedData, null, new DbDiffOptions()), null);
                }
            }
            foreach (var fk in refsToCreate)
            {
                CreateConstraint(fk);
            }
            if (props.CreateSpecificObjects)
            {
                foreach (var obj in db.GetSpecObjectsOrderByDependency())
                {
                    SetCurWork(String.Format("{0} {1}", Texts.Get("s_creating_object"), obj.ObjectName));
                    if (m_props.DumpWriterConfig != null && m_props.DumpWriterConfig.IncludeDropStatement)
                    {
                        DropSpecificObject(obj, DropFlags.TestIfExist);
                    }
                    try
                    {
                        CreateSpecificObject(obj);
                    }
                    catch (Exception err)
                    {
                        if (ProgressInfo != null)
                        {
                            ProgressInfo.LogMessage("s_create_object", LogLevel.Error, Texts.Get("s_error_creating_object$name", "name", obj.ObjectName) + ": " + err.Message);
                        }
                        Logging.Error("Error creating object:" + err.ToString());
                    }
                }
            }
        }
Exemplo n.º 14
0
        public virtual void CreateTable(ITableStructure tableSrc)
        {
            TableStructure table = new TableStructure(tableSrc);

            Put("^create ^table %f ( &>&n", table.FullName);
            bool first = true;

            foreach (IColumnStructure col in table.Columns)
            {
                if (!first)
                {
                    Put(", &n");
                }
                first = false;
                Put("%i ", col.ColumnName);
                ColumnDefinition(col, true, true, true);
            }
            foreach (IConstraint cnt in table.Constraints)
            {
                if (cnt is IPrimaryKey)
                {
                    if (CreateTablePrimaryKey(table, (IPrimaryKey)cnt))
                    {
                        if (!first)
                        {
                            Put(", &n");
                        }
                        first = false;
                        if (cnt.Name != null && !m_dialect.DialectCaps.AnonymousPrimaryKey)
                        {
                            Put("^constraint %i", cnt.Name);
                        }
                        Put(" ^primary ^key (%,i)", ((IPrimaryKey)cnt).Columns);
                    }
                }
                if (cnt is IForeignKey && m_dialect.DialectCaps.UncheckedReferences)
                {
                    if (!first)
                    {
                        Put(", &n");
                    }
                    first = false;
                    CreateForeignKeyCore((IForeignKey)cnt);
                }
            }
            Put("&<&n)");
            CreateTableOptions(table);
            EndCommand();
            foreach (IConstraint cnt in table.Constraints)
            {
                if (cnt is IPrimaryKey)
                {
                    continue;
                }
                if (cnt is IForeignKey && m_dialect.DialectCaps.UncheckedReferences)
                {
                    continue;
                }
                CreateConstraint(cnt);
            }
        }
Exemplo n.º 15
0
        protected virtual void LoadTableColumns(TableStructure table)
        {
            DataTable columns = GetCachedTableColumnsTable(table.FullName);

            ProcessTableColumnsTable(table, columns);
        }
Exemplo n.º 16
0
        public void SaveConstraints(TableStructure table, DatabaseAnalyser analyser)
        {
            MergeKeys();
            cols.Sort(CompareCols);
            bool refsAdded = false;

            foreach (Key key in keys)
            {
                if (key.IsForTable(table))
                {
                    switch (key.keytype)
                    {
                    case "PRIMARY KEY":
                    {
                        PrimaryKey cnt = new PrimaryKey();
                        cnt.Name = key.keyname;
                        //cnt.Table = new NameWithSchema(key.tblschema, key.tblname);
                        foreach (Col col in GetCols(key))
                        {
                            cnt.Columns.Add(col.getcolref());
                        }
                        if (!analyser.SkipConstraint(cnt))
                        {
                            table._Constraints.Add(cnt);
                        }
                    } break;

                    case "FOREIGN KEY":
                    {
                        ForeignKey cnt = new ForeignKey();
                        FillFk(key, cnt);
                        if (!analyser.SkipConstraint(cnt))
                        {
                            table._Constraints.Add(cnt);
                        }
                    } break;

                    case "UNIQUE":
                    {
                        UniqueConstraint cnt = new UniqueConstraint();
                        cnt.Name = key.keyname;
                        //cnt.Table = new NameWithSchema(key.tblschema, key.tblname);
                        foreach (Col col in GetCols(key))
                        {
                            cnt.Columns.Add(col.getcolref());
                        }
                        if (!analyser.SkipConstraint(cnt))
                        {
                            table._Constraints.Add(cnt);
                        }
                    } break;

                    case "CHECK":
                    {
                        CheckConstraint cnt = new CheckConstraint();
                        cnt.Name = key.keyname;
                        //cnt.Table = new NameWithSchema(key.tblschema, key.tblname);
                        cnt.Expression = key.checkexpr;
                        if (!analyser.SkipConstraint(cnt))
                        {
                            table._Constraints.Add(cnt);
                        }
                    } break;

                    case "INDEX":
                    {
                        IndexConstraint cnt = new IndexConstraint();
                        cnt.Name     = key.keyname;
                        cnt.IsUnique = key.keyisunique ?? false;
                        //cnt.Table = new NameWithSchema(key.tblschema, key.tblname);
                        foreach (Col col in GetCols(key))
                        {
                            cnt.Columns.Add(col.getcolref());
                        }
                        if (!analyser.SkipConstraint(cnt))
                        {
                            table._Constraints.Add(cnt);
                        }
                    } break;
                    }
                }
                if (key.IsForTableDest(table) && key.keytype == "FOREIGN KEY")
                {
                    ForeignKey cnt = new ForeignKey();
                    FillFk(key, cnt);
                    refsAdded = true;
                    table.AddReference(cnt);
                    //table._ReferencedFrom.Add(cnt);
                }
            }

            // deduce keys from columns
            if (keys.Count == 0 && AllowDeduceFromColumns)
            {
                var pks  = new Dictionary <string, PrimaryKey>();
                var fks  = new Dictionary <string, ForeignKey>();
                var uqs  = new Dictionary <string, UniqueConstraint>();
                var idxs = new Dictionary <string, IndexConstraint>();
                foreach (Col col in cols)
                {
                    if (!col.IsForTable(table))
                    {
                        continue;
                    }
                    if (col.keytype == null)
                    {
                        continue;
                    }
                    switch (col.keytype)
                    {
                    case "PRIMARY KEY":
                    {
                        if (!pks.ContainsKey(col.keyname))
                        {
                            pks[col.keyname] = new PrimaryKey();
                            table._Constraints.Add(pks[col.keyname]);
                        }
                        // zde NESMI byt cnt.SetDummyTable
                        //pks[col.keyname].Table = table.FullName;
                        pks[col.keyname].Name = col.keyname;
                        pks[col.keyname].Columns.Add(col.getcolref());
                    } break;

                    case "FOREIGN KEY":
                    {
                        if (!fks.ContainsKey(col.keyname))
                        {
                            fks[col.keyname] = new ForeignKey();
                            table._Constraints.Add(fks[col.keyname]);
                        }
                        // zde NESMI byt cnt.SetDummyTable
                        //fks[col.keyname].Table = table.FullName;
                        fks[col.keyname].Name = col.keyname;
                        fks[col.keyname].Columns.Add(col.getcolref());
                        fks[col.keyname].PrimaryKeyColumns.Add(col.getdstcolref());
                        fks[col.keyname].PrimaryKeyTable = analyser.NewNameWithSchema(col.dsttblschema, col.dsttblname);
                    } break;

                    case "UNIQUE":
                    {
                        if (!uqs.ContainsKey(col.keyname))
                        {
                            uqs[col.keyname] = new UniqueConstraint();
                            table._Constraints.Add(uqs[col.keyname]);
                        }
                        // zde NESMI byt cnt.SetDummyTable
                        //uqs[col.keyname].Table = table.FullName;
                        uqs[col.keyname].Name = col.keyname;
                        uqs[col.keyname].Columns.Add(col.getcolref());
                    } break;

                    case "INDEX":
                    {
                        if (!idxs.ContainsKey(col.keyname))
                        {
                            idxs[col.keyname] = new IndexConstraint();
                            table._Constraints.Add(idxs[col.keyname]);
                        }
                        // zde NESMI byt cnt.SetDummyTable
                        //idxs[col.keyname].Table = table.FullName;
                        idxs[col.keyname].Name = col.keyname;
                        idxs[col.keyname].Columns.Add(col.getcolref());
                        idxs[col.keyname].IsUnique = col.keyisunique;
                    } break;
                    }
                }
            }

            if (!refsAdded)
            {
                Dictionary <string, ForeignKey> refs = new Dictionary <string, ForeignKey>();

                foreach (Col col in cols)
                {
                    if (col.IsForTableDest(table))
                    {
                        if (!refs.ContainsKey(col.keyname))
                        {
                            refs[col.keyname] = new ForeignKey();
                        }
                        ForeignKey cnt = refs[col.keyname];
                        cnt.Name = col.keyname;
                        cnt.SetDummyTable(new NameWithSchema(col.tblschema, col.tblname));
                        cnt.PrimaryKeyTable = new NameWithSchema(col.dsttblschema, col.dsttblname);
                        cnt.Columns.Add(col.getcolref());
                        cnt.PrimaryKeyColumns.Add(col.getdstcolref());
                    }
                }

                foreach (ForeignKey fk in refs.Values)
                {
                    table.AddReference(fk);
                }
            }

            //pkcols.Sort(CompareCols);
            //fkcols.Sort(CompareCols);
            //refcols.Sort(CompareCols);

            //foreach (Pk pk in pks)
            //{
            //    if (pk.tblname != table.Name && pk.tblschema != table.SchemaName) continue;
            //    PrimaryKey cnt = new PrimaryKey();
            //    cnt.Name = pk.pkname;
            //    cnt.Table = new NameWithSchema(pk.tblschema, pk.tblname);
            //    foreach (PkCol col in GetPkCols(pk))
            //    {
            //        cnt.Columns.Add(col.colname);
            //    }
            //    table.Constraints.Add(cnt);
            //}

            //SaveFks(fks, fkcols, table.Constraints, table.FullName, Fk.ExtractTable);
            //SaveFks(fks, fkcols, table.ReferencedFrom, table.FullName, Fk.ExtractDestTable);
        }
Exemplo n.º 17
0
 protected virtual void AfterLoadIndexesOrConstraints(TableStructure table)
 {
 }
Exemplo n.º 18
0
 protected virtual void LoadIndexes(TableStructure table)
 {
 }
Exemplo n.º 19
0
 public bool IsForTableDest(TableStructure table)
 {
     return(table.Name == dsttblname && table.SchemaName == dsttblschema);
 }
Exemplo n.º 20
0
 public static void PutQueryStructure(this DatabaseCache cache, string sql, TableStructure value)
 {
     cache.Put("analyser.querystructure", sql, value);
 }
Exemplo n.º 21
0
 public virtual void MigrateTable(TableStructure table, IMigrationProfile profile, IProgressInfo progress)
 {
     m_dialect.MigrateTable(table, profile, progress);
 }
Exemplo n.º 22
0
 public InMemoryTableOperation(ITableStructure table)
 {
     m_table      = new TableStructure(table);
     m_colIndexes = new List <int>(PyList.Range(m_table.Columns.Count));
 }
Exemplo n.º 23
0
        public static void LoadQueue(Stream fr, IDataQueue queue)
        {
            try
            {
                BinaryReader br  = new BinaryReader(fr);
                int          sgn = br.ReadInt32();
                if (sgn != SIGNATURE)
                {
                    throw new InternalError("DAE-00021 Bad BED file");
                }
                int ver = br.ReadInt32();
                if (ver != 1 && ver != 2)
                {
                    throw new InternalError("DAE-00022 Bad BED file");
                }
                int            colcnt = br.Read7BitEncodedInt();
                TableStructure ts     = new TableStructure();
                PrimaryKey     pk     = new PrimaryKey();
                for (int i = 0; i < colcnt; i++)
                {
                    ColumnStructure col = new ColumnStructure();
                    col.ColumnName = br.ReadString();
                    if (ver >= 2)
                    {
                        var type = (TypeStorage)br.ReadByte();
                        col.DataType = type.GetDatAdminType();
                        var flags = (ColFlags)br.ReadByte();
                        if ((flags & ColFlags.ISPK) != 0)
                        {
                            pk.Columns.Add(new ColumnReference(col.ColumnName));
                        }
                    }
                    ts._Columns.Add(col);
                }
                if (pk.Columns.Count > 0)
                {
                    ts._Constraints.Add(pk);
                }

                for (; ;)
                {
                    int len = br.Read7BitEncodedInt();
                    if (len < 0)
                    {
                        break;
                    }
                    var rec = LoadRecord(br, ts);
                    queue.PutRecord(rec);
                }

                queue.PutEof();
            }
            catch (Exception e)
            {
                Errors.Report(e);
                queue.PutError(e);
            }
            finally
            {
                queue.CloseWriting();
            }
        }
Exemplo n.º 24
0
 public InMemoryTable(ITableStructure table)
 {
     Initialize();
     m_structure = new TableStructure(table);
 }
Exemplo n.º 25
0
 public void SetTable(TableStructure table)
 {
 }
Exemplo n.º 26
0
 public BedTable(ITableStructure structure)
 {
     m_structure    = new TableStructure(structure);
     Rows           = new BedRowCollection(this);
     m_defConvertor = new BedValueConvertor(new DataFormatSettings());
 }