mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[ticket/15055] Properly support index length check on mssql
PHPBB3-15055
This commit is contained in:
@@ -545,10 +545,7 @@ class mssql extends tools
|
||||
{
|
||||
$statements = array();
|
||||
|
||||
if ($this->mssql_is_sql_server_2000())
|
||||
{
|
||||
$this->check_index_name_length($table_name, $index_name);
|
||||
}
|
||||
$this->check_index_name_length($table_name, $index_name);
|
||||
|
||||
// remove index length
|
||||
$column = preg_replace('#:.*$#', '', $column);
|
||||
@@ -558,6 +555,21 @@ class mssql extends tools
|
||||
return $this->_sql_run_sql($statements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function get_max_index_name_length()
|
||||
{
|
||||
if ($this->mssql_is_sql_server_2000())
|
||||
{
|
||||
return parent::get_max_index_name_length();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@@ -1561,7 +1561,8 @@ class tools implements tools_interface
|
||||
*/
|
||||
protected function check_index_name_length($table_name, $index_name, $throw_error = true)
|
||||
{
|
||||
if (strlen($index_name) > 30)
|
||||
$max_index_name_length = $this->get_max_index_name_length();
|
||||
if (strlen($index_name) > $max_index_name_length)
|
||||
{
|
||||
// Try removing the table prefix if it's at the beginning
|
||||
$table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config)
|
||||
@@ -1582,13 +1583,23 @@ class tools implements tools_interface
|
||||
|
||||
if ($throw_error)
|
||||
{
|
||||
trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
|
||||
trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return $index_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maximum index name length. Might vary depending on db type
|
||||
*
|
||||
* @return int Maximum index name length
|
||||
*/
|
||||
protected function get_max_index_name_length()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user