]> git.pld-linux.org Git - packages/mysql.git/commitdiff
This commit was manufactured by cvs2git to create tag 'auto-ac-mysql- auto/ac/mysql-5_0_68-2
authorcvs2git <feedback@pld-linux.org>
Thu, 30 Oct 2008 23:01:24 +0000 (23:01 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
5_0_68-2'.

Sprout from MYSQL_5_0 2008-10-30 23:01:24 UTC Elan Ruusamäe <glen@pld-linux.org> '- release 2'
Cherrypick from master 2008-10-27 13:57:07 UTC Elan Ruusamäe <glen@pld-linux.org> '- use same error log for init procedure':
    mysql-client.conf -> 1.2
    mysql.init -> 1.131
Delete:
    mysql-CVE-2007-5925.patch
    mysql-acc-pslist.patch
    mysql-bug-24148.patch
    mysql-bug-27694.patch
    mysql-bug-29082.patch
    mysql-ssl.patch

mysql-CVE-2007-5925.patch [deleted file]
mysql-acc-pslist.patch [deleted file]
mysql-bug-24148.patch [deleted file]
mysql-bug-27694.patch [deleted file]
mysql-bug-29082.patch [deleted file]
mysql-client.conf [new file with mode: 0644]
mysql-ssl.patch [deleted file]
mysql.init [new file with mode: 0644]

diff --git a/mysql-CVE-2007-5925.patch b/mysql-CVE-2007-5925.patch
deleted file mode 100644 (file)
index bcb64dd..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 91_SECURITY_CVE-2007-5925.dpatch by  <nobse@debian.org>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: Fix for CVE-2007-5925: The convert_search_mode_to_innobase function in
-## DP: ha_innodb.cc in the InnoDB engine in MySQL 5.1.23-BK and earlier allows
-## DP: remote authenticated users to cause a denial of service (database crash)
-## DP: via a certain CONTAINS operation on an indexed column, which triggers an
-## DP: assertion error. (closes: #451235)
-
-@DPATCH@
-diff -ru old/innobase/include/db0err.h new/innobase/include/db0err.h
---- old/innobase/include/db0err.h      2007-07-04 16:06:59.000000000 +0300
-+++ new/innobase/include/db0err.h      2007-11-15 10:23:51.000000000 +0200
-@@ -57,6 +57,18 @@
-                                       buffer pool (for big transactions,
-                                       InnoDB stores the lock structs in the
-                                       buffer pool) */
-+#define DB_FOREIGN_DUPLICATE_KEY 46   /* foreign key constraints
-+                                      activated by the operation would
-+                                      lead to a duplicate key in some
-+                                      table */
-+#define DB_TOO_MANY_CONCURRENT_TRXS 47        /* when InnoDB runs out of the
-+                                      preconfigured undo slots, this can
-+                                      only happen when there are too many
-+                                      concurrent transactions */
-+#define DB_UNSUPPORTED                48      /* when InnoDB sees any artefact or
-+                                      a feature that it can't recoginize or
-+                                      work with e.g., FT indexes created by
-+                                      a later version of the engine. */
- /* The following are partial failure codes */
- #define DB_FAIL               1000
-diff -ru old/innobase/include/page0cur.h new/innobase/include/page0cur.h
---- old/innobase/include/page0cur.h    2007-07-04 16:06:10.000000000 +0300
-+++ new/innobase/include/page0cur.h    2007-11-15 10:23:51.000000000 +0200
-@@ -22,6 +22,7 @@
- /* Page cursor search modes; the values must be in this order! */
-+#define       PAGE_CUR_UNSUPP 0
- #define       PAGE_CUR_G      1
- #define       PAGE_CUR_GE     2
- #define       PAGE_CUR_L      3
-diff -ru old/sql/ha_innodb.cc new/sql/ha_innodb.cc
---- old/sql/ha_innodb.cc       2007-07-04 16:06:48.000000000 +0300
-+++ new/sql/ha_innodb.cc       2007-11-15 10:25:55.000000000 +0200
-@@ -526,6 +526,9 @@
-               }
-               return(HA_ERR_LOCK_TABLE_FULL);
-+      } else if (error == DB_UNSUPPORTED) {
-+ 
-+              return(HA_ERR_UNSUPPORTED);
-       } else {
-               return(-1);                     // Unknown error
-       }
-@@ -3689,11 +3692,21 @@
-                 and comparison of non-latin1 char type fields in
-                 innobase_mysql_cmp() to get PAGE_CUR_LE_OR_EXTENDS to
-                 work correctly. */
--
--              default:                        assert(0);
-+              case HA_READ_MBR_CONTAIN:
-+              case HA_READ_MBR_INTERSECT:
-+              case HA_READ_MBR_WITHIN:
-+              case HA_READ_MBR_DISJOINT:
-+                      my_error(ER_TABLE_CANT_HANDLE_SPKEYS, MYF(0));
-+                      return(PAGE_CUR_UNSUPP);
-+              /* do not use "default:" in order to produce a gcc warning:
-+              enumeration value '...' not handled in switch
-+              (if -Wswitch or -Wall is used)
-+              */
-       }
--      return(0);
-+      my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "this functionality");
-+
-+      return(PAGE_CUR_UNSUPP);
- }
- /*
-@@ -3831,11 +3844,18 @@
-       last_match_mode = (uint) match_mode;
--      innodb_srv_conc_enter_innodb(prebuilt->trx);
-+      if (mode != PAGE_CUR_UNSUPP) {
--      ret = row_search_for_mysql((byte*) buf, mode, prebuilt, match_mode, 0);
-+              innodb_srv_conc_enter_innodb(prebuilt->trx);
--      innodb_srv_conc_exit_innodb(prebuilt->trx);
-+              ret = row_search_for_mysql((byte*) buf, mode, prebuilt,
-+                                         match_mode, 0);
-+
-+              innodb_srv_conc_exit_innodb(prebuilt->trx);
-+      } else {
-+
-+              ret = DB_UNSUPPORTED;
-+      }
-       if (ret == DB_SUCCESS) {
-               error = 0;
-@@ -5150,8 +5170,16 @@
-       mode2 = convert_search_mode_to_innobase(max_key ? max_key->flag :
-                                                 HA_READ_KEY_EXACT);
--      n_rows = btr_estimate_n_rows_in_range(index, range_start,
--                                              mode1, range_end, mode2);
-+      if (mode1 != PAGE_CUR_UNSUPP && mode2 != PAGE_CUR_UNSUPP) {
-+
-+              n_rows = btr_estimate_n_rows_in_range(index, range_start,
-+                                                    mode1, range_end,
-+                                                    mode2);
-+      } else {
-+
-+              n_rows = 0;
-+      }
-+
-       dtuple_free_for_mysql(heap1);
-       dtuple_free_for_mysql(heap2);
diff --git a/mysql-acc-pslist.patch b/mysql-acc-pslist.patch
deleted file mode 100644 (file)
index f54950e..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-diff -r 174803e7e869 mysql-test/r/create.result
---- a/mysql-test/r/create.result       Thu Sep 04 12:17:56 2008 -0700
-+++ b/mysql-test/r/create.result       Thu Sep 04 12:20:19 2008 -0700
-@@ -1720,7 +1720,8 @@
-   `COMMAND` varchar(16) NOT NULL DEFAULT '',
-   `TIME` bigint(7) NOT NULL DEFAULT '0',
-   `STATE` varchar(64) DEFAULT NULL,
--  `INFO` longtext
-+  `INFO` longtext,
-+  `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000'
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8
- drop table t1;
- create temporary table t1 like information_schema.processlist;
-@@ -1734,7 +1735,8 @@
-   `COMMAND` varchar(16) NOT NULL DEFAULT '',
-   `TIME` bigint(7) NOT NULL DEFAULT '0',
-   `STATE` varchar(64) DEFAULT NULL,
--  `INFO` longtext
-+  `INFO` longtext,
-+  `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000'
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8
- drop table t1;
- create table t1 like information_schema.character_sets;
-diff -r 174803e7e869 mysql-test/r/not_embedded_server.result
---- a/mysql-test/r/not_embedded_server.result  Thu Sep 04 12:17:56 2008 -0700
-+++ b/mysql-test/r/not_embedded_server.result  Thu Sep 04 12:20:19 2008 -0700
-@@ -1,7 +1,7 @@
- prepare stmt1 from ' SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!=\'Daemon\' ';
- execute stmt1;
--ID    USER    HOST    DB      COMMAND TIME    STATE   INFO
--number        root    localhost       test    Query   time    executing       SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!='Daemon'
-+ID    USER    HOST    DB      COMMAND TIME    STATE   INFO    TIME_MS
-+number        root    localhost       test    Query   time    executing       SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!='Daemon'    time_ms
- deallocate prepare stmt1;
- FLUSH STATUS;
- SHOW GLOBAL STATUS LIKE 'com_select';
-diff -r 174803e7e869 mysql-test/t/not_embedded_server.test
---- a/mysql-test/t/not_embedded_server.test    Thu Sep 04 12:17:56 2008 -0700
-+++ b/mysql-test/t/not_embedded_server.test    Thu Sep 04 12:20:19 2008 -0700
-@@ -16,7 +16,7 @@
- # End of 4.1 tests
- prepare stmt1 from ' SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!=\'Daemon\' ';
----replace_column 1 number 6 time 3 localhost
-+--replace_column 1 number 6 time 3 localhost 9 time_ms
- execute stmt1;
- deallocate prepare stmt1;
-diff -r 174803e7e869 patch_info/acc-pslist.info
---- /dev/null  Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/acc-pslist.info       Thu Sep 04 12:20:19 2008 -0700
-@@ -0,0 +1,6 @@
-+File=acc-pslist.patch
-+Name=Milliseconds in PROCESSLIST
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r 174803e7e869 sql/sql_show.cc
---- a/sql/sql_show.cc  Thu Sep 04 12:17:56 2008 -0700
-+++ b/sql/sql_show.cc  Thu Sep 04 12:20:19 2008 -0700
-@@ -1803,7 +1803,7 @@
-   TABLE *table= tables->table;
-   CHARSET_INFO *cs= system_charset_info;
-   char *user;
--  time_t now= my_time(0);
-+  ulonglong unow= my_micro_time();
-   DBUG_ENTER("fill_process_list");
-   user= thd->security_ctx->master_access & PROCESS_ACL ?
-@@ -1861,8 +1861,8 @@
-         table->field[4]->store(command_name[tmp->command].str,
-                                command_name[tmp->command].length, cs);
-       /* MYSQL_TIME */
--      table->field[5]->store((uint32)(tmp->start_time ?
--                                      now - tmp->start_time : 0), TRUE);
-+      const ulonglong utime= tmp->start_utime ? unow - tmp->start_utime : 0;
-+      table->field[5]->store(utime / 1000000, TRUE);
-       /* STATE */
- #ifndef EMBEDDED_LIBRARY
-       val= (char*) (tmp->locked ? "Locked" :
-@@ -1896,11 +1896,15 @@
-         table->field[7]->set_notnull();
-       }
-+      /* TIME_MS */
-+      table->field[8]->store((double)(utime / 1000.0));
-+
-       if (schema_table_store_record(thd, table))
-       {
-         VOID(pthread_mutex_unlock(&LOCK_thread_count));
-         DBUG_RETURN(1);
-       }
-+
-     }
-   }
-@@ -5532,7 +5536,7 @@
-     into it two numbers, based on modulus of base-10 numbers.  In the ones
-     position is the number of decimals.  Tens position is unused.  In the
-     hundreds and thousands position is a two-digit decimal number representing
--    length.  Encode this value with  (decimals*100)+length  , where
-+    length.  Encode this value with  (length*100)+decimals  , where
-     0<decimals<10 and 0<=length<100 .
-   @param
-@@ -6540,6 +6544,8 @@
-   {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE},
-   {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info",
-    SKIP_OPEN_TABLE},
-+  {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+    0, 0, "Time_ms", SKIP_OPEN_TABLE},
-   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
- };
diff --git a/mysql-bug-24148.patch b/mysql-bug-24148.patch
deleted file mode 100644 (file)
index 1e04db2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-From: msvensson at mysql dot com
-Date: December 22 2006 12:05am
-Subject: bk commit into 5.0 tree (msvensson:1.2352) BUG#24148
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of msvensson. When msvensson does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2006-12-22 00:05:40+01:00, msvensson@stripped +1 -0
-  Bug#24148 regression tests hang with SSL enabled
-   - Don't call SSL_shutdown a second time
-
-  vio/viossl.c@stripped, 2006-12-22 00:05:39+01:00, msvensson@stripped +9 -5
-    SSL_shutdown might return 0 indicating that it should be called once
-    again for a graceful shutdown. Since the socket are going to be closed
-    anyway ther is no need for the second call.
-
-# This is a BitKeeper patch.  What follows are the unified diffs for the
-# set of deltas contained in the patch.  The rest of the patch, the part
-# that BitKeeper cares about, is below these diffs.
-# User:        msvensson
-# Host:        pilot.mysql.com
-# Root:        /home/msvensson/mysql/mysql-5.0-maint
-
---- 1.38/vio/viossl.c  2006-11-20 21:41:56 +01:00
-+++ 1.39/vio/viossl.c  2006-12-22 00:05:39 +01:00
-@@ -126,12 +126,16 @@
-   {
-     switch ((r= SSL_shutdown(ssl)))
-     {
--    case 1: /* Shutdown successful */
-+    case 1:
-+      /* Shutdown successful */
-+      break;
-+    case 0:
-+      /*
-+        Shutdown not yet finished - since the socket is going to
-+        be closed there is no need to call SSL_shutdown() a second
-+        time to wait for the other side to respond
-+      */
-       break;
--    case 0: /* Shutdown not yet finished, call it again */
--      if ((r= SSL_shutdown(ssl) >= 0))
--        break;
--      /* Fallthrough */
-     default: /* Shutdown failed */
-       DBUG_PRINT("vio_error", ("SSL_shutdown() failed, error: %d",
-                                SSL_get_error(ssl, r)));
diff --git a/mysql-bug-27694.patch b/mysql-bug-27694.patch
deleted file mode 100644 (file)
index 4dba319..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
---- mysql-5.0.41/scripts/mysqlhotcopy.sh~      2007-06-21 14:17:42.000000000 +0300
-+++ mysql-5.0.41/scripts/mysqlhotcopy.sh       2007-06-21 14:17:43.671033114 +0300
-@@ -840,6 +840,7 @@
-     my $quote = $dbh->get_info(29); # SQL_IDENTIFIER_QUOTE_CHAR
-     if ($quote) {
-       foreach (@dbh_tables) {
-+        s/$quote.+$quote\.//; # perl-DBD-mysql-4.003 fix
-         s/^$quote(.*)$quote$/$1/;
-         s/$quote$quote/$quote/g;
-       }
diff --git a/mysql-bug-29082.patch b/mysql-bug-29082.patch
deleted file mode 100644 (file)
index 0cb62d9..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
---- mysql-5.0.41/scripts/mysqlhotcopy.sh~      2007-06-21 14:37:22.000000000 +0300
-+++ mysql-5.0.41/scripts/mysqlhotcopy.sh       2007-06-21 14:37:24.924257114 +0300
-@@ -605,7 +605,12 @@
-       # add recursive option for scp
-       $cp.= " -r" if $^O =~ /m^(solaris|linux|freebsd|darwin)$/ && $method =~ /^scp\b/;
--      my @non_raid = map { "'$_'" } grep { ! m:/$raid_dir_regex/[^/]+$: } @$files;
-+      my @non_raid;
-+      if (@$raid_dirs) {
-+          @non_raid = map { "'$_'" } grep { ! m:/$raid_dir_regex/[^/]+$: } @$files;
-+      } else {
-+          @non_raid = @$files;
-+      }
-       # add files to copy and the destination directory
-       safe_system( $cp, @non_raid, "'$target'" ) if (@non_raid);
diff --git a/mysql-client.conf b/mysql-client.conf
new file mode 100644 (file)
index 0000000..431e5dd
--- /dev/null
@@ -0,0 +1,6 @@
+#[client]
+#default-character-set=latin2
+
+[mysql]
+prompt='\\R:\\m:\\s mysql{\\c}> '
+show-warnings
diff --git a/mysql-ssl.patch b/mysql-ssl.patch
deleted file mode 100644 (file)
index 4404b93..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-From: msvenssonDate: February 7 2008 8:48am
-Subject: bk commit into 5.0 tree (msvensson:1.2573) BUG#33050
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of msvensson.  When msvensson does a push these changes
-will be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2008-02-07 08:48:28+01:00, msvensson@stripped +1 -0
-  Bug#33050 5.0.50 fails many SSL testcases
-
-  vio/viossl.c@stripped, 2008-02-07 08:48:27+01:00, msvensson@stripped +21 -14
-    Bug#33050 5.0.50 fails many SSL testcases
-
-diff -Nrup a/vio/viossl.c b/vio/viossl.c
---- a/vio/viossl.c     2007-08-28 11:34:42 +02:00
-+++ b/vio/viossl.c     2008-02-07 08:48:27 +01:00
-@@ -172,20 +172,15 @@ void vio_ssl_delete(Vio *vio)
-   vio_delete(vio);
- }
--int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
--{
--  DBUG_ENTER("sslaccept");
--  DBUG_RETURN(sslconnect(ptr, vio, timeout));
--}
--
--int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
-+static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
-+                  int (*connect_accept_func)(SSL*))
- {
-   SSL *ssl;
-   my_bool unused;
-   my_bool was_blocking;
--  DBUG_ENTER("sslconnect");
-+  DBUG_ENTER("ssl_do");
-   DBUG_PRINT("enter", ("ptr: 0x%lx, sd: %d  ctx: 0x%lx",
-                        (long) ptr, vio->sd, (long) ptr->ssl_context));
-@@ -204,13 +199,9 @@ int sslconnect(struct st_VioSSLFd *ptr, 
-   SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout);
-   SSL_set_fd(ssl, vio->sd);
--  /*
--    SSL_do_handshake will select between SSL_connect
--    or SSL_accept depending on server or client side
--  */
--  if (SSL_do_handshake(ssl) < 1)
-+  if (connect_accept_func(ssl) < 1)
-   {
--    DBUG_PRINT("error", ("SSL_do_handshake failure"));
-+    DBUG_PRINT("error", ("SSL_connect/accept failure"));
-     report_errors(ssl);
-     SSL_free(ssl);
-     vio_blocking(vio, was_blocking, &unused);
-@@ -259,6 +250,20 @@ int sslconnect(struct st_VioSSLFd *ptr, 
- }
-+int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
-+{
-+  DBUG_ENTER("sslaccept");
-+  DBUG_RETURN(ssl_do(ptr, vio, timeout, SSL_accept));
-+}
-+
-+
-+int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
-+{
-+  DBUG_ENTER("sslconnect");
-+  DBUG_RETURN(ssl_do(ptr, vio, timeout, SSL_connect));
-+}
-+
-+
- int vio_ssl_blocking(Vio *vio __attribute__((unused)),
-                    my_bool set_blocking_mode,
-                    my_bool *old_mode)
-@@ -268,5 +273,7 @@ int vio_ssl_blocking(Vio *vio __attribut
-   /* Return error if we try to change to non_blocking mode */
-   return (set_blocking_mode ? 0 : 1);
- }
-+
-+
- #endif /* HAVE_OPENSSL */
diff --git a/mysql.init b/mysql.init
new file mode 100644 (file)
index 0000000..ebfad62
--- /dev/null
@@ -0,0 +1,597 @@
+#!/bin/sh
+#
+# mysql                A very fast and reliable SQL database engine
+#
+# chkconfig:   2345 84 25
+#
+# description:  A very fast and reliable SQL database engine.
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config
+if [ -f /etc/sysconfig/mysql ]; then
+       . /etc/sysconfig/mysql
+else
+       nls "Error: %s not found" /etc/sysconfig/mysql
+       nls "%s can't be run." MySQL
+       exit 1
+fi
+
+if [ -n "$MYSQL_DB_CLUSTERS" ]; then
+       nls "Warning: MYSQL_DB_CLUSTERS is set. It's obsolete. Use %s instead." /etc/mysql/clusters.conf
+fi
+
+if [ -f /etc/mysql/clusters.conf ]; then
+       MYSQL_DB_CLUSTERS=$(awk -F= '!/^#/{print $2}' /etc/mysql/clusters.conf)
+       if [ -z "$MYSQL_DB_CLUSTERS"  ]; then
+               nls "Warning: there are no configured clusters."
+       fi
+
+else
+       nls "Warning: Missing clusters config file %s" /etc/mysql/clusters.conf
+       if [ -z "$MYSQL_DB_CLUSTERS"  ]; then
+               nls "Warning: there are no configured clusters."
+               nls "Using default cluster /var/lib/mysql (compatibility mode)"
+               MYSQL_DB_CLUSTERS=/var/lib/mysql
+       fi
+fi
+
+
+# Check that networking is up
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
+               msg_network_down MySQL
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+action="$1"
+
+# any db cluster as command line argument?
+if [ $# -gt 1 ]; then
+       shift
+       # perform action for specified clusters only
+       for a in "$@"; do
+               # try auto resolving from /etc/mysql/clusters.conf
+               if [[ "$a" != /* ]]; then
+                       m=$(awk -va="$a" -F= 'substr($0, 1, length(a)) == a {print $1}' /etc/mysql/clusters.conf)
+                       if [ -z "$m" ]; then
+                               echo >&2 "Cluster name '$a' did not match anything!"
+                               exit 1
+                       fi
+                       if [ $(echo "$m" | wc -l) -gt 1 ]; then
+                               echo >&2 "Cluster name '$a' ambiguous:" $m
+                               exit 1
+                       fi
+                       a=$(awk -va="$a" -F= 'substr($0, 1, length(a)) == a {print $2}' /etc/mysql/clusters.conf)
+               fi
+               DB_CLUSTERS="$DB_CLUSTERS $a"
+       done
+else
+       DB_CLUSTERS="$MYSQL_DB_CLUSTERS"
+fi
+
+# global error log, if mysqld.conf hasn't migrated to log-error style
+MYSQL_ERRLOG=/var/log/mysql/mysqld.log
+MYSQL_STOP_WAIT_TIME=${MYSQL_STOP_WAIT_TIME:-900}
+
+#
+# Useful functions.
+#
+
+#
+# check for mysql status
+#
+# arguments:
+# $1 - db cluster
+# $2 - start|stop
+#
+# sets variables:
+# MYSQL_STATUS = starting | running | not running | died
+# MYSQL_PID    = pid of mysqld process
+#
+mysqlstatus() {
+       clusterdir="$1"
+       mode="$2"
+       
+       mysqlgetconfig "$clusterdir"
+
+       MYSQL_STATUS="not running"
+       MYSQL_PID="unknown"
+       MYSQL_PIDFILE_PID=""
+       MYSQL_GREP_PID=""
+
+       if [ -f "$MYSQL_PIDFILE" ]; then
+               MYSQL_PIDFILE_PID=$(cat "$MYSQL_PIDFILE")
+       fi
+       
+       if [ -n "$MYSQL_PIDFILE_PID" ]; then
+               MYSQL_PID=$MYSQL_PIDFILE_PID
+               if [ ! -d "/proc/$MYSQL_PID" ]; then
+                       MYSQL_STATUS="died"
+                       return
+               elif (grep -qa "$MYSQL_PIDFILE" /proc/$MYSQL_PID/cmdline 2> /dev/null); then
+                       MYSQL_STATUS="running"
+                       return
+               fi
+       fi
+
+       if [ "$mode" = "start" ]; then
+               MYSQL_GREP_PID=$(grep -lE "^/usr/sbin/mysqld.*${MYSQL_PIDFILE}" /proc/[0-9]*/cmdline 2> /dev/null | awk -F "/" '{ print $3; exit; }')
+               if [ -n "$MYSQL_GREP_PID" ]; then
+                       MYSQL_PID=$MYSQL_GREP_PID
+                       if grep -qa "$MYSQL_PIDFILE" /proc/$MYSQL_PID/cmdline 2> /dev/null; then
+                               if [ -f "$MYSQL_PIDFILE" ]; then
+                                       MYSQL_PIDFILE_PID=$(cat "$MYSQL_PIDFILE")
+                               fi
+                               if [ -n "$MYSQL_PIDFILE_PID" ]; then
+                                       MYSQL_PID=$MYSQL_PIDFILE_PID
+                                       MYSQL_STATUS="running"
+                                       return
+                               else
+                                       MYSQL_STATUS="starting"
+                                       return
+                               fi
+                       fi
+               fi
+       fi
+
+       # else default, "not running"
+}
+
+# get mysql configuration in variables
+# MYSQL_CONFIG MYSQL_DATA_DIR MYSQL_USER MYSQL_PIDFILE
+#
+# arguments
+# $1 - db cluster
+
+mysqlgetconfig() {
+       clusterdir="$1"
+
+       # emulate old behaviour if only one cluster specified
+       if [ "$clusterdir" = "$MYSQL_DB_CLUSTERS" -a "$clusterdir" = "/var/lib/mysql" -a -f /etc/mysqld.conf ]; then
+               MYSQL_RA_COMPAT=yes
+               config_file=/etc/mysqld.conf
+       else
+               config=$(awk -F= -vclusterdir="$clusterdir" '!/^#/{ if (clusterdir == $2) print $1}' /etc/mysql/clusters.conf)
+               if [[ $config = /* ]]; then
+                       config_file="$config"
+               elif [ -f "/etc/mysql/$config" ]; then
+                       config_file="/etc/mysql/$config"
+               else
+                       config_file="$clusterdir/mysqld.conf"
+               fi
+       fi
+
+       MYSQL_CLUSTER_DIR="$clusterdir"
+
+       if [ -z "$config_file" ]; then
+               nls "Error: Can't find config file for %s cluster" "$clusterdir"
+               exit 6
+       else
+               MYSQL_CONFIG="$config_file"
+       fi
+
+       if [ ! -f "$config_file" ]; then
+               nls "Error: config file %s not found" "$config_file"
+               nls "MySQL can't be run. Did you initialize DB by doing \`$0 init'?"
+               exit 6
+       fi
+
+       eval `awk '
+/^[ \t]*\[.*\][ \t]*$/ {
+       match($0,/\[.*\]/)
+       section=substr($0, RSTART + 1, RSTART + RLENGTH - 3)
+}
+section == "mysqld" && $2 ~ "=" {
+       if ($1 == "datadir") {
+               printf("MYSQL_DATA_DIR=%s;", $3)
+       } else if ($1 == "user") {
+               printf("MYSQL_USER=%s;", $3)
+       } else if ($1 == "pid-file") {
+               printf("MYSQL_PIDFILE=%s;", $3)
+       } else if ($1 == "socket") {
+               printf("MYSQL_SOCKET=%s;", $3)
+       }
+}
+' $config_file`
+
+
+       if is_yes "$MYSQL_RA_COMPAT"; then
+               MYSQL_DATA_DIR_SUB=""
+       else
+               MYSQL_DATA_DIR_SUB="/mysqldb"
+       fi
+
+       if [ -z "$MYSQL_DATA_DIR" -o "$MYSQL_DATA_DIR" != "${clusterdir}${MYSQL_DATA_DIR_SUB}/db" ]; then
+               nls "Error: datadir specified in %s should be %s" "$config_file" "$clusterdir${MYSQL_DATA_DIR_SUB}/db"
+               nls " MySQL can't be run."
+               exit 6
+       fi
+
+       if [ -z "$MYSQL_PIDFILE" -o "$MYSQL_PIDFILE" != "$clusterdir${MYSQL_DATA_DIR_SUB}/mysql.pid" ]; then
+               nls "Error: pid-file specified in %s should be %s" "$config_file" "$clusterdir${MYSQL_DATA_DIR_SUB}/mysql.pid"
+               nls " MySQL can't be run."
+               exit 6
+       fi
+
+       if [ -z $MYSQL_USER ]; then
+               echo "$(nls 'MySQL user not configured properly')"'!' >&2
+               nls "Edit %s and configure it." "$config_file" >&2
+               exit 6
+       fi
+}
+
+# start mysql
+mysqlstart() {
+       clusterdir="$1"
+       mysqlgetconfig "$clusterdir"
+       if [ ! -d "$MYSQL_DATA_DIR/mysql" ]; then
+               nls "MySQL cluster %s not initialized." "$clusterdir"
+               nls "Try \`%s init %s' before start." "$0" "$clusterdir"
+               exit 6
+       fi
+
+       msg_starting "MySQL $clusterdir"
+       busy
+       [ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0
+       rm -f "$MYSQL_PIDFILE"
+
+       if [ "$(grep -c ^log-error $MYSQL_CONFIG)" -lt 1 ]; then
+               # error log not defined in config file. add one
+               MYSQL_OPTIONS="$MYSQL_OPTIONS --log-error=$MYSQL_ERRLOG"
+       fi
+
+       TMPDIR=/tmp nice -n ${SERVICE_RUN_NICE_LEVEL:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} \
+               /usr/bin/setsid /usr/sbin/mysqld \
+                       --defaults-file=$MYSQL_CONFIG \
+                       --datadir=$MYSQL_DATA_DIR \
+                       --pid-file=$MYSQL_PIDFILE \
+                       $MYSQL_OPTIONS &
+       pid=$!
+
+       sleep 0.1
+       mysqlstatus "$clusterdir" start
+       # it takes longer for mysqld to start and create pidfile if it has to recover innodb transactions
+       if [ "$MYSQL_STATUS" = "starting" ]; then
+               echo ""
+               show "Waiting for MySQL to start"
+               busy
+
+               # while the pid is running, mysql is starting up
+               # if the pidfile was created, it started up successfully
+               # if either case fails we break and report status
+               while true; do
+                       [ -d /proc/$pid ] || break
+                       [ -f "$MYSQL_PIDFILE" ] && break
+                       sleep 0.2
+               done
+       fi
+
+       mysqlstatus "$clusterdir" start
+       if [ "$MYSQL_STATUS" = "running" -a "$MYSQL_PID" != "unknown" ]; then
+               ok
+       elif [ "$MYSQL_STATUS" = "died" ]; then
+               RETVAL=1
+               died
+       else
+               RETVAL=1
+               fail
+       fi
+}
+
+# stop mysql
+mysqlstop() {
+       clusterdir="$1"
+       mysqlstatus "$clusterdir" stop
+       msg_stopping "MySQL $clusterdir"
+       busy
+
+       # try graceful shutdown -- send shutdown command
+       # requires mysql_sysadmin user proper privs
+       /usr/bin/mysqladmin --defaults-file=$MYSQL_CONFIG ${MYSQL_SOCKET:+--socket=$MYSQL_SOCKET} shutdown >/dev/null 2>&1
+       mysqlstatus "$clusterdir" stop
+
+       if [ "$MYSQL_PID" != "unknown" ]; then
+               kill -TERM "$MYSQL_PID" 2> /dev/null
+               for nr in $(seq 1 $(($MYSQL_STOP_WAIT_TIME*10))); do
+                       [ -d "/proc/$MYSQL_PID" ] || break
+                       sleep 0.1
+               done
+       fi
+       
+       mysqlstatus "$clusterdir" stop
+       if [ "$MYSQL_STATUS" = "died" ]; then
+               died
+       elif [ "$MYSQL_STATUS" = "running" -o "$MYSQL_STATUS" = "starting" ]; then
+               fail
+       else
+               ok
+       fi
+}
+
+#
+# check for running mysql instances; if any instance is running then
+# create subsys lock file
+#
+mysqlsubsys() {
+       # check for every defined db cluster in sysconfig file
+       for mysqldir in $DB_CLUSTERS; do
+               mysqlstatus "$mysqldir"
+               if [ "$MYSQL_STATUS" = "running" ]; then
+                       touch /var/lock/subsys/mysql
+                       return
+               fi
+       done
+       rm -f /var/lock/subsys/mysql
+}
+
+mysqlinit() {
+       clusterdir="$1"
+
+       if [ -f /etc/mysqld.conf ]; then
+               nls "Running in \`no cluster compat' mode: can't initialize database."
+               nls "Move /etc/mysqld.conf away and rerun \`$0 init' (new config will be in $clusterdir)."
+               exit 1
+       fi
+
+       if [ -f "$clusterdir/mysqld.conf" ]; then
+               mysqlgetconfig "$clusterdir"
+       else
+               MYSQL_USER="mysql"
+               MYSQL_CLUSTER_DIR="$clusterdir"
+               MYSQL_DATA_DIR="$clusterdir/mysqldb/db"
+               MYSQL_PIDFILE="$clusterdir/mysqldb/mysql.pid"
+               MYSQL_SOCKET="$clusterdir/mysqldb/mysql.sock"
+
+               # this $MYSQL_CONFIG will be created later
+               MYSQL_CONFIG="$MYSQL_CLUSTER_DIR/mysqld.conf"
+       fi
+
+       show "Initializing cluster %s" "$clusterdir"; echo
+
+       # Check if not exist init database
+       if [ -d "$MYSQL_DATA_DIR/mysql" ]; then
+               nls "Seems that database is initialized now. Remove by hand %s" "$MYSQL_DATA_DIR/mysql"
+               nls "before initializing database."
+               nls "For now skipping cluster %s." "$clusterdir"
+               return
+       fi
+
+       show "Installing MySQL system tables for $MYSQL_DATA_DIR"
+       busy
+       TMP=/tmp TMPDIR=/tmp
+
+       mkdir -p "$MYSQL_DATA_DIR" > /dev/null 2>&1
+       # Using mysql:mysql for MYSQL_CLUSTER_DIR is creating SECURITY hole, root:root is proper
+       chown root:root "$MYSQL_CLUSTER_DIR"
+       chown mysql:mysql "$MYSQL_CLUSTER_DIR/mysqldb" "$MYSQL_DATA_DIR" > /dev/null 2>&1
+       chmod 751 "$MYSQL_CLUSTER_DIR" "$MYSQL_CLUSTER_DIR/mysqldb"
+
+       if [ -f /usr/share/mysql/mysqld.conf -a ! -f "$MYSQL_CLUSTER_DIR/mysqld.conf" ]; then
+           sed -e "
+               s#\(datadir.*\)=.*#\1= $MYSQL_DATA_DIR#g;
+               s#\(pid-file.*\)=.*#\1= $MYSQL_PIDFILE#g;
+               s#\(socket.*\)=.*#\1= $MYSQL_SOCKET#g;
+               s#@clusterdir@#$MYSQL_CLUSTER_DIR#g;
+               " /usr/share/mysql/mysqld.conf > "$MYSQL_CLUSTER_DIR/mysqld.conf"
+           chown root:root "$MYSQL_CLUSTER_DIR/mysqld.conf"
+           chmod 640 "$MYSQL_CLUSTER_DIR/mysqld.conf"
+       fi
+
+       if [ ! -e /var/lib/mysql/mysql.sock ] || [ -L /var/lib/mysql/mysql.sock ] && [ -z "$(readlink /var/lib/mysql/mysql.sock)" ]; then
+               sock=${MYSQL_SOCKET#/var/lib/mysql/} # make it relative if possible
+           ln -s "$sock" /var/lib/mysql/mysql.sock
+       fi
+
+       cat > $MYSQL_DATA_DIR/mysql-init.sql <<-EOF
+               CREATE DATABASE mysql;
+               use mysql;
+               $(cat /usr/share/mysql/mysql_system_tables.sql)
+               $(sed -e "/@current_hostname/d" /usr/share/mysql/mysql_system_tables_data.sql)
+EOF
+
+       ok=0
+       /usr/sbin/mysqld --bootstrap --skip-grant-tables \
+               --datadir=$MYSQL_DATA_DIR --user=$MYSQL_USER \
+               --slave-load-tmpdir=$MYSQL_DATA_DIR --tmpdir=$MYSQL_DATA_DIR --log-error=$MYSQL_ERRLOG \
+               < $MYSQL_DATA_DIR/mysql-init.sql && ok=1
+       [ -f $MYSQL_DATA_DIR/mysql/host.frm ] || ok=0
+
+       if [ "$ok" = 1 ]; then
+               rm -f $MYSQL_DATA_DIR/mysql-init.sql
+               ok
+               cat << END_OF_MSG
+
+PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL USERS!
+This is done, after starting database, in the order shown,
+with:
+
+For 'mysql_sysadmin' (RELOAD and SHUTDOWN privileges):
+echo "update mysql.user set password=password('newpassword') where user='mysql_sysadmin'; FLUSH PRIVILEGES;" | mysql -u mysql -S $MYSQL_SOCKET
+
+For 'mysql' user (ALL privileges, DB admin):
+echo "update mysql.user set password=password('newpassword') where user='mysql'; FLUSH PRIVILEGES;" | mysql -u mysql -S $MYSQL_SOCKET
+
+NOTE: mysql_sysadmin password should be placed to $MYSQL_CONFIG in
+mysqladmin section. See the manual for more instructions.
+(This user is used at logs rotation and server shutdown)
+
+END_OF_MSG
+               show "Filling help tables..."
+               ok=0
+               ( echo "use mysql;"; cat /usr/share/mysql/fill_help_tables.sql ) | \
+                       /usr/sbin/mysqld --bootstrap --skip-grant-tables \
+                       --datadir=$MYSQL_DATA_DIR --user=$MYSQL_USER \
+                       --slave-load-tmpdir=$MYSQL_DATA_DIR --tmpdir=$MYSQL_DATA_DIR --log-error=$MYSQL_ERRLOG \
+                       && ok=1
+               if [ "$ok" = 1 ]; then
+                       ok
+               else
+                       cat << END_OF_MSG
+
+WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!
+The "HELP" command might not work properly.
+
+END_OF_MSG
+               fi
+       else
+               fail
+               cat << END_OF_MSG
+Installation of grant tables FAILED!
+
+The initialization SQL script was preserved at $MYSQL_DATA_DIR/mysql-init.sql
+
+Examine the logs in /var/log/mysql for more information.  You can
+also try to start the mysqld daemon with:
+
+/usr/sbin/mysqld --skip-grant &
+
+You can use the command line tool mysql to connect to the mysql
+database and look at the grant tables:
+
+shell> mysql -u mysql mysql
+mysql> show tables
+
+Try 'mysqld --help' if you have problems with paths. Setting on
+logging in /etc/mysqld.conf gives you a log in /var/log/mysql/log that
+may be helpful. The latest information about MySQL is available on the
+web at http://www.mysql.com/.
+
+Please check PLD Linux ftp site for newer versions of this package.
+
+Please consult the MySQL manual section: 'Problems running
+mysql_install_db', and the manual section that describes problems on
+your OS.  Another information source is the MySQL email archive.
+Please check all of the above before mailing us!  And if you do mail
+us, you MUST use the mysqlbug script!
+
+END_OF_MSG
+               exit 1
+       fi
+}
+
+#
+# End of useful functions.
+#
+
+start() {
+       for mysqldir in $DB_CLUSTERS; do
+               mysqlstatus "$mysqldir" start
+               if [ "$MYSQL_STATUS" = "running" ]; then
+                       msg_already_running "MySQL $mysqldir"
+               else
+                       mysqlstart "$mysqldir"
+               fi
+       done
+       mysqlsubsys
+}
+
+stop() {
+       for mysqldir in $DB_CLUSTERS; do
+               mysqlstatus "$mysqldir" stop
+               if [ "$MYSQL_STATUS" = "not running" ]; then
+                       msg_not_running "MySQL $mysqldir"
+               else
+                       mysqlstop "$mysqldir"
+               fi
+       done
+       mysqlsubsys
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/mysql ]; then
+               stop
+               start
+       else
+               msg_not_running "MySQL"
+               RETVAL=$1
+       fi
+}
+
+RETVAL=0
+case "$action" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       for mysqldir in $DB_CLUSTERS; do
+               mysqlstatus "$mysqldir"
+               if [ "$MYSQL_STATUS" = "running" ]; then
+                       show "MySQL cluster %s, PID %s" "$mysqldir" "$MYSQL_PID"
+                       pids="$pids/$MYSQL_PID/"
+                       progress "$MYSQL_STATUS"
+               else
+                       show "MySQL cluster %s" "$mysqldir"
+                       progress "$MYSQL_STATUS" "$CFAIL"
+               fi
+               echo
+       done
+
+       for pid in $(/sbin/pidof mysqld); do
+               if [[ $pids != */$pid/* ]]; then
+                       running="$running $pid"
+               fi
+       done
+
+       if [ $# -gt 1 -a "$running" ]; then
+               nls "Warning: MySQL Daemon processes not under clusters.conf control:"
+               # see if we can display their status
+               for pid in $running; do
+                       datadir=$(cat /proc/$pid/cmdline | tr '\0' '\n' | fgrep -- --datadir=)
+                       datadir=${datadir#--datadir=} # strip --datadir
+                       mysqldir=${datadir%/mysqldb/db} # strip /mysqldb/db
+                       mysqlstatus "$mysqldir"
+                       if [ "$MYSQL_STATUS" = "running" ]; then
+                               show "MySQL cluster %s, PID %s" "$mysqldir" "$pid"
+                               progress "$MYSQL_STATUS"
+                       else
+                               show "MySQL cluster %s" "$mysqldir"
+                               progress "$MYSQL_STATUS" "$CFAIL"
+                       fi
+                       echo
+               done
+       fi
+       ;;
+  init)
+       for mysqldir in $DB_CLUSTERS; do
+               mysqlinit "$mysqldir"
+       done
+       exit $?
+       ;;
+  flush-logs)
+       for mysqldir in $DB_CLUSTERS; do
+           mysqlgetconfig "$mysqldir"
+               # just if mysqld is really running
+               if /usr/bin/mysqladmin --defaults-file="$MYSQL_CONFIG" --socket="$MYSQL_SOCKET" ping >/dev/null 2>&1; then
+                       /usr/bin/mysqladmin --defaults-file="$MYSQL_CONFIG" --socket="$MYSQL_SOCKET" flush-logs
+               fi
+       done
+       ;;
+  *)
+       msg_usage "$0 {start|stop|init|restart|try-restart|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL
This page took 0.082785 seconds and 4 git commands to generate.