forked from Emill/Npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlNotice.cs
More file actions
executable file
·171 lines (147 loc) · 6.64 KB
/
NpgsqlNotice.cs
File metadata and controls
executable file
·171 lines (147 loc) · 6.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using Npgsql.BackendMessages;
namespace Npgsql
{
/// <summary>
/// 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).
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/protocol-flow.html#PROTOCOL-ASYNC
/// </remarks>
public class NpgsqlNotice
{
readonly ErrorOrNoticeMessage _msg;
#region Message Fields
/// <summary>
/// Severity of the error or notice.
/// Always present.
/// </summary>
public ErrorSeverity Severity { get { return _msg.Severity; } }
/// <summary>
/// The SQLSTATE code for the error.
/// </summary>
/// <remarks>
/// Always present.
/// See http://www.postgresql.org/docs/current/static/errcodes-appendix.html
/// </remarks>
public string Code { get { return _msg.Code; } }
/// <summary>
/// The primary human-readable error message. This should be accurate but terse.
/// </summary>
/// <remarks>
/// Always present.
/// </remarks>
public string MessageText { get { return _msg.Message; } }
/// <summary>
/// An optional secondary error message carrying more detail about the problem.
/// May run to multiple lines.
/// </summary>
public string Detail { get { return _msg.Detail; } }
/// <summary>
/// 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.
/// </summary>
public string Hint { get { return _msg.Hint; } }
/// <summary>
/// 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.
/// </summary>
public int Position { get { return _msg.Position; } }
/// <summary>
/// This is defined the same as the <see cref="Position"/> field, but it is used when the cursor position refers to an internally generated command rather than the one submitted by the client.
/// The <see cref="InternalQuery" /> field will always appear when this field appears.
/// 0 means not provided.
/// </summary>
public int InternalPosition { get { return _msg.InternalPosition; } }
/// <summary>
/// The text of a failed internally-generated command.
/// This could be, for example, a SQL query issued by a PL/pgSQL function.
/// </summary>
public string InternalQuery { get { return _msg.InternalQuery; } }
/// <summary>
/// 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.
/// </summary>
public string Where { get { return _msg.Where; } }
/// <summary>
/// If the error was associated with a specific database object, the name of the schema containing that object, if any.
/// </summary>
/// <remarks>PostgreSQL 9.3 and up.</remarks>
public string SchemaName { get { return _msg.SchemaName; } }
/// <summary>
/// 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.)
/// </summary>
/// <remarks>PostgreSQL 9.3 and up.</remarks>
public string TableName { get { return _msg.TableName; } }
/// <summary>
/// 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.)
/// </summary>
/// <remarks>PostgreSQL 9.3 and up.</remarks>
public string ColumnName { get { return _msg.ColumnName; } }
/// <summary>
/// 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.)
/// </summary>
/// <remarks>PostgreSQL 9.3 and up.</remarks>
public string DataTypeName { get { return _msg.DataTypeName; } }
/// <summary>
/// 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.)
/// </summary>
/// <remarks>PostgreSQL 9.3 and up.</remarks>
public string ConstraintName { get { return _msg.ConstraintName; } }
/// <summary>
/// The file name of the source-code location where the error was reported.
/// </summary>
/// <remarks>PostgreSQL 9.3 and up.</remarks>
public string File { get { return _msg.File; } }
/// <summary>
/// The line number of the source-code location where the error was reported.
/// </summary>
public string Line { get { return _msg.Line; } }
/// <summary>
/// The name of the source-code routine reporting the error.
/// </summary>
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);
}
}
/// <summary>
/// Provides data for a notice event.
/// </summary>
public class NpgsqlNoticeEventArgs : EventArgs
{
/// <summary>
/// The Notice that was sent from the database.
/// </summary>
public NpgsqlNotice Notice { get; private set; }
internal NpgsqlNoticeEventArgs(NpgsqlNotice notice)
{
Notice = notice;
}
}
}