public override ValueTask DescribeAsync(CancellationToken cancellationToken = default) { ClearStatusVector(); _fields = new Descriptor(_fields.ActualCount); var sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); _db.FbClient.isc_dsql_describe( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); _fields = descriptor; return(ValueTask2.CompletedTask); }
public override void Describe() { lock (this.db) { // Update structure this.fields = new Descriptor(this.fields.ActualCount); // Marshal structures to pointer XsqldaMarshaler marshaler = XsqldaMarshaler.Instance; IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields); int[] statusVector = ExtConnection.GetNewStatusVector(); int stmtHandle = this.handle; SafeNativeMethods.isc_dsql_describe( statusVector, ref stmtHandle, IscCodes.SQLDA_VERSION1, sqlda); // Marshal Pointer Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda); // Free memory marshaler.CleanUpNativeData(ref sqlda); // Parse status vector this.db.ParseStatusVector(statusVector); // Update field descriptor this.fields = descriptor; } }
public override void Describe() { lock (_db) { // Clear the status vector ClearStatusVector(); // Update structure _fields = new Descriptor(_fields.ActualCount); // Marshal structures to pointer IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); _db.FbClient.isc_dsql_describe( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); // Marshal Pointer Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); // Free memory XsqldaMarshaler.CleanUpNativeData(ref sqlda); // Parse status vector _db.ProcessStatusVector(_statusVector); // Update field descriptor _fields = descriptor; } }
public override ValueTask DescribeParametersAsync(CancellationToken cancellationToken = default) { ClearStatusVector(); _parameters = new Descriptor(1); var sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); _db.ProcessStatusVector(_statusVector); if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount) { var n = descriptor.ActualCount; descriptor = new Descriptor(n); XsqldaMarshaler.CleanUpNativeData(ref sqlda); sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, descriptor); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); } else { if (descriptor.ActualCount == 0) { descriptor = new Descriptor(0); } } if (sqlda != IntPtr.Zero) { XsqldaMarshaler.CleanUpNativeData(ref sqlda); } _parameters = descriptor; return(ValueTask2.CompletedTask); }
public override async Task DescribeParameters(AsyncWrappingCommonArgs async) { ClearStatusVector(); _parameters = new Descriptor(1); var sqlda = await XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters, async).ConfigureAwait(false); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); _db.ProcessStatusVector(_statusVector); if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount) { var n = descriptor.ActualCount; descriptor = new Descriptor(n); XsqldaMarshaler.CleanUpNativeData(ref sqlda); sqlda = await XsqldaMarshaler.MarshalManagedToNative(_db.Charset, descriptor, async).ConfigureAwait(false); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); } else { if (descriptor.ActualCount == 0) { descriptor = new Descriptor(0); } } if (sqlda != IntPtr.Zero) { XsqldaMarshaler.CleanUpNativeData(ref sqlda); } _parameters = descriptor; }
public override async ValueTask PrepareAsync(string commandText, CancellationToken cancellationToken = default) { ClearAll(); ClearStatusVector(); if (State == StatementState.Deallocated) { Allocate(); } _fields = new Descriptor(1); var sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); var trHandle = _transaction.HandlePtr; var buffer = _db.Charset.GetBytes(commandText); _db.FbClient.isc_dsql_prepare( _statusVector, ref trHandle, ref _handle, (short)buffer.Length, buffer, _db.Dialect, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); _fields = descriptor; if (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count) { Describe(); } else { if (_fields.ActualCount == 0) { _fields = new Descriptor(0); } } _fields.ResetValues(); DescribeParameters(); StatementType = await GetStatementTypeAsync(cancellationToken).ConfigureAwait(false); State = StatementState.Prepared; }
public override void Execute() { if (_state == StatementState.Deallocated) { throw new InvalidOperationException("Statment is not correctly created."); } ClearStatusVector(); var inSqlda = IntPtr.Zero; var outSqlda = IntPtr.Zero; if (_parameters != null) { inSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); } if (_statementType == DbStatementType.StoredProcedure) { Fields.ResetValues(); outSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } var trHandle = _transaction.HandlePtr; _db.FbClient.isc_dsql_execute2( _statusVector, ref trHandle, ref _handle, IscCodes.SQLDA_VERSION1, inSqlda, outSqlda); if (outSqlda != IntPtr.Zero) { var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, outSqlda, true); var values = new DbValue[descriptor.Count]; for (var i = 0; i < values.Length; i++) { values[i] = new DbValue(this, descriptor[i]); } _outputParams.Enqueue(values); } XsqldaMarshaler.CleanUpNativeData(ref inSqlda); XsqldaMarshaler.CleanUpNativeData(ref outSqlda); _db.ProcessStatusVector(_statusVector); UpdateRecordsAffected(); _state = StatementState.Executed; }
private void DescribeParameters() { ClearStatusVector(); _parameters = new Descriptor(1); var sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); _db.ProcessStatusVector(_statusVector); if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount) { var n = descriptor.ActualCount; descriptor = new Descriptor(n); XsqldaMarshaler.CleanUpNativeData(ref sqlda); sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, descriptor); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); } else { if (descriptor.ActualCount == 0) { descriptor = new Descriptor(0); } } if (sqlda != IntPtr.Zero) { XsqldaMarshaler.CleanUpNativeData(ref sqlda); } _parameters = descriptor; }
public override void Prepare(string commandText) { ClearAll(); ClearStatusVector(); if (_state == StatementState.Deallocated) { Allocate(); } _fields = new Descriptor(1); IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); TransactionHandle trHandle = _transaction.HandlePtr; byte[] buffer = _db.Charset.GetBytes(commandText); _db.FbClient.isc_dsql_prepare( _statusVector, ref trHandle, ref _handle, (short)buffer.Length, buffer, _db.Dialect, sqlda); Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); _fields = descriptor; if (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count) { Describe(); } else { if (_fields.ActualCount == 0) { _fields = new Descriptor(0); } } _fields.ResetValues(); _statementType = GetStatementType(); _state = StatementState.Prepared; }
private void Describe() { ClearStatusVector(); _fields = new Descriptor(_fields.ActualCount); var sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); _db.FbClient.isc_dsql_describe( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); _fields = descriptor; }
public override async Task Describe(AsyncWrappingCommonArgs async) { ClearStatusVector(); _fields = new Descriptor(_fields.ActualCount); var sqlda = await XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields, async).ConfigureAwait(false); _db.FbClient.isc_dsql_describe( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); XsqldaMarshaler.CleanUpNativeData(ref sqlda); _db.ProcessStatusVector(_statusVector); _fields = descriptor; }
public override void Execute() { if (this.state == StatementState.Deallocated) { throw new InvalidOperationException("Statment is not correctly created."); } lock (this.db) { // Marshal structures to pointer XsqldaMarshaler marshaler = XsqldaMarshaler.Instance; IntPtr inSqlda = IntPtr.Zero; IntPtr outSqlda = IntPtr.Zero; if (this.parameters != null) { inSqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.parameters); } if (this.statementType == DbStatementType.StoredProcedure) { this.Fields.ResetValues(); outSqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields); } int[] statusVector = ExtConnection.GetNewStatusVector(); int trHandle = this.transaction.Handle; int stmtHandle = this.handle; SafeNativeMethods.isc_dsql_execute2( statusVector, ref trHandle, ref stmtHandle, IscCodes.SQLDA_VERSION1, inSqlda, outSqlda); if (outSqlda != IntPtr.Zero) { Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, outSqlda); // This would be an Execute procedure DbValue[] values = new DbValue[descriptor.Count]; for (int i = 0; i < values.Length; i++) { values[i] = new DbValue(this, descriptor[i]); } this.outputParams.Enqueue(values); } // Free memory marshaler.CleanUpNativeData(ref inSqlda); marshaler.CleanUpNativeData(ref outSqlda); this.db.ParseStatusVector(statusVector); this.UpdateRecordsAffected(); this.state = StatementState.Executed; } }
public override DbValue[] Fetch() { DbValue[] row = null; if (this.state == StatementState.Deallocated) { throw new InvalidOperationException("Statement is not correctly created."); } if (this.statementType != DbStatementType.Select && this.statementType != DbStatementType.SelectForUpdate) { return(null); } lock (this.db) { if (!this.allRowsFetched) { // Get the XSQLDA Marshaler XsqldaMarshaler marshaler = XsqldaMarshaler.Instance; // Reset actual field values this.fields.ResetValues(); // Marshal structures to pointer IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields); // Creta a new status vector int[] statusVector = ExtConnection.GetNewStatusVector(); // Statement handle to be passed to the fetch method int stmtHandle = this.handle; // Fetch data int status = SafeNativeMethods.isc_dsql_fetch(statusVector, ref stmtHandle, IscCodes.SQLDA_VERSION1, sqlda); // Obtain values Descriptor rowDesc = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda); if (this.fields.Count == rowDesc.Count) { // Try to preserve Array Handle information for (int i = 0; i < this.fields.Count; i++) { if (this.fields[i].IsArray() && this.fields[i].ArrayHandle != null) { rowDesc[i].ArrayHandle = this.fields[i].ArrayHandle; } } } this.fields = rowDesc; // Free memory marshaler.CleanUpNativeData(ref sqlda); // Parse status vector this.db.ParseStatusVector(statusVector); if (status == 100) { this.allRowsFetched = true; } else { // Set row values row = new DbValue[this.fields.ActualCount]; for (int i = 0; i < row.Length; i++) { row[i] = new DbValue(this, this.fields[i]); } } } } return(row); }
public override void Execute() { EnsureNotDeallocated(); ClearStatusVector(); var inSqlda = IntPtr.Zero; var outSqlda = IntPtr.Zero; if (_parameters != null) { inSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); } if (StatementType == DbStatementType.StoredProcedure) { Fields.ResetValues(); outSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } var trHandle = _transaction.HandlePtr; _db.FbClient.isc_dsql_execute2( _statusVector, ref trHandle, ref _handle, IscCodes.SQLDA_VERSION1, inSqlda, outSqlda); if (outSqlda != IntPtr.Zero) { var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, outSqlda, true); var values = new DbValue[descriptor.Count]; for (var i = 0; i < values.Length; i++) { var d = descriptor[i]; var value = d.DbValue.GetValue(); values[i] = new DbValue(this, d, value); } OutputParameters.Enqueue(values); } XsqldaMarshaler.CleanUpNativeData(ref inSqlda); XsqldaMarshaler.CleanUpNativeData(ref outSqlda); _db.ProcessStatusVector(_statusVector); if (DoRecordsAffected) { RecordsAffected = GetRecordsAffected(); } else { RecordsAffected = -1; } State = StatementState.Executed; }
public override void Prepare(string commandText) { // Clear data this.ClearAll(); lock (this.db) { if (this.state == StatementState.Deallocated) { // Allocate statement this.Allocate(); } // Marshal structures to pointer XsqldaMarshaler marshaler = XsqldaMarshaler.Instance; // Setup fields structure this.fields = new Descriptor(1); IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields); int[] statusVector = ExtConnection.GetNewStatusVector(); int trHandle = this.transaction.Handle; int stmtHandle = this.handle; byte[] buffer = this.db.Charset.GetBytes(commandText); SafeNativeMethods.isc_dsql_prepare( statusVector, ref trHandle, ref stmtHandle, (short)buffer.Length, buffer, this.db.Dialect, sqlda); // Marshal Pointer Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda); // Free memory marshaler.CleanUpNativeData(ref sqlda); // Parse status vector this.db.ParseStatusVector(statusVector); // Describe fields this.fields = descriptor; if (this.fields.ActualCount > 0 && this.fields.ActualCount != this.fields.Count) { this.Describe(); } else { if (this.fields.ActualCount == 0) { this.fields = new Descriptor(0); } } // Reset actual field values this.fields.ResetValues(); // Get Statement type this.statementType = this.GetStatementType(); // Update state this.state = StatementState.Prepared; } }
public override DbValue[] Fetch() { DbValue[] row = null; if (_state == StatementState.Deallocated) { throw new InvalidOperationException("Statement is not correctly created."); } if (_statementType == DbStatementType.StoredProcedure && !_allRowsFetched) { _allRowsFetched = true; return(GetOutputParameters()); } else if (_statementType == DbStatementType.Insert && _allRowsFetched) { return(null); } else if (_statementType != DbStatementType.Select && _statementType != DbStatementType.SelectForUpdate) { return(null); } if (!_allRowsFetched) { _fields.ResetValues(); if (_fetchSqlDa == IntPtr.Zero) { _fetchSqlDa = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } ClearStatusVector(); var status = _db.FbClient.isc_dsql_fetch(_statusVector, ref _handle, IscCodes.SQLDA_VERSION1, _fetchSqlDa); var rowDesc = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, _fetchSqlDa, true); if (_fields.Count == rowDesc.Count) { for (var i = 0; i < _fields.Count; i++) { if (_fields[i].IsArray() && _fields[i].ArrayHandle != null) { rowDesc[i].ArrayHandle = _fields[i].ArrayHandle; } } } _fields = rowDesc; _db.ProcessStatusVector(_statusVector); if (status == new IntPtr(100)) { _allRowsFetched = true; XsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa); } else { row = new DbValue[_fields.ActualCount]; for (var i = 0; i < row.Length; i++) { row[i] = new DbValue(this, _fields[i]); } } } return(row); }
public override async ValueTask <DbValue[]> FetchAsync(CancellationToken cancellationToken = default) { EnsureNotDeallocated(); if (StatementType == DbStatementType.StoredProcedure && !_allRowsFetched) { _allRowsFetched = true; return(GetOutputParameters()); } else if (StatementType == DbStatementType.Insert && _allRowsFetched) { return(null); } else if (StatementType != DbStatementType.Select && StatementType != DbStatementType.SelectForUpdate) { return(null); } if (_allRowsFetched) { return(null); } _fields.ResetValues(); if (_fetchSqlDa == IntPtr.Zero) { _fetchSqlDa = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } ClearStatusVector(); var status = _db.FbClient.isc_dsql_fetch(_statusVector, ref _handle, IscCodes.SQLDA_VERSION1, _fetchSqlDa); if (status == new IntPtr(100)) { _allRowsFetched = true; XsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa); return(null); } else { var rowDesc = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, _fetchSqlDa, true); if (_fields.Count == rowDesc.Count) { for (var i = 0; i < _fields.Count; i++) { if (_fields[i].IsArray() && _fields[i].ArrayHandle != null) { rowDesc[i].ArrayHandle = _fields[i].ArrayHandle; } } } _fields = rowDesc; _db.ProcessStatusVector(_statusVector); var row = new DbValue[_fields.ActualCount]; for (var i = 0; i < row.Length; i++) { var d = _fields[i]; var value = await d.DbValue.GetValueAsync(cancellationToken).ConfigureAwait(false); row[i] = new DbValue(this, d, value); } return(row); } }
public override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default) { EnsureNotDeallocated(); await descriptorFiller.FillAsync(_parameters, 0, cancellationToken).ConfigureAwait(false); ClearStatusVector(); NativeHelpers.CallIfExists(() => { _db.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout); _db.ProcessStatusVector(_statusVector); }); ClearStatusVector(); var inSqlda = IntPtr.Zero; var outSqlda = IntPtr.Zero; if (_parameters != null) { inSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); } if (StatementType == DbStatementType.StoredProcedure) { Fields.ResetValues(); outSqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } var trHandle = _transaction.HandlePtr; _db.FbClient.isc_dsql_execute2( _statusVector, ref trHandle, ref _handle, IscCodes.SQLDA_VERSION1, inSqlda, outSqlda); if (outSqlda != IntPtr.Zero) { var descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, outSqlda, true); var values = new DbValue[descriptor.Count]; for (var i = 0; i < values.Length; i++) { var d = descriptor[i]; var value = await d.DbValue.GetValueAsync(cancellationToken).ConfigureAwait(false); values[i] = new DbValue(this, d, value); } OutputParameters.Enqueue(values); } XsqldaMarshaler.CleanUpNativeData(ref inSqlda); XsqldaMarshaler.CleanUpNativeData(ref outSqlda); _db.ProcessStatusVector(_statusVector); if (DoRecordsAffected) { RecordsAffected = await GetRecordsAffectedAsync(cancellationToken).ConfigureAwait(false); } else { RecordsAffected = -1; } State = StatementState.Executed; }
public override void Prepare(string commandText) { // Clear data ClearAll(); lock (_db) { // Clear the status vector ClearStatusVector(); // Allocate the statement if needed if (_state == StatementState.Deallocated) { Allocate(); } // Marshal structures to pointer // Setup fields structure _fields = new Descriptor(1); IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); TransactionHandle trHandle = _transaction.HandlePtr; byte[] buffer = _db.Charset.GetBytes(commandText); _db.FbClient.isc_dsql_prepare( _statusVector, ref trHandle, ref _handle, (short)buffer.Length, buffer, _db.Dialect, sqlda); // Marshal Pointer Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); // Free memory XsqldaMarshaler.CleanUpNativeData(ref sqlda); // Parse status vector _db.ProcessStatusVector(_statusVector); // Describe fields _fields = descriptor; if (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count) { Describe(); } else { if (_fields.ActualCount == 0) { _fields = new Descriptor(0); } } // Reset actual field values _fields.ResetValues(); // Get Statement type _statementType = GetStatementType(); // Update state _state = StatementState.Prepared; } }
public override DbValue[] Fetch() { DbValue[] row = null; if (_state == StatementState.Deallocated) { throw new InvalidOperationException("Statement is not correctly created."); } if (_statementType != DbStatementType.Select && _statementType != DbStatementType.SelectForUpdate) { return(null); } lock (_db) { if (!_allRowsFetched) { // Get the XSQLDA Marshaler // Reset actual field values _fields.ResetValues(); // Marshal structures to pointer if (_fetchSqlDa == IntPtr.Zero) { _fetchSqlDa = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields); } // Clear the status vector ClearStatusVector(); // Statement handle to be passed to the fetch method // Fetch data IntPtr status = _db.FbClient.isc_dsql_fetch(_statusVector, ref _handle, IscCodes.SQLDA_VERSION1, _fetchSqlDa); // Obtain values Descriptor rowDesc = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, _fetchSqlDa, true); if (_fields.Count == rowDesc.Count) { // Try to preserve Array Handle information for (int i = 0; i < _fields.Count; i++) { if (_fields[i].IsArray() && _fields[i].ArrayHandle != null) { rowDesc[i].ArrayHandle = _fields[i].ArrayHandle; } } } _fields = rowDesc; // Parse status vector _db.ProcessStatusVector(_statusVector); if (status == new IntPtr(100)) { _allRowsFetched = true; XsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa); } else { // Set row values row = new DbValue[_fields.ActualCount]; for (int i = 0; i < row.Length; i++) { row[i] = new DbValue(this, _fields[i]); } } } } return(row); }
public override void DescribeParameters() { lock (this.db) { // Marshal structures to pointer XsqldaMarshaler marshaler = XsqldaMarshaler.Instance; this.parameters = new Descriptor(1); IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, parameters); int[] statusVector = ExtConnection.GetNewStatusVector(); int stmtHandle = this.handle; SafeNativeMethods.isc_dsql_describe_bind( statusVector, ref stmtHandle, IscCodes.SQLDA_VERSION1, sqlda); Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda); // Parse status vector this.db.ParseStatusVector(statusVector); if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount) { short n = descriptor.ActualCount; descriptor = new Descriptor(n); // Fre memory marshaler.CleanUpNativeData(ref sqlda); // Marshal new structure sqlda = marshaler.MarshalManagedToNative(this.db.Charset, descriptor); SafeNativeMethods.isc_dsql_describe_bind( statusVector, ref stmtHandle, IscCodes.SQLDA_VERSION1, sqlda); descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda); // Free memory marshaler.CleanUpNativeData(ref sqlda); // Parse status vector this.db.ParseStatusVector(statusVector); } else { if (descriptor.ActualCount == 0) { descriptor = new Descriptor(0); } } // Free memory if (sqlda != IntPtr.Zero) { marshaler.CleanUpNativeData(ref sqlda); } // Update parameter descriptor this.parameters = descriptor; } }
public override void DescribeParameters() { lock (_db) { // Clear the status vector ClearStatusVector(); // Marshal structures to pointer _parameters = new Descriptor(1); IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); // Parse status vector _db.ProcessStatusVector(_statusVector); if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount) { short n = descriptor.ActualCount; descriptor = new Descriptor(n); // Fre memory XsqldaMarshaler.CleanUpNativeData(ref sqlda); // Marshal new structure sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, descriptor); _db.FbClient.isc_dsql_describe_bind( _statusVector, ref _handle, IscCodes.SQLDA_VERSION1, sqlda); descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda); // Free memory XsqldaMarshaler.CleanUpNativeData(ref sqlda); // Parse status vector _db.ProcessStatusVector(_statusVector); } else { if (descriptor.ActualCount == 0) { descriptor = new Descriptor(0); } } // Free memory if (sqlda != IntPtr.Zero) { XsqldaMarshaler.CleanUpNativeData(ref sqlda); } // Update parameter descriptor _parameters = descriptor; } }