Bug 1326205, in which MySQL installs would error out if there was a dbprefix present, has caused me to realize that we don't really have a set limit on maximum dbprefix length. Obviously, setting one that's too long, like "thisisareallyreallyreallyreallylongdbprefix" will cause the code to crash no matter what.
It would probably be a good idea to decide on a maximum dbprefix length, and put this into the pre-install sanity check. (It doesn't need to be mentioned in the config-dist.php file, because most people are going to be reasonable and use something short.)
For reference, MySQL has a limit of 64 characters for names of most things ( http://dev.mysql.com/doc/refman/5.1/en/identifiers.html ) and Postgres has a limit of 63 characters (because the "name" datatype is limited to 64 characters, one of which is used for a terminating null: http://www.postgresql.org/docs/8.3/static/datatype-character.html ).
With some quick testing, I find that in 1.10dev, the max length I can use in mysql is 25 characters, and in postgres it's 19 characters. I'm not sure why there's such a big difference... presumably this is due to some objects being created in Postgres but not in MySQL?
As discussed on IRC, the best reason to allow a long dbprefix, is that in some shared hosting environments users may be forced to have a dbprefix of "virtual host name + user name + application name".
So perhaps pegging it at 19 is a good idea. That gives us a maximum table name length of 44 characters, for Postgres.
The longest table name currently in the code base is 36 characters, a tie between interaction_ forum_subscript ion_forum, and interaction_ forum_subscript ion_topic.
When you're creating a trigger in Postgres, we add the 9-letter sequence "_function" to the end of it to determine its function name, so that puts a limit of 35 characters on how long is the name you should pass to the trigger. Currently the longest one is the one we just fixed "unmark_ quota_exceed_ upd_usr_ set", which is 31 characters.
Indeed, the functions like db_create_trigger() and create_table(), which create schema objects, should probably check that the name passed in isn't too long.