[Phpmyadmin-devel] Re: PMA db copy and InnoDB

Marc Delisle Marc.Delisle at cegepsherbrooke.qc.ca
Fri Dec 23 06:46:04 CET 2005


Michal Čihař a écrit :
> Hi Marc
> 
> replying to devel list as I thing it belongs there.
> 
> On Thu, 22 Dec 2005 13:46:20 -0500
> Marc Delisle <Marc.Delisle at cegepsherbrooke.qc.ca> wrote:
> 
> 
>>Can you confirm that there remains some work to do, to be able to copy a 
>>db containing innodb constraints? The constraints creation must be done 
>>after all necessary tables have been created.
> 
> 
> If you copy one table, you have to handle constraints manually. While
> copying whole database, it should work (if there are not possible cross
> db relations, what I don't know right now).

In my test, the copy of the following db fails, because when calling 
PMA_table_move_copy() the first time with table "persons", the 
referenced table "towns" does not exist but an attempt is made to create 
the constraint.

Note that exporting this db produces a correct dump, remembering to 
create the constraints after all the tables are created.


CREATE TABLE `persons` (
   `id` int(11) NOT NULL default '0',
   `name` varchar(50) NOT NULL default '',
   `town_id` int(11) NOT NULL default '0',
   PRIMARY KEY  (`id`),
   KEY `town_id` (`town_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `towns` (
   `id` int(11) NOT NULL default '0',
   `description` varchar(50) NOT NULL default '',
   PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


-- 
-- Constraints for table `persons`
-- 
ALTER TABLE `persons`
   ADD CONSTRAINT `persons_ibfk_1` FOREIGN KEY (`town_id`) REFERENCES 
`towns` (`id`);

> 
> 
>>Also, what's the goal of "Add constraints" ? I see that if someone does 
>>not tick it, it's a way to copy a db without an error about constraints, 
>>but what's next for the user? Manual constraints creation on the copy?
> 
> 
> Yes, currently you can use this to copy table without constraints.
> 
> 
>>A user cannot choose to copy "constraints only". If he could, this would 
>>be interesting for him because he can do the full db copy in 2 passes 
>>(assuming PMA does not let him do it in one pass).
> 
> 
> This should be easy to add, is it really needed? Shouldn't we provide
> tool for copying all dependent tables?
> 





More information about the Developers mailing list