pgsqlclient-checkins Mailing List for PostgreSqlClient (Page 10)
Status: Inactive
Brought to you by:
carlosga_fb
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(120) |
Aug
(95) |
Sep
(95) |
Oct
(213) |
Nov
(114) |
Dec
(64) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(6) |
Feb
(134) |
Mar
(88) |
Apr
(28) |
May
(22) |
Jun
(15) |
Jul
(23) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(6) |
Dec
|
2005 |
Jan
(8) |
Feb
(6) |
Mar
|
Apr
(42) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(84) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
(84) |
Apr
(46) |
May
(40) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7345/Data/Protocol Added Files: InfoMessageCallback.cs NotificationCallback.cs PgAuthMethods.cs PgBackendCodes.cs PgCharSet.cs PgCharSetCollection.cs PgClientError.cs PgClientErrorCollection.cs PgClientException.cs PgClientMessageEventArgs.cs PgClientMessageEventHandler.cs PgClientNotificationEventArgs.cs PgClientNotificationEventHandler.cs PgCodes.cs PgConnectionParams.cs PgDataType.cs PgDbClient.cs PgErrorCodes.cs PgFieldDescriptor.cs PgFrontEndCodes.cs PgOutputPacket.cs PgParameter.cs PgResponsePacket.cs PgRowDescriptor.cs PgStatement.cs PgStatementStatus.cs PgType.cs PgTypeCollection.cs PgTypeFormat.cs PgTypeStringFormats.cs SslConnectionCallback.cs Log Message: Started the reorganization of the CVS module --- NEW FILE: PgTypeFormat.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: PgStatement.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Text; using System.Data; using System.Collections; namespace PostgreSql.Data.Protocol { internal class PgStatement { #region · Fields · private PgDbClient db; private string stmtText; private bool hasRows; private string tag; private string parseName; private string portalName; private int fetchSize; private bool allRowsFetched; private PgRowDescriptor rowDescriptor; private object[] rows; private int rowIndex; private PgParameter[] parameters; private PgParameter outParameter; private int recordsAffected; private char transactionStatus; private PgStatementStatus status; #endregion #region · Properties · public PgDbClient DbHandle { get { return this.db; } set { this.db = value; } } public string StmtText { get { return this.stmtText; } set { this.stmtText = value; } } public bool HasRows { get { return this.hasRows; } } public string Tag { get { return this.tag; } } public string ParseName { get { return this.parseName; } set { this.parseName = value; } } public string PortalName { get { return this.portalName; } set { this.portalName = value; } } public PgRowDescriptor RowDescriptor { get { return this.rowDescriptor; } } public object[] Rows { get { return this.rows; } } public PgParameter[] Parameters { get { return this.parameters; } } public PgParameter OutParameter { get { return this.outParameter; } set { this.outParameter = value; } } public int RecordsAffected { get { return this.recordsAffected; } } public PgStatementStatus Status { get { return this.status; } } public char TransactionStatus { get { return this.transactionStatus; } } #endregion #region · Constructors · public PgStatement() : this(null) { } public PgStatement(PgDbClient db) : this(db, null, null) { } public PgStatement(PgDbClient db, string parseName, string portalName) : this(db, parseName, portalName, null) { } public PgStatement(PgDbClient db, string stmtText) : this(db, null, null, stmtText) { } public PgStatement(string parseName, string portalName) : this(null, parseName, portalName, null) { } public PgStatement(PgDbClient db, string parseName, string portalName, string stmtText) { this.db = db; this.outParameter = new PgParameter(); this.rows = null; this.rowIndex = 0; this.parseName = parseName; this.portalName = portalName; this.recordsAffected = -1; this.status = PgStatementStatus.Initial; this.fetchSize = 200; this.stmtText = stmtText; GC.SuppressFinalize(this); } #endregion #region · Methods · public void Parse() { lock (this.db) { try { // Clear actual row list this.rows = null; this.rowIndex = 0; // Initialize RowDescriptor and Parameters this.rowDescriptor = new PgRowDescriptor(0); this.parameters = new PgParameter[0]; PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); packet.WriteNullString(this.ParseName); packet.WriteNullString(this.stmtText); packet.WriteShort(0); // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.PARSE); // Update status this.status = PgStatementStatus.Parsed; } catch (PgClientException) { // Update status this.status = PgStatementStatus.Error; // Throw exception throw; } } } public void Describe() { this.Describe('S'); } public void DescribePortal() { this.Describe('P'); } private void Describe(char stmtType) { lock (this.db) { try { string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); packet.Write((byte)stmtType); packet.WriteNullString(name); // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.DESCRIBE); // Flush pending messages this.db.Flush(); // Receive Describe response PgResponsePacket response = new PgResponsePacket(); while ((response.Message != PgBackendCodes.ROW_DESCRIPTION && response.Message != PgBackendCodes.NODATA)) { response = this.db.ReceiveResponsePacket(); this.ProcessSqlPacket(response); } // Update status this.status = PgStatementStatus.Described; } catch (Exception) { // Update status this.status = PgStatementStatus.Error; // Throw exception throw; } } } public void Bind() { lock (this.db) { try { PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); // Destination portal name packet.WriteNullString(this.PortalName); // Prepared statement name packet.WriteNullString(this.ParseName); // Send parameters format code. packet.WriteShort((short)parameters.Length); for (int i = 0; i < parameters.Length; i++) { packet.WriteShort((short)this.parameters[i].DataType.FormatCode); } // Send parameter values packet.WriteShort((short)parameters.Length); for (int i = 0; i < parameters.Length; i++) { packet.WriteParameter(this.parameters[i]); } // Send column information packet.WriteShort((short)this.rowDescriptor.Fields.Length); for (int i = 0; i < this.rowDescriptor.Fields.Length; i++) { packet.WriteShort((short)this.rowDescriptor.Fields[i].DataType.FormatCode); } // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.BIND); // Update status this.status = PgStatementStatus.Parsed; } catch (Exception) { // Update status this.status = PgStatementStatus.Error; // Throw exception throw; } } } public void Execute() { lock (this.db) { try { PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); packet.WriteNullString(this.PortalName); packet.WriteInt(this.fetchSize); // Rows to retrieve ( 0 = nolimit ) // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.EXECUTE); // Flush pending messages this.db.Flush(); // Receive response PgResponsePacket response = new PgResponsePacket(); while (response.Message != PgBackendCodes.READY_FOR_QUERY && response.Message != PgBackendCodes.PORTAL_SUSPENDED && response.Message != PgBackendCodes.COMMAND_COMPLETE) { response = this.db.ReceiveResponsePacket(); this.ProcessSqlPacket(response); } // reset rowIndex this.rowIndex = 0; // If the command is finished and has returned rows // set all rows are received if ((response.Message == PgBackendCodes.READY_FOR_QUERY || response.Message == PgBackendCodes.COMMAND_COMPLETE) && this.hasRows) { this.allRowsFetched = true; } // If all rows are received or the command doesn't return // rows perform a Sync. if (!this.hasRows || this.allRowsFetched) { this.db.Sync(); } // Update status this.status = PgStatementStatus.Executed; } catch (Exception) { // Update status this.status = PgStatementStatus.Error; // Throw exception throw; } } } public void ExecuteFunction(int id) { lock (this.db) { try { PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); // Function id packet.WriteInt(id); // Send parameters format code. packet.WriteShort((short)this.parameters.Length); for (int i = 0; i < this.parameters.Length; i++) { packet.WriteShort((short)this.parameters[i].DataType.FormatCode); } // Send parameter values packet.WriteShort((short)this.parameters.Length); for (int i = 0; i < this.parameters.Length; i++) { packet.WriteParameter(this.parameters[i]); } // Send the format code for the function result packet.WriteShort(PgCodes.BINARY_FORMAT); // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.FUNCTION_CALL); // Receive response PgResponsePacket response = new PgResponsePacket(); while (response.Message != PgBackendCodes.READY_FOR_QUERY) { response = this.db.ReceiveResponsePacket(); this.ProcessSqlPacket(response); } // Update status this.status = PgStatementStatus.Executed; } catch (Exception) { // Update status this.status = PgStatementStatus.Error; // Throw exception throw; } } } public void Query() { ArrayList innerRows = new ArrayList(); lock (this.db) { try { PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); packet.WriteNullString(this.stmtText); // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.QUERY); // Update Status this.status = PgStatementStatus.OnQuery; // Set fetch size this.fetchSize = 1; // Receive response PgResponsePacket response = new PgResponsePacket(); while (response.Message != PgBackendCodes.READY_FOR_QUERY) { response = this.db.ReceiveResponsePacket(); this.ProcessSqlPacket(response); if (this.hasRows && response.Message == PgBackendCodes.DATAROW) { innerRows.Add(this.rows[0]); this.rowIndex = 0; } } if (this.hasRows) { // Obtain all the rows this.rows = (object[])innerRows.ToArray(typeof(object)); // reset rowIndex this.rowIndex = 0; // Set allRowsFetched flag this.allRowsFetched = true; } // reset fetch size this.fetchSize = 200; // Update status this.status = PgStatementStatus.Executed; } catch (Exception) { // Update status this.status = PgStatementStatus.Error; // Throw exception throw; } } } public object[] FetchRow() { object[] row = null; if ((!this.allRowsFetched && this.rows == null) || (!this.allRowsFetched && this.rows.Length == 0) || (!this.allRowsFetched && this.rowIndex >= this.fetchSize)) { lock (this) { // Retrieve next group of rows this.Execute(); } } if (this.rows != null && this.rows.Length > 0 && this.rows[this.rowIndex] != null) { // Return always first row row = (object[])this.rows[this.rowIndex++]; } if (this.rows != null && (this.rowIndex >= this.fetchSize || this.rowIndex >= this.rows.Length || this.rows[this.rowIndex] == null)) { this.rows = null; } return row; } public void Close() { this.Close('S'); } public void ClosePortal() { this.Close('P'); } private void Close(char stmtType) { lock (this.db) { try { string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); packet.Write((byte)stmtType); packet.WriteNullString(name); // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.CLOSE); // Sync server and client this.db.Flush(); // Read until CLOSE COMPLETE message is received PgResponsePacket response = new PgResponsePacket(); while (response.Message != PgBackendCodes.CLOSE_COMPLETE) { response = this.db.ReceiveResponsePacket(); this.ProcessSqlPacket(response); } // Clear rows this.rows = null; this.rowIndex = 0; // Update Status this.status = PgStatementStatus.Initial; } catch (Exception) { // Update Status this.status = PgStatementStatus.Error; // Throw exception throw; } } } #endregion #region · Misc Methods · public string GetPlan(bool verbose) { lock (db) { try { PgStatement getPlan = new PgStatement(); getPlan.DbHandle = this.db; getPlan.StmtText = "EXPLAIN ANALYZE "; if (verbose) { getPlan.StmtText += "VERBOSE "; } getPlan.StmtText += stmtText; getPlan.Query(); StringBuilder stmtPlan = new StringBuilder(); foreach (object[] row in getPlan.Rows) { stmtPlan.AppendFormat("{0} \r\n", row[0]); } getPlan.Close(); return stmtPlan.ToString(); } catch (PgClientException) { throw; } } } #endregion #region · Response Methods · private void ProcessSqlPacket(PgResponsePacket packet) { switch (packet.Message) { case PgBackendCodes.READY_FOR_QUERY: this.transactionStatus = packet.ReadChar(); break; case PgBackendCodes.FUNCTION_CALL_RESPONSE: this.ProcessFunctionResult(packet); break; case PgBackendCodes.ROW_DESCRIPTION: this.ProcessRowDescription(packet); break; case PgBackendCodes.DATAROW: this.hasRows = true; this.ProcessDataRow(packet); break; case PgBackendCodes.EMPTY_QUERY_RESPONSE: case PgBackendCodes.NODATA: this.hasRows = false; this.rows = null; this.rowIndex = 0; break; case PgBackendCodes.COMMAND_COMPLETE: this.ProcessTag(packet); break; case PgBackendCodes.PARAMETER_DESCRIPTION: this.ProcessParameterDescription(packet); break; case PgBackendCodes.BIND_COMPLETE: case PgBackendCodes.PARSE_COMPLETE: case PgBackendCodes.CLOSE_COMPLETE: break; } } private void ProcessTag(PgResponsePacket packet) { string[] elements = null; tag = packet.ReadNullString(); elements = tag.Split(' '); switch (elements[0]) { case "FETCH": case "SELECT": this.recordsAffected = -1; break; case "INSERT": this.recordsAffected = Int32.Parse(elements[2]); break; case "UPDATE": case "DELETE": case "MOVE": this.recordsAffected = Int32.Parse(elements[1]); break; } } private void ProcessFunctionResult(PgResponsePacket packet) { int length = packet.ReadInt(); outParameter.Value = packet.ReadValue(outParameter.DataType, length); } private void ProcessRowDescription(PgResponsePacket packet) { this.rowDescriptor = new PgRowDescriptor(packet.ReadShort()); for (int i = 0; i < rowDescriptor.Fields.Length; i++) { this.rowDescriptor.Fields[i] = new PgFieldDescriptor(); this.rowDescriptor.Fields[i].FieldName = packet.ReadNullString(); this.rowDescriptor.Fields[i].OidTable = packet.ReadInt(); this.rowDescriptor.Fields[i].OidNumber = packet.ReadShort(); this.rowDescriptor.Fields[i].DataType = PgDbClient.Types[packet.ReadInt()]; this.rowDescriptor.Fields[i].DataTypeSize = packet.ReadShort(); this.rowDescriptor.Fields[i].TypeModifier = packet.ReadInt(); this.rowDescriptor.Fields[i].FormatCode = (PgTypeFormat)packet.ReadShort(); } } private void ProcessParameterDescription(PgResponsePacket packet) { this.parameters = new PgParameter[packet.ReadShort()]; for (int i = 0; i < parameters.Length; i++) { this.parameters[i] = new PgParameter(packet.ReadInt()); } } private void ProcessDataRow(PgResponsePacket packet) { int fieldCount = packet.ReadShort(); object[] values = new object[fieldCount]; if (this.rows == null) { this.rows = new object[fetchSize]; this.rowIndex = 0; } for (int i = 0; i < values.Length; i++) { int length = packet.ReadInt(); switch (length) { case -1: values[i] = System.DBNull.Value; break; default: if (this.status == PgStatementStatus.OnQuery) { values[i] = packet.ReadValueFromString( this.rowDescriptor.Fields[i].DataType, length); } else { values[i] = packet.ReadValue( this.rowDescriptor.Fields[i].DataType, length); } break; } } this.rows[this.rowIndex++] = values; } #endregion } } --- NEW FILE: PgOutputPacket.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Net; using System.IO; using System.Text; using System.Globalization; using PostgreSql.Data.PgTypes; namespace PostgreSql.Data.Protocol { internal class PgOutputPacket : BinaryWriter { #region · Fields · private Encoding encoding; #endregion #region · Properties · public long Position { get { return ((MemoryStream)this.BaseStream).Position; } } public long Length { get { return ((MemoryStream)this.BaseStream).Length; } } #endregion #region · Constructors · public PgOutputPacket() : base(new MemoryStream()) { this.encoding = Encoding.Default; this.Write(new byte[0]); } public PgOutputPacket(Encoding encoding) : base(new MemoryStream(), encoding) { this.encoding = encoding; this.Write(new byte[0]); } #endregion #region · Stream Methods · public int GetByteCount() { return (int)((MemoryStream)this.BaseStream).Length; } public byte[] ToArray() { return ((MemoryStream)this.BaseStream).ToArray(); } public void Reset() { ((MemoryStream)this.BaseStream).SetLength(0); ((MemoryStream)this.BaseStream).Position = 0; } #endregion #region · String Types · public void WriteNullString(string data) { if (!data.EndsWith(PgCodes.NULL_TERMINATOR.ToString())) { data += PgCodes.NULL_TERMINATOR; } this.Write(this.encoding.GetBytes(data)); } public void WriteString(string data) { byte[] buffer = this.encoding.GetBytes(data); this.WriteInt(buffer.Length); this.Write(buffer); } #endregion #region · Numeric Types · public void WriteShort(short val) { this.Write((short)IPAddress.HostToNetworkOrder(val)); } public void WriteInt(int val) { this.Write((int)IPAddress.HostToNetworkOrder(val)); } public void WriteLong(long val) { this.Write((long)IPAddress.HostToNetworkOrder(val)); } public void WriteFloat(float val) { byte[] buffer = BitConverter.GetBytes(val); this.Write(BitConverter.ToInt32(buffer, 0)); } public void WriteDouble(double val) { byte[] buffer = BitConverter.GetBytes(val); this.WriteLong(BitConverter.ToInt64(buffer, 0)); } #endregion #region · Date & Time Types · public void WriteDate(DateTime date) { TimeSpan days = date.Subtract(PgCodes.BASE_DATE); this.WriteInt(days.Days); } public void WriteInterval(TimeSpan interval) { int months = (interval.Days / 30); int days = (interval.Days % 30); this.WriteDouble(interval.Subtract(TimeSpan.FromDays(months * 30)).TotalSeconds); this.WriteInt(months); } public void WriteTime(DateTime time) { this.WriteString(time.ToString("HH:mm:ss.fff")); } public void WriteTimeWithTZ(DateTime time) { this.WriteString(time.ToString("HH:mm:ss.fff zz")); } public void WriteTimestamp(DateTime timestamp) { this.WriteString(timestamp.ToString("yyyy/MM/dd HH:mm:ss.fff")); } public void WriteTimestampWithTZ(DateTime timestamp) { this.WriteString(timestamp.ToString("yyyy/MM/dd HH:mm:ss.fff zz")); } #endregion #region · Geometric Types · public void WritePoint(PgPoint point) { this.WriteDouble(point.X); this.WriteDouble(point.Y); } public void WriteCircle(PgCircle circle) { this.WritePoint(circle.Center); this.WriteDouble(circle.Radius); } public void WriteLine(PgLine line) { this.WritePoint(line.StartPoint); this.WritePoint(line.EndPoint); } public void WriteLSeg(PgLSeg lseg) { this.WritePoint(lseg.StartPoint); this.WritePoint(lseg.EndPoint); } public void WriteBox(PgBox box) { this.WritePoint(box.UpperRight); this.WritePoint(box.LowerLeft); } public void WritePolygon(PgPolygon polygon) { this.WriteInt(polygon.Points.Length); for (int i = 0; i < polygon.Points.Length; i++) { this.WritePoint(polygon.Points[i]); } } public void WritePath(PgPath path) { this.Write(path.IsClosedPath); this.WriteInt(path.Points.Length); for (int i = 0; i < path.Points.Length; i++) { this.WritePoint(path.Points[i]); } } #endregion #region · Parameters · public void WriteParameter(PgParameter parameter) { int size = parameter.DataType.Size; if (parameter.Value == System.DBNull.Value || parameter.Value == null) { // -1 indicates a NULL argument value this.WriteInt(-1); } else { if (parameter.DataType.DataType == PgDataType.Array || parameter.DataType.DataType == PgDataType.Vector) { // Handle this type as Array values System.Array array = (System.Array)parameter.Value; // Get array elements type info PgType elementType = PgDbClient.Types[parameter.DataType.ElementType]; size = elementType.Size; // Create a new packet for write array parameter information PgOutputPacket packet = new PgOutputPacket(); // Write the number of dimensions packet.WriteInt(array.Rank); // Write flags (always 0) packet.WriteInt(0); // Write base type of the array elements packet.WriteInt(parameter.DataType.ElementType); // Write lengths and lower bounds for (int i = 0; i < array.Rank; i ++) { packet.WriteInt(array.GetLength(i)); packet.WriteInt(array.GetLowerBound(i) + 1); } // Write array values foreach (object element in array) { this.WriteParameter(packet, elementType.DataType, size, element); } // Write parameter size this.WriteInt(packet.GetByteCount()); // Write parameter data this.Write(packet.ToArray()); } else { this.WriteParameter(this, parameter.DataType.DataType, size, parameter.Value); } } } #endregion #region · Packet Methods · public byte[] GetSimplePacketBytes() { PgOutputPacket packet = new PgOutputPacket(); // Write packet contents packet.WriteInt(GetByteCount() + 4); packet.Write(ToArray()); return packet.ToArray(); } public byte[] GetPacketBytes(char format) { PgOutputPacket packet = new PgOutputPacket(); packet.Write((byte)format); packet.WriteInt(GetByteCount() + 4); packet.Write(ToArray()); return packet.ToArray(); } #endregion #region · Private Methods · private void WriteParameter(PgOutputPacket packet, PgDataType dataType, int size, object value) { switch (dataType) { case PgDataType.Binary: packet.WriteInt(((byte[])value).Length); packet.Write((byte[])value); break; case PgDataType.Byte: packet.WriteInt(size); packet.Write((byte)value); break; case PgDataType.Boolean: packet.WriteInt(size); packet.Write(Convert.ToByte((bool)value)); break; case PgDataType.Char: case PgDataType.VarChar: { string paramValue = value.ToString() + PgCodes.NULL_TERMINATOR; packet.WriteString(paramValue); } break; case PgDataType.Int2: packet.WriteInt(size); packet.WriteShort(Convert.ToInt16(value)); break; case PgDataType.Int4: packet.WriteInt(size); packet.WriteInt(Convert.ToInt32(value)); break; case PgDataType.Int8: packet.WriteInt(size); packet.WriteLong(Convert.ToInt64(value)); break; case PgDataType.Interval: packet.WriteInt(size); packet.WriteInterval(TimeSpan.Parse(value.ToString())); break; case PgDataType.Decimal: { string paramValue = value.ToString(); packet.WriteInt(encoding.GetByteCount(paramValue)); packet.Write(paramValue.ToCharArray()); } break; case PgDataType.Double: packet.WriteInt(size); packet.WriteDouble(Convert.ToDouble(value)); break; case PgDataType.Float: packet.WriteInt(size); packet.WriteFloat(Convert.ToSingle(value)); break; case PgDataType.Currency: packet.WriteInt(size); packet.WriteInt(Convert.ToInt32(Convert.ToSingle(value) * 100)); break; case PgDataType.Date: packet.WriteInt(size); packet.WriteDate(Convert.ToDateTime(value)); break; case PgDataType.Time: packet.WriteTime(Convert.ToDateTime(value)); break; case PgDataType.TimeWithTZ: packet.WriteTimeWithTZ(Convert.ToDateTime(value)); break; case PgDataType.Timestamp: packet.WriteTimestamp(Convert.ToDateTime(value)); break; case PgDataType.TimestampWithTZ: packet.WriteTimestampWithTZ(Convert.ToDateTime(value)); break; case PgDataType.Point: packet.WriteInt(size); packet.WritePoint((PgPoint)value); break; case PgDataType.Circle: packet.WriteInt(size); packet.WriteCircle((PgCircle)value); break; case PgDataType.Line: packet.WriteInt(size); packet.WriteLine((PgLine)value); break; case PgDataType.LSeg: packet.WriteInt(size); packet.WriteLSeg((PgLSeg)value); break; case PgDataType.Box: packet.WriteInt(size); packet.WriteBox((PgBox)value); break; case PgDataType.Polygon: PgPolygon polygon = (PgPolygon)value; packet.WriteInt((size * polygon.Points.Length) + 4); packet.WritePolygon(polygon); break; case PgDataType.Path: PgPath path = (PgPath)value; packet.WriteInt((size * path.Points.Length) + 5); packet.WritePath(path); break; } } #endregion } } --- NEW FILE: PgClientError.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.Protocol { internal sealed class PgClientError { #region · Fields · private string severity; private string code; private string message; private string detail; private string hint; private string where; private string position; private string file; private int line; private string routine; #endregion #region · Properties · public string Severity { get { return this.severity; } set { this.severity = value; } } public string Message { get { return this.message; } set { this.message = value; } } public string Code { get { return this.code; } set { this.code = value; } } public string Detail { get { return this.detail; } set { this.detail = value; } } public string Hint { get { return this.hint; } set { this.hint = value; } } public string Where { get { return this.where; } set { this.where = value; } } public string Position { get { return this.position; } set { this.position = value; } } public string File { get { return this.file; } set { this.file = value; } } public int Line { get { return this.line; } set { this.line = value; } } public string Routine { get { return this.routine; } set { this.routine = value; } } #endregion #region · Constructors · public PgClientError() { } public PgClientError(string message) { this.message = message; } public PgClientError(string severity, string code, string message) { this.severity = severity; this.code = code; this.message = message; } #endregion } } --- NEW FILE: PgParameter.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.Protocol { internal class PgParameter { #region · Fields · private PgType dataType; private object data; #endregion #region · Properties · public PgType DataType { get { return this.dataType; } set { this.dataType = value; } } public object Value { get { return this.data; } set { this.data = value; } } #endregion #region · Constructors · public PgParameter() { } public PgParameter(int dataType) { this.dataType = PgDbClient.Types[dataType]; } public PgParameter(int dataType, object data) : this(dataType) { this.data = data; } #endregion } } --- NEW FILE: PgBackendCodes.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: PgDataType.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.Protocol { // This is a exact copy of PgDbType enum for // allow a better and more simple handling of // data types in the protocol implementation. internal enum PgDataType { Array , Binary , Boolean , Box , Byte , Char , Circle , Currency , Date , Decimal , Double , Float , Int2 , Int4 , Int8 , Interval , Line , LSeg , Numeric , Path , Point , Polygon , Text , Time , TimeWithTZ , Timestamp , TimestampWithTZ , VarChar , Vector } } --- NEW FILE: PgResponsePacket.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Globalization; using System.IO; using System.Text; using System.Net; using PostgreSql.Data.PgTypes; namespace PostgreSql.Data.Protocol { internal class PgResponsePacket : BinaryReader { #region · Fields · private char message; private Encoding encoding; #endregion #region · Properties · public char Message { get { return this.message; } set { this.message = value; } } public Encoding Encoding { get { return this.encoding; } set { this.encoding = value; } } public long Length { get { return ((MemoryStream)this.BaseStream).Length; } } public long Position { get { return ((MemoryStream)this.BaseStream).Position; } } public bool EOF { get { if (this.Position < this.Length) { return false; } else { return true; } } } public long Pending { get { return this.Length - this.Position; } } #endregion #region · Constructors · public PgResponsePacket() : base(new MemoryStream()) { } public PgResponsePacket(byte[] contents) : base(new MemoryStream(contents)) { } public PgResponsePacket(char message, byte[] contents) : base(new MemoryStream(contents)) { this.message = message; } #endregion #region · Stream Methods · public void Reset() { ((MemoryStream)this.BaseStream).SetLength(0); ((MemoryStream)this.BaseStream).Position = 0; } public byte[] ToArray() { return ((MemoryStream)this.BaseStream).ToArray(); } #endregion #region · String Types · public string ReadNullString() { StringBuilder cString = new StringBuilder(); char c; while ((c = ReadChar()) != PgCodes.NULL_TERMINATOR ) { cString.Append(c); } return cString.ToString(); } public string ReadString(int length) { byte[] buffer = new byte[length]; this.Read(buffer, 0, length); return this.encoding.GetString(buffer); } public new string ReadString() { int length = this.ReadInt(); byte[] buffer = new byte[length]; this.Read(buffer, 0, length); return this.encoding.GetString(buffer); } #endregion #region · Numeric Types · public short ReadShort() { short val = base.ReadInt16(); return IPAddress.HostToNetworkOrder(val); } public int ReadInt() { int val = base.ReadInt32(); return IPAddress.HostToNetworkOrder(val); } public long ReadLong() { return IPAddress.HostToNetworkOrder(base.ReadInt64()); } public override float ReadSingle() { return BitConverter.ToSingle(BitConverter.GetBytes(this.ReadInt()), 0); } public float ReadCurrency() { float val = (float)this.ReadInt(); return val/100; } public override double ReadDouble() { byte[] buffer = BitConverter.GetBytes(this.ReadLong()); return BitConverter.ToDouble(buffer, 0); } #endregion #region · Date & Time Types · public DateTime ReadDate() { int days = this.ReadInt(); DateTime date = new DateTime(days); return PgCodes.BASE_DATE.AddDays(days); } public TimeSpan ReadInterval() { double intervalTime = this.ReadDouble(); int intervalMonth = this.ReadInt(); TimeSpan interval = TimeSpan.FromSeconds(intervalTime); return interval.Add(TimeSpan.FromDays(intervalMonth*30)); } public DateTime ReadTime(int length) { return DateTime.ParseExact(this.ReadString(length), PgTypeStringFormats.TimeFormats, CultureInfo.CurrentCulture, DateTimeStyles.None); } public DateTime ReadTimeWithTZ(int length) { return DateTime.Parse(this.ReadString(length)); } public DateTime ReadTimestamp(int length) { return DateTime.Parse(this.ReadString(length)); } public DateTime ReadTimestampWithTZ(int length) { return DateTime.Parse(this.ReadString(length)); } #endregion #region · Array & Vector Types · public Array ReadArray(PgType type, int length) { if (type.FormatCode == 0) { return this.ReadStringArray(type, length); } else { int[] lengths; int[] lowerBounds; // Read number of dimensions int dimensions = this.ReadInt(); // Initialize arrays for lengths and lower bounds lengths = new int[dimensions]; lowerBounds = new int[dimensions]; // Read flags value int flags = this.ReadInt(); if (flags != 0) { throw new NotSupportedException("Invalid flags value"); } // Read array element type PgType elementType = PgDbClient.Types[this.ReadInt()]; // Read array lengths and lower bounds for (int i = 0; i < dimensions; i++) { lengths[i] = this.ReadInt(); lowerBounds[i] = this.ReadInt(); } // Read Array data if (type.SystemType.IsPrimitive) { return this.ReadPrimitiveArray(elementType, length, dimensions, flags, lengths, lowerBounds); } else { return this.ReadNonPrimitiveArray(elementType, length, dimensions, flags, lengths, lowerBounds); } } } public Array ReadVector(PgType type, int length) { PgType elementType = PgDbClient.Types[type.ElementType]; Array data = null; data = Array.CreateInstance(elementType.SystemType, PgCodes.INDEX_MAX_KEYS); for (int i = 0; i < data.Length; i++ ) { object elementValue = ReadValue(elementType, elementType.Size); data.SetValue(elementValue, i); } return data; } #endregion #region · Geometric Types · public PgPoint ReadPoint() { double x = this.ReadDouble(); double y = this.ReadDouble(); return new PgPoint(x, y); } public PgCircle ReadCircle() { return new PgCircle(this.ReadPoint(), this.ReadDouble()); } public PgLine ReadLine() { return new PgLine(this.ReadPoint(), this.ReadPoint()); } public PgLSeg ReadLSeg() { return new PgLSeg(this.ReadPoint(), this.ReadPoint()); } public PgBox ReadBox() { PgPoint upperRight = this.ReadPoint(); PgPoint lowerLeft = this.ReadPoint(); return new PgBox(lowerLeft, upperRight); } public PgPolygon ReadPolygon() { PgPoint[] points = new PgPoint[this.ReadInt()]; for (int i = 0; i < points.Length; i++) { points[i] = this.ReadPoint(); } return new PgPolygon(points); } public PgPath ReadPath() { bool isClosedPath = this.ReadBoolean(); PgPoint[] points = new PgPoint[this.ReadInt()]; for (int i = 0; i < points.Length; i++) { points[i] = this.ReadPoint(); } return new PgPath(isClosedPath, points); } #endregion #region · Common Methods · public object ReadValue(PgType type, int length) { switch (type.DataType) { case PgDataType.Array: return this.ReadArray(type, length); case PgDataType.Vector: return this.ReadVector(type, length); case PgDataType.Binary: return this.ReadBytes(length); case PgDataType.Char: case PgDataType.VarChar: return this.ReadString(length); case PgDataType.Boolean: return this.ReadBoolean(); case PgDataType.Byte: return this.ReadByte(); case PgDataType.Decimal: return Decimal.Parse( this.ReadString(length), NumberFormatInfo.InvariantInfo); case PgDataType.Currency: return this.ReadCurrency(); case PgDataType.Float: return this.ReadSingle(); case PgDataType.Double: return this.ReadDouble(); case PgDataType.Int2: return this.ReadShort(); case PgDataType.Int4: return this.ReadInt(); case PgDataType.Int8: return this.ReadLong(); case PgDataType.Interval: return this.ReadInterval(); case PgDataType.Date: return this.ReadDate(); case PgDataType.Time: return this.ReadTime(length); case PgDataType.TimeWithTZ: return this.ReadTimeWithTZ(length); case PgDataType.Timestamp: return this.ReadTimestamp(length); case PgDataType.TimestampWithTZ: return this.ReadTimestampWithTZ(length); case PgDataType.Point: return this.ReadPoint(); case PgDataType.Circle: return this.ReadCircle(); case PgDataType.Line: return this.ReadLine(); case PgDataType.LSeg: return this.ReadLSeg(); case PgDataType.Box: return this.ReadBox(); case PgDataType.Polygon: return this.ReadPolygon(); case PgDataType.Path: return this.ReadPath(); default: return this.ReadBytes(length); } } public object ReadValueFromString(PgType type, int length) { string stringValue = this.ReadString(length); switch (type.DataType) { case PgDataType.Array: return null; case PgDataType.Vector: return null; case PgDataType.Binary: return null; case PgDataType.Char: case PgDataType.VarChar: return stringValue; case PgDataType.Boolean: switch (stringValue.ToLower()) { case "t": case "true": case "y": case "yes": case "1": return true; default: return false; } case PgDataType.Byte: return Byte.Parse(stringValue); case PgDataType.Decimal: return Decimal.Parse( stringValue, NumberFormatInfo.InvariantInfo); case PgDataType.Currency: case PgDataType.Float: return Single.Parse( stringValue, NumberFormatInfo.InvariantInfo); case PgDataType.Double: return Double.Parse( stringValue, NumberFormatInfo.InvariantInfo); case PgDataType.Int2: return Int16.Parse( stringValue, NumberFormatInfo.InvariantInfo); case PgDataType.Int4: return Int32.Parse( stringValue, NumberFormatInfo.InvariantInfo); case PgDataType.Int8: return Int64.Parse( stringValue, NumberFormatInfo.InvariantInfo); case PgDataType.Interval: return null; case PgDataType.Date: case PgDataType.Timestamp: case PgDataType.Time: case PgDataType.TimeWithTZ: case PgDataType.TimestampWithTZ: return DateTime.Parse(stringValue); case PgDataType.Point: return PgPoint.Parse(stringValue); case PgDataType.Circle: return PgCircle.Parse(stringValue); case PgDataType.Line: return PgLine.Parse(stringValue); case PgDataType.LSeg: return PgLSeg.Parse(stringValue); case PgDataType.Box: return PgBox.Parse(stringValue); case PgDataType.Polygon: return PgPolygon.Parse(stringValue); case PgDataType.Path: return PgPath.Parse(stringValue); default: return ReadBytes(length); } } #endregion #region · Array Handling Methods · private Array ReadPrimitiveArray(PgType elementType, int length, int dimensions, int flags, int[] lengths, int[] lowerBounds) { Array data = Array.CreateInstance(elementType.SystemType, lengths, lowerBounds); // Read array data byte[] sourceArray = this.DecodeArrayData(elementType, data.Length, length); Buffer.BlockCopy(sourceArray, 0, data, 0, sourceArray.Length); return data; } private Array ReadNonPrimitiveArray(PgType elementType, int length, int dimensions, int flags, int[] lengths, int[] lowerBounds) { Array data = Array.CreateInstance(elementType.SystemType, lengths, lowerBounds); for (int i = data.GetLowerBound(0); i <= data.GetUpperBound(0); i++) { int elementLen = this.ReadInt(); data.SetValue(this.ReadValue(elementType, elementType.Size), i); } return data; } private Array ReadStringArray(PgType type, int length) { PgType elementType = PgDbClient.Types[type.ElementType]; Array data = null; string contents = ReadString(length); contents = contents.Substring(1, contents.Length - 2); string[] elements = contents.Split(','); data = Array.CreateInstance(elementType.SystemType, elements.Length); for (int i = 0; i < elements.Length; i++) { data.SetValue(elements[i], i); } return data; } private byte[] DecodeArrayData(PgType type, int elementCount, int length) { byte[] data = new byte[length]; int element = 0; int index = 0; while (element < elementCount) { byte[] elementData = null; int elementLen = this.ReadInt(); switch (type.DataType) { case PgDataType.Boolean: elementData = BitConverter.GetBytes(this.ReadBoolean()); break; case PgDataType.Float: elementData = BitConverter.GetBytes(this.ReadSingle()); break; case PgDataType.Double: elementData = BitConverter.GetBytes(this.ReadDouble()); break; case PgDataType.Int2: elementData = BitConverter.GetBytes(this.ReadShort()); break; case PgDataType.Int4: elementData = BitConverter.GetBytes(this.ReadInt()); break; case PgDataType.Int8: elementData = BitConverter.GetBytes(this.ReadLong()); break; } // Copy element data to dest array elementData.CopyTo(data, index); // Increment counters element++; index += elementData.Length; } byte[] destArray = new byte[index]; System.Array.Copy(data, 0, destArray, 0, destArray.Length); return destArray; } #endregion } } --- NEW FILE: PgType.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; namespace PostgreSql.Data.Protocol { internal class PgType { #region · Fields · private int oid; private string name; private PgDataType dataType; private Type systemType; private int elementType; private PgTypeFormat formatCode; private int size; #endregion #region · Properties · public int Oid { get { return this.oid; } } public PgDataType DataType { get { return this.dataType; } } public string Name { get { return this.name; } } public Type SystemType { get { return this.systemType; } } public int ElementType { get { int type = elementType; while (PgDbClient.Types[type].DataType == PgDataType.Array) { type = PgDbClient.Types[type].ElementType; } return type; } } public PgTypeFormat FormatCode { get { return this.formatCode; } } public int Size { get { return this.size; } } #endregion #region · Constructors · public PgType(int oid, string name, PgDataType dataType, int elementType, PgTypeFormat formatCode, int size) { this.oid = oid; this.name = name; this.dataType = dataType; this.elementType = elementType; this.formatCode = formatCode; this.size = size; this.systemType = this.InferSystemType(); } #endregion #region · Methods · public bool IsNumeric() { bool returnValue = false; if (this.dataType == PgDataType.Currency || this.dataType == PgDataType.Int2 || this.dataType == PgDataType.Int4 || this.dataType == PgDataType.Int8 || this.dataType == PgDataType.Float || this.dataType == PgDataType.Double || this.dataType == PgDataType.Decimal || this.dataType == PgDataType.Byte) { returnValue = true; } return returnValue; } public bool IsLong() { bool returnValue = false; if (this.dataType == PgDataType.Binary) { returnValue = true; } return returnValue; } #endregion #region · Private Methods · private Type InferSystemType() { switch (this.dataType) { case PgDataType.Array: case PgDataType.Binary: case PgDataType.Vector: return Type.GetType("System.Array"); case PgDataType.Boolean: return Type.GetType("System.Boolean"); case PgDataType.Box: return Type.GetType("PostgreSql.Data.PgTypes.PgBox"); case PgDataType.Circle: return Type.GetType("PostgreSql.Data.PgTypes.PgCircle"); case PgDataType.Line: return Type.GetType("PostgreSql.Data.PgTypes.PgLine"); case PgDataType.LSeg: return Type.GetType("PostgreSql.Data.PgTypes.PgLSeg"); case PgDataType.Path: return Type.GetType("PostgreSql.Data.PgTypes.PgPath"); case PgDataType.Point: return Type.GetType("PostgreSql.Data.PgTypes.PgPoint"); case PgDataType.Polygon: return Type.GetType("PostgreSql.Data.PgTypes.PgPolygon"); case PgDataType.Byte: return Type.GetType("System.Byte"); case PgDataType.Char: case PgDataType.Text: case PgDataType.VarChar: return Type.GetType("System.String"); case PgDataType.Currency: case PgDataType.Decimal: case PgDataType.Numeric: return Type.GetType("System.Decimal"); case PgDataType.Date: case PgDataType.Time: case PgDataType.TimeWithTZ: case PgDataType.Timestamp: case PgDataType.TimestampWithTZ: return Type.GetType("System.DateTime"); case PgDataType.Double: return Type.GetType("System.Double"); case PgDataType.Float: return Type.GetType("System.Single"); case PgDataType.Int2: return Type.GetType("System.Int16"); case PgDataType.Int4: return Type.GetType("System.Int32"); case PgDataType.Int8: return Type.GetType("System.Int64"); default: return Type.GetType("System.Object"); } } #endregion } } --- NEW FILE: PgCodes.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.Protocol { internal class PgCodes { // Protocol version 3.0 public const int PROTOCOL_VERSION2_MAYOR = 2; public const int PROTOCOL_VERSION2_MINOR = 0; public const int PROTOCOL_VERSION2 = (PROTOCOL_VERSION2_MAYOR << 16) | PROTOCOL_VERSION2_MINOR; // Protocol version 3.0 public const int PROTOCOL_VERSION3_MAYOR = 3; public const int PROTOCOL_VERSION3_MINOR = 0; public const int PROTOCOL_VERSION3 = (PROTOCOL_VERSION3_MAYOR << 16) | PROTOCOL_VERSION3_MINOR; // SSL Request code public const int SSL_REQUEST_MOST = 1234; public const int SSL_REQUEST_LEAST = 5679; public const int SSL_REQUEST = (SSL_REQUEST_MOST << 16) | SSL_REQUEST_LEAST; // Cancel request code public const int CANCEL_REQUEST_MOST = 1234; public const int CANCEL_REQUEST_LEAST = 5678; public const int CANCEL_REQUEST = (CANCEL_REQUEST_MOST << 16) | CANCEL_REQUEST_LEAST; // Backend & FrontEnd Message Formats public const int COPY_DATA = 'd'; public const int COPY_DONE = 'c'; // Authentication values public const int AUTH_OK = 0; public const int AUTH_KERBEROS_V4 = 1; public const int AUTH_KERBEROS_V5 = 2; public const int AUTH_CLEARTEXT_PASSWORD = 3; public const int AUTH_CRYPT_PASSWORD = 4; public const int AUTH_MD5_PASSWORD = 5; public const int AUTH_SCM_CREDENTIAL = 6; // Max keys for vector data type public const int INDEX_MAX_KEYS = 32; // public const char NULL_TERMINATOR = '\0'; // public static readonly DateTime BASE_DATE = new DateTime(2000, 1, 1); // MD5 prefix public static string MD5_PREFIX = "md5"; // Format codes public const int TEXT_FORMAT = 0; public const int BINARY_FORMAT = 1; // Date & Time codes public const string DATE_STYLE = "ISO"; // Numeric data type public const int NUMERIC_SIGN_MASK = 0xC000; public const int NUMERIC_POS = 0x0000; public const int NUMERIC_NEG = 0x4000; public const int NUMERIC_NAN = 0xC000; public const int NUMERIC_MAX_PRECISION = 1000; public const int NUMERIC_DSCALE_MASK = 0x3FFF; public const int NUMERIC_HDRSZ = 10; } } --- NEW FILE: PgCharSetCollection.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Collections; using System.Globalization; namespace PostgreSql.Data.Protocol { internal class PgCharSetCollection : ArrayList { #region · Properties · public new PgCharSet this[int index] { get { return (PgCharSet)base[index]; } set { base[index] = (PgCharSet)value; } } public PgCharSet this[string name] { get { return (PgCharSet)this[IndexOf(name)]; } set { this[IndexOf(name)] = (PgCharSet)value; } } #endregion #region · Methods · public bool Contains(string charset) { return (-1 != this.IndexOf(charset)); } public int IndexOf(string charset) { int index = 0; foreach (PgCharSet item in this) { if (this.CultureAwareCompare(item.CharSet, charset)) { return index; } index++; } return -1; } public void RemoveAt(string charset) { this.RemoveAt(IndexOf(charset)); } public PgCharSet Add(PgCharSet charset) { base.Add(charset); return charset; } public PgCharSet Add(string charset, string systemCharset) { PgCharSet charSet = new PgCharSet(charset, systemCharset); base.Add(charSet); return charSet; } public PgCharSet Add(string charset, int cp) { PgCharSet charSet = new PgCharSet(charset, cp); base.Add(charSet); return charSet; } #endregion #region · Private Methods · private bool CultureAwareCompare(string strA, string strB) { return CultureInfo.CurrentCulture.CompareInfo.Compare( strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false; } #endregion } } --- NEW FILE: PgClientMessageEventArgs.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License ... [truncated message content] |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PostgreSqlClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7345/Data/PostgreSqlClient Added Files: PgCommand.cs PgCommandBuilder.cs PgConnection.cs PgConnectionInternal.cs PgConnectionPool.cs PgDataAdapter.cs PgDataReader.cs PgDbType.cs PgError.cs PgErrorCollection.cs PgException.cs PgInfoMessageEventArgs.cs PgNotificationEventArgs.cs PgNotificationEventHandler.cs PgParameter.cs PgParameterCollection.cs PgRowUpdatedEventArgs.cs PgRowUpdatingEventArgs.cs PgTransaction.cs Log Message: Started the reorganization of the CVS module --- NEW FILE: PgTransaction.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Collections; using PostgreSql.Data.Protocol; namespace PostgreSql.Data.PostgreSqlClient { public sealed class PgTransaction : MarshalByRefObject, IDbTransaction, IDisposable { #region · Fields · private PgConnection connection; private IsolationLevel isolationLevel; private bool disposed; private bool isUpdated; #endregion #region · Properties · IDbConnection IDbTransaction.Connection { get { return this.Connection; } } public PgConnection Connection { get { if (!this.isUpdated) { return this.connection; } else { return null; } } } public IsolationLevel IsolationLevel { get { return this.isolationLevel; } } internal bool IsUpdated { get { return this.isUpdated; } set { if (this.connection != null && value) { this.connection.InternalConnection.ActiveTransaction = null; this.connection = null; } this.isUpdated = value; } } #endregion #region · Constructors · private PgTransaction() : this(null) { } internal PgTransaction(PgConnection connection) : this(connection, IsolationLevel.ReadCommitted) { } internal PgTransaction(PgConnection connection, IsolationLevel isolation) { this.connection = connection; this.isolationLevel = isolation; } #endregion #region · Finalizer · ~PgTransaction() { this.Dispose(false); } #endregion #region · IDisposable Methods · public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { try { if (this.connection != null && !this.isUpdated) { // Implicitly roll back if the transaction still valid. this.Rollback(); } } finally { if (this.connection != null) { this.connection.InternalConnection.ActiveTransaction = null; this.connection = null; } this.disposed = true; this.isUpdated = true; } } } } #endregion #region · Methods · public void Commit() { if (this.isUpdated) { throw new InvalidOperationException("This Transaction has completed; it is no longer usable."); } try { this.connection.InternalConnection.Database.CommitTransaction(); this.IsUpdated = true; } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } } public void Rollback() { if (this.isUpdated) { throw new InvalidOperationException("This Transaction has completed; it is no longer usable."); } try { this.connection.InternalConnection.Database.RollbackTransction(); this.IsUpdated = true; } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } } #endregion #region · Internal Methods · internal void InternalBeginTransaction() { try { this.connection.InternalConnection.Database.BeginTransaction(isolationLevel); this.IsUpdated = false; } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } } #endregion } } --- NEW FILE: PgInfoMessageEventArgs.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using PostgreSql.Data.Protocol; using PostgreSql.Data.DbSchema; namespace PostgreSql.Data.PostgreSqlClient { #region Delegates public delegate void PgInfoMessageEventHandler(object sender, PgInfoMessageEventArgs e); #endregion public sealed class PgInfoMessageEventArgs : EventArgs { #region · Fields · private PgErrorCollection errors = new PgErrorCollection(); private string message = String.Empty; #endregion #region · Properties · public PgErrorCollection Errors { get { return this.errors; } } public string Message { get { return this.message; } } #endregion #region · Constructors · internal PgInfoMessageEventArgs(PgClientException ex) { this.message = ex.Message; foreach (PgClientError error in ex.Errors) { PgError newError = new PgError(); newError.Severity = error.Severity; newError.Code = error.Code; newError.Message = error.Message; newError.Detail = error.Detail; newError.Hint = error.Hint; newError.Line = error.Line; newError.Where = error.Where; newError.Position = error.Position; newError.Routine = error.Routine; this.errors.Add(newError); } } #endregion } } --- NEW FILE: PgNotificationEventHandler.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PostgreSqlClient { public delegate void PgNotificationEventHandler(object sender, PgNotificationEventArgs e); } --- NEW FILE: PgConnectionPool.cs --- // // Firebird .NET Data Provider - Firebird managed data provider for .NET and Mono // Copyright (C) 2002-2004 Carlos Guzman Alvarez // // Distributable under LGPL license. // You may obtain a copy of the License at http://www.gnu.org/copyleft/lesser.html // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // using System; using System.Data; using System.Collections; using System.Threading; namespace PostgreSql.Data.PostgreSqlClient { internal class PgConnectionPool : MarshalByRefObject { #region · Fields · private static ConnectionPool pool = null; #endregion #region · Methods · public static void Init() { if (pool == null) { pool = new ConnectionPool(); } } public static PgConnectionInternal GetConnection(string connectionString, PgConnection owningConnection) { Init(); return ((PgConnectionInternal)pool.CheckOut(connectionString, owningConnection)); } public static void FreeConnection(PgConnectionInternal c) { pool.CheckIn(c); } #endregion } internal class ConnectionPool { #region · Fields · private ArrayList locked; private ArrayList unlocked; private Thread cleanUpThread; #endregion #region · Constructors · public ConnectionPool() { this.locked = ArrayList.Synchronized(new ArrayList()); this.unlocked = ArrayList.Synchronized(new ArrayList()); this.cleanUpThread = new Thread(new ThreadStart(RunCleanUp)); this.cleanUpThread.Name = "CleanUp Thread"; this.cleanUpThread.Start(); this.cleanUpThread.IsBackground = true; } #endregion #region · Methods · public PgConnectionInternal CheckOut(string connectionString, PgConnection owningConnection) { PgConnectionInternal newConnection = null; lock (typeof(PgConnectionPool)) { if (this.unlocked.Count > 0) { long now = System.DateTime.Now.Ticks; PgConnectionInternal[] list = new PgConnectionInternal[this.unlocked.Count]; this.unlocked.CopyTo(0, list, 0, list.Length); foreach (PgConnectionInternal connection in list) { if (this.Validate(connection, connectionString)) { if (connection.Lifetime != 0) { if ((now - connection.Created) > connection.Lifetime) { this.unlocked.Remove(connection); this.Expire(connection); } else { this.unlocked.Remove(connection); this.locked.Add(connection); connection.OwningConnection = owningConnection; return connection; } } else { this.unlocked.Remove(connection); this.locked.Add(connection); connection.OwningConnection = owningConnection; return connection; } } else { this.unlocked.Remove(connection); this.Expire(connection); } } } newConnection = this.Create(connectionString); newConnection.OwningConnection = owningConnection; newConnection.Pooled = true; newConnection.Created = System.DateTime.Now.Ticks; newConnection.Connect(); this.locked.Add(newConnection); } return newConnection; } public void CheckIn(PgConnectionInternal connection) { lock (typeof(PgConnectionPool)) { connection.Created = System.DateTime.Now.Ticks; connection.OwningConnection = null; this.locked.Remove(connection); this.unlocked.Add(connection); } } #endregion #region · Private Methods · private void RunCleanUp() { TimeSpan interval = new TimeSpan(0, 0, 10); while (true) { this.CleanUp(null); Thread.Sleep(interval); } } private PgConnectionInternal Create(string connectionString) { try { PgConnectionInternal connection = new PgConnectionInternal(connectionString); return connection; } catch (Exception) { throw; } } private bool Validate(PgConnectionInternal connection, string connectionString) { try { return (connection.ConnectionString == connectionString && connection.Verify()); } catch (Exception) { throw; } } private void Expire(PgConnectionInternal connection) { try { if (connection.Verify()) { connection.Disconnect(); } } catch (Exception) { throw new PgException("Error closing database connection."); } } private void CleanUp(object State) { long now = System.DateTime.Now.Ticks; lock (this.unlocked.SyncRoot) { if (this.unlocked.Count > 0) { PgConnectionInternal[] list = new PgConnectionInternal[this.unlocked.Count]; this.unlocked.CopyTo(0, list, 0, list.Length); foreach (PgConnectionInternal connection in list) { if (connection.Lifetime != 0) { if ((now - connection.Created) >= connection.Lifetime) { this.unlocked.Remove(connection); this.Expire(connection); } } } } } } #endregion } } --- NEW FILE: PgConnectionInternal.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Collections; using System.Data; using System.Text; using System.Text.RegularExpressions; using Mono.Security.Protocol.Tls; using PostgreSql.Data.Protocol; using PostgreSql.Data.DbSchema; namespace PostgreSql.Data.PostgreSqlClient { internal sealed class PgConnectionInternal : MarshalByRefObject { #region · Fields · private string connectionString; private PgConnection owningConnection; private PgDbClient database; private PgConnectionParams options; private PgTransaction activeTransaction; private ArrayList preparedCommands; private int lifetime; private long created; private bool pooled; #endregion #region · Properties · public PgDbClient Database { get { return this.database; } } public PgTransaction ActiveTransaction { get { return this.activeTransaction; } set { this.activeTransaction = value; } } public string ConnectionString { get { return this.connectionString; } } public int Lifetime { get { return this.lifetime; } set { this.lifetime = value; } } public long Created { get { return this.created; } set { this.created = value; } } public bool Pooled { get { return this.pooled; } set { this.pooled = value; } } public PgConnectionParams Options { get { return this.options; } } public ArrayList PreparedCommands { get { if (this.preparedCommands == null) { this.preparedCommands = new ArrayList(); } return this.preparedCommands; } } public bool HasActiveTransaction { get { return (this.activeTransaction != null && !this.activeTransaction.IsUpdated); } } public PgConnection OwningConnection { set { this.owningConnection = value; } } #endregion #region · Constructors · public PgConnectionInternal(string connectionString) { this.options = new PgConnectionParams(); this.connectionString = connectionString; this.lifetime = 0; this.created = 0; this.pooled = true; this.database = new PgDbClient(); this.owningConnection = owningConnection; if (connectionString != null) { this.ParseConnectionString(connectionString); } } #endregion #region · Methods · public void Connect() { try { this.database.SslConnection = new SslConnectionCallback(OnSslConnection); this.database.Settings = this.Options; this.database.Connect(); } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } } public void Disconnect() { try { this.database.Disconnect(); } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } } public PgTransaction BeginTransaction(IsolationLevel level) { if (this.activeTransaction != null && !this.activeTransaction.IsUpdated) { throw new InvalidOperationException("A transaction is currently active. Parallel transactions are not supported."); } try { this.activeTransaction = new PgTransaction(this.owningConnection, level); this.activeTransaction.InternalBeginTransaction(); } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } return this.activeTransaction; } public DataTable GetSchema(string collectionName, string[] restrictions) { PgDbSchema dbSchema = PgDbSchemaFactory.GetSchema(collectionName); if (dbSchema == null) { throw new NotSupportedException("Specified schema type is not supported."); } if (restrictions != null) { if (restrictions.Length > dbSchema.RestrictionColumns.Count) { throw new InvalidOperationException("The number of specified restrictions is not valid."); } } return dbSchema.GetSchema(this.owningConnection, restrictions); } public void DisposeActiveTransaction() { // Rollback active transation if (this.HasActiveTransaction) { this.activeTransaction.Dispose(); this.activeTransaction = null; } } public void ClosePreparedCommands() { if (this.PreparedCommands.Count > 0) { PgCommand[] commands = new PgCommand[this.PreparedCommands.Count]; this.PreparedCommands.CopyTo(0, commands, 0, commands.Length); foreach (PgCommand command in commands) { command.InternalClose(); } this.preparedCommands.Clear(); this.preparedCommands = null; } } public void AddPreparedCommand(PgCommand command) { if (!this.PreparedCommands.Contains(command)) { this.PreparedCommands.Add(command); } } public void RemovePreparedCommand(PgCommand command) { if (this.PreparedCommands.Contains(command)) { this.PreparedCommands.Remove(command); } } #endregion #region · Internal Methods · internal bool Verify() { bool isValid = true; try { // Try to send a Sync message to the PostgreSQL Server this.database.Sync(); } catch (Exception) { isValid = false; } return isValid; } #endregion #region · Private Methods · private void ParseConnectionString(string connectionStirng) { Regex search = new Regex(@"([\w\s\d]*)\s*=\s*([^;]*)"); MatchCollection elements = search.Matches(connectionString); foreach (Match element in elements) { if (element.Groups[2].Value.Trim().Length > 0) { switch (element.Groups[1].Value.Trim().ToLower()) { case "datasource": case "server": case "host": this.options.ServerName = element.Groups[2].Value.Trim(); break; case "database": this.options.Database = element.Groups[2].Value.Trim(); break; case "user name": case "user": this.options.UserName = element.Groups[2].Value.Trim(); break; case "user password": case "password": this.options.UserPassword = element.Groups[2].Value.Trim(); break; case "port": this.options.ServerPort = Int32.Parse(element.Groups[2].Value.Trim()); break; case "connection lifetime": this.lifetime = Int32.Parse(element.Groups[2].Value.Trim()); break; case "timeout": case "connection timeout": this.options.Timeout = Int32.Parse(element.Groups[2].Value.Trim()); break; case "packet size": this.options.PacketSize = Int32.Parse(element.Groups[2].Value.Trim()); break; case "pooling": this.options.Pooling = Boolean.Parse(element.Groups[2].Value.Trim()); break; case "ssl": this.options.SSL = Boolean.Parse(element.Groups[2].Value.Trim()); break; } } } if (options.UserName == String.Empty || options.ServerName == String.Empty || options.ServerPort == 0) { throw new ArgumentException("An invalid connection string argument has been supplied or a required connection string argument has not been supplied."); } else { if (options.PacketSize < 512 || options.PacketSize > 32767) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("'Packet Size' value of {0} is not valid.\r\nThe value should be an integer >= 512 and <= 32767.", options.PacketSize); throw new ArgumentException(msg.ToString()); } } } #endregion #region SSL Callbacks private void OnSslConnection() { // Server certificate validation this.database.SslClientStream.ServerCertValidationDelegate = new CertificateValidationCallback(owningConnection.OnServerCertificateValidation); // Client certificate selection this.database.SslClientStream.ClientCertSelectionDelegate = new CertificateSelectionCallback(owningConnection.OnClientCertificateSelection); } #endregion } } --- NEW FILE: PgDbType.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PostgreSqlClient { [Serializable] public enum PgDbType { Array , Binary , Boolean , Box , Byte , Char , Circle , Currency , Date , Decimal , Double , Float , Int2 , Int4 , Int8 , Interval , Line , LSeg , Numeric , Path , Point , Polygon , Text , Time , TimeWithTZ , Timestamp , TimestampWithTZ , VarChar , Vector } } --- NEW FILE: PgDataReader.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Collections; using System.Data; using System.Data.Common; using System.Globalization; using System.Reflection; using System.ComponentModel; using PostgreSql.Data.Protocol; using PostgreSql.Data.DbSchema; using PostgreSql.Data.PgTypes; namespace PostgreSql.Data.PostgreSqlClient { public sealed class PgDataReader : MarshalByRefObject, IEnumerable, IDataReader, IDisposable, IDataRecord { #region · Fields · private const int STARTPOS = -1; private bool disposed; private bool open; private int position; private int recordsAffected; private int fieldCount; private DataTable schemaTable; private CommandBehavior behavior; private PgCommand command; private PgConnection connection; private object[] row; #endregion #region · Constructors · private PgDataReader() { this.open = true; this.position = STARTPOS; this.recordsAffected = -1; this.fieldCount = -1; } internal PgDataReader(PgCommand command, PgConnection connection) : this() { this.command = command; this.behavior = this.command.CommandBehavior; this.connection = connection; this.fieldCount = this.command.Statement.RowDescriptor.Fields.Length; } #endregion #region · Finalizer · ~PgDataReader() { this.Dispose(false); } #endregion #region · IDisposable Methods · void IDisposable.Dispose() { this.Dispose(true); System.GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (!this.disposed) { try { if (disposing) { // release any managed resources this.Close(); this.command = null; this.connection = null; this.row = null; this.schemaTable= null; } // release any unmanaged resources } finally { } this.disposed = true; } } #endregion #region IDataReader Properties & Methods public int Depth { get { return 0; } } public bool IsClosed { get { return !this.open; } } public int RecordsAffected { get { return this.IsClosed ? this.recordsAffected : -1; } } public bool HasRows { get { return this.command.Statement.HasRows; } } public void Close() { if (!this.open) { return; } // This will update RecordsAffected property this.UpdateRecordsAffected(); if (this.command != null && !this.command.IsDisposed) { if (this.command.Statement != null) { // Set values of output parameters this.command.InternalSetOutputParameters(); } this.command.ActiveDataReader = null; } if (this.connection != null) { if ((this.behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection) { this.connection.Close(); } } this.open = false; this.position = STARTPOS; } public bool NextResult() { return false; } public bool Read() { bool read = false; if ((this.behavior == CommandBehavior.SingleRow && this.position != STARTPOS) || !this.command.Statement.HasRows) { } else { try { this.fieldCount = this.command.Statement.RowDescriptor.Fields.Length; this.position++; row = this.command.Statement.FetchRow(); read = (this.row == null) ? false : true; } catch (PgClientException ex) { throw new PgException(ex.Message, ex); } } return read; } #endregion #region GetSchemaTable Method public DataTable GetSchemaTable() { if (schemaTable == null) { schemaTable = this.GetSchemaTableStructure(); schemaTable.BeginLoadData(); PgCommand cInfoCmd = this.GetColumnInfoCmd(); PgCommand pKeyCmd = this.GetPrimaryKeyInfoCmd(); for (int i = 0; i < command.Statement.RowDescriptor.Fields.Length; i++) { object[] columnInfo = null; System.Array pKeyInfo = null; // Execute commands cInfoCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidNumber; cInfoCmd.Parameters[1].Value = command.Statement.RowDescriptor.Fields[i].OidTable; pKeyCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidTable; cInfoCmd.InternalPrepare(); pKeyCmd.InternalPrepare(); cInfoCmd.InternalExecute(); pKeyCmd.InternalExecute(); // Get Column Information if (cInfoCmd.Statement.Rows != null && cInfoCmd.Statement.Rows.Length > 0) { columnInfo = (object[])cInfoCmd.Statement.Rows[0]; } // Get Primary Key Info if (pKeyCmd.Statement.Rows != null && pKeyCmd.Statement.Rows.Length > 0) { object[] temp = (object[])pKeyCmd.Statement.Rows[0]; pKeyInfo = (System.Array)temp[3]; } // Add row information DataRow schemaRow = schemaTable.NewRow(); schemaRow["ColumnName"] = this.GetName(i); schemaRow["ColumnOrdinal"] = i; schemaRow["ColumnSize"] = this.GetSize(i); if (this.IsNumeric(i)) { schemaRow["NumericPrecision"] = this.GetNumericPrecision(i); schemaRow["NumericScale"] = this.GetNumericScale(i); } else { schemaRow["NumericPrecision"] = DBNull.Value; schemaRow["NumericScale"] = DBNull.Value; } schemaRow["DataType"] = this.GetFieldType(i); schemaRow["ProviderType"] = this.GetProviderType(i); schemaRow["IsLong"] = this.IsLong(i); schemaRow["IsRowVersion"] = false; schemaRow["IsUnique"] = false; schemaRow["IsAliased"] = this.IsAliased(i); schemaRow["IsExpression"] = this.IsExpression(i); schemaRow["BaseCatalogName"] = System.DBNull.Value; if (columnInfo != null) { schemaRow["IsReadOnly"] = (bool)columnInfo[10]; schemaRow["IsAutoIncrement"] = (bool)columnInfo[10]; schemaRow["IsKey"] = this.IsPrimaryKey(pKeyInfo, (short)columnInfo[6]); schemaRow["AllowDBNull"] = ((bool)columnInfo[9]) ? false : true; schemaRow["BaseSchemaName"] = columnInfo[0].ToString(); schemaRow["BaseTableName"] = columnInfo[1].ToString(); schemaRow["BaseColumnName"] = columnInfo[2].ToString(); } else { schemaRow["IsReadOnly"] = false; schemaRow["IsAutoIncrement"] = false; schemaRow["IsKey"] = false; schemaRow["AllowDBNull"] = System.DBNull.Value; schemaRow["BaseSchemaName"] = System.DBNull.Value; schemaRow["BaseTableName"] = System.DBNull.Value; schemaRow["BaseColumnName"] = System.DBNull.Value; } schemaTable.Rows.Add(schemaRow); } schemaTable.EndLoadData(); cInfoCmd.Dispose(); pKeyCmd.Dispose(); } return schemaTable; } private PgCommand GetColumnInfoCmd() { PgDbSchema dbSchema = PgDbSchemaFactory.GetSchema("Columns"); dbSchema.AddWhereFilter("pg_attribute.attnum = @OidNumber"); dbSchema.AddWhereFilter("pg_attribute.attrelid = @OidTable"); PgCommand cmd = new PgCommand(dbSchema.GetCommandText(null), command.Connection); cmd.Parameters.Add("@OidNumber", PgDbType.Int4); cmd.Parameters.Add("@OidTable", PgDbType.Int4); return cmd; } private PgCommand GetPrimaryKeyInfoCmd() { PgDbSchema dbSchema = PgDbSchemaFactory.GetSchema("PrimaryKeys"); dbSchema.AddWhereFilter("pg_class.oid = @OidTable"); PgCommand cmd = new PgCommand(dbSchema.GetCommandText(null), command.Connection); cmd.Parameters.Add("@OidTable", PgDbType.Int4); return cmd; } private bool IsPrimaryKey(System.Array pKeyInfo, short ordinal) { if (pKeyInfo != null) { for (int i = pKeyInfo.GetLowerBound(0); i <= pKeyInfo.GetUpperBound(0); i++) { if ((short)pKeyInfo.GetValue(i) == ordinal) { return true; } } } return false; } #endregion #region Indexers public object this[int i] { get { return this.GetValue(i); } } public object this[string name] { get { return this.GetValue(this.GetOrdinal(name)); } } #endregion #region IDataRecord Properties & Methods public int FieldCount { get { return this.command.Statement.RowDescriptor.Fields.Length; } } public String GetName(int i) { this.CheckIndex(i); return this.command.Statement.RowDescriptor.Fields[i].FieldName; } [EditorBrowsable(EditorBrowsableState.Never)] public String GetDataTypeName(int i) { this.CheckIndex(i); return this.command.Statement.RowDescriptor.Fields[i].DataType.Name; } public Type GetFieldType(int i) { this.CheckIndex(i); return this.command.Statement.RowDescriptor.Fields[i].DataType.SystemType; } public object GetValue(int i) { this.CheckPosition(); this.CheckIndex(i); return this.row[i]; } public int GetValues(object[] values) { this.CheckPosition(); for (int i = 0; i < FieldCount; i++) { values[i] = GetValue(i); } return values.Length; } public int GetOrdinal(string name) { if (this.IsClosed) { throw new InvalidOperationException("Reader closed"); } for (int i = 0; i < this.command.Statement.RowDescriptor.Fields.Length; i++) { if (this.CultureAwareCompare(command.Statement.RowDescriptor.Fields[i].FieldName, name)) { return i; } } return -1; } public bool GetBoolean(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToBoolean(this.GetValue(i)); } public byte GetByte(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToByte(this.GetValue(i)); } public long GetBytes( int i, long dataIndex, byte[] buffer, int bufferIndex, int length) { int bytesRead = 0; int realLength = length; if (buffer == null) { if (this.IsDBNull(i)) { return 0; } else { byte[] data = (byte[])this.GetValue(i); return data.Length; } } byte[] byteArray = (byte[])this.GetValue(i); if (length > (byteArray.Length - dataIndex)) { realLength = byteArray.Length - (int)dataIndex; } Array.Copy(byteArray, (int)dataIndex, buffer, bufferIndex, realLength); if ((byteArray.Length - dataIndex) < length) { bytesRead = byteArray.Length - (int)dataIndex; } else { bytesRead = length; } return bytesRead; } [EditorBrowsable(EditorBrowsableState.Never)] public char GetChar(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToChar(this.GetValue(i)); } public long GetChars( int i, long dataIndex, char[] buffer, int bufferIndex, int length) { this.CheckPosition(); this.CheckIndex(i); if (buffer == null) { if (this.IsDBNull(i)) { return 0; } else { char[] data = ((string)this.GetValue(i)).ToCharArray(); return data.Length; } } int charsRead = 0; int realLength = length; char[] charArray = ((string)this.GetValue(i)).ToCharArray(); if (length > (charArray.Length - dataIndex)) { realLength = charArray.Length - (int)dataIndex; } System.Array.Copy(charArray, (int)dataIndex, buffer, bufferIndex, realLength); if ( (charArray.Length - dataIndex) < length) { charsRead = charArray.Length - (int)dataIndex; } else { charsRead = length; } return charsRead; } public Guid GetGuid(int i) { throw new NotSupportedException("Guid datatype is not supported"); } public Int16 GetInt16(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToInt16(this.GetValue(i)); } public Int32 GetInt32(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToInt32(this.GetValue(i)); } public Int64 GetInt64(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToInt64(this.GetValue(i)); } public float GetFloat(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToSingle(this.GetValue(i)); } public double GetDouble(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToDouble(this.GetValue(i)); } public String GetString(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToString(this.GetValue(i)); } public Decimal GetDecimal(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToDecimal(this.GetValue(i)); } public DateTime GetDateTime(int i) { this.CheckPosition(); this.CheckIndex(i); return Convert.ToDateTime(this.GetValue(i)); } public TimeSpan GetTimeSpan(int i) { this.CheckPosition(); this.CheckIndex(i); return (TimeSpan)GetValue(i); } public PgPoint GetPgPoint(int i) { this.CheckPosition(); this.CheckIndex(i); return (PgPoint)this.GetPgValue(i); } public PgBox GetPgBox(int i) { this.CheckPosition(); this.CheckIndex(i); return (PgBox)this.GetPgValue(i); } public PgLSeg GetPgLSeg(int i) { this.CheckPosition(); this.CheckIndex(i); return (PgLSeg)this.GetPgValue(i); } public PgCircle GetPgCircle(int i) { this.CheckPosition(); this.CheckIndex(i); return (PgCircle)this.GetPgValue(i); } public PgPath GetPgPath(int i) { this.CheckPosition(); this.CheckIndex(i); return (PgPath)this.GetPgValue(i); } public PgPolygon GetPgPolygon(int i) { this.CheckPosition(); this.CheckIndex(i); return (PgPolygon)this.GetPgValue(i); } public PgTimeSpan GetPgTimeSpan(int i) { this.CheckPosition(); this.CheckIndex(i); return new PgTimeSpan(this.GetTimeSpan(i)); } public object GetPgValue(int i) { this.CheckPosition(); this.CheckIndex(i); switch (this.GetProviderType(i)) { case PgDbType.Interval: return this.GetPgTimeSpan(i); default: return this.GetValue(i); } } public int GetPgValues(object[] values) { return this.GetValues(values); } public IDataReader GetData(int i) { throw new NotSupportedException(); } public bool IsDBNull(int i) { this.CheckPosition(); this.CheckIndex(i); bool returnValue = false; if (this.row[i] == System.DBNull.Value) { returnValue = true; } return returnValue; } #endregion #region IEnumerable Methods IEnumerator IEnumerable.GetEnumerator() { return new DbEnumerator(this); } #endregion #region · Private Methods · private void CheckIndex(int i) { if (i < 0 || i >= this.fieldCount) { throw new IndexOutOfRangeException("Could not find specified column in results."); } } private void CheckPosition() { if (this.position == STARTPOS) { throw new InvalidOperationException("There are no data to read."); } } private int GetSize(int i) { return this.command.Statement.RowDescriptor.Fields[i].DataType.Size; } private int GetNumericPrecision(int i) { #warning "Add implementation" return 0; } private int GetNumericScale(int i) { #warning "Add implementation" return 0; } private PgDbType GetProviderType(int i) { return (PgDbType)this.command.Statement.RowDescriptor.Fields[i].DataType.DataType; } private bool IsNumeric(int i) { if (i < 0 || i >= this.FieldCount) { throw new IndexOutOfRangeException("Could not find specified column in results."); } return this.command.Statement.RowDescriptor.Fields[i].DataType.IsNumeric(); } private bool IsLong(int i) { if (i < 0 || i >= this.FieldCount) { throw new IndexOutOfRangeException("Could not find specified column in results."); } return this.command.Statement.RowDescriptor.Fields[i].DataType.IsLong(); } private bool IsAliased(int i) { /* TODO: Add implementation */ return false; } private bool IsExpression(int i) { bool returnValue = false; if (this.command.Statement.RowDescriptor.Fields[i].OidNumber == 0 && this.command.Statement.RowDescriptor.Fields[i].OidTable == 0) { returnValue = true; } return returnValue; } private DataTable GetSchemaTableStructure() { DataTable schema = new DataTable("Schema"); schema.Columns.Add("ColumnName" , System.Type.GetType("System.String")); schema.Columns.Add("ColumnOrdinal" , System.Type.GetType("System.Int32")); schema.Columns.Add("ColumnSize" , System.Type.GetType("System.Int32")); schema.Columns.Add("NumericPrecision", System.Type.GetType("System.Int32")); schema.Columns.Add("NumericScale" , System.Type.GetType("System.Int32")); schema.Columns.Add("DataType" , System.Type.GetType("System.Type")); schema.Columns.Add("ProviderType" , System.Type.GetType("System.Int32")); schema.Columns.Add("IsLong" , System.Type.GetType("System.Boolean")); schema.Columns.Add("AllowDBNull" , System.Type.GetType("System.Boolean")); schema.Columns.Add("IsReadOnly" , System.Type.GetType("System.Boolean")); schema.Columns.Add("IsRowVersion" , System.Type.GetType("System.Boolean")); schema.Columns.Add("IsUnique" , System.Type.GetType("System.Boolean")); schema.Columns.Add("IsKey" , System.Type.GetType("System.Boolean")); schema.Columns.Add("IsAutoIncrement", System.Type.GetType("System.Boolean")); schema.Columns.Add("IsAliased" , System.Type.GetType("System.Boolean")); schema.Columns.Add("IsExpression" , System.Type.GetType("System.Boolean")); schema.Columns.Add("BaseSchemaName" , System.Type.GetType("System.String")); schema.Columns.Add("BaseCatalogName", System.Type.GetType("System.String")); schema.Columns.Add("BaseTableName" , System.Type.GetType("System.String")); schema.Columns.Add("BaseColumnName" , System.Type.GetType("System.String")); return schema; } private void UpdateRecordsAffected() { if (this.command != null && !this.command.IsDisposed) { if (this.command.RecordsAffected != -1) { this.recordsAffected = this.recordsAffected == -1 ? 0 : this.recordsAffected; this.recordsAffected += this.command.RecordsAffected; } } } private bool CultureAwareCompare(string strA, string strB) { return CultureInfo.CurrentCulture.CompareInfo.Compare( strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false; } #endregion } } --- NEW FILE: PgCommandBuilder.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Data.Common; using System.Text; using System.ComponentModel; using PostgreSql.Data.Protocol; namespace PostgreSql.Data.PostgreSqlClient { public sealed class PgCommandBuilder : Component { #region · Fields · private PgDataAdapter dataAdapter; private PgCommand insertCommand; private PgCommand updateCommand; private PgCommand deleteCommand; private DataTable schemaTable; private string sqlInsert; private string sqlUpdate; private string sqlDelete; private string separator; private string whereClausule1; private string whereClausule2; private string setClausule; private string tableName; private bool hasPrimaryKey; private bool hasUniqueKey; private string quotePrefix; private string quoteSuffix; private bool disposed; private PgRowUpdatingEventHandler adapterHandler; #endregion #region · Properties · [DefaultValue(null)] public PgDataAdapter DataAdapter { get { return this.dataAdapter; } set { this.dataAdapter = value; // Registers the CommandBuilder as a listener for RowUpdating events that are // generated by the PgDataAdapter specified in this property. if (this.dataAdapter != null) { this.adapterHandler = new PgRowUpdatingEventHandler(this.RowUpdatingHandler); this.dataAdapter.RowUpdating += this.adapterHandler; } } } [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string QuotePrefix { get { return this.quotePrefix; } set { if (this.insertCommand != null || this.updateCommand != null || this.deleteCommand != null) { throw new InvalidOperationException("This property cannot be changed after an insert, update, or delete command has been generated."); } this.quotePrefix = value; } } [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string QuoteSuffix { get { return this.quoteSuffix; } set { if (this.insertCommand != null || this.updateCommand != null || this.deleteCommand != null) { throw new InvalidOperationException("This property cannot be changed after an insert, update, or delete command has been generated."); } this.quoteSuffix = value; } } #endregion #region · Internal Properties · internal PgCommand SelectCommand { get { if (this.dataAdapter.SelectCommand != null) { return this.dataAdapter.SelectCommand; } return null; } } #endregion #region · Constructors · public PgCommandBuilder() : base() { this.sqlInsert = "INSERT INTO {0} ({1}) VALUES ({2})"; this.sqlUpdate = "UPDATE {0} SET {1} WHERE ( {2} )"; this.sqlDelete = "DELETE FROM {0} WHERE ( {1} )"; this.whereClausule1 = "(({0} IS NULL AND ${1} = NULL) OR ({0} = ${2}))"; // this.whereClausule2 = "({0} = ${1})"; // this.setClausule = "{0} = ${1}"; this.whereClausule2 = "({0} = {1})"; this.setClausule = "{0} = {1}"; this.separator = ", "; this.quotePrefix = String.Empty; this.quoteSuffix = String.Empty; GC.SuppressFinalize(this); } public PgCommandBuilder(PgDataAdapter adapter) : this() { this.DataAdapter = adapter; } #endregion #region · IDisposable Methods · protected override void Dispose(bool disposing) { if (!this.disposed) { try { if (disposing) { this.RefreshSchema(); if (this.adapterHandler != null) { this.dataAdapter.RowUpdating -= this.adapterHandler; } this.sqlInsert = null; this.sqlUpdate = null; this.sqlDelete = null; this.whereClausule1 = null; this.whereClausule2 = null; this.setClausule = null; this.separator = null; this.quotePrefix = null; this.quoteSuffix = null; } // release any unmanaged resources this.disposed = true; } finally { base.Dispose(disposing); } } } #endregion #region · Static Methods · public static void DeriveParameters(PgCommand command) { if (command.CommandType != CommandType.StoredProcedure) { throw new InvalidOperationException("The command text is not a valid stored procedure name."); } command.Parameters.Clear(); DataTable spSchema = command.Connection.GetSchema("Functions", new string[] { null, command.CommandText.ToLower() }); if (spSchema.Rows.Count != 0) { int[] parameterTypes = (int[])spSchema.Rows[0]["ARGUMENTS"]; int parameterCount = (short)spSchema.Rows[0]["ARGUMENT_NUMBER"]; for (int i = 0; i < parameterCount; i++) { PgParameter parameter = command.Parameters.Add( "@ip" + i.ToString(), (PgDbType)PgDbClient.Types[parameterTypes[i]].DataType); parameter.Direction = ParameterDirection.Input; } int returnType = (int)spSchema.Rows[0]["RETURN_TYPE"]; if (returnType != 0) { PgParameter parameter = command.Parameters.Add( "@op0", PgDbClient.Types[returnType]); parameter.Direction = ParameterDirection.Output; } } } #endregion #region · Methods · public PgCommand GetInsertCommand() { if (this.insertCommand == null) { this.BuildInsertCommand(null, null); } return this.insertCommand; } public PgCommand GetUpdateCommand() { if (this.updateCommand == null) { this.BuildUpdateCommand(null, null); } return this.updateCommand; } public PgCommand GetDeleteCommand() { if (this.deleteCommand == null) { this.BuildDeleteCommand(null, null); } return this.deleteCommand; } public void RefreshSchema() { if (this.dataAdapter != null) { if (this.dataAdapter.InsertCommand == this.insertCommand) { this.dataAdapter.InsertCommand = null; } if (this.dataAdapter.DeleteCommand == this.deleteCommand) { this.dataAdapter.DeleteCommand = null; } if (this.dataAdapter.UpdateCommand == this.updateCommand) { this.dataAdapter.UpdateCommand = null; } } if (this.insertCommand != null) { this.insertCommand.Dispose(); } if (this.updateCommand != null) { this.updateCommand.Dispose(); } if (this.deleteCommand != null) { this.deleteCommand.Dispose(); } if (this.schemaTable != null) { this.schemaTable.Dispose(); } this.schemaTable = null; this.insertCommand = null; this.updateCommand = null; this.deleteCommand = null; } #endregion #region Build Command Methods private PgCommand BuildInsertCommand(DataRow row, DataTableMapping tableMapping) { StringBuilder sql = new StringBuilder(); StringBuilder fields = new StringBuilder(); StringBuilder values = new StringBuilder(); this.BuildSchemaTable(); // Create a new command this.CreateCommand(ref this.insertCommand); int i = 1; foreach (DataRow schemaRow in schemaTable.Rows) { if (this.IsUpdatable(schemaRow, row, tableMapping)) { if (fields.Length > 0) { fields.Append(this.separator); } if (values.Length > 0) { values.Append(this.separator); } PgParameter parameter = this.CreateParameter( schemaRow, i, false); if (row != null && tableMapping != null) { DataColumn column = this.GetDataColumn( schemaRow["BaseColumnName"].ToString(), tableMapping, row); if (column != null) { parameter.Value = row[column]; } } i++; // Build Field name and append it to the string fields.Append(this.GetQuotedIdentifier(schemaRow["BaseColumnName"])); // Build value name and append it to the string values.Append(parameter.ParameterName); this.insertCommand.Parameters.Add(parameter); } } sql.AppendFormat( this.sqlInsert, this.GetQuotedIdentifier(tableName), fields.ToString(), values.ToString()); this.insertCommand.CommandText = sql.ToString(); return this.insertCommand; } private PgCommand BuildUpdateCommand(DataRow row, DataTableMapping tableMapping) { StringBuilder sql = new StringBuilder(); StringBuilder sets = new StringBuilder(); StringBuilder where = new StringBuilder(); this.BuildSchemaTable(); if (!this.hasPrimaryKey && !this.hasUniqueKey) { throw new InvalidOperationException("Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."); } // Create a new command this.CreateCommand(ref this.updateCommand); int i = 1; foreach (DataRow schemaRow in schemaTable.Rows) { if (this.IsUpdatable(schemaRow, row, tableMapping)) { if (sets.Length > 0) { sets.Append(separator); } PgParameter parameter = this.CreateParameter(schemaRow, i, false); // Build Field name and append it to the string sets.AppendFormat( this.setClausule, this.GetQuotedIdentifier(schemaRow["BaseColumnName"]), parameter.ParameterName); if (row != null && tableMapping != null) { DataColumn column = this.GetDataColumn( schemaRow["BaseColumnName"].ToString(), tableMapping, row); if (column != null) { parameter.Value = row[column]; } } this.updateCommand.Parameters.Add(parameter); i++; } } // Build where clausule foreach (DataRow schemaRow in schemaTable.Rows) { if (this.IncludedInWhereClause(schemaRow)) { if (where.Length > 0) { where.Append(" AND "); } string quotedId = this.GetQuotedIdentifier(schemaRow["BaseColumnName"]); PgParameter parameter = this.CreateParameter(schemaRow, i, true); where.AppendFormat( this.whereClausule2, quotedId, parameter.ParameterName); if (row != null && tableMapping != null) { DataColumn column = this.GetDataColumn( schemaRow["BaseColumnName"].ToString(), tableMapping, row); if (column != null) { parameter.Value = row[column, DataRowVersion.Original]; } } this.updateCommand.Parameters.Add(parameter); i++; } } sql.AppendFormat( this.sqlUpdate, this.GetQuotedIdentifier(tableName), sets.ToString(), where.ToString()); this.updateCommand.CommandText = sql.ToString(); return this.updateCommand; } private PgCommand BuildDeleteCommand(DataRow row, DataTableMapping tableMapping) { StringBuilder sql = new StringBuilder(); StringBuilder where = new StringBuilder(); string dsColumnName = String.Empty; this.BuildSchemaTable(); if (!this.hasPrimaryKey && !this.hasUniqueKey) { throw new InvalidOperationException("Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information."); } // Create a new command this.CreateCommand(ref this.deleteCommand); // Build where clausule int i = 1; foreach (DataRow schemaRow in schemaTable.Rows) { if (this.IncludedInWhereClause(schemaRow)) { if (where.Length > 0) { where.Append(" AND "); } string quotedId = this.GetQuotedIdentifier(schemaRow["BaseColumnName"]); PgParameter parameter = this.CreateParameter(schemaRow, i, true); where.AppendFormat( this.whereClausule2, quotedId, parameter.ParameterName); if (row != null && tableMapping != null) { DataColumn column = this.GetDataColumn( schemaRow["BaseColumnName"].ToString(), tableMapping, row); if (column != null) { parameter.Value = row[column, DataRowVersion.Original]; } } this.deleteCommand.Parameters.Add(parameter); i++; } } sql.AppendFormat( this.sqlDelete, this.GetQuotedIdentifier(tableName), where.ToString()); this.deleteCommand.CommandText = sql.ToString(); return this.deleteCommand; } private PgParameter CreateParameter( DataRow schemaRow, int index, bool isWhereParameter) { PgParameter parameter = new PgParameter(String.Format("@p{0}", index), (PgDbType)schemaRow["ProviderType"]); parameter.Size = Convert.ToInt32(schemaRow["ColumnSize"]); if (schemaRow["NumericPrecision"] != DBNull.Value) { parameter.Precision = Convert.ToByte(schemaRow["NumericPrecision"]); } if (schemaRow["NumericScale"] != DBNull.Value) { parameter.Precision = Convert.ToByte(schemaRow["NumericScale"]); } parameter.SourceColumn = Convert.ToString(schemaRow["BaseColumnName"]); if (isWhereParameter) { parameter.SourceVersion = DataRowVersion.Original; } else { parameter.SourceVersion = DataRowVersion.Current; } return parameter; } private bool IsUpdatable( DataRow schemaRow, DataRow row, DataTableMapping tableMapping) { if (row != null && tableMapping != null) { DataColumn column = this.GetDataColumn( schemaRow["BaseColumnName"].ToString(), tableMapping, row); if (column != null) { if (column.Expression != null && column.Expression.Length != 0) { return false; } if (column.AutoIncrement) { return false; } if (column.ReadOnly) { return false; } } } if ((bool) schemaRow["IsExpression"]) { return false; } if ((bool) schemaRow["IsAutoIncrement"]) { return false; } if ((bool) schemaRow["IsRowVersion"]) { return false; } if ((bool) schemaRow["IsReadOnly"]) { return false; } return true; } private bool IncludedInWhereClause(DataRow schemaRow) { PgDbType pgDbType = (PgDbType)schemaRow["ProviderType"]; if (!(bool)schemaRow["IsKey"]) { return false; } if (pgDbType == PgDbType.Binary) { return false; } if (pgDbType == PgDbType.Array) { return false; } return true; } private void BuildSchemaTable() { bool mustClose = false; if (this.SelectCommand == null) { throw new InvalidOperationException("The DataAdapter.SelectCommand property needs to be initialized."); } if (this.SelectCommand.Connection == null) { throw new InvalidOperationException("The DataAdapter.SelectCommand.Connection property needs to be initialized."); } if (this.schemaTable == null) { if (this.SelectCommand.Connection.State == ConnectionState.Closed) { mustClose = true; this.SelectCommand.Connection.Open(); } try { PgDataReader reader = SelectCommand.ExecuteReader(CommandBehavior.SchemaOnly); schemaTable = reader.GetSchemaTable(); reader.Close(); this.CheckSchemaTable(); } catch { throw; } finally { if (mustClose) { this.SelectCommand.Connection.Close(); } } } } private void CheckSchemaTable() { tableName = String.Empty; hasPrimaryKey = false; hasUniqueKey = false; foreach (DataRow schemaRow in schemaTable.Rows) { if (tableName.Length == 0) { tableName = (string)schemaRow["BaseSchemaName"] + "." + (string)schemaRow["BaseTableName"]; } if (!(bool)schemaRow["IsExpression"] && tableName != (string)schemaRow["BaseSchemaName"] + "." + (string)schemaRow["BaseTableName"]) { throw new InvalidOperationException("Dynamic SQL generation is not supported against multiple base tables."); } if ((bool)schemaRow["IsKey"]) { hasPrimaryKey = true; } if ((bool)schemaRow["IsUnique"]) { hasUniqueKey = true; } } } private string GetQuotedIdentifier(object identifier) { return quotePrefix + identifier.ToString() + quoteSuffix; } private void CreateCommand(ref PgCommand command) { if (command == null) { command = this.SelectCommand.Connection.CreateCommand(); } command.Transaction = this.SelectCommand.Transaction; command.CommandType = CommandType.Text; // ... [truncated message content] |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PgTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7345/Data/PgTypes Added Files: PgBox.cs PgCircle.cs PgLSeg.cs PgLine.cs PgPath.cs PgPoint.cs PgPolygon.cs PgTimeSpan.cs Log Message: Started the reorganization of the CVS module --- NEW FILE: PgTimeSpan.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgTimeSpan : IComparable { #region · Fields · private TimeSpan interval; #endregion #region · Properties · public int Days { get { return this.interval.Days; } } public int Hours { get { return this.interval.Hours; } } public int Milliseconds { get { return this.interval.Milliseconds; } } public int Minutes { get { return this.interval.Minutes; } } public int Seconds { get { return this.interval.Seconds; } } public TimeSpan Value { get { return interval; } } #endregion #region · Static Fields · public static readonly PgTimeSpan MaxValue = new PgTimeSpan(TimeSpan.MaxValue); public static readonly PgTimeSpan MinValue = new PgTimeSpan(TimeSpan.MinValue); public static readonly PgTimeSpan Null = new PgTimeSpan(TimeSpan.Zero); #endregion #region · Constructors · public PgTimeSpan(TimeSpan interval) { this.interval = interval; } #endregion #region · IComparable methods · public int CompareTo(object obj) { return interval.CompareTo(obj); } #endregion #region · Static Methods · public static bool GreatherThan(PgTimeSpan x, PgTimeSpan y) { return (x > y); } public static bool GreatherThanOrEqual(PgTimeSpan x, PgTimeSpan y) { return (x >= y); } public static bool LessThan(PgTimeSpan x, PgTimeSpan y) { return (x < y); } public static bool LessThanOrEqual(PgTimeSpan x, PgTimeSpan y) { return (x <= y); } public static bool NotEquals(PgTimeSpan x, PgTimeSpan y) { return (x != y); } public static PgTimeSpan Parse(string s) { return new PgTimeSpan(TimeSpan.Parse(s)); } #endregion #region · Operators · public static bool operator ==(PgTimeSpan left, PgTimeSpan right) { bool equals = false; if (left.Value == right.Value) { equals = true; } return equals; } public static bool operator !=(PgTimeSpan left, PgTimeSpan right) { bool notequals = false; if (left.Value != right.Value) { notequals = true; } return notequals; } public static bool operator >(PgTimeSpan left, PgTimeSpan right) { bool greater = false; if (left.Value > right.Value) { greater = true; } return greater; } public static bool operator >=(PgTimeSpan left, PgTimeSpan right) { bool greater = false; if (left.Value >= right.Value) { greater = true; } return greater; } public static bool operator <(PgTimeSpan left, PgTimeSpan right) { bool less = false; if (left.Value < right.Value) { less = true; } return less; } public static bool operator <=(PgTimeSpan left, PgTimeSpan right) { bool less = false; if (left.Value <= right.Value) { less = true; } return less; } public static explicit operator TimeSpan(PgTimeSpan x) { return x.Value; } public static explicit operator PgTimeSpan(string x) { return new PgTimeSpan(TimeSpan.Parse(x)); } #endregion #region · Overriden Methods · public override string ToString() { return interval.ToString(); } public override int GetHashCode() { return interval.GetHashCode(); } public override bool Equals(object obj) { if (obj != null && obj is PgTimeSpan) { return ((PgTimeSpan)obj) == this; } else { return false; } } #endregion } } --- NEW FILE: PgPoint.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgPoint { #region · Fields · private double x; private double y; #endregion #region · Properties · public double X { get { return x; } } public double Y { get { return y; } } #endregion #region · Constructors · public PgPoint(double x, double y) { this.x = x; this.y = y; } #endregion #region · Operators · public static bool operator ==(PgPoint left, PgPoint right) { if (left.X == right.X && left.Y == right.Y) { return true; } else { return true; } } public static bool operator !=(PgPoint left, PgPoint right) { if (left.X != right.X || left.Y != right.Y) { return true; } else { return true; } } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.AppendFormat("({0},{1})", this.x, this.y); return b.ToString(); } public override int GetHashCode() { return (this.x.GetHashCode() ^ this.y.GetHashCode()); } public override bool Equals(object obj) { if (obj != null && obj is PgPoint) { return ((PgPoint)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgPoint Parse(string s) { throw new NotSupportedException(); } #endregion } } --- NEW FILE: PgCircle.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgCircle { #region · Fields · private PgPoint center; private double radius; #endregion #region · Properties · public PgPoint Center { get { return center; } } public double Radius { get { return radius; } } #endregion #region · Constructors · public PgCircle(PgPoint center, double radius) { this.center = center; this.radius = radius; } public PgCircle(double x, double y, double radius) { this.center = new PgPoint(x, y); this.radius = radius; } #endregion #region · Operators · public static bool operator ==(PgCircle left, PgCircle right) { if (left.Center == right.Center && left.Radius == right.Radius) { return true; } else { return true; } } public static bool operator !=(PgCircle left, PgCircle right) { if (left.Center != right.Center || left.Radius != right.Radius) { return true; } else { return true; } } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.AppendFormat("<({0},{1}),{2}>", this.center.X, this.center.Y, this.radius); return b.ToString(); } public override int GetHashCode() { return this.center.GetHashCode() ^ this.radius.GetHashCode(); } public override bool Equals(object obj) { if (obj != null && obj is PgCircle) { return ((PgCircle)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgCircle Parse(string s) { throw new NotSupportedException(); } #endregion } } --- NEW FILE: PgPath.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgPath { #region · Fields · private PgPoint[] points; private bool isClosedPath; #endregion #region · Properties · public PgPoint[] Points { get { return points; } } public bool IsClosedPath { get { return isClosedPath; } } #endregion #region · Constructors · public PgPath(bool isClosedPath, PgPoint[] points) { this.isClosedPath = isClosedPath; this.points = (PgPoint[])points.Clone(); } #endregion #region · Operators · public static bool operator ==(PgPath left, PgPath right) { bool equals = false; if (left.Points.Length == right.Points.Length) { equals = true; for (int i = 0; i < left.Points.Length; i++) { if (left.Points[i] != right.Points[i]) { equals = false; break; } } } return equals; } public static bool operator !=(PgPath left, PgPath right) { bool notequals = true; if (left.Points.Length == right.Points.Length) { notequals = false; for (int i = 0; i < left.Points.Length; i++) { if (left.Points[i] != right.Points[i]) { notequals = true; break; } } } return notequals; } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.Append(this.isClosedPath ? "(" : "["); for (int i = 0; i < this.points.Length; i++) { if (b.Length > 1) { b.Append(","); } b.Append(this.points[i].ToString()); } b.Append(this.isClosedPath ? ")" : "]"); return b.ToString(); } public override int GetHashCode() { return (this.points.GetHashCode() ^ this.isClosedPath.GetHashCode()); } public override bool Equals(object obj) { if (obj != null && obj is PgPath) { return ((PgPath)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgPath Parse(string s) { throw new NotSupportedException(); } #endregion } } --- NEW FILE: PgBox.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgBox { #region · Fields · private PgPoint upperRight; private PgPoint lowerLeft; #endregion #region · Properties · public PgPoint UpperRight { get { return upperRight; } } public PgPoint LowerLeft { get { return lowerLeft; } } #endregion #region · Constructors · public PgBox(PgPoint lowerLeft, PgPoint upperRight) { this.lowerLeft = lowerLeft; this.upperRight = upperRight; } public PgBox(double x1, double y1, double x2, double y2) { this.lowerLeft = new PgPoint(x1, y1); this.upperRight = new PgPoint(x2, y2); } #endregion #region · Operators · public static bool operator ==(PgBox left, PgBox right) { if (left.UpperRight == right.UpperRight && left.LowerLeft == right.LowerLeft) { return true; } else { return false; } } public static bool operator !=(PgBox left, PgBox right) { if (left.UpperRight != right.UpperRight || left.LowerLeft != right.LowerLeft) { return true; } else { return false; } } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.AppendFormat("(({0},{1}),({2},{3}))", this.lowerLeft.X , this.lowerLeft.Y, this.upperRight.X , this.upperRight.Y); return b.ToString(); } public override int GetHashCode() { return (this.UpperRight.GetHashCode() ^ this.LowerLeft.GetHashCode()); } public override bool Equals(object obj) { if (obj is PgBox) { return ((PgBox)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgBox Parse(string s) { throw new NotSupportedException(); } #endregion } } --- NEW FILE: PgLSeg.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgLSeg { #region · Fields · private PgPoint startPoint; private PgPoint endPoint; #endregion #region · Properties · public PgPoint StartPoint { get { return startPoint; } } public PgPoint EndPoint { get { return endPoint; } } #endregion #region · Constructors · public PgLSeg(PgPoint startPoint, PgPoint endPoint) { this.startPoint = startPoint; this.endPoint = endPoint; } public PgLSeg(double x1, double y1, double x2, double y2) { this.startPoint = new PgPoint(x1, y1); this.endPoint = new PgPoint(x2, y2); } #endregion #region · Operators · public static bool operator ==(PgLSeg left, PgLSeg right) { if (left.StartPoint == right.StartPoint && left.EndPoint == right.EndPoint) { return true; } else { return false; } } public static bool operator !=(PgLSeg left, PgLSeg right) { if (left.StartPoint != right.StartPoint || left.EndPoint != right.EndPoint) { return true; } else { return false; } } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.AppendFormat("[({0},{1}),({2},{3})]", this.startPoint.X , this.startPoint.Y, this.endPoint.X , this.endPoint.Y); return b.ToString(); } public override int GetHashCode() { return (this.startPoint.GetHashCode() ^ this.endPoint.GetHashCode()); } public override bool Equals(object obj) { if (obj != null && obj is PgLSeg) { return ((PgLSeg)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgLSeg Parse(string s) { throw new NotSupportedException(); } #endregion } } --- NEW FILE: PgLine.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgLine { #region · Fields · private PgPoint startPoint; private PgPoint endPoint; #endregion #region · Properties · public PgPoint StartPoint { get { return startPoint; } } public PgPoint EndPoint { get { return endPoint; } } #endregion #region · Constructors · public PgLine(PgPoint startPoint, PgPoint endPoint) { this.startPoint = startPoint; this.endPoint = endPoint; } public PgLine(double x1, double y1, double x2, double y2) { this.startPoint = new PgPoint(x1, y1); this.endPoint = new PgPoint(x2, y2); } #endregion #region · Operators · public static bool operator ==(PgLine left, PgLine right) { if (left.StartPoint == right.StartPoint && left.EndPoint == right.EndPoint) { return true; } else { return false; } } public static bool operator !=(PgLine left, PgLine right) { if (left.StartPoint != right.StartPoint || left.EndPoint != right.EndPoint) { return true; } else { return false; } } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.AppendFormat("(({0},{1}),({2},{3}))", this.startPoint.X , this.startPoint.Y, this.endPoint.X , this.endPoint.Y); return b.ToString(); } public override int GetHashCode() { return this.startPoint.GetHashCode() ^ this.endPoint.GetHashCode(); } public override bool Equals(object obj) { if (obj != null && obj is PgLine) { return ((PgLine)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgLine Parse(string s) { throw new NotSupportedException(); } #endregion } } --- NEW FILE: PgPolygon.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.PgTypes { [Serializable] public struct PgPolygon { #region · Fields · private PgPoint[] points; #endregion #region · Properties · public PgPoint[] Points { get { return points; } } #endregion #region · Constructors · public PgPolygon(PgPoint[] points) { this.points = (PgPoint[])points.Clone(); } #endregion #region · Operators · public static bool operator ==(PgPolygon left, PgPolygon right) { bool equals = false; if (left.Points.Length == right.Points.Length) { equals = true; for (int i = 0; i < left.Points.Length; i++) { if (left.Points[i] != right.Points[i]) { equals = false; break; } } } return equals; } public static bool operator !=(PgPolygon left, PgPolygon right) { bool notequals = true; if (left.Points.Length == right.Points.Length) { notequals = false; for (int i = 0; i < left.Points.Length; i++) { if (left.Points[i] != right.Points[i]) { notequals = true; break; } } } return notequals; } #endregion #region · Overriden Methods · public override string ToString() { System.Text.StringBuilder b = new System.Text.StringBuilder(); b.Append("("); for (int i = 0; i < this.points.Length; i++) { if (b.Length > 1) { b.Append(","); } b.Append(this.points[i].ToString()); } b.Append(")"); return b.ToString(); } public override int GetHashCode() { return (this.points.GetHashCode()); } public override bool Equals(object obj) { if (obj != null && obj is PgPolygon) { return ((PgPolygon)obj) == this; } else { return false; } } #endregion #region · Static Methods · public static PgPolygon Parse(string s) { throw new NotSupportedException(); } #endregion } } |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:42:03
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Design/ParameterCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7345/Data/Design/ParameterCollection Added Files: PgParameterCollectionEditor.cs PgParameterConverter.cs Log Message: Started the reorganization of the CVS module --- NEW FILE: PgParameterConverter.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Globalization; using System.Reflection; namespace PostgreSql.Data.Design { internal class PgParameterConverter : TypeConverter { #region · Methods · public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is PgParameter) { PgParameter param = (PgParameter)value; ConstructorInfo ctor = typeof(PgParameter).GetConstructor( new Type[] {typeof(string) , typeof(PgDbType), typeof(int) , typeof(ParameterDirection), typeof(bool) , typeof(byte), typeof(byte) , typeof(string), typeof(DataRowVersion), typeof(object) }); if (ctor != null) { return new InstanceDescriptor(ctor, new object[] { param.ParameterName , param.PgDbType, param.Size , param.Direction, param.IsNullable , param.Precision, param.Scale , param.SourceColumn, param.SourceVersion , param.Value }); } } return base.ConvertTo(context, culture, value, destinationType); } #endregion } } --- NEW FILE: PgParameterCollectionEditor.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Globalization; using System.Reflection; namespace PostgreSql.Data.Design { internal class PgParameterCollectionEditor : System.ComponentModel.Design.CollectionEditor { #region · Fields · private PgParameterCollection parameters; #endregion #region · Methods · public PgParameterCollectionEditor(Type type) : base(type) { parameters = null; } protected override object CreateInstance(Type type) { PgParameter parameter = (PgParameter)base.CreateInstance(type); parameter.ParameterName = this.GenerateParameterName("Parameter"); return parameter; } public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { this.parameters = (PgParameterCollection)value; return base.EditValue(context, provider, value); } #endregion #region · Private Methods · private string GenerateParameterName(string prefix) { string parameterName = String.Empty; int index = parameters.Count + 1; bool valid = false; while (!valid) { parameterName = prefix + index.ToString(); if (parameters.IndexOf(parameterName) == -1) { valid = true; } index++; } return parameterName; } #endregion } } |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:40:58
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PgTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7093/PgTypes Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PgTypes added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:40:46
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PostgreSqlClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7035/PostgreSqlClient Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PostgreSqlClient added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:40:34
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6934/Protocol Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:39:39
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PgSqlClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6625/PgSqlClient Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PgSqlClient added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:39:09
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Design/ParameterCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6484/ParameterCollection Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Design/ParameterCollection added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:38:34
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Design In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6191/Design Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Design added to the repository |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/DbSchema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6002 Added Files: PgAggregatesSchema.cs PgCastsSchema.cs PgCheckConstraints.cs PgCheckConstraintsByTable.cs PgColumnsSchema.cs PgDatabaseSchema.cs PgDbSchema.cs PgDbSchemaFactory.cs PgDomainsSchema.cs PgForeignKeysSchema.cs PgFunctionPrivilegesSchema.cs PgFunctionsSchema.cs PgGroupsSchema.cs PgIndexesSchema.cs PgPrimaryKeysSchema.cs PgProviderTypesSchema.cs PgSchemataSchema.cs PgSqlLanguagesSchema.cs PgTableConstraintsSchema.cs PgTablePrivilegesSchema.cs PgTablesSchema.cs PgTableStatisticsSchema.cs PgTriggersSchema.cs PgUsersSchema.cs PgViewPrivilegesSchema.cs PgViewsSchema.cs Log Message: Started the reorganization of the CVS module --- NEW FILE: PgCastsSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgCastsSchema : PgDbSchema { #region · Constructors · public PgCastsSchema() : base("Casts") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_cast"); } public override void AddRestrictionColumns() { } public override void AddDataColumns() { AddDataColumn("pg_typesrc.typname" , "SOURCE_TYPE"); AddDataColumn("pg_typetgt.typname" , "TARGET_TYPE"); AddDataColumn("pg_namespace.nspname", "FUNCTION_SCHEMA"); AddDataColumn("pg_proc.proname" , "FUNCTION_NAME"); AddDataColumn(this.GetContextExpression("pg_cast.castcontext"), "CAST_CONTEXT"); } public override void AddJoins() { AddJoin("left join", "pg_type as pg_typesrc", "pg_cast.castsource = pg_typesrc.oid"); AddJoin("left join", "pg_type as pg_typetgt", "pg_cast.casttarget = pg_typetgt.oid"); AddJoin("left join", "pg_proc" , "pg_cast.castfunc = pg_proc.oid"); AddJoin("left join", "pg_namespace" , "pg_proc.pronamespace = pg_namespace.oid"); } public override void AddOrderByColumns() { AddOrderBy("pg_proc.proname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion #region · Private Methods · private string GetContextExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'e' THEN 'EXPLICIT'"); expression.Append(" when 'a' THEN 'ASSIGNMENT'"); expression.Append(" when 'i' THEN 'EXPRESSIONS'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgTriggersSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgTriggersSchema : PgDbSchema { #region · Constructors · public PgTriggersSchema() : base("Triggers") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_trigger"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "TRIGGER_SCHEMA", null); AddRestrictionColumn("pg_proc.proname" , "TRIGGER_NAME", null); AddRestrictionColumn("pg_class.relnamespace", "TABLE_SCHEMA", null); AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_language.lanname" , "PROCEDURE_LANGUAGE"); AddDataColumn("pg_proc.proisagg" , "IS_AGGREGATE"); AddDataColumn("pg_proc.prosecdef" , "IS_SECURITY_DEFINER"); AddDataColumn("pg_proc.proisstrict" , "IS_STRICT"); AddDataColumn("pg_proc.proretset" , "RETURNS_SET"); } public override void AddJoins() { AddJoin("left join", "pg_class" , "pg_trigger.tgconstrrelid = pg_class.oid"); AddJoin("left join", "pg_proc" , "pg_trigger.tgfoid = pg_proc.oid"); AddJoin("left join", "pg_namespace" , "pg_proc.pronamespace = pg_namespace.oid"); AddJoin("left join", "pg_language" , "pg_proc.prolang = pg_language.oid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_proc.proname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgProviderTypesSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgProviderTypesSchema : PgDbSchema { #region · Constructors · public PgProviderTypesSchema() : base("ProviderTypes") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_type"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname", "TYPE_SCHEMA", null); AddRestrictionColumn("pg_type.typname", "TYPE_NAME", null); AddRestrictionColumn("pg_type.oid", "DATA_TYPE", null); } public override void AddDataColumns() { AddDataColumn("pg_type.typlen", "COLUMN_SIZE"); AddDataColumn("pg_type.typnotnull", "IS_NOT_NULL"); AddDataColumn("pg_type.typndims", "ARRAY_DIMENSIONS"); AddDataColumn("pg_type.typelem", "ELEMENT_TYPE"); AddDataColumn("pg_type.typbasetype", "BASE_TYPE"); AddDataColumn("pg_type.typtypmod", "BASE_TYPE_MODIFIER"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_namespace", "pg_type.typnamespace = pg_namespace.oid"); AddJoin("left join", "pg_description", "pg_type.oid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_type.typname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgIndexesSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgIndexesSchema : PgDbSchema { #region · Constructors · public PgIndexesSchema() : base("Indexes") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_index"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "TABLE_SCHEMA", null); AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); AddRestrictionColumn("pg_classidx.relname" , "INDEX_NAME", null); } public override void AddDataColumns() { AddDataColumn("Pgnamespidx.nspname" , "INDEX_SCHEMA"); AddDataColumn("pg_am.amname" , "TYPE"); AddDataColumn("pg_index.indkey" , "INDEX_KEY"); AddDataColumn("pg_index.indisclustered" , "CLUSTERED"); AddDataColumn("pg_index.indisunique" , "UNIQUE"); AddDataColumn("pg_index.indisprimary" , "PRIMARY"); AddDataColumn("pg_am.amindexnulls" , "ALLOW_NULLS"); AddDataColumn("pg_am.amcanmulticol" , "MULTICOLUMN"); AddDataColumn("pg_am.amconcurrent" , "CONCURRENT"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_class", "pg_index.indrelid = pg_class.oid"); AddJoin("left join", "pg_class as pg_classidx", "pg_index.indexrelid = pg_classidx.oid"); AddJoin("left join", "pg_namespace", "pg_classidx.relnamespace = pg_namespace.oid"); AddJoin("left join", "pg_namespace as Pgnamespidx", "pg_classidx.relnamespace = Pgnamespidx.oid"); AddJoin("left join", "pg_am", "pg_classidx.relam = pg_am.oid"); AddJoin("left join", "pg_description", "pg_index.indexrelid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_class.relname"); AddOrderBy("pg_classidx.relname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgTablePrivilegesSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; using System.Text.RegularExpressions; namespace PostgreSql.Data.DbSchema { internal class PgTablePrivilegesSchema : PgDbSchema { #region · Constructors · public PgTablePrivilegesSchema() : base("Table_Privileges") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_class"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "TABLE_SCHEMA", null); AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_class.relacl", "PRIVILEGES"); } public override void AddJoins() { AddJoin("left join", "pg_namespace", "pg_class.relnamespace = pg_namespace.oid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_class.relname"); } public override void AddWhereFilters() { AddWhereFilter("pg_class.relkind = 'r'"); } #endregion #region · Overriden Methods · public override DataTable GetSchema(PgConnection connection, string[] restrictions) { DataTable tablesSchema= base.GetSchema(connection, restrictions); DataTable privileges = this.GetPrivilegesDataTable(); privileges.BeginLoadData(); foreach (DataRow row in tablesSchema.Rows) { if (row["PRIVILEGES"] != System.DBNull.Value) { PgPrivilege[] priv = DecodePrivileges((string[])row["PRIVILEGES"]); for (int i = 0; i < priv.Length; i++) { DataRow newRow = privileges.NewRow(); newRow["TABLE_SCHEMA"] = row["TABLE_SCHEMA"]; newRow["TABLE_NAME"] = row["TABLE_NAME"]; newRow["USER_NAME"] = priv[i].User; FillPrivileges(newRow, priv[i].Privileges); privileges.Rows.Add(newRow); } } } privileges.EndLoadData(); return privileges; } private DataTable GetPrivilegesDataTable() { DataTable privileges = new DataTable("Table_Privileges"); privileges.BeginInit(); privileges.Columns.Add("TABLE_SCHEMA", Type.GetType("System.String")); privileges.Columns.Add("TABLE_NAME", Type.GetType("System.String")); privileges.Columns.Add("USER_NAME", Type.GetType("System.String")); AddPrivilegesColumns(privileges); privileges.EndInit(); return privileges; } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { return restrictions; } #endregion } } --- NEW FILE: PgFunctionPrivilegesSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgFunctionPrivilegesSchema : PgDbSchema { #region · Constructors · public PgFunctionPrivilegesSchema() : base("Function_Privileges") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_proc"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "FUNCTION_SCHEMA", null); AddRestrictionColumn("pg_proc.proname" , "FUNCTION_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_proc.proacl", "PRIVILEGES"); } public override void AddJoins() { AddJoin("left join", "pg_namespace" , "pg_proc.pronamespace = pg_namespace.oid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_proc.proname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion #region · Overriden Methods · public override DataTable GetSchema(PgConnection connection, string[] restrictions) { DataTable functionsSchema = base.GetSchema(connection, restrictions); DataTable privileges = this.GetPrivilegesDataTable(); privileges.BeginLoadData(); foreach (DataRow row in functionsSchema.Rows) { if (row["PRIVILEGES"] != System.DBNull.Value) { PgPrivilege[] priv = this.DecodePrivileges((string[])row["PRIVILEGES"]); for (int i = 0; i < priv.Length; i++) { DataRow newRow = privileges.NewRow(); newRow["FUNCTION_SCHEMA"] = row["FUNCTION_SCHEMA"]; newRow["FUNCTION_NAME"] = row["FUNCTION_NAME"]; newRow["USER_NAME"] = priv[i].User; this.FillPrivileges(newRow, priv[i].Privileges); privileges.Rows.Add(newRow); } } } privileges.EndLoadData(); return privileges; } private DataTable GetPrivilegesDataTable() { DataTable privileges = new DataTable("Function_Privileges"); privileges.BeginInit(); privileges.Columns.Add("FUNCTION_SCHEMA", Type.GetType("System.String")); privileges.Columns.Add("FUNCTION_NAME" , Type.GetType("System.String")); privileges.Columns.Add("USER_NAME" , Type.GetType("System.String")); this.AddPrivilegesColumns(privileges); privileges.EndInit(); return privileges; } #endregion #region · Private Methods · private string GetVolatileExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'i' THEN 'INMUTABLE'"); expression.Append(" when 's' THEN 'STABLE'"); expression.Append(" when 'v' THEN 'VOLATILE'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgUsersSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgUsersSchema : PgDbSchema { #region · Constructors · public PgUsersSchema() : base("Users") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_shadow"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_shadow.usename", "USER_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_shadow.usecreatedb", "CREATE_DATABASE"); AddDataColumn("pg_shadow.usesuper", "IS_SUPERUSER"); AddDataColumn("pg_shadow.usecatupd", "UPDATE_SYSCATALOGS"); AddDataColumn("pg_shadow.passwd", "PASSWORD"); AddDataColumn("pg_shadow.useconfig", "CONFIGURATION"); } public override void AddJoins() { } public override void AddOrderByColumns() { AddOrderBy("pg_shadow.usename"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgForeignKeysSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgForeignKeysSchema : PgDbSchema { #region · Constructors · public PgForeignKeysSchema() : base("ForeignKeys") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_constraint"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "PK_TABLE_SCHEMA", null); AddRestrictionColumn("pk_table.relname" , "PK_TABLE_NAME", null); AddRestrictionColumn("pg_namespace.nspname" , "FK_TABLE_SCHEMA", null); AddRestrictionColumn("fk_table.relname" , "FK_TABLE_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_constraint.conkey" , "PK_COLUMNS"); AddDataColumn("pg_constraint.confkey" , "FK_COLUMNS"); AddDataColumn(this.GetRuleExpression("pg_constraint.confupdtype"), "UPDATE_RULE"); AddDataColumn(this.GetRuleExpression("pg_constraint.confdeltype"), "DELETE_RULE"); AddDataColumn("pg_constraint.conname" , "FK_NAME"); AddDataColumn("pg_constraint.condeferrable" , "DEFERRABILITY"); AddDataColumn("pg_constraint.condeferred" , "IS_DEFERRED"); AddDataColumn("pg_description.description" , "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join" , "pg_namespace", "pg_constraint.connamespace = pg_namespace.oid"); AddJoin("left join" , "pg_class as pk_table", "pg_constraint.conrelid = pk_table.oid"); AddJoin("right join", "pg_class as fk_table", "pg_constraint.confrelid = fk_table.oid"); AddJoin("left join" , "pg_description", "pg_constraint.oid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pk_table.relname"); AddOrderBy("pg_constraint.conname"); } public override void AddWhereFilters() { // Get Only Primary Key information AddWhereFilter("pg_constraint.contype = 'f'"); } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion #region · Private Methods · private string GetRuleExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'a' THEN 'NO ACTION'"); expression.Append(" when 'r' THEN 'RESTRICT'"); expression.Append(" when 'c' THEN 'CASCADE'"); expression.Append(" when 'd' THEN 'SET DEFAULT'"); expression.Append(" when 'n' THEN 'SET NULL'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgFunctionsSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgFunctionsSchema : PgDbSchema { #region · Constructors · public PgFunctionsSchema() : base("Functions") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_proc"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "FUNCTION_SCHEMA", null); AddRestrictionColumn("pg_proc.proname" , "FUNCTION_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_language.lanname" , "PROCEDURE_LANGUAGE"); AddDataColumn("pg_proc.proisagg" , "IS_AGGREGATE"); AddDataColumn("pg_proc.prosecdef" , "IS_SECURITY_DEFINER"); AddDataColumn("pg_proc.proisstrict" , "IS_STRICT"); AddDataColumn(this.GetVolatileExpression("pg_proc.provolatile"), "VOLATILE"); AddDataColumn("pg_proc.proretset" , "RETURNS_SET"); AddDataColumn("pg_proc.prorettype" , "RETURN_TYPE"); AddDataColumn("pg_proc.pronargs" , "ARGUMENT_NUMBER"); AddDataColumn("pg_proc.proargtypes" , "ARGUMENTS"); AddDataColumn("pg_proc.prosrc" , "SOURCE"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_namespace" , "pg_proc.pronamespace = pg_namespace.oid"); AddJoin("left join", "pg_language" , "pg_proc.prolang = pg_language.oid"); AddJoin("left join", "pg_description", "pg_proc.oid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_proc.proname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion #region · Private Methods · private string GetVolatileExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'i' THEN 'INMUTABLE'"); expression.Append(" when 's' THEN 'STABLE'"); expression.Append(" when 'v' THEN 'VOLATILE'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgCheckConstraints.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgCheckConstraintsSchema : PgDbSchema { #region · Constructors · public PgCheckConstraintsSchema() : base("CheckConstraints") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_constraint"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname", "CONSTRAINT_SCHEMA", null); AddRestrictionColumn("pg_constraint.conname", "CONSTRAINT_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_get_constraintdef(pg_constraint.oid)", "CHECK_CLAUSULE"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_namespace" , "pg_constraint.connamespace = pg_namespace.oid"); AddJoin("left join", "pg_description" , "pg_constraint.oid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_constraint.conname"); } public override void AddWhereFilters() { AddWhereFilter("pg_constraint.contype = 'c'"); } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; if (parsed != null) { if (parsed.Length == 7 && parsed[6] != null) { switch (parsed[6].ToString().ToUpper()) { case "UNIQUE": parsed[3] = "u"; break; case "PRIMARY KEY": parsed[3] = "p"; break; case "FOREIGN KEY": parsed[3] = "f"; break; case "CHECK": parsed[3] = "c"; break; } } } return parsed; } #endregion #region · Private Methods · private string GetConstraintTypeExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'u' THEN 'UNIQUE'"); expression.Append(" when 'p' THEN 'PRIMARY KEY'"); expression.Append(" when 'f' THEN 'FOREIGN KEY'"); expression.Append(" when 'c' THEN 'CHECK'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgColumnsSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgColumnsSchema : PgDbSchema { #region · Constructors · public PgColumnsSchema() : base("Columns") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_attribute"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "TABLE_SCHEMA", null); AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); AddRestrictionColumn("pg_attribute.attname" , "COLUMN_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_attribute.atttypid" , "DATA_TYPE"); AddDataColumn("pg_attribute.attlen" , "COLUMN_SIZE"); AddDataColumn("pg_attribute.attndims" , "COLUMN_DIMENSIONS"); AddDataColumn("pg_attribute.attnum" , "ORDINAL_POSITION"); AddDataColumn("pg_attribute.atthasdef" , "HAS_DEFAULT"); AddDataColumn("pg_attrdef.adsrc" , "COLUMN_DEFAULT"); AddDataColumn("pg_attribute.attnotnull" , "IS_NOT_NULL"); AddDataColumn("(pg_depend.objid is not null)", "IS_AUTOINCREMENT"); AddDataColumn(this.GetStorageExpression("pg_attribute.attstorage"), "STORAGE"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_class" , "pg_attribute.attrelid = pg_class.oid"); AddJoin("left join", "pg_namespace" , "pg_class.relnamespace = pg_namespace.oid"); AddJoin("left join", "pg_attrdef" , "(pg_class.oid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum)"); AddJoin("left join", "pg_description", "(pg_attribute.attrelid = pg_description.objoid AND pg_attribute.attnum = pg_description.objsubid)"); AddJoin("left join", "pg_depend", "(pg_attribute.attrelid = pg_depend.refobjid AND pg_attribute.attnum = pg_depend.refobjsubid AND pg_depend.deptype = 'i')"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_class.relname"); AddOrderBy("pg_attribute.attnum"); } public override void AddWhereFilters() { // Do not get dropped columns AddWhereFilter("pg_attribute.attisdropped = false"); // Get only columns with a number > 0 AddWhereFilter("pg_attribute.attnum > 0"); } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion #region · Private Methods · private string GetSerialExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 0 THEN true"); expression.Append(" default THEN false"); expression.Append(" END "); return expression.ToString(); } private string GetStorageExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'p' THEN 'PLAIN'"); expression.Append(" when 'e' THEN 'EXTERNAL'"); expression.Append(" when 'm' THEN 'MAIN'"); expression.Append(" when 'x' THEN 'EXTENDED'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgGroupsSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgGroupsSchema : PgDbSchema { #region · Constructors · public PgGroupsSchema() : base("Groups") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_group"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_group.groname", "GROUP_NAME", null); } public override void AddDataColumns() { AddRestrictionColumn("pg_group.grolist", "GROUP_USERS", null); } public override void AddJoins() { } public override void AddOrderByColumns() { AddOrderBy("pg_group.groname"); } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgDbSchemaFactory.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; namespace PostgreSql.Data.DbSchema { internal class PgDbSchemaFactory { public static PgDbSchema GetSchema(string collectionName) { PgDbSchema returnSchema = null; switch (collectionName.ToLower()) { case "aggregates": returnSchema = new PgAggregatesSchema(); break; case "casts": returnSchema = new PgCastsSchema(); break; case "checkconstraints": returnSchema = new PgCheckConstraintsSchema(); break; case "checkconstraintsbytable": returnSchema = new PgCheckConstraintsByTableSchema(); break; case "columns": returnSchema = new PgColumnsSchema(); break; case "database": returnSchema = new PgDatabaseSchema(); break; case "domains": returnSchema = new PgDomainsSchema(); break; case "foreignkeys": returnSchema = new PgForeignKeysSchema(); break; case "groups": returnSchema = new PgGroupsSchema(); break; case "indexes": returnSchema = new PgIndexesSchema(); break; case "primarykeys": returnSchema = new PgPrimaryKeysSchema(); break; case "functionprivileges": returnSchema = new PgFunctionPrivilegesSchema(); break; case "functions": returnSchema = new PgFunctionsSchema(); break; case "providertypes": returnSchema = new PgProviderTypesSchema(); break; case "schemata": returnSchema = new PgSchemataSchema(); break; case "sqllanguages": returnSchema = new PgSqlLanguagesSchema(); break; case "statistics": break; case "tables": returnSchema = new PgTablesSchema(); break; case "tableconstraint": returnSchema = new PgTableConstraintsSchema(); break; case "tablesinfo": break; case "tableprivileges": returnSchema = new PgTablePrivilegesSchema(); break; case "tablestatistics": break; case "triggers": returnSchema = new PgTriggersSchema(); break; case "users": returnSchema = new PgUsersSchema(); break; case "views": returnSchema = new PgViewsSchema(); break; case "viewprivileges": returnSchema = new PgViewPrivilegesSchema(); break; } return returnSchema; } } } --- NEW FILE: PgCheckConstraintsByTable.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgCheckConstraintsByTableSchema : PgDbSchema { #region · Constructors · public PgCheckConstraintsByTableSchema() : base("CheckConstraintsByTable") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_constraint"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "CONSTRAINT_SCHEMA" , null); AddRestrictionColumn("pg_constraint.conname", "CONSTRAINT_NAME" , null); AddRestrictionColumn("tbn.nspname" , "TABLE_SCHEMA" , null); AddRestrictionColumn("pg_class.relname" , "TABLE_NAME" , null); } public override void AddDataColumns() { AddDataColumn("pg_get_constraintdef(pg_constraint.oid)", "CHECK_CLAUSULE"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_class" , "pg_class.oid = pg_constraint.conrelid"); AddJoin("left join", "pg_namespace tbn" , "pg_class.relnamespace = tbn.oid"); AddJoin("left join", "pg_namespace" , "pg_constraint.connamespace = pg_namespace.oid"); AddJoin("left join", "pg_description" , "pg_constraint.oid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_class.relname"); AddOrderBy("pg_constraint.conname"); } public override void AddWhereFilters() { AddWhereFilter("pg_constraint.contype = 'c'"); AddWhereFilter("pg_class.relkind = 'r'"); } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; if (parsed != null) { if (parsed.Length == 7 && parsed[6] != null) { switch (parsed[6].ToString().ToUpper()) { case "UNIQUE": parsed[3] = "u"; break; case "PRIMARY KEY": parsed[3] = "p"; break; case "FOREIGN KEY": parsed[3] = "f"; break; case "CHECK": parsed[3] = "c"; break; } } } return parsed; } #endregion #region · Private Methods · private string GetConstraintTypeExpression(string fieldName) { StringBuilder expression = new StringBuilder(); expression.AppendFormat(" case {0} ", fieldName); expression.Append(" when 'u' THEN 'UNIQUE'"); expression.Append(" when 'p' THEN 'PRIMARY KEY'"); expression.Append(" when 'f' THEN 'FOREIGN KEY'"); expression.Append(" when 'c' THEN 'CHECK'"); expression.Append(" END "); return expression.ToString(); } #endregion } } --- NEW FILE: PgPrimaryKeysSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgPrimaryKeysSchema : PgDbSchema { #region · Constructors · public PgPrimaryKeysSchema() : base("PrimaryKeys") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_constraint"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_namespace.nspname" , "TABLE_SCHEMA", null); AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_constraint.conname" , "PK_NAME"); AddDataColumn("pg_constraint.conkey" , "PK_COLUMNS"); AddDataColumn("pg_description.description", "DESCRIPTION"); } public override void AddJoins() { AddJoin("left join", "pg_class", "pg_constraint.conrelid = pg_class.oid"); AddJoin("left join", "pg_namespace", "pg_constraint.connamespace = pg_namespace.oid"); AddJoin("left join", "pg_description", "pg_constraint.oid = pg_description.objoid"); } public override void AddOrderByColumns() { AddOrderBy("pg_namespace.nspname"); AddOrderBy("pg_class.relname"); AddOrderBy("pg_constraint.conname"); } public override void AddWhereFilters() { // Get Only Primary Key information AddWhereFilter("pg_constraint.contype = 'p'"); } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgDbSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; using System.Text.RegularExpressions; using System.Collections; namespace PostgreSql.Data.DbSchema { #region Structures internal struct PgColumn { public string ColumnName; public string ColumnAlias; public string WhereColumnName; } internal struct PgTableJoin { public string JoinType; public string RightTable; public string Expression; } internal struct PgPrivilege { public string User; public MatchCollection Privileges; } #endregion internal abstract class PgDbSchema { #region · Fields · private ArrayList restrictionColumns; private ArrayList dataColumns; private ArrayList tables; private ArrayList joins; private ArrayList orderByColumns; private ArrayList whereFilters; private string tableName; #endregion #region · Properties · public ArrayList RestrictionColumns { get { return restrictionColumns; } } #endregion #region · Constructors · public PgDbSchema() { this.restrictionColumns = new ArrayList(); this.dataColumns = new ArrayList(); this.tables = new ArrayList(); this.joins = new ArrayList(); this.orderByColumns = new ArrayList(); this.whereFilters = new ArrayList(); this.AddTables(); this.AddRestrictionColumns(); this.AddDataColumns(); this.AddJoins(); this.AddOrderByColumns(); this.AddWhereFilters(); } public PgDbSchema(string tableName) : this() { this.tableName = tableName; } #endregion #region Abstract Methods public abstract void AddTables(); public abstract void AddRestrictionColumns(); public abstract void AddDataColumns(); public abstract void AddJoins(); public abstract void AddOrderByColumns(); public abstract void AddWhereFilters(); public abstract string[] ParseRestrictions(string[] restrictions); #endregion #region · Add Methods · public void AddTable(string tableName) { tables.Add(tableName); } public void AddRestrictionColumn(string columnName, string columnAlias, string whereColumnName) { PgColumn column = new PgColumn(); column.ColumnName = columnName; column.ColumnAlias = columnAlias; if (whereColumnName != null) { column.WhereColumnName = whereColumnName; } else { column.WhereColumnName = columnName; } restrictionColumns.Add(column); } public void AddDataColumn(string columnName, string columnAlias) { PgColumn column = new PgColumn(); column.ColumnName = columnName; column.ColumnAlias = columnAlias; dataColumns.Add(column); } public void AddJoin(string joinType, string rightTable, string expression) { PgTableJoin join = new PgTableJoin(); join.JoinType = joinType; join.RightTable = rightTable; join.Expression = expression; joins.Add(join); } public void AddOrderBy(string column) { orderByColumns.Add(column); } public void AddWhereFilter(string filter) { whereFilters.Add(filter); } #endregion #region · Methods · public virtual DataTable GetSchema(PgConnection connection, string[] restrictions) { restrictions = this.ParseRestrictions(restrictions); DataSet dataSet = null; PgDataAdapter adapter = null; PgCommand command = new PgCommand(); try { command.Connection = connection; command.CommandText = GetCommandText(restrictions); if (connection.InternalConnection.HasActiveTransaction) { command.Transaction = connection.InternalConnection.ActiveTransaction; } adapter = new PgDataAdapter(command); dataSet = new DataSet(tableName); adapter.Fill(dataSet, tableName); } catch (PgException pgex) { throw pgex; } catch (Exception ex) { throw new PgException(ex.Message); } finally { command.Dispose(); adapter.Dispose(); } return dataSet.Tables[tableName]; } public string GetCommandText(object[] restrictions) { StringBuilder sql = new StringBuilder(); // Add restriction columns sql.Append("SELECT "); foreach (PgColumn column in restrictionColumns) { sql.AppendFormat("{0} AS {1}", column.ColumnName, column.ColumnAlias); if ((restrictionColumns.IndexOf(column) + 1) < restrictionColumns.Count) { sql.Append(", "); } } // Add DataColumns if (restrictionColumns.Count > 0 && dataColumns.Count > 0) { sql.Append(", "); } foreach (PgColumn column in dataColumns) { sql.AppendFormat("{0} AS {1}", column.ColumnName, column.ColumnAlias); if ((dataColumns.IndexOf(column) + 1) < dataColumns.Count) { sql.Append(", "); } } // Add tables sql.Append(" FROM "); foreach (string table in tables) { sql.Append(table); if ((tables.IndexOf(table) + 1) < tables.Count) { sql.Append(", "); } } if (joins.Count != 0) { foreach (PgTableJoin join in joins) { sql.AppendFormat(" {0} {1} ON {2}", join.JoinType, join.RightTable, join.Expression); } } // Add restrictions StringBuilder whereFilter = new StringBuilder(); if (restrictions != null && restrictions.Length > 0) { for (int i = 0; i < restrictions.Length; i++) { if (restrictions[i] != null) { if (whereFilter.Length > 0) { whereFilter.Append(" AND "); } whereFilter.AppendFormat("{0} = '{1}'", ((PgColumn)restrictionColumns[i]).WhereColumnName, restrictions[i]); } } } if (whereFilters != null && whereFilters.Count > 0) { foreach (string condition in whereFilters) { if (whereFilter.Length > 0) { whereFilter.Append(" AND "); } whereFilter.Append(condition); } } if (whereFilter.Length > 0) { sql.AppendFormat(" WHERE {0}", whereFilter); } // Add Order By if (orderByColumns.Count > 0) { sql.Append(" ORDER BY "); foreach (string columnName in orderByColumns) { sql.Append(columnName); if ((orderByColumns.IndexOf(columnName) + 1) < orderByColumns.Count) { sql.Append(", "); } } } return sql.ToString(); } #endregion #region Protected Methods protected void AddPrivilegesColumns(DataTable table) { table.Columns.Add("INSERT", Type.GetType("System.Boolean")); table.Columns["INSERT"].DefaultValue = false; table.Columns.Add("INSERT_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["INSERT_WITH_GRANT"].DefaultValue = false; table.Columns.Add("SELECT", Type.GetType("System.Boolean")); table.Columns["SELECT"].DefaultValue = false; table.Columns.Add("SELECT_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["SELECT_WITH_GRANT"].DefaultValue = false; table.Columns.Add("UPDATE", Type.GetType("System.Boolean")); table.Columns["UPDATE"].DefaultValue = false; table.Columns.Add("UPDATE_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["UPDATE_WITH_GRANT"].DefaultValue = false; table.Columns.Add("DELETE", Type.GetType("System.Boolean")); table.Columns["DELETE"].DefaultValue = false; table.Columns.Add("DELETE_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["DELETE_WITH_GRANT"].DefaultValue = false; table.Columns.Add("RULE", Type.GetType("System.Boolean")); table.Columns["RULE"].DefaultValue = false; table.Columns.Add("RULE_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["RULE_WITH_GRANT"].DefaultValue = false; table.Columns.Add("REFERENCES", Type.GetType("System.Boolean")); table.Columns["REFERENCES"].DefaultValue = false; table.Columns.Add("REFERENCES_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["REFERENCES_WITH_GRANT"].DefaultValue = false; table.Columns.Add("TRIGGER", Type.GetType("System.Boolean")); table.Columns["TRIGGER"].DefaultValue = false; table.Columns.Add("TRIGGER_WITH_GRANT", Type.GetType("System.Boolean")); table.Columns["TRIGGER_WITH_GRANT"].DefaultValue = false; } protected PgPrivilege[] DecodePrivileges(string[] acl) { Regex search = new Regex(@"((a|r|w|d|R|x|t)\*?)"); PgPrivilege[] priv = new PgPrivilege[acl.Length]; for (int i = 0; i < acl.Length; i++) { priv[i].User = acl[i].Split('=')[0]; if (priv[i].User.Length == 0) { priv[i].User = "PUBLIC"; } string aclitem = acl[i].Split('=')[1]; aclitem = aclitem.Split('/')[0]; priv[i].Privileges = search.Matches(aclitem); } return priv; } protected void FillPrivileges(DataRow row, MatchCollection privileges) { foreach (Match privilege in privileges) { switch (privilege.Value) { case "a": case "a*": row["INSERT"] = true; if (privilege.Value.IndexOf("*") != -1) { row["INSERT_WITH_GRANT"] = true; } break; case "r": case "r*": row["SELECT"] = true; if (privilege.Value.IndexOf("*") != -1) { row["SELECT_WITH_GRANT"] = true; } break; case "w": case "w*": row["UPDATE"] = true; if (privilege.Value.IndexOf("*") != -1) { row["UPDATE_WITH_GRANT"] = true; } break; case "d": case "d*": row["DELETE"] = true; if (privilege.Value.IndexOf("*") != -1) { row["DELETE_WITH_GRANT"] = false; } break; case "R": case "R*": row["RULE"] = true; if (privilege.Value.IndexOf("*") != -1) { row["RULE_WITH_GRANT"] = true; } break; case "x": case "x*": row["REFERENCES"] = true; if (privilege.Value.IndexOf("*") != -1) { row["REFERENCES_WITH_GRANT"] = true; } break; case "t": case "t*": row["TRIGGER"] = true; if (privilege.Value.IndexOf("*") != -1) { row["TRIGGER_WITH_GRANT"] = true; } break; } } } #endregion } } --- NEW FILE: PgDatabaseSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgDatabaseSchema : PgDbSchema { #region · Constructors · public PgDatabaseSchema() : base("Database") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_database"); } public override void AddRestrictionColumns() { AddRestrictionColumn("pg_database.datname", "DATABASE_NAME", null); } public override void AddDataColumns() { AddDataColumn("pg_database.datistemplate" , "IS_TEMPLATE"); AddDataColumn("pg_database.datallowconn" , "ALLOW_CONNECTION"); AddDataColumn("pg_database.datconfig" , "DATABASE_CONFIG"); } public override void AddJoins() { } public override void AddOrderByColumns() { } public override void AddWhereFilters() { } #endregion #region · Parse Methods · public override string[] ParseRestrictions(string[] restrictions) { string[] parsed = restrictions; return parsed; } #endregion } } --- NEW FILE: PgSqlLanguagesSchema.cs --- /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * Copyright (c) 2003-2005 Carlos Guzman Alvarez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using System; using System.Data; using System.Text; namespace PostgreSql.Data.DbSchema { internal class PgSqlLanguagesSchema : PgDbSchema { #region · Constructors · public PgSqlLanguagesSchema() : base("SqlLanguages") { } #endregion #region · Add Methods · public override void AddTables() { AddTable("pg_language"); } public override void AddRestrictionColumns() { } public override void AddDataColumns() { AddDataColumn("pg_language.lanname", ... [truncated message content] |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:37:22
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/DbSchema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5852/DbSchema Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/DbSchema added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:37:05
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5715/Data Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:36:48
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5616/PostgreSql Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:36:29
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5545/source Log Message: Directory /cvsroot/pgsqlclient/pgsqlclient_10/source added to the repository |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:36:07
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5426/PostgreSql.Data.PgSqlClient.UnitTests Removed Files: PostgreSql.Data.PgSqlClient.UnitTests.dll.config Log Message: Started the reorganization of the CVS module --- PostgreSql.Data.PgSqlClient.UnitTests.dll.config DELETED --- |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:35:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient/source/PgTypes Removed Files: PgBox.cs PgCircle.cs PgLSeg.cs PgLine.cs PgPath.cs PgPoint.cs PgPolygon.cs PgTimeSpan.cs Log Message: Started the reorganization of the CVS module --- PgTimeSpan.cs DELETED --- --- PgPoint.cs DELETED --- --- PgCircle.cs DELETED --- --- PgPath.cs DELETED --- --- PgBox.cs DELETED --- --- PgLSeg.cs DELETED --- --- PgLine.cs DELETED --- --- PgPolygon.cs DELETED --- |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:35:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient.UnitTests/source Removed Files: AssemblyInfo.cs PgArrayTest.cs PgBaseTest.cs PgCommandBuilderTest.cs PgCommandTest.cs PgConnectionTest.cs PgDataAdapterTest.cs PgDataReaderTest.cs PgDatabaseSchemaTest.cs PgGeometicTypesTest.cs PgTransactionTest.cs Log Message: Started the reorganization of the CVS module --- PgGeometicTypesTest.cs DELETED --- --- PgDataAdapterTest.cs DELETED --- --- PgCommandBuilderTest.cs DELETED --- --- PgDatabaseSchemaTest.cs DELETED --- --- AssemblyInfo.cs DELETED --- --- PgBaseTest.cs DELETED --- --- PgArrayTest.cs DELETED --- --- PgCommandTest.cs DELETED --- --- PgDataReaderTest.cs DELETED --- --- PgConnectionTest.cs DELETED --- --- PgTransactionTest.cs DELETED --- |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:35:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/Resources/ToolBox In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient/source/Resources/ToolBox Removed Files: PgCommand.bmp PgConnection.bmp PgDataAdapter.bmp Log Message: Started the reorganization of the CVS module --- PgConnection.bmp DELETED --- --- PgCommand.bmp DELETED --- --- PgDataAdapter.bmp DELETED --- |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:35:27
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/Design/ParameterCollection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient/source/Design/ParameterCollection Removed Files: PgParameterCollectionEditor.cs PgParameterConverter.cs Log Message: Started the reorganization of the CVS module --- PgParameterConverter.cs DELETED --- --- PgParameterCollectionEditor.cs DELETED --- |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient/source Removed Files: AssemblyInfo.cs PgCommand.cs PgCommandBuilder.cs PgConnection.cs PgConnectionInternal.cs PgConnectionPool.cs PgDataAdapter.cs PgDataReader.cs PgDbType.cs PgError.cs PgErrorCollection.cs PgException.cs PgInfoMessageEventArgs.cs PgNotificationEventArgs.cs PgParameter.cs PgParameterCollection.cs PgRowUpdatedEventArgs.cs PgRowUpdatingEventArgs.cs PgTransaction.cs Log Message: Started the reorganization of the CVS module --- PgTransaction.cs DELETED --- --- PgInfoMessageEventArgs.cs DELETED --- --- PgError.cs DELETED --- --- PgConnectionPool.cs DELETED --- --- PgConnectionInternal.cs DELETED --- --- PgDbType.cs DELETED --- --- PgDataReader.cs DELETED --- --- PgCommandBuilder.cs DELETED --- --- AssemblyInfo.cs DELETED --- --- PgErrorCollection.cs DELETED --- --- PgParameterCollection.cs DELETED --- --- PgNotificationEventArgs.cs DELETED --- --- PgParameter.cs DELETED --- --- PgDataAdapter.cs DELETED --- --- PgCommand.cs DELETED --- --- PgRowUpdatedEventArgs.cs DELETED --- --- PgException.cs DELETED --- --- PgConnection.cs DELETED --- --- PgRowUpdatingEventArgs.cs DELETED --- |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient/source/NPgClient Removed Files: InfoMessageCallback.cs NotificationCallback.cs PgAuthMethods.cs PgBackendCodes.cs PgCharSet.cs PgCharSetCollection.cs PgClientError.cs PgClientErrorCollection.cs PgClientException.cs PgClientMessageEventArgs.cs PgClientMessageEventHandler.cs PgClientNotificationEventArgs.cs PgCodes.cs PgConnectionParams.cs PgDataType.cs PgDbClient.cs PgErrorCodes.cs PgFieldDescriptor.cs PgFrontEndCodes.cs PgOutputPacket.cs PgParameter.cs PgResponsePacket.cs PgRowDescriptor.cs PgStatement.cs PgStatementStatus.cs PgType.cs PgTypeCollection.cs PgTypeFormat.cs PgTypeStringFormats.cs SslConnectionCallback.cs Log Message: Started the reorganization of the CVS module --- PgTypeFormat.cs DELETED --- --- PgStatement.cs DELETED --- --- PgOutputPacket.cs DELETED --- --- PgClientError.cs DELETED --- --- PgParameter.cs DELETED --- --- PgBackendCodes.cs DELETED --- --- PgDataType.cs DELETED --- --- PgResponsePacket.cs DELETED --- --- PgType.cs DELETED --- --- PgCodes.cs DELETED --- --- PgCharSetCollection.cs DELETED --- --- PgClientMessageEventArgs.cs DELETED --- --- PgClientException.cs DELETED --- --- PgTypeCollection.cs DELETED --- --- PgStatementStatus.cs DELETED --- --- PgErrorCodes.cs DELETED --- --- PgDbClient.cs DELETED --- --- PgRowDescriptor.cs DELETED --- --- SslConnectionCallback.cs DELETED --- --- PgClientErrorCollection.cs DELETED --- --- PgFrontEndCodes.cs DELETED --- --- PgAuthMethods.cs DELETED --- --- PgConnectionParams.cs DELETED --- --- NotificationCallback.cs DELETED --- --- PgCharSet.cs DELETED --- --- PgClientMessageEventHandler.cs DELETED --- --- PgTypeStringFormats.cs DELETED --- --- InfoMessageCallback.cs DELETED --- --- PgFieldDescriptor.cs DELETED --- --- PgClientNotificationEventArgs.cs DELETED --- |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114/PostgreSql.Data.PgSqlClient/source/DbSchema Removed Files: PgAggregatesSchema.cs PgCastsSchema.cs PgCheckConstraints.cs PgCheckConstraintsByTable.cs PgColumnsSchema.cs PgDatabaseSchema.cs PgDbSchema.cs PgDbSchemaFactory.cs PgDomainsSchema.cs PgForeignKeysSchema.cs PgFunctionPrivilegesSchema.cs PgFunctionsSchema.cs PgGroupsSchema.cs PgIndexesSchema.cs PgPrimaryKeysSchema.cs PgProviderTypesSchema.cs PgSchemataSchema.cs PgSqlLanguagesSchema.cs PgTableConstraintsSchema.cs PgTablePrivilegesSchema.cs PgTableStatisticsSchema.cs PgTablesSchema.cs PgTriggersSchema.cs PgUsersSchema.cs PgViewPrivilegesSchema.cs PgViewsSchema.cs Log Message: Started the reorganization of the CVS module --- PgCastsSchema.cs DELETED --- --- PgTriggersSchema.cs DELETED --- --- PgProviderTypesSchema.cs DELETED --- --- PgIndexesSchema.cs DELETED --- --- PgTablePrivilegesSchema.cs DELETED --- --- PgFunctionPrivilegesSchema.cs DELETED --- --- PgUsersSchema.cs DELETED --- --- PgForeignKeysSchema.cs DELETED --- --- PgFunctionsSchema.cs DELETED --- --- PgCheckConstraints.cs DELETED --- --- PgColumnsSchema.cs DELETED --- --- PgGroupsSchema.cs DELETED --- --- PgDbSchemaFactory.cs DELETED --- --- PgCheckConstraintsByTable.cs DELETED --- --- PgPrimaryKeysSchema.cs DELETED --- --- PgDbSchema.cs DELETED --- --- PgDatabaseSchema.cs DELETED --- --- PgSqlLanguagesSchema.cs DELETED --- --- PgSchemataSchema.cs DELETED --- --- PgTableConstraintsSchema.cs DELETED --- --- PgTablesSchema.cs DELETED --- --- PgViewsSchema.cs DELETED --- --- PgTableStatisticsSchema.cs DELETED --- --- PgAggregatesSchema.cs DELETED --- --- PgViewPrivilegesSchema.cs DELETED --- --- PgDomainsSchema.cs DELETED --- |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:35:22
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5114 Removed Files: Build.bat PgSqlClient.build PostgreSql.Data.PgSqlClient.snk Log Message: Started the reorganization of the CVS module --- PostgreSql.Data.PgSqlClient.snk DELETED --- --- Build.bat DELETED --- --- PgSqlClient.build DELETED --- |
From: Carlos G. Á. <car...@us...> - 2005-09-08 18:32:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3769 Removed Files: LICENSE.TXT README.TXT changelog.txt Log Message: Started the reorganization of the CVS module --- changelog.txt DELETED --- --- LICENSE.TXT DELETED --- --- README.TXT DELETED --- |