Skip to content

Commit af5a2c3

Browse files
committed
Support specifying database name in authentication phase
1 parent f77f6ff commit af5a2c3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

packages/wp-mysql-proxy/src/class-mysql-session.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,15 @@ private function process_authentication( string $payload ): string {
251251
// Get the database name.
252252
if ( $client_flags & MySQL_Protocol::CLIENT_CONNECT_WITH_DB ) {
253253
$database = MySQL_Protocol::read_null_terminated_string( $payload, $offset );
254+
$result = $this->adapter->handle_query( 'USE ' . $database );
255+
if ( $result->error_info ) {
256+
return MySQL_Protocol::build_err_packet(
257+
$this->packet_id++,
258+
1049,
259+
'42000',
260+
sprintf( "Unknown database: '%s'", $database )
261+
);
262+
}
254263
}
255264

256265
// Get the authentication plugin name.

0 commit comments

Comments
 (0)