@@ -316,7 +316,7 @@ private function createResult(\PgSql\Result $result, string $sql): PostgresResul
316
316
317
317
\assert ($ this ->types !== null , 'Expected type array to be populated before creating a result ' );
318
318
319
- switch (\pg_result_status ($ result )) {
319
+ switch ($ status = \pg_result_status ($ result )) {
320
320
case \PGSQL_EMPTY_QUERY :
321
321
throw new SqlQueryError ("Empty query string " );
322
322
@@ -353,7 +353,11 @@ private function createResult(\PgSql\Result $result, string $sql): PostgresResul
353
353
default :
354
354
// @codeCoverageIgnoreStart
355
355
$ 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
+ ));
357
361
// @codeCoverageIgnoreEnd
358
362
}
359
363
}
@@ -471,7 +475,7 @@ public function prepare(string $sql): PostgresStatement
471
475
$ future = async (function () use ($ name , $ modifiedSql , $ sql ): string {
472
476
$ result = $ this ->send (\pg_send_prepare (...), $ name , $ modifiedSql );
473
477
474
- switch (\pg_result_status ($ result, \ PGSQL_STATUS_LONG )) {
478
+ switch ($ status = \pg_result_status ($ result )) {
475
479
case \PGSQL_COMMAND_OK :
476
480
return $ name ; // Statement created successfully.
477
481
@@ -488,7 +492,11 @@ public function prepare(string $sql): PostgresStatement
488
492
489
493
default :
490
494
// @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
+ ));
492
500
// @codeCoverageIgnoreEnd
493
501
}
494
502
});
0 commit comments