X Tutup
using System; using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Linq; using System.Text; using Npgsql.BackendMessages; namespace Npgsql { /// /// A non-critical (warning or info) message generated by the backend. /// Can be synchronous (i.e. in response to a query) or asynchronous (a totally unrelated /// backend-side event). /// /// /// http://www.postgresql.org/docs/current/static/protocol-flow.html#PROTOCOL-ASYNC /// public class NpgsqlNotice { readonly ErrorOrNoticeMessage _msg; #region Message Fields /// /// Severity of the error or notice. /// Always present. /// public ErrorSeverity Severity { get { return _msg.Severity; } } /// /// The SQLSTATE code for the error. /// /// /// Always present. /// See http://www.postgresql.org/docs/current/static/errcodes-appendix.html /// public string Code { get { return _msg.Code; } } /// /// The primary human-readable error message. This should be accurate but terse. /// /// /// Always present. /// public string MessageText { get { return _msg.Message; } } /// /// An optional secondary error message carrying more detail about the problem. /// May run to multiple lines. /// public string Detail { get { return _msg.Detail; } } /// /// An optional suggestion what to do about the problem. /// This is intended to differ from Detail in that it offers advice (potentially inappropriate) rather than hard facts. /// May run to multiple lines. /// public string Hint { get { return _msg.Hint; } } /// /// The field value is a decimal ASCII integer, indicating an error cursor position as an index into the original query string. /// The first character has index 1, and positions are measured in characters not bytes. /// 0 means not provided. /// public int Position { get { return _msg.Position; } } /// /// This is defined the same as the field, but it is used when the cursor position refers to an internally generated command rather than the one submitted by the client. /// The field will always appear when this field appears. /// 0 means not provided. /// public int InternalPosition { get { return _msg.InternalPosition; } } /// /// The text of a failed internally-generated command. /// This could be, for example, a SQL query issued by a PL/pgSQL function. /// public string InternalQuery { get { return _msg.InternalQuery; } } /// /// An indication of the context in which the error occurred. /// Presently this includes a call stack traceback of active PL functions. /// The trace is one entry per line, most recent first. /// public string Where { get { return _msg.Where; } } /// /// If the error was associated with a specific database object, the name of the schema containing that object, if any. /// /// PostgreSQL 9.3 and up. public string SchemaName { get { return _msg.SchemaName; } } /// /// Table name: if the error was associated with a specific table, the name of the table. /// (Refer to the schema name field for the name of the table's schema.) /// /// PostgreSQL 9.3 and up. public string TableName { get { return _msg.TableName; } } /// /// If the error was associated with a specific table column, the name of the column. /// (Refer to the schema and table name fields to identify the table.) /// /// PostgreSQL 9.3 and up. public string ColumnName { get { return _msg.ColumnName; } } /// /// If the error was associated with a specific data type, the name of the data type. /// (Refer to the schema name field for the name of the data type's schema.) /// /// PostgreSQL 9.3 and up. public string DataTypeName { get { return _msg.DataTypeName; } } /// /// If the error was associated with a specific constraint, the name of the constraint. /// Refer to fields listed above for the associated table or domain. /// (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.) /// /// PostgreSQL 9.3 and up. public string ConstraintName { get { return _msg.ConstraintName; } } /// /// The file name of the source-code location where the error was reported. /// /// PostgreSQL 9.3 and up. public string File { get { return _msg.File; } } /// /// The line number of the source-code location where the error was reported. /// public string Line { get { return _msg.Line; } } /// /// The name of the source-code routine reporting the error. /// public string Routine { get { return _msg.Routine; } } #endregion internal NpgsqlNotice(NpgsqlBuffer buf) { _msg = new ErrorOrNoticeMessage(buf); } [ContractInvariantMethod] void ObjectInvariants() { Contract.Invariant(Severity == ErrorSeverity.Log || Severity == ErrorSeverity.Info || Severity == ErrorSeverity.Debug || Severity == ErrorSeverity.Notice || Severity == ErrorSeverity.Warning); } } /// /// Provides data for a notice event. /// public class NpgsqlNoticeEventArgs : EventArgs { /// /// The Notice that was sent from the database. /// public NpgsqlNotice Notice { get; private set; } internal NpgsqlNoticeEventArgs(NpgsqlNotice notice) { Notice = notice; } } }
X Tutup