You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Ramin Moazeni <rm...@gmail.com> on 2007/06/07 10:21:52 UTC
Regarding DERBY-2658: Converting jdbcapi/parameterMetaDataJdbc30.java to JUnit
Hello,
The following piece of code gives two different results when it is run
as embedded
and net client and therefore, I am getting test failures. The results
are as follows:
--------embedded------------
DUMMYINT alias returned 6
DUMMYINT alias returned 22222
-------net client--------------
DUMMYINT alias returned 22222
DUMMYINT alias returned 22222
------expected result-------
DUMMYINT alias returned 6
DUMMYINT alias returned 22222
/**
* test behaviour of meta data and out params after re-compile
*/
public void testMetatdataAfterProcRecompile () throws SQLException {
//System.out.println("Behaviour of meta data and out
params after re-compile");
Statement stmt = createStatement();
CallableStatement cs = prepareCall("CALL dummyint(?,?,?,?)");
cs.registerOutParameter(3,Types.INTEGER);
cs.registerOutParameter(4,Types.INTEGER);
cs.setInt(1,1);
cs.setInt(2,1);
cs.setInt(4,4);
cs.execute();
//System.out.println("DUMMYINT alias returned " + cs.getInt(4));
assertEquals("Unexpected DUMMYINT alias returned",
11111, cs.getInt(4));
stmt.executeUpdate("drop procedure dummyint");
stmt.executeUpdate("create procedure dummyint(in a
integer, in b integer, out c integer, inout d integer) language java
external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyint2'
parameter style java");
cs.execute();
cs.setInt(4, 6);
// following is incorrect sequence, should execute
first, then get
// but leaving it in as an additional negative test.
see beetle 5886
----> System.out.println("DUMMYINT alias returned " + cs.getInt(4));
//assertEquals("Unexpected DUMMYINT alias returned",
6, cs.getInt(4));
cs.execute();
-----> System.out.println("DUMMYINT alias returned " + cs.getInt(4));
//assertEquals("Unexpected DUMMYINT alias returned",
22222, cs.getInt(4));
stmt.executeUpdate("drop procedure dummyint");
cs.close();
}
Re: Regarding DERBY-2658: Converting jdbcapi/parameterMetaDataJdbc30.java
to JUnit
Posted by Kathey Marsden <km...@sbcglobal.net>.
Ramin Moazeni wrote:
> Hello,
>
> The following piece of code gives two different results when it is run
> as embedded
> and net client and therefore, I am getting test failures. The results
>
I think there is a bug here but I am not totally sure whether it is in
embedded, client or both.
It seems to me maybe the correct thing is to throw an exception in this
case, since the CallableStatement has not been executed after the
parameter is set. Does that sound correct? If a value should be
returned, I think the client behaviour is more sensible.
It would be good to get other opinions.
Here is the translated information from the old bug mentioned.
Embedded gets the value last 'set' if no execute was done
right before; Client gets the value from the last execute.
Basically, if the sequence of events is:
cs.prepareCall, cs.registerOutParameter, cs.set*, cs.get* (i.e.
no execute), Embedded will return the value used in the set*
(e.g. setInt) statement. Client returns either an inappropriate
message (invalid operation: wasNull() called with no data
retrieved) - but that's another issue) or the value obtained in
the last execution.
Thus, if the sequence is: prepare, register, set, execute, set,
get, Embedded returns the value passed into the INOUT
parameter with the set, Client returns the value obtained in from
the last execute.
Similarly, if the sequence of events is:
prepare, get (no register, set, or execute), embedded returns: 0.
This does not make sense, and a graceful message should be
issued.
test: conn/parameterMetaData.java:
---------------------
s.executeUpdate("create procedure dummyint(in a integer, in b
integer, out c integer, inout d integer) language java external
name
'com.ibm.db2j.functionTests.conn.parameterMetaDataJdbc30.dummyin
t' parameter style java");
// the method dummyint returns 11111
System.out.println("Behaviour of meta data and out params after
re-compile");
cs = con.prepareCall("CALL dummyint(?,?,?,?)");
cs.registerOutParameter(3,Types.INTEGER);
cs.registerOutParameter(4,Types.INTEGER);
cs.setInt(1,1);
cs.setInt(2,1);
cs.setInt(4,4);
dumpParameterMetaData(cs.getParameterMetaData());
cs.execute();
System.out.println("DUMMYINT alias returned " +
cs.getInt(4));
------------
This first time, the value returned is 11111. It's like
that with networkserver and Embedded
The dummyint2 method used next is like dummyint1, but always
returns 22222.
------------
s.executeUpdate("drop procedure dummyint");
s.executeUpdate("create procedure dummyint(in a integer,
in b integer, out c integer, inout d integer) language java
external name
'com.ibm.db2j.functionTests.conn.parameterMetaDataJdbc30.dummyin
t2' parameter style java");
cs.execute();
dumpParameterMetaData(cs.getParameterMetaData());
cs.setInt(4, 6);
System.out.println("DUMMYINT alias returned " +
cs.getInt(4));
-------------
---> This is where a cs.execute() should happen in proper
code...
-------------
System.out.println("DUMMYINT alias returned " +
cs.getInt(4));
cs.close();
--------------------------------
The returned value is 22222 for networkserver,
but Embedded returns 6.
Re: Making a patch
Posted by Kathey Marsden <km...@sbcglobal.net>.
Kathey Marsden wrote:
> Ravinder Reddy wrote:
>>
>> hi,
>> I am converting the declareGlobalTempTableJava.java to junit.
>> Now I want to Submit my first patch. How to create a patch.I
>> have checked out
>> the source (trunk) using eclipse when I build derby.can we create
>> a patch using eclipse.?
>>
> I usually do it from the commandline. From the top of the source tree
> type :
>
> svn diff > derby-xxxx_diff.txt and also
> svn stat > derby-xxxx_diff.txt
oops should have been
svn stat -q > derby-xxxx_stat.txt
Re: Making a patch
Posted by Kathey Marsden <km...@sbcglobal.net>.
Ravinder Reddy wrote:
>
> hi,
> I am converting the declareGlobalTempTableJava.java to junit.
> Now I want to Submit my first patch. How to create a patch.I have
> checked out
> the source (trunk) using eclipse when I build derby.can we create
> a patch using eclipse.?
>
I usually do it from the commandline. From the top of the source tree type :
svn diff > derby-xxxx_diff.txt and also
svn stat > derby-xxxx_diff.txt
where xxxx is the JIRA issue for converting the test (which you should
create if you haven't already).
Attach these files to the Jira Issue along with a description of your
patch and what tests you ran.
Check the 'Patch Available' box so folks know your patch is ready for
review.
see
http://wiki.apache.org/db-derby/PatchAdvice
for more advice on patches.
Kathey
Note:With the svn plugin for eclipse I see an option Team-> Create Patch
option but I have never tried it and I don't see how to get the svn stat
output from within eclipse.
Re:
Posted by Myrna van Lunteren <m....@gmail.com>.
On 6/7/07, Ravinder Reddy <pa...@students.iiit.ac.in> wrote:
>
> hi,
> I am converting the declareGlobalTempTableJava.java to junit.
> Now I want to Submit my first patch. How to create a patch.I have checked out
> the source (trunk) using eclipse when I build derby.can we create
> a patch using eclipse.?
>
> Thank U.
Hi Ravinder,
I admit, I've never done it, but I usually apply a patch using
Eclipse, so I see no reason why you couldn't create a patch using
eclipse, assuming you have the subclipse plugin.
:-)
Depending on your findings, we could think of updating the wiki
http://wiki.apache.org/db-derby/PatchAdvice.
Myrna