mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Provide database object names as separate fields in error messages.
This patch addresses the problem that applications currently have to extract object names from possibly-localized textual error messages, if they want to know for example which index caused a UNIQUE_VIOLATION failure. It adds new error message fields to the wire protocol, which can carry the name of a table, table column, data type, or constraint associated with the error. (Since the protocol spec has always instructed clients to ignore unrecognized field types, this should not create any compatibility problem.) Support for providing these new fields has been added to just a limited set of error reports (mainly, those in the "integrity constraint violation" SQLSTATE class), but we will doubtless add them to more calls in future. Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with additional hacking by Tom Lane.
This commit is contained in:
@ -220,6 +220,8 @@ extern int errposition(int cursorpos);
|
||||
extern int internalerrposition(int cursorpos);
|
||||
extern int internalerrquery(const char *query);
|
||||
|
||||
extern int err_generic_string(int field, const char *str);
|
||||
|
||||
extern int geterrcode(void);
|
||||
extern int geterrposition(void);
|
||||
extern int getinternalerrposition(void);
|
||||
@ -386,6 +388,11 @@ typedef struct ErrorData
|
||||
char *detail_log; /* detail error message for server log only */
|
||||
char *hint; /* hint message */
|
||||
char *context; /* context message */
|
||||
char *schema_name; /* name of schema */
|
||||
char *table_name; /* name of table */
|
||||
char *column_name; /* name of column */
|
||||
char *datatype_name; /* name of datatype */
|
||||
char *constraint_name; /* name of constraint */
|
||||
int cursorpos; /* cursor index into query string */
|
||||
int internalpos; /* cursor index into internalquery */
|
||||
char *internalquery; /* text of internally-generated query */
|
||||
|
Reference in New Issue
Block a user