Skip to content

Commit 862e602

Browse files
committed
Added more test to sql-bench
- test-alter now correctly drops all columns - test-alter has a new test that times adding columns in middle of table - test-insert has a new test to check updates that doesn't change data - test-insert: update_with_key_prefix didn't change data. Now fixed
1 parent cb16bc9 commit 862e602

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

sql-bench/server-cfg.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ sub new
131131
$limits{'alter_add_multi_col'}= 1; #Have ALTER TABLE t add a int,add b int;
132132
$limits{'alter_table'} = 1; # Have ALTER TABLE
133133
$limits{'alter_table_dropcol'}= 1; # Have ALTER TABLE DROP column
134+
$limits{'alter_table_after'}= 1; # Have ALTER TABLE .. AFTER other_column
134135
$limits{'column_alias'} = 1; # Alias for fields in select statement.
135136
$limits{'func_extra_%'} = 1; # Has % as alias for mod()
136137
$limits{'func_extra_if'} = 1; # Have function if.

sql-bench/test-alter-table.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,10 @@ while ($field_count > $opt_start_field_count)
202202
$count++;
203203
$end=max($field_count-$add,$opt_start_field_count);
204204
$fields="";
205-
while(--$field_count >= $end)
205+
while ($field_count > $end)
206206
{
207207
$fields.=",DROP i${field_count}";
208+
$field_count--;
208209
}
209210
$dbh->do("ALTER TABLE bench " . substr($fields,1) . $server->{'drop_attr'})
210211
|| die $DBI::errstr;
@@ -221,6 +222,39 @@ else
221222
print " for alter_table_drop ($count): " .
222223
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
223224

225+
####
226+
#### Add fields in middle of the table
227+
####
228+
229+
goto skip_dropcol if (!$limits->{'alter_table_after'});
230+
231+
$count=0;
232+
while ($field_count < $opt_field_count)
233+
{
234+
$count++;
235+
$end=min($field_count+$add,$opt_field_count);
236+
$fields="";
237+
$tmp="ADD ";
238+
while ($field_count < $end)
239+
{
240+
$field_count++;
241+
$fields.=",$tmp i${field_count} integer after i1";
242+
$tmp="" if (!$multi_add);# Adabas
243+
}
244+
do_query($dbh,"ALTER TABLE bench " . substr($fields,1));
245+
$end_time=new Benchmark;
246+
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$count,
247+
$opt_field_count/$add+1));
248+
}
249+
250+
$end_time=new Benchmark;
251+
if ($estimated)
252+
{ print "Estimated time"; }
253+
else
254+
{ print "Time"; }
255+
print " for alter_table_add_in_middle ($count): " .
256+
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
257+
224258
skip_dropcol:
225259

226260
################################ END ###################################

sql-bench/test-insert.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,11 +993,22 @@ $end_time=new Benchmark;
993993
print "Time for update_with_key (" . ($opt_loop_count*3) . "): " .
994994
timestr(timediff($end_time, $loop_time),"all") . "\n";
995995

996+
print "Testing update with key, no changes in data\n";
997+
$loop_time=new Benchmark;
998+
for ($i=0 ; $i < $opt_loop_count*3 ; $i++)
999+
{
1000+
$sth = $dbh->do("update bench1 set dummy1='updated' where id=$i and id2=$i") or die $DBI::errstr;
1001+
}
1002+
1003+
$end_time=new Benchmark;
1004+
print "Time for update_with_key_record_unchanged (" . ($opt_loop_count*3) . "): " .
1005+
timestr(timediff($end_time, $loop_time),"all") . "\n";
1006+
9961007
$loop_time=new Benchmark;
9971008
$count=0;
9981009
for ($i=1 ; $i < $opt_loop_count*3 ; $i+=3)
9991010
{
1000-
$sth = $dbh->do("update bench1 set dummy1='updated' where id=$i") or die $DBI::errstr;
1011+
$sth = $dbh->do("update bench1 set dummy1='really updated' where id=$i") or die $DBI::errstr;
10011012
$end_time=new Benchmark;
10021013
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,($i-1)/3,
10031014
$opt_loop_count));

0 commit comments

Comments
 (0)