Exemplo n.º 1
0
 private ChapterHandle(object chapteredRowset, RowBinding binding, int valueOffset) : base(chapteredRowset)
 {
     RuntimeHelpers.PrepareConstrainedRegions();
     try {} finally {
         _chapterHandle = binding.InterlockedExchangePointer(valueOffset);
     }
 }
Exemplo n.º 2
0
        // tagDBBINDING[] starting 64bit aligned
        // all DBSTATUS values (32bit per value), starting 64bit aligned
        // all DBLENGTH values (32/64bit per value), starting 64bit alignedsa
        // all data values listed after that (variable length), each individual starting 64bit aligned
        // Int64 - zero for pointers to emptystring

        internal static RowBinding CreateBuffer(int bindingCount, int databuffersize, bool needToReset)
        {
            int headerLength = RowBinding.AlignDataSize(bindingCount * ODB.SizeOf_tagDBBINDING);
            int length       = RowBinding.AlignDataSize(headerLength + databuffersize) + 8; // 8 bytes for a null terminated string

            return(new RowBinding(bindingCount, headerLength, databuffersize, length, needToReset));
        }
Exemplo n.º 3
0
        internal int AllocateForAccessor(OleDbDataReader dataReader, int indexStart, int indexForAccessor)
        {
            Debug.Assert(null == _rowBinding, "row binding already allocated");
            Debug.Assert(null == _columnBindings, "column bindings already allocated");

            RowBinding rowBinding = System.Data.OleDb.RowBinding.CreateBuffer(_count, _dataBufferSize, _needToReset);

            _rowBinding = rowBinding;

            ColumnBinding[] columnBindings = rowBinding.SetBindings(dataReader, this, indexStart, indexForAccessor, _parameters, _dbbindings, _ifIRowsetElseIRow);
            Debug.Assert(null != columnBindings, "null column bindings");
            _columnBindings = columnBindings;

            if (!_ifIRowsetElseIRow)
            {
                Debug.Assert(columnBindings.Length == _dbcolumns.Length, "length mismatch");
                for (int i = 0; i < columnBindings.Length; ++i)
                {
                    _dbcolumns[i].pData = rowBinding.DangerousGetDataPtr(columnBindings[i].ValueOffset); // We are simply pointing at a location later in the buffer, so we're OK to not addref the buffer.
                }
            }

#if DEBUG
            int index = -1;
            foreach (ColumnBinding binding in columnBindings)
            {
                Debug.Assert(index < binding.Index, "invaild index");
                index = binding.Index;
            }
#endif
            return(indexStart + columnBindings.Length);
        }
Exemplo n.º 4
0
 internal static ChapterHandle CreateChapterHandle(object chapteredRowset, RowBinding binding, int valueOffset)
 {
     if ((null == chapteredRowset) || (IntPtr.Zero == binding.ReadIntPtr(valueOffset)))
     {
         return(ChapterHandle.DB_NULL_HCHAPTER);
     }
     return(new ChapterHandle(chapteredRowset, binding, valueOffset));
 }
 internal static ChapterHandle CreateChapterHandle(object chapteredRowset, RowBinding binding, int valueOffset)
 {
     if ((chapteredRowset != null) && !(IntPtr.Zero == binding.ReadIntPtr(valueOffset)))
     {
         return new ChapterHandle(chapteredRowset, binding, valueOffset);
     }
     return DB_NULL_HCHAPTER;
 }
 private ChapterHandle(object chapteredRowset, RowBinding binding, int valueOffset) : base(chapteredRowset)
 {
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
     }
     finally
     {
         this._chapterHandle = binding.InterlockedExchangePointer(valueOffset);
     }
 }
Exemplo n.º 7
0
        public void Dispose()
        {
            _parameters     = null;
            _dataReader     = null;
            _columnBindings = null;

            RowBinding rowBinding = _rowBinding;

            _rowBinding = null;
            if (null != rowBinding)
            {
                rowBinding.Dispose();
            }
        }
Exemplo n.º 8
0
        // dbindings handle can't be freed until the output parameters
        // have been filled in which occurs after the last rowset is released
        // dbbindings.FreeDataHandle occurs in Cloe
        private int ExecuteCommandText(out object executeResult)
        {
            int         retcode;
            tagDBPARAMS dbParams    = null;
            RowBinding  rowbinding  = null;
            Bindings    bindings    = ParameterBindings;
            bool        mustRelease = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (null != bindings)
                { // parameters may be suppressed
                    rowbinding = bindings.RowBinding();

                    rowbinding.DangerousAddRef(ref mustRelease);

                    // bindings can't be released until after last rowset is released
                    // that is when output parameters are populated
                    // initialize the input parameters to the input databuffer
                    bindings.ApplyInputParameters();

                    dbParams            = new tagDBPARAMS();
                    dbParams.pData      = rowbinding.DangerousGetDataPtr();
                    dbParams.cParamSets = 1;
                    dbParams.hAccessor  = rowbinding.DangerousGetAccessorHandle();
                }
                if ((0 == (CommandBehavior.SingleResult & this.commandBehavior)) && _connection.SupportMultipleResults())
                {
                    retcode = ExecuteCommandTextForMultpleResults(dbParams, out executeResult);
                }
                else if (0 == (CommandBehavior.SingleRow & this.commandBehavior) || !_executeQuery)
                {
                    retcode = ExecuteCommandTextForSingleResult(dbParams, out executeResult);
                }
                else
                {
                    retcode = ExecuteCommandTextForSingleRow(dbParams, out executeResult);
                }
            }
            finally
            {
                if (mustRelease)
                {
                    rowbinding.DangerousRelease();
                }
            }
            return(retcode);
        }
Exemplo n.º 9
0
        internal void CleanupBindings()
        {
            RowBinding rowBinding = this.RowBinding();

            if (null != rowBinding)
            {
                rowBinding.ResetValues();

                ColumnBinding[] columnBindings = this.ColumnBindings();
                for (int i = 0; i < columnBindings.Length; ++i)
                {
                    ColumnBinding binding = columnBindings[i];
                    if (null != binding)
                    {
                        binding.ResetValue();
                    }
                }
            }
        }
        private int ExecuteCommandText(out object executeResult)
        {
            tagDBPARAMS dbParams = null;
            RowBinding  binding  = null;
            int         num;
            Bindings    parameterBindings = this.ParameterBindings;
            bool        success           = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (parameterBindings != null)
                {
                    binding = parameterBindings.RowBinding();
                    binding.DangerousAddRef(ref success);
                    parameterBindings.ApplyInputParameters();
                    dbParams = new tagDBPARAMS {
                        pData      = binding.DangerousGetDataPtr(),
                        cParamSets = 1,
                        hAccessor  = binding.DangerousGetAccessorHandle()
                    };
                }
                if (((CommandBehavior.SingleResult & this.commandBehavior) == CommandBehavior.Default) && this._connection.SupportMultipleResults())
                {
                    return(this.ExecuteCommandTextForMultpleResults(dbParams, out executeResult));
                }
                if (((CommandBehavior.SingleRow & this.commandBehavior) == CommandBehavior.Default) || !this._executeQuery)
                {
                    return(this.ExecuteCommandTextForSingleResult(dbParams, out executeResult));
                }
                num = this.ExecuteCommandTextForSingleRow(dbParams, out executeResult);
            }
            finally
            {
                if (success)
                {
                    binding.DangerousRelease();
                }
            }
            return(num);
        }
Exemplo n.º 11
0
        internal ColumnBinding(OleDbDataReader dataReader, int index, int indexForAccessor, int indexWithinAccessor,
                                OleDbParameter parameter, RowBinding rowbinding, Bindings bindings, tagDBBINDING binding, int offset,
                                bool ifIRowsetElseIRow) {

            Debug.Assert(null != rowbinding, "null rowbinding");
            Debug.Assert(null != bindings, "null bindings");
            Debug.Assert(ODB.SizeOf_tagDBBINDING <= offset, "invalid offset" + offset);

            _dataReader = dataReader;
            _rowbinding = rowbinding;
            _bindings = bindings;
            _index = index;
            _indexForAccessor = indexForAccessor;
            _indexWithinAccessor = indexWithinAccessor;

            if (null != parameter) {
                _parameter = parameter;
                _parameterChangeID = parameter.ChangeID;
            }
            _offsetStatus = binding.obStatus.ToInt32() + offset;
            _offsetLength = binding.obLength.ToInt32() + offset;
            _offsetValue  = binding.obValue.ToInt32() + offset;

            Debug.Assert(0 <= _offsetStatus, "negative _offsetStatus");
            Debug.Assert(0 <= _offsetLength, "negative _offsetLength");
            Debug.Assert(0 <= _offsetValue,  "negative _offsetValue");

            _ordinal = binding.iOrdinal.ToInt32();
            _maxLen = binding.cbMaxLen.ToInt32();
            _wType = binding.wType;
            _precision = binding.bPrecision;

            _ifIRowsetElseIRow = ifIRowsetElseIRow;

            SetSize(Bindings.ParamSize.ToInt32());
        }
Exemplo n.º 12
0
        private OleDbDataReader GetDataForReader(IntPtr ordinal, RowBinding rowbinding, int valueOffset) {
            UnsafeNativeMethods.IRowsetInfo rowsetInfo = IRowsetInfo();
            UnsafeNativeMethods.IRowset result;
            OleDbHResult hr;

            Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB> %d#, ColumnOrdinal=%Id\n", ObjectID, ordinal);
            hr = rowsetInfo.GetReferencedRowset((IntPtr)ordinal, ref ODB.IID_IRowset, out result);
            Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB|RET> %08X{HRESULT}\n", hr);

            ProcessResults(hr);

            OleDbDataReader reader = null;
            if (null != result) {
                // only when the first datareader is closed will the connection close
                ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(result, rowbinding, valueOffset);
                reader = new OleDbDataReader(_connection, _command, 1+Depth, _commandBehavior & ~CommandBehavior.CloseConnection);
                reader.InitializeIRowset(result, chapterHandle, ADP.RecordsUnaffected);
                reader.BuildMetaInfo();
                reader.HasRowsRead();

                if (null != _connection) {
                    // connection tracks all readers to prevent cmd from executing
                    // until all readers (including nested) are closed
                    _connection.AddWeakReference(reader, OleDbReferenceCollection.DataReaderTag);
                }
            }
            return reader;
        }
Exemplo n.º 13
0
 internal OleDbDataReader ResetChapter(int bindingIndex, int index, RowBinding rowbinding, int valueOffset) {
     return GetDataForReader(_metadata[bindingIndex + index].ordinal, rowbinding, valueOffset);
 }
Exemplo n.º 14
0
        public void Dispose() {
            _parameters = null;
            _dataReader = null;
            _columnBindings = null;

            RowBinding rowBinding = _rowBinding;
            _rowBinding = null;
            if (null != rowBinding) {
                rowBinding.Dispose();
            }
        }
Exemplo n.º 15
0
        internal int AllocateForAccessor(OleDbDataReader dataReader, int indexStart, int indexForAccessor) {
            Debug.Assert(null == _rowBinding, "row binding already allocated");
            Debug.Assert(null == _columnBindings, "column bindings already allocated");

            RowBinding rowBinding = System.Data.OleDb.RowBinding.CreateBuffer(_count, _dataBufferSize, _needToReset);
            _rowBinding = rowBinding;

            ColumnBinding[] columnBindings = rowBinding.SetBindings(dataReader, this, indexStart, indexForAccessor, _parameters, _dbbindings, _ifIRowsetElseIRow);
            Debug.Assert(null != columnBindings, "null column bindings");
            _columnBindings = columnBindings;

            if (!_ifIRowsetElseIRow) {
                Debug.Assert(columnBindings.Length == _dbcolumns.Length, "length mismatch");
                for(int i = 0; i < columnBindings.Length; ++i) { // WebData 94427
                    _dbcolumns[i].pData = rowBinding.DangerousGetDataPtr(columnBindings[i].ValueOffset); // We are simply pointing at a location later in the buffer, so we're OK to not addref the buffer.
                }
            }

#if DEBUG
            int index = -1;
            foreach(ColumnBinding binding in columnBindings) {
                Debug.Assert(index < binding.Index, "invaild index");
                index = binding.Index;
            }
#endif
            return (indexStart + columnBindings.Length);
        }
 private OleDbDataReader GetDataForReader(IntPtr ordinal, RowBinding rowbinding, int valueOffset)
 {
     System.Data.Common.UnsafeNativeMethods.IRowset rowset;
     System.Data.Common.UnsafeNativeMethods.IRowsetInfo info = this.IRowsetInfo();
     Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB> %d#, ColumnOrdinal=%Id\n", this.ObjectID, ordinal);
     OleDbHResult result = info.GetReferencedRowset(ordinal, ref ODB.IID_IRowset, out rowset);
     Bid.Trace("<oledb.IRowsetInfo.GetReferencedRowset|API|OLEDB|RET> %08X{HRESULT}\n", result);
     this.ProcessResults(result);
     OleDbDataReader reader = null;
     if (rowset != null)
     {
         ChapterHandle chapterHandle = ChapterHandle.CreateChapterHandle(rowset, rowbinding, valueOffset);
         reader = new OleDbDataReader(this._connection, this._command, 1 + this.Depth, this._commandBehavior & ~CommandBehavior.CloseConnection);
         reader.InitializeIRowset(rowset, chapterHandle, ADP.RecordsUnaffected);
         reader.BuildMetaInfo();
         reader.HasRowsRead();
         if (this._connection != null)
         {
             this._connection.AddWeakReference(reader, 2);
         }
     }
     return reader;
 }