|
1 | 1 | <!--
|
2 |
| -$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.131 2003/08/13 16:29:03 tgl Exp $ |
| 2 | +$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.132 2003/08/24 18:36:38 petere Exp $ |
3 | 3 | -->
|
4 | 4 |
|
5 | 5 | <chapter id="libpq">
|
@@ -1283,20 +1283,138 @@ Returns an individual field of an error report.
|
1283 | 1283 | <synopsis>
|
1284 | 1284 | char *PQresultErrorField(const PGresult *res, int fieldcode);
|
1285 | 1285 | </synopsis>
|
1286 |
| -<parameter>fieldcode</> is an error field identifier defined by the |
1287 |
| -<productname>PostgreSQL</> protocol (see <xref |
1288 |
| -linkend="protocol-error-fields">), for example <literal>'C'</> for |
1289 |
| -the SQLSTATE error code. NULL is returned if the |
| 1286 | +<parameter>fieldcode</> is an error field identifier; see the symbols |
| 1287 | +listed below. <symbol>NULL</symbol> is returned if the |
1290 | 1288 | <structname>PGresult</structname> is not an error or warning result,
|
1291 | 1289 | or does not include the specified field. Field values will normally
|
1292 | 1290 | not include a trailing newline.
|
1293 | 1291 | </para>
|
1294 | 1292 |
|
1295 | 1293 | <para>
|
1296 |
| -Errors generated internally by libpq will have severity and primary message, |
1297 |
| -but typically no other fields. Errors returned by a pre-3.0-protocol server |
1298 |
| -will include severity and primary message, and sometimes a detail message, |
1299 |
| -but no other fields. |
| 1294 | +The following field codes are available: |
| 1295 | +<variablelist> |
| 1296 | + |
| 1297 | +<varlistentry> |
| 1298 | +<term><symbol>PG_DIAG_SEVERITY</></term> |
| 1299 | +<listitem> |
| 1300 | +<para> |
| 1301 | +The severity; the field contents are <literal>ERROR</>, |
| 1302 | +<literal>FATAL</>, or <literal>PANIC</> (in an error message), or |
| 1303 | +<literal>WARNING</>, <literal>NOTICE</>, <literal>DEBUG</>, |
| 1304 | +<literal>INFO</>, or <literal>LOG</> (in a notice message), or a |
| 1305 | +localized translation of one of these. Always present. |
| 1306 | +</para> |
| 1307 | +</listitem> |
| 1308 | +</varlistentry> |
| 1309 | + |
| 1310 | +<varlistentry> |
| 1311 | +<term><symbol>PG_DIAG_SQLSTATE</> |
| 1312 | +</term> |
| 1313 | +<listitem> |
| 1314 | +<para> |
| 1315 | +The SQLSTATE code for the error (a 5-character string following SQL |
| 1316 | +spec conventions). Not localizable. Always present. |
| 1317 | +</para> |
| 1318 | +</listitem> |
| 1319 | +</varlistentry> |
| 1320 | + |
| 1321 | +<varlistentry> |
| 1322 | +<term><symbol>PG_DIAG_MESSAGE_PRIMARY</></term> |
| 1323 | +<listitem> |
| 1324 | +<para> |
| 1325 | +The primary human-readable error message (typically one line). Always |
| 1326 | +present. |
| 1327 | +</para> |
| 1328 | +</listitem> |
| 1329 | +</varlistentry> |
| 1330 | + |
| 1331 | +<varlistentry> |
| 1332 | +<term><symbol>PG_DIAG_MESSAGE_DETAIL</></term> |
| 1333 | +<listitem> |
| 1334 | +<para> |
| 1335 | +Detail: an optional secondary error message carrying more detail about |
| 1336 | +the problem. May run to multiple lines. |
| 1337 | +</para> |
| 1338 | +</listitem> |
| 1339 | +</varlistentry> |
| 1340 | + |
| 1341 | +<varlistentry> |
| 1342 | +<term><symbol>PG_DIAG_MESSAGE_HINT</></term> |
| 1343 | +<listitem> |
| 1344 | +<para> |
| 1345 | +Hint: an optional suggestion what to do about the problem. This is |
| 1346 | +intended to differ from detail in that it offers advice (potentially |
| 1347 | +inappropriate) rather than hard facts. May run to multiple lines. |
| 1348 | +</para> |
| 1349 | +</listitem> |
| 1350 | +</varlistentry> |
| 1351 | + |
| 1352 | +<varlistentry> |
| 1353 | +<term><symbol>PG_DIAG_STATEMENT_POSITION</></term> |
| 1354 | +<listitem> |
| 1355 | +<para> |
| 1356 | +A string containing a decimal integer indicating an error cursor |
| 1357 | +position as an index into the original statement string. The first |
| 1358 | +character has index 1, and positions are measured in characters not |
| 1359 | +bytes. |
| 1360 | +</para> |
| 1361 | +</listitem> |
| 1362 | +</varlistentry> |
| 1363 | + |
| 1364 | +<varlistentry> |
| 1365 | +<term><symbol>PG_DIAG_CONTEXT</></term> |
| 1366 | +<listitem> |
| 1367 | +<para> |
| 1368 | +An indication of the context in which the error occurred. Presently |
| 1369 | +this includes a call stack traceback of active PL functions. The |
| 1370 | +trace is one entry per line, most recent first. |
| 1371 | +</para> |
| 1372 | +</listitem> |
| 1373 | +</varlistentry> |
| 1374 | + |
| 1375 | +<varlistentry> |
| 1376 | +<term><symbol>PG_DIAG_SOURCE_FILE</></term> |
| 1377 | +<listitem> |
| 1378 | +<para> |
| 1379 | +The file name of the source-code location where the error was |
| 1380 | +reported. |
| 1381 | +</para> |
| 1382 | +</listitem> |
| 1383 | +</varlistentry> |
| 1384 | + |
| 1385 | +<varlistentry> |
| 1386 | +<term><symbol>PG_DIAG_SOURCE_LINE</></term> |
| 1387 | +<listitem> |
| 1388 | +<para> |
| 1389 | +The line number of the source-code location where the error was |
| 1390 | +reported. |
| 1391 | +</para> |
| 1392 | +</listitem> |
| 1393 | +</varlistentry> |
| 1394 | + |
| 1395 | +<varlistentry> |
| 1396 | +<term><symbol>PG_DIAG_SOURCE_FUNCTION</></term> |
| 1397 | +<listitem> |
| 1398 | +<para> |
| 1399 | +The name of the source-code function reporting the error. |
| 1400 | +</para> |
| 1401 | +</listitem> |
| 1402 | +</varlistentry> |
| 1403 | +</variablelist> |
| 1404 | +</para> |
| 1405 | + |
| 1406 | +<para> |
| 1407 | +The client is responsible for formatting displayed information to meet |
| 1408 | +its needs; in particular it should break long lines as needed. |
| 1409 | +Newline characters appearing in the error message fields should be |
| 1410 | +treated as paragraph breaks, not line breaks. |
| 1411 | +</para> |
| 1412 | + |
| 1413 | +<para> |
| 1414 | +Errors generated internally by <application>libpq</application> will |
| 1415 | +have severity and primary message, but typically no other fields. |
| 1416 | +Errors returned by a pre-3.0-protocol server will include severity and |
| 1417 | +primary message, and sometimes a detail message, but no other fields. |
1300 | 1418 | </para>
|
1301 | 1419 |
|
1302 | 1420 | <para>
|
|
0 commit comments