Re: [Firebird-net-provider] [firebird-support] Create Autoincrement
On 03/24/2017 03:09 PM, Clyde Eisenbeis wrote: > Using http://www.firebirdfaq.org/faq29/ as a reference. > > 1) If I understand this website, the CREATE GENERATOR is initiated only once? Yes. It's a global item like a table, so you just need to create it once (and commit that change to the DB,. Changes to tables and other global items like that all need to be committed before using them). It'll have an initial value of 0 and calls to GEN_ID will increment it by the specified value (usually 1) > 2) Likewise the CREATE TRIGGER is initiated only once? Yes. It's just associated with the table, ready to run whenever the specific event happens, so... > 3) When is the T1_BI used (CREATE TRIGGER T1_BI FOR T1)? The "ACTIVE BEFORE INSERT POSITION 0" specifies that. In this case 'BEFORE INSERT', so whenever a new item is inserted into the table, that trigger is run. > 4) I see the 'id' field in table t1. I see upper case 'ID' in the > TRIGGER. Are these two the same? Yes. (Bit of bad form in that FAQ there I'd say, mixing case) Unquoted identifiers (names of tables, columns, etc.) are stored in upper case. So id, ID, iD, and Id are all the same (ID). You'll get more detailed answers about this stuff on the main Firebird mailing list, and I highly recommend the Firebird Book by Helen Borrie, which covers all this clearly and in depth. It's things like triggers and foreign keys that make a proper DB so powerful, but it can take a bit of getting used to. Scott -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
[Firebird-net-provider] Casting Text BLOB to null
Am I missing a trick here? I'm reading from a BLOB SUB_TYPE 1 column using the following: FbDataReader reader = /* blah */ string text = (string)reader[LONG_TEXT]; It's okay when there is data, but if the column happens to be NULL I get an error (Unable to cast object of type 'System.DBNull' to type 'System.String'), where I'd ideally like to get a plain null. FbDataReader.GetString doesn't work for me as it just returns So I'm left with a messy lump of GetOrdinal, IsDBNull, code. There's got to be a better way, but I'm not seeing it. Scott -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Re: [Firebird-net-provider] FbEmbed Not Releasing Database
On 27/06/14 17:27, Mark Rotteveel wrote: On 27-6-2014 18:09, Scott Morgan wrote: Trying to drop a DB opened with the embedded system, but something seems to be holding the file open after the connection is closed. The .net provider has a connection pool, so the physical connection is still open. You need to flush the pool, or disable connection pooling. You can flush the pool with: FbConnection.ClearAllPools(); That did the job, thanks. (Had a feeling it was pooling, but completely missed that function) Scott -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
[Firebird-net-provider] FbEmbed Not Releasing Database
Trying to drop a DB opened with the embedded system, but something seems to be holding the file open after the connection is closed. Test case from a console app: Console.WriteLine(Attempting to open DB...); var conn = new FbConnection(); conn.ConnectionString = myConnectionString; conn.Open(); Console.WriteLine(Attempting to close DB...); conn.Close(); conn = null; GC.Collect(); // Getting desperate here Console.WriteLine(Attempting to delete DB...); FbConnection.DropDatabase(ConnectionString); // File.Delete(DBPath); // doesn't work either Scott -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
[Firebird-net-provider] Backup/Restore Results?
How do you determine if a backup or restore has succeeded? e.g. (trying to restore from non-existent file) var restore = new FbRestore(); ... set ConnectionString etc... restore.BackupFiles.Add( new FbBackupFile(C:\I\Do\Not\Exist.fbk, null) ); ... restore.Execute(); Runs without throwing an exception and Execute doesn't return any value to check. Scott -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Re: [Firebird-net-provider] Backup/Restore Results?
On 25/06/14 14:50, Jiri Cincura wrote: You need to use Verbose = true. :\ Ah yes, it throws a relevant exception now. Thanks. Scott -- Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
[Firebird-net-provider] [FB-Tracker] Created: (DNET-420) FbCommand mishandling BLOB field parameters on empty resultsets
FbCommand mishandling BLOB field parameters on empty resultsets --- Key: DNET-420 URL: http://tracker.firebirdsql.org/browse/DNET-420 Project: .NET Data provider Issue Type: Bug Components: ADO.NET Provider Affects Versions: 2.6.5 Environment: Windows XP Firebird 2.5.1 Reporter: Scott Morgan Assignee: Jiri Cincura Assume a table of form: CREATE TABLE PHRASES ( TEXT BLOB SUB_TYPE 1 ); Then attempt the following, looking for a non-existent value: FbCommand cmd = new FbCommand(SELECT TEXT FROM PHRASES WHERE LOWER(TEXT) LIKE @search_str, conn)) cmd.Parameters.Add(@search_str, FbDbType.Text).Value = dont exist;// -- needs to be 7 chars long FbDataReader reader = cmd.ExecuteReader(); An exception is thrown by ExecuteReader: Unhandled Exception: FirebirdSql.Data.FirebirdClient.FbException: arithmetic exception, numeric overflow, or string truncation string right truncation --- FirebirdSql.Data.Common.IscException: arithmetic exception, numeric overflow, or string truncation string right truncation at FirebirdSql.Data.Client.Managed.Version10.XdrStream.Write(DbField param) in C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version10\XdrStream.cs:line 695 at FirebirdSql.Data.Client.Managed.Version10.XdrStream.Write(Descriptor descriptor) in C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version10\XdrStream.cs:line 650 at FirebirdSql.Data.Client.Managed.Version10.GdsStatement.SendExecuteToBuffer() in C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version10\GdsStatement.cs:line 596 at FirebirdSql.Data.Client.Managed.Version12.GdsStatement.Execute() in C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version12\GdsStatement.cs:line 61 at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) in C:\projects\fb.net\source\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 1250 at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\projects\fb.net\source\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 551 The problem seems to be the lib mistaking the field for a VARCHAR type when the resultset is empty. A workaround is to explicitly cast the parameter as a BLOB: FbCommand cmd = new FbCommand(SELECT TEXT FROM PHRASES WHERE LOWER(TEXT) LIKE CAST(@search_str AS BLOB SUB_TYPE 1), conn)) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Re: [Firebird-net-provider] Deadlock problem (possible: DNET-382)
On 09/30/2011 02:21 PM, Scott Morgan wrote: On 09/30/2011 12:59 PM, Mark Rotteveel wrote: True, but making sure that you always lock resources in the same order, is the only sure way to prevent deadlocks. I think I see the problem: In Version10/GdsTransaction.cs (copy/paste from the Sourceforge SVN browser, so excuse the formatting) ... The SyncObject lock is to protect the calls to this.database.Write etc. (lines 194-200) but it also covers the transaction's state change (lines 202-207) which it shouldn't and is the point the deadlock occurs. Something like this may be better: ... Similar changes would need to be made to the other functions in this class (Commit, RollbackRetaining, etc...) Scott See patch against the SVN trunk. Scott Index: GdsServiceManager.cs === --- GdsServiceManager.cs(revision 53626) +++ GdsServiceManager.cs(working copy) @@ -64,15 +64,18 @@ { try { - this.database.Write(IscCodes.op_service_attach); - this.database.Write(0); - this.database.Write(service); - this.database.WriteBuffer(spb.ToArray()); - this.database.Flush(); + lock (this.database.SyncObject) + { + this.database.Write(IscCodes.op_service_attach); + this.database.Write(0); + this.database.Write(service); + this.database.WriteBuffer(spb.ToArray()); + this.database.Flush(); -response = this.database.ReadGenericResponse(); + response = this.database.ReadGenericResponse(); + } -this.handle = response.ObjectHandle; + this.handle = response.ObjectHandle; } catch (IOException) { @@ -89,12 +92,15 @@ { try { - this.database.Write(IscCodes.op_service_detach); - this.database.Write(this.Handle); - this.database.Write(IscCodes.op_disconnect); - this.database.Flush(); + lock (this.database.SyncObject) + { + this.database.Write(IscCodes.op_service_detach); + this.database.Write(this.Handle); + this.database.Write(IscCodes.op_disconnect); + this.database.Flush(); - this.database.ReadResponse(); + this.database.ReadResponse(); + } this.handle = 0; } @@ -127,20 +133,23 @@ { try { - this.database.Write(IscCodes.op_service_start); - this.database.Write(this.Handle); - this.database.Write(0); - this.database.WriteBuffer(spb.ToArray(), spb.Length); - this.database.Flush(); + lock (this.database.SyncObject) + { + this.database.Write(IscCodes.op_service_start); + this.database.Write(this.Handle); + this.database.Write(0); + this.database.WriteBuffer(spb.ToArray(), spb.Length); + this.database.Flush(); - try - { - this.database.ReadResponse(); + try + { + this.database.ReadResponse
Re: [Firebird-net-provider] Deadlock problem (possible: DNET-382)
On 09/30/2011 12:59 PM, Mark Rotteveel wrote: True, but making sure that you always lock resources in the same order, is the only sure way to prevent deadlocks. I think I see the problem: In Version10/GdsTransaction.cs (copy/paste from the Sourceforge SVN browser, so excuse the formatting) 186 public void Rollback() 187 { 188 this.CheckTransactionState(); 189 190 lock (this.database.SyncObject) 191 { 192 try 193 { 194 this.database.Write(IscCodes.op_rollback); 195 this.database.Write(this.handle); 196 this.database.Flush(); 197 198 this.database.ReadResponse(); 199 200 this.database.TransactionCount--; 201 202 if (this.Update != null) 203 { 204 this.Update(this, new EventArgs()); 205 } 206 207 this.state = TransactionState.NoTransaction; 208 } 209 catch (IOException) 210 { 211 throw new IscException(IscCodes.isc_net_read_err); 212 } 213 } 214 } The SyncObject lock is to protect the calls to this.database.Write etc. (lines 194-200) but it also covers the transaction's state change (lines 202-207) which it shouldn't and is the point the deadlock occurs. Something like this may be better: public void Rollback() { this.CheckTransactionState(); lock (aNewPrivateTransactionLockObject) { try { // Make sure this sequence of actions on the DB object isn't broken lock (this.database.SyncObject) { this.database.Write(IscCodes.op_rollback); this.database.Write(this.handle); this.database.Flush(); this.database.ReadResponse(); this.database.TransactionCount--; } if (this.Update != null) { this.Update(this, new EventArgs()); } this.state = TransactionState.NoTransaction; } ...etc... } } Similar changes would need to be made to the other functions in this class (Commit, RollbackRetaining, etc...) Scott -- All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
[Firebird-net-provider] Deadlock problem (possible: DNET-382)
Think this might be related to http://tracker.firebirdsql.org/browse/DNET-382 I've been hitting a deadlock between the GC and main threads. Examining it I've seen that the main thread calls FbTransaction.Rollback which, in sequence, locks: 1. The transaction object itself 2. database.SyncObject 3. A GdsStatement object Whilst the GC thread is calling FbCommand.Dispose, which locks: 1. The command object 2. The same GdsStatement object as above 3. database.SyncObject (call stacks at end of mail) Obviously there's a race condition here, between the statement and the SyncObject. As a temporary fix I changed all locks to refer to the database.SyncObject, which isn't pretty in terms of scaling, but does remove the deadlock. A better solution might involve adding a transaction synch object, not sure though, as I haven't really had the time to go through the code fully. Scott Morgan Main thread call stack: FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.Client.Managed.Version10.GdsStatement.TransactionUpdated(object sender, System.EventArgs e) Line 659 C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.Client.Managed.Version10.GdsTransaction.Rollback() Line 207C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.FirebirdClient.FbTransaction.Rollback() Line 191 C# GC thread call stack: FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.Client.Managed.Version11.GdsStatement.Free(int option) Line 205C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.Common.StatementBase.Release() Line 263C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.Client.Managed.Version10.GdsStatement.Dispose(bool disposing) Line 183 + 0xa bytes C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.Common.StatementBase.Dispose() Line 178C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.FirebirdClient.FbCommand.Release() Line 843C# FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.FirebirdClient.FbCommand.Dispose(bool disposing) Line 399 C# -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ___ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider