示例#1
0
        public Node GetLeft()
        {
            if (Trace.AssertEnabled)
            {
                Trace.Assert(iBalance != -2);
            }

            if (iLeft == 0)
            {
                return(nLeft);
            }

            // rData.iLastAccess=Row.iCurrentAccess++;
            return(rData.GetNode(iLeft, iId));
        }
示例#2
0
        public Node GetNode(int pos, int index)
        {
            Row r = tTable.cCache.GetRow(pos, tTable);

            r.LastAccess = CurrentAccess++;

            return(r.GetNode(index));
        }
示例#3
0
        public void InsertNoCheck(object[] row, Channel c, bool log)
        {
            int i;

            if (iIdentityColumn != -1)
            {
                if (row[iIdentityColumn] == null)
                {
                    if (c != null)
                    {
                        c.LastIdentity = iIdentityId;
                    }

                    row[iIdentityColumn] = iIdentityId++;
                }
                else
                {
                    i = (int)row[iIdentityColumn];

                    if (iIdentityId <= i)
                    {
                        if (c != null)
                        {
                            c.LastIdentity = i;
                        }

                        iIdentityId = i + 1;
                    }
                }
            }

            if (iTimestampColumn != -1)
            {
                if (row[iTimestampColumn] == null)
                {
                    row[iTimestampColumn] = DateTime.Now;
                }
                else
                {
                    DateTime timestamp = DateTime.Now;
                    DateTime original  = (DateTime)row[iTimestampColumn];

                    // just in case to assure our timestamp is unique
                    if (timestamp == original)
                    {
                        row[iTimestampColumn] = timestamp.AddMilliseconds(1);
                    }
                    else
                    {
                        row[iTimestampColumn] = timestamp;
                    }
                }
            }

            for (i = 0; i < iColumnCount; i++)
            {
                if (row[i] == null && !GetColumn(i).IsNullable)
                {
                    throw Trace.Error(Trace.TRY_TO_INSERT_NULL);
                }
            }

            try
            {
                Row r = new Row(this, row);

                for (i = 0; i < iIndexCount; i++)
                {
                    Node n = r.GetNode(i);

                    GetIndex(i).Insert(n);
                }
            }
            catch (Exception e)
            {                // rollback insert
                for (--i; i >= 0; i--)
                {
                    GetIndex(i).Delete(row, i == 0);
                }

                throw e;                                      // and throw error again
            }

            if (c != null)
            {
                c.AddTransactionInsert(this, row);
            }

            if (lLog != null)
            {
                lLog.Write(c, GetInsertStatement(row));
            }
        }
示例#4
0
        public void InsertNoCheck(object[] row, Channel c, bool log)
        {
            int i;

            if (iIdentityColumn != -1)
            {
                if (row[iIdentityColumn] == null)
                {
                    if (c != null)
                    {
                        c.LastIdentity = iIdentityId;
                    }

                    row[iIdentityColumn] = iIdentityId++;
                }
                else
                {
                    i = (int) row[iIdentityColumn];

                    if (iIdentityId <= i)
                    {
                        if (c != null)
                        {
                            c.LastIdentity = i;
                        }

                        iIdentityId = i + 1;
                    }
                }
            }

            if (iTimestampColumn != -1)
            {
                if (row[iTimestampColumn] == null)
                {
                    row[iTimestampColumn] = DateTime.Now;
                }
                else
                {
                    DateTime timestamp = DateTime.Now;
                    DateTime original = (DateTime) row[iTimestampColumn];

                    // just in case to assure our timestamp is unique
                    if ( timestamp == original )
                    {
                        row[iTimestampColumn] = timestamp.AddMilliseconds(1);
                    }
                    else
                    {
                        row[iTimestampColumn] = timestamp;
                    }
                }
            }

            for (i = 0; i < iColumnCount; i++)
            {
                if (row[i] == null &&!GetColumn(i).IsNullable)
                {
                    throw TracingHelper.Error(TracingHelper.TRY_TO_INSERT_NULL);
                }
            }

            try
            {
                Row r = new Row(this, row);

                for (i = 0; i < iIndexCount; i++)
                {
                    Node n = r.GetNode(i);

                    GetIndex(i).Insert(n);
                }
            }
            catch (Exception e)
            {    // rollback insert
                for (--i; i >= 0; i--)
                {
                    GetIndex(i).Delete(row, i == 0);
                }

                throw e;		      // and throw error again
            }

            if (c != null)
            {
                c.AddTransactionInsert(this, row);
            }

            if (lLog != null)
            {
                lLog.Write(c, GetInsertStatement(row));
            }
        }