Make it clear what the maximum length is for $cfg->dbprefix

Bug #1332373 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Low
Aaron Wells

Bug Description

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?

Revision history for this message
Aaron Wells (u-aaronw) wrote :

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_subscription_forum, and interaction_forum_subscription_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.

Changed in mahara:
status: In Progress → New
status: New → Confirmed
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 1.10.0 → 1.10.1
milestone: 1.10.1 → 1.11.0
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 15.04.0 → 15.04.1
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 15.04.1 → 15.10.0
assignee: nobody → Aaron Wells (u-aaronw)
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 15.10.0 → 16.04.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/6057

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/6057
Committed: https://git.mahara.org/mahara/mahara/commit/240befff090020a134804a47a09a1b67f8b017f1
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 240befff090020a134804a47a09a1b67f8b017f1
Author: Aaron Wells <email address hidden>
Date: Fri Feb 12 15:36:50 2016 +1300

Bug 1332373: Add 19-character dbprefix limit to documentation

Based on the maximum database object name length in Postgres,
and the longest names of objects we're currently using, 19
characters is the hard limit. (Technically... 25 characters
for MySQL. But why confuse things?)

We're actively testing on test.mahara.org with a 19-character
db prefix, so I think it's safe to tell the users that they
can use one that long.

Change-Id: Id13ee82ca70780791870782b8465695366cee8eb
behatnotneeded: comment change only

Robert Lyon (robertl-9)
Changed in mahara:
status: Confirmed → Fix Committed
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.