~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/include/diff_tables.inc

Merge of trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
while ($_diff_i) {
66
66
 
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)`;
78
78
  }
79
79
 
80
80
  # Sanity-check the input.
81
 
  let $_diff_error= `SELECT '$_diff_table' NOT LIKE '_%._%'`;
82
 
  if ($_diff_error) {
83
 
    --echo !!!ERROR IN TEST: \$diff_table_$_diff_i='$_diff_table' is not in the form database.table
84
 
    exit;
85
 
  }
 
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
 
84
    --die
 
85
  }
 
86
 
 
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
 
91
    --die
 
92
  }
 
93
 
 
94
  # NOTE:  We disable this ORDERING bit as it 
 
95
  # was causing fits for drizzledump_restore.test
 
96
  # The returned ORDINAL_POSITION value was 0 instead of 1 as we
 
97
  # expect in MySQL and things didn't work out
 
98
  # As the only test that uses this include file is
 
99
  # drizzledump_restore, it doesn't cause any problems
 
100
  # Leaving the code here at the moment in case someone should need
 
101
  # it, but recommend removing this entirely ~1 year from commit
 
102
  # date - 19 May 2010
86
103
 
87
104
  # We need the output files to be sorted (so that diff_files does not
88
105
  # think the files are different just because they are differently
91
108
  # just generate a comma-separated list of all numbers from 1 to the
92
109
  # number of columns in the table.
93
110
  let $_diff_column_index=`SELECT MAX(ordinal_position)
94
 
                           FROM information_schema.columns
 
111
                           FROM data_dictionary.columns
95
112
                           WHERE CONCAT(table_schema, '.', table_name) =
96
113
                                 '$_diff_table'`;
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;
102
 
  }
 
114
 
 
115
  # The content of $_diff_column_index must be an integer >= 0.
 
116
  # If not the following might happen:
 
117
  # Result of SELECT | $_diff_column_index | dec $_diff_column_index
 
118
  #    NULL          | empty string        | -1
 
119
  #    ''            | empty string        | -1
 
120
  #    'a1'          | a1                  | -1
 
121
  #    '1a'          | 1a                  |  0
 
122
  #    ........................
 
123
  # (Bug#51057 Weak code in diff_tables.inc can lead to 100% CPU consumption)
 
124
  # In case $i = 1 the soone following loop
 
125
  # while ($i) {
 
126
  #   ...
 
127
  #   dec $i;
 
128
  # }
 
129
  # will never terminate.
 
130
  #if (`SELECT CAST(CAST('$_diff_column_index' AS UNSIGNED) AS CHAR(65))
 
131
  #            <> '$_diff_column_index'
 
132
  #         OR CAST('$_diff_column_index' AS UNSIGNED) < 1`) {
 
133
  #  --echo !!!ERROR IN TEST: \$_diff_column_index is '$_diff_column_index'
 
134
  #  --echo                   but must be an unsigned integer > 0
 
135
  #  --die
 
136
  #}
 
137
 
 
138
  #let $_diff_column_list=$_diff_column_index;
 
139
  #dec $_diff_column_index;
 
140
  #while ($_diff_column_index) {
 
141
  #  let $_diff_column_list=$_diff_column_index, $_diff_column_list;
 
142
  #  dec $_diff_column_index;
 
143
  #}
103
144
 
104
145
  # Now that we have the comma-separated list of columns, we can write
105
146
  # the table to a file.
106
 
  eval SELECT * FROM $_diff_table ORDER BY $_diff_column_list
 
147
  eval SELECT * FROM $_diff_table ORDER BY 1 
107
148
              INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/diff_table_$_diff_i';
108
149
 
109
150
  # Do the same for $diff_table_1.