Database table prefix

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The next feature release of phpBB 3 will be 3.2/Rhea followed by 3.3.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.1. If you need support for phpBB 3.1 please visit the 3.1.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 » Sat Aug 08, 2015 11:30 am

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 » Sat Aug 08, 2015 11:51 am

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

User avatar
kinerity
Registered User
Posts: 22
Joined: Mon Sep 01, 2014 10:54 pm

Re: Database table prefix

Post by kinerity » Tue Aug 18, 2015 9:54 pm

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


Post Reply