~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/include/diff_tables.inc

fix pthread atomics. operator precedence is important. The unit test now passes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
disable_query_log;
57
57
 
58
58
--error 0,1
59
 
--remove_file $DRIZZLETEST_VARDIR/tmp/diff_table_1
 
59
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_1
60
60
--error 0,1
61
 
--remove_file $DRIZZLETEST_VARDIR/tmp/diff_table_2
 
61
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_2
62
62
 
63
63
let $_diff_table=$diff_table_2;
64
64
let $_diff_i=2;
91
91
    --die
92
92
  }
93
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
 
103
 
 
104
  # We need the output files to be sorted (so that diff_files does not
 
105
  # think the files are different just because they are differently
 
106
  # ordered).  To this end, we first generate a query that sorts the
 
107
  # table by all columns.  Since ORDER BY accept column indices, we
 
108
  # just generate a comma-separated list of all numbers from 1 to the
 
109
  # number of columns in the table.
 
110
  let $_diff_column_index=`SELECT MAX(ordinal_position)
 
111
                           FROM data_dictionary.columns
 
112
                           WHERE CONCAT(table_schema, '.', table_name) =
 
113
                                 '$_diff_table'`;
 
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
  #}
94
137
 
95
138
  #let $_diff_column_list=$_diff_column_index;
96
139
  #dec $_diff_column_index;
102
145
  # Now that we have the comma-separated list of columns, we can write
103
146
  # the table to a file.
104
147
  eval SELECT * FROM $_diff_table ORDER BY 1 
105
 
              INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/diff_table_$_diff_i';
 
148
              INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/diff_table_$_diff_i';
106
149
 
107
150
  # Do the same for $diff_table_1.
108
151
  dec $_diff_i;
112
155
 
113
156
# ==== Compare the generated files ====
114
157
 
115
 
diff_files $DRIZZLETEST_VARDIR/tmp/diff_table_1 $DRIZZLETEST_VARDIR/tmp/diff_table_2;
 
158
diff_files $MYSQLTEST_VARDIR/tmp/diff_table_1 $MYSQLTEST_VARDIR/tmp/diff_table_2;
116
159
 
117
 
--remove_file $DRIZZLETEST_VARDIR/tmp/diff_table_1
118
 
--remove_file $DRIZZLETEST_VARDIR/tmp/diff_table_2
 
160
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_1
 
161
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_2
119
162
 
120
163
enable_query_log;