[Mono-dev] Bug with your exception-optimization
Hubert FONGARNAND
informatique.internet at fiducial.fr
Mon Oct 3 07:59:58 EDT 2005
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20051003/b69580f8/attachment.html
More information about the Mono-devel-list
mailing list