Example #1
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);
        }