Hyphens not accepted in database name templates

5 posts / 0 new
Last post
#1 Fri, 01/29/2010 - 14:55
jo

Hyphens not accepted in database name templates

The server template accepts hyphens without complaint, but when the domain owner tries to create a database, that hyphen is mapped to an underscore.

I'm wondering why: is this a setting somewhere? Or is there a technical reason? (I have been thinking it can't be the latter, since I have been using database names like jo-sql4 for years now, with no problems whatsoever.)

Fri, 01/29/2010 - 17:37
jo

Update: I see it's done because "mysql does not like hyphens or dots in a database name". I don't know about dots, but it does not care about hyphens, at least not since 5.0 (probably even since 4.x for some x).

Oh, and the removal of hyphens and dots is done twice, once in fix_database_name and once in edit_database.cgi, this should be done only in one place (and whatever the policy is, it should be reported when setting up the database prefix in the server template).

Sat, 01/30/2010 - 02:43
jo

Update 2: Virtualmin does not properly sanitize database names anyway.

The full rules for 5.0 are listed on page http://dev.mysql.com/doc/refman/5.0/en/identifiers.html . Short list: No U+0000, no U+00ff, no ./\ .

It may be smarter to leave checking of database names to Mysql.

Should I leave a tracker issue?

Sat, 01/30/2010 - 09:26
andreychek

Howdy,

Should I leave a tracker issue?

Yup, I might suggest doing that. I can't really speak to the specifics of why things were designed the way they were in the database area, so you may need to chat with Jamie there in the bug tracker a bit to get that all sorted out :-)

-Eric

Sat, 01/30/2010 - 12:13 (Reply to #4)
jo

OK, will do that.

I found that the code that does database name sanitizing is distributed across several files, so some clean-up would be in order anyway :)

Topic locked