Bug #17466 View dependencies not resolved

Submitted: 16 Feb 2006 15:12 Modified: 22 Jun 2006 14:03
Reporter: Kristian Koehntopp Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Migration Toolkit Severity:S2 (Serious)
Version:1.0.23 OS:Windows (Windows)
Assigned to: Michael G. Zinner CPU Architecture:Any

[16 Feb 2006 15:12] Kristian Koehntopp
Description:
Currently, MySQL requires that the objects references by view definitions exist when creating a view. MTK does not resolve the order of views properly and generates non-executeable SQL. mysqldump has the same problem, but solves it by generating stand-in tables which are later replaced by a view definition.

To resolve the problem, the stand-in table definitions must be added manually.

How to repeat:
create table basetable ( id integer );
create view first as select * from basetable;
create view second as select * from first;

in Oracle, migrate to MySQL.

Suggested fix:
Use the stand-in table technique that mysqldump uses for this:

--
-- Dumping data for table `basetable`
--

/*!40000 ALTER TABLE `basetable` DISABLE KEYS */;
LOCK TABLES `basetable` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `basetable` ENABLE KEYS */;

--
-- Table structure for table `first`
--

DROP TABLE IF EXISTS `first`;
/*!50001 DROP VIEW IF EXISTS `first`*/;
/*!50001 DROP TABLE IF EXISTS `first`*/;
/*!50001 CREATE TABLE `first` (
  `id` int(11)
) */;

--
-- Table structure for table `second`
--

DROP TABLE IF EXISTS `second`;
/*!50001 DROP VIEW IF EXISTS `second`*/;
/*!50001 DROP TABLE IF EXISTS `second`*/;
/*!50001 CREATE TABLE `second` (
  `id` int(11)
) */;

--
-- View structure for view `first`
--

/*!50001 DROP TABLE IF EXISTS `first`*/;
/*!50001 DROP VIEW IF EXISTS `first`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `first` AS select `basetable`.`id` AS `id` from `basetable`*/;

--
-- View structure for view `second`
--

/*!50001 DROP TABLE IF EXISTS `second`*/;
/*!50001 DROP VIEW IF EXISTS `second`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `second` AS select `first`.`id` AS `id` from `first`*/;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
[17 Feb 2006 13:40] Valeriy Kravchuk
Thank you for a problem report.
[22 Jun 2006 14:03] Michael G. Zinner
I now have disabled the migration of views per default because there are a lot of side effects that we cannot cover because we do not parse the view SQL code with a grammar in this version of the Migration Toolkit.

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.