示例#1
0
 internal static void Trace(string fmtPrintfW, OciHandle a1, OCI.HTYPE a2, OciHandle a3, int a4, IntPtr a5, int a6)
 {
     if (((modFlags & ApiGroup.Trace) != ApiGroup.Off) && (modID != NoData))
     {
         NativeMethods.Trace(modID, UIntPtr.Zero, UIntPtr.Zero, fmtPrintfW, OciHandle.HandleValueToTrace(a1), a2.ToString(), OciHandle.HandleValueToTrace(a3), a4, a5, a6);
     }
 }
示例#2
0
        override protected bool ExtraDispose(HandleRef localHandle, OCI.HTYPE handleType)
        {
            int rc;

            if (IntPtr.Zero != _serverHandle.Handle)
            {
                rc = TracedNativeMethods.OCIServerDetach(
                    _serverHandle,                                  // srvhp
                    _errorHandle,                                   // errhp
                    OCI.MODE.OCI_DEFAULT                            // mode
                    );

                if (0 != rc)
                {
                    Debug.WriteLine(String.Format("OracleClient: OCIServerDetach(0x{0,-8:x} failed: rc={1:d}", localHandle.Handle, rc));
                    Debug.Assert(false, "OCIServerDetach failed");
                }
                rc = TracedNativeMethods.OCIHandleFree(_serverHandle, OCI.HTYPE.OCI_HTYPE_SERVER);
            }
            if (IntPtr.Zero != _errorHandle.Handle)
            {
                rc = TracedNativeMethods.OCIHandleFree(_errorHandle, OCI.HTYPE.OCI_HTYPE_ERROR);
            }

            rc = TracedNativeMethods.OCIHandleFree(localHandle, handleType);
            GC.KeepAlive(this);
            return(false);   // don't bother with the default clean up, we already did it.
        }
示例#3
0
 internal static void Trace(string fmtPrintfW, OciHandle a1, OCI.HTYPE a2, OCI.ATTR a3, OciHandle a4, string a5, uint a6, int a7)
 {
     if (((modFlags & ApiGroup.Trace) != ApiGroup.Off) && (modID != NoData))
     {
         NativeMethods.Trace(modID, UIntPtr.Zero, UIntPtr.Zero, fmtPrintfW, OciHandle.HandleValueToTrace(a1), a2.ToString(), OciHandle.GetAttributeName(a1, a3), OciHandle.HandleValueToTrace(a4), a5, a6, a7);
     }
 }
示例#4
0
        // Construct from an external handle and type
        protected OciHandle(
            OciHandle parentOciHandle,
            OCI.HTYPE handleType,
            IntPtr handle
            )
        {
            if (OCI.HTYPE.OCI_HTYPE_ENV != handleType && null == parentOciHandle)
            {
                Debug.Assert(false, "non-environment handle must have a parent");
            }
            else if (OCI.HTYPE.OCI_HTYPE_ENV == handleType && null != parentOciHandle)
            {
                Debug.Assert(false, "environment handle must not have a parent");
            }
            _parentOciHandle = parentOciHandle;
            _handleType      = handleType;
            _handle          = handle;

            if (null != _parentOciHandle)
            {
                _unicode = parentOciHandle._unicode;
            }
            else
            {
                _unicode = false;
            }

//          Console.WriteLine(String.Format("OracleClient:     Wrap handle=0x{0,-8:x} parent=0x{2,-8:x} type={1}", handle, handleType, (null != parentOciHandle ) ? parentOciHandle.Handle : IntPtr.Zero));
        }
 static internal extern int OCIParamGet
 (
     HandleRef hndlp,
     OCI.HTYPE htype,
     HandleRef errhp,
     out IntPtr paramdpp,                                // can't return a handle ref!
     int pos
 );
 static internal extern int OCIDescriptorAlloc
 (
     HandleRef parenth,
     out IntPtr descp,                                           // can't return a handle ref!
     OCI.HTYPE type,
     int xtramem_sz,
     HandleRef usrmempp
 );
 static internal extern int OCIHandleAlloc
 (
     HandleRef parenth,
     out IntPtr hndlpp,                          // can't return a handle ref!
     OCI.HTYPE type,
     int xtramemsz,
     HandleRef usrmempp
 );
示例#8
0
 internal static int OCIHandleFree(IntPtr hndlp, OCI.HTYPE type)
 {
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<oc.OCIHandleFree|ADV|OCI>           hndlp=0x%-07Ix type=%3d\n", hndlp, (int)type);
     }
     return(System.Data.Common.UnsafeNativeMethods.OCIHandleFree(hndlp, type));
 }
 static internal extern int OCIAttrGet
 (
     HandleRef trgthndlp,
     OCI.HTYPE trghndltyp,
     out IntPtr attributep,                                      // can't return a handle ref!
     out int sizep,
     OCI.ATTR attrtype,
     HandleRef errhp
 );
 static internal extern int OCIAttrSet
 (
     HandleRef trgthndlp,
     OCI.HTYPE trghndltyp,
     ref int attributep,
     int size,
     OCI.ATTR attrtype,
     HandleRef errhp
 );
示例#11
0
        virtual protected bool ExtraDispose(HandleRef localHandle, OCI.HTYPE handleType)
        {
            //  Override this method to perform extra work when the handle is being
            //  disposed -- don't touch other managed objects, however.

            //  Return true if you wan't to force the handle to be freed, false if you've
            //  already handled it.
            return(true);
        }
 static internal extern int OCIAttrGet
 (
     HandleRef trgthndlp,
     OCI.HTYPE trghndltyp,
     out short attributep,
     out int sizep,
     OCI.ATTR attrtype,
     HandleRef errhp
 );
示例#13
0
 // Construct from an external handle and type
 protected OciHandle(
     OciHandle parentOciHandle,
     OCI.HTYPE handleType,
     IntPtr handle,
     bool unicode
     ) : this(parentOciHandle, handleType, handle)
 {
     _unicode = unicode;
 }
 static internal extern int OCIAttrSet
 (
     HandleRef trgthndlp,
     OCI.HTYPE trghndltyp,
     [In, MarshalAs(UnmanagedType.LPArray)]
     byte[]          attributep,
     int size,
     OCI.ATTR attrtype,
     HandleRef errhp
 );
示例#15
0
        internal static int OCIParamGet(OciHandle hndlp, OCI.HTYPE hType, OciHandle errhp, out IntPtr paramdpp, int pos)
        {
            int num = System.Data.Common.UnsafeNativeMethods.OCIParamGet(hndlp, hType, errhp, out paramdpp, (uint)pos);

            if (Bid.AdvancedOn)
            {
                Bid.Trace("<oc.OCIParamGet|ADV|OCI|RET>         hndlp=0x%-07Ix htype=%-18ls errhp=0x%-07Ix pos=%d paramdpp=0x%-07Ix rc=%d\n", hndlp, hType, errhp, pos, paramdpp, num);
            }
            return(num);
        }
示例#16
0
        internal static int OCIHandleAlloc(OciHandle parenth, out IntPtr hndlpp, OCI.HTYPE type)
        {
            int num = System.Data.Common.UnsafeNativeMethods.OCIHandleAlloc(parenth, out hndlpp, type, IntPtr.Zero, IntPtr.Zero);

            if (Bid.AdvancedOn)
            {
                Bid.Trace("<oc.OCIHandleAlloc|ADV|OCI|RET>      parenth=0x%-07Ix type=%3d xtramemsz=0x%-07Ix usrmempp=0x%-07Ix hndlpp=0x%-07Ix rc=%d\n", parenth, (int)type, IntPtr.Zero, IntPtr.Zero, hndlpp, num);
            }
            return(num);
        }
 static internal extern int OCIErrorGet
 (
     HandleRef hndlp,
     int recordno,
     HandleRef sqlstate,
     out int errcodep,
     HandleRef bufp,
     int bufsiz,
     OCI.HTYPE type
 );
示例#18
0
        static internal OciHandle GetHandle(OCI.HTYPE handleType)
        {
            OracleConnection.OraclePermission.Demand();

            if (!isInitialized)
            {
                Initialize();
            }

            if (OCI.HTYPE.OCI_HTYPE_ERROR == handleType)
            {
                return(availableErrorHandle);                           // TODO: we probably have thread-safety issues here; can we get some thread affinity?
            }
            return(environmentHandle.CreateOciHandle(handleType));
        }
示例#19
0
        // Construct by allocating a new handle as a child of the specified parent handle
        protected OciHandle(
            OciHandle parentOciHandle,
            OCI.HTYPE handleType
            )
        {
            int rc;

            _parentOciHandle = parentOciHandle;
            _handleType      = handleType;
            _unicode         = parentOciHandle._unicode;

            if (_handleType < OCI.HTYPE.OCI_DTYPE_FIRST)
            {
                rc = TracedNativeMethods.OCIHandleAlloc(
                    parentOciHandle,
                    out _handle,
                    _handleType,
                    0,
                    ADP.NullHandleRef);
            }
            else
            {
                rc = TracedNativeMethods.OCIDescriptorAlloc(
                    parentOciHandle,
                    out _handle,
                    _handleType,
                    0,
                    ADP.NullHandleRef);
            }

            if (0 != rc || IntPtr.Zero == _handle)
            {
                throw ADP.OperationFailed("OCIDescriptorAllocate", rc);
            }

//          Console.WriteLine(String.Format("OracleClient: Allocate handle=0x{0,-8:x} parent=0x{2,-8:x} type={1}", _handle, _handleType, (null != parentOciHandle ) ? parentOciHandle.Handle : IntPtr.Zero));
        }
示例#20
0
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        //
        // Methods
        //
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////

        internal OciHandle CreateOciHandle(
            OCI.HTYPE handleType
            )
        {
            //  Constructs a new handle of the type requested, with this handle
            //  as it's parent.  Basically, creates a new handle using the
            //  constructor that does all the work.
            switch (handleType)
            {
            case OCI.HTYPE.OCI_HTYPE_ERROR:     return(new OciErrorHandle(this));

            case OCI.HTYPE.OCI_HTYPE_SERVER:    return(new OciServerHandle(this));

            case OCI.HTYPE.OCI_HTYPE_SVCCTX:    return(new OciServiceContextHandle(this));

            case OCI.HTYPE.OCI_HTYPE_SESSION:   return(new OciSessionHandle(this));

            case OCI.HTYPE.OCI_HTYPE_STMT:      return(new OciStatementHandle(this));

            default:
                Debug.Assert(false, "Unexpected OCI Handle Type requested:" + handleType.ToString("G"));
                return(null);
            }
        }
        internal int Release()
        {
            int num2;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                int num;
                num2 = Interlocked.Decrement(ref this._refCount);
                if (num2 != 0)
                {
                    goto Label_0168;
                }
                IntPtr hndlp = Interlocked.CompareExchange(ref this.handle, IntPtr.Zero, base.handle);
                if (!(IntPtr.Zero != hndlp))
                {
                    goto Label_0168;
                }
                OCI.HTYPE handleType   = this.HandleType;
                OciHandle parentHandle = this.ParentHandle;
                switch (handleType)
                {
                case OCI.HTYPE.OCI_HTYPE_ENV:
                    num = TracedNativeMethods.OCIHandleFree(hndlp, handleType);
                    if (num != 0)
                    {
                        throw System.Data.Common.ADP.OperationFailed("OCIHandleFree", num);
                    }
                    goto Label_015E;

                case OCI.HTYPE.OCI_HTYPE_ERROR:
                case OCI.HTYPE.OCI_HTYPE_STMT:
                case OCI.HTYPE.OCI_HTYPE_SESSION:
                    break;

                case OCI.HTYPE.OCI_HTYPE_SVCCTX:
                {
                    OciHandle handle2 = parentHandle;
                    if (handle2 != null)
                    {
                        OciHandle handle4 = handle2.ParentHandle;
                        if (handle4 != null)
                        {
                            OciHandle handle3 = handle4.ParentHandle;
                            if (handle3 != null)
                            {
                                num = TracedNativeMethods.OCISessionEnd(hndlp, handle3.DangerousGetHandle(), handle2.DangerousGetHandle(), OCI.MODE.OCI_DEFAULT);
                            }
                        }
                    }
                    break;
                }

                case OCI.HTYPE.OCI_HTYPE_SERVER:
                    TracedNativeMethods.OCIServerDetach(hndlp, parentHandle.DangerousGetHandle(), OCI.MODE.OCI_DEFAULT);
                    break;

                case OCI.HTYPE.OCI_DTYPE_FIRST:
                case OCI.HTYPE.OCI_DTYPE_ROWID:
                case OCI.HTYPE.OCI_DTYPE_FILE:
                case OCI.HTYPE.OCI_DTYPE_INTERVAL_DS:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_TZ:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_LTZ:
                    num = TracedNativeMethods.OCIDescriptorFree(hndlp, handleType);
                    if (num != 0)
                    {
                        throw System.Data.Common.ADP.OperationFailed("OCIDescriptorFree", num);
                    }
                    goto Label_015E;

                default:
                    goto Label_015E;
                }
                num = TracedNativeMethods.OCIHandleFree(hndlp, handleType);
                if (num != 0)
                {
                    throw System.Data.Common.ADP.OperationFailed("OCIHandleFree", num);
                }
Label_015E:
                if (parentHandle != null)
                {
                    parentHandle.Release();
                }
                Label_0168 :;
            }
            return(num2);
        }
 protected OciHandle(OciHandle parentHandle, OCI.HTYPE handleType) : this(parentHandle, handleType, OCI.MODE.OCI_DEFAULT, HANDLEFLAG.DEFAULT)
 {
 }
        protected OciHandle(OciHandle parentHandle, OCI.HTYPE handleType, OCI.MODE ocimode, HANDLEFLAG handleflags) : this()
        {
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                int num;
                this._handleType   = handleType;
                this._parentHandle = parentHandle;
                this._refCount     = 1;
                switch (handleType)
                {
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_TZ:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_LTZ:
                case OCI.HTYPE.OCI_DTYPE_INTERVAL_DS:
                case OCI.HTYPE.OCI_DTYPE_FIRST:
                case OCI.HTYPE.OCI_DTYPE_ROWID:
                case OCI.HTYPE.OCI_DTYPE_FILE:
                    num = TracedNativeMethods.OCIDescriptorAlloc(parentHandle.EnvironmentHandle, out this.handle, handleType);
                    if ((num != 0) || (IntPtr.Zero == base.handle))
                    {
                        throw System.Data.Common.ADP.OperationFailed("OCIDescriptorAlloc", num);
                    }
                    break;

                case OCI.HTYPE.OCI_HTYPE_ENV:
                    if ((handleflags & HANDLEFLAG.NLS) != HANDLEFLAG.NLS)
                    {
                        num = TracedNativeMethods.OCIEnvCreate(out this.handle, ocimode);
                        if ((num != 0) || (IntPtr.Zero == base.handle))
                        {
                            throw System.Data.Common.ADP.OperationFailed("OCIEnvCreate", num);
                        }
                    }
                    else
                    {
                        num = TracedNativeMethods.OCIEnvNlsCreate(out this.handle, ocimode, 0, 0);
                        if ((num != 0) || (IntPtr.Zero == base.handle))
                        {
                            throw System.Data.Common.ADP.OperationFailed("OCIEnvNlsCreate", num);
                        }
                    }
                    break;

                case OCI.HTYPE.OCI_HTYPE_ERROR:
                case OCI.HTYPE.OCI_HTYPE_SVCCTX:
                case OCI.HTYPE.OCI_HTYPE_STMT:
                case OCI.HTYPE.OCI_HTYPE_SERVER:
                case OCI.HTYPE.OCI_HTYPE_SESSION:
                    num = TracedNativeMethods.OCIHandleAlloc(parentHandle.EnvironmentHandle, out this.handle, handleType);
                    if ((num != 0) || (IntPtr.Zero == base.handle))
                    {
                        throw System.Data.Common.ADP.OperationFailed("OCIHandleAlloc", num);
                    }
                    break;
                }
                if (parentHandle != null)
                {
                    parentHandle.AddRef();
                    this._isUnicode = parentHandle.IsUnicode;
                }
                else
                {
                    this._isUnicode = (handleflags & HANDLEFLAG.UNICODE) == HANDLEFLAG.UNICODE;
                }
            }
        }
示例#24
0
 internal static extern int OCIDescriptorAlloc(OciHandle parenth, out IntPtr descp, [In, MarshalAs(UnmanagedType.U4)] OCI.HTYPE type, IntPtr xtramem_sz, IntPtr usrmempp);
 protected OciHandle(OCI.HTYPE handleType) : base(IntPtr.Zero, false)
 {
     this._handleType = handleType;
 }
示例#26
0
 internal static extern int OCIDescriptorFree(IntPtr hndlp, [In, MarshalAs(UnmanagedType.U4)] OCI.HTYPE type);
示例#27
0
 internal static extern int OCIErrorGet(OciHandle hndlp, uint recordno, IntPtr sqlstate, out int errcodep, NativeBuffer bufp, uint bufsiz, [In, MarshalAs(UnmanagedType.U4)] OCI.HTYPE type);
 static internal extern int OCIHandleFree
 (
     HandleRef hndlp,
     OCI.HTYPE type
 );
示例#29
0
 internal static extern int OCIHandleAlloc(OciHandle parenth, out IntPtr hndlpp, [In, MarshalAs(UnmanagedType.U4)] OCI.HTYPE type, IntPtr xtramemsz, IntPtr usrmempp);
 static internal extern int OCIDescriptorFree
 (
     HandleRef hndlp,
     OCI.HTYPE type
 );