public override bool ContainsRow(object[] data) { IRowIterator iterator1 = this._mainIndex.FindFirstRow(this._session, this.Store, data); bool flag = iterator1.HasNext(); iterator1.Release(); return(flag); }
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); } } }
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); }
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++; } } }