mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
- reimplemented autoincrement support in the convertor, made it more generic
#7528 git-svn-id: file:///svn/phpbb/trunk@6980 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
b8b1aa812b
commit
f885fc36ae
2 changed files with 39 additions and 80 deletions
|
@ -314,6 +314,7 @@ if (!$get_info)
|
||||||
'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
|
'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
|
||||||
'primary' => 'attachments.attach_id',
|
'primary' => 'attachments.attach_id',
|
||||||
'query_first' => (defined('MOD_ATTACHMENT')) ? $convert->truncate_statement . ATTACHMENTS_TABLE : '',
|
'query_first' => (defined('MOD_ATTACHMENT')) ? $convert->truncate_statement . ATTACHMENTS_TABLE : '',
|
||||||
|
'autoincrement' => 'attach_id',
|
||||||
|
|
||||||
array('attach_id', 'attachments.attach_id', ''),
|
array('attach_id', 'attachments.attach_id', ''),
|
||||||
array('post_msg_id', 'attachments.post_id', ''),
|
array('post_msg_id', 'attachments.post_id', ''),
|
||||||
|
@ -338,6 +339,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
|
'target' => (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
|
||||||
'primary' => 'attachments.attach_id',
|
'primary' => 'attachments.attach_id',
|
||||||
|
'autoincrement' => 'attach_id',
|
||||||
|
|
||||||
array('attach_id', 'attachments.attach_id', ''),
|
array('attach_id', 'attachments.attach_id', ''),
|
||||||
array('post_msg_id', 'attachments.privmsgs_id', ''),
|
array('post_msg_id', 'attachments.privmsgs_id', ''),
|
||||||
|
@ -362,6 +364,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => (defined('MOD_ATTACHMENT')) ? EXTENSIONS_TABLE : '',
|
'target' => (defined('MOD_ATTACHMENT')) ? EXTENSIONS_TABLE : '',
|
||||||
'query_first' => (defined('MOD_ATTACHMENT')) ? $convert->truncate_statement . EXTENSIONS_TABLE : '',
|
'query_first' => (defined('MOD_ATTACHMENT')) ? $convert->truncate_statement . EXTENSIONS_TABLE : '',
|
||||||
|
'autoincrement' => 'extension_id',
|
||||||
|
|
||||||
array('extension_id', 'extensions.ext_id', ''),
|
array('extension_id', 'extensions.ext_id', ''),
|
||||||
array('group_id', 'extensions.group_id', ''),
|
array('group_id', 'extensions.group_id', ''),
|
||||||
|
@ -371,6 +374,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => (defined('MOD_ATTACHMENT')) ? EXTENSION_GROUPS_TABLE : '',
|
'target' => (defined('MOD_ATTACHMENT')) ? EXTENSION_GROUPS_TABLE : '',
|
||||||
'query_first' => (defined('MOD_ATTACHMENT')) ? $convert->truncate_statement . EXTENSION_GROUPS_TABLE : '',
|
'query_first' => (defined('MOD_ATTACHMENT')) ? $convert->truncate_statement . EXTENSION_GROUPS_TABLE : '',
|
||||||
|
'autoincrement' => 'group_id',
|
||||||
|
|
||||||
array('group_id', 'extension_groups.group_id', ''),
|
array('group_id', 'extension_groups.group_id', ''),
|
||||||
array('group_name', 'extension_groups.group_name', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
|
array('group_name', 'extension_groups.group_name', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
|
||||||
|
@ -414,6 +418,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => RANKS_TABLE,
|
'target' => RANKS_TABLE,
|
||||||
'query_first' => $convert->truncate_statement . RANKS_TABLE,
|
'query_first' => $convert->truncate_statement . RANKS_TABLE,
|
||||||
|
'autoincrement' => 'rank_id',
|
||||||
|
|
||||||
array('rank_id', 'ranks.rank_id', ''),
|
array('rank_id', 'ranks.rank_id', ''),
|
||||||
array('rank_title', 'ranks.rank_title', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
|
array('rank_title', 'ranks.rank_title', array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
|
||||||
|
@ -426,6 +431,7 @@ if (!$get_info)
|
||||||
'target' => TOPICS_TABLE,
|
'target' => TOPICS_TABLE,
|
||||||
'query_first' => $convert->truncate_statement . TOPICS_TABLE,
|
'query_first' => $convert->truncate_statement . TOPICS_TABLE,
|
||||||
'primary' => 'topics.topic_id',
|
'primary' => 'topics.topic_id',
|
||||||
|
'autoincrement' => 'topic_id',
|
||||||
|
|
||||||
array('topic_id', 'topics.topic_id', ''),
|
array('topic_id', 'topics.topic_id', ''),
|
||||||
array('forum_id', 'topics.forum_id', ''),
|
array('forum_id', 'topics.forum_id', ''),
|
||||||
|
@ -456,6 +462,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => TOPICS_TABLE,
|
'target' => TOPICS_TABLE,
|
||||||
'primary' => 'topics.topic_id',
|
'primary' => 'topics.topic_id',
|
||||||
|
'autoincrement' => 'topic_id',
|
||||||
|
|
||||||
array('topic_id', 'topics.topic_id', ''),
|
array('topic_id', 'topics.topic_id', ''),
|
||||||
array('forum_id', 'topics.forum_id', ''),
|
array('forum_id', 'topics.forum_id', ''),
|
||||||
|
@ -496,6 +503,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => SMILIES_TABLE,
|
'target' => SMILIES_TABLE,
|
||||||
'query_first' => $convert->truncate_statement . SMILIES_TABLE,
|
'query_first' => $convert->truncate_statement . SMILIES_TABLE,
|
||||||
|
'autoincrement' => 'smiley_id',
|
||||||
|
|
||||||
array('smiley_id', 'smilies.smilies_id', ''),
|
array('smiley_id', 'smilies.smilies_id', ''),
|
||||||
array('code', 'smilies.code', 'phpbb_set_encoding'),
|
array('code', 'smilies.code', 'phpbb_set_encoding'),
|
||||||
|
@ -543,6 +551,7 @@ if (!$get_info)
|
||||||
'target' => WORDS_TABLE,
|
'target' => WORDS_TABLE,
|
||||||
'primary' => 'words.word_id',
|
'primary' => 'words.word_id',
|
||||||
'query_first' => $convert->truncate_statement . WORDS_TABLE,
|
'query_first' => $convert->truncate_statement . WORDS_TABLE,
|
||||||
|
'autoincrement' => 'word_id',
|
||||||
|
|
||||||
array('word_id', 'words.word_id', ''),
|
array('word_id', 'words.word_id', ''),
|
||||||
array('word', 'words.word', 'phpbb_set_encoding'),
|
array('word', 'words.word', 'phpbb_set_encoding'),
|
||||||
|
@ -552,6 +561,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => POSTS_TABLE,
|
'target' => POSTS_TABLE,
|
||||||
'primary' => 'posts.post_id',
|
'primary' => 'posts.post_id',
|
||||||
|
'autoincrement' => 'post_id',
|
||||||
'query_first' => $convert->truncate_statement . POSTS_TABLE,
|
'query_first' => $convert->truncate_statement . POSTS_TABLE,
|
||||||
'execute_first' => '
|
'execute_first' => '
|
||||||
$config["max_post_chars"] = 0;
|
$config["max_post_chars"] = 0;
|
||||||
|
@ -595,6 +605,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => PRIVMSGS_TABLE,
|
'target' => PRIVMSGS_TABLE,
|
||||||
'primary' => 'privmsgs.privmsgs_id',
|
'primary' => 'privmsgs.privmsgs_id',
|
||||||
|
'autoincrement' => 'privmsgs_id',
|
||||||
'query_first' => array(
|
'query_first' => array(
|
||||||
$convert->truncate_statement . PRIVMSGS_TABLE,
|
$convert->truncate_statement . PRIVMSGS_TABLE,
|
||||||
$convert->truncate_statement . PRIVMSGS_RULES_TABLE,
|
$convert->truncate_statement . PRIVMSGS_RULES_TABLE,
|
||||||
|
@ -741,6 +752,7 @@ if (!$get_info)
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'target' => GROUPS_TABLE,
|
'target' => GROUPS_TABLE,
|
||||||
|
'autoincrement' => 'group_id',
|
||||||
'query_first' => $convert->truncate_statement . GROUPS_TABLE,
|
'query_first' => $convert->truncate_statement . GROUPS_TABLE,
|
||||||
|
|
||||||
array('group_id', 'groups.group_id', ''),
|
array('group_id', 'groups.group_id', ''),
|
||||||
|
@ -781,6 +793,7 @@ if (!$get_info)
|
||||||
array(
|
array(
|
||||||
'target' => USERS_TABLE,
|
'target' => USERS_TABLE,
|
||||||
'primary' => 'users.user_id',
|
'primary' => 'users.user_id',
|
||||||
|
'autoincrement' => 'user_id',
|
||||||
'query_first' => array(
|
'query_first' => array(
|
||||||
'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS,
|
'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS,
|
||||||
$convert->truncate_statement . BOTS_TABLE
|
$convert->truncate_statement . BOTS_TABLE
|
||||||
|
|
|
@ -910,48 +910,13 @@ class install_convert extends module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($db->sql_layer === 'postgres')
|
if (!empty($schema['autoincrement']))
|
||||||
{
|
{
|
||||||
$tables = array(
|
switch ($db->sql_layer)
|
||||||
ATTACHMENTS_TABLE => 'attach_id',
|
|
||||||
ACL_OPTIONS_TABLE => 'auth_option_id',
|
|
||||||
ACL_ROLES_TABLE => 'role_id',
|
|
||||||
BANLIST_TABLE => 'ban_id',
|
|
||||||
BOTS_TABLE => 'bot_id',
|
|
||||||
DISALLOW_TABLE => 'disallow_id',
|
|
||||||
DRAFTS_TABLE => 'draft_id',
|
|
||||||
EXTENSIONS_TABLE => 'extension_id',
|
|
||||||
EXTENSION_GROUPS_TABLE => 'group_id',
|
|
||||||
FORUMS_TABLE => 'forum_id',
|
|
||||||
GROUPS_TABLE => 'group_id',
|
|
||||||
ICONS_TABLE => 'icons_id',
|
|
||||||
LANG_TABLE => 'lang_id',
|
|
||||||
LOG_TABLE => 'log_id',
|
|
||||||
MODULES_TABLE => 'module_id',
|
|
||||||
POSTS_TABLE => 'post_id',
|
|
||||||
PRIVMSGS_TABLE => 'msg_id',
|
|
||||||
PRIVMSGS_FOLDER_TABLE => 'folder_id',
|
|
||||||
PRIVMSGS_RULES_TABLE => 'rule_id',
|
|
||||||
PROFILE_FIELDS_TABLE => 'field_id',
|
|
||||||
RANKS_TABLE => 'rank_id',
|
|
||||||
REPORTS_TABLE => 'report_id',
|
|
||||||
REPORTS_REASONS_TABLE => 'reason_id',
|
|
||||||
SEARCH_WORDLIST_TABLE => 'word_id',
|
|
||||||
SITELIST_TABLE => 'site_id',
|
|
||||||
SMILIES_TABLE => 'smiley_id',
|
|
||||||
STYLES_TABLE => 'style_id',
|
|
||||||
STYLES_TEMPLATE_TABLE => 'template_id',
|
|
||||||
STYLES_TEMPLATE_DATA_TABLE => 'template_id',
|
|
||||||
STYLES_THEME_TABLE => 'theme_id',
|
|
||||||
STYLES_IMAGESET_TABLE => 'imageset_id',
|
|
||||||
TOPICS_TABLE => 'topic_id',
|
|
||||||
USERS_TABLE => 'user_id',
|
|
||||||
WARNINGS_TABLE => 'warning_id',
|
|
||||||
WORDS_TABLE => 'word_id'
|
|
||||||
);
|
|
||||||
if (!empty($tables[$schema['target']]))
|
|
||||||
{
|
{
|
||||||
$db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $tables[$schema['target']] . ")>0 then max(" . $tables[$schema['target']] . ")+1 else 1 end from " . $schema['target'] . '));');
|
case 'postgres':
|
||||||
|
$db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $schema['autoincrement'] . ")>0 then max(" . $schema['autoincrement'] . ")+1 else 1 end from " . $schema['target'] . '));');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1051,6 +1016,17 @@ class install_convert extends module
|
||||||
|
|
||||||
$convert->row = $convert_row = array();
|
$convert->row = $convert_row = array();
|
||||||
|
|
||||||
|
if (!empty($schema['autoincrement']))
|
||||||
|
{
|
||||||
|
switch ($db->sql_layer)
|
||||||
|
{
|
||||||
|
case 'mssql':
|
||||||
|
case 'mssql_odbc':
|
||||||
|
$db->sql_query('SET IDENTITY_INSERT ' . $schema['target'] . ' ON');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now handle the rows until time is over or no more rows to process...
|
// Now handle the rows until time is over or no more rows to process...
|
||||||
while (still_on_time())
|
while (still_on_time())
|
||||||
{
|
{
|
||||||
|
@ -1168,48 +1144,18 @@ class install_convert extends module
|
||||||
$waiting_rows = array();
|
$waiting_rows = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($db->sql_layer === 'postgres')
|
if (!empty($schema['autoincrement']))
|
||||||
{
|
{
|
||||||
$tables = array(
|
switch ($db->sql_layer)
|
||||||
ATTACHMENTS_TABLE => 'attach_id',
|
|
||||||
ACL_OPTIONS_TABLE => 'auth_option_id',
|
|
||||||
ACL_ROLES_TABLE => 'role_id',
|
|
||||||
BANLIST_TABLE => 'ban_id',
|
|
||||||
BOTS_TABLE => 'bot_id',
|
|
||||||
DISALLOW_TABLE => 'disallow_id',
|
|
||||||
DRAFTS_TABLE => 'draft_id',
|
|
||||||
EXTENSIONS_TABLE => 'extension_id',
|
|
||||||
EXTENSION_GROUPS_TABLE => 'group_id',
|
|
||||||
FORUMS_TABLE => 'forum_id',
|
|
||||||
GROUPS_TABLE => 'group_id',
|
|
||||||
ICONS_TABLE => 'icons_id',
|
|
||||||
LANG_TABLE => 'lang_id',
|
|
||||||
LOG_TABLE => 'log_id',
|
|
||||||
MODULES_TABLE => 'module_id',
|
|
||||||
POSTS_TABLE => 'post_id',
|
|
||||||
PRIVMSGS_TABLE => 'msg_id',
|
|
||||||
PRIVMSGS_FOLDER_TABLE => 'folder_id',
|
|
||||||
PRIVMSGS_RULES_TABLE => 'rule_id',
|
|
||||||
PROFILE_FIELDS_TABLE => 'field_id',
|
|
||||||
RANKS_TABLE => 'rank_id',
|
|
||||||
REPORTS_TABLE => 'report_id',
|
|
||||||
REPORTS_REASONS_TABLE => 'reason_id',
|
|
||||||
SEARCH_WORDLIST_TABLE => 'word_id',
|
|
||||||
SITELIST_TABLE => 'site_id',
|
|
||||||
SMILIES_TABLE => 'smiley_id',
|
|
||||||
STYLES_TABLE => 'style_id',
|
|
||||||
STYLES_TEMPLATE_TABLE => 'template_id',
|
|
||||||
STYLES_TEMPLATE_DATA_TABLE => 'template_id',
|
|
||||||
STYLES_THEME_TABLE => 'theme_id',
|
|
||||||
STYLES_IMAGESET_TABLE => 'imageset_id',
|
|
||||||
TOPICS_TABLE => 'topic_id',
|
|
||||||
USERS_TABLE => 'user_id',
|
|
||||||
WARNINGS_TABLE => 'warning_id',
|
|
||||||
WORDS_TABLE => 'word_id'
|
|
||||||
);
|
|
||||||
if (!empty($tables[$schema['target']]))
|
|
||||||
{
|
{
|
||||||
$db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $tables[$schema['target']] . ")>0 then max(" . $tables[$schema['target']] . ")+1 else 1 end from " . $schema['target'] . '));');
|
case 'mssql':
|
||||||
|
case 'mssql_odbc':
|
||||||
|
$db->sql_query('SET IDENTITY_INSERT ' . $schema['target'] . ' OFF');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'postgres':
|
||||||
|
$db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $schema['autoincrement'] . ")>0 then max(" . $schema['autoincrement'] . ")+1 else 1 end from " . $schema['target'] . '));');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue