public void BeginTransaction(TransactionParameterBuffer tpb) { lock (stateSyncRoot) { if (this.state != TransactionState.NoTransaction) { throw GetNoValidTransactionException(); } try { GenericResponse response; lock (this.database.SyncObject) { this.database.Write(IscCodes.op_transaction); this.database.Write(this.database.Handle); this.database.WriteBuffer(tpb.ToArray()); this.database.Flush(); response = this.database.ReadGenericResponse(); this.database.TransactionCount++; } this.handle = response.ObjectHandle; this.state = TransactionState.Active; } catch (IOException) { throw new IscException(IscCodes.isc_net_read_err); } } }
public ITransaction BeginTransaction(TransactionParameterBuffer tpb) { ExtTransaction transaction = new ExtTransaction(this); transaction.BeginTransaction(tpb); return transaction; }
public void BeginTransaction(TransactionParameterBuffer tpb) { lock (_stateSyncRoot) { if (_state != TransactionState.NoTransaction) { throw GetNoValidTransactionException(); } try { GenericResponse response; lock (_database.SyncObject) { _database.XdrStream.Write(IscCodes.op_transaction); _database.XdrStream.Write(_database.Handle); _database.XdrStream.WriteBuffer(tpb.ToArray()); _database.XdrStream.Flush(); response = _database.ReadGenericResponse(); _database.TransactionCount++; } _handle = response.ObjectHandle; _state = TransactionState.Active; } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex); } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { lock (this.db) { if (this.state != TransactionState.NoTransaction) { throw new IscException( IscCodes.isc_arg_gds, IscCodes.isc_tra_state, this.handle, "no valid"); } IscTeb teb = new IscTeb(); IntPtr tebData = IntPtr.Zero; try { this.state = TransactionState.TrasactionStarting; // Set db handle teb.dbb_ptr = Marshal.AllocHGlobal(4); Marshal.WriteInt32(teb.dbb_ptr, this.db.Handle); // Set tpb length teb.tpb_len = tpb.Length; // Set TPB data teb.tpb_ptr = Marshal.AllocHGlobal(tpb.Length); Marshal.Copy(tpb.ToArray(), 0, teb.tpb_ptr, tpb.Length); // Alloc memory for the IscTeb structure int size = Marshal.SizeOf(typeof(IscTeb)); tebData = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(teb, tebData, true); int[] statusVector = FesConnection.GetNewStatusVector(); int trHandle = this.handle; FbClient.isc_start_multiple( statusVector, ref trHandle, 1, tebData); this.handle = trHandle; // Parse status vector this.db.ParseStatusVector(statusVector); // Update transaction state this.state = TransactionState.TransactionStarted; // Update transaction count this.db.TransactionCount++; } catch (Exception) { throw; } finally { // Free memory if (teb.dbb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.dbb_ptr); } if (teb.tpb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.tpb_ptr); } if (tebData != IntPtr.Zero) { Marshal.DestroyStructure(tebData, typeof(IscTeb)); Marshal.FreeHGlobal(tebData); } } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { // Clear the status vector ClearStatusVector(); int trHandle = 0; lock (_db) { SafeNativeMethods.isc_get_current_transaction(_statusVector, ref trHandle); _handle = trHandle; _state = TransactionState.Active; } }
private TransactionParameterBuffer BuildTpb(FbTransactionOptions options) { TransactionParameterBuffer tpb = new TransactionParameterBuffer(); tpb.Append(IscCodes.isc_tpb_version3); if ((options.TransactionBehavior & FbTransactionBehavior.Consistency) == FbTransactionBehavior.Consistency) { tpb.Append(IscCodes.isc_tpb_consistency); } if ((options.TransactionBehavior & FbTransactionBehavior.Concurrency) == FbTransactionBehavior.Concurrency) { tpb.Append(IscCodes.isc_tpb_concurrency); } if ((options.TransactionBehavior & FbTransactionBehavior.Wait) == FbTransactionBehavior.Wait) { tpb.Append(IscCodes.isc_tpb_wait); if (options.WaitTimeout.HasValue) { tpb.Append(IscCodes.isc_tpb_lock_timeout, (short)options.WaitTimeout); } } if ((options.TransactionBehavior & FbTransactionBehavior.NoWait) == FbTransactionBehavior.NoWait) { tpb.Append(IscCodes.isc_tpb_nowait); } if ((options.TransactionBehavior & FbTransactionBehavior.Read) == FbTransactionBehavior.Read) { tpb.Append(IscCodes.isc_tpb_read); } if ((options.TransactionBehavior & FbTransactionBehavior.Write) == FbTransactionBehavior.Write) { tpb.Append(IscCodes.isc_tpb_write); } foreach (var table in options.LockTables) { int lockType; if ((table.Value & FbTransactionBehavior.LockRead) == FbTransactionBehavior.LockRead) { lockType = IscCodes.isc_tpb_lock_read; } else if ((table.Value & FbTransactionBehavior.LockWrite) == FbTransactionBehavior.LockWrite) { lockType = IscCodes.isc_tpb_lock_write; } else { throw new ArgumentException("Must specify either LockRead or LockWrite."); } tpb.Append(lockType, table.Key); int? lockBehavior = null; if ((table.Value & FbTransactionBehavior.Exclusive) == FbTransactionBehavior.Exclusive) { lockBehavior = IscCodes.isc_tpb_exclusive; } else if ((table.Value & FbTransactionBehavior.Protected) == FbTransactionBehavior.Protected) { lockBehavior = IscCodes.isc_tpb_protected; } else if ((table.Value & FbTransactionBehavior.Shared) == FbTransactionBehavior.Shared) { lockBehavior = IscCodes.isc_tpb_shared; } if (lockBehavior.HasValue) tpb.Append((int)lockBehavior); } if ((options.TransactionBehavior & FbTransactionBehavior.ReadCommitted) == FbTransactionBehavior.ReadCommitted) { tpb.Append(IscCodes.isc_tpb_read_committed); } if ((options.TransactionBehavior & FbTransactionBehavior.Autocommit) == FbTransactionBehavior.Autocommit) { tpb.Append(IscCodes.isc_tpb_autocommit); } if ((options.TransactionBehavior & FbTransactionBehavior.RecVersion) == FbTransactionBehavior.RecVersion) { tpb.Append(IscCodes.isc_tpb_rec_version); } if ((options.TransactionBehavior & FbTransactionBehavior.NoRecVersion) == FbTransactionBehavior.NoRecVersion) { tpb.Append(IscCodes.isc_tpb_no_rec_version); } if ((options.TransactionBehavior & FbTransactionBehavior.RestartRequests) == FbTransactionBehavior.RestartRequests) { tpb.Append(IscCodes.isc_tpb_restart_requests); } if ((options.TransactionBehavior & FbTransactionBehavior.NoAutoUndo) == FbTransactionBehavior.NoAutoUndo) { tpb.Append(IscCodes.isc_tpb_no_auto_undo); } return tpb; }
public void BeginTransaction(TransactionParameterBuffer tpb) { if (this.state != TransactionState.NoTransaction) { throw new IscException(IscCodes.isc_arg_gds, IscCodes.isc_tra_state, this.handle, "no valid"); } lock (this.database.SyncObject) { try { this.database.Write(IscCodes.op_transaction); this.database.Write(this.database.Handle); this.database.WriteBuffer(tpb.ToArray()); this.database.Flush(); GenericResponse response = this.database.ReadGenericResponse(); this.handle = response.ObjectHandle; this.state = TransactionState.Active; this.database.TransactionCount++; } catch (IOException) { throw new IscException(IscCodes.isc_net_read_err); } } }
public abstract void BeginTransaction(TransactionParameterBuffer tpb);
public abstract Task BeginTransaction(TransactionParameterBuffer tpb, AsyncWrappingCommonArgs async);
public virtual ITransaction BeginTransaction(TransactionParameterBuffer tpb) { GdsTransaction transaction = new GdsTransaction(this); transaction.BeginTransaction(tpb); return transaction; }
public abstract ValueTask BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default);
public abstract TransactionBase BeginTransaction(TransactionParameterBuffer tpb);
public void BeginTransaction(TransactionParameterBuffer tpb) { if (_state != TransactionState.NoTransaction) { throw IscException.ForTypeErrorCodeIntParamStrParam(IscCodes.isc_arg_gds, IscCodes.isc_tra_state, _handle, "no valid"); } lock (_db) { IscTeb teb = new IscTeb(); IntPtr tebData = IntPtr.Zero; try { // Clear the status vector ClearStatusVector(); // Set db handle teb.dbb_ptr = Marshal.AllocHGlobal(4); Marshal.WriteInt32(teb.dbb_ptr, _db.Handle); // Set tpb length teb.tpb_len = tpb.Length; // Set TPB data teb.tpb_ptr = Marshal.AllocHGlobal(tpb.Length); Marshal.Copy(tpb.ToArray(), 0, teb.tpb_ptr, tpb.Length); // Alloc memory for the IscTeb structure int size = Marshal.SizeOf(typeof(IscTeb)); tebData = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(teb, tebData, true); int trHandle = _handle; _db.FbClient.isc_start_multiple( _statusVector, ref trHandle, 1, tebData); _handle = trHandle; // Parse status vector _db.ParseStatusVector(_statusVector); // Update transaction state _state = TransactionState.Active; // Update transaction count _db.TransactionCount++; } catch { throw; } finally { // Free memory if (teb.dbb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.dbb_ptr); } if (teb.tpb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.tpb_ptr); } if (tebData != IntPtr.Zero) { Marshal.DestroyStructure(tebData, typeof(IscTeb)); Marshal.FreeHGlobal(tebData); } } } }
private TransactionParameterBuffer BuildTpb(FbTransactionOptions options) { TransactionParameterBuffer tpb = new TransactionParameterBuffer(); tpb.Append(IscCodes.isc_tpb_version3); if ((options & FbTransactionOptions.Consistency) == FbTransactionOptions.Consistency) { tpb.Append(IscCodes.isc_tpb_consistency); } if ((options & FbTransactionOptions.Concurrency) == FbTransactionOptions.Concurrency) { tpb.Append(IscCodes.isc_tpb_concurrency); } if ((options & FbTransactionOptions.Shared) == FbTransactionOptions.Shared) { tpb.Append(IscCodes.isc_tpb_shared); } if ((options & FbTransactionOptions.Protected) == FbTransactionOptions.Protected) { tpb.Append(IscCodes.isc_tpb_protected); } if ((options & FbTransactionOptions.Exclusive) == FbTransactionOptions.Exclusive) { tpb.Append(IscCodes.isc_tpb_exclusive); } if ((options & FbTransactionOptions.Wait) == FbTransactionOptions.Wait) { tpb.Append(IscCodes.isc_tpb_wait); } if ((options & FbTransactionOptions.NoWait) == FbTransactionOptions.NoWait) { tpb.Append(IscCodes.isc_tpb_nowait); } if ((options & FbTransactionOptions.Read) == FbTransactionOptions.Read) { tpb.Append(IscCodes.isc_tpb_read); } if ((options & FbTransactionOptions.Write) == FbTransactionOptions.Write) { tpb.Append(IscCodes.isc_tpb_write); } if ((options & FbTransactionOptions.LockRead) == FbTransactionOptions.LockRead) { tpb.Append(IscCodes.isc_tpb_lock_read); } if ((options & FbTransactionOptions.LockWrite) == FbTransactionOptions.LockWrite) { tpb.Append(IscCodes.isc_tpb_lock_write); } if ((options & FbTransactionOptions.ReadCommitted) == FbTransactionOptions.ReadCommitted) { tpb.Append(IscCodes.isc_tpb_read_committed); } if ((options & FbTransactionOptions.Autocommit) == FbTransactionOptions.Autocommit) { tpb.Append(IscCodes.isc_tpb_autocommit); } if ((options & FbTransactionOptions.RecVersion) == FbTransactionOptions.RecVersion) { tpb.Append(IscCodes.isc_tpb_rec_version); } if ((options & FbTransactionOptions.NoRecVersion) == FbTransactionOptions.NoRecVersion) { tpb.Append(IscCodes.isc_tpb_no_rec_version); } if ((options & FbTransactionOptions.RestartRequests) == FbTransactionOptions.RestartRequests) { tpb.Append(IscCodes.isc_tpb_restart_requests); } if ((options & FbTransactionOptions.NoAutoUndo) == FbTransactionOptions.NoAutoUndo) { tpb.Append(IscCodes.isc_tpb_no_auto_undo); } return tpb; }
private TransactionParameterBuffer BuildTpb(FbTransactionOptions options) { TransactionParameterBuffer tpb = new TransactionParameterBuffer(); tpb.Append(IscCodes.isc_tpb_version3); FbTransactionOptions[] o = (FbTransactionOptions[])Enum.GetValues(options.GetType()); for (int i = 0; i < o.Length; i++) { FbTransactionOptions option = ((FbTransactionOptions)(o[i])); if ((options & option) == option) { switch (option) { case FbTransactionOptions.Consistency: tpb.Append(IscCodes.isc_tpb_consistency); break; case FbTransactionOptions.Concurrency: tpb.Append(IscCodes.isc_tpb_concurrency); break; case FbTransactionOptions.Shared: tpb.Append(IscCodes.isc_tpb_shared); break; case FbTransactionOptions.Protected: tpb.Append(IscCodes.isc_tpb_protected); break; case FbTransactionOptions.Exclusive: tpb.Append(IscCodes.isc_tpb_exclusive); break; case FbTransactionOptions.Wait: tpb.Append(IscCodes.isc_tpb_wait); break; case FbTransactionOptions.NoWait: tpb.Append(IscCodes.isc_tpb_nowait); break; case FbTransactionOptions.Read: tpb.Append(IscCodes.isc_tpb_read); break; case FbTransactionOptions.Write: tpb.Append(IscCodes.isc_tpb_write); break; case FbTransactionOptions.LockRead: tpb.Append(IscCodes.isc_tpb_lock_read); break; case FbTransactionOptions.LockWrite: tpb.Append(IscCodes.isc_tpb_lock_write); break; case FbTransactionOptions.ReadCommitted: tpb.Append(IscCodes.isc_tpb_read_committed); break; case FbTransactionOptions.Autocommit: tpb.Append(IscCodes.isc_tpb_autocommit); break; case FbTransactionOptions.RecVersion: tpb.Append(IscCodes.isc_tpb_rec_version); break; case FbTransactionOptions.NoRecVersion: tpb.Append(IscCodes.isc_tpb_no_rec_version); break; case FbTransactionOptions.RestartRequests: tpb.Append(IscCodes.isc_tpb_restart_requests); break; case FbTransactionOptions.NoAutoUndo: tpb.Append(IscCodes.isc_tpb_no_auto_undo); break; } } } return tpb; }
public void BeginTransaction(TransactionParameterBuffer tpb) { lock (this.db) { if (this.state != TransactionState.NoTransaction) { throw new IscException( IscCodes.isc_arg_gds, IscCodes.isc_tra_state, this.handle, "no valid"); } this.state = TransactionState.TrasactionStarting; try { this.db.Send.Write(IscCodes.op_transaction); this.db.Send.Write(this.db.Handle); this.db.Send.WriteBuffer(tpb.ToArray()); this.db.Send.Flush(); this.handle = db.ReadGenericResponse().ObjectHandle; this.state = TransactionState.TransactionStarted; this.db.TransactionCount++; } catch (IOException) { throw new IscException(IscCodes.isc_net_read_err); } } }