Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-18827

Create utility to parse frm files and print their DDL (Full-time project - potential part-time)

Details

    Description

      It would be useful if MariaDB had a utility that was able to parse frm files and print the DDL associated with the table.

      For example, it would be useful for users who performed a partial backup with Mariabackup:

      https://mariadb.com/kb/en/library/partial-backup-and-restore-with-mariabackup/

      But they forgot to also backup the table DDL, so they can't restore the tables using the following process:

      https://mariadb.com/kb/en/library/innodb-file-per-table-tablespaces/#importing-transportable-tablespaces-for-non-partitioned-tables

      mysqlfrm is a tool that already exists that does similar things:

      https://github.com/mysql/mysql-utilities/blob/master/scripts/mysqlfrm.py

      But it doesn't seem very user-friendly. It needs to be able to contact the local MariaDB server, and it also needs to be able to spawn a server instance, and it seems to need to be able to create a bunch of files during this process. e.g.:

      [ec2-user@ip-172-30-0-249 ~]$ cd /tmp
      [ec2-user@ip-172-30-0-249 tmp]$ sudo mysqlfrm --server=root:@localhost:3306 /var/lib/mysql/db1/tab.frm --port=12345 --user=mysql
      # Source on localhost: ... connected.
      # Spawning server with --user=mysql.
      # Starting the spawned server on port 12345 ... done.
      # Reading .frm files
      #
      # Reading the tab.frm file.
      #
      # CREATE statement for /var/lib/mysql/db1/tab.frm:
      #
       
      CREATE TABLE `db1`.`tab` (
        `id` int(11) NOT NULL,
        `str` varchar(50) DEFAULT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1
       
      #...done.
      

      Attachments

        Issue Links

          Activity

            This would be a huge benefit for mariabackup partial table or schema restore. this tool could help to automatize and thus simplify partial table or schema restore with mariabackup!!! which is still quite complicated for normal admins. Ideally Vladislav Vaintroub and/or Vladislav Lesin should look into this???

            oli Oli Sennhauser added a comment - This would be a huge benefit for mariabackup partial table or schema restore. this tool could help to automatize and thus simplify partial table or schema restore with mariabackup!!! which is still quite complicated for normal admins. Ideally Vladislav Vaintroub and/or Vladislav Lesin should look into this???

            The actual ROW_FORMAT used by InnoDB can differ from what is specified in the .frm file. See MDEV-26577 for a recent example.

            Sometimes, there are many .frm file encodings that lead to the same SHOW CREATE TABLE output, even though internally there is some significant change. Examples include MDEV-15225 and MDEV-28727.

            For partial restore of backups, I think that the correct solution would be to implement .frm file based IMPORT (MDEV-11658).

            marko Marko Mäkelä added a comment - The actual ROW_FORMAT used by InnoDB can differ from what is specified in the .frm file. See MDEV-26577 for a recent example. Sometimes, there are many .frm file encodings that lead to the same SHOW CREATE TABLE output, even though internally there is some significant change. Examples include MDEV-15225 and MDEV-28727 . For partial restore of backups, I think that the correct solution would be to implement .frm file based IMPORT ( MDEV-11658 ).

            As a partial workaround there is frmdump utility by DBSake:

            Decode a MySQL .frm file and output a CREATE VIEW or CREATE TABLE statement.

            This command does not require a MySQL server and interprets a .frm file according to rules similar to the MySQL server.

            barda Antonio Bardazzi added a comment - As a partial workaround there is frmdump utility by DBSake : Decode a MySQL .frm file and output a CREATE VIEW or CREATE TABLE statement. This command does not require a MySQL server and interprets a .frm file according to rules similar to the MySQL server.

            ALTER TABLE…IMPORT TABLESPACE based on the contents of the original .frm file was actually implemented in MDEV-26137.

            marko Marko Mäkelä added a comment - ALTER TABLE…IMPORT TABLESPACE based on the contents of the original .frm file was actually implemented in MDEV-26137 .

            People

              cvicentiu Vicențiu Ciorbaru
              GeoffMontee Geoff Montee (Inactive)
              Votes:
              5 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.