~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-security

« back to all changes in this revision

Viewing changes to mysql-test/include/get_relay_log_pos.inc

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-21 15:31:05 UTC
  • mfrom: (1.2.1 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100621153105-lv81twvjdgzvzrre
Tags: 5.1.48-1ubuntu1
* Merge from debian unstable, remaining changes:
  + debian/control:
     * Update maintainer according to spec.
     * Move section from "misc" to "database".
     * Added libmysqlclient16-dev an empty transitional package. 
     * Added mysql-client-core-5.1 package.
     * Suggest mailx for mysql-server-5.1
     * Add mysql-testsuite package so you can run the testsuite seperately.
  + debian/additions/my.cnf:
    * Remove language options. Error message files are located in a different directory in Mysql
      5.0. Setting the language option to use /usr/share/mysql/english breaks Mysql 5.0. Both 5.0
      and 5.1 use a different value that works. (LP: #316974)
  + Add apparmor profile:
    + debian/apparmor-profile: apparmor-profile
    + debian/rules, debian/mysql-server-5.1.files: install apparmor profile
    + debian/mysql-server-5.1.dirs: add etc/apparmor.d/fore-complain
    + debian/mysql-server-5.1.postrm: remove symlink in force-complain/ on purge.
    + debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    + debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    + debian/mysql-server-5.1.postinst: reload apparmor profiles
  * Convert the package from sysvinit to upstart:
    + debian/mysql-server-5.1.mysql.upstart: Add upstart script.
    + debian/mysql-server-5.1.mysql.init: Dropped, unused now with upstart.
    + debian/additions/mysqld_safe_syslog.cnf: Dropped, unused now with upstart.
    + debian/additons/my.cnf: Remove pid declaration and setup error logging to /var/log/mysql since
      we're not piping anything around logger anymore.
    + debian/rules, debian/mysql-server-5.1.logcheck.ignore.{paranoid,worstation},
      debian/mysql-server-5.1.logcheck.ignore.server: : Remove references to mysqld_safe
    + debian/patches/38_scripts_mysqld_safe.sh_signals.dpatch: Dropped
  * Added -fno-strict-aliasing to CFLAGS to get around mysql testsuite build failures.
  * Add Apport hook (LP: #354188):
    + debian/mysql-server-5.1.py: apport package hook
    + debian/rules: Make it installable
  * debian/mysql-server-5.1.mysql-server.logrotate: Check to see if mysql is running before
    running logrotate. (LP: #513135)
  * Make the testsuite installable. (LP: #530752)
    + debian/mysql-server-5.1.files, debian/rules: install apport package hook
  * debian/mysql-server-5.1.preinst: Set mysql user's home directory
    to /nonexistent to protect against having the /var/lib/mysql
    user-writeable. If an attacker can trick mysqld into creating
    dot files in the home directory, he could do .rhost-like attacks
    on the system. (LP: #293258)
  * debian/control: mysql-client-5.1 should depend on mysql-core-client-5.1.
    (LP: #590952) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# For a given event which is at position $master_log_pos in the the master's
 
2
# binary log, returns its position in the slave's relay log file
 
3
# $relay_log_file.  
 
4
# The position is stored in the variable $relay_log_pos.
 
5
 
 
6
# Usage:
 
7
#   let $relay_log_file= 'relay-log-bin.000001'; 
 
8
#   let $master_log_pos= 106; 
 
9
#   source include/get_relay_log_pos.inc; 
 
10
#   # at this point, get_relay_log_pos.inc sets $relay_log_pos. echo position
 
11
#   # in $relay_log_file: $relay_log_pos. 
 
12
 
 
13
if (`SELECT '$relay_log_file' = ''`)
 
14
{
 
15
  --die 'variable $relay_log_file is null'
 
16
}
 
17
 
 
18
if (`SELECT '$master_log_pos' = ''`)
 
19
{
 
20
  --die 'variable $master_log_pos is null'
 
21
}
 
22
 
 
23
let $MYSQLD_DATADIR= `select @@datadir`;
 
24
let $_suffix= `SELECT UUID()`;
 
25
let $_tmp_file= $MYSQLTEST_VARDIR/tmp/mysqlbinlog.$_suffix;
 
26
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$relay_log_file > $_tmp_file
 
27
 
 
28
# All queries in this file should not be logged.
 
29
--disable_query_log
 
30
 
 
31
--disable_warnings
 
32
DROP TEMPORARY TABLE IF EXISTS mysqlbinlog_events;
 
33
DROP TEMPORARY TABLE IF EXISTS events_at;
 
34
DROP TEMPORARY TABLE IF EXISTS events_pos;
 
35
CREATE TEMPORARY TABLE mysqlbinlog_events(c1 INT AUTO_INCREMENT KEY, c2 varchar(256));
 
36
 
 
37
# Event position is in the comments output by mysqlbinlog, we load this
 
38
# comments into the table 
 
39
# '# at 106' 
 
40
# '# ....  end_log_pos 46'
 
41
eval LOAD DATA LOCAL INFILE '$_tmp_file' INTO TABLE mysqlbinlog_events
 
42
  LINES STARTING BY '#' (c2) SET c1 = NULL;
 
43
--enable_warnings
 
44
 
 
45
# Event pos in relay log file is inserted into table events_at
 
46
CREATE TEMPORARY TABLE events_at(c1 INT AUTO_INCREMENT KEY, c2 varchar(256))
 
47
  SELECT c2 FROM mysqlbinlog_events WHERE c2 LIKE ' at%' ORDER BY c1;
 
48
 
 
49
# Event pos in master log file is inserted into table events_pos
 
50
CREATE TEMPORARY TABLE events_pos(c1 INT AUTO_INCREMENT KEY, c2 varchar(256))
 
51
  SELECT c2 FROM mysqlbinlog_events WHERE c2 LIKE '% end_log_pos %' ORDER BY c1;
 
52
 
 
53
#  events_at                                events_pos
 
54
#  c1------c2--------------------------     c1------c2------------------------
 
55
#  1       ev1's begin pos in relay log     1      ev1's end pos in master log
 
56
#  2       ev2's begin pos in relay log     2      ev2's end pos in master log
 
57
#  3       ev3's begin pos in relay log     3      ev3's end pos in master log
 
58
#  events always keep the same sequence.  
 
59
#  Because event[N]'s end pos is equal to event[N+1]'s begin pos we want to
 
60
#  find event's end pos in relay log, we can find the right relay_log_pos
 
61
#  using the relationship that 'events_pos.c1 = events_at.c1 + 1'
 
62
 
63
# There is a fault that we can't get the relay log position of the last event,
 
64
# as it is not output by mysqlbinlog
 
65
let $relay_log_pos= `SELECT SUBSTRING(a.c2, 5)
 
66
  FROM events_at a, events_pos b
 
67
  WHERE a.c1=b.c1+1 and b.c2 LIKE '% $master_log_pos%'`;
 
68
DROP TEMPORARY TABLE mysqlbinlog_events, events_at, events_pos;
 
69
--remove_file $_tmp_file
 
70
--enable_query_log