Skip to content

Commit

Permalink
ext/mysql: Don't mention errors for optional part of the test
Browse files Browse the repository at this point in the history
If the user we're running the tests as in MySQL is an unprivileged user,
we skip the CREATE DATABASE and CREATE SERVER tests. However, the
cleanup code still assumes they're there, and will fail with instead.

Instead, we simply don't print the messages for the equivalent DROP
calls. However, we still do for TABLE, since if we can't run anything in
the test database as the user we're running as, far more tests will
fail.

I don't know if this is the best approach; silencing the errors for when
those tests do run is unwise.
  • Loading branch information
NattyNarwhal committed Jan 13, 2025
1 parent 0e1fbf9 commit 2c71b2a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ext/mysqli/tests/mysqli_get_client_stats.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -922,14 +922,14 @@ if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test"))
if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test"))
printf("[c004] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats_"))
printf("[c005] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// These tests are optional if the database and server fail to create them;
// for example, if the user the tests run as are unprivileged. If we didn't
// run those before, then errors like no permissions here are spurious.
mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats_");

if (!mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats"))
printf("[c006] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats");

if (!mysqli_query($link, "DROP SERVER IF EXISTS myself"))
printf("[c007] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_query($link, "DROP SERVER IF EXISTS myself");

mysqli_close($link);
?>
Expand Down

0 comments on commit 2c71b2a

Please sign in to comment.