phpmyadmin icon indicating copy to clipboard operation
phpmyadmin copied to clipboard

History tab

Open aurbacia opened this issue 6 years ago • 5 comments

Is your feature request related to a problem? Please describe.

I miss the tab where I can check all queries written/generated in PhpMyAdmin with option to undo some queries like UPDATE, INSERT or DELETE.

Describe the solution you'd like

Adding History tab where is list of all queries from last N-days generated or written by hand in PhpMyAdmin for specific table (with query, user who generate/written query and date execute of query). Also adding to settings option how long queries have to be remembered. History can be saved in phpmyadmin table. It is worth remembering such basic things as:

  • Pagination (for example. 10-15 entries on page)
  • Collapsed queries by default
  • I guess that it's worth add option to disable history for SELECT queries because many of them is generated automatic during using PhpMyAdmin (and them can't be undo)
  • I think that undo the query should be written in history, because "undo" is only generating query which is opposite to query. For example undo for INSERT: INSERT INTO `table` (`id`, `col1`, `col2`) VALUES (1, 'a', 'b') is: DELETE FROM `table` WHERE `id`=1 Undo for UPDATE: UPDATE `table` SET `col1` = 'c' WHERE `id`=1 is: UPDATE `table` SET `col1` = 'a' WHERE `id`=1 Undo for DELETE: DELETE FROM `table` WHERE `id`=1 is: INSERT INTO `table` (`id`, `col1`, `col2`) VALUES (1, 'a', 'b') Probably at the beginning is good to use PRIMARY KEY in undo's (and requirining PRIMARY KEY in table to undo's)

Describe alternatives you've considered

I don't have idea

Additional context

  • phpMyAdmin version: N/A

I wanna work on this feature if there are no contraindications to adding such a feature

aurbacia avatar May 02 '20 20:05 aurbacia

@ibennetch Could I have your advice on this feature request ?

williamdes avatar May 02 '20 20:05 williamdes

Hello, sorry but what about making this feature? I can start working on this?

aurbacia avatar May 17 '20 14:05 aurbacia

Hello @kbacia7

Yes, you can start working on this one, please open a draft pull-request as soon as possible so we can discuss the implementation

williamdes avatar May 17 '20 14:05 williamdes

I seem to have missed this when it first came up.

From what I understand of your suggestion is that this would be a lot like the current history tab, except for (1) configuring which databases are logged and (2) the undo feature.

About (1), I'd be okay with a directive to more finely control the logging. Currently this is global across a phpMyAdmin install, $cfg['QueryHistoryDB'] can't be set per-server much less per database or table. I think a robust implementation of this would be a configuration directive such as an array (probably with wildcard options) to enable or disable logging for particular databases (maybe tables, too). This quickly can turn in to a runaway feature, so we should define the scope, though.

Regarding (2), I don't think this is a good idea. There are too many queries and too much potential complexity to have a reliable undo option. If there are nested subqueries or a complex insert statement, or even something with no primary key, how can phpMyAdmin know what to undo? There could be intended modifications after the initial insert; what if a user inserts a value 'foo' through phpMyAdmin, modifies that to 'bar' from another application, and then tries to undo it with phpMyAdmin — what should the result be? This seems to me too complex and too fragile to be part of phpMyAdmin.

ibennetch avatar May 17 '20 17:05 ibennetch

Hm, okay. After some time I think that you are right that this is too hard to implementation, I didn't think about that queries which can contains for example subquery (INSERT also can contains subquery) and probably quickly turn out that many types of queries cannot use "undo", so now I see that this feature probably will not find much use and will be complicated

aurbacia avatar May 20 '20 17:05 aurbacia