-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postgresql error context (where) information is missing, please consider including 'W' context error field. #2517
Comments
In #1572, |
Suggested 'P' returns a string with a decimal integer of error position in the SQL. Actually for the kind of error that is described in this issue, it returns as None. I commented on the issue you mentioned. Hopefully the fact that 'P' contains a string with a decimal integer value may help to move with the awaiting PR/merge. Though I'd still believe that adding context() based on 'W' is quite beneficial for troubleshooting the errors:
May I prepare a PR with a context() method, similar to what was done in #1572 for 'P'? |
Opening a PR would certainly make it easier to discuss the design. Otherwise this seems like a meaningful addition for me. |
SqlState also would be helpful as a separate getter. Many DBMS supports error codes beyond string message |
What about SqlState ? should it be addressed in another issue? |
@Mart-Bogdan That's completely unrelated to this issue. Feel free to write a proposal adding such an API in our discussion forum, but be sure to answer the questions outlined in our contribution guidelines. |
Feature Flags
postgresql
Problem Description
Error reporting with
diesel::result::Error::DatabaseError
is missing context information for postgresql. This makes it harder to troubleshoot where database error happens.What are you trying to accomplish?
E.g. I have a before delete trigger that calls a function that has more fields in
INSERT INTO (fields...)
than SELECT that follows.Error presented by many clients when I try to delete the row that would trigger the trigger/function is:
What is the actual output?
Diesel most detailed presentation of the error is:
Only message field is non-empty in this case via Diesel:
kind, details, hint, table, column, constraint name are all None.
What is the expected output?
One would expect diesel to provide that "where" bit of the information:
Per
And trait:
There is no way to convey that context/where information that is contained in https://github.com/postgres/postgres/blob/master/src/include/postgres_ext.h:
It would be great if someone can decide if DatabaseErrorInformation deserves a new method like context() or if this context information can be added to the "details()" implementation of PgErrorInformation trait implementation:
Adding this context information is something that would help the error logging in common, but I also think that it can improve situation with reporting migration errors? See #2378 - More verbose errors on diesel migrations?
I can help with implementation, but this is something that spans multiple database systems as
pub trait DatabaseErrorInformation
is generic and I'd need guidance on how to implement. I can imagine providing a PR with adding 'W' Context into ResultField and adding this todetails
of PgErrorInformation, but I'm not sure this would be the best approach.Or I'm missing some easy way of getting this context information without extending anything?
The text was updated successfully, but these errors were encountered: