#4242 (ok 4.1.7) Wildcard-containing only_db failure in sidebar

4.1.5
fixed
Marc Delisle
None
1
2014-02-09
2014-01-21
Wayne Davison
No

The documentation for only_db still mentions that mysql LIKE wildcards are accepted, but using them fails to display properly in the sidebar -- the wildcards display literally, leaving no usable DB names in the sidebar.

A couple suggestions for how to fix this:

You could have a single spot in the code check the only_db list for wildcards, and if present, expand the list using "SHOW DATABASES LIKE ..." so that the only_db setting can always be assumed to be an array of actual DB names in the rest of the code. This would also allow you to remove some of the uses of LIKE in the db-name matching (which will improve speed due to SHOW DATABASES LIKE being faster than SELECT...FROM information_schema...LIKE).

You could decide to disallow wildcards in only_db and force the user to set the only_db config to a list of DB names. I'm using this idiom to work around the bug -- e.g. using this dir-listing idiom:

$prefix = 'expected_prefix_goes_here_';
$cfg['Servers'][$i]['only_db'] = preg_replace(
    '/@00([0-9a-f][0-9a-f])/e',
    'chr(hexdec(\'\1\'))',
    preg_grep("/^$prefix/", scandir('/var/lib/mysql/')));

Yes, that has some short-cuts in it (e.g. no check for dir-ness for matches and limited substitution for escaped letters), but it works for my needs.

Discussion

  • Vasu Bhardwaj
    Vasu Bhardwaj
    2014-01-25

    Isn't there a scope for ambiguity in [only_db] ??
    for e.g.
    $cfg['Servers'][$i]['only_db']='test%';
    this can mean-
    1.a database named test% ,or
    2.% is to be used a wildcard

     
  • Isaac Bennetch
    Isaac Bennetch
    2014-01-25

    Well, this isn't an authoritative or official answer, but IMHO "test%" should represent the wildcard and "test\%" should represent the literal database name test%.

     
  • Marc Delisle
    Marc Delisle
    2014-02-05

    Isaac's answer agrees with phpMyAdmin's documentation.

     
  • Vasu Bhardwaj
    Vasu Bhardwaj
    2014-02-06

    Thanks.
    I will try to fix it.

     
  • Marc Delisle
    Marc Delisle
    2014-02-09

    • summary: Wildcard-containing only_db failure in sidebar --> (ok 4.1.7) Wildcard-containing only_db failure in sidebar
    • status: open --> resolved
    • assigned_to: Marc Delisle
    • Priority: 5 --> 1
     
  • Marc Delisle
    Marc Delisle
    2014-02-09

    • Status: resolved --> fixed
     
  • Wayne Davison
    Wayne Davison
    2014-02-09

    Sadly, this change makes phpmyadmin even slower for systems with a lot of DBs, since it now does even more SELECT ... FROM information_schema requests than it did before. For our setup, I'll need to patch the removed code back into the source to get any useful performance.