diff options
author | Veerapuram Varadhan <v.varadhan@gmail.com> | 2010-03-26 15:23:01 +0300 |
---|---|---|
committer | Veerapuram Varadhan <v.varadhan@gmail.com> | 2010-03-26 15:23:01 +0300 |
commit | de5e09e40e043cba32fe06a8ba5196611ed0c908 (patch) | |
tree | c22f881a07537e3a79f877e918eca70976390ed6 /mcs | |
parent | 92d05f673b181aa517dacee5deacc232652fc7c3 (diff) |
2010-03-24 Veerapuram Varadhan <vvaradhan@novell.com>
** Fixes #565149 - by Daniel Morgan <monodanmorg@yahoo.com>
* System.Data.OracleClient/OracleParameter.cs:
- if programmer explicitly sets the Size property,
do not override the size later if the Value property
is set for character data.
- for character and numeric data types, output and
return parameters were not allocated memory.
Also, input/output parameters need to allocate memory
based on Size because the output can be bigger than
the input after an execute.
* Test/TestOracleClient.cs: Data Adapter Test 2 is failing
for NET_2_0 profile.
svn path=/branches/mono-2-6/mcs/; revision=154261
Diffstat (limited to 'mcs')
3 files changed, 57 insertions, 9 deletions
diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient/ChangeLog b/mcs/class/System.Data.OracleClient/System.Data.OracleClient/ChangeLog index eea0a29e9d3..7548aa5c179 100644 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient/ChangeLog +++ b/mcs/class/System.Data.OracleClient/System.Data.OracleClient/ChangeLog @@ -1,3 +1,19 @@ +2010-03-24 Veerapuram Varadhan <vvaradhan@novell.com> + + ** Fixes #565149 - by Daniel Morgan <monodanmorg@yahoo.com> + * System.Data.OracleClient/OracleParameter.cs: + - if programmer explicitly sets the Size property, + do not override the size later if the Value property + is set for character data. + - for character and numeric data types, output and + return parameters were not allocated memory. + Also, input/output parameters need to allocate memory + based on Size because the output can be bigger than + the input after an execute. + + * Test/TestOracleClient.cs: Data Adapter Test 2 is failing + for NET_2_0 profile. + 2009-10-29 Veerapuram Varadhan <vvaradhan@novell.com> ** Fixes #322695 diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs index 744dbab9b97..2edef7d4d1c 100644 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs +++ b/mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs @@ -80,6 +80,7 @@ namespace System.Data.OracleClient short indicator; int bindSize; + bool sizeManuallySet; #endregion // Fields @@ -332,6 +333,7 @@ namespace System.Data.OracleClient set { sizeSet = true; size = value; + sizeManuallySet = true; } } @@ -485,13 +487,26 @@ namespace System.Data.OracleClient // Get size of buffer status = OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, out rsize); - // allocate memory based on oracle returned length - bytes = new byte [rsize]; + if (direction == ParameterDirection.Input) + bindSize = rsize; + else { + // this cannot be rsize because you need room for the output after the execute + bindSize = Encoding.UTF8.GetMaxByteCount (Size + 1); + } + + // allocate memory based on bind size + bytes = new byte [bindSize]; // Fill buffer status = OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, out rsize); - bindSize = bytes.Length; } + + if (direction == ParameterDirection.ReturnValue || direction == ParameterDirection.Output) { + // for Return and Output params, get size in bytes + bindSize = Encoding.UTF8.GetMaxByteCount (size + 1); + // allocate memory for oracle to place the results for the Return or Output param + bytes = new byte [bindSize]; + } break; case OciDataType.Date: bindType = OciDataType.Date; @@ -605,8 +620,18 @@ namespace System.Data.OracleClient OciCalls.OCIUnicodeToCharSet (statement.Parent, null, svalue, out rsize); // Fill buffer - bytes = new byte [rsize]; + + if (direction == ParameterDirection.Input) + bindSize = rsize; + else + bindSize = 30; // need room for output possibly being bigger than the input + + bytes = new byte [bindSize]; OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, svalue, out rsize); + } + if (direction == ParameterDirection.ReturnValue || direction == ParameterDirection.Output) { + bindSize = 30; + bytes = new byte [bindSize]; } break; case OciDataType.Long: @@ -958,6 +983,8 @@ namespace System.Data.OracleClient case OciDataType.OciString: case OciDataType.Long: case OciDataType.LongVarChar: + if (sizeManuallySet == true) + return size; if (value == null || value == DBNull.Value) newSize = 0; else diff --git a/mcs/class/System.Data.OracleClient/Test/TestOracleClient.cs b/mcs/class/System.Data.OracleClient/Test/TestOracleClient.cs index da95b69cedb..114abb85c50 100644 --- a/mcs/class/System.Data.OracleClient/Test/TestOracleClient.cs +++ b/mcs/class/System.Data.OracleClient/Test/TestOracleClient.cs @@ -3223,6 +3223,10 @@ namespace Test.OracleClient Wait (""); + Console.WriteLine ("Out Parameter and PL/SQL Block Test 2 BEGIN..."); + OutParmTest2 (con1); + Console.WriteLine ("Out Parameter and PL/SQL Block Test 2 END..."); + Console.WriteLine ("LOB Test BEGIN..."); CLOBTest (con1); BLOBTest (con1); @@ -3242,7 +3246,12 @@ namespace Test.OracleClient Wait (""); Console.WriteLine ("DataAdapter Test 2 BEGIN..."); - DataAdapterTest2(con1); + // FIXME: test is failing in NET_2_0 profile but not in NET_1_1 profile + // Unhandled Exception: System.Data.OracleClient.OracleException: ORA-01400: cannot insert NULL + // into ("SCOTT"."MONO_ADAPTER_TEST"."NUMBER_WHOLE_VALUE") + // NUMBER_WHOLE_VALUE is a primary key on the table. + //DataAdapterTest2(con1); + Console.WriteLine ("***DataAdapter Test 2 FAILS!"); Console.WriteLine ("DataAdapter Test 2 END."); Wait (""); @@ -3284,10 +3293,6 @@ namespace Test.OracleClient OutParmTest1 (con1); Console.WriteLine ("Out Parameter and PL/SQL Block Test 1 END..."); - Console.WriteLine ("Out Parameter and PL/SQL Block Test 2 BEGIN..."); - OutParmTest2 (con1); - Console.WriteLine ("Out Parameter and PL/SQL Block Test 2 END..."); - Console.WriteLine ("Out Parameter and PL/SQL Block Test 3 BEGIN..."); OutParmTest3 (con1); Console.WriteLine ("Out Parameter and PL/SQL Block Test 3 END..."); |