From d6ac8f443a2b71b6eebd53963ff25b0c0fa79523 Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Fri, 15 Apr 2011 17:50:51 +0400 Subject: [PATCH 1/4] Create indexes for database tables during installation process --- src/messenger/webim/install/dbinfo.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index 502cf682..7557d3c6 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -112,6 +112,12 @@ $dbtables = array( ) ); +$dbtables_indexes = array( + "${mysqlprefix}chatmessage" => array( + "idx_agentid" => "agentid" + ) +); + $memtables = array(); $dbtables_can_update = array( @@ -139,7 +145,7 @@ function show_install_err($text) function create_table($id, $link) { - global $dbtables, $memtables, $dbencoding, $mysqlprefix; + global $dbtables, $dbtables_indexes, $memtables, $dbencoding, $mysqlprefix; if (!isset($dbtables[$id])) { show_install_err("Unknown table: $id, " . mysql_error($link)); @@ -152,6 +158,12 @@ function create_table($id, $link) $query .= " $k $v,\n"; } + if (isset($dbtables_indexes[$id])) { + foreach ($dbtables_indexes[$id] as $k => $v) { + $query .= " INDEX $k ($v),\n"; + } + } + $query = preg_replace("/,\n$/", "", $query); $query .= ") charset $dbencoding"; if (in_array($id, $memtables)) { From 2a5b6015def9b0d3e27968eeab4f406e6b57ca1c Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Fri, 15 Apr 2011 17:51:14 +0400 Subject: [PATCH 2/4] Fix check of existance of tables indexes during database upgrade process --- src/messenger/webim/install/dbperform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php index 9f5c3ae8..f64aadb3 100644 --- a/src/messenger/webim/install/dbperform.php +++ b/src/messenger/webim/install/dbperform.php @@ -154,7 +154,7 @@ if ($act == "silentcreateall") { runsql("ALTER TABLE ${mysqlprefix}chatgroup ADD vcemail varchar(64)", $link); } - $res = mysql_query("select null from information_schema.statistics where table_name = '${mysqlprefix}chatmessage' and index_name = 'idx_agentid'", $link); + $res = mysql_query("select null from information_schema.statistics where table_schema = '$mysqldb' and table_name = '${mysqlprefix}chatmessage' and index_name = 'idx_agentid'", $link); if ($res && mysql_num_rows($res) == 0) { runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link); } From f0b8fd06c32b80a68fcb05b277d00ed24cb250df Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Mon, 18 Apr 2011 16:05:45 +0400 Subject: [PATCH 3/4] Prepare to cut off branch --- src/messenger/webim/install/dbinfo.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index 7557d3c6..502cf682 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -112,12 +112,6 @@ $dbtables = array( ) ); -$dbtables_indexes = array( - "${mysqlprefix}chatmessage" => array( - "idx_agentid" => "agentid" - ) -); - $memtables = array(); $dbtables_can_update = array( @@ -145,7 +139,7 @@ function show_install_err($text) function create_table($id, $link) { - global $dbtables, $dbtables_indexes, $memtables, $dbencoding, $mysqlprefix; + global $dbtables, $memtables, $dbencoding, $mysqlprefix; if (!isset($dbtables[$id])) { show_install_err("Unknown table: $id, " . mysql_error($link)); @@ -158,12 +152,6 @@ function create_table($id, $link) $query .= " $k $v,\n"; } - if (isset($dbtables_indexes[$id])) { - foreach ($dbtables_indexes[$id] as $k => $v) { - $query .= " INDEX $k ($v),\n"; - } - } - $query = preg_replace("/,\n$/", "", $query); $query .= ") charset $dbencoding"; if (in_array($id, $memtables)) { From b10298807303ddcd31f974402b1e6025cb47bf96 Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Mon, 18 Apr 2011 16:06:27 +0400 Subject: [PATCH 4/4] Prepare to cut off branch --- src/messenger/webim/install/dbperform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php index f64aadb3..9f5c3ae8 100644 --- a/src/messenger/webim/install/dbperform.php +++ b/src/messenger/webim/install/dbperform.php @@ -154,7 +154,7 @@ if ($act == "silentcreateall") { runsql("ALTER TABLE ${mysqlprefix}chatgroup ADD vcemail varchar(64)", $link); } - $res = mysql_query("select null from information_schema.statistics where table_schema = '$mysqldb' and table_name = '${mysqlprefix}chatmessage' and index_name = 'idx_agentid'", $link); + $res = mysql_query("select null from information_schema.statistics where table_name = '${mysqlprefix}chatmessage' and index_name = 'idx_agentid'", $link); if ($res && mysql_num_rows($res) == 0) { runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link); }