[Mono-dev] Bug with your exception-optimization
Zoltan Varga
vargaz at gmail.com
Mon Oct 3 08:58:26 EDT 2005
Hi,
Could you create a testcase which doesn't depend on System.Data+Oracle
etc ?
Zoltan
On 10/3/05, Hubert FONGARNAND <informatique.internet at fiducial.fr> wrote:
> Hello,
> I've seen that your have commited an optimization in exception handling in
> mini... Fri Sept 30...
> I've found a very very nasty bug...
>
> Try this test case :
>
> // project created on 03/10/2005 at 11:30
> using System;
> using System.Data;
> using System.Data.OracleClient;
>
>
> class MainClass
> {
>
>
>
> private static void CreateDummy()
> {
> IDbConnection sqlCon = new OracleConnection("user id=hubert;data
> source=10.69.100.181:1521/ORALINUX;password=cosmic");
> IDbCommand command = sqlCon.CreateCommand();
> command.Connection = sqlCon;
> sqlCon.Open();
> command.CommandText =
> @" DROP TABLE INTRA_LANGUE CASCADE CONSTRAINTS";
> try{
> command.ExecuteNonQuery();
> }catch(Exception e)
> {}
> command.CommandText =
> @" CREATE TABLE INTRA_LANGUE (LANGUE_CODE VARCHAR2(40) NOT NULL,LANGUE
> VARCHAR2(100), CONSTRAINT PK_INTRA_LANGUE PRIMARY KEY (LANGUE_CODE))";
> command.ExecuteNonQuery();
> sqlCon.Close();
> }
>
> public void checkexception(Exception e, IDbCommand command, string stack)
> {
> //Console.WriteLine(e.GetType().ToString());
> try
> {
> throw e;
> }
> catch (OracleException ee)
> {
> Console.WriteLine("OracleException :::"+ee.Message);
> Console.WriteLine("Command text :"+command.CommandText);
> foreach (IDataParameter param in command.Parameters)
> {
> Console.WriteLine(param.ParameterName);
> Console.WriteLine(param.Value.ToString());
> }
>
> }
> }
>
> public void Test()
> {
> IDbCommand command=new OracleCommand();
> try
> {
> NSUniDataAccess.UniDataAccess.SetDb("Oracle");
> IDbConnection sqlCon =
> NSUniDataAccess.UniDataAccess.GetConnection("user
> id=hubert;data
> source=10.69.100.181:1521/ORALINUX;password=cosmic");
> command = sqlCon.CreateCommand();
> command.Connection = sqlCon;
> sqlCon.Open();
> OracleParameter p1 = new OracleParameter("param1",OracleType.VarChar);
> p1.Value = "en";
> OracleParameter p2 = new OracleParameter("param2",OracleType.VarChar);
> p2.Value = "english";
> command.Parameters.Add(p1);
> command.Parameters.Add(p2);
> command.CommandText =
> @" INSERT INTO INTRA_LANGUE (LANGUE_CODE,LANGUE)
> VALUES(:param1,:param2)";
> command.ExecuteNonQuery();
> command.CommandText =
> @" INSERT INTO INTRA_LANGUE (LANGUE_CODE,LANGUE)
> VALUES(:param1,:param2)";
> // Should throw a Unique constraint exception...
> command.ExecuteNonQuery();
> sqlCon.Close();
> }
> catch(Exception e)
> {
> Console.WriteLine("oops : execption");
> checkexception(e,command,e.StackTrace);
> }
> return;
> }
> public static void Main(string[] args)
> {
> CreateDummy();
> Console.WriteLine("Hello World!");
> MainClass monprog=new MainClass();
> monprog.Test();
> }
> }
>
> With the last svn revision : i got as a result of this program:
>
> Hello World!
> oops : execption
> OracleException :::ORA-00001: unique constraint (HUBERT.PK_INTRA_LANGUE)
> violated
>
> Command text : INSERT INTO INTRA_LANGUE (LANGUE_CODE,LANGUE)
> VALUES(:param1,:param2)
> param1
> en
>
> Unhandled Exception: System.NullReferenceException: Object reference not
> set to an instance of an object
> in [0x0006b] (at
> /home/hubert/Projects/ExceptionBug/Main.cs:47)
> MainClass:checkexception (System.Exception e, IDbCommand command,
> System.String stack)
> in [0x000bf] (at
> /home/hubert/Projects/ExceptionBug/Main.cs:79)
> MainClass:Test ()
> in [0x00016] (at
> /home/hubert/Projects/ExceptionBug/Main.cs:88)
> MainClass:Main (System.String[] args)
>
> If I revert your changes : I get :
> Hello World!
> oops : execption
> System.Data.OracleClient.OracleException
> OracleException :::ORA-00001: unique constraint (HUBERT.PK_INTRA_LANGUE)
> violated
>
> Command text : INSERT INTO INTRA_LANGUE (LANGUE_CODE,LANGUE)
> VALUES(:param1,:param2)
> param1
> en
> param2
> english
>
>
> I dont't know exactly what's the underlying problem, but I know that this
> regression is caused by your commit...
>
> Thanks... _______________________________________________
> Ce message et les �ventuels documents joints peuvent contenir des
> informations confidentielles.
> Au cas o� il ne vous serait pas destin�, nous vous remercions de bien
> vouloir le supprimer et en aviser imm�diatement l'exp�diteur. Toute
> utilisation de ce message non conforme � sa destination, toute diffusion ou
> publication, totale ou partielle et quel qu'en soit le moyen est
> formellement interdite.
> Les communications sur internet n'�tant pas s�curis�es, l'int�grit� de ce
> message n'est pas assur�e et la soci�t� �mettrice ne peut �tre tenue pour
> responsable de son contenu.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>
More information about the Mono-devel-list
mailing list