Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
//
// OciAttributeType.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
internal enum OciAttributeType {
FunctionCode = 0x01,
ObjectMode = 0x02,
NonBlockingMode = 0x03,
SqlCode = 0x04,
Environment = 0x05,
Server = 0x06,
Session = 0x07,
Transaction = 0x08,
RowCount = 0x09,
SqlFunctionCode = 0x0a,
PrefetchRows = 0x0b,
NestedPrefetchRows = 0x0c,
PrefetchMemory = 0x0d,
NestedPrefetchMemory = 0x0e,
CharacterCount = 0x0f,
PackedDecimalScale = 0x10,
PackedDecimalFormat = 0x11,
ParameterCount = 0x12,
RowId = 0x13,
CharacterSet = 0x14,
NChar = 0x15,
Username = 0x16,
Password = 0x17,
StatementType = 0x18,
InternalName = 0x19,
ExternalName = 0x1a,
TransactionId = 0x1b,
TransactionLock = 0x1c,
TransactionName = 0x1d,
HeapAlloc = 0x1e,
CharacterSetId = 0x1f,
CharacterSetForm = 0x20,
MaxDataSize = 0x21,
CacheOptimalSize = 0x22,
CacheMaxSize = 0x23,
PinOption = 0x24,
AllocDuration = 0x25,
PinDuration = 0x26,
FormatDescriptorObject = 0x27,
PostProcessingCallback = 0x28,
PostProcessingContext = 0x29,
RowsReturned = 0x2a,
FailoverCallback = 0x2b,
InV8Mode = 0x2c,
LobEmpty = 0x2d,
SessionLanguage = 0x2e,
DateFormat = 0x4b,
/* Attributes common to columns and stored procedures */
DataSize = 0x01,
DataType = 0x02,
DisplaySize = 0x03,
Name = 0x04,
Precision = 0x05,
Scale = 0x06,
IsNull = 0x07,
TypeName = 0x08,
SchemaName = 0x09,
SubName = 0x0a,
Position = 0x0b,
/* Only columns */
DisplayName = 0x64
}
}

View File

@@ -0,0 +1,66 @@
//
// OciBindHandle.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace System.Data.OracleClient.Oci {
internal sealed class OciBindHandle : OciHandle, IDisposable
{
#region Fields
bool disposed = false;
IntPtr value;
#endregion // Fields
#region Constructors
public OciBindHandle (OciHandle parent)
: base (OciHandleType.Bind, parent, IntPtr.Zero)
{
}
#endregion // Constructors
#region Properties
public IntPtr Value {
get { return value; }
set { this.value = value; }
}
#endregion // Properties
#region Methods
protected override void Dispose (bool disposing)
{
if (!disposed) {
try {
Marshal.FreeHGlobal (value);
disposed = true;
} finally {
base.Dispose (disposing);
}
}
}
#endregion // Methods
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
//
// OciColumnInfo.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
internal struct OciColumnInfo
{
public string ColumnName;
public int ColumnOrdinal;
public ushort ColumnSize;
public byte Precision;
public sbyte Scale;
public OciDataType DataType;
public bool AllowDBNull;
public string BaseColumnName;
}
}

View File

@@ -0,0 +1,26 @@
//
// OciCredentialType.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
internal enum OciCredentialType {
RDBMS = 0x01,
External = 0x02,
Proxy = 0x03
}
}

View File

@@ -0,0 +1,54 @@
//
// OciDataType.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Authors:
// Tim Coleman <tim@timcoleman.com>
// Daniel Morgan <danielmorgan@verizon.net>
//
// Copyright (C) Tim Coleman, 2003
// Copyright (C) Daniel Morgan, 2005
//
//
namespace System.Data.OracleClient.Oci {
internal enum OciDataType : uint {
VarChar2 = 0x01,
Number = 0x02,
Integer = 0x03,
Float = 0x04,
String = 0x05,
VarNum = 0x06,
Long = 0x08,
VarChar = 0x09,
RowId = 0x0b,
Date = 0x0c,
VarRaw = 0x0f,
Raw = 0x17,
LongRaw = 0x18,
UnsignedInt = 0x44,
LongVarChar = 0x5e,
LongVarRaw = 0x5f,
Char = 0x60,
CharZ = 0x61,
RowIdDescriptor = 0x68,
NamedDataType = 0x6c,
Ref = 0x6e,
Clob = 0x70,
Blob = 0x71,
BFile = 0x72,
RSet = 0x74, // REF CURSOR
OciString = 0x9b,
OciDate = 0x9c,
TimeStamp = 0xbb,
IntervalYearToMonth = 0xbd,
IntervalDayToSecond = 0xbe
}
}

View File

@@ -0,0 +1,119 @@
//
// OciDateTimeDescriptor.cs - used for an Oracle TIMESTAMP
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Daniel Morgan <danielmorgan@verizon.net>
//
// Copyright (C) Daniel Morgan, 2005
//
using System;
using System.Data;
using System.Data.OracleClient;
using System.Runtime.InteropServices;
namespace System.Data.OracleClient.Oci {
internal sealed class OciDateTimeDescriptor : OciDescriptorHandle, IDisposable
{
#region Fields
OciErrorHandle errorHandle;
//OciServiceHandle service;
bool disposed = false;
#endregion // Fields
#region Constructors
public OciDateTimeDescriptor (OciHandle parent, IntPtr newHandle)
: base (OciHandleType.TimeStamp, parent, newHandle)
{
}
#endregion // Constructors
#region Properties
public OciErrorHandle ErrorHandle {
get { return errorHandle; }
set { errorHandle = value; }
}
#endregion // Properties
#region Methods
protected override void Dispose (bool disposing)
{
if (!disposed) {
disposed = true;
base.Dispose (disposing);
}
}
public void SetDateTime (OciHandle handle, OciErrorHandle errorHandle,
short year, byte month, byte day,
byte hour, byte min, byte sec, uint fsec, string timezone)
{
// Get size of buffer
int rsize = 0;
int status = OciCalls.OCIUnicodeToCharSet (handle, null, timezone, out rsize);
// Fill buffer
byte[] bytes = new byte[rsize];
if (status == 0 && rsize > 0)
OciCalls.OCIUnicodeToCharSet (handle, bytes, timezone, out rsize);
if (fsec > 0)
fsec = fsec * 1000000;
uint timezoneSize = (uint) bytes.Length;
OciCalls.OCIDateTimeConstruct (handle,
errorHandle, this.Handle,
year, month, day,
hour, min, sec, fsec,
bytes, timezoneSize);
//uint valid = 0;
//int result = OciCalls.OCIDateTimeCheck (handle,
// errorHandle, this.Handle, out valid);
}
public DateTime GetDateTime (OciHandle handle, OciErrorHandle errorHandle)
{
short year = 0;
byte month = 0;
byte day = 0;
byte hour = 0;
byte min = 0;
byte sec = 0;
uint fsec = 0;
int fs = 0;
OciCalls.OCIDateTimeGetDate (handle, errorHandle, this.Handle,
out year, out month, out day);
OciCalls.OCIDateTimeGetTime (handle, errorHandle, this.Handle,
out hour, out min, out sec, out fsec);
// a TIMESTAMP can have up to 9 digits of millisecond but DateTime only
// can be up to 999.
if (fsec > 0) {
int fseci = (int) fsec;
fs = fseci / 1000000;
}
return new DateTime(year, month, day, hour, min, sec, fs);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,56 @@
//
// OciDescriptorHandle.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
using System.Runtime.InteropServices;
namespace System.Data.OracleClient.Oci {
internal abstract class OciDescriptorHandle : OciHandle
{
#region Constructors
internal OciDescriptorHandle (OciHandleType type, OciHandle parent, IntPtr newHandle)
: base (type, parent, newHandle)
{
}
#endregion // Constructors
#region Methods
protected override void FreeHandle ()
{
// Parameter handles are disposed implicitely
if (HandleType >= OciHandleType.LobLocator) {
switch(HandleType) {
case OciHandleType.Parameter:
case OciHandleType.TimeStamp:
break;
default:
if (Handle != IntPtr.Zero) {
OciCalls.OCIDescriptorFree (this, HandleType);
SetHandle (IntPtr.Zero);
}
break;
}
}
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,59 @@
//
// OciEnvironmentHandle.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
using System.Runtime.InteropServices;
namespace System.Data.OracleClient.Oci {
internal class OciEnvironmentHandle : OciHandle, IDisposable
{
#region Constructors
public OciEnvironmentHandle ()
: this (OciEnvironmentMode.Default)
{
}
public OciEnvironmentHandle (OciEnvironmentMode mode)
: base (OciHandleType.Environment, null, IntPtr.Zero)
{
IntPtr newHandle = IntPtr.Zero;
OciCalls.OCIEnvCreate (out newHandle,
mode,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
0,
IntPtr.Zero);
SetHandle (newHandle);
}
#endregion // Constructors
#region Methods
public OciErrorInfo HandleError ()
{
OciErrorInfo info = OciErrorHandle.HandleError (this);
return info;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,34 @@
//
// OciEnvironmentMode.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
[Flags]
internal enum OciEnvironmentMode {
Default = 0x00,
Threaded = 0x01,
Object = 0x02,
Events = 0x04,
Shared = 0x10,
NoUserCallback = 0x40,
NoMutex = 0x80,
SharedExt = 0x100,
Cache = 0x200,
NoCache = 0x400
}
}

View File

@@ -0,0 +1,154 @@
//
// OciErrorHandle.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace System.Data.OracleClient.Oci {
internal sealed class OciErrorHandle : OciHandle, IDisposable
{
#region Fields
bool disposed = false;
#endregion // Fields
#region Constructors
public OciErrorHandle (OciHandle parent, IntPtr newHandle)
: base (OciHandleType.Error, parent, newHandle)
{
}
#endregion // Constructors
#region Methods
protected override void Dispose (bool disposing)
{
if (!disposed) {
disposed = true;
base.Dispose (disposing);
}
}
public static void ThrowExceptionIfError (OciHandle hwnd, int status)
{
if (status == 0)
return;
OciErrorInfo info = HandleError (hwnd, status);
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
public static OciErrorInfo HandleError (OciHandle hwnd, int status)
{
OciErrorInfo info;
info.ErrorCode = status;
info.ErrorMessage = OciGlue.ReturnCodeToString (status);
if (status == OciGlue.OCI_ERROR || status == OciGlue.OCI_SUCCESS_WITH_INFO) {
OciHandle h = hwnd;
if (h == null)
throw new Exception ("Internal driver error: handle is null.");
int errbufSize = 4096;
IntPtr errbuf = OciCalls.AllocateClear (errbufSize);
OciCalls.OCIErrorGet (hwnd,
1,
IntPtr.Zero,
out info.ErrorCode,
errbuf,
(uint) errbufSize,
OciHandleType.Error);
byte[] bytea = new byte[errbufSize];
Marshal.Copy (errbuf, bytea, 0, errbufSize);
errbufSize = 0;
// first call to OCICharSetToUnicode gets the size
OciCalls.OCICharSetToUnicode (h, null, bytea, out errbufSize);
StringBuilder str = new StringBuilder (errbufSize);
// second call to OCICharSetToUnicode gets the string
OciCalls.OCICharSetToUnicode (h, str, bytea, out errbufSize);
string errmsg = String.Empty;
if (errbufSize > 0) {
errmsg = str.ToString ();
info.ErrorMessage = String.Copy (errmsg);
}
Marshal.FreeHGlobal (errbuf);
}
return info;
}
public static OciErrorInfo HandleError (OciHandle hand)
{
OciErrorInfo info;
info.ErrorCode = 0;
info.ErrorMessage = String.Empty;
int errbufSize = 4096;
IntPtr errbuf = OciCalls.AllocateClear (errbufSize);
OciCalls.OCIErrorGet (hand,
1,
IntPtr.Zero,
out info.ErrorCode,
errbuf,
(uint) errbufSize,
OciHandleType.Error);
byte[] bytea = new byte[errbufSize];
Marshal.Copy (errbuf, bytea, 0, errbufSize);
errbufSize = 0;
OciHandle h = hand.Parent;
if (h == null)
h = hand;
if (h == null)
throw new Exception ("Internal driver error: handle is null.");
// first call to OCICharSetToUnicode gets the size
OciCalls.OCICharSetToUnicode (h, null, bytea, out errbufSize);
StringBuilder str = new StringBuilder (errbufSize);
// second call to OCICharSetToUnicode gets the string
OciCalls.OCICharSetToUnicode (h, str, bytea, out errbufSize);
string errmsg = String.Empty;
if (errbufSize > 0)
errmsg = str.ToString ();
else
errmsg = "Internal driver error. Could not retrieve error message.";
info.ErrorMessage = String.Copy (errmsg);
Marshal.FreeHGlobal (errbuf);
return info;
}
public OciErrorInfo HandleError ()
{
return HandleError (this);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,26 @@
//
// OciErrorInfo.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
internal struct OciErrorInfo
{
public int ErrorCode;
public string ErrorMessage;
}
}

View File

@@ -0,0 +1,35 @@
//
// OciExecuteMode.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
[Flags]
internal enum OciExecuteMode {
Default = 0x00,
BatchMode = 0x01,
ExactFetch = 0x02,
KeepFetchState = 0x04,
ScrollableCursor = 0x08,
DescribeOnly = 0x10,
CommitOnSuccess = 0x20,
NonBlocking = 0x40,
BatchErrors = 0x80,
ParseOnly = 0x100,
ShowDmlWarnings = 0x400
}
}

View File

@@ -0,0 +1,353 @@
//
// OciHandle.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
// Daniel Morgan <danielmorgan@verizon.net>
//
// Copyright (C) Tim Coleman, 2003
// Copyright (C) Daniel Morgan, 2005
//
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Security.Cryptography;
using System.Globalization;
namespace System.Data.OracleClient.Oci {
internal abstract class OciHandle : IDisposable {
#region Fields
bool disposed = false;
protected internal IntPtr handle = IntPtr.Zero;
OciHandle parent = null;
OciHandleType type;
#endregion // Fields
#region Constructors
internal OciHandle (OciHandleType type, OciHandle parent, IntPtr newHandle) {
this.type = type;
this.parent = parent;
this.handle = newHandle;
}
~OciHandle () {
Dispose (false);
}
#endregion // Constructors
#region Properties
internal OciHandle Parent {
get { return parent; }
}
internal IntPtr Handle {
get { return handle; }
}
internal OciHandleType HandleType {
get { return type; }
}
#endregion // Properties
#region Methods
internal OciHandle Allocate (OciHandleType type) {
int status = 0;
IntPtr newHandle = IntPtr.Zero;
if (type < OciHandleType.LobLocator)
status = OciCalls.OCIHandleAlloc (this,
out newHandle,
type,
0,
IntPtr.Zero);
else
status = OciCalls.OCIDescriptorAlloc (this,
out newHandle,
type,
0,
IntPtr.Zero);
if (status != 0 && status != 1)
throw new Exception (String.Format ("Could not allocate new OCI Handle of type {0}", type));
switch (type) {
case OciHandleType.Service:
return new OciServiceHandle (this, newHandle);
case OciHandleType.Error:
return new OciErrorHandle (this, newHandle);
case OciHandleType.Server:
return new OciServerHandle (this, newHandle);
case OciHandleType.Session:
return new OciSessionHandle (this, newHandle);
case OciHandleType.Statement:
return new OciStatementHandle (this, newHandle);
case OciHandleType.Transaction:
return new OciTransactionHandle (this, newHandle);
case OciHandleType.LobLocator:
return new OciLobLocator (this, newHandle);
case OciHandleType.RowId:
return new OciRowIdDescriptor (this, newHandle);
case OciHandleType.TimeStamp:
return new OciDateTimeDescriptor (this, newHandle);
case OciHandleType.IntervalDayToSecond:
case OciHandleType.IntervalYearToMonth:
return new OciIntervalDescriptor (this, type, newHandle);
}
return null;
}
protected virtual void Dispose (bool disposing) {
if (!disposed) {
FreeHandle ();
if (disposing) {
parent = null;
}
disposed = true;
}
}
public void Dispose () {
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void FreeHandle ()
{
if (type < OciHandleType.LobLocator) {
switch (type) {
case OciHandleType.Bind:
case OciHandleType.Define:
// Bind and Define handles are freed when Statement handle is disposed
break;
case OciHandleType.Environment:
if (handle != IntPtr.Zero) {
OciCalls.OCIHandleFree (handle, type);
}
break;
default:
if ( handle != IntPtr.Zero &&
parent != null &&
parent.Handle != IntPtr.Zero ) {
OciCalls.OCIHandleFree (handle, type);
}
break;
}
handle = IntPtr.Zero;
}
}
internal bool GetAttributeBool (OciAttributeType attrType, OciErrorHandle errorHandle) {
return (GetAttributeInt32 (attrType, errorHandle) != 0);
}
internal sbyte GetAttributeSByte (OciAttributeType attrType, OciErrorHandle errorHandle) {
int status = 0;
sbyte output;
status = OciCalls.OCIAttrGetSByte (Handle,
HandleType,
out output,
IntPtr.Zero,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return output;
}
internal byte GetAttributeByte (OciAttributeType attrType, OciErrorHandle errorHandle) {
int status = 0;
byte output;
status = OciCalls.OCIAttrGetByte (Handle,
HandleType,
out output,
IntPtr.Zero,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return output;
}
internal ushort GetAttributeUInt16 (OciAttributeType attrType, OciErrorHandle errorHandle) {
int status = 0;
ushort output;
status = OciCalls.OCIAttrGetUInt16 (Handle,
HandleType,
out output,
IntPtr.Zero,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return output;
}
internal int GetAttributeInt32 (OciAttributeType attrType, OciErrorHandle errorHandle) {
int status = 0;
int output;
status = OciCalls.OCIAttrGetInt32 (Handle,
HandleType,
out output,
IntPtr.Zero,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = OciErrorHandle.HandleError (errorHandle, status);
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return output;
}
[DllImport ("oci", EntryPoint = "OCIAttrGet")]
internal static extern int OCIAttrGetRowIdDesc (IntPtr trgthndlp,
[MarshalAs (UnmanagedType.U4)] OciHandleType trghndltyp,
IntPtr attributep,
ref uint sizep,
[MarshalAs (UnmanagedType.U4)] OciAttributeType attrtype,
IntPtr errhp);
internal OciRowIdDescriptor GetAttributeRowIdDescriptor (OciErrorHandle errorHandle, OciHandle env)
{
OciRowIdDescriptor descriptor = null;
IntPtr outputPtr = IntPtr.Zero;
int outSize = 16;
int status = 0;
OciAttributeType attrType = OciAttributeType.RowId;
outputPtr = OciCalls.AllocateClear (outSize);
uint siz = (uint) outSize;
status = OCIAttrGetRowIdDesc (Handle,
HandleType,
outputPtr,
ref siz,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
if (outputPtr != IntPtr.Zero && siz > 0) {
descriptor = (OciRowIdDescriptor) env.Allocate(OciHandleType.RowId);
descriptor.SetHandle (outputPtr);
}
return descriptor;
}
internal IntPtr GetAttributeIntPtr (OciAttributeType attrType, OciErrorHandle errorHandle) {
int status = 0;
IntPtr output = IntPtr.Zero;
status = OciCalls.OCIAttrGetIntPtr (Handle,
HandleType,
out output,
IntPtr.Zero,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return output;
}
internal string GetAttributeString (OciAttributeType attrType, OciErrorHandle errorHandle) {
string output = String.Empty;
IntPtr outputPtr = IntPtr.Zero;
int outSize;
int status = 0;
status = OciCalls.OCIAttrGet (Handle,
HandleType,
out outputPtr,
out outSize,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
if (outputPtr != IntPtr.Zero && outSize > 0) {
object str = Marshal.PtrToStringAnsi (outputPtr, outSize);
if (str != null)
output = String.Copy ((string) str);
}
return output;
}
internal void SetAttributeString (string attribute, OciAttributeType attrType, OciErrorHandle errorHandle)
{
int status = 0;
status = OciCalls.OCIAttrSetString (Handle,
HandleType,
attribute,
(uint) attribute.Length,
attrType,
errorHandle);
if (status != 0) {
OciErrorInfo info = errorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
}
internal void SetHandle (IntPtr h)
{
handle = h;
}
#endregion // Methods
#region Operators and Type Conversions
public static implicit operator IntPtr (OciHandle h)
{
return h.Handle;
}
#endregion // Operators and Type Conversions
}
}

View File

@@ -0,0 +1,65 @@
//
// OciHandleType.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
internal enum OciHandleType {
Environment = 0x01,
Error = 0x02,
Service = 0x03,
Statement = 0x04,
Bind = 0x05,
Define = 0x06,
Describe = 0x07,
Server = 0x08,
Session = 0x09,
Transaction = 0x0a,
ComplexObject = 0x0b,
Security = 0x0c,
Subscription = 0x0d,
DirectPathContext = 0x0e,
DirectPathColumnArray = 0x0f,
DirectPathStream = 0x10,
Process = 0x11,
// Descriptor handles
LobLocator = 0x32,
Snapshot = 0x33,
ResultSet = 0x34,
Parameter = 0x35,
RowId = 0x36,
//ComplexObject = 0x37,
FileLobLocator = 0x38,
EnqueueOptions = 0x39,
DequeueOptions = 0x3a,
MessageProperties = 0x3b,
Agent = 0x3c,
Locator = 0x3d,
IntervalYearToMonth = 0x3e,
IntervalDayToSecond = 0x3f,
Notify = 0x40,
Date = 0x41,
Time = 0x42,
TimeWithTZ = 0x43,
TimeStamp = 0x44,
TimeStampWithTZ = 0x45,
TimeStampLocal = 0x46,
UserCallback = 0x47
}
}

View File

@@ -0,0 +1,92 @@
//
// OciIntervalDescriptor.cs - used for an Oracle TIMESPAN/INTERVAL{YTM/DTS}
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Veerapuram Varadhan <vvaradhan@novell.com>
//
// Copyright (C) Novell Inc, 2009
//
using System;
using System.Data;
using System.Data.OracleClient;
using System.Runtime.InteropServices;
namespace System.Data.OracleClient.Oci {
internal sealed class OciIntervalDescriptor : OciDescriptorHandle, IDisposable
{
#region Fields
OciErrorHandle errorHandle;
bool disposed = false;
#endregion // Fields
#region Constructors
public OciIntervalDescriptor (OciHandle parent, OciHandleType type, IntPtr newHandle)
: base (type, parent, newHandle)
{
}
#endregion // Constructors
#region Properties
public OciErrorHandle ErrorHandle {
get { return errorHandle; }
set { errorHandle = value; }
}
#endregion // Properties
#region Methods
protected override void Dispose (bool disposing)
{
if (!disposed) {
disposed = true;
base.Dispose (disposing);
}
}
public TimeSpan GetDayToSecond (OciHandle handle, OciErrorHandle errorHandle)
{
int days = 0;
int hours = 0;
int mins = 0;
int secs = 0;
int fsec = 0;
int fs = 0;
OciCalls.OCIIntervalGetDaySecond (handle, errorHandle, out days, out hours,
out mins, out secs, out fsec, this.handle);
if (fsec > 0) {
int fseci = (int) fsec;
fs = fseci / 1000000;
}
return new TimeSpan (days, hours, mins, secs, fs);
}
public int GetYearToMonth (OciHandle handle, OciErrorHandle errorHandle)
{
int years = 0;
int months = 0;
OciCalls.OCIIntervalGetYearMonth (handle, errorHandle, out years, out months, this.handle);
return ((years * 12) + months);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,255 @@
//
// OciLobLocator.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
using System.Data.OracleClient;
using System.Runtime.InteropServices;
namespace System.Data.OracleClient.Oci {
internal sealed class OciLobLocator : OciDescriptorHandle, IDisposable
{
#region Fields
bool disposed = false;
OciErrorHandle errorHandle;
OciServiceHandle service;
OciEnvironmentHandle environment;
OciDataType type;
#endregion // Fields
#region Constructors
public OciLobLocator (OciHandle parent, IntPtr handle)
: base (OciHandleType.LobLocator, parent, handle)
{
}
#endregion // Constructors
#region Properties
public OciErrorHandle ErrorHandle {
get { return errorHandle; }
set { errorHandle = value; }
}
public OciServiceHandle Service {
get { return service; }
set { service = value; }
}
public OciDataType LobType {
get { return type; }
set { type = value; }
}
public OciEnvironmentHandle Environment {
get { return environment; }
set { environment = value; }
}
#endregion // Properties
#region Methods
public void BeginBatch (OracleLobOpenMode mode)
{
int status = 0;
status = OciCalls.OCILobOpen (Service,
ErrorHandle,
Handle,
(byte) mode);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
}
public uint Copy (OciLobLocator destination, uint amount, uint destinationOffset, uint sourceOffset)
{
OciCalls.OCILobCopy (Service,
ErrorHandle,
destination,
Handle,
amount,
destinationOffset,
sourceOffset);
return amount;
}
protected override void Dispose (bool disposing)
{
if (!disposed) {
disposed = true;
base.Dispose ();
}
}
public void EndBatch ()
{
int status = 0;
status = OciCalls.OCILobClose (Service, ErrorHandle, this);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
}
public uint Erase (uint offset, uint amount)
{
int status = 0;
uint output = amount;
status = OciCalls.OCILobErase (Service,
ErrorHandle,
this,
ref output,
(uint) offset);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return output;
}
public int GetChunkSize ()
{
int status = 0;
uint output;
status = OciCalls.OCILobGetChunkSize (Service,
ErrorHandle,
this,
out output);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return (int) output;
}
public long GetLength (bool binary)
{
int status = 0;
uint output;
status = OciCalls.OCILobGetLength (Service,
ErrorHandle,
this,
out output);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
if (!binary)
output *= 2;
return (long) output;
}
public int Read (byte[] buffer, uint offset, uint count, bool binary)
{
int status = 0;
uint amount = count;
byte csfrm = 0;
// Character types are UTF-16, so amount of characters is 1/2
// the amount of bytes
if (!binary) {
amount /= 2;
status = OciCalls.OCILobCharSetForm (environment,
ErrorHandle,
this,
out csfrm);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
}
status = OciCalls.OCILobRead (Service,
ErrorHandle,
this,
ref amount,
offset,
buffer,
count,
IntPtr.Zero,
IntPtr.Zero,
1000, // OCI_UCS2ID
csfrm);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return (int) amount;
}
public void Trim (uint newlen)
{
int status = 0;
status = OciCalls.OCILobTrim (Service,
ErrorHandle,
this,
newlen);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
}
public int Write (byte[] buffer, uint offset, uint count, OracleType type)
{
int status = 0;
uint amount = count;
if (type == OracleType.Clob)
amount /= 2;
status = OciCalls.OCILobWrite (Service,
ErrorHandle,
this,
ref amount,
offset,
buffer,
count,
0, // OCI_ONE_PIECE
IntPtr.Zero,
IntPtr.Zero,
1000, // OCI_UCS2ID
0);
if (status != 0) {
OciErrorInfo info = ErrorHandle.HandleError ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
return (int) amount;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,25 @@
//
// OciLobType.cs
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Tim Coleman <tim@timcoleman.com>
//
// Copyright (C) Tim Coleman, 2003
//
using System;
namespace System.Data.OracleClient.Oci {
internal enum OciLobType {
Blob = 0x01,
Clob = 0x02
}
}

View File

@@ -0,0 +1,107 @@
//
// OciNlsServiceType.cs - OCI NLS Service Type
//
// Part of managed C#/.NET library System.Data.OracleClient.dll
//
// Part of the Mono class libraries at
// mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
//
// Assembly: System.Data.OracleClient.dll
// Namespace: System.Data.OracleClient.Oci
//
// Author:
// Daniel Morgan <danielmorgan@verizon.net>
//
// Copyright (C) Daniel Morgan, 2005
//
//
using System;
namespace System.Data.OracleClient.Oci {
internal enum OciNlsServiceType : ushort {
// native name
DAYNAME1 = 1, // Monday
DAYNAME2 = 2, // Tuesday
DAYNAME3 = 3, // Wednesday
DAYNAME4 = 4, // Thursday
DAYNAME5 = 5, // Friday
DAYNAME6 = 6, // Saturday
DAYNAME7 = 7, // Sunday
// native abbreviated name
ABDAYNAME1 = 8, // Monday
ABDAYNAME2 = 9, // Tuesday
ABDAYNAME3 = 10, // Wednesday
ABDAYNAME4 = 11, // Thursday
ABDAYNAME5 = 12, // Friday
ABDAYNAME6 = 13, // Saturday
ABDAYNAME7 = 14, // Sunday
// native name
MONTHNAME1 = 15, // January
MONTHNAME2 = 16, // February
MONTHNAME3 = 17, // March
MONTHNAME4 = 18, // April,
MONTHNAME5 = 19, // May
MONTHNAME6 = 20, // June
MONTHNAME7 = 21, // July
MONTHNAME8 = 22, // August
MONTHNAME9 = 23, // September
MONTHNAME10 = 24, // October
MONTHNAME11 = 25, // November
MONTHNAME12 = 26, // December
// native abbreviated name
ABMONTHNAME1 = 27, // January
ABMONTHNAME2 = 28, // February
ABMONTHNAME3 = 29, // March
ABMONTHNAME4 = 30, // April
ABMONTHNAME5 = 31, // May
ABMONTHNAME6 = 32, // June
ABMONTHNAME7 = 33, // July
ABMONTHNAME8 = 34, // August
ABMONTHNAME9 = 35, // September
ABMONTHNAME10 = 36, // October
ABMONTHNAME11 = 37, // November
ABMONTHNAME12 = 38, // December
// native string
YES = 39, // Affirmative response
NO = 40, // Negative response
// native equivalent string
AM = 41, // AM
PM = 42, // PM
AD = 43, // AD
BC = 44, // BC
DECIMAL = 45, // Decimal character
GROUP = 46, // Group separator
DEBIT = 47, // native symbol for Debit
CREDIT = 48, // native symbol for Credit
DATEFORMAT = 49, // Oracle Date Format
INT_CURRENCY = 50, // International Currency symbol
LOC_CURRENCY = 51, // Locale Currency symbol
LANGUAGE = 52, // Language Name
ABLANGUAGE = 53, // abbreviation for Language Name
TERRITORY = 54, // Territory Name
CHARACTER_SET = 55, // Character set Name
LINGUISTIC_NAME = 56, // Linguistic Name
CALENDAR = 57, // Calendar name
DUAL_CURRENCY = 78, // Dual currency symbol
WRITINGDIR = 79, // Language writing direction
ABTERRITORY = 80, // Territory Abbreviation
DDATEFORMAT = 81, // Oracle default date format
DTIMEFORMAT = 82, // Oracle default time format
SFDATEFORMAT = 83, // Local string formatted date format
SFTIMEFORMAT = 84, // Local string formatted time format
NUMGROUPING = 85, // Number grouping fields
LISTSEP = 86, // List separator
MONDECIMAL = 87, // Monetary decimal character
MONGROUP = 88, // Monetary group separator
MONGROUPING = 89, // Monetary grouping fields
INT_CURRENCYSEP = 90, // International currency separator
CHARSET_MAXBYTESZ = 91, // Maximum character byte size
CHARSET_FIXEDWIDTH = 92, // Fixed-width charset byte size
CHARSET_ID = 93, // Character set id
NCHARSET_ID = 94, // NCharacter set id
MAXBUFSZ = 100 // Max buffer size for OCINlsGetInfo
}
}

Some files were not shown because too many files have changed in this diff Show More