[bcl] Use RuntimeHelpers.GetHashCode () for getting the hash code of … (#5511)
[mono.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient.Oci / OciCalls.cs
index a489933fdc036e686ac628e28f6b35acbd42330f..e6125bf5c918c580e0bb9c5d04b5c9984dcd4235 100644 (file)
@@ -1,5 +1,5 @@
-//
-// OciCalls.cs 
+//
+// OciCalls.cs
 //
 // Part of the Mono class libraries at
 // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
@@ -8,14 +8,16 @@
 // Namespace: System.Data.OracleClient.Oci
 //
 // Authors: Joerg Rosenkranz <joergr@voelcker.com>
-//          Daniel Morgan <danielmorgan@verizon.net>
+//          Daniel Morgan <monodanmorg@yahoo.com>
 //
 // Copyright (C) Joerg Rosenkranz, 2004
-// Copyright (C) Daniel Morgan, 2005
+// Copyright (C) Daniel Morgan, 2005, 2009
 //
 // Licensed under the MIT/X11 License.
 //
 
+//#define ORACLE_DATA_ACCESS
+
 using System;
 using System.Diagnostics;
 using System.Runtime.InteropServices;
@@ -25,9 +27,8 @@ namespace System.Data.OracleClient.Oci
 {
        internal sealed class OciCalls
        {
-
-               private static bool traceOci;
 #if TRACE
+               private static bool traceOci;
 
                static OciCalls()
                {
@@ -63,6 +64,19 @@ namespace System.Data.OracleClient.Oci
                                [MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
                                IntPtr errhp);
 
+#if ORACLE_DATA_ACCESS
+                       [DllImport ("oci", EntryPoint = "OCIPasswordChange")]
+                       internal static extern int OCIPasswordChange (IntPtr svchp, 
+                               IntPtr errhp,
+                               byte [] user_name, 
+                               [MarshalAs (UnmanagedType.U4)] int usernm_len,
+                               byte [] opasswd,
+                               [MarshalAs (UnmanagedType.U4)] int opasswd_len,
+                               byte [] npasswd,
+                               [MarshalAs (UnmanagedType.U4)] int npasswd_len,
+                               [MarshalAs (UnmanagedType.U4)] uint mode);
+#endif
+
                        [DllImport ("oci")]
                        internal static extern int OCIErrorGet (IntPtr hndlp,
                                uint recordno,
@@ -81,7 +95,7 @@ namespace System.Data.OracleClient.Oci
                                IntPtr valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                               ref short indp,
+                               IntPtr indp,
                                IntPtr alenp,
                                IntPtr rcodep,
                                uint maxarr_len,
@@ -97,7 +111,7 @@ namespace System.Data.OracleClient.Oci
                                ref IntPtr valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                               ref short indp,
+                               IntPtr indp,
                                IntPtr alenp,
                                IntPtr rcodep,
                                uint maxarr_len,
@@ -113,7 +127,7 @@ namespace System.Data.OracleClient.Oci
                                byte[] valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                               ref short indp,
+                               IntPtr indp,
                                IntPtr alenp,
                                IntPtr rcodep,
                                uint maxarr_len,
@@ -128,7 +142,7 @@ namespace System.Data.OracleClient.Oci
                                IntPtr valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                               ref short indp,
+                               IntPtr indp,
                                IntPtr alenp,
                                IntPtr rcodep,
                                uint maxarr_len,
@@ -143,7 +157,7 @@ namespace System.Data.OracleClient.Oci
                                byte[] valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                               ref short indp,
+                               IntPtr indp,
                                IntPtr alenp,
                                IntPtr rcodep,
                                uint maxarr_len,
@@ -158,7 +172,7 @@ namespace System.Data.OracleClient.Oci
                                ref IntPtr valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                               ref short indp,
+                               IntPtr indp,
                                IntPtr alenp,
                                IntPtr rcodep,
                                uint maxarr_len,
@@ -179,8 +193,8 @@ namespace System.Data.OracleClient.Oci
                                IntPtr valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U4)] OciDataType dty,
-                               ref short indp,
-                               ref short rlenp,
+                               IntPtr indp,
+                               IntPtr rlenp,
                                IntPtr rcodep,
                                uint mode);
 
@@ -192,8 +206,8 @@ namespace System.Data.OracleClient.Oci
                                ref IntPtr valuep,
                                int value_sz,
                                [MarshalAs (UnmanagedType.U4)] OciDataType dty,
-                               ref short indp,
-                               ref short rlenp,
+                               IntPtr indp,
+                               IntPtr rlenp,
                                IntPtr rcodep,
                                uint mode);
 
@@ -211,6 +225,11 @@ namespace System.Data.OracleClient.Oci
                                int xtramem_sz,
                                IntPtr usrmempp);
 
+                       [DllImport ("oci")]
+                       internal static extern int OCICacheFree (IntPtr envhp,
+                               IntPtr errhp,
+                               IntPtr stmthp);
+
                        [DllImport ("oci")]
                        internal static extern int OCIAttrGet (IntPtr trgthndlp,
                                [MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
@@ -350,10 +369,16 @@ namespace System.Data.OracleClient.Oci
                                byte csfrm);
 
                        [DllImport ("oci")]
-                       internal static extern int OCINlsGetInfo (IntPtr hndl, 
+                       internal static extern int OCILobCharSetForm (IntPtr svchp, 
+                               IntPtr errhp,
+                               IntPtr locp,
+                               out byte csfrm);
+                       
+                       [DllImport ("oci")]
+                       internal static extern int OCINlsGetInfo (IntPtr hndl,
                                IntPtr errhp,
                                [In][Out] byte[] bufp,
-                               uint buflen, 
+                               uint buflen,
                                ushort item);
 
                        [DllImport ("oci")]
@@ -411,7 +436,7 @@ namespace System.Data.OracleClient.Oci
                                uint nrows,
                                ushort orientation,
                                uint mode);
-                                                       
+
 
                        [DllImport ("oci")]
                        internal static extern int OCIStmtPrepare (IntPtr stmthp,
@@ -440,20 +465,20 @@ namespace System.Data.OracleClient.Oci
                        [DllImport ("oci")]
                        internal static extern int OCICharSetToUnicode (
                                IntPtr svchp,
-                               [MarshalAs (UnmanagedType.LPWStr)] StringBuilder dst, 
-                               [MarshalAs (UnmanagedType.U4)] int dstlen, 
+                               [MarshalAs (UnmanagedType.LPWStr)] StringBuilder dst,
+                               [MarshalAs (UnmanagedType.SysUInt)] int dstlen,
                                byte [] src,
-                               [MarshalAs (UnmanagedType.U4)] int srclen,
-                               [MarshalAs (UnmanagedType.U4)] out int rsize);
-                       
+                               [MarshalAs (UnmanagedType.SysUInt)] int srclen,
+                               out long rsize);
+
                        [DllImport ("oci")]
                        internal static extern int OCIUnicodeToCharSet (
                                IntPtr svchp,
                                byte [] dst,
-                               [MarshalAs (UnmanagedType.U4)] int dstlen, 
-                               [MarshalAs (UnmanagedType.LPWStr)] string src, 
-                               [MarshalAs (UnmanagedType.U4)] int srclen,
-                               [MarshalAs (UnmanagedType.U4)] out int rsize);
+                               [MarshalAs (UnmanagedType.SysUInt)] int dstlen,
+                               [MarshalAs (UnmanagedType.LPWStr)] string src,
+                               [MarshalAs (UnmanagedType.SysUInt)] int srclen,
+                               out long rsize);
                }
 
                #endregion
@@ -467,7 +492,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, string.Format("OCIAttrSet ({0}, {1})", trghndltyp, attrtype), "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrSet (trgthndlp, trghndltyp, attributep, size, attrtype, errhp);
                }
 
@@ -478,10 +505,26 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, string.Format("OCIAttrSetString ({0}, {1})", trghndltyp, attrtype), "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrSetString (trgthndlp, trghndltyp, attributep, size, attrtype, errhp);
                }
-
+#if ORACLE_DATA_ACCESS
+               internal static int OCIPasswordChange (IntPtr svchp, IntPtr errhp,
+                               int usernm_len,
+                               byte [] opasswd,
+                               int opasswd_len,
+                               byte [] npasswd,
+                               int npasswd_len,
+                               uint mode)
+               {
+                       #if TRACE
+                       Trace.WriteLineIf(traceOci, string.Format("OCIPasswordChange"), "OCI");
+                       #endif
+                       return OciNativeCalls.OCIPasswordChange (svchp, errhp, user_name, (uint) usernm_len, opasswd, (uint) opasswd_len, npasswd, (uint) npasswd_len, mode);
+               }
+#endif
                internal static int OCIErrorGet (IntPtr hndlp,
                        uint recordno,
                        IntPtr sqlstate,
@@ -490,7 +533,9 @@ namespace System.Data.OracleClient.Oci
                        uint bufsize,
                        OciHandleType type)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIErrorGet", "OCI");
+                       #endif
                        return OciNativeCalls.OCIErrorGet (hndlp, recordno, sqlstate, out errcodep, bufp, bufsize, type);
                }
 
@@ -502,16 +547,18 @@ namespace System.Data.OracleClient.Oci
                        IntPtr valuep,
                        int value_sz,
                        OciDataType dty,
-                       ref short indp,
+                       IntPtr indp,
                        IntPtr alenp,
                        IntPtr rcodep,
                        uint maxarr_len,
                        IntPtr curelp,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
-                       return OciNativeCalls.OCIBindByName (stmtp, out bindpp, errhp, placeholder, placeh_len, valuep, 
-                               value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
+                       #endif
+                       return OciNativeCalls.OCIBindByName (stmtp, out bindpp, errhp, placeholder, placeh_len, valuep,
+                               value_sz, dty, indp, alenp, rcodep, maxarr_len, curelp, mode);
                }
 
                internal static int OCIBindByNameRef (IntPtr stmtp,
@@ -522,16 +569,18 @@ namespace System.Data.OracleClient.Oci
                        ref IntPtr valuep,
                        int value_sz,
                        OciDataType dty,
-                       ref short indp,
+                       IntPtr indp,
                        IntPtr alenp,
                        IntPtr rcodep,
                        uint maxarr_len,
                        IntPtr curelp,
-                       uint mode) 
+                       uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
-                       return OciNativeCalls.OCIBindByNameRef (stmtp, out bindpp, errhp, placeholder, placeh_len, ref valuep, 
-                               value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
+                       #endif
+                       return OciNativeCalls.OCIBindByNameRef (stmtp, out bindpp, errhp, placeholder, placeh_len, ref valuep,
+                               value_sz, dty, indp, alenp, rcodep, maxarr_len, curelp, mode);
                }
 
                internal static int OCIBindByNameBytes (IntPtr stmtp,
@@ -542,16 +591,18 @@ namespace System.Data.OracleClient.Oci
                        byte[] valuep,
                        int value_sz,
                        [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                       ref short indp,
+                       IntPtr indp,
                        IntPtr alenp,
                        IntPtr rcodep,
                        uint maxarr_len,
                        IntPtr curelp,
-                       uint mode) 
+                       uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIBindByName", "OCI");
-                       return OciNativeCalls.OCIBindByNameBytes (stmtp, out bindpp, errhp, placeholder, placeh_len, valuep, 
-                               value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
+                       #endif
+                       return OciNativeCalls.OCIBindByNameBytes (stmtp, out bindpp, errhp, placeholder, placeh_len, valuep,
+                               value_sz, dty, indp, alenp, rcodep, maxarr_len, curelp, mode);
                }
 
                internal static int OCIBindByPos (IntPtr stmtp,
@@ -561,16 +612,18 @@ namespace System.Data.OracleClient.Oci
                        IntPtr valuep,
                        int value_sz,
                        [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                       ref short indp,
+                       IntPtr indp,
                        IntPtr alenp,
                        IntPtr rcodep,
                        uint maxarr_len,
                        IntPtr curelp,
-                       uint mode) 
+                       uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
-                       return OciNativeCalls.OCIBindByPos (stmtp, out bindpp, errhp, position, valuep, 
-                               value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
+                       #endif
+                       return OciNativeCalls.OCIBindByPos (stmtp, out bindpp, errhp, position, valuep,
+                               value_sz, dty, indp, alenp, rcodep, maxarr_len, curelp, mode);
                }
 
                internal static int OCIBindByPosRef (IntPtr stmtp,
@@ -580,16 +633,18 @@ namespace System.Data.OracleClient.Oci
                        ref IntPtr valuep,
                        int value_sz,
                        [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                       ref short indp,
+                       IntPtr indp,
                        IntPtr alenp,
                        IntPtr rcodep,
                        uint maxarr_len,
                        IntPtr curelp,
-                       uint mode) 
+                       uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
-                       return OciNativeCalls.OCIBindByPosRef (stmtp, out bindpp, errhp, position, ref valuep, 
-                               value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
+                       #endif
+                       return OciNativeCalls.OCIBindByPosRef (stmtp, out bindpp, errhp, position, ref valuep,
+                               value_sz, dty, indp, alenp, rcodep, maxarr_len, curelp, mode);
                }
 
                internal static int OCIBindByPosBytes (IntPtr stmtp,
@@ -599,16 +654,18 @@ namespace System.Data.OracleClient.Oci
                        byte[] valuep,
                        int value_sz,
                        [MarshalAs (UnmanagedType.U2)] OciDataType dty,
-                       ref short indp,
+                       IntPtr indp,
                        IntPtr alenp,
                        IntPtr rcodep,
                        uint maxarr_len,
                        IntPtr curelp,
-                       uint mode) 
+                       uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIBindByPos", "OCI");
-                       return OciNativeCalls.OCIBindByPosBytes (stmtp, out bindpp, errhp, position, valuep, 
-                               value_sz, dty, ref indp, alenp, rcodep, maxarr_len, curelp, mode);
+                       #endif
+                       return OciNativeCalls.OCIBindByPosBytes (stmtp, out bindpp, errhp, position, valuep,
+                               value_sz, dty, indp, alenp, rcodep, maxarr_len, curelp, mode);
                }
 
                [DllImport ("oci")]
@@ -641,6 +698,23 @@ namespace System.Data.OracleClient.Oci
                        out byte min,
                        out byte sec,
                        out uint fsec);
+                               
+               [DllImport ("oci")]
+               internal static extern int OCIIntervalGetDaySecond (IntPtr hndl,
+                       IntPtr err,
+                       out int days,
+                       out int hours,
+                       out int mins,
+                       out int secs,
+                       out int fsec,
+                       IntPtr interval);
+
+               [DllImport ("oci")]
+               internal static extern int OCIIntervalGetYearMonth (IntPtr hndl,
+                       IntPtr err,
+                       out int years,
+                       out int months,
+                       IntPtr interval);
 
                internal static int OCIDefineByPos (IntPtr stmtp,
                        out IntPtr defnpp,
@@ -649,14 +723,16 @@ namespace System.Data.OracleClient.Oci
                        IntPtr valuep,
                        int value_sz,
                        OciDataType dty,
-                       ref short indp,
-                       ref short rlenp,
+                       IntPtr indp,
+                       IntPtr rlenp,
                        IntPtr rcodep,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIDefineByPos", "OCI");
-                       return OciNativeCalls.OCIDefineByPos (stmtp, out defnpp, errhp, position, valuep, 
-                               value_sz, dty, ref indp, ref rlenp, rcodep, mode);
+                       #endif
+                       return OciNativeCalls.OCIDefineByPos (stmtp, out defnpp, errhp, position, valuep,
+                               value_sz, dty, indp, rlenp, rcodep, mode);
                }
 
                internal static int OCIDefineByPosPtr (IntPtr stmtp,
@@ -666,20 +742,24 @@ namespace System.Data.OracleClient.Oci
                        ref IntPtr valuep,
                        int value_sz,
                        OciDataType dty,
-                       ref short indp,
-                       ref short rlenp,
+                       IntPtr indp,
+                       IntPtr rlenp,
                        IntPtr rcodep,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIDefineByPosPtr", "OCI");
-                       return OciNativeCalls.OCIDefineByPosPtr (stmtp, out defnpp, errhp, position, ref valuep, 
-                               value_sz, dty, ref indp, ref rlenp, rcodep, mode);
+                       #endif
+                       return OciNativeCalls.OCIDefineByPosPtr (stmtp, out defnpp, errhp, position, ref valuep,
+                               value_sz, dty, indp, rlenp, rcodep, mode);
                }
 
                internal static int OCIDescriptorFree (IntPtr hndlp,
                        OciHandleType type)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, string.Format("OCIDescriptorFree ({0})", type), "OCI");
+                       #endif
                        return OciNativeCalls.OCIDescriptorFree (hndlp, type);
                }
 
@@ -692,11 +772,23 @@ namespace System.Data.OracleClient.Oci
                        int xtramem_sz,
                        IntPtr usrmempp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIEnvCreate", "OCI");
+                       #endif
                        return OciNativeCalls.OCIEnvCreate (out envhpp, mode, ctxp, malocfp, ralocfp, mfreep,
                                xtramem_sz, usrmempp);
                }
 
+               internal static int OCICacheFree (IntPtr envhp,
+                       IntPtr svchp,
+                       IntPtr stmthp)
+               {
+                       #if TRACE
+                       Trace.WriteLineIf(traceOci, "OCICacheFree", "OCI");
+                       #endif
+                       return OciNativeCalls.OCICacheFree (envhp, svchp, stmthp);
+               }
+
                internal static int OCIAttrGet (IntPtr trgthndlp,
                        OciHandleType trghndltyp,
                        out IntPtr attributep,
@@ -704,7 +796,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIAttrGet", "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrGet (trgthndlp, trghndltyp, out attributep, out sizep, attrtype, errhp);
                }
 
@@ -715,7 +809,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIAttrGetSByte", "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrGetSByte (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
                }
 
@@ -726,7 +822,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIAttrGetByte", "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrGetByte (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
                }
 
@@ -737,7 +835,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIAttrGetUInt16", "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrGetUInt16 (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
                }
 
@@ -748,7 +848,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIAttrGetInt32", "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrGetInt32 (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
                }
 
@@ -759,7 +861,9 @@ namespace System.Data.OracleClient.Oci
                        OciAttributeType attrtype,
                        IntPtr errhp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIAttrGetIntPtr", "OCI");
+                       #endif
                        return OciNativeCalls.OCIAttrGetIntPtr (trgthndlp, trghndltyp, out attributep, sizep, attrtype, errhp);
                }
 
@@ -769,7 +873,9 @@ namespace System.Data.OracleClient.Oci
                        int xtramem_sz,
                        IntPtr usrmempp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIDescriptorAlloc", "OCI");
+                       #endif
                        return OciNativeCalls.OCIDescriptorAlloc (parenth, out hndlpp, type, xtramem_sz, usrmempp);
                }
 
@@ -779,14 +885,18 @@ namespace System.Data.OracleClient.Oci
                        int xtramem_sz,
                        IntPtr usrmempp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, string.Format("OCIHandleAlloc ({0})", type), "OCI");
+                       #endif
                        return OciNativeCalls.OCIHandleAlloc (parenth, out descpp, type, xtramem_sz, usrmempp);
                }
 
                internal static int OCIHandleFree (IntPtr hndlp,
                        OciHandleType type)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, string.Format("OCIHandleFree ({0})", type), "OCI");
+                       #endif
                        return OciNativeCalls.OCIHandleFree (hndlp, type);
                }
 
@@ -794,7 +904,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr errhp,
                        IntPtr locp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobClose", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobClose (svchp, errhp, locp);
                }
 
@@ -806,7 +918,9 @@ namespace System.Data.OracleClient.Oci
                        uint dst_offset,
                        uint src_offset)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobCopy", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobCopy (svchp, errhp, dst_locp, src_locp, amount, dst_offset, src_offset);
                }
 
@@ -816,7 +930,9 @@ namespace System.Data.OracleClient.Oci
                        ref uint amount,
                        uint offset)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobErase", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobErase (svchp, errhp, locp, ref amount, offset);
                }
 
@@ -825,7 +941,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr locp,
                        out uint chunk_size)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobGetChunkSize", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobGetChunkSize (svchp, errhp, locp, out chunk_size);
                }
 
@@ -834,7 +952,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr locp,
                        out uint lenp)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobGetLength", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobGetLength (svchp, errhp, locp, out lenp);
                }
 
@@ -843,7 +963,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr locp,
                        byte mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobOpen", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobOpen (svchp, errhp, locp, mode);
                }
 
@@ -859,8 +981,10 @@ namespace System.Data.OracleClient.Oci
                        ushort csid,
                        byte csfrm)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobRead", "OCI");
-                       return OciNativeCalls.OCILobRead (svchp, errhp, locp, ref amtp, offset, bufp, bufl, 
+                       #endif
+                       return OciNativeCalls.OCILobRead (svchp, errhp, locp, ref amtp, offset, bufp, bufl,
                                ctxp, cbfp, csid, csfrm);
                }
 
@@ -869,7 +993,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr locp,
                        uint newlen)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobTrim", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobTrim (svchp, errhp, locp, newlen);
                }
 
@@ -886,18 +1012,33 @@ namespace System.Data.OracleClient.Oci
                        ushort csid,
                        byte csfrm)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCILobWrite", "OCI");
+                       #endif
                        return OciNativeCalls.OCILobWrite (svchp, errhp, locp, ref amtp, offset, bufp, bufl,
                                piece, ctxp, cbfp, csid, csfrm);
                }
 
-               internal static int OCINlsGetInfo (IntPtr hndl, 
+               internal static int OCILobCharSetForm (IntPtr svchp, 
+                       IntPtr errhp,
+                       IntPtr locp,
+                       out byte csfrm)
+               {
+                       #if TRACE
+                       Trace.WriteLineIf(traceOci, "OCILobCharSetForm", "OCI");
+                       #endif
+                       return OciNativeCalls.OCILobCharSetForm (svchp, errhp, locp, out csfrm);                        
+               }
+               
+               internal static int OCINlsGetInfo (IntPtr hndl,
                        IntPtr errhp,
                        ref byte[] bufp,
-                       uint buflen, 
-                       ushort item) 
+                       uint buflen,
+                       ushort item)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCINlsGetInfo", "OCI");
+                       #endif
                        return OciNativeCalls.OCINlsGetInfo (hndl, errhp, bufp, buflen, item);
                }
 
@@ -907,7 +1048,9 @@ namespace System.Data.OracleClient.Oci
                        int dblink_len,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIServerAttach", "OCI");
+                       #endif
                        return OciNativeCalls.OCIServerAttach (srvhp, errhp, dblink, dblink_len, mode);
                }
 
@@ -915,7 +1058,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr errhp,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIServerDetach", "OCI");
+                       #endif
                        return OciNativeCalls.OCIServerDetach (srvhp, errhp, mode);
                }
 
@@ -923,9 +1068,11 @@ namespace System.Data.OracleClient.Oci
                        IntPtr errhp,
                        ref byte[] bufp,
                        uint bufsz,
-                       OciHandleType hndltype) 
+                       OciHandleType hndltype)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIServerVersion", "OCI");
+                       #endif
                        return OciNativeCalls.OCIServerVersion (hndlp,
                                errhp,
                                bufp,
@@ -939,7 +1086,9 @@ namespace System.Data.OracleClient.Oci
                        OciCredentialType credt,
                        OciSessionMode mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCISessionBegin", "OCI");
+                       #endif
                        return OciNativeCalls.OCISessionBegin (svchp, errhp, usrhp, credt, mode);
                }
 
@@ -948,7 +1097,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr usrhp,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCISessionEnd", "OCI");
+                       #endif
                        return OciNativeCalls.OCISessionEnd (svchp, errhp, usrhp, mode);
                }
 
@@ -958,7 +1109,9 @@ namespace System.Data.OracleClient.Oci
                        out IntPtr parmdpp,
                        int pos)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIParamGet", "OCI");
+                       #endif
                        return OciNativeCalls.OCIParamGet (hndlp, htype, errhp, out parmdpp, pos);
                }
 
@@ -971,12 +1124,14 @@ namespace System.Data.OracleClient.Oci
                        IntPtr snap_out,
                        OciExecuteMode mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIStmtExecute", "OCI");
-                       
+                       #endif
+
                        uint it = 0;
                        if (iters == true)
                                it = 1;
-                       
+
                        return OciNativeCalls.OCIStmtExecute (svchp, stmthp, errhp, it, rowoff,
                                snap_in, snap_out, mode);
                }
@@ -987,10 +1142,12 @@ namespace System.Data.OracleClient.Oci
                        ushort orientation,
                        uint mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCIStmtFetch", "OCI");
+                       #endif
                        return OciNativeCalls.OCIStmtFetch (stmtp, errhp, nrows, orientation, mode);
                }
-                                                       
+
 
                internal static int OCIStmtPrepare (IntPtr stmthp,
                        IntPtr errhp,
@@ -999,8 +1156,10 @@ namespace System.Data.OracleClient.Oci
                        OciStatementLanguage language,
                        OciStatementMode mode)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, string.Format("OCIStmtPrepare ({0})", System.Text.Encoding.UTF8.GetString(stmt)), "OCI");
-                       
+                       #endif
+
                        return OciNativeCalls.OCIStmtPrepare (stmthp, errhp, stmt, stmt_length, language, mode);
                }
 
@@ -1008,7 +1167,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr errhp,
                        uint flags)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCITransCommit", "OCI");
+                       #endif
                        return OciNativeCalls.OCITransCommit (svchp, errhp, flags);
                }
 
@@ -1016,7 +1177,9 @@ namespace System.Data.OracleClient.Oci
                        IntPtr errhp,
                        uint flags)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCITransRollback", "OCI");
+                       #endif
                        return OciNativeCalls.OCITransRollback (svchp, errhp, flags);
                }
 
@@ -1025,37 +1188,81 @@ namespace System.Data.OracleClient.Oci
                        uint timeout,
                        OciTransactionFlags flags)
                {
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCITransStart", "OCI");
+                       #endif
                        return OciNativeCalls.OCITransStart (svchp, errhp, timeout, flags);
                }
 
                internal static int OCICharSetToUnicode (
                        IntPtr svchp,
-                       StringBuilder dst, 
+                       StringBuilder dst,
                        byte [] src,
                        out int rsize)
                {
+                       int rc;
+                       long retSize;
+
+                       #if TRACE
                        Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
-                       
-                       return OciNativeCalls.OCICharSetToUnicode (svchp, dst, dst!=null ? dst.Capacity : 0, src, src.Length, out rsize);
+                       #endif
+                       rc = OciNativeCalls.OCICharSetToUnicode (svchp, dst,
+                                               (dst != null ? dst.Capacity : 0), 
+                                               src, src.Length, out retSize);
+                       rsize = (int) retSize;
+                       return(rc);
                }
 
                internal static int OCIUnicodeToCharSet (
                        IntPtr svchp,
                        byte [] dst,
-                       [MarshalAs (UnmanagedType.LPWStr)] string src, 
-                       [MarshalAs (UnmanagedType.U4)] out int rsize)
+                       string src,
+                       out int rsize)
                {
-                       Trace.WriteLineIf(traceOci, "OCICharSetToUnicode", "OCI");
-                       
-                       return OciNativeCalls.OCIUnicodeToCharSet (svchp, dst, dst!=null ? dst.Length : 0, src, src.Length, out rsize);
+                       int rc;
+                       long retSize;
+
+                       #if TRACE
+                       Trace.WriteLineIf(traceOci, "OCIUnicodeToCharSet", "OCI");
+                       #endif
+
+                       rc = OciNativeCalls.OCIUnicodeToCharSet (svchp, dst,
+                                       (dst != null ? dst.Length : 0), 
+                                       src, src.Length, out retSize);
+                       rsize = (int) retSize;
+                       return(rc);
                }
 
                [DllImport ("oci")]
-               internal static extern int OCIDateTimeCheck (IntPtr hndl,\r
+               internal static extern int OCIDateTimeCheck (IntPtr hndl,
                        IntPtr err, IntPtr date, out uint valid);
 
                #endregion
+
+               #region AllocateClear
+
+               private static bool IsUnix =
+                       (int) Environment.OSVersion.Platform == 4 || (int) Environment.OSVersion.Platform == 128 || (int) Environment.OSVersion.Platform == 6;
+
+               [DllImport("libc")]
+               private static extern IntPtr calloc (int nmemb, int size);
+
+               private const int GMEM_ZEROINIT = 0x40;
+
+               [DllImport("kernel32")]
+               private static extern IntPtr GlobalAlloc (int flags, int bytes);
+
+               //http://download-uk.oracle.com/docs/cd/B14117_01/appdev.101/b10779/oci05bnd.htm#423147
+               internal static IntPtr AllocateClear (int cb)
+               {
+                       if (IsUnix) {
+                               return calloc (1, cb);
+                       } else {
+                               return GlobalAlloc (GMEM_ZEROINIT, cb);
+                       }
+               }
+
+               #endregion AllocateClear
        }
 }