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

TABLE METADATA - Add a table history, about STRUCTURE and queries that was done to change the structure (like GIT log)

    Details

    • Type: Task
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      hi guys, should be nice a tool or sql commands to see .frm history
      what i'm talking about?
      1)CREATE TABLE A (a int);
      2)ALTER TABLE A add b int;
      3)ALTER TABLE A drop a;

      that information that could be nice to have
      and maybe after this we could some tool like diff

      diff table a.1 a.current
      and it will create a query like:
      )alter table a add b int, drop a;

      something similar to git, but instead of checkout, just reproduce the diff query (queries) to update the current table from some point in time

      second part is replication or export/import and merge
      it's like merge in git, and push/pull

      well it's a bit complicated but with this tool and git, i could have a full history of table inside database, instead inside some other file, and since it's inside database, i will never lost historical information

      i don't know if this could be done with binlog or something similar, but could be nice this tool be a per table log, instead a "daemon" binlog

      for first version just history could be nice, and at a second version the diff tool

      some fields that i thik that are usefull
      unique hash (like git), user, datetime, ddl command

      well that's all thanks guys!

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            you can do that with an audit plugin. this plugin can be notified when a table is created or altered, and it can keep track of all statements that did that.

            Show
            serg Sergei Golubchik added a comment - you can do that with an audit plugin. this plugin can be notified when a table is created or altered, and it can keep track of all statements that did that.
            Hide
            rspadim roberto spadim added a comment -

            some ALTER command needs a UPDATE, in other words, maybe some UPDATE queries should be changed to include a option, like:
            1) CREATE TABLE A (a int, primary key(a));
            2) ALTER TABLE A add b int;
            3) UPDATE INCLUDE_IN_HISTORY A SET b=a;
            4) ALTER TABLE DROP PRIMARY KEY, ADD PRIMARY KEY (b);

            the INCLUDE_IN_HISTORY could add the query to table definition log
            well for now that's all

            Show
            rspadim roberto spadim added a comment - some ALTER command needs a UPDATE, in other words, maybe some UPDATE queries should be changed to include a option, like: 1) CREATE TABLE A (a int, primary key(a)); 2) ALTER TABLE A add b int; 3) UPDATE INCLUDE_IN_HISTORY A SET b=a; 4) ALTER TABLE DROP PRIMARY KEY, ADD PRIMARY KEY (b); the INCLUDE_IN_HISTORY could add the query to table definition log well for now that's all
            Hide
            rspadim roberto spadim added a comment -

            hi sergey, i'm a source code begineer, could you give me more information about audit? maybe a example?
            i will need information about how to write inside files too, example, how to write to file "table_name.hist" in the same folder of "table_name.frm"?
            and the other question is, what file format should i use? a flat file? a "sqlite" file? any idea?

            Show
            rspadim roberto spadim added a comment - hi sergey, i'm a source code begineer, could you give me more information about audit? maybe a example? i will need information about how to write inside files too, example, how to write to file "table_name.hist" in the same folder of "table_name.frm"? and the other question is, what file format should i use? a flat file? a "sqlite" file? any idea?
            Hide
            serg Sergei Golubchik added a comment -

            Yes. see plugin/audit_null example in the MariaDB 5.5 source tree.
            It also shows how to create files and write there.
            Still, for basic C/C++ questions, please use appropriate forums or mailing lists.

            Show
            serg Sergei Golubchik added a comment - Yes. see plugin/audit_null example in the MariaDB 5.5 source tree. It also shows how to create files and write there. Still, for basic C/C++ questions, please use appropriate forums or mailing lists.
            Hide
            rspadim roberto spadim added a comment -

            nice, what about make it a 'default' feature of mariadb?
            should i first create plugin, submit it and wait for a stable version?
            after that mariadb could include it by default in binary/source code packages?

            Show
            rspadim roberto spadim added a comment - nice, what about make it a 'default' feature of mariadb? should i first create plugin, submit it and wait for a stable version? after that mariadb could include it by default in binary/source code packages?
            Hide
            serg Sergei Golubchik added a comment -

            yes, if you create such a plugin, and we accept it into the mainline, then it can be included by default in our releases.

            Show
            serg Sergei Golubchik added a comment - yes, if you create such a plugin, and we accept it into the mainline, then it can be included by default in our releases.
            Hide
            rspadim roberto spadim added a comment -

            maybe this MDEV-4259 could help here

            Show
            rspadim roberto spadim added a comment - maybe this MDEV-4259 could help here

              People

              • Assignee:
                Unassigned
                Reporter:
                rspadim roberto spadim
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - 10 weeks
                  10w
                  Remaining:
                  Remaining Estimate - 10 weeks
                  10w
                  Logged:
                  Time Spent - Not Specified
                  Not Specified