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"); }
public Result GetResult(Session session) { QNameManager.QName schemaName = this._statements[0].GetSchemaName(); if (base.IsExplain) { return(Result.NewSingleColumnStringResult("OPERATION", this.Describe(session))); } Result result2 = this._statements[0].Execute(session); List <Constraint> list = new List <Constraint>(); StatementSchema schema = new StatementSchema(null, 0x430, null); if ((this._statements.Length != 1) && !result2.IsError()) { QNameManager.QName currentSchemaQName = session.GetCurrentSchemaQName(); for (int i = 1; i < this._statements.Length; i++) { try { session.SetSchema(schemaName.Name); } catch (CoreException) { } this._statements[i].SetSchemaQName(schemaName); session.Parser.Reset(this._statements[i].GetSql()); try { StatementSchema schema2; session.Parser.Read(); int statementType = this._statements[i].GetStatementType(); if (statementType <= 0x3d) { switch (statementType) { case 0x30: case 0x31: result2 = this._statements[i].Execute(session); goto Label_02D0; case 0x34: case 6: goto Label_02B4; case 0x17: case 14: goto Label_026F; case 0x3d: case 8: case 10: goto Label_025D; } goto Label_02C0; } if (statementType <= 0x72) { StatementSchema schema1; switch (statementType) { case 0x4d: schema1 = session.Parser.CompileCreate(); schema1.IsSchemaDefinition = true; schema1.SetSchemaQName(schemaName); if (session.Parser.token.TokenType != 0x2ec) { throw session.Parser.UnexpectedToken(); } break; case 0x4e: case 0x51: case 0x52: goto Label_02C0; case 0x4f: goto Label_02B4; case 80: case 0x54: goto Label_026F; case 0x53: goto Label_025D; default: if (statementType == 0x72) { goto Label_02B4; } goto Label_02C0; } schema1.SetIsLogged(false); result2 = schema1.Execute(session); QNameManager.QName name = ((Table)schema1.Arguments[0]).GetName(); Table schemaObject = (Table)session.database.schemaManager.GetSchemaObject(name); List <Constraint> collection = (List <Constraint>)schema1.Arguments[1]; list.AddRange(collection); collection.Clear(); schema.Sql = schemaObject.GetSql(); schema.Execute(session); goto Label_02D0; } switch (statementType) { case 0x75: goto Label_02B4; case 0x85: break; case 0x41c: goto Label_026F; default: goto Label_02C0; } Label_025D: result2 = this._statements[i].Execute(session); goto Label_02D0; Label_026F: schema2 = session.Parser.CompileCreate(); schema2.IsSchemaDefinition = true; schema2.SetSchemaQName(schemaName); if (session.Parser.token.TokenType != 0x2ec) { throw session.Parser.UnexpectedToken(); } result2 = schema2.Execute(session); goto Label_02D0; Label_02B4: throw session.Parser.UnsupportedFeature(); Label_02C0: throw Error.RuntimeError(0xc9, ""); Label_02D0: if (result2.IsError()) { break; } } catch (CoreException exception2) { result2 = Result.NewErrorResult(exception2, this._statements[i].GetSql()); break; } } if (!result2.IsError()) { try { for (int j = 0; j < list.Count; j++) { Constraint c = list[j]; Table userTable = session.database.schemaManager.GetUserTable(session, c.Core.RefTableName); ParserDDL.AddForeignKey(session, userTable, c, null); schema.Sql = c.GetSql(); schema.Execute(session); } } catch (CoreException exception3) { result2 = Result.NewErrorResult(exception3, base.Sql); } } if (result2.IsError()) { try { session.database.schemaManager.DropSchema(session, schemaName.Name, true); session.database.logger.WriteToLog(session, GetDropSchemaStatement(schemaName)); } catch (CoreException) { } } try { session.SetCurrentSchemaQName(currentSchemaQName); } catch (Exception) { } } return(result2); }
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); }