Bug #42321 --change_user with default args works different in embedded and standalone mode

Submitted: 24 Jan 2009 14:05 Modified: 9 Jan 2015 16:01
Reporter: Gleb Shchepa Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.0, 5.1, 6.0 bzr OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any
Tags: change_user, embedded, mysqltest, regression

[24 Jan 2009 14:05] Gleb Shchepa
Description:
The mysqltest client executes the "change_user" command without database name parameter differently under standalone and embedded server mode:

a) for standalone server mode it uses _current_ database as default database,
b) for embedded server it uses _no_ database as default database.

How to repeat:
Standard test file:

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (i INT);
--change_user
SELECT * FROM t1;
DROP TABLE t1;

Standalone server mode: no errors.
Embedded server mode:

mysqltest: At line 6: query 'SELECT * FROM t1' failed: 1046: No database selected

Suggested fix:
For a standalone mode a client program calls CLI_MYSQL_REAL_CONNECT() that set MYSQL::db field to opening database name. Then mysqltest uses that field value as default database name for --change_user command etc. However, a client doesn't call that function in embedded mode, and its MYSQL::db field is always set to NULL.

Probably it may be a robust solution to move an assignment of the current database name to MYSQL::db field from the CLI_MYSQL_REAL_CONNECT function to all kinds of mysql_real_connect function.
[25 Jan 2009 17:14] Sveta Smirnova
Thank you for the report.

Verified as described. With version 4.1 bug is not repeatable.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.