You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
psycopg2.Warning exceptions are never raised as stated in documentation though notices are correctly set. After a quick search I couldn't find where Warnings were raised in psycopg history. One could argue warnings such as privilege_not_revoked are 'important'.
Reason:
PGRES_NONFATAL_ERROR is not handled in pqpath.pq_fetch() and there is no 'warning' case in pqpath.exception_from_sqlstate() as PGRES_NONFATAL_ERROR is never returned by PQresultStatus. This is as libpq was designed and intended, non fatal errors are sent to the notice processor instead, however Warning Exceptions are not raised in connection_int where the notice processing occurs.
Possible resolutions:
Meh who cares.
Raise Warning in connection_int.conn_notice_callback() or connection_int.conn_notice_process() (could break current implementations that don't catch warnings). After looking at postgresql warning messages one could argue privilege_not_revoked (01006) for example is at least worthy of a Warning exception.
Add a code example somewhere similar to that below for users that want to pull out WARNING notices after each execute statement or block of statements if desired. This deletes notices after so there is no confusion which statement or block of statements caused the warning (there are no timestamps or counters associated with the notices).
Warnings are only passed as notices: I don't think it's a good idea building any policy on top of them at driver level. For a starter, "WARNING" is probably localized so we cannot really trust that string. So if anything I'd improve the docs. Feel free to provide a documentation patch, thank you.
Closing the issue. Meaningful doc patches are well accepted but we won't convert postgres warnings into python warnings. The application can easily do that where needed.
Overview:
psycopg2.Warning exceptions are never raised as stated in documentation though notices are correctly set. After a quick search I couldn't find where Warnings were raised in psycopg history. One could argue warnings such as privilege_not_revoked are 'important'.
Reason:
PGRES_NONFATAL_ERROR is not handled in pqpath.pq_fetch() and there is no 'warning' case in pqpath.exception_from_sqlstate() as PGRES_NONFATAL_ERROR is never returned by PQresultStatus. This is as libpq was designed and intended, non fatal errors are sent to the notice processor instead, however Warning Exceptions are not raised in connection_int where the notice processing occurs.
Possible resolutions:
or
The text was updated successfully, but these errors were encountered: