[geeklog-cvs] geeklog: Modernized script to convert MyISAM to InnoDB tables - ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Aug 30 13:14:52 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/e4342d9f4180
changeset: 7270:e4342d9f4180
user: Dirk Haun <dirk at haun-online.de>
date: Sat Aug 29 20:46:46 2009 +0200
description:
Modernized script to convert MyISAM to InnoDB tables - mostly cosmetics. Create 'database_engine' entries in gl_vars table
diffstat:
public_html/admin/install/toinnodb.php | 85 +++++++++++++++------------
1 files changed, 47 insertions(+), 38 deletions(-)
diffs (142 lines):
diff -r d286e7c8b31d -r e4342d9f4180 public_html/admin/install/toinnodb.php
--- a/public_html/admin/install/toinnodb.php Sat Aug 29 19:57:10 2009 +0200
+++ b/public_html/admin/install/toinnodb.php Sat Aug 29 20:46:46 2009 +0200
@@ -2,15 +2,15 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.3 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | toinnodb.php |
// | |
// | Change Geeklog tables from MyISAM to InnoDB. |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2004 by the following authors: |
+// | Copyright (C) 2004-2009 by the following authors: |
// | |
-// | Authors: Dirk Haun - dirk at haun-online.de |
+// | Authors: Dirk Haun - dirk AT haun-online DOT de |
// +---------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
@@ -28,21 +28,16 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: toinnodb.php,v 1.1 2004/08/14 09:05:11 dhaun Exp $
-require_once ('../../lib-common.php');
+require_once '../../lib-common.php';
-// bail if user isn't a root user
-if (!SEC_inGroup ('Root')) {
- $display = COM_siteHeader ('menu');
- $display .= COM_startBlock ($MESSAGE[30], '',
- COM_getBlockTemplate ('_msg_block', 'header'));
- $display .= $LANG20[6];
- $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
- $display .= COM_siteFooter ();
- COM_accessLog ("User {$_USER['username']} tried to illegally access the optimize database screen.");
- echo $display;
+// bail if user isn't a Root user
+if (!SEC_inGroup('Root')) {
+ $display = COM_siteHeader('menu', $MESSAGE[30])
+ . COM_showMessageText($LANG20[6], $MESSAGE[30])
+ . COM_siteFooter();
+ COM_accessLog('User ' . COM_getDisplayName() . ' tried to illegally access the optimize database screen.');
+ COM_output($display);
exit;
}
@@ -53,15 +48,19 @@
* @return true = InnoDB tables supported, false = not supported
*
*/
-function innodb_supported ()
+function innodb_supported()
{
- $result = DB_query ("SHOW VARIABLES LIKE 'have_innodb'");
- $A = DB_fetchArray ($result, true);
+ global $_DB_dbms;
- if (strcasecmp ($A[1], 'yes') == 0) {
- $retval = true;
- } else {
- $retval = false;
+ $retval = false;
+
+ if ($_DB_dbms == 'mysql') {
+ $result = DB_query("SHOW VARIABLES LIKE 'have_innodb'");
+ $A = DB_fetchArray($result, true);
+
+ if (strcasecmp($A[1], 'yes') == 0) {
+ $retval = true;
+ }
}
return $retval;
@@ -70,29 +69,39 @@
// MAIN
-echo COM_siteHeader ('menu');
-echo COM_startBlock ('Changing tables to InnoDB');
+echo COM_siteHeader('menu', 'Changing tables to InnoDB');
+echo COM_startBlock('Changing tables to InnoDB');
-if (innodb_supported ()) {
+if (innodb_supported()) {
echo '<p>This may take a while ...</p>' . LB;
- flush ();
+ flush();
- $opt_time = new timerobject ();
- $opt_time->startTimer ();
+ $opt_time = new timerobject();
+ $opt_time->startTimer();
- $result = DB_query ("SHOW TABLES");
- $numTables = DB_numRows ($result);
+ DB_displayError(true);
+
+ $result = DB_query("SHOW TABLES");
+ $numTables = DB_numRows($result);
for ($i = 0; $i < $numTables; $i++) {
- $A = DB_fetchArray ($result, true);
- if (in_array ($A[0], $_TABLES)) {
- DB_query ("ALTER TABLE $A[0] TYPE=InnoDB");
+ $A = DB_fetchArray($result, true);
+ if (in_array($A[0], $_TABLES)) {
+ $make_innodb = DB_query("ALTER TABLE $A[0] TYPE=InnoDB", 1);
+ if ($make_innodb === false) {
+ echo '<p>SQL error for table "' . $A[0] . '" (ignored): '
+ . DB_error() . '</p>' . LB;
+ flush();
+ }
}
}
- $exectime = $opt_time->stopTimer ();
+ DB_delete($_TABLES['vars'], 'name', 'database_engine');
+ DB_query("INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_engine', 'InnoDB')");
- echo '<p>Changing ' . sizeof ($_TABLES) . ' tables to InnoDB took '
+ $exectime = $opt_time->stopTimer();
+
+ echo '<p>Changing ' . count($_TABLES) . ' tables to InnoDB took '
. $exectime . ' seconds.<p>' . LB;
} else {
@@ -101,7 +110,7 @@
}
-echo COM_endBlock ();
-echo COM_siteFooter ();
+echo COM_endBlock();
+echo COM_siteFooter();
?>
More information about the geeklog-cvs
mailing list