67
67
# Parse out any leading "master:" or "slave:" from the table
68
# specification and connect the appropriate server.
68
# specification and connect to the appropriate server.
69
69
let $_diff_conn_master=`SELECT SUBSTR('$_diff_table', 1, 7) = 'master:'`;
70
70
if ($_diff_conn_master) {
71
71
let $_diff_table=`SELECT SUBSTR('$_diff_table', 8)`;
80
80
# Sanity-check the input.
81
let $_diff_error= `SELECT '$_diff_table' NOT LIKE '_%._%'`;
83
--echo !!!ERROR IN TEST: \$diff_table_$_diff_i='$_diff_table' is not in the form database.table
87
# We need the output files to be sorted (so that diff_files does not
88
# think the files are different just because they are differently
89
# ordered). To this end, we first generate a query that sorts the
90
# table by all columns. Since ORDER BY accept column indices, we
91
# just generate a comma-separated list of all numbers from 1 to the
92
# number of columns in the table.
93
let $_diff_column_index=`SELECT MAX(ordinal_position)
94
FROM information_schema.columns
95
WHERE CONCAT(table_schema, '.', table_name) =
97
let $_diff_column_list=$_diff_column_index;
98
dec $_diff_column_index;
99
while ($_diff_column_index) {
100
let $_diff_column_list=$_diff_column_index, $_diff_column_list;
101
dec $_diff_column_index;
81
if (`SELECT '$_diff_table' NOT LIKE '_%._%'`) {
82
--echo !!!ERROR IN TEST: \$diff_table_$_diff_i='$_diff_table'
83
--echo is not in the form database.table
87
# Check if the table exists
88
if (`SELECT COUNT(*) = 0 FROM data_dictionary.tables
89
WHERE CONCAT(table_schema, '.', table_name) = '$_diff_table'`) {
90
--echo !!!ERROR IN TEST: The table '$_diff_table' does not exist
95
#let $_diff_column_list=$_diff_column_index;
96
#dec $_diff_column_index;
97
#while ($_diff_column_index) {
98
# let $_diff_column_list=$_diff_column_index, $_diff_column_list;
99
# dec $_diff_column_index;
104
102
# Now that we have the comma-separated list of columns, we can write
105
103
# the table to a file.
106
eval SELECT * FROM $_diff_table ORDER BY $_diff_column_list
104
eval SELECT * FROM $_diff_table ORDER BY 1
107
105
INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/diff_table_$_diff_i';
109
107
# Do the same for $diff_table_1.