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,44 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
//
using System;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the System.Data.OracleClient assembly
[assembly: AssemblyTitle ("System.Data.OracleClient.dll")]
[assembly: AssemblyDescription ("System.Data.OracleClient.dll")]
[assembly: AssemblyDefaultAlias ("System.Data.OracleClient.dll")]
[assembly: AssemblyCompany (Consts.MonoCompany)]
[assembly: AssemblyProduct (Consts.MonoProduct)]
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: SatelliteContractVersion (Consts.FxVersion)]
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: ComVisible (false)]
#if !TARGET_JVM
[assembly: CLSCompliant (true)]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../ecma.pub")]
#endif
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
[assembly: Dependency ("System.Data,", LoadHint.Always)]

View File

@ -0,0 +1,17 @@
2008-04-23 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* AssemblyInfo.cs: Use consts where possible, fix attribute
2004-06-19 Gert Driesen <drieseng@users.sourceforge.net>
* Consts.cs: Added
2004-05-15 Gert Driesen <drieseng@users.sourceforge.net>
* AssemblyInfo.cs: System.Data.OracleClient is CLS compliant
2004-04-06 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* AssemblyInfo.cs: Added
* ChangeLog: Added
* Locale.cs: Added

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,205 @@
//
// Mainsoft.Data.Jdbc.Providers.OracleProvider
//
// Authors:
// Konstantin Triger <kostat@mainsoft.com>
// Boris Kirzner <borisk@mainsoft.com>
//
// (C) 2006 Mainsoft Corporation (http://www.mainsoft.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using Mainsoft.Data.Configuration;
using System.Reflection;
namespace Mainsoft.Data.Jdbc.Providers
{
public class OracleProvider : GenericProvider
{
#region Consts
private const string Port = "Port";
#endregion //Consts
#region Fields
#endregion // Fields
#region Constructors
public OracleProvider (IDictionary providerInfo) : base (providerInfo)
{
}
#endregion // Constructors
#region Properties
#endregion // Properties
#region Methods
public override IConnectionStringDictionary GetConnectionStringBuilder (string connectionString)
{
IConnectionStringDictionary conectionStringBuilder = base.GetConnectionStringBuilder (connectionString);
string port = (string) conectionStringBuilder [Port];
if (port == null || port.Length == 0) {
port = (string) ProviderInfo [Port];
conectionStringBuilder.Add (Port, port);
}
return conectionStringBuilder;
}
public override java.sql.Connection GetConnection(IConnectionStringDictionary conectionStringBuilder) {
return new OracleConnection(base.GetConnection (conectionStringBuilder));
}
#endregion //Methods
#region OracleConnection
sealed class OracleConnection : Connection {
public OracleConnection(java.sql.Connection connection)
: base(connection) {}
public override java.sql.CallableStatement prepareCall(string arg_0) {
return base.prepareCall (arg_0);
}
public override java.sql.CallableStatement prepareCall(string arg_0, int arg_1, int arg_2) {
return new OracleCallableStatement(base.prepareCall (arg_0, arg_1, arg_2));
}
public override java.sql.CallableStatement prepareCall(string arg_0, int arg_1, int arg_2, int arg_3) {
return new OracleCallableStatement(base.prepareCall (arg_0, arg_1, arg_2, arg_3));
}
public override java.sql.PreparedStatement prepareStatement(string arg_0) {
return new OraclePreparedStatement(base.prepareStatement (arg_0));
}
public override java.sql.PreparedStatement prepareStatement(string arg_0, int arg_1) {
return new OraclePreparedStatement(base.prepareStatement (arg_0, arg_1));
}
public override java.sql.PreparedStatement prepareStatement(string arg_0, int arg_1, int arg_2) {
return new OraclePreparedStatement(base.prepareStatement (arg_0, arg_1, arg_2));
}
public override java.sql.PreparedStatement prepareStatement(string arg_0, int arg_1, int arg_2, int arg_3) {
return new OraclePreparedStatement(base.prepareStatement (arg_0, arg_1, arg_2, arg_3));
}
public override java.sql.PreparedStatement prepareStatement(string arg_0, int[] arg_1) {
return new OraclePreparedStatement(base.prepareStatement (arg_0, arg_1));
}
public override java.sql.PreparedStatement prepareStatement(string arg_0, string[] arg_1) {
return new OraclePreparedStatement(base.prepareStatement (arg_0, arg_1));
}
}
#endregion
sealed class OraclePreparedStatement : PreparedStatement, IPreparedStatement {
readonly MethodInfo _info;
public OraclePreparedStatement(java.sql.PreparedStatement statement)
: base(statement) {
_info = Wrapped.GetType().GetMethod("setFixedCHAR");
}
#region IPreparedStatement Members
public void setBit(int parameterIndex, int value) {
base.setInt(parameterIndex, value);
}
public void setChar(int parameterIndex, string value) {
if (_info == null) {
base.setString(parameterIndex, value);
return;
}
_info.Invoke(Wrapped, new object[] {
new java.lang.Integer(parameterIndex),
value});
}
public void setNumeric(int parameterIndex, java.math.BigDecimal value) {
base.setBigDecimal(parameterIndex, value);
}
public void setReal(int parameterIndex, double value) {
base.setDouble(parameterIndex, value);
}
#endregion
}
sealed class OracleCallableStatement : CallableStatement, IPreparedStatement {
readonly MethodInfo _info;
public OracleCallableStatement(java.sql.CallableStatement statement)
: base(statement) {
_info = Wrapped.GetType().GetMethod("setFixedCHAR");
}
#region IPreparedStatement Members
public void setBit(int parameterIndex, int value) {
base.setInt(parameterIndex, value);
}
public void setChar(int parameterIndex, string value) {
if (_info == null) {
base.setString(parameterIndex, value);
return;
}
_info.Invoke(Wrapped, new object[] {
new java.lang.Integer(parameterIndex),
value});
}
public void setNumeric(int parameterIndex, java.math.BigDecimal value) {
base.setBigDecimal(parameterIndex, value);
}
public void setReal(int parameterIndex, double value) {
base.setDouble(parameterIndex, value);
}
#endregion
}
}
}

View File

@ -0,0 +1,28 @@
thisdir = class/System.Data.OracleClient
SUBDIRS =
include ../../build/rules.make
LIBRARY = System.Data.OracleClient.dll
ifeq (net_1_1_java, $(PROFILE))
LIB_MCS_FLAGS = \
-r:rt.dll \
-r:J2SE.Helpers.dll \
/r:System.dll \
/r:System.Xml.dll /r:../../class/lib/net_1_1_java/System.Data.dll \
-nowarn:649 -nowarn:169 -nowarn:219 -nowarn:168 -nowarn:1595 \
-r:$(corlib) \
-r:System.Xml.dll \
/r:System.Drawing.dll
else
LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll \
/r:System.Xml.dll /r:System.Data.dll \
/r:System.EnterpriseServices.dll \
/r:System.Drawing.dll
endif
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) /nowarn:618
EXTRA_DISTFILES = Test/*.cs
include ../../build/library.make

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
}
}

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