"Column has been unexpectedly deleted" error when change structure in different 
connections
-------------------------------------------------------------------------------------------

                 Key: DNET-359
                 URL: http://tracker.firebirdsql.org/browse/DNET-359
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 2.6, 2.5.2
         Environment: Windows 7, Win2008, Win2008R2, FB 2.5 SuperClassic 
Instance
            Reporter: Anton Kononov
            Assignee: Jiri Cincura
            Priority: Critical


1. We have some table TABLE1 contains one column ID (int)
2. Open 2 connections in different threads
3. Connection 1 - select some data from TABLE1, then close
4. Connection 2 - changes structure of TABLE1 adding column COL_1 (any type)
5. Connection 1 (open new)
6. Connection 2 - close
7. Connection 1 - insert data in TABLE1, gets error

Here is sample Code for console application:


using System;
using System.Collections.Generic;
using System.Text;
using FirebirdSql.Data.FirebirdClient;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static FbConnectionStringBuilder fbcs;
        static FbConnection cn1;
        static FbConnection cn2;
        static ManualResetEvent e1 = new ManualResetEvent(false);
        static ManualResetEvent e2 = new ManualResetEvent(false);
        static ManualResetEvent e3 = new ManualResetEvent(false);

        static void Main(string[] args)
        {
            fbcs = new FbConnectionStringBuilder();
            fbcs.ServerType = FbServerType.Default;
            fbcs.Database = @"C:\Temp\base.fdb"; //Path to sample DB
            fbcs.DataSource = "localhost";
            fbcs.Dialect = 3;
            fbcs.UserID = "SYSDBA";
            fbcs.Password = "masterkey";

            ThreadPool.QueueUserWorkItem(new WaitCallback(StartConnectionOne));
            ThreadPool.QueueUserWorkItem(new WaitCallback(DoInThread));

            Thread.Sleep(1000);

            e1.Set();

            Console.Read();
        }

        static void StartConnectionOne(object state)
        {
            cn1 = new FbConnection(fbcs.ConnectionString);
            cn1.Open();

            e2.WaitOne();

            using (var cmd = cn1.CreateCommand())
            {
                cmd.Transaction = cn1.BeginTransaction();

                try
                {
                    Console.WriteLine("Alter");
                    cmd.CommandText = "alter table TABLE1 add COL_1 
varchar(255)";

                    cmd.ExecuteNonQuery();

                    cmd.Transaction.Commit();
                    Console.WriteLine("Alter success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Alter error: " + ex.Message);
                    cmd.Transaction.Rollback();
                }
            }

            e3.Set();

        }

        static void DoInThread(object state)
        {
            cn2 = new FbConnection(fbcs.ConnectionString);
            cn2.Open();

            e1.WaitOne();

            using (var cmd = cn2.CreateCommand())
            {
                try
                {
                    Console.WriteLine("Select 1");
                    cmd.CommandText = "select * from TABLE1 order by ID";

                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Console.WriteLine(r.ToString());
                        }
                    }
                    Console.WriteLine("Select 1 success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Select 1 error: " + ex.Message);
                }
            }

            cn2.Close();
            cn2.Dispose();

            e2.Set();

            e3.WaitOne();

            cn2 = new FbConnection(fbcs.ConnectionString);
            cn2.Open();

            cn1.Close();
            cn1.Dispose();

            using (var cmd = cn2.CreateCommand())
            {
                try
                {
                    Console.WriteLine("Select 2");
                    cmd.CommandText = "select * from TABLE1 order by COL_1";

                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            Console.WriteLine(r.ToString());
                        }
                    }
                    Console.WriteLine("Select 2 success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Select 2 error: " + ex.Message);
                }
            }

            using (var cmd = cn2.CreateCommand())
            {
                cmd.Transaction = cn2.BeginTransaction();

                try
                {
                    Console.WriteLine("Insert");
                    cmd.CommandText = "insert into TABLE1 (ID, COL_1) Values 
(1, '1234')";
                    
                    cmd.ExecuteNonQuery();

                    cmd.Transaction.Commit();
                    Console.WriteLine("Insert success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Insert error: " + ex.Message);
                    cmd.Transaction.Rollback();
                }
            }
        }
    }
}


-- 
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

        

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to