Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take care of dependencies between VIEW definitions #72

Open
mpdude opened this issue Sep 7, 2020 · 0 comments
Open

Take care of dependencies between VIEW definitions #72

mpdude opened this issue Sep 7, 2020 · 0 comments

Comments

@mpdude
Copy link
Member

mpdude commented Sep 7, 2020

Since v1.10, slimdump will also dump VIEW definitions.

One possible issue with that is that one VIEW might be built on top of another one. To make it possible to load the dump into an empty database schema, we need to take these dependencies between VIEWs into consideration.

One approach might be to build something like a dependency graph and dump the VIEWs in the right order. I'd suspect that there cannot be cycles for logical reasons.

The other solution would be to have a look at how mysqldump solves this. In fact, it creates something like temporary placeholders for views and replacing those in a final phase.

/* many lines removed for clarity ... */
CREATE TABLE `test` (
  `id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*!50001 CREATE VIEW `view1` AS SELECT 1 AS `id`*/;

/*!50001 CREATE VIEW `view2` AS SELECT 1 AS `id`*/;

--
-- Final view structure for view `view1`
--

/*!50001 DROP VIEW IF EXISTS `view1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`...`@`...` SQL SECURITY DEFINER */
/*!50001 VIEW `view1` AS select `view2`.`id` AS `id` from `view2` */;

--
-- Final view structure for view `view2`
--

/*!50001 DROP VIEW IF EXISTS `view2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`...`@`...` SQL SECURITY DEFINER */
/*!50001 VIEW `view2` AS select `test`.`id` AS `id` from `test` */;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant