1 /*-------------------------------------------------------------------------
4 * POSTGRES error logging definitions.
7 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: elog.h,v 1.56 2003/07/24 17:52:49 tgl Exp $
12 *-------------------------------------------------------------------------
17 /* Error level codes */
18 #define DEBUG5 10 /* Debugging messages, in categories of
19 * decreasing detail. */
23 #define DEBUG1 14 /* used by GUC debug_* variables */
24 #define LOG 15 /* Server operational messages; sent only
25 * to server log by default. */
26 #define COMMERROR 16 /* Client communication problems; same as
27 * LOG for server reporting, but never
29 #define INFO 17 /* Informative messages that are always
30 * sent to client; is not affected by
31 * client_min_messages */
32 #define NOTICE 18 /* Helpful messages to users about query
33 * operation; sent to client and server
35 #define WARNING 19 /* Warnings */
36 #define ERROR 20 /* user error - abort transaction; return
38 /* Save ERROR value in PGERROR so it can be restored when Win32 includes
39 * modify it. We have to use a constant rather than ERROR because macros
40 * are expanded only when referenced outside macros.
45 #define FATAL 21 /* fatal error - abort process */
46 #define PANIC 22 /* take down the other backends with me */
48 /*#define DEBUG DEBUG1*/ /* Backward compatibility with pre-7.3 */
51 /* macros for representing SQLSTATE strings compactly */
52 #define PGSIXBIT(ch) (((ch) - '0') & 0x3F)
53 #define PGUNSIXBIT(val) (((val) & 0x3F) + '0')
55 #define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \
56 (PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
57 (PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
61 * SQLSTATE codes for errors.
63 * The SQL99 code set is rather impoverished, especially in the area of
64 * syntactical and semantic errors. We have borrowed codes from IBM's DB2
65 * and invented our own codes to develop a useful code set.
67 * When adding a new code, make sure it is placed in the most appropriate
68 * class (the first two characters of the code value identify the class).
69 * The listing is organized by class to make this prominent.
71 * The generic '000' class code should be used for an error only when there
72 * is not a more-specific code defined.
75 /* Class 00 - Successful Completion */
76 #define ERRCODE_SUCCESSFUL_COMPLETION MAKE_SQLSTATE('0','0', '0','0','0')
78 /* Class 01 - Warning */
79 /* (do not use this class for failure conditions!) */
80 #define ERRCODE_WARNING MAKE_SQLSTATE('0','1', '0','0','0')
81 #define ERRCODE_WARNING_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','1', '0','0','C')
82 #define ERRCODE_WARNING_IMPLICIT_ZERO_BIT_PADDING MAKE_SQLSTATE('0','1', '0','0','8')
83 #define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
84 #define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1', '0','0','4')
86 /* Class 02 - No Data --- this is also a warning class per SQL99 */
87 /* (do not use this class for failure conditions!) */
88 #define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2', '0','0','0')
89 #define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2', '0','0','1')
91 /* Class 03 - SQL Statement Not Yet Complete */
92 #define ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE MAKE_SQLSTATE('0','3', '0','0','0')
94 /* Class 08 - Connection Exception */
95 #define ERRCODE_CONNECTION_EXCEPTION MAKE_SQLSTATE('0','8', '0','0','0')
96 #define ERRCODE_CONNECTION_DOES_NOT_EXIST MAKE_SQLSTATE('0','8', '0','0','3')
97 #define ERRCODE_CONNECTION_FAILURE MAKE_SQLSTATE('0','8', '0','0','6')
98 #define ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION MAKE_SQLSTATE('0','8', '0','0','1')
99 #define ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION MAKE_SQLSTATE('0','8', '0','0','4')
100 #define ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN MAKE_SQLSTATE('0','8', '0','0','7')
101 #define ERRCODE_PROTOCOL_VIOLATION MAKE_SQLSTATE('0','8', 'P','0','1')
103 /* Class 09 - Triggered Action Exception */
104 #define ERRCODE_TRIGGERED_ACTION_EXCEPTION MAKE_SQLSTATE('0','9', '0','0','0')
106 /* Class 0A - Feature Not Supported */
107 #define ERRCODE_FEATURE_NOT_SUPPORTED MAKE_SQLSTATE('0','A', '0','0','0')
109 /* Class 0B - Invalid Transaction Initiation */
110 #define ERRCODE_INVALID_TRANSACTION_INITIATION MAKE_SQLSTATE('0','B', '0','0','0')
112 /* Class 0F - Locator Exception */
113 #define ERRCODE_LOCATOR_EXCEPTION MAKE_SQLSTATE('0','F', '0','0','0')
114 #define ERRCODE_L_E_INVALID_SPECIFICATION MAKE_SQLSTATE('0','F', '0','0','1')
116 /* Class 0L - Invalid Grantor */
117 #define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0','L', '0','0','0')
118 #define ERRCODE_INVALID_GRANT_OPERATION MAKE_SQLSTATE('0','L', 'P','0','1')
120 /* Class 0P - Invalid Role Specification */
121 #define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P', '0','0','0')
123 /* Class 21 - Cardinality Violation */
124 /* (this means something returned the wrong number of rows) */
125 #define ERRCODE_CARDINALITY_VIOLATION MAKE_SQLSTATE('2','1', '0','0','0')
127 /* Class 22 - Data Exception */
128 #define ERRCODE_DATA_EXCEPTION MAKE_SQLSTATE('2','2', '0','0','0')
129 #define ERRCODE_ARRAY_ELEMENT_ERROR MAKE_SQLSTATE('2','2', '0','2','E')
130 /* SQL99's actual definition of "array element error" is subscript error */
131 #define ERRCODE_ARRAY_SUBSCRIPT_ERROR ERRCODE_ARRAY_ELEMENT_ERROR
132 #define ERRCODE_CHARACTER_NOT_IN_REPERTOIRE MAKE_SQLSTATE('2','2', '0','2','1')
133 #define ERRCODE_DATETIME_FIELD_OVERFLOW MAKE_SQLSTATE('2','2', '0','0','8')
134 #define ERRCODE_DIVISION_BY_ZERO MAKE_SQLSTATE('2','2', '0','1','2')
135 #define ERRCODE_ERROR_IN_ASSIGNMENT MAKE_SQLSTATE('2','2', '0','0','5')
136 #define ERRCODE_ESCAPE_CHARACTER_CONFLICT MAKE_SQLSTATE('2','2', '0','0','B')
137 #define ERRCODE_INDICATOR_OVERFLOW MAKE_SQLSTATE('2','2', '0','2','2')
138 #define ERRCODE_INTERVAL_FIELD_OVERFLOW MAKE_SQLSTATE('2','2', '0','1','5')
139 #define ERRCODE_INVALID_CHARACTER_VALUE_FOR_CAST MAKE_SQLSTATE('2','2', '0','1','8')
140 #define ERRCODE_INVALID_DATETIME_FORMAT MAKE_SQLSTATE('2','2', '0','0','7')
141 #define ERRCODE_INVALID_ESCAPE_CHARACTER MAKE_SQLSTATE('2','2', '0','1','9')
142 #define ERRCODE_INVALID_ESCAPE_OCTET MAKE_SQLSTATE('2','2', '0','0','D')
143 #define ERRCODE_INVALID_ESCAPE_SEQUENCE MAKE_SQLSTATE('2','2', '0','2','5')
144 #define ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE MAKE_SQLSTATE('2','2', '0','1','0')
145 #define ERRCODE_INVALID_LIMIT_VALUE MAKE_SQLSTATE('2','2', '0','2','0')
146 #define ERRCODE_INVALID_PARAMETER_VALUE MAKE_SQLSTATE('2','2', '0','2','3')
147 #define ERRCODE_INVALID_REGULAR_EXPRESSION MAKE_SQLSTATE('2','2', '0','1','B')
148 #define ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE MAKE_SQLSTATE('2','2', '0','0','9')
149 #define ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER MAKE_SQLSTATE('2','2', '0','0','C')
150 #define ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH MAKE_SQLSTATE('2','2', '0','0','2')
151 #define ERRCODE_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('2','2', '0','0','4')
152 #define ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER MAKE_SQLSTATE('2','2', '0','0','G')
153 #define ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE MAKE_SQLSTATE('2','2', '0','0','3')
154 #define ERRCODE_STRING_DATA_LENGTH_MISMATCH MAKE_SQLSTATE('2','2', '0','2','6')
155 #define ERRCODE_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('2','2', '0','0','1')
156 #define ERRCODE_SUBSTRING_ERROR MAKE_SQLSTATE('2','2', '0','1','1')
157 #define ERRCODE_TRIM_ERROR MAKE_SQLSTATE('2','2', '0','2','7')
158 #define ERRCODE_UNTERMINATED_C_STRING MAKE_SQLSTATE('2','2', '0','2','4')
159 #define ERRCODE_ZERO_LENGTH_CHARACTER_STRING MAKE_SQLSTATE('2','2', '0','0','F')
160 #define ERRCODE_BAD_COPY_FILE_FORMAT MAKE_SQLSTATE('2','2', 'P','0','1')
161 #define ERRCODE_INVALID_BINARY_REPRESENTATION MAKE_SQLSTATE('2','2', 'P','0','2')
162 #define ERRCODE_FLOATING_POINT_EXCEPTION MAKE_SQLSTATE('2','2', 'P','0','3')
164 /* Class 23 - Integrity Constraint Violation */
165 #define ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('2','3', '0','0','0')
166 #define ERRCODE_RESTRICT_VIOLATION MAKE_SQLSTATE('2','3', '0','0','1')
167 #define ERRCODE_NOT_NULL_VIOLATION MAKE_SQLSTATE('2','3', '5','0','2')
168 #define ERRCODE_FOREIGN_KEY_VIOLATION MAKE_SQLSTATE('2','3', '5','0','3')
169 #define ERRCODE_UNIQUE_VIOLATION MAKE_SQLSTATE('2','3', '5','0','5')
170 #define ERRCODE_CHECK_VIOLATION MAKE_SQLSTATE('2','3', '5','1','4')
172 /* Class 24 - Invalid Cursor State */
173 #define ERRCODE_INVALID_CURSOR_STATE MAKE_SQLSTATE('2','4', '0','0','0')
175 /* Class 25 - Invalid Transaction State */
176 #define ERRCODE_INVALID_TRANSACTION_STATE MAKE_SQLSTATE('2','5', '0','0','0')
177 #define ERRCODE_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','1')
178 #define ERRCODE_BRANCH_TRANSACTION_ALREADY_ACTIVE MAKE_SQLSTATE('2','5', '0','0','2')
179 #define ERRCODE_HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL MAKE_SQLSTATE('2','5', '0','0','8')
180 #define ERRCODE_INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','3')
181 #define ERRCODE_INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','4')
182 #define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','5')
183 #define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','6')
184 #define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED MAKE_SQLSTATE('2','5', '0','0','7')
185 #define ERRCODE_NO_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5', 'P','0','1')
186 #define ERRCODE_IN_FAILED_SQL_TRANSACTION MAKE_SQLSTATE('2','5', 'P','0','2')
188 /* Class 26 - Invalid SQL Statement Name */
189 /* (we take this to mean prepared statements) */
190 #define ERRCODE_INVALID_SQL_STATEMENT_NAME MAKE_SQLSTATE('2','6', '0','0','0')
192 /* Class 27 - Triggered Data Change Violation */
193 #define ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION MAKE_SQLSTATE('2','7', '0','0','0')
195 /* Class 28 - Invalid Authorization Specification */
196 #define ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION MAKE_SQLSTATE('2','8', '0','0','0')
198 /* Class 2B - Dependent Privilege Descriptors Still Exist */
199 #define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B', '0','0','0')
200 #define ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST MAKE_SQLSTATE('2','B', 'P','0','1')
202 /* Class 2D - Invalid Transaction Termination */
203 #define ERRCODE_INVALID_TRANSACTION_TERMINATION MAKE_SQLSTATE('2','D', '0','0','0')
205 /* Class 2F - SQL Routine Exception */
206 #define ERRCODE_SQL_ROUTINE_EXCEPTION MAKE_SQLSTATE('2','F', '0','0','0')
207 #define ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT MAKE_SQLSTATE('2','F', '0','0','5')
208 #define ERRCODE_S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('2','F', '0','0','2')
209 #define ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('2','F', '0','0','3')
210 #define ERRCODE_S_R_E_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('2','F', '0','0','4')
212 /* Class 34 - Invalid Cursor Name */
213 #define ERRCODE_INVALID_CURSOR_NAME MAKE_SQLSTATE('3','4', '0','0','0')
215 /* Class 38 - External Routine Exception */
216 #define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION MAKE_SQLSTATE('3','8', '0','0','0')
217 #define ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','1')
218 #define ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','2')
219 #define ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('3','8', '0','0','3')
220 #define ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','4')
222 /* Class 39 - External Routine Invocation Exception */
223 #define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION MAKE_SQLSTATE('3','9', '0','0','0')
224 #define ERRCODE_E_R_I_E_INVALID_SQLSTATE_RETURNED MAKE_SQLSTATE('3','9', '0','0','1')
225 #define ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('3','9', '0','0','4')
226 #define ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED MAKE_SQLSTATE('3','9', 'P','0','1')
227 #define ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED MAKE_SQLSTATE('3','9', 'P','0','2')
229 /* Class 3D - Invalid Catalog Name */
230 #define ERRCODE_INVALID_CATALOG_NAME MAKE_SQLSTATE('3','D', '0','0','0')
232 /* Class 3F - Invalid Schema Name */
233 #define ERRCODE_INVALID_SCHEMA_NAME MAKE_SQLSTATE('3','F', '0','0','0')
235 /* Class 40 - Transaction Rollback */
236 #define ERRCODE_TRANSACTION_ROLLBACK MAKE_SQLSTATE('4','0', '0','0','0')
237 #define ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('4','0', '0','0','2')
238 #define ERRCODE_T_R_SERIALIZATION_FAILURE MAKE_SQLSTATE('4','0', '0','0','1')
239 #define ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN MAKE_SQLSTATE('4','0', '0','0','3')
241 /* Class 42 - Syntax Error or Access Rule Violation */
242 #define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION MAKE_SQLSTATE('4','2', '0','0','0')
243 /* never use the above; use one of these two if no specific code exists: */
244 #define ERRCODE_SYNTAX_ERROR MAKE_SQLSTATE('4','2', '6','0','1')
245 #define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4','2', '5','0','1')
246 #define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4','2', '8','4','6')
247 #define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4','2', '8','0','3')
248 #define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4','2', '8','3','0')
249 #define ERRCODE_INVALID_NAME MAKE_SQLSTATE('4','2', '6','0','2')
250 #define ERRCODE_NAME_TOO_LONG MAKE_SQLSTATE('4','2', '6','2','2')
251 #define ERRCODE_RESERVED_NAME MAKE_SQLSTATE('4','2', '9','3','9')
252 #define ERRCODE_DATATYPE_MISMATCH MAKE_SQLSTATE('4','2', '8','0','4')
253 #define ERRCODE_INDETERMINATE_DATATYPE MAKE_SQLSTATE('4','2', 'P','1','8')
254 #define ERRCODE_WRONG_OBJECT_TYPE MAKE_SQLSTATE('4','2', '8','0','9')
256 * Note: for ERRCODE purposes, we divide namable objects into these categories:
257 * databases, schemas, prepared statements, cursors, tables, columns,
258 * functions (including operators), and all else (lumped as "objects").
259 * (The first four categories are mandated by the existence of separate
260 * SQLSTATE classes for them in the spec; in this file, however, we group
261 * the ERRCODE names with all the rest under class 42.) Parameters are
262 * sort-of-named objects and get their own ERRCODE.
264 * The same breakdown is used for "duplicate" and "ambiguous" complaints,
265 * as well as complaints associated with incorrect declarations.
267 #define ERRCODE_UNDEFINED_COLUMN MAKE_SQLSTATE('4','2', '7','0','3')
268 #define ERRCODE_UNDEFINED_CURSOR ERRCODE_INVALID_CURSOR_NAME
269 #define ERRCODE_UNDEFINED_DATABASE ERRCODE_INVALID_CATALOG_NAME
270 #define ERRCODE_UNDEFINED_FUNCTION MAKE_SQLSTATE('4','2', '8','8','3')
271 #define ERRCODE_UNDEFINED_PSTATEMENT ERRCODE_INVALID_SQL_STATEMENT_NAME
272 #define ERRCODE_UNDEFINED_SCHEMA ERRCODE_INVALID_SCHEMA_NAME
273 #define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2', 'P','0','1')
274 #define ERRCODE_UNDEFINED_PARAMETER MAKE_SQLSTATE('4','2', 'P','0','2')
275 #define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4','2', '7','0','4')
276 #define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4','2', '7','0','1')
277 #define ERRCODE_DUPLICATE_CURSOR MAKE_SQLSTATE('4','2', 'P','0','3')
278 #define ERRCODE_DUPLICATE_DATABASE MAKE_SQLSTATE('4','2', 'P','0','4')
279 #define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4','2', '7','2','3')
280 #define ERRCODE_DUPLICATE_PSTATEMENT MAKE_SQLSTATE('4','2', 'P','0','5')
281 #define ERRCODE_DUPLICATE_SCHEMA MAKE_SQLSTATE('4','2', 'P','0','6')
282 #define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2', 'P','0','7')
283 #define ERRCODE_DUPLICATE_ALIAS MAKE_SQLSTATE('4','2', '7','1','2')
284 #define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4','2', '7','1','0')
285 #define ERRCODE_AMBIGUOUS_COLUMN MAKE_SQLSTATE('4','2', '7','0','2')
286 #define ERRCODE_AMBIGUOUS_FUNCTION MAKE_SQLSTATE('4','2', '7','2','5')
287 #define ERRCODE_AMBIGUOUS_PARAMETER MAKE_SQLSTATE('4','2', 'P','0','8')
288 #define ERRCODE_AMBIGUOUS_ALIAS MAKE_SQLSTATE('4','2', 'P','0','9')
289 #define ERRCODE_INVALID_COLUMN_REFERENCE MAKE_SQLSTATE('4','2', 'P','1','0')
290 #define ERRCODE_INVALID_COLUMN_DEFINITION MAKE_SQLSTATE('4','2', '6','1','1')
291 #define ERRCODE_INVALID_CURSOR_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','1')
292 #define ERRCODE_INVALID_DATABASE_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','2')
293 #define ERRCODE_INVALID_FUNCTION_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','3')
294 #define ERRCODE_INVALID_PSTATEMENT_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','4')
295 #define ERRCODE_INVALID_SCHEMA_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','5')
296 #define ERRCODE_INVALID_TABLE_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','6')
297 #define ERRCODE_INVALID_OBJECT_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','7')
299 /* Class 44 - WITH CHECK OPTION Violation */
300 #define ERRCODE_WITH_CHECK_OPTION_VIOLATION MAKE_SQLSTATE('4','4', '0','0','0')
302 /* Class 53 - Insufficient Resources (PostgreSQL-specific error class) */
303 #define ERRCODE_INSUFFICIENT_RESOURCES MAKE_SQLSTATE('5','3', '0','0','0')
304 #define ERRCODE_DISK_FULL MAKE_SQLSTATE('5','3', '1','0','0')
305 #define ERRCODE_OUT_OF_MEMORY MAKE_SQLSTATE('5','3', '2','0','0')
306 #define ERRCODE_TOO_MANY_CONNECTIONS MAKE_SQLSTATE('5','3', '3','0','0')
308 /* Class 54 - Program Limit Exceeded (class borrowed from DB2) */
309 /* (this is for wired-in limits, not resource exhaustion problems) */
310 #define ERRCODE_PROGRAM_LIMIT_EXCEEDED MAKE_SQLSTATE('5','4', '0','0','0')
311 #define ERRCODE_STATEMENT_TOO_COMPLEX MAKE_SQLSTATE('5','4', '0','0','1')
312 #define ERRCODE_TOO_MANY_COLUMNS MAKE_SQLSTATE('5','4', '0','1','1')
313 #define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('5','4', '0','2','3')
315 /* Class 55 - Object Not In Prerequisite State (class borrowed from DB2) */
316 #define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
317 #define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
318 #define ERRCODE_INDEXES_DEACTIVATED MAKE_SQLSTATE('5','5', 'P','0','1')
319 #define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('5','5', 'P','0','2')
321 /* Class 57 - Operator Intervention (class borrowed from DB2) */
322 #define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
323 #define ERRCODE_QUERY_CANCELED MAKE_SQLSTATE('5','7', '0','1','4')
324 #define ERRCODE_ADMIN_SHUTDOWN MAKE_SQLSTATE('5','7', 'P','0','1')
325 #define ERRCODE_CRASH_SHUTDOWN MAKE_SQLSTATE('5','7', 'P','0','2')
326 #define ERRCODE_CANNOT_CONNECT_NOW MAKE_SQLSTATE('5','7', 'P','0','3')
328 /* Class 58 - System Error (class borrowed from DB2) */
329 /* (we define this as errors external to PostgreSQL itself) */
330 #define ERRCODE_IO_ERROR MAKE_SQLSTATE('5','8', '0','3','0')
332 /* Class F0 - Configuration File Error (PostgreSQL-specific error class) */
333 #define ERRCODE_CONFIG_FILE_ERROR MAKE_SQLSTATE('F','0', '0','0','0')
335 /* Class XX - Internal Error (PostgreSQL-specific error class) */
336 /* (this is for "can't-happen" conditions and software bugs) */
337 #define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
340 /* Which __func__ symbol do we have, if any? */
341 #ifdef HAVE_FUNCNAME__FUNC
342 #define PG_FUNCNAME_MACRO __func__
344 #ifdef HAVE_FUNCNAME__FUNCTION
345 #define PG_FUNCNAME_MACRO __FUNCTION__
347 #define PG_FUNCNAME_MACRO NULL
353 * New-style error reporting API: to be used in this way:
355 * (errcode(ERRCODE_UNDEFINED_CURSOR),
356 * errmsg("portal \"%s\" not found", stmt->portalname),
357 * ... other errxxx() fields as needed ...));
359 * The error level is required, and so is a primary error message (errmsg
360 * or errmsg_internal). All else is optional. errcode() defaults to
361 * ERRCODE_INTERNAL_ERROR if elevel is ERROR or more, ERRCODE_WARNING
362 * if elevel is WARNING, or ERRCODE_SUCCESSFUL_COMPLETION if elevel is
366 #define ereport(elevel, rest) \
367 (errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO) ? \
368 (errfinish rest) : (void) 0)
370 extern bool errstart(int elevel, const char *filename, int lineno,
371 const char *funcname);
372 extern void errfinish(int dummy, ...);
374 extern int errcode(int sqlerrcode);
376 extern int errcode_for_file_access(void);
377 extern int errcode_for_socket_access(void);
379 extern int errmsg(const char *fmt, ...)
380 /* This extension allows gcc to check the format string for consistency with
381 the supplied arguments. */
382 __attribute__((format(printf, 1, 2)));
384 extern int errmsg_internal(const char *fmt, ...)
385 /* This extension allows gcc to check the format string for consistency with
386 the supplied arguments. */
387 __attribute__((format(printf, 1, 2)));
389 extern int errdetail(const char *fmt, ...)
390 /* This extension allows gcc to check the format string for consistency with
391 the supplied arguments. */
392 __attribute__((format(printf, 1, 2)));
394 extern int errhint(const char *fmt, ...)
395 /* This extension allows gcc to check the format string for consistency with
396 the supplied arguments. */
397 __attribute__((format(printf, 1, 2)));
399 extern int errcontext(const char *fmt, ...)
400 /* This extension allows gcc to check the format string for consistency with
401 the supplied arguments. */
402 __attribute__((format(printf, 1, 2)));
404 extern int errfunction(const char *funcname);
405 extern int errposition(int cursorpos);
409 * Old-style error reporting API: to be used in this way:
410 * elog(ERROR, "portal \"%s\" not found", stmt->portalname);
413 #define elog errstart(ERROR, __FILE__, __LINE__, PG_FUNCNAME_MACRO), elog_finish
416 elog_finish(int elevel, const char *fmt, ...)
417 /* This extension allows gcc to check the format string for consistency with
418 the supplied arguments. */
419 __attribute__((format(printf, 2, 3)));
422 /* Support for attaching context information to error reports */
424 typedef struct ErrorContextCallback
426 struct ErrorContextCallback *previous;
427 void (*callback) (void *arg);
429 } ErrorContextCallback;
431 extern DLLIMPORT ErrorContextCallback *error_context_stack;
434 /* GUC-configurable parameters */
438 PGERROR_TERSE, /* single-line error messages */
439 PGERROR_DEFAULT, /* recommended style */
440 PGERROR_VERBOSE /* all the facts, ma'am */
443 extern PGErrorVerbosity Log_error_verbosity;
444 extern bool Log_timestamp;
447 extern int Use_syslog;
451 /* Other exported functions */
452 extern void DebugFileOpen(void);