Пример #1
0
        public NodeAVL Last(Session session, IPersistentStore store, NodeAVL x)
        {
            if (x == null)
            {
                return(null);
            }
            lock (this._lock)
            {
Label_0012:
                x = this.Last(store, x);
                if (x != null)
                {
                    if (session == null)
                    {
                        return(x);
                    }
                    Row row = x.GetRow(store);
                    if (!session.database.TxManager.CanRead(session, row, 0, null))
                    {
                        goto Label_0012;
                    }
                }
                else
                {
                    return(x);
                }
                return(x);
            }
        }
Пример #2
0
        public IRowIterator FirstRow(Session session, IPersistentStore store)
        {
            IRowIterator iterator;
            int          num = 0;

            Monitor.Enter(this._lock);
            try
            {
                NodeAVL accessor = this.GetAccessor(store);
                NodeAVL left     = accessor;
                while (left != null)
                {
                    accessor = left;
                    left     = accessor.GetLeft(store);
                    num++;
                }
                while ((session != null) && (accessor != null))
                {
                    Row row = accessor.GetRow(store);
                    if (session.database.TxManager.CanRead(session, row, 0, null))
                    {
                        break;
                    }
                    accessor = this.Next(store, accessor);
                }
                iterator = this.GetIterator(session, store, accessor, false, false);
            }
            finally
            {
                this.Depth = num;
                Monitor.Exit(this._lock);
            }
            return(iterator);
        }
Пример #3
0
        protected bool IsEqualReadable(Session session, IPersistentStore store, NodeAVL node)
        {
            object[] data;
            NodeAVL  x = node;

            if (!session.database.TxManager.CanRead(session, node.GetRow(store), 1, null))
            {
                Row row;
                data = node.GetData(store);
                do
                {
                    x = this.Last(store, x);
                    if (x == null)
                    {
                        goto Label_006E;
                    }
                    object[] data = x.GetData(store);
                    if (this.CompareRow(session, data, data) != 0)
                    {
                        goto Label_006E;
                    }
                    row = x.GetRow(store);
                }while (!session.database.TxManager.CanRead(session, row, 1, null));
            }
            return(true);

Label_006E:
            x = this.Next(session, store, node);
            if (x != null)
            {
                object[] data = x.GetData(store);
                if (this.CompareRow(session, data, data) != 0)
                {
                    return(false);
                }
                Row row = x.GetRow(store);
                if (!session.database.TxManager.CanRead(session, row, 1, null))
                {
                    goto Label_006E;
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Пример #4
0
 public IRowIterator LastRow(Session session, IPersistentStore store)
 {
     lock (this._lock)
     {
         NodeAVL accessor = this.GetAccessor(store);
         for (NodeAVL eavl2 = accessor; eavl2 != null; eavl2 = accessor.GetRight(store))
         {
             accessor = eavl2;
         }
         while ((session != null) && (accessor != null))
         {
             Row row = accessor.GetRow(store);
             if (session.database.TxManager.CanRead(session, row, 0, null))
             {
                 break;
             }
             accessor = this.Last(store, accessor);
         }
         return(this.GetIterator(null, store, accessor, false, true));
     }
 }
Пример #5
0
        public virtual void Insert(Session session, IPersistentStore store, Row row)
        {
            bool useRowId = !this.isUnique || this.HasNulls(row.RowData);

            Monitor.Enter(this._lock);
            store.LockStore();
            try
            {
                bool       flag2;
                NodeAVL    eavl2;
                Constraint uniqueConstraintForIndex;
                Row        row2;
                RowAVL     wavl     = (RowAVL)row;
                NodeAVL    accessor = this.GetAccessor(store);
                if (accessor == null)
                {
                    store.SetAccessor(this, wavl.GetNode(this.Position));
                    store.SetElementCount(this, 1, 1);
                    return;
                }
Label_005C:
                row2 = accessor.GetRow(store);
                int num = this.CompareRowForInsertOrDelete(session, row, row2, useRowId, 0);
                if ((((num == 0) && (session != null)) && (!useRowId && session.database.TxManager.IsMvRows())) && !this.IsEqualReadable(session, store, accessor))
                {
                    useRowId = true;
                    num      = this.CompareRowForInsertOrDelete(session, row, row2, useRowId, this.ColIndex.Length);
                }
                if (num != 0)
                {
                    flag2    = num < 0;
                    eavl2    = accessor;
                    accessor = eavl2.Child(store, flag2);
                    if (accessor != null)
                    {
                        goto Label_005C;
                    }
                }
                else
                {
                    uniqueConstraintForIndex = null;
                    if (this.isConstraint)
                    {
                        uniqueConstraintForIndex = ((Table)this.table).GetUniqueConstraintForIndex(this);
                    }
                    goto Label_0119;
                }
                eavl2 = eavl2.Set(store, flag2, wavl.GetNode(this.Position));
                this.Balance(store, eavl2, flag2);
                store.UpdateElementCount(this, 1, 1);
                return;

Label_0119:
                if (uniqueConstraintForIndex == null)
                {
                    throw Error.GetError(0x68, this.Name.StatementName);
                }
                throw uniqueConstraintForIndex.GetException(row.RowData);
            }
            finally
            {
                store.UnlockStore();
                Monitor.Exit(this._lock);
            }
        }
Пример #6
0
        private NodeAVL FindNode(Session session, IPersistentStore store, object[] rowdata, int[] rowColMap, int fieldCount, int compareType, int readMode, bool reversed)
        {
            NodeAVL eavl;

            lock (this._lock)
            {
                Row     row2;
                NodeAVL accessor = this.GetAccessor(store);
                NodeAVL left     = null;
                NodeAVL x        = null;
                if ((compareType != 0x29) && (compareType != 0x2f))
                {
                    fieldCount--;
                }
                while (accessor != null)
                {
                    Row row = accessor.GetRow(store);
                    int num = 0;
                    if (fieldCount > 0)
                    {
                        num = this.CompareRowNonUnique(session, row.RowData, rowdata, rowColMap, fieldCount);
                    }
                    if (num != 0)
                    {
                        goto Label_017B;
                    }
                    switch (compareType)
                    {
                    case 0x29:
                    case 0x2f:
                        x    = accessor;
                        left = accessor.GetLeft(store);
                        goto Label_0197;

                    case 0x2a:
                        if (this.CompareObject(session, row.RowData, rowdata, rowColMap, fieldCount) >= 0)
                        {
                            break;
                        }
                        left = accessor.GetRight(store);
                        goto Label_0197;

                    case 0x2b:
                    case 0x30:
                        if (this.CompareObject(session, row.RowData, rowdata, rowColMap, fieldCount) > 0)
                        {
                            goto Label_00FC;
                        }
                        left = accessor.GetRight(store);
                        goto Label_0197;

                    case 0x2c:
                        if (this.CompareObject(session, row.RowData, rowdata, rowColMap, fieldCount) >= 0)
                        {
                            goto Label_0131;
                        }
                        x    = accessor;
                        left = accessor.GetRight(store);
                        goto Label_0197;

                    case 0x2d:
                        if (this.CompareObject(session, row.RowData, rowdata, rowColMap, fieldCount) > 0)
                        {
                            goto Label_0161;
                        }
                        x    = accessor;
                        left = accessor.GetRight(store);
                        goto Label_0197;

                    default:
                        throw Error.RuntimeError(0xc9, "Index");
                    }
                    x    = accessor;
                    left = accessor.GetLeft(store);
                    goto Label_0197;
Label_00FC:
                    x    = accessor;
                    left = accessor.GetLeft(store);
                    goto Label_0197;
Label_0131:
                    left = accessor.GetLeft(store);
                    goto Label_0197;
Label_0161:
                    left = accessor.GetLeft(store);
                    goto Label_0197;
Label_017B:
                    if (num < 0)
                    {
                        left = accessor.GetRight(store);
                    }
                    else if (num > 0)
                    {
                        left = accessor.GetLeft(store);
                    }
Label_0197:
                    if (left == null)
                    {
                        break;
                    }
                    accessor = left;
                }
                if (session != null)
                {
                    goto Label_0210;
                }
                return(x);

Label_01A9:
                row2 = x.GetRow(store);
                if (session.database.TxManager.CanRead(session, row2, readMode, this.ColIndex))
                {
                    goto Label_0213;
                }
                x = reversed ? this.Last(store, x) : this.Next(store, x);
                if (x == null)
                {
                    goto Label_0213;
                }
                row2 = x.GetRow(store);
                if ((fieldCount > 0) && (this.CompareRowNonUnique(session, row2.RowData, rowdata, rowColMap, fieldCount) != 0))
                {
                    x = null;
                    goto Label_0213;
                }
Label_0210:
                if (x != null)
                {
                    goto Label_01A9;
                }
Label_0213:
                eavl = x;
            }
            return(eavl);
        }