| 1 |
--source setup.inc |
| 2 |
|
| 3 |
# |
| 4 |
# Truncate tables one by one and check it's empty |
| 5 |
# |
| 6 |
|
| 7 |
let $counter = 1; |
| 8 |
while ($counter <= $num_tables) |
| 9 |
{ |
| 10 |
# Default table name is t$counter, ie. t1, t2, etc |
| 11 |
let $tx=t$counter; |
| 12 |
|
| 13 |
eval TRUNCATE TABLE $tx; |
| 14 |
|
| 15 |
# Check that new table contains expected number of rows |
| 16 |
let $tx_count = `SELECT count(*) from $tx`; |
| 17 |
if ($tx_count != 0) |
| 18 |
{ |
| 19 |
echo Wrong number of rows, expected 0 got $tx_count; |
| 20 |
die Wrong number of rows in truncated table; |
| 21 |
} |
| 22 |
|
| 23 |
inc $counter; |
| 24 |
} |
| 25 |
|
| 26 |
--source verify_mysql_dd.inc |
| 27 |
|
| 28 |
# |
| 29 |
# Show that TRUNCATE may give the table a new table id in NDB |
| 30 |
# |
| 31 |
|
| 32 |
# Save table id of t5 |
| 33 |
let $table_id_5 = `SELECT id FROM ndbinfo.dict_obj_info |
| 34 |
WHERE fq_name='ndb_ddl_test/def/t5'`; |
| 35 |
|
| 36 |
# Save table id of t3 |
| 37 |
let $table_id_3 = `SELECT id FROM ndbinfo.dict_obj_info |
| 38 |
WHERE fq_name='ndb_ddl_test/def/t3'`; |
| 39 |
|
| 40 |
# Check assumption that t3 has lower table id than t5 |
| 41 |
if ($table_id_3 >= $table_id_5) |
| 42 |
{ |
| 43 |
echo table_id_3: $table_id_3; |
| 44 |
echo table_id_5: $table_id_5; |
| 45 |
die Test assumes that t3 has lower table id than t5; |
| 46 |
} |
| 47 |
|
| 48 |
# Open a free tableid slot that will be used by t5 when truncated |
| 49 |
DROP TABLE ndb_ddl_test.t3; |
| 50 |
|
| 51 |
TRUNCATE ndb_ddl_test.t5; |
| 52 |
|
| 53 |
# Save table id of t5 |
| 54 |
let $new_table_id_5 = `SELECT id FROM ndbinfo.dict_obj_info |
| 55 |
WHERE fq_name='ndb_ddl_test/def/t5'`; |
| 56 |
|
| 57 |
# Check that t5 changed id |
| 58 |
if ($new_table_id_5 == $table_id_5) |
| 59 |
{ |
| 60 |
die Table t5 didnt get the new (lower) table id; |
| 61 |
} |
| 62 |
|
| 63 |
--source verify_mysql_dd.inc |
| 64 |
|
| 65 |
--source cleanup.inc |
| 66 |
|