Bug #17463 no "use <database>" generated
Submitted: 16 Feb 2006 15:06 Modified: 18 Jun 2006 19:11
Reporter: Kristian Koehntopp Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Migration Toolkit Severity:S3 (Non-critical)
Version:1.0.23 OS:Windows (Windows)
Assigned to: Michael G. Zinner CPU Architecture:Any

[16 Feb 2006 15:06] Kristian Koehntopp
Description:
When migrating a large number of schema definitions at once, a CREATE DATABASE statement is generated, but is not followed by a USE statement. Some of the generated statements depend on the current database being set correctly, though.

How to repeat:
Select 2 schema definitions and migrate them into a Creates.sql file. Look at the generated code. CREATE DATABASE statements are generated, USE statements for these database are not generated.

This will fail later when migrating views, foreign key constraints and other stuff.

Suggested fix:
Simply add a USE statement where needed.
[16 Feb 2006 17:33] MySQL Verification Team
Hi,

I got another behavior also a bug:

I created 2 schemas on Windows db34 and db35 and 2 tables
db34.tb34 and db34.tb35. The scripr created for to migrate to
a Linux box, creates the db34 and the 2 tables and creates the
db35 empty.

Initializing JDBC driver ... 
Driver class MySQL JDBC Driver 3.1
Opening connection ... 
Connection jdbc:mysql://192.168.0.119:3306/?user=miguel&password=miguel&useServerPrepStmts=false

Execute script header commands.
-- ----------------------------------------------------------------------
-- MySQL GRT Application
-- SQL Script
-- ----------------------------------------------------------------------

SET FOREIGN_KEY_CHECKS = 0
Creating schema db34 ...
CREATE DATABASE IF NOT EXISTS `db34`
  CHARACTER SET latin1 COLLATE latin1_swedish_ci
Creating tables ...

Creating table tb34 ...
DROP TABLE IF EXISTS `db34`.`tb34`
Creating table tb34 ...

CREATE TABLE `db34`.`tb34` (
  `id` INT(11) NULL
)
ENGINE = INNODB

Creating table tb35 ...
DROP TABLE IF EXISTS `db34`.`tb35`
Creating table tb35 ...

CREATE TABLE `db34`.`tb35` (
  `id` INT(11) NULL
)
ENGINE = INNODB
Creating views ...
Creating procedures ...

Creating schema db35 ...
CREATE DATABASE IF NOT EXISTS `db35`
  CHARACTER SET latin1 COLLATE latin1_swedish_ci
Creating tables ...
Creating views ...
Creating procedures ...

Execute script footer commands.
SET FOREIGN_KEY_CHECKS = 1
[16 Feb 2006 17:34] MySQL Verification Team
I meant 2 tables db34.tb34 and db35.tb35. One table for each schema.
[18 Jun 2006 19:11] Michael G. Zinner
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html