~percona-dev/percona-server/release-5.5.11-20.2-fix-bug-764138

« back to all changes in this revision

Viewing changes to build/debian/additions/debian-start.inc.sh

  • Committer: Ignacio Nin
  • Date: 2011-03-13 17:18:23 UTC
  • mfrom: (33.3.17 release-5.5.8-20)
  • Revision ID: ignacio.nin@percona.com-20110313171823-m06xs104nekulywb
Merge changes from release-5.5.8-20 to 5.5.9

Merge changes from the release branch of 5.5.8 to 5.5.9. These include
the HandlerSocket and UDF directories and the building scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# This file is included by /etc/mysql/debian-start
 
4
#
 
5
 
 
6
## Check all unclosed tables.
 
7
# - Requires the server to be up.
 
8
# - Is supposed to run silently in background. 
 
9
function check_for_crashed_tables() {
 
10
  set -e
 
11
  set -u
 
12
 
 
13
  # But do it in the background to not stall the boot process.
 
14
  logger -p daemon.info -i -t$0 "Triggering myisam-recover for all MyISAM tables"
 
15
 
 
16
  # Checking for $? is unreliable so the size of the output is checked.
 
17
  # Some table handlers like HEAP do not support CHECK TABLE.
 
18
  tempfile=`tempfile`
 
19
  # We have to use xargs in this case, because a for loop barfs on the 
 
20
  # spaces in the thing to be looped over. 
 
21
  LC_ALL=C $MYSQL --skip-column-names --batch -e  '
 
22
      select concat("select count(*) into @discard from `",
 
23
                    TABLE_SCHEMA, "`.`", TABLE_NAME, "`") 
 
24
      from information_schema.TABLES where ENGINE="MyISAM"' | \
 
25
    xargs -i $MYSQL --skip-column-names --silent --batch \
 
26
                    --force -e "{}" >$tempfile 
 
27
  if [ -s $tempfile ]; then
 
28
    (
 
29
      /bin/echo -e "\n" \
 
30
        "Improperly closed tables are also reported if clients are accessing\n" \
 
31
        "the tables *now*. A list of current connections is below.\n";
 
32
       $MYADMIN processlist status
 
33
    ) >> $tempfile
 
34
    # Check for presence as a dependency on mailx would require an MTA.
 
35
    if [ -x /usr/bin/mailx ]; then 
 
36
      mailx -e -s"$MYCHECK_SUBJECT" $MYCHECK_RCPT < $tempfile 
 
37
    fi
 
38
    (echo "$MYCHECK_SUBJECT"; cat $tempfile) | logger -p daemon.warn -i -t$0
 
39
  fi
 
40
  rm $tempfile
 
41
}
 
42
 
 
43
## Check for tables needing an upgrade.
 
44
# - Requires the server to be up.
 
45
# - Is supposed to run silently in background. 
 
46
function upgrade_system_tables_if_necessary() {
 
47
  set -e
 
48
  set -u
 
49
 
 
50
  logger -p daemon.info -i -t$0 "Upgrading MySQL tables if necessary."
 
51
 
 
52
  # Filter all "duplicate column", "duplicate key" and "unknown column"
 
53
  # errors as the script is designed to be idempotent.
 
54
  LC_ALL=C $MYUPGRADE \
 
55
    2>&1 \
 
56
    | egrep -v '^(1|@had|ERROR (1054|1060|1061))' \
 
57
    | logger -p daemon.warn -i -t$0
 
58
}
 
59
 
 
60
## Check for the presence of both, root accounts with and without password.
 
61
# This might have been caused by a bug related to mysql_install_db (#418672).
 
62
function check_root_accounts() {
 
63
  set -e
 
64
  set -u
 
65
  
 
66
  logger -p daemon.info -i -t$0 "Checking for insecure root accounts."
 
67
 
 
68
  ret=$( echo "SELECT count(*) FROM mysql.user WHERE user='root' and password='';" | $MYSQL --skip-column-names )
 
69
  if [ "$ret" -ne "0" ]; then
 
70
    logger -p daemon.warn -i -t$0 "WARNING: mysql.user contains $ret root accounts without password!"
 
71
  fi
 
72
}