Пример #1
0
        public override void IntersectAll(RowSetNavigatorData other)
        {
            object[] b = null;
            this.SortFull();
            this.Reset();
            other.SortFull();
            IRowIterator emptyIterator = this._fullIndex.GetEmptyIterator();

            while (base.HasNext())
            {
                object[] next = base.GetNext();
                if ((b == null) || (this._fullIndex.CompareRowNonUnique(this._session, next, b, this._fullIndex.GetColumnCount()) > 0))
                {
                    b             = next;
                    emptyIterator = other.FindFirstRow(next);
                }
                Row      nextRow   = emptyIterator.GetNextRow();
                object[] objArray3 = (nextRow == null) ? null : nextRow.RowData;
                if ((objArray3 == null) || (this._fullIndex.CompareRowNonUnique(this._session, next, objArray3, this._fullIndex.GetColumnCount()) != 0))
                {
                    this.Remove();
                }
            }
            other.Close();
        }
Пример #2
0
        public override bool ContainsRow(object[] data)
        {
            IRowIterator iterator1 = this._mainIndex.FindFirstRow(this._session, this.Store, data);
            bool         flag      = iterator1.HasNext();

            iterator1.Release();
            return(flag);
        }
Пример #3
0
 public RangeIteratorBase(Session session, IPersistentStore store, TableBase t, int position)
 {
     this.session       = session;
     this.rangePosition = position;
     this.Store         = store;
     this.It            = t.GetRowIterator(store);
     this.isBeforeFirst = true;
 }
Пример #4
0
        public int[] WriteTableToDataFile(Table table)
        {
            IPersistentStore    rowStore = this._database.GetSessionManager().GetSysSession().sessionData.GetRowStore(table);
            IRowOutputInterface output   = this._cache.RowOut.Duplicate();
            DoubleIntIndex      lookup   = new DoubleIntIndex(table.GetPrimaryIndex().SizeUnique(rowStore), false);

            int[] indexRootsArray = table.GetIndexRootsArray();
            long  num             = this._fileOffset;
            int   num2            = 0;

            lookup.SetKeysSearchTarget();
            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_lookup_begins__ + this._stopw.ElapsedTime());
            IRowIterator rowIterator = table.GetRowIterator(rowStore);

            while (rowIterator.HasNext())
            {
                ICachedObject nextRow = rowIterator.GetNextRow();
                lookup.AddUnsorted(nextRow.GetPos(), (int)(num / ((long)this._scale)));
                if ((num2 % 0xc350) == 0)
                {
                    Error.PrintSystemOut(string.Concat(new object[] { FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_pointer_pair_for_row_, num2, FwNs.Core.LC.cResources.SR.Single_Space, nextRow.GetPos(), FwNs.Core.LC.cResources.SR.Single_Space, num }));
                }
                num += nextRow.GetStorageSize();
                num2++;
            }
            Error.PrintSystemOut(string.Concat(new object[] { FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_table__, table.GetName().Name, FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile__list_done__, this._stopw.ElapsedTime() }));
            num2        = 0;
            rowIterator = table.GetRowIterator(rowStore);
            while (rowIterator.HasNext())
            {
                ICachedObject nextRow = rowIterator.GetNextRow();
                output.Reset();
                nextRow.Write(output, lookup);
                this._fileStreamOut.Write(output.GetOutputStream().GetBuffer(), 0, output.Size());
                this._fileOffset += nextRow.GetStorageSize();
                if ((num2 % 0xc350) == 0)
                {
                    Error.PrintSystemOut(num2 + FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile__rows_ + this._stopw.ElapsedTime());
                }
                num2++;
            }
            for (int i = 0; i < table.GetIndexCount(); i++)
            {
                if (indexRootsArray[i] != -1)
                {
                    int num4 = lookup.FindFirstEqualKeyIndex(indexRootsArray[i]);
                    if (num4 == -1)
                    {
                        throw Error.GetError(0x1d2);
                    }
                    indexRootsArray[i] = lookup.GetValue(num4);
                }
            }
            this.SetTransactionRowLookups(lookup);
            Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_table__ + table.GetName().Name + FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile____table_converted);
            return(indexRootsArray);
        }
Пример #5
0
 public virtual void Reset()
 {
     if (this.It != null)
     {
         this.It.Release();
     }
     this.It            = null;
     this.CurrentRow    = null;
     this.isBeforeFirst = true;
 }
Пример #6
0
        public void CheckConvertColDataType(ColumnSchema oldCol, ColumnSchema newCol)
        {
            int          columnIndex = this._table.GetColumnIndex(oldCol.GetName().Name);
            IRowIterator rowIterator = this._table.GetRowIterator(this._session);

            while (rowIterator.HasNext())
            {
                object a = rowIterator.GetNextRow().RowData[columnIndex];
                newCol.GetDataType().ConvertToType(this._session, a, oldCol.GetDataType());
            }
        }
Пример #7
0
        public void MoveData(Session session, IPersistentStore other, int colindex, int adjust)
        {
            object  defaultValue = null;
            SqlType type         = null;
            SqlType type2        = null;

            if ((adjust >= 0) && (colindex != -1))
            {
                defaultValue = ((Table)this.table).GetColumn(colindex).GetDefaultValue(session);
                type2        = this.table.GetColumnTypes()[colindex];
            }
            if ((adjust <= 0) && (colindex != -1))
            {
                type = other.GetTable().GetColumnTypes()[colindex];
            }
            IRowIterator rowIterator = other.GetRowIterator();
            Table        table       = (Table)this.table;

            try
            {
                while (rowIterator.HasNext())
                {
                    object[] rowData      = rowIterator.GetNextRow().RowData;
                    object[] emptyRowData = table.GetEmptyRowData();
                    object   a            = null;
                    if ((adjust == 0) && (colindex != -1))
                    {
                        a            = rowData[colindex];
                        defaultValue = type2.ConvertToType(session, a, type);
                    }
                    if ((defaultValue != null) && type2.IsLobType())
                    {
                        session.sessionData.AdjustLobUsageCount(defaultValue, 1);
                    }
                    if (((a != null) && (type != null)) && type.IsLobType())
                    {
                        session.sessionData.AdjustLobUsageCount(a, -1);
                    }
                    ArrayUtil.CopyAdjustArray <object>(rowData, emptyRowData, defaultValue, colindex, adjust);
                    table.SystemSetIdentityColumn(session, emptyRowData);
                    table.EnforceTypeLimits(session, emptyRowData);
                    table.EnforceRowConstraints(session, emptyRowData);
                    Row newCachedObject = this.GetNewCachedObject(null, emptyRowData);
                    this.IndexRow(null, newCachedObject);
                }
            }
            catch (OutOfMemoryException)
            {
                throw Error.GetError(460);
            }
        }
Пример #8
0
        public void CheckReferencedRows(Session session, Table table, int[] rowColArray)
        {
            IRowIterator rowIterator = table.GetRowIterator(session);

            while (true)
            {
                Row nextRow = rowIterator.GetNextRow();
                if (nextRow == null)
                {
                    break;
                }
                object[] rowData = nextRow.RowData;
                this.CheckInsert(session, table, rowData, false);
            }
        }
Пример #9
0
 public override void Update(object[] oldData, object[] newData)
 {
     if (!this._isSimpleAggregate)
     {
         IRowIterator iterator = this._groupIndex.FindFirstRow(this._session, this.Store, oldData);
         if (iterator.HasNext())
         {
             iterator.GetNextRow();
             iterator.Remove();
             iterator.Release();
             base.Size--;
             this.Add(newData);
         }
     }
 }
Пример #10
0
        public int GetNodeCount(Session session, IPersistentStore store)
        {
            int num = 0;

            lock (this._lock)
            {
                IRowIterator iterator = this.FirstRow(session, store);
                while (iterator.HasNext())
                {
                    iterator.GetNextRow();
                    num++;
                }
                return(num);
            }
        }
Пример #11
0
        public void DropIndexFromRows(Index primaryIndex, Index oldIndex)
        {
            IRowIterator iterator = primaryIndex.FirstRow(this);
            int          num      = oldIndex.GetPosition() - 1;

            while (iterator.HasNext())
            {
                int     num2 = num - 1;
                NodeAVL node = ((RowAVL)iterator.GetNextRow()).GetNode(0);
                while (num2-- > 0)
                {
                    node = node.nNext;
                }
                node.nNext = node.nNext.nNext;
            }
        }
Пример #12
0
        public object[] GetValues(Session session)
        {
            IRowIterator rowIterator = this._table.GetRowIterator(session);

            if (!rowIterator.HasNext())
            {
                return(new object[this._table.GetColumnCount()]);
            }
            Row nextRow = rowIterator.GetNextRow();

            if (rowIterator.HasNext())
            {
                throw Error.GetError(0xc81);
            }
            return(nextRow.RowData);
        }
Пример #13
0
        protected void WriteExistingData()
        {
            this.CurrentSession.LoggedSchema = null;
            Iterator <string> iterator = this._database.schemaManager.AllSchemaNameIterator();

            while (iterator.HasNext())
            {
                string            schemaName = iterator.Next();
                Iterator <object> iterator2  = this._database.schemaManager.DatabaseObjectIterator(schemaName, 3);
                while (iterator2.HasNext())
                {
                    Table t    = (Table)iterator2.Next();
                    bool  flag = false;
                    switch (t.GetTableType())
                    {
                    case 4:
                        flag = true;
                        break;

                    case 5:
                        flag = this._includeCachedData;
                        break;
                    }
                    try
                    {
                        if (flag)
                        {
                            this.SchemaToLog = t.GetName().schema;
                            this.WriteTableInit(t);
                            IRowIterator rowIterator = t.GetRowIterator(this.CurrentSession);
                            while (rowIterator.HasNext())
                            {
                                this.WriteRow(this.CurrentSession, t, rowIterator.GetNextRow().RowData);
                            }
                            WriteTableTerm(t);
                        }
                        continue;
                    }
                    catch (Exception exception)
                    {
                        throw Error.GetError(0x1c4, exception.ToString());
                    }
                }
            }
            this.WriteDataTerm();
        }
Пример #14
0
        public void IndexRows()
        {
            IRowIterator rowIterator = this.GetRowIterator();

            for (int i = 1; i < this.indexList.Length; i++)
            {
                this.SetAccessor(this.indexList[i], (ICachedObject)null);
            }
            while (rowIterator.HasNext())
            {
                Row nextRow = rowIterator.GetNextRow();
                ((RowAVL)nextRow).ClearNonPrimaryNodes();
                for (int j = 1; j < this.indexList.Length; j++)
                {
                    this.indexList[j].Insert(null, this, nextRow);
                }
            }
        }
Пример #15
0
 public void ChangeToDiskTable()
 {
     this._cache = this._session.sessionData.GetResultCache();
     if (this._cache != null)
     {
         IRowIterator rowIterator = base.table.GetRowIterator(this);
         ArrayUtil.FillArray(base.AccessorList, null);
         this._isCached = true;
         this._cache.StoreCount++;
         while (rowIterator.HasNext())
         {
             Row nextRow         = rowIterator.GetNextRow();
             Row newCachedObject = this.GetNewCachedObject(this._session, nextRow.RowData);
             this.IndexRow(null, newCachedObject);
             nextRow.Destroy();
         }
     }
     this._maxMemoryRowCount = 0x7fffffff;
 }
Пример #16
0
        public bool InsertIndexNodes(Index primaryIndex, Index newIndex)
        {
            CoreException error;
            int           position = newIndex.GetPosition();
            IRowIterator  iterator = primaryIndex.FirstRow(this);
            int           num2     = 0;

            try
            {
                while (iterator.HasNext())
                {
                    Row nextRow = iterator.GetNextRow();
                    ((RowAVL)nextRow).InsertNode(position);
                    num2++;
                    newIndex.Insert(null, this, nextRow);
                }
                return(true);
            }
            catch (OutOfMemoryException)
            {
                error = Error.GetError(460);
            }
            catch (CoreException exception2)
            {
                error = exception2;
            }
            iterator = primaryIndex.FirstRow(this);
            for (int i = 0; i < num2; i++)
            {
                NodeAVL node = ((RowAVL)iterator.GetNextRow()).GetNode(0);
                int     num4 = position;
                while (--num4 > 0)
                {
                    node = node.nNext;
                }
                node.nNext = node.nNext.nNext;
            }
            throw error;
        }
Пример #17
0
        public Result ExecuteDeleteTruncateStatement(Session session)
        {
            IPersistentStore rowStore = base.TargetTable.GetRowStore(session);
            IRowIterator     iterator = base.TargetTable.GetPrimaryIndex().FirstRow(rowStore);

            try
            {
                while (iterator.HasNext())
                {
                    Row nextRow = iterator.GetNextRow();
                    session.AddDeleteAction((Table)nextRow.GetTable(), nextRow, null);
                }
                if (base.RestartIdentity && (base.TargetTable.IdentitySequence != null))
                {
                    base.TargetTable.IdentitySequence.Reset();
                }
            }
            finally
            {
                iterator.Release();
            }
            return(Result.UpdateOneResult);
        }
Пример #18
0
        public virtual void IntersectAll(RowSetNavigatorData other)
        {
            object[] b = null;
            this.SortFull();
            other.SortFull();
            IRowIterator emptyIterator = this._queryExpression.FullIndex.GetEmptyIterator();

            while (base.HasNext())
            {
                object[] next = base.GetNext();
                if ((b == null) || (this._queryExpression.FullIndex.CompareRowNonUnique((Session)base.session, next, b, this._visibleColumnCount) > 0))
                {
                    b             = next;
                    emptyIterator = other.FindFirstRow(next);
                }
                object[] objArray3 = emptyIterator.GetNext();
                if ((objArray3 == null) || (this._queryExpression.FullIndex.CompareRowNonUnique((Session)base.session, next, objArray3, this._visibleColumnCount) != 0))
                {
                    this.Remove();
                }
            }
            other.Close();
            this.Reset();
        }
Пример #19
0
        public override object[] GetGroupData(object[] data)
        {
            if (this._isSimpleAggregate)
            {
                if (this._simpleAggregateData == null)
                {
                    this._simpleAggregateData = data;
                    return(null);
                }
                return(this._simpleAggregateData);
            }
            IRowIterator iterator = this._groupIndex.FindFirstRow(this._session, this.Store, data);

            if (iterator.HasNext())
            {
                Row nextRow = iterator.GetNextRow();
                if (this._isAggregate)
                {
                    nextRow.SetChanged();
                }
                return(nextRow.RowData);
            }
            return(null);
        }
Пример #20
0
        public Result GetProcedureResult(Session session)
        {
            Result updateZeroResult;

            object[] objArray = new object[0];
            if (this._arguments.Length != 0)
            {
                objArray = new object[this._arguments.Length];
            }
            Dictionary <string, IRowIterator> dictionary = new Dictionary <string, IRowIterator>();

            for (int i = 0; i < this._arguments.Length; i++)
            {
                Expression expression = this._arguments[i];
                object     a          = expression.GetValue(session);
                if (expression != null)
                {
                    ColumnSchema parameter = this.Procedure.GetParameter(i);
                    SqlType      dataType  = parameter.GetDataType();
                    objArray[i] = dataType.ConvertToType(session, a, expression.GetDataType());
                    if (dataType.IsTableType())
                    {
                        IRowIterator argumentNavigator = this.GetArgumentNavigator(session, expression.GetColumnName());
                        dictionary.Add(parameter.GetName().Name, argumentNavigator);
                    }
                }
            }
            session.sessionContext.Push(true);
            session.sessionContext.PushRoutineTables(this.Procedure.ScopeTables);
            foreach (KeyValuePair <string, IRowIterator> pair in dictionary)
            {
                Table parameterTable = this.Procedure.GetParameterTable(pair.Key);
                if (parameterTable != null)
                {
                    IPersistentStore rowStore = session.sessionData.GetRowStore(parameterTable);
                    parameterTable.ClearAllData(rowStore);
                    IRowIterator iterator2 = pair.Value;
                    while (iterator2.HasNext())
                    {
                        object[] next = iterator2.GetNext();
                        parameterTable.InsertData(session, rowStore, next);
                    }
                }
            }
            session.sessionContext.RoutineArguments = objArray;
            session.sessionContext.RoutineVariables = new object[0];
            if (this.Procedure.IsPsm())
            {
                updateZeroResult = this.ExecutePsmProcedure(session);
            }
            else
            {
                updateZeroResult = this.ExecuteClrProcedure(session);
            }
            object[] routineArguments = session.sessionContext.RoutineArguments;
            session.sessionContext.PopRoutineTables();
            session.sessionContext.Pop(true);
            bool flag = false;

            for (int j = 0; j < this.Procedure.GetParameterCount(); j++)
            {
                if (this.Procedure.GetParameter(j).GetParameterMode() != 1)
                {
                    if (this._arguments[j].IsDynamicParam())
                    {
                        int parameterIndex = this._arguments[j].ParameterIndex;
                        session.sessionContext.DynamicArguments[parameterIndex] = routineArguments[j];
                        flag = true;
                    }
                    else if (this._arguments[j].IsParameter())
                    {
                        int columnIndex = this._arguments[j].GetColumnIndex();
                        session.sessionContext.RoutineArguments[columnIndex] = routineArguments[j];
                    }
                    else
                    {
                        int columnIndex = this._arguments[j].GetColumnIndex();
                        session.sessionContext.RoutineVariables[columnIndex] = routineArguments[j];
                    }
                }
            }
            if (!updateZeroResult.IsError())
            {
                if (updateZeroResult.IsSimpleValue())
                {
                    updateZeroResult = Result.UpdateZeroResult;
                }
                if (flag)
                {
                    updateZeroResult = Result.NewCallResponse(this.GetParametersMetaData().GetParameterTypes(), base.Id, session.sessionContext.DynamicArguments);
                }
            }
            return(updateZeroResult);
        }
Пример #21
0
 public override void Reset()
 {
     base.Reset();
     this._iterator = this._mainIndex.FirstRow(this.Store);
 }
Пример #22
0
        public void DropColumn(int colIndex, bool cascade)
        {
            OrderedHashSet <QNameManager.QName> dropConstraintSet     = new OrderedHashSet <QNameManager.QName>();
            OrderedHashSet <Constraint>         dependentConstraints  = this._table.GetDependentConstraints(colIndex);
            OrderedHashSet <Constraint>         containingConstraints = this._table.GetContainingConstraints(colIndex);
            OrderedHashSet <QNameManager.QName> containingIndexNames  = this._table.GetContainingIndexNames(colIndex);
            ColumnSchema column = this._table.GetColumn(colIndex);

            QNameManager.QName name = column.GetName();
            OrderedHashSet <QNameManager.QName> referencingObjectNames = this._database.schemaManager.GetReferencingObjectNames(this._table.GetName(), name);

            this.CheckModifyTable();
            if (!cascade)
            {
                if (!containingConstraints.IsEmpty())
                {
                    QNameManager.QName name2 = containingConstraints.Get(0).GetName();
                    throw Error.GetError(0x15a0, name2.GetSchemaQualifiedStatementName());
                }
                if (!referencingObjectNames.IsEmpty())
                {
                    for (int j = 0; j < referencingObjectNames.Size(); j++)
                    {
                        QNameManager.QName name3 = referencingObjectNames.Get(j);
                        if (name3 != name)
                        {
                            for (int k = 0; k < dependentConstraints.Size(); k++)
                            {
                                if (dependentConstraints.Get(k).GetName() == name3)
                                {
                                    continue;
                                }
                            }
                            throw Error.GetError(0x15a0, name3.GetSchemaQualifiedStatementName());
                        }
                    }
                }
            }
            dependentConstraints.AddAll(containingConstraints);
            containingConstraints.Clear();
            OrderedHashSet <Table> tableSet = new OrderedHashSet <Table>();

            for (int i = 0; i < dependentConstraints.Size(); i++)
            {
                Constraint constraint = dependentConstraints.Get(i);
                if (constraint.ConstType == 0)
                {
                    tableSet.Add(constraint.GetMain());
                    dropConstraintSet.Add(constraint.GetMainName());
                    dropConstraintSet.Add(constraint.GetRefName());
                    containingIndexNames.Add(constraint.GetRefIndex().GetName());
                }
                if (constraint.ConstType == 1)
                {
                    tableSet.Add(constraint.GetRef());
                    dropConstraintSet.Add(constraint.GetMainName());
                    dropConstraintSet.Add(constraint.GetRefName());
                    containingIndexNames.Add(constraint.GetRefIndex().GetName());
                }
                dropConstraintSet.Add(constraint.GetName());
            }
            tableSet = this.MakeNewTables(tableSet, dropConstraintSet, containingIndexNames);
            Table newTable = this._table.MoveDefinition(this._session, this._table.TableType, null, null, null, colIndex, -1, dropConstraintSet, containingIndexNames);

            this.MoveData(this._table, newTable, colIndex, -1);
            this._database.schemaManager.RemoveSchemaObjects(referencingObjectNames);
            this._database.schemaManager.RemoveSchemaObjects(dropConstraintSet);
            this._database.schemaManager.RemoveSchemaObject(name);
            this.SetNewTableInSchema(newTable);
            this.SetNewTablesInSchema(tableSet);
            this.UpdateConstraints(newTable, this.EmptySetQName);
            this.UpdateConstraints(tableSet, dropConstraintSet);
            this._database.schemaManager.RecompileDependentObjects(tableSet);
            this._database.schemaManager.RecompileDependentObjects(newTable);
            newTable.Compile(this._session, null);
            if (column.GetDataType().IsLobType())
            {
                IRowIterator rowIterator = this._table.GetRowIterator(this._session);
                while (rowIterator.HasNext())
                {
                    object[] rowData = rowIterator.GetNextRow().RowData;
                    if (rowData[colIndex] != null)
                    {
                        this._session.sessionData.AdjustLobUsageCount(rowData[colIndex], -1);
                    }
                }
            }
            this._table = newTable;
        }
Пример #23
0
        private static void PerformReferentialActions(Session session, Table table, RowSetNavigatorDataChange navigator, Row row, object[] data, int[] changedCols, HashSet <object> path)
        {
            if (session.database.IsReferentialIntegrity())
            {
                bool flag   = data == null;
                int  index  = 0;
                int  length = table.FkMainConstraints.Length;
                while (index < length)
                {
                    Constraint item = table.FkMainConstraints[index];
                    int        num3 = flag ? item.Core.DeleteAction : item.Core.UpdateAction;
                    if (flag || (ArrayUtil.HaveCommonElement(changedCols, item.Core.MainCols) && (item.Core.MainIndex.CompareRowNonUnique(session, row.RowData, data, item.Core.MainCols) != 0)))
                    {
                        IRowIterator iterator = item.FindFkRef(session, row.RowData);
                        if (iterator.HasNext())
                        {
                            while (iterator.HasNext())
                            {
                                object[]     emptyRowData;
                                int          num6;
                                int          num7;
                                ColumnSchema schema;
                                Row          nextRow = iterator.GetNextRow();
                                if (item.Core.RefIndex.CompareRowNonUnique(session, nextRow.RowData, row.RowData, item.Core.MainCols) != 0)
                                {
                                    break;
                                }
                                if (flag && (nextRow.GetId() == row.GetId()))
                                {
                                    iterator.Release();
                                }
                                else
                                {
                                    switch (num3)
                                    {
                                    case 0:
                                        if (!flag)
                                        {
                                            goto Label_0151;
                                        }
                                        if (navigator.AddRow(nextRow))
                                        {
                                            PerformReferentialActions(session, item.Core.RefTable, navigator, nextRow, null, null, path);
                                        }
                                        break;

                                    case 1:
                                    case 3:
                                        if (!navigator.ContainsDeletedRow(nextRow))
                                        {
                                            int      code = (item.Core.DeleteAction == 3) ? 8 : 0xdad;
                                            string[] add  = new string[] { item.Core.RefName.Name, item.Core.RefTable.GetName().Name };
                                            iterator.Release();
                                            throw Error.GetError(null, code, 2, add);
                                        }
                                        break;

                                    case 2:
                                        emptyRowData = item.Core.RefTable.GetEmptyRowData();
                                        Array.Copy(nextRow.RowData, 0, emptyRowData, 0, emptyRowData.Length);
                                        num6 = 0;
                                        goto Label_0268;

                                    case 4:
                                        emptyRowData = item.Core.RefTable.GetEmptyRowData();
                                        Array.Copy(nextRow.RowData, 0, emptyRowData, 0, emptyRowData.Length);
                                        num7 = 0;
                                        goto Label_02E5;
                                    }
                                }
                                continue;
Label_0151:
                                emptyRowData = item.Core.RefTable.GetEmptyRowData();
                                Array.Copy(nextRow.RowData, 0, emptyRowData, 0, emptyRowData.Length);
                                for (int i = 0; i < item.Core.RefCols.Length; i++)
                                {
                                    emptyRowData[item.Core.RefCols[i]] = data[item.Core.MainCols[i]];
                                }
                                goto Label_02F6;
Label_0250:
                                emptyRowData[item.Core.RefCols[num6]] = null;
                                num6++;
Label_0268:
                                if (num6 < item.Core.RefCols.Length)
                                {
                                    goto Label_0250;
                                }
                                goto Label_02F6;
Label_02A6:
                                schema = item.Core.RefTable.GetColumn(item.Core.RefCols[num7]);
                                emptyRowData[item.Core.RefCols[num7]] = schema.GetDefaultValue(session);
                                num7++;
Label_02E5:
                                if (num7 < item.Core.RefCols.Length)
                                {
                                    goto Label_02A6;
                                }
Label_02F6:
                                emptyRowData = navigator.AddRow(session, nextRow, emptyRowData, table.GetColumnTypes(), item.Core.RefCols);
                                if (path.Add(item))
                                {
                                    PerformReferentialActions(session, item.Core.RefTable, navigator, nextRow, emptyRowData, item.Core.RefCols, path);
                                    path.Remove(item);
                                }
                            }
                            iterator.Release();
                        }
                    }
                    index++;
                }
            }
        }
Пример #24
0
        private Result GetResult(Session session)
        {
            Routine       routine;
            View          view;
            SchemaManager schemaManager = session.database.schemaManager;

            if (base.IsExplain)
            {
                return(Result.NewSingleColumnStringResult("OPERATION", this.Describe(session)));
            }
            int type = base.type;

            if (type > 0x54)
            {
                if (type <= 0x87)
                {
                    switch (type)
                    {
                    case 0x72:
                    case 0x73:
                    case 0x74:
                    case 0x7f:
                    case 0x81:
                    case 0x85:
                    case 0x86:
                    case 0x87:
                        goto Label_05DC;

                    case 0x75:
                        return(Result.UpdateZeroResult);
                    }
                    goto Label_0684;
                }
                switch (type)
                {
                case 0x41b:
                case 0x41c:
                case 0x41d:
                case 0x421:
                case 0x422:
                case 0x423:
                case 0x426:
                    goto Label_05DC;

                case 0x41e:
                case 0x41f:
                case 0x420:
                case 0x424:
                case 0x425:
                case 0x427:
                    goto Label_0684;

                case 0x428:
                {
                    QNameManager.QName schema = (QNameManager.QName) this.Arguments[0];
                    QNameManager.QName name   = (QNameManager.QName) this.Arguments[1];
                    if (schema.type == 1)
                    {
                        try
                        {
                            session.CheckAdmin();
                            session.CheckDdlWrite();
                            schema.Rename(name);
                            goto Label_0694;
                        }
                        catch (CoreException exception8)
                        {
                            return(Result.NewErrorResult(exception8, base.Sql));
                        }
                    }
                    if (schema.type == 2)
                    {
                        CheckSchemaUpdateAuthorisation(session, schema);
                        schemaManager.CheckSchemaNameCanChange(schema);
                        schemaManager.RenameSchema(schema, name);
                        goto Label_0694;
                    }
                    try
                    {
                        ISchemaObject column;
                        schema.SetSchemaIfNull(session.GetCurrentSchemaQName());
                        if (schema.type == 9)
                        {
                            Table userTable = schemaManager.GetUserTable(session, schema.Parent);
                            column = userTable.GetColumn(userTable.GetColumnIndex(schema.Name));
                        }
                        else
                        {
                            column = schemaManager.GetSchemaObject(schema);
                            if (column == null)
                            {
                                throw Error.GetError(0x157d, schema.Name);
                            }
                            schema = column.GetName();
                        }
                        CheckSchemaUpdateAuthorisation(session, schema.schema);
                        name.SetSchemaIfNull(schema.schema);
                        if (schema.schema != name.schema)
                        {
                            return(Result.NewErrorResult(Error.GetError(0x1581), base.Sql));
                        }
                        name.Parent = schema.Parent;
                        if (column.GetSchemaObjectType() == 9)
                        {
                            QNameManager.QName parent = column.GetName().Parent;
                            schemaManager.CheckColumnIsReferenced(parent, column.GetName());
                            schemaManager.GetUserTable(session, parent).RenameColumn((ColumnSchema)column, name);
                        }
                        else
                        {
                            schemaManager.RenameSchemaObject(schema, name);
                        }
                        goto Label_0694;
                    }
                    catch (CoreException exception9)
                    {
                        return(Result.NewErrorResult(exception9, base.Sql));
                    }
                    break;
                }
                }
                if (type != 0x430)
                {
                    if (type == 0x817)
                    {
                        goto Label_0649;
                    }
                    if (type != 0x818)
                    {
                        goto Label_0684;
                    }
                    this.ProcessComment(session, schemaManager);
                }
                goto Label_0694;
            }
            if (type > 0x34)
            {
                switch (type)
                {
                case 0x3b:
                case 60:
                case 0x40:
                    goto Label_0364;

                case 0x3d:
                    try
                    {
                        session.CheckAdmin();
                        session.CheckDdlWrite();
                        QNameManager.QName name = (QNameManager.QName) this.Arguments[0];
                        session.database.GetGranteeManager().AddRole(name);
                        goto Label_0694;
                    }
                    catch (CoreException exception2)
                    {
                        return(Result.NewErrorResult(exception2, base.Sql));
                    }
                    break;

                case 0x3e:
                case 0x3f:
                    goto Label_0684;
                }
                switch (type)
                {
                case 0x4d:
                {
                    Table             table           = (Table)this.Arguments[0];
                    List <Constraint> tempConstraints = (List <Constraint>) this.Arguments[1];
                    StatementDMQL     tdmql           = (StatementDMQL)this.Arguments[2];
                    List <Constraint> constraintList  = null;
                    try
                    {
                        this.SetOrCheckObjectName(session, null, table.GetName(), true);
                    }
                    catch (CoreException exception3)
                    {
                        return(Result.NewErrorResult(exception3, base.Sql));
                    }
                    try
                    {
                        if (this.IsSchemaDefinition)
                        {
                            constraintList = new List <Constraint>();
                        }
                        if (tempConstraints != null)
                        {
                            table             = ParserDDL.AddTableConstraintDefinitions(session, table, tempConstraints, constraintList, true);
                            this.Arguments[1] = constraintList;
                        }
                        table.Compile(session, null);
                        schemaManager.AddSchemaObject(table);
                        if (tdmql != null)
                        {
                            Result result = tdmql.Execute(session);
                            table.InsertIntoTable(session, result);
                        }
                        if (table.hasLobColumn)
                        {
                            IRowIterator rowIterator = table.GetRowIterator(session);
                            while (rowIterator.HasNext())
                            {
                                object[] rowData = rowIterator.GetNextRow().RowData;
                                session.sessionData.AdjustLobUsageCount(table, rowData, 1);
                            }
                        }
                        return(Result.UpdateZeroResult);
                    }
                    catch (CoreException exception4)
                    {
                        schemaManager.RemoveExportedKeys(table);
                        schemaManager.RemoveDependentObjects(table.GetName());
                        return(Result.NewErrorResult(exception4, base.Sql));
                    }
                    break;
                }

                case 0x4e:
                    goto Label_0364;

                case 0x4f:
                    break;

                case 80:
                    try
                    {
                        this.ProcessCreateTrigger(session, schemaManager);
                        goto Label_0694;
                    }
                    catch (CoreException exception5)
                    {
                        return(Result.NewErrorResult(exception5, base.Sql));
                    }
                    goto Label_0320;

                case 0x51:
                case 0x52:
                    goto Label_0684;

                case 0x53:
                    goto Label_0320;

                case 0x54:
                    goto Label_0342;

                default:
                    goto Label_0684;
                }
                return(Result.UpdateZeroResult);
            }
            switch (type)
            {
            case 3:
            case 4:
            case 10:
            case 14:
            case 0x17:
            case 0x18:
            case 0x19:
            case 0x1a:
            case 0x1b:
            case 0x1d:
            case 30:
            case 0x1f:
            case 0x20:
            case 0x21:
            case 0x22:
            case 0x23:
            case 0x24:
                goto Label_0136;

            case 5:
            case 7:
            case 9:
            case 11:
            case 12:
            case 13:
            case 15:
            case 0x10:
            case 0x12:
            case 0x13:
            case 20:
            case 0x15:
            case 0x16:
            case 0x1c:
                goto Label_0684;

            case 6:
                goto Label_0674;

            case 8:
            {
                Charset charset = (Charset)this.Arguments[0];
                try
                {
                    this.SetOrCheckObjectName(session, null, charset.GetName(), true);
                    schemaManager.AddSchemaObject(charset);
                    goto Label_0694;
                }
                catch (CoreException exception1)
                {
                    return(Result.NewErrorResult(exception1, base.Sql));
                }
                break;
            }

            case 0x11:
                goto Label_05FD;
            }
            switch (type)
            {
            case 0x30:
            case 0x31:
                break;

            case 0x34:
                goto Label_0364;

            default:
                goto Label_0684;
            }
Label_0136:
            return(Result.UpdateZeroResult);

            Label_0320 :;
            try
            {
                this.ProcessCreateType(session, schemaManager);
                goto Label_0694;
            }
            catch (CoreException exception6)
            {
                return(Result.NewErrorResult(exception6, base.Sql));
            }
            Label_0342 :;
            try
            {
                this.ProcessCreateView(session, schemaManager);
                goto Label_0694;
            }
            catch (CoreException exception7)
            {
                return(Result.NewErrorResult(exception7, base.Sql));
            }
Label_0364:
            return(Result.UpdateZeroResult);

            Label_05DC :;
            try
            {
                this.ProcessAlterSequence(session);
                goto Label_0694;
            }
            catch (CoreException exception10)
            {
                return(Result.NewErrorResult(exception10, base.Sql));
            }
Label_05FD:
            routine = (Routine)this.Arguments[0];
            try
            {
                routine.ResolveReferences(session);
                Routine schemaObject = (Routine)schemaManager.GetSchemaObject(routine.GetSpecificName());
                schemaManager.ReplaceReferences(schemaObject, routine);
                schemaObject.SetAsAlteredRoutine(routine);
                goto Label_0694;
            }
            catch (CoreException exception11)
            {
                return(Result.NewErrorResult(exception11, base.Sql));
            }
Label_0649:
            view = (View)this.Arguments[0];
            try
            {
                ProcessAlterView(session, schemaManager, view);
                goto Label_0694;
            }
            catch (CoreException exception12)
            {
                return(Result.NewErrorResult(exception12, base.Sql));
            }
Label_0674:
            return(Result.UpdateZeroResult);

Label_0684:
            throw Error.RuntimeError(0xc9, "CompiledStateemntSchema");
Label_0694:
            return(Result.UpdateZeroResult);
        }