예제 #1
0
        public Result GetResult(Session session)
        {
            Table table;
            bool  flag;

            ColumnSchema[] schemaArray;
            int            num2;
            object         obj2;
            Grantee        role;

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

            if (type <= 0x4c)
            {
                if (type > 0x16)
                {
                    switch (type)
                    {
                    case 0x20:
                    {
                        QNameManager.QName name = (QNameManager.QName) this._parameters[0];
                        bool flag6 = (bool)this._parameters[1];
                        if (session.sessionContext.FindSessionTable(name.Name) == null)
                        {
                            if (!flag6)
                            {
                                throw Error.GetError(0x157d, name.Name);
                            }
                            return(Result.UpdateZeroResult);
                        }
                        session.sessionContext.DropSessionTable(name.Name);
                        return(Result.UpdateZeroResult);
                    }

                    case 0x21:
                    case 0x22:
                    case 0x23:
                    case 0x24:
                    case 0x29:
                    case 0x2a:
                    case 0x2e:
                        goto Label_094C;

                    case 0x25:
                    case 0x26:
                    case 0x27:
                    case 40:
                    case 0x2d:
                    case 0x2f:
                    case 0x38:
                        goto Label_0944;

                    case 0x2b:
                        return(this.ProcessExecuteImmediate(session));

                    case 0x2c:
                        return(this.ProcessExecute(session));
                    }
                    if (type == 0x39)
                    {
                        string str3 = (string)this._parameters[0];
                        try
                        {
                            session.ReleaseSavepoint(str3);
                            return(Result.UpdateZeroResult);
                        }
                        catch (CoreException exception9)
                        {
                            return(Result.NewErrorResult(exception9, base.Sql));
                        }
                    }
                    switch (type)
                    {
                    case 0x3e:
                    {
                        bool chain = Convert.ToBoolean(this._parameters[0], CultureInfo.CurrentCulture);
                        session.Rollback(chain);
                        return(Result.UpdateZeroResult);
                    }

                    case 0x3f:
                    {
                        string str4 = (string)this._parameters[0];
                        session.Savepoint(str4);
                        return(Result.UpdateZeroResult);
                    }

                    case 0x42:
                        try
                        {
                            string data = (string)this._expressions[0].GetValue(session);
                            data = (string)SqlType.SqlVarchar.Trim(session, data, " ", true, true);
                            if (session.database.GetCatalogName().Name.Equals(data))
                            {
                                return(Result.UpdateZeroResult);
                            }
                            return(Result.NewErrorResult(Error.GetError(0x12e8), base.Sql));
                        }
                        catch (CoreException exception10)
                        {
                            return(Result.NewErrorResult(exception10, base.Sql));
                        }
                        goto Label_056E;

                    case 0x47:
                    case 0x4b:
                        goto Label_07EA;

                    case 0x49:
                        goto Label_056E;

                    case 0x4a:
                        try
                        {
                            string str7;
                            if (this._expressions == null)
                            {
                                str7 = ((QNameManager.QName) this._parameters[0]).Name;
                            }
                            else
                            {
                                str7 = (string)this._expressions[0].GetValue(session);
                            }
                            str7 = (string)SqlType.SqlVarchar.Trim(session, str7, " ", true, true);
                            QNameManager.QName schemaQName = session.database.schemaManager.GetSchemaQName(str7);
                            session.SetSchema(schemaQName.Name);
                            return(Result.UpdateZeroResult);
                        }
                        catch (CoreException exception12)
                        {
                            return(Result.NewErrorResult(exception12, base.Sql));
                        }
                        goto Label_06C8;

                    case 0x4c:
                        goto Label_06C8;
                    }
                }
                else
                {
                    switch (type)
                    {
                    case 11:
                        try
                        {
                            bool chain = this._parameters > null;
                            session.Commit(chain);
                            return(Result.UpdateZeroResult);
                        }
                        catch (CoreException exception8)
                        {
                            return(Result.NewErrorResult(exception8, base.Sql));
                        }
                        goto Label_0374;

                    case 0x10:
                    {
                        string name = (string)this._parameters[0];
                        try
                        {
                            session.statementManager.FreeStatement(name);
                            return(Result.UpdateZeroResult);
                        }
                        catch (CoreException exception7)
                        {
                            return(Result.NewErrorResult(exception7, base.Sql));
                        }
                        break;
                    }

                    case 0x16:
                        goto Label_0374;
                    }
                }
            }
            else
            {
                if (type <= 0x40a)
                {
                    if ((type - 0x62) <= 1)
                    {
                        goto Label_0944;
                    }
                    switch (type)
                    {
                    case 0x6d:
                        goto Label_0184;

                    case 110:
                        goto Label_094C;

                    case 0x6f:
                    {
                        bool flag2 = true;
                        try
                        {
                            if (this._parameters[0] != null)
                            {
                                bool rdy = Convert.ToBoolean(this._parameters[0], CultureInfo.CurrentCulture);
                                session.SetReadOnly(rdy);
                            }
                            if (this._parameters[1] != null)
                            {
                                int level = Convert.ToInt32(this._parameters[1]);
                                session.SetIsolation(level);
                            }
                            if (flag2)
                            {
                                session.StartTransaction();
                            }
                            return(Result.UpdateZeroResult);
                        }
                        catch (CoreException exception1)
                        {
                            return(Result.NewErrorResult(exception1, base.Sql));
                        }
                        break;
                    }
                    }
                    if (type != 0x40a)
                    {
                        goto Label_094C;
                    }
                    try
                    {
                        bool mode = Convert.ToBoolean(this._parameters[0], CultureInfo.CurrentCulture);
                        session.SetIgnoreCase(mode);
                        return(Result.UpdateZeroResult);
                    }
                    catch (CoreException exception2)
                    {
                        return(Result.NewErrorResult(exception2, base.Sql));
                    }
                }
                switch (type)
                {
                case 0x415:
                    goto Label_0245;

                case 0x416:
                    goto Label_02CF;

                case 0x417:
                {
                    int count = Convert.ToInt32(this._parameters[0]);
                    session.SetResultMemoryRowCount(count);
                    return(Result.UpdateZeroResult);
                }

                case 0x418:
                {
                    string name = (string)this._parameters[0];
                    try
                    {
                        session.RollbackToSavepoint(name);
                        return(Result.UpdateZeroResult);
                    }
                    catch (CoreException exception3)
                    {
                        return(Result.NewErrorResult(exception3, base.Sql));
                    }
                    break;
                }

                case 0x420:
                    goto Label_027F;

                case 0x814:
                    goto Label_0184;
                }
            }
            goto Label_094C;
Label_0184:
            table = (Table)this._parameters[0];
            List <Constraint> tempConstraints = (List <Constraint>) this._parameters[1];
            StatementDMQL     tdmql           = (StatementDMQL)this._parameters[2];
            ColumnSchema      variable        = null;

            if (this._parameters.Length > 3)
            {
                variable = (ColumnSchema)this._parameters[3];
            }
            try
            {
                if (tempConstraints != null)
                {
                    table = ParserDDL.AddTableConstraintDefinitions(session, table, tempConstraints, null, false);
                }
                table.Compile(session, null);
                session.sessionContext.AddSessionTable(table);
                if (table.hasLobColumn)
                {
                    throw Error.GetError(0x4b0);
                }
                if (tdmql != null)
                {
                    Result result = tdmql.Execute(session);
                    table.InsertIntoTable(session, result);
                }
                if (variable != null)
                {
                    session.sessionContext.AddSessionVariable(variable);
                }
                return(Result.UpdateZeroResult);
            }
            catch (CoreException exception4)
            {
                return(Result.NewErrorResult(exception4, base.Sql));
            }
Label_0245:
            flag = Convert.ToBoolean(this._parameters[0], CultureInfo.CurrentCulture);
            try
            {
                session.SetAutoCommit(flag);
                return(Result.UpdateZeroResult);
            }
            catch (CoreException exception5)
            {
                return(Result.NewErrorResult(exception5, base.Sql));
            }
Label_027F:
            schemaArray = (ColumnSchema[])this._parameters[0];
            try
            {
                for (int i = 0; i < schemaArray.Length; i++)
                {
                    session.sessionContext.AddSessionVariable(schemaArray[i]);
                }
                return(Result.UpdateZeroResult);
            }
            catch (CoreException exception6)
            {
                return(Result.NewErrorResult(exception6, base.Sql));
            }
Label_02CF:
            num2 = Convert.ToInt32(this._parameters[0]);
            session.SetSqlMaxRows(num2);
            return(Result.UpdateZeroResult);

Label_0374:
            session.Close();
            return(Result.UpdateZeroResult);

Label_056E:
            role = null;
            try
            {
                string data = (string)this._expressions[0].GetValue(session);
                if (data != null)
                {
                    data = (string)SqlType.SqlVarchar.Trim(session, data, " ", true, true);
                    role = session.database.granteeManager.GetRole(data);
                }
            }
            catch (CoreException)
            {
                return(Result.NewErrorResult(Error.GetError(0x898), base.Sql));
            }
            if (session.IsInMidTransaction())
            {
                return(Result.NewErrorResult(Error.GetError(0xe75), base.Sql));
            }
            if (role == null)
            {
                session.SetRole(null);
                return(Result.UpdateZeroResult);
            }
            if (session.GetGrantee().HasRole(role))
            {
                session.SetRole(role);
                return(Result.UpdateZeroResult);
            }
            return(Result.NewErrorResult(Error.GetError(0x898), base.Sql));

Label_06C8:
            if (session.IsInMidTransaction())
            {
                return(Result.NewErrorResult(Error.GetError(0xe75), base.Sql));
            }
            try
            {
                User   user;
                string password = null;
                string data     = (string)this._expressions[0].GetValue(session);
                data = (string)SqlType.SqlVarchar.Trim(session, data, " ", true, true);
                if (this._expressions[1] != null)
                {
                    password = (string)this._expressions[1].GetValue(session);
                }
                if (password == null)
                {
                    user = session.database.userManager.Get(data);
                }
                else
                {
                    user = session.database.GetUserManager().GetUser(data, password);
                }
                if (user == null)
                {
                    throw Error.GetError(0xfa1);
                }
                base.Sql = user.GetConnectUserSQL();
                if (user != session.GetGrantee())
                {
                    if ((password == null) && !session.GetGrantee().CanChangeAuthorisation())
                    {
                        throw Error.GetError(0xfa0);
                    }
                    session.SetUser(user);
                    session.SetRole(null);
                    session.ResetSchema();
                }
                return(Result.UpdateZeroResult);
            }
            catch (CoreException exception13)
            {
                return(Result.NewErrorResult(exception13, base.Sql));
            }
Label_07EA:
            obj2 = null;
            if ((this._expressions[0].GetExprType() == 1) && (this._expressions[0].GetConstantValueNoCheck(session) == null))
            {
                session.SetZoneSeconds(session.SessionTimeZoneSeconds);
                return(Result.UpdateZeroResult);
            }
            try
            {
                obj2 = this._expressions[0].GetValue(session);
            }
            catch (CoreException)
            {
            }
            Result result3 = obj2 as Result;

            if (result3 != null)
            {
                if (!result3.IsData())
                {
                    return(Result.NewErrorResult(Error.GetError(0xd51), base.Sql));
                }
                object[] next = result3.GetNavigator().GetNext();
                if ((result3.GetNavigator().Next() || (next == null)) || (next[0] == null))
                {
                    result3.GetNavigator().Close();
                    return(Result.NewErrorResult(Error.GetError(0xd51), base.Sql));
                }
                obj2 = next[0];
                result3.GetNavigator().Close();
            }
            else if (obj2 == null)
            {
                return(Result.NewErrorResult(Error.GetError(0xd51), base.Sql));
            }
            long seconds = ((IntervalSecondData)obj2).GetSeconds();

            if ((-((long)DTIType.TimezoneSecondsLimit) <= seconds) && (seconds <= DTIType.TimezoneSecondsLimit))
            {
                session.SetZoneSeconds((int)seconds);
                return(Result.UpdateZeroResult);
            }
            return(Result.NewErrorResult(Error.GetError(0xd51), base.Sql));

Label_0944:
            return(this.ProcessPrepare(session));

Label_094C:
            throw Error.RuntimeError(0xc9, "StatementSession");
        }
예제 #2
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);
        }