Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>2006-10-20 09:21:40 +0400
committerFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>2006-10-20 09:21:40 +0400
commit713b2f43ad2658c13aeef3a0dfa1476a1033cc75 (patch)
tree801f8893d5d9510639545288fd2eb7fd84daa647 /mcs/class/Npgsql
parente2b1fa634dde28d8dc3b43495785ba9e0d3f61f2 (diff)
2006-10-20 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
*Npgsql/NpgsqlCommand.resx, Npgsql/NpgsqlConnection.cs, Npgsql/NpgsqlCommand.cs, Npgsql/NpgsqlState.cs, Npgsql/NpgsqlConnectorPool.cs, Npgsql/NpgsqlCommandBuilder.cs, Npgsql/NpgsqlDataReader.cs, NpgsqlTypes/LargeObjectManager.cs, NpgsqlTypes/NpgsqlDbType.cs, NpgsqlTypes/LargeObject.cs, NpgsqlTypes/NpgsqlTypesHelper.cs, NpgsqlTypes/FastPath.cs: Updated to 1.0 final version. svn path=/trunk/mcs/; revision=66824
Diffstat (limited to 'mcs/class/Npgsql')
-rw-r--r--mcs/class/Npgsql/ChangeLog18
-rw-r--r--mcs/class/Npgsql/Npgsql/NpgsqlCommand.resx5
-rw-r--r--mcs/class/Npgsql/Npgsql/NpgsqlCommandBuilder.cs39
-rw-r--r--mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs11
-rw-r--r--mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs82
-rw-r--r--mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs60
-rw-r--r--mcs/class/Npgsql/Npgsql/NpgsqlState.cs19
-rw-r--r--mcs/class/Npgsql/NpgsqlTypes/FastPath.cs85
-rw-r--r--mcs/class/Npgsql/NpgsqlTypes/LargeObject.cs22
-rw-r--r--mcs/class/Npgsql/NpgsqlTypes/LargeObjectManager.cs14
-rw-r--r--mcs/class/Npgsql/NpgsqlTypes/NpgsqlDbType.cs3
-rw-r--r--mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs3
12 files changed, 246 insertions, 115 deletions
diff --git a/mcs/class/Npgsql/ChangeLog b/mcs/class/Npgsql/ChangeLog
index 3595efb6ce9..99aff68af1c 100644
--- a/mcs/class/Npgsql/ChangeLog
+++ b/mcs/class/Npgsql/ChangeLog
@@ -1,3 +1,21 @@
+
+2006-10-20 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
+
+ *Npgsql/NpgsqlCommand.resx,
+ Npgsql/NpgsqlConnection.cs,
+ Npgsql/NpgsqlCommand.cs,
+ Npgsql/NpgsqlState.cs,
+ Npgsql/NpgsqlConnectorPool.cs,
+ Npgsql/NpgsqlCommandBuilder.cs,
+ Npgsql/NpgsqlDataReader.cs,
+ NpgsqlTypes/LargeObjectManager.cs,
+ NpgsqlTypes/NpgsqlDbType.cs,
+ NpgsqlTypes/LargeObject.cs,
+ NpgsqlTypes/NpgsqlTypesHelper.cs,
+ NpgsqlTypes/FastPath.cs: Updated to 1.0 final version.
+
+
+
2006-09-06 Kornél Pál <kornelpal@gmail.com>
* Test/TestConfiguration.cs: Moved from build/common.
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlCommand.resx b/mcs/class/Npgsql/Npgsql/NpgsqlCommand.resx
index 848913ca6d1..5c90a49dbaa 100644
--- a/mcs/class/Npgsql/Npgsql/NpgsqlCommand.resx
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlCommand.resx
@@ -127,4 +127,7 @@
<data name="Exception_ParamNotInQuery">
<value>Parameter {0} not found in query.</value>
</data>
-</root> \ No newline at end of file
+ <data name="Exception_ConnectionBroken">
+ <value>The Connection is broken.</value>
+ </data>
+</root>
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlCommandBuilder.cs b/mcs/class/Npgsql/Npgsql/NpgsqlCommandBuilder.cs
index 1f28b40a948..4628d91ce0a 100644
--- a/mcs/class/Npgsql/Npgsql/NpgsqlCommandBuilder.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlCommandBuilder.cs
@@ -1,9 +1,9 @@
// NpgsqlCommandBuilder.cs
//
// Author:
-// Pedro Martínez Juliá (yoros@wanadoo.es)
+// Pedro Martínez Juliá (yoros@wanadoo.es)
//
-// Copyright (C) 2003 Pedro Martínez Juliá
+// Copyright (C) 2003 Pedro Martínez Juliá
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -150,14 +150,39 @@ namespace Npgsql
/// <param name="command">NpgsqlCommand whose function parameters will be obtained.</param>
public static void DeriveParameters (NpgsqlCommand command)
{
- String query = "select proargtypes from pg_proc where proname = :procname";
-
+
+ // Updated after 0.99.3 to support the optional existence of a name qualifying schema and case insensitivity when the schema ror procedure name do not contain a quote.
+ // This fixed an incompatibility with NpgsqlCommand.CheckFunctionReturn(String ReturnType)
+ String query = null;
+ string procedureName = null;
+ string schemaName = null;
+ string[] fullName = command.CommandText.Split('.');
+ if (fullName.Length > 1 && fullName[0].Length > 0)
+ {
+ query = "select proargtypes from pg_proc p left join pg_namespace n on p.pronamespace = n.oid where proname=:proname and n.nspname=:nspname";
+ schemaName = (fullName[0].IndexOf("\"") != -1) ? fullName[0] : fullName[0].ToLower();
+ procedureName = (fullName[1].IndexOf("\"") != -1) ? fullName[1] : fullName[1].ToLower();
+ }
+ else
+ {
+ query = "select proargtypes from pg_proc where proname = :proname";
+ procedureName = (fullName[0].IndexOf("\"") != -1) ? fullName[0] : fullName[0].ToLower();
+ }
+
NpgsqlCommand c = new NpgsqlCommand(query, command.Connection);
- c.Parameters.Add(new NpgsqlParameter("procname", NpgsqlDbType.Text));
- c.Parameters[0].Value = command.CommandText;
+ c.Parameters.Add(new NpgsqlParameter("proname", NpgsqlDbType.Text));
+
+
+ c.Parameters[0].Value = procedureName.Replace("\"", "").Trim();
+
+ if (fullName.Length > 1 && schemaName.Length > 0)
+ {
+ NpgsqlParameter prm = c.Parameters.Add(new NpgsqlParameter("nspname", NpgsqlDbType.Text));
+ prm.Value = schemaName.Replace("\"", "").Trim();
+ }
String types = (String) c.ExecuteScalar();
-
+
if (types == null)
throw new InvalidOperationException (String.Format(resman.GetString("Exception_InvalidFunctionName"), command.CommandText));
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs b/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs
index 2bb15a95087..cbc595c351f 100644
--- a/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlConnection.cs
@@ -871,6 +871,17 @@ namespace Npgsql
throw new NotSupportedException();
}
}
+
+ public void ClearPool()
+ {
+ NpgsqlConnectorPool.ConnectorPoolMgr.ClearPool(this);
+ }
+
+ public void ClearAllPools()
+ {
+ NpgsqlConnectorPool.ConnectorPoolMgr.ClearAllPools();
+ }
+
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs b/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs
index 9b79a5ff346..4690c8e654f 100644
--- a/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs
@@ -310,29 +310,19 @@ namespace Npgsql
PooledConnectors[Connection.ConnectionString.ToString()] = Queue;
}
+ // Fix queue use count. Use count may be dropped below zero if Queue was cleared and there were connections open.
+ if (Queue.UseCount < 0)
+ Queue.UseCount = 0;
+
+
if (Queue.Count > 0)
{
// Found a queue with connectors. Grab the top one.
// Check if the connector is still valid.
- while (true)
- {
- Connector = (NpgsqlConnector)Queue.Dequeue();
- if (Connector.IsValid())
- {
- Queue.UseCount++;
- break;
- }
-
- // Don't need - we dequeue connector = decrease Queue.Count.
- //Queue.UseCount--;
-
- if (Queue.Count <= 0)
- return GetPooledConnector(Connection);
-
-
- }
+ Connector = (NpgsqlConnector)Queue.Dequeue();
+ Queue.UseCount++;
@@ -460,9 +450,7 @@ namespace Npgsql
Queue = (ConnectorQueue)PooledConnectors[Connector.ConnectionString.ToString()];
if (Queue == null)
- {
- throw new InvalidOperationException("Internal: No connector queue found for existing connector.");
- }
+ return; // Queue may be emptied by connection problems. See ClearPool below.
Connector.CertificateSelectionCallback -= Connection.CertificateSelectionCallbackDelegate;
Connector.CertificateValidationCallback -= Connection.CertificateValidationCallbackDelegate;
@@ -511,5 +499,59 @@ namespace Npgsql
{
// To be implemented
}
+
+ private void ClearQueue(ConnectorQueue Queue)
+ {
+ if (Queue == null)
+ return;
+
+ while (Queue.Count > 0)
+ {
+ NpgsqlConnector connector = (NpgsqlConnector)Queue.Dequeue();
+
+ try
+ {
+ connector.Close();
+ }
+ catch {
+ // Maybe we should log something here to say we got an exception while closing connector?
+
+ }
+
+ }
+
+ }
+
+
+ internal void ClearPool(NpgsqlConnection Connection)
+ {
+ // Prevent multithread access to connection pool count.
+ lock(this)
+ {
+ // Try to find a queue.
+ ConnectorQueue queue = (ConnectorQueue)PooledConnectors[Connection.ConnectionString.ToString()];
+
+ ClearQueue(queue);
+
+ PooledConnectors[Connection.ConnectionString.ToString()] = null;
+
+ }
+
+
+ }
+
+ internal void ClearAllPools()
+ {
+
+ lock (this)
+ {
+ foreach (ConnectorQueue Queue in PooledConnectors.Values)
+ ClearQueue(Queue);
+
+ }
+
+
+ }
+
}
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs b/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs
index c9a3e9e39d0..6244c36e493 100644
--- a/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlDataReader.cs
@@ -42,6 +42,7 @@ namespace Npgsql
private ArrayList _responses;
private Int32 _rowIndex;
private Int32 _resultsetIndex;
+ private Int32 _recordsAffected;
private NpgsqlResultSet _currentResultset;
private DataTable _currentResultsetSchema;
private CommandBehavior _behavior;
@@ -58,10 +59,12 @@ namespace Npgsql
_responses = responses;
_connection = command.Connection;
_rowIndex = -1;
- _resultsetIndex = 0;
+ _resultsetIndex = -1;
+ _recordsAffected = -1;
- if (_resultsets.Count > 0)
- _currentResultset = (NpgsqlResultSet)_resultsets[_resultsetIndex];
+ // positioned before the first results.
+ // move to the first results
+ NextResult();
_behavior = behavior;
_isClosed = false;
@@ -153,22 +156,7 @@ namespace Npgsql
get
{
NpgsqlEventLog.LogPropertyGet(LogLevel.Debug, CLASSNAME, "RecordsAffected");
-
- if (HaveResultSet())
- {
- return -1;
- }
-
- String[] _returnStringTokens = ((String)_responses[_resultsetIndex]).Split(null); // whitespace separator.
-
- try
- {
- return Int32.Parse(_returnStringTokens[_returnStringTokens.Length - 1]);
- }
- catch (FormatException)
- {
- return -1;
- }
+ return _recordsAffected;
}
}
@@ -213,15 +201,41 @@ namespace Npgsql
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "NextResult");
- if((_resultsetIndex + 1) < _resultsets.Count)
+ _currentResultset = null;
+ while((_resultsetIndex + 1) < _resultsets.Count && !HaveResultSet())
{
_resultsetIndex++;
_rowIndex = -1;
_currentResultset = (NpgsqlResultSet)_resultsets[_resultsetIndex];
- return true;
+
+ if (!HaveResultSet())
+ {
+ String[] _returnStringTokens = ((String)_responses[_resultsetIndex]).Split(null); // whitespace separator.
+ int responseAffectedRows = 0;
+
+ try
+ {
+ responseAffectedRows = Int32.Parse(_returnStringTokens[_returnStringTokens.Length - 1]);
+ }
+ catch (FormatException)
+ {
+ responseAffectedRows = -1;
+ }
+
+ if (responseAffectedRows != -1)
+ {
+ if (_recordsAffected == -1)
+ {
+ _recordsAffected = responseAffectedRows;
+ }
+ else
+ {
+ _recordsAffected += responseAffectedRows;
+ }
+ }
+ }
}
- else
- return false;
+ return HaveResultSet();
}
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlState.cs b/mcs/class/Npgsql/Npgsql/NpgsqlState.cs
index 77e8d23e851..e8dcad05163 100644
--- a/mcs/class/Npgsql/Npgsql/NpgsqlState.cs
+++ b/mcs/class/Npgsql/Npgsql/NpgsqlState.cs
@@ -146,7 +146,16 @@ namespace Npgsql
// Process commandTimeout behavior.
if ((context.Mediator.CommandTimeout > 0) && (!context.Socket.Poll(1000000 * context.Mediator.CommandTimeout, SelectMode.SelectRead)))
- context.CancelRequest();
+ {
+ // If timeout occurs when establishing the session with server then
+ // throw an exception instead of trying to cancel query. This helps to prevent loop as CancelRequest will also try to stablish a connection and sends commands.
+ if ((this is NpgsqlStartupState || this is NpgsqlConnectedState))
+ throw new NpgsqlException(resman.GetString("Exception_ConnectionTimeout"));
+ else
+ context.CancelRequest();
+
+ }
+
switch (context.BackendProtocolVersion)
@@ -428,6 +437,10 @@ namespace Npgsql
// Wait for ReadForQuery message
break;
+ case -1:
+ // Connection broken. Mono returns -1 instead of throw an exception as ms.net does.
+ throw new IOException();
+
default :
// This could mean a number of things
// We've gotten out of sync with the backend?
@@ -747,6 +760,10 @@ namespace Npgsql
break;
+ case -1:
+ // Connection broken. Mono returns -1 instead of throw an exception as ms.net does.
+ throw new IOException();
+
default :
// This could mean a number of things
// We've gotten out of sync with the backend?
diff --git a/mcs/class/Npgsql/NpgsqlTypes/FastPath.cs b/mcs/class/Npgsql/NpgsqlTypes/FastPath.cs
index e6aa2d62b2d..ab88f518cde 100644
--- a/mcs/class/Npgsql/NpgsqlTypes/FastPath.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/FastPath.cs
@@ -85,17 +85,25 @@ namespace NpgsqlTypes
* @param resulttype True if the result is an integer, false for other results
* @param args FastpathArguments to pass to fastpath
* @return null if no data, Integer if an integer result, or byte[] otherwise
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public Object FastpathCall(Int32 fnid, Boolean resulttype, FastpathArg[] args)
{
- if (conn.BackendProtocolVersion == ProtocolVersion.Version3)
+ try
{
- return FastpathV3(fnid, resulttype, args);
+ if (conn.BackendProtocolVersion == ProtocolVersion.Version3)
+ {
+ return FastpathV3(fnid, resulttype, args);
+ }
+ else
+ {
+ return FastpathV2(fnid, resulttype, args);
+ }
}
- else
+ catch(IOException e)
{
- return FastpathV2(fnid, resulttype, args);
+ conn.ClearPool();
+ throw new NpgsqlException("The Connection is broken.");
}
}
@@ -105,34 +113,30 @@ namespace NpgsqlTypes
lock (stream)
{
// send the function call
- try
+
{
Int32 l_msgLen = 0;
l_msgLen += 16;
for (Int32 i=0;i < args.Length;i++)
l_msgLen += args[i].SendSize();
-
+
stream.WriteByte((Byte)'F');
PGUtil.WriteInt32(stream,l_msgLen);
PGUtil.WriteInt32(stream,fnid);
PGUtil.WriteInt16(stream,1);
PGUtil.WriteInt16(stream,1);
PGUtil.WriteInt16(stream,(short)args.Length);
-
+
for (Int32 i = 0;i < args.Length;i++)
args[i].Send(stream);
-
+
PGUtil.WriteInt16(stream,1);
-
+
// This is needed, otherwise data can be lost
stream.Flush();
-
- }
- catch (Exception ex)
- {
- throw new Exception(ex.ToString());
}
+
// Now handle the result
// Now loop, reading the results
@@ -162,7 +166,7 @@ namespace NpgsqlTypes
case 'E':
NpgsqlError e = new NpgsqlError(conn.BackendProtocolVersion);
e.ReadFromStream(stream,conn.Connector.Encoding);
- throw new Exception(e.ToString());
+ throw new NpgsqlException(e.ToString());
//------------------------------
// Notice from backend
@@ -216,14 +220,14 @@ namespace NpgsqlTypes
case 'Z':
//TODO: use size better
if (PGUtil.ReadInt32(stream,input_buffer) != 5)
- throw new Exception("Received Z" );
+ throw new NpgsqlException("Received Z" );
//TODO: handle transaction status
Char l_tStatus = (Char)stream.ReadByte();
l_endQuery = true;
break;
default:
- throw new Exception("postgresql.fp.protocol received " + c.ToString());
+ throw new NpgsqlException("postgresql.fp.protocol received " + c.ToString());
}
}
@@ -240,29 +244,22 @@ namespace NpgsqlTypes
lock (stream)
{
// send the function call
- try
- {
- // 70 is 'F' in ASCII. Note: don't use SendChar() here as it adds padding
- // that confuses the backend. The 0 terminates the command line.
- stream.WriteByte((Byte)70);
- stream.WriteByte((Byte)0);
+
+ // 70 is 'F' in ASCII. Note: don't use SendChar() here as it adds padding
+ // that confuses the backend. The 0 terminates the command line.
+ stream.WriteByte((Byte)70);
+ stream.WriteByte((Byte)0);
- PGUtil.WriteInt32(stream,fnid);
- PGUtil.WriteInt32(stream,args.Length);
+ PGUtil.WriteInt32(stream,fnid);
+ PGUtil.WriteInt32(stream,args.Length);
- for (Int32 i = 0;i < args.Length;i++)
- args[i].Send(stream);
+ for (Int32 i = 0;i < args.Length;i++)
+ args[i].Send(stream);
- // This is needed, otherwise data can be lost
- stream.Flush();
+ // This is needed, otherwise data can be lost
+ stream.Flush();
- }
- catch (IOException ioe)
- {
- //Should be sending exception as second arg.
- throw new Exception("postgresql.fp.send: " + ioe.ToString());
- }
// Now handle the result
@@ -343,12 +340,12 @@ namespace NpgsqlTypes
break;
default:
- throw new Exception("postgresql.fp.protocol " + c.ToString());
+ throw new NpgsqlException("postgresql.fp.protocol " + c.ToString());
}
}
if ( errorMessage != null )
- throw new Exception("postgresql.fp.error" + errorMessage);
+ throw new NpgsqlException("postgresql.fp.error" + errorMessage);
return result;
}
@@ -370,7 +367,7 @@ namespace NpgsqlTypes
* results
* @param args FastpathArguments to pass to fastpath
* @return null if no data, Integer if an integer result, or byte[] otherwise
- * @exception SQLException if name is unknown or if a database-access error
+ * @exception NpgsqlException if name is unknown or if a database-access error
* occurs.
* @see org.postgresql.largeobject.LargeObject
*/
@@ -384,7 +381,7 @@ namespace NpgsqlTypes
* @param name Function name
* @param args Function arguments
* @return integer result
- * @exception SQLException if a database-access error occurs or no result
+ * @exception NpgsqlException if a database-access error occurs or no result
*/
public Int32 GetInteger(String name, FastpathArg[] args)
{
@@ -398,7 +395,7 @@ namespace NpgsqlTypes
* @param name Function name
* @param args Function arguments
* @return byte[] array containing result
- * @exception SQLException if a database-access error occurs or no result
+ * @exception NpgsqlException if a database-access error occurs or no result
*/
public Byte[] GetData(String name, FastpathArg[] args)
{
@@ -450,7 +447,7 @@ namespace NpgsqlTypes
* unwarranted headaches in the future.
*
* @param rs ResultSet
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
* @see org.postgresql.largeobject.LargeObjectManager
*/
public void AddFunctions(IDataReader rs)
@@ -467,11 +464,11 @@ namespace NpgsqlTypes
* This returns the function id associated by its name
*
* <p>If addFunction() or addFunctions() have not been called for this name,
- * then an SQLException is thrown.
+ * then an NpgsqlException is thrown.
*
* @param name Function name to lookup
* @return Function ID for fastpath call
- * @exception SQLException is function is unknown.
+ * @exception NpgsqlException is function is unknown.
*/
public Int32 GetID(String name)
{
diff --git a/mcs/class/Npgsql/NpgsqlTypes/LargeObject.cs b/mcs/class/Npgsql/NpgsqlTypes/LargeObject.cs
index b1090714f60..bf242a2bd7a 100644
--- a/mcs/class/Npgsql/NpgsqlTypes/LargeObject.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/LargeObject.cs
@@ -60,13 +60,13 @@ namespace NpgsqlTypes
/*
* This opens a large object.
*
- * <p>If the object does not exist, then an SQLException is thrown.
+ * <p>If the object does not exist, then an NpgsqlException is thrown.
*
* @param fp FastPath API for the connection to use
* @param oid of the Large Object to open
* @param mode Mode of opening the large object
* (defined in LargeObjectManager)
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
* @see org.postgresql.largeobject.LargeObjectManager
*/
public LargeObject(Fastpath fp, Int32 oid, Int32 mode)
@@ -92,7 +92,7 @@ namespace NpgsqlTypes
/*
* This method closes the object. You must not call methods in this
* object after this is called.
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public void Close()
{
@@ -112,7 +112,7 @@ namespace NpgsqlTypes
*
* @param len number of bytes to read
* @return byte[] array containing data read
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public Byte[] Read(Int32 len)
{
@@ -155,7 +155,7 @@ namespace NpgsqlTypes
* @param off offset within array
* @param len number of bytes to read
* @return the number of bytes actually read
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public Int32 Read(Byte[] buf, Int32 off, Int32 len)
{
@@ -170,7 +170,7 @@ namespace NpgsqlTypes
* Writes an array to the object
*
* @param buf array to write
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public void Write(Byte[] buf)
{
@@ -186,7 +186,7 @@ namespace NpgsqlTypes
* @param buf destination array
* @param off offset within array
* @param len number of bytes to write
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public void Write(Byte[] buf, Int32 off, Int32 len)
{
@@ -204,7 +204,7 @@ namespace NpgsqlTypes
*
* @param pos position within object
* @param ref Either SEEK_SET, SEEK_CUR or SEEK_END
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public void Seek(Int32 pos, Int32 refi)
{
@@ -222,7 +222,7 @@ namespace NpgsqlTypes
* allows you to have random access to the large object.
*
* @param pos position within object from begining
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public void Seek(Int32 pos)
{
@@ -231,7 +231,7 @@ namespace NpgsqlTypes
/*
* @return the current position within the object
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public Int32 Tell()
{
@@ -248,7 +248,7 @@ namespace NpgsqlTypes
* <p>A better method will be found in the future.
*
* @return the size of the large object
- * @exception SQLException if a database-access error occurs.
+ * @exception NpgsqlException if a database-access error occurs.
*/
public Int32 Size()
{
diff --git a/mcs/class/Npgsql/NpgsqlTypes/LargeObjectManager.cs b/mcs/class/Npgsql/NpgsqlTypes/LargeObjectManager.cs
index 10e25323c76..26d082fce77 100644
--- a/mcs/class/Npgsql/NpgsqlTypes/LargeObjectManager.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/LargeObjectManager.cs
@@ -116,7 +116,7 @@ namespace NpgsqlTypes
if (res == null)
- throw new Exception("postgresql.lo.init");
+ throw new NpgsqlException("postgresql.lo.init");
fp.AddFunctions(res);
@@ -128,7 +128,7 @@ namespace NpgsqlTypes
*
* @param oid of large object
* @return LargeObject instance providing access to the object
- * @exception SQLException on error
+ * @exception NpgsqlException on error
*/
public LargeObject Open(Int32 oid)
{
@@ -141,7 +141,7 @@ namespace NpgsqlTypes
* @param oid of large object
* @param mode mode of open
* @return LargeObject instance providing access to the object
- * @exception SQLException on error
+ * @exception NpgsqlException on error
*/
public LargeObject Open(Int32 oid, Int32 mode)
{
@@ -154,7 +154,7 @@ namespace NpgsqlTypes
* <p>It defaults to READWRITE for the new object's attributes.
*
* @return oid of new object
- * @exception SQLException on error
+ * @exception NpgsqlException on error
*/
public Int32 Create()
{
@@ -168,7 +168,7 @@ namespace NpgsqlTypes
*
* @param mode a bitmask describing different attributes of the new object
* @return oid of new object
- * @exception SQLException on error
+ * @exception NpgsqlException on error
*/
public Int32 Create(Int32 mode)
{
@@ -181,7 +181,7 @@ namespace NpgsqlTypes
* This deletes a large object.
*
* @param oid describing object to delete
- * @exception SQLException on error
+ * @exception NpgsqlException on error
*/
public void Delete(Int32 oid)
{
@@ -197,7 +197,7 @@ namespace NpgsqlTypes
* unlink.
*
* @param oid describing object to delete
- * @exception SQLException on error
+ * @exception NpgsqlException on error
*/
public void Unlink(Int32 oid)
{
diff --git a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlDbType.cs b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlDbType.cs
index 4690ab8d67f..d3f8c87d19b 100644
--- a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlDbType.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlDbType.cs
@@ -56,7 +56,8 @@ namespace NpgsqlTypes
Varchar,
Refcursor,
Inet,
- Bit
+ Bit,
+ TimestampTZ
}
diff --git a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
index da9479a5e39..847c05b7380 100644
--- a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
@@ -242,6 +242,9 @@ namespace NpgsqlTypes
NativeTypeMapping.AddTypeAlias("timestamp", typeof(DateTime));
+ NativeTypeMapping.AddType("timestamptz", NpgsqlDbType.TimestampTZ, DbType.DateTime, true,
+ new ConvertNativeToBackendHandler(BasicNativeToBackendTypeConverter.ToDateTime));
+
NativeTypeMapping.AddType("point", NpgsqlDbType.Point, DbType.Object, true,
new ConvertNativeToBackendHandler(ExtendedNativeToBackendTypeConverter.ToPoint));