mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +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:
@@ -143,7 +143,10 @@ extern Datum char_text(PG_FUNCTION_ARGS);
|
||||
/* domains.c */
|
||||
extern Datum domain_in(PG_FUNCTION_ARGS);
|
||||
extern Datum domain_recv(PG_FUNCTION_ARGS);
|
||||
extern void domain_check(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt);
|
||||
extern void domain_check(Datum value, bool isnull, Oid domainType,
|
||||
void **extra, MemoryContext mcxt);
|
||||
extern int errdatatype(Oid datatypeOid);
|
||||
extern int errdomainconstraint(Oid datatypeOid, const char *conname);
|
||||
|
||||
/* encode.c */
|
||||
extern Datum binary_encode(PG_FUNCTION_ARGS);
|
||||
|
@@ -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 */
|
||||
|
@@ -52,6 +52,14 @@ extern void RelationSetIndexList(Relation relation,
|
||||
|
||||
extern void RelationInitIndexAccessInfo(Relation relation);
|
||||
|
||||
/*
|
||||
* Routines to support ereport() reports of relation-related errors
|
||||
*/
|
||||
extern int errtable(Relation rel);
|
||||
extern int errtablecol(Relation rel, int attnum);
|
||||
extern int errtablecolname(Relation rel, const char *colname);
|
||||
extern int errtableconstraint(Relation rel, const char *conname);
|
||||
|
||||
/*
|
||||
* Routines for backend startup
|
||||
*/
|
||||
|
@@ -66,10 +66,12 @@ extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc,
|
||||
extern Tuplesortstate *tuplesort_begin_cluster(TupleDesc tupDesc,
|
||||
Relation indexRel,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_index_btree(Relation indexRel,
|
||||
extern Tuplesortstate *tuplesort_begin_index_btree(Relation heapRel,
|
||||
Relation indexRel,
|
||||
bool enforceUnique,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_index_hash(Relation indexRel,
|
||||
extern Tuplesortstate *tuplesort_begin_index_hash(Relation heapRel,
|
||||
Relation indexRel,
|
||||
uint32 hash_mask,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_datum(Oid datumType,
|
||||
|
Reference in New Issue
Block a user