/** Walk each configuration and if they are all the same alt, return * that alt else return NFA.INVALID_ALT_NUMBER. Ignore resolved * configurations, but don't ignore resolveWithPredicate configs * because this state should not be an accept state. We need to add * this to the work list and then have semantic predicate edges * emanating from it. */ public virtual int GetUniquelyPredictedAlt() { if (cachedUniquelyPredicatedAlt != PREDICTED_ALT_UNSET) { return(cachedUniquelyPredicatedAlt); } int alt = NFA.INVALID_ALT_NUMBER; int numConfigs = nfaConfigurations.Size(); for (int i = 0; i < numConfigs; i++) { NFAConfiguration configuration = (NFAConfiguration)nfaConfigurations.Get(i); // ignore anything we resolved; predicates will still result // in transitions out of this state, so must count those // configurations; i.e., don't ignore resolveWithPredicate configs if (configuration.resolved) { continue; } if (alt == NFA.INVALID_ALT_NUMBER) { alt = configuration.alt; // found first nonresolved alt } else if (configuration.alt != alt) { return(NFA.INVALID_ALT_NUMBER); } } this.cachedUniquelyPredicatedAlt = alt; return(alt); }
public void Revoke(OrderedHashSet <string> granteeList, ISchemaObject dbObject, Right rights, Grantee grantor, bool grantOption, bool cascade) { RoutineSchema schema = dbObject as RoutineSchema; if (schema != null) { ISchemaObject[] specificRoutines = schema.GetSpecificRoutines(); this.Revoke(granteeList, specificRoutines, rights, grantor, grantOption, cascade); } else { QNameManager.QName specificName = dbObject.GetName(); Routine routine = dbObject as Routine; if (routine != null) { specificName = routine.GetSpecificName(); } if (!grantor.IsFullyAccessibleByRole(specificName)) { throw Error.GetError(0x157d, dbObject.GetName().Name); } if (grantor.IsAdmin()) { grantor = dbObject.GetOwner(); } for (int i = 0; i < granteeList.Size(); i++) { string str = granteeList.Get(i); if (this.Get(str) == null) { throw Error.GetError(0xfa1, str); } if (IsImmutable(str)) { throw Error.GetError(0xfa2, str); } } for (int j = 0; j < granteeList.Size(); j++) { string str2 = granteeList.Get(j); Grantee role = this.Get(str2); role.Revoke(dbObject, rights, grantor, grantOption); role.UpdateAllRights(); if (role.IsRole) { this.UpdateAllRights(role); } } } }
private Result GetExplainResult(Session session) { Result result = Result.NewSingleColumnStringResult("OPERATION", this.Describe(session)); OrderedHashSet <QNameManager.QName> references = this.GetReferences(); object[] data = new object[] { "Object References" }; result.navigator.Add(data); for (int i = 0; i < references.Size(); i++) { QNameManager.QName name = references.Get(i); object[] objArray2 = new object[] { name.GetSchemaQualifiedStatementName() }; result.navigator.Add(objArray2); } object[] objArray3 = new object[] { "Read Locks" }; result.navigator.Add(objArray3); for (int j = 0; j < base.ReadTableNames.Length; j++) { QNameManager.QName name2 = base.ReadTableNames[j]; object[] objArray4 = new object[] { name2.GetSchemaQualifiedStatementName() }; result.navigator.Add(objArray4); } object[] objArray5 = new object[] { "WriteLocks" }; result.navigator.Add(objArray5); for (int k = 0; k < base.WriteTableNames.Length; k++) { QNameManager.QName name3 = base.WriteTableNames[k]; object[] objArray6 = new object[] { name3.GetSchemaQualifiedStatementName() }; result.navigator.Add(objArray6); } return(result); }
public static void SetVariables(RangeVariable[] rangeVars, OrderedHashSet <string> colNames, int[] indexes, ColumnSchema[] variables) { int i = -1; for (int j = 0; j < variables.Length; j++) { string columnName = colNames.Get(j); for (int k = 0; k < rangeVars.Length; k++) { if (rangeVars[k].IsVariable) { i = rangeVars[k].FindColumn(columnName); if (i > -1) { indexes[j] = i; variables[j] = rangeVars[k].GetColumn(i); break; } } } if (i == -1) { throw Error.GetError(0x157d, columnName); } } }
private static void SetColumns(Table t, OrderedHashSet <string> set) { int num = 0; bool[] newColumnCheckList = t.GetNewColumnCheckList(); for (int i = 0; i < set.Size(); i++) { string name = set.Get(i); int index = t.FindColumn(name); if (index == -1) { throw Error.GetError(0x157d, name); } newColumnCheckList[index] = true; num++; } if (num == 0) { throw Error.GetError(0x157d); } set.Clear(); for (int j = 0; j < newColumnCheckList.Length; j++) { if (newColumnCheckList[j]) { set.Add(t.GetColumn(j).GetName().Name); } } }
public void CheckRoleList(string granteeName, OrderedHashSet <string> roleList, Grantee grantor, bool grant) { Grantee grantee = this.Get(granteeName); for (int i = 0; i < roleList.Size(); i++) { string name = roleList.Get(i); Grantee role = this.GetRole(name); if (role == null) { throw Error.GetError(0x898, name); } if (name.Equals("SYS") || name.Equals("PUBLIC")) { throw Error.GetError(0xfa2, name); } if (grant) { if (grantee.GetDirectRoles().Contains(role)) { throw Error.GetError(0x898, granteeName); } } else if (!grantee.GetDirectRoles().Contains(role)) { throw Error.GetError(0x898, name); } if (!grantor.IsAdmin()) { throw Error.GetError(0x7d0, grantor.GetNameString()); } } }
public Right GetAllGrantableRights(QNameManager.QName name) { if (this._isAdmin) { return(name.schema.Owner.OwnerRights); } if (name.schema.Owner == this) { return(this.OwnerRights); } if (this.Roles.Contains(name.schema.Owner)) { return(name.schema.Owner.OwnerRights); } OrderedHashSet <Grantee> allRoles = this.GetAllRoles(); for (int i = 0; i < allRoles.Size(); i++) { Grantee grantee = allRoles.Get(i); if (name.schema.Owner == grantee) { return(grantee.OwnerRights); } } Right right2 = this._fullRightsMap.Get(name); if ((right2 != null) && (right2.GrantableRights != null)) { return(right2.GrantableRights); } return(Right.NoRights); }
public OrderedHashSet <QNameManager.QName> GetReferences() { switch (this.ConstType) { case 0: { OrderedHashSet <QNameManager.QName> set1 = new OrderedHashSet <QNameManager.QName>(); set1.Add(this.Core.UniqueName); return(set1); } case 3: { OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>(); this.Check.CollectObjectNames(set); for (int i = set.Size() - 1; i >= 0; i--) { QNameManager.QName name = set.Get(i); if ((name.type == 9) || (name.type == 3)) { set.Remove(i); } } return(set); } } return(new OrderedHashSet <QNameManager.QName>()); }
public void UpdateConstraints(OrderedHashSet <Table> tableSet, OrderedHashSet <QNameManager.QName> dropConstraints) { for (int i = 0; i < tableSet.Size(); i++) { Table t = tableSet.Get(i); this.UpdateConstraints(t, dropConstraints); } }
public void SetNewTablesInSchema(OrderedHashSet <Table> tableSet) { for (int i = 0; i < tableSet.Size(); i++) { Table newTable = tableSet.Get(i); this.SetNewTableInSchema(newTable); } }
public OrderedHashSet <Table> MakeNewTables(OrderedHashSet <Table> tableSet, OrderedHashSet <QNameManager.QName> dropConstraintSet, OrderedHashSet <QNameManager.QName> dropIndexSet) { OrderedHashSet <Table> set = new OrderedHashSet <Table>(); for (int i = 0; i < tableSet.Size(); i++) { Table table = tableSet.Get(i); TableWorks works = new TableWorks(this._session, table); works.MakeNewTable(dropConstraintSet, dropIndexSet); set.Add(works.GetTable()); } return(set); }
private void ProcessGrantRevokeRole(Session session) { bool grant = base.type == 0x31; OrderedHashSet <string> granteeList = (OrderedHashSet <string>) this.Arguments[0]; OrderedHashSet <string> roleList = (OrderedHashSet <string>) this.Arguments[1]; Grantee grantor = (Grantee)this.Arguments[2]; GranteeManager granteeManager = session.database.granteeManager; granteeManager.CheckGranteeList(granteeList); for (int i = 0; i < granteeList.Size(); i++) { string granteeName = granteeList.Get(i); granteeManager.CheckRoleList(granteeName, roleList, grantor, grant); } if (grant) { for (int j = 0; j < granteeList.Size(); j++) { string granteeName = granteeList.Get(j); for (int k = 0; k < roleList.Size(); k++) { string roleName = roleList.Get(k); granteeManager.Grant(granteeName, roleName, grantor); } } } else { for (int j = 0; j < granteeList.Size(); j++) { string granteeName = granteeList.Get(j); for (int k = 0; k < roleList.Size(); k++) { granteeManager.Revoke(granteeName, roleList.Get(k), grantor); } } } }
private static bool IsChildObjectResolved(ISchemaObject obj, OrderedHashSet <object> resolved) { OrderedHashSet <QNameManager.QName> references = obj.GetReferences(); for (int i = 0; i < references.Size(); i++) { QNameManager.QName name = references.Get(i); if (!SqlInvariants.IsSystemSchemaName(name) && !resolved.Contains(name)) { return(false); } } return(true); }
public static string RoleMapToString(OrderedHashSet <Grantee> roles) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < roles.Size(); i++) { if (builder.Length > 0) { builder.Append(','); } builder.Append(roles.Get(i).GetStatementName()); } return(builder.ToString()); }
public void CheckGranteeList(OrderedHashSet <string> granteeList) { for (int i = 0; i < granteeList.Size(); i++) { string name = granteeList.Get(i); if (this.Get(name) == null) { throw Error.GetError(0xfa1, name); } if (IsImmutable(name)) { throw Error.GetError(0xfa2, name); } } }
private static void DropDomain(Session session, QNameManager.QName name, bool cascade) { SqlType schemaObject = (SqlType)session.database.schemaManager.GetSchemaObject(name); OrderedHashSet <QNameManager.QName> referencingObjectNames = session.database.schemaManager.GetReferencingObjectNames(schemaObject.GetName()); if (!cascade && (referencingObjectNames.Size() > 0)) { QNameManager.QName name2 = referencingObjectNames.Get(0); throw Error.GetError(0x157e, name2.GetSchemaQualifiedStatementName()); } Constraint[] constraints = schemaObject.userTypeModifier.GetConstraints(); referencingObjectNames.Clear(); for (int i = 0; i < constraints.Length; i++) { referencingObjectNames.Add(constraints[i].GetName()); } session.database.schemaManager.RemoveSchemaObjects(referencingObjectNames); session.database.schemaManager.RemoveSchemaObject(schemaObject.GetName(), cascade); schemaObject.userTypeModifier = null; }
private static void GetColumnList(Table t, OrderedHashSet <string> set, StringBuilder buf) { int num = 0; bool[] newColumnCheckList = t.GetNewColumnCheckList(); for (int i = 0; i < set.Size(); i++) { string name = set.Get(i); int num5 = t.FindColumn(name); if (num5 != -1) { newColumnCheckList[num5] = true; num++; } } if (num == 0) { throw Error.RuntimeError(0xc9, "Right"); } buf.Append('('); int index = 0; int num3 = 0; while (index < newColumnCheckList.Length) { if (newColumnCheckList[index]) { num3++; buf.Append(t.GetColumn(index).GetName().StatementName); if (num3 < num) { buf.Append(','); } } index++; } buf.Append(')'); }
private static void CheckNoSqlData(Database database, OrderedHashSet <QNameManager.QName> set) { for (int i = 0; i < set.Size(); i++) { QNameManager.QName name = set.Get(i); if (name.type == 0x18) { Routine schemaObject = (Routine)database.schemaManager.GetSchemaObject(name); if (schemaObject.DataImpact == 3) { throw Error.GetError(0x15e8, "READS SQL"); } if (schemaObject.DataImpact == 4) { throw Error.GetError(0x15e8, "MODIFIES SQL"); } if (name.type == 3) { throw Error.GetError(0x15e8, "READS SQL"); } } } }
private Result ProcessExecute(Session session) { string name = (string)this._parameters[0]; OrderedHashSet <Expression> set = (OrderedHashSet <Expression>) this._parameters[1]; try { object[] parameterValues = new object[set.Size()]; for (int i = 0; i < set.Size(); i++) { parameterValues[i] = set.Get(i).GetValue(session); } Statement statement = session.statementManager.GetStatement(session, name); Result cmd = Result.NewPreparedExecuteRequest(statement.GetParametersMetaData().GetParameterTypes(), statement.GetId()); cmd.SetStatement(statement); cmd.SetPreparedExecuteProperties(parameterValues, 0, 0, ResultProperties.DefaultPropsValue); return(session.Execute(cmd)); } catch (CoreException exception1) { return(Result.NewErrorResult(exception1, base.Sql)); } }
public void Grant(OrderedHashSet <string> granteeList, ISchemaObject dbObject, Right right, Grantee grantor, bool withGrantOption) { RoutineSchema schema = dbObject as RoutineSchema; if (schema != null) { ISchemaObject[] specificRoutines = schema.GetSpecificRoutines(); this.Grant(granteeList, specificRoutines, right, grantor, withGrantOption); } else { QNameManager.QName specificName = dbObject.GetName(); Routine routine = dbObject as Routine; if (routine != null) { specificName = routine.GetSpecificName(); } if (!grantor.IsGrantable(dbObject, right)) { throw Error.GetError(0x7d0, grantor.GetNameString()); } if (grantor.IsAdmin()) { grantor = dbObject.GetOwner(); } this.CheckGranteeList(granteeList); for (int i = 0; i < granteeList.Size(); i++) { Grantee role = this.Get(granteeList.Get(i)); role.Grant(specificName, right, grantor, withGrantOption); if (role.IsRole) { this.UpdateAllRights(role); } } } }
/** Add label uniquely and disjointly; intersection with * another set or int/char forces breaking up the set(s). * * Example, if reachable list of labels is [a..z, {k,9}, 0..9], * the disjoint list will be [{a..j,l..z}, k, 9, 0..8]. * * As we add NFA configurations to a DFA state, we might as well track * the set of all possible transition labels to make the DFA conversion * more efficient. W/o the reachable labels, we'd need to check the * whole vocabulary space (could be 0..\uFFFF)! The problem is that * labels can be sets, which may overlap with int labels or other sets. * As we need a deterministic set of transitions from any * state in the DFA, we must make the reachable labels set disjoint. * This operation amounts to finding the character classes for this * DFA state whereas with tools like flex, that need to generate a * homogeneous DFA, must compute char classes across all states. * We are going to generate DFAs with heterogeneous states so we * only care that the set of transitions out of a single state are * unique. :) * * The idea for adding a new set, t, is to look for overlap with the * elements of existing list s. Upon overlap, replace * existing set s[i] with two new disjoint sets, s[i]-t and s[i]&t. * (if s[i]-t is nil, don't add). The remainder is t-s[i], which is * what you want to add to the set minus what was already there. The * remainder must then be compared against the i+1..n elements in s * looking for another collision. Each collision results in a smaller * and smaller remainder. Stop when you run out of s elements or * remainder goes to nil. If remainder is non nil when you run out of * s elements, then add remainder to the end. * * Single element labels are treated as sets to make the code uniform. */ protected virtual void AddReachableLabel(Label label) { if (_reachableLabels == null) { _reachableLabels = new OrderedHashSet <Label>(); } /* * [email protected]("addReachableLabel to state "+dfa.decisionNumber+"."+stateNumber+": "+label.getSet().toString(dfa.nfa.grammar)); * [email protected]("start of add to state "+dfa.decisionNumber+"."+stateNumber+": " + * "reachableLabels="+reachableLabels.toString()); */ if (_reachableLabels.Contains(label)) { // exact label present return; } IIntSet t = label.Set; IIntSet remainder = t; // remainder starts out as whole set to add int n = _reachableLabels.Size(); // only look at initial elements // walk the existing list looking for the collision for (int i = 0; i < n; i++) { Label rl = _reachableLabels.Get(i); /* * [email protected]("comparing ["+i+"]: "+label.toString(dfa.nfa.grammar)+" & "+ * rl.toString(dfa.nfa.grammar)+"="+ * intersection.toString(dfa.nfa.grammar)); */ if (!Label.Intersect(label, rl)) { continue; } //[email protected](label+" collides with "+rl); // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t) // (ignoring s_i-t if nil; don't put in list) // Replace existing s_i with intersection since we // know that will always be a non nil character class IIntSet s_i = rl.Set; IIntSet intersection = s_i.And(t); _reachableLabels.Set(i, new Label(intersection)); // Compute s_i-t to see what is in current set and not in incoming IIntSet existingMinusNewElements = s_i.Subtract(t); //[email protected](s_i+"-"+t+"="+existingMinusNewElements); if (!existingMinusNewElements.IsNil) { // found a new character class, add to the end (doesn't affect // outer loop duration due to n computation a priori. Label newLabel = new Label(existingMinusNewElements); _reachableLabels.Add(newLabel); } /* * [email protected]("after collision, " + * "reachableLabels="+reachableLabels.toString()); */ // anything left to add to the reachableLabels? remainder = t.Subtract(s_i); if (remainder.IsNil) { break; // nothing left to add to set. done! } t = remainder; } if (!remainder.IsNil) { /* * [email protected]("before add remainder to state "+dfa.decisionNumber+"."+stateNumber+": " + * "reachableLabels="+reachableLabels.toString()); * [email protected]("remainder state "+dfa.decisionNumber+"."+stateNumber+": "+remainder.toString(dfa.nfa.grammar)); */ Label newLabel = new Label(remainder); _reachableLabels.Add(newLabel); } /* * [email protected]("#END of add to state "+dfa.decisionNumber+"."+stateNumber+": " + * "reachableLabels="+reachableLabels.toString()); */ }
public static void AddAllSql(OrderedHashSet <object> resolved, OrderedHashSet <object> unresolved, List <string> list, Iterator <object> it, OrderedHashSet <object> newResolved) { while (it.HasNext()) { ISchemaObject key = (ISchemaObject)it.Next(); OrderedHashSet <QNameManager.QName> references = key.GetReferences(); bool flag = true; for (int i = 0; i < references.Size(); i++) { QNameManager.QName name = references.Get(i); if (SqlInvariants.IsSystemSchemaName(name) || (name.schema == SqlInvariants.ModuleQname)) { continue; } int type = name.type; switch (type) { case 3: { if (!resolved.Contains(name)) { flag = false; } continue; } case 4: case 6: case 7: case 8: case 10: case 11: case 15: { continue; } case 5: { if (name.Parent == key.GetName()) { Constraint constraint = ((Table)key).GetConstraint(name.Name); if ((constraint.GetConstraintType() == 3) && !IsChildObjectResolved(constraint, resolved)) { flag = false; } } continue; } case 9: { if (key.GetSchemaObjectType() != 3) { break; } Table table1 = (Table)key; if (!IsChildObjectResolved(table1.GetColumn(table1.FindColumn(name.Name)), resolved)) { flag = false; } continue; } case 12: case 13: case 0x10: case 0x11: goto Label_0147; case 14: { if (name.schema != null) { goto Label_0147; } continue; } default: goto Label_013B; } if (!resolved.Contains(name.Parent)) { flag = false; } continue; Label_013B: if ((type != 0x18) && (type != 0x1b)) { continue; } Label_0147: if (!resolved.Contains(name)) { flag = false; } } if (!flag) { unresolved.Add(key); } else { QNameManager.QName specificName; if (((key.GetSchemaObjectType() == 0x10) || (key.GetSchemaObjectType() == 0x1b)) || (key.GetSchemaObjectType() == 0x11)) { specificName = ((Routine)key).GetSpecificName(); } else { specificName = key.GetName(); } resolved.Add(specificName); if (newResolved != null) { newResolved.Add(key); } if (key.GetSchemaObjectType() == 3) { list.AddRange(((Table)key).GetSql(resolved, unresolved)); } else { if (((key.GetSchemaObjectType() - 0x10) <= 1) && ((Routine)key).IsRecursive) { list.Add(((Routine)key).GetSqlDeclaration()); list.Add(((Routine)key).GetSqlAlter()); continue; } list.Add(key.GetSql()); } } } }
protected virtual IList<IIntSet> MakeEdgeSetsDisjoint( IList<IIntSet> edges ) { OrderedHashSet<IIntSet> disjointSets = new OrderedHashSet<IIntSet>(); // walk each incoming edge label/set and add to disjoint set int numEdges = edges.Count; for ( int e = 0; e < numEdges; e++ ) { IntervalSet t = (IntervalSet)edges[e]; if ( disjointSets.Contains( t ) ) { // exact set present continue; } // compare t with set i for disjointness IntervalSet remainder = t; // remainder starts out as whole set to add int numDisjointElements = disjointSets.Size(); for ( int i = 0; i < numDisjointElements; i++ ) { IntervalSet s_i = (IntervalSet)disjointSets.Get( i ); if ( t.And( s_i ).IsNil ) { // nothing in common continue; } //[email protected](label+" collides with "+rl); // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t) // (ignoring s_i-t if nil; don't put in list) // Replace existing s_i with intersection since we // know that will always be a non nil character class IntervalSet intersection = (IntervalSet)s_i.And( t ); disjointSets.Set( i, intersection ); // Compute s_i-t to see what is in current set and not in incoming IIntSet existingMinusNewElements = s_i.Subtract( t ); //[email protected](s_i+"-"+t+"="+existingMinusNewElements); if ( !existingMinusNewElements.IsNil ) { // found a new character class, add to the end (doesn't affect // outer loop duration due to n computation a priori. disjointSets.Add( existingMinusNewElements ); } // anything left to add to the reachableLabels? remainder = (IntervalSet)t.Subtract( s_i ); if ( remainder.IsNil ) { break; // nothing left to add to set. done! } t = remainder; } if ( !remainder.IsNil ) { disjointSets.Add( remainder ); } } return disjointSets.GetElements(); }
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; }
public void DropConstraint(string name, bool cascade) { Constraint constraint = this._table.GetConstraint(name); if (constraint == null) { throw Error.GetError(0x157d, name); } switch (constraint.GetConstraintType()) { case 0: { this.CheckModifyTable(); OrderedHashSet <QNameManager.QName> dropConstraints = new OrderedHashSet <QNameManager.QName>(); QNameManager.QName mainName = constraint.GetMainName(); dropConstraints.Add(mainName); dropConstraints.Add(constraint.GetRefName()); OrderedHashSet <QNameManager.QName> dropIndexes = new OrderedHashSet <QNameManager.QName>(); dropIndexes.Add(constraint.GetRefIndex().GetName()); Table newTable = this._table.MoveDefinition(this._session, this._table.TableType, null, null, null, -1, 0, dropConstraints, dropIndexes); this.MoveData(this._table, newTable, -1, 0); this._database.schemaManager.RemoveSchemaObject(constraint.GetName()); this.SetNewTableInSchema(newTable); constraint.GetMain().RemoveConstraint(mainName.Name); this.UpdateConstraints(newTable, this.EmptySetQName); this._database.schemaManager.RecompileDependentObjects(this._table); this._table = newTable; return; } case 1: throw Error.GetError(0xfa2); case 2: case 4: { this.CheckModifyTable(); OrderedHashSet <Constraint> dependentConstraints = this._table.GetDependentConstraints(constraint); if (!cascade && !dependentConstraints.IsEmpty()) { Constraint constraint2 = dependentConstraints.Get(0); throw Error.GetError(0x159d, constraint2.GetName().GetSchemaQualifiedStatementName()); } OrderedHashSet <Table> tableSet = new OrderedHashSet <Table>(); OrderedHashSet <QNameManager.QName> dropConstraints = new OrderedHashSet <QNameManager.QName>(); OrderedHashSet <QNameManager.QName> dropIndexes = new OrderedHashSet <QNameManager.QName>(); for (int i = 0; i < dependentConstraints.Size(); i++) { Constraint constraint3 = dependentConstraints.Get(i); Table main = constraint3.GetMain(); if (main != this._table) { tableSet.Add(main); } main = constraint3.GetRef(); if (main != this._table) { tableSet.Add(main); } dropConstraints.Add(constraint3.GetMainName()); dropConstraints.Add(constraint3.GetRefName()); dropIndexes.Add(constraint3.GetRefIndex().GetName()); } dropConstraints.Add(constraint.GetName()); if (constraint.GetConstraintType() == 2) { dropIndexes.Add(constraint.GetMainIndex().GetName()); } Table newTable = this._table.MoveDefinition(this._session, this._table.TableType, null, null, null, -1, 0, dropConstraints, dropIndexes); this.MoveData(this._table, newTable, -1, 0); tableSet = this.MakeNewTables(tableSet, dropConstraints, dropIndexes); if (constraint.GetConstraintType() == 4) { int[] mainColumns = constraint.GetMainColumns(); for (int j = 0; j < mainColumns.Length; j++) { newTable.GetColumn(mainColumns[j]).SetPrimaryKey(false); newTable.SetColumnTypeVars(mainColumns[j]); } } this._database.schemaManager.RemoveSchemaObjects(dropConstraints); this.SetNewTableInSchema(newTable); this.SetNewTablesInSchema(tableSet); this.UpdateConstraints(newTable, this.EmptySetQName); this.UpdateConstraints(tableSet, dropConstraints); this._database.schemaManager.RecompileDependentObjects(tableSet); this._database.schemaManager.RecompileDependentObjects(newTable); this._table = newTable; return; } case 3: this._database.schemaManager.RemoveSchemaObject(constraint.GetName()); if (constraint.IsNotNull()) { this._table.GetColumn(constraint.NotNullColumnIndex).SetNullable(false); this._table.SetColumnTypeVars(constraint.NotNullColumnIndex); } return; } }