Database table prefix

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
marcovo
Registered User
Posts: 7
Joined: Sat Nov 15, 2014 9:57 am

Database table prefix

Post by marcovo »

This topic arose from two topics on the community site, here and here.

These topics are in essence about the error I also got, see the quote below.
General Error
Index name 'phpbb3_search_wordmatch_un_mtch' on table 'phpbb3_search_wordmatch' is too long. The maximum is 30 characters.

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/tools.php
LINE: 2119
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/tools.php
LINE: 664
CALL: phpbb\db\tools->sql_create_unique_index()

FILE: [ROOT]/install/install_install.php
LINE: 1216
CALL: phpbb\db\tools->sql_create_table()

FILE: [ROOT]/install/install_install.php
LINE: 99
CALL: install_install->load_schema()

FILE: [ROOT]/install/index.php
LINE: 409
CALL: install_install->main()

FILE: [ROOT]/install/index.php
LINE: 289
CALL: module->load()
The default table prefix is 'phpbb_', which is just small enough with its 6 characters. Any additional character will fail phpBB to install, which is caused by these lines of code. So, phpBB enforces a table prefix of at most 6 characters, but there are 2 problems here:
- The user is free to choose any prefix he/she wants; no checks are done to ensure the table prefix is short enough. You would at least assume there would be some warning message, before phpBB starts filling the database, to end up crashing?
- Additionally, isn't this index name a bit too long? Couldn't it be shortened? At the moment I do not any more; but there was a time I had 2 versions of a board running side-by-side, one called phpbb2_ (with, yes, phpBB 2.*), and the other phpbb3_ (you guessed it, 3.*). Now the prefix has to be shortened because the actual name is awfully long? This while the actual name shouldn't pop up too often, and people that deal with phpBB databases look at the prefixes all the time? :P

EDIT:
Additionally, I also wonder why here the table-prefix is hard-coded to be 'phpbb_' when the table-names are 'possibly' loaded. Because of this, in phpbb/db/tools.php#L2115-L2120 as above I now have:

Code: Select all

$table_prefix = 'phpbb_'
$table_name = 'phpbb3_search_wordmatch'
$index_name = 'un_mtch'
That prefix doesn't seem right to me?
Last edited by marcovo on Sat Aug 08, 2015 11:51 am, edited 1 time in total.

User avatar
javiexin
Registered User
Posts: 90
Joined: Thu Dec 22, 2011 10:04 am

Re: Database table prefix

Post by javiexin »

Indeed, I bumped into the same issue a way back: https://www.phpbb.com/community/viewtop ... &t=2306051

User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 36
Joined: Mon Sep 01, 2014 10:54 pm

Re: Database table prefix

Post by Kailey »

I can't say I've ever experienced this issue. Are you sure this isn't a DBMS issue and not a phpBB issue?

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 137
Joined: Sun Dec 18, 2005 5:44 pm
Location: Texas
Contact:

Re: Database table prefix

Post by Noxwizard »

There is a ticket open about this here: https://tracker.phpbb.com/browse/PHPBB3-13705

Post Reply