File: truncate.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (66 lines) | stat: -rw-r--r-- 1,515 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--source setup.inc

#
# Truncate tables one by one and check it's empty
#

let $counter = 1;
while ($counter <= $num_tables)
{
   # Default table name is t$counter, ie. t1, t2, etc
   let $tx=t$counter;

  eval TRUNCATE TABLE $tx;

  # Check that new table contains expected number of rows
  let $tx_count = `SELECT count(*) from $tx`;
  if ($tx_count != 0)
  {
    echo Wrong number of rows, expected 0 got $tx_count;
    die Wrong number of rows in truncated table;
  }

  inc $counter;
}

--source verify_mysql_dd.inc

#
# Show that TRUNCATE may give the table a new table id in NDB
#

# Save table id of t5
let $table_id_5 = `SELECT id FROM ndbinfo.dict_obj_info
                     WHERE fq_name='ndb_ddl_test/def/t5'`;

# Save table id of t3
let $table_id_3 = `SELECT id FROM ndbinfo.dict_obj_info
                     WHERE fq_name='ndb_ddl_test/def/t3'`;

# Check  assumption that t3 has lower table id than t5
if ($table_id_3 >= $table_id_5)
{
  echo table_id_3: $table_id_3;
  echo table_id_5: $table_id_5;
  die Test assumes that t3 has lower table id than t5;
}

# Open a free tableid slot that will be used by t5 when truncated
DROP TABLE ndb_ddl_test.t3;

TRUNCATE ndb_ddl_test.t5;

# Save table id of t5
let $new_table_id_5 = `SELECT id FROM ndbinfo.dict_obj_info
                         WHERE fq_name='ndb_ddl_test/def/t5'`;

# Check that t5 changed id
if ($new_table_id_5 == $table_id_5)
{
  die Table t5 didnt get the new (lower) table id;
}

--source verify_mysql_dd.inc

--source cleanup.inc