@@ -316,7 +316,7 @@ private function createResult(\PgSql\Result $result, string $sql): PostgresResul
316316
317317 \assert ($ this ->types !== null , 'Expected type array to be populated before creating a result ' );
318318
319- switch (\pg_result_status ($ result )) {
319+ switch ($ status = \pg_result_status ($ result )) {
320320 case \PGSQL_EMPTY_QUERY :
321321 throw new SqlQueryError ("Empty query string " );
322322
@@ -353,7 +353,11 @@ private function createResult(\PgSql\Result $result, string $sql): PostgresResul
353353 default :
354354 // @codeCoverageIgnoreStart
355355 $ this ->close ();
356- throw new SqlException ("Unknown result status " );
356+ throw new SqlException (\sprintf (
357+ "Unknown result status: %d; error: %s " ,
358+ $ status ,
359+ \pg_result_error ($ result ) ?: 'none ' ,
360+ ));
357361 // @codeCoverageIgnoreEnd
358362 }
359363 }
@@ -471,7 +475,7 @@ public function prepare(string $sql): PostgresStatement
471475 $ future = async (function () use ($ name , $ modifiedSql , $ sql ): string {
472476 $ result = $ this ->send (\pg_send_prepare (...), $ name , $ modifiedSql );
473477
474- switch (\pg_result_status ($ result, \ PGSQL_STATUS_LONG )) {
478+ switch ($ status = \pg_result_status ($ result )) {
475479 case \PGSQL_COMMAND_OK :
476480 return $ name ; // Statement created successfully.
477481
@@ -488,7 +492,11 @@ public function prepare(string $sql): PostgresStatement
488492
489493 default :
490494 // @codeCoverageIgnoreStart
491- throw new SqlException ("Unknown result status " );
495+ throw new SqlException (\sprintf (
496+ "Unknown result status: %d; error: %s " ,
497+ $ status ,
498+ \pg_result_error ($ result ) ?: 'none ' ,
499+ ));
492500 // @codeCoverageIgnoreEnd
493501 }
494502 });
0 commit comments