Problem/Motivation

The PostgreSQL driver throw a DatabaseExceptionWrapper to provide additional debug information.
For the Insert query, this driver pass wrong argument to this Exception (an integer instead of a throwable).

throw new DatabaseExceptionWrapper($message, 0, $e->getCode());

Proposed resolution

It should pass the exception code as second argument and the exception as the third one.

throw new DatabaseExceptionWrapper($message, $e->getCode(), $e);

Comments

papajo created an issue. See original summary.

papajo’s picture

Here is a patch to fix it.

cilefen’s picture

Status: Active » Needs review
Issue tags: -pgsql exception
kalpaitch’s picture

Status: Needs review » Reviewed & tested by the community

Tested, this works for me and looks like the correct approach.

szeidler’s picture

Good catch. +1 for the change. Otherwise you will see a Wrong parameters for Drupal\Core\Database\DatabaseExceptionWrapper( instead of the database error you're interested in.

quietone’s picture

Version: 9.2.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Bug Smash Initiative

The file being changed here was deprecated in Drupal 9.4 and moved to the pgsql module, in #3129043: Move core database drivers to modules of their own. The exception is now handled in \Drupal\Core\Database\ExceptionHandler::handleExecutionException() which is where I think this change needs to be moved to. Setting to NW and changing version to 10.0.x

kalpaitch’s picture

Version: 10.0.x-dev » 9.3.x-dev
Status: Needs work » Closed (won't fix)

This doesn't seem to be an issue in 9.4. The exception handler handles exceptions as expected. Still an issue for older versions prior to 9.4 though.