WL#2795: mysqldump option to dump routines

Affects: Server-5.0   —   Status: Assigned

See BUG#9056

there're different tasks to solve:

   - backup. in this case sql dump should be able to restore db to the
     exact state it was before

   - migrate. There were bugreports that views are dumped together with
     the db name, and they cannot be restored to another db. The same
     arguing could be applied to the routine dump if it will include
     definer.

 problems:

   - a mere user cannot access mysql.proc table to get routine data,
     though he can use SHOW CREATE PROCEDURE|FUNCTION and
     SHOW PROCEDURE|FUNCTION STATUS

   - a mere user cannot insert into mysql.proc, he can only use
     CREATE PROCEDURE|FUNCTION, and this way he can only create routines
     with himself as a definer. (good for "migrate" task, bad for
     "backup")

Solution:

  command line option --routines

  if it's specified, mysqldump uses SHOW commands are used to get
  routine data, CREATE commands are written in the dump. No need to
  bother about timestamps or definer. We assume "mere user" mode and
  "migrate" task.

  if it's not specified, mysqldump does not dump routines or does
  anything special about them at all. User can dump mysql.proc table
  directly (if he has enough privileges to access it), and INSERT will
  go into the dump to restore routines - all the routine attributes,
  including timestamps and definer will be restored. It corresponds to the
  "DBA" mode and "backup" task.

The difference between these modes and tasks is not exactly trivial, so
as a part of this WL, documentation team should not only get a
description of what new command line option does ("dumps routines"), but
also when, how, and who should use it (these "modes" and "tasks").