File: sdbscript.tcl

package info (click to toggle)
mysql-dfsg-5.0 5.0.32-7etch12
  • links: PTS
  • area: main
  • in suites: etch
  • size: 89,332 kB
  • ctags: 94,781
  • sloc: cpp: 436,297; ansic: 409,141; sh: 40,574; tcl: 30,484; perl: 27,872; yacc: 8,236; makefile: 5,532; java: 4,610; xml: 3,914; pascal: 3,462; sql: 2,673; awk: 1,338; asm: 1,061; sed: 772
file content (47 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download | duplicates (5)
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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1999-2002
#	Sleepycat Software.  All rights reserved.
#
# $Id: sdbscript.tcl,v 11.9 2002/01/11 15:53:36 bostic Exp $
#
# Usage: subdbscript testfile subdbnumber factor
# testfile: name of DB itself
# subdbnumber: n, subdb indicator, of form sub$n.db
# factor: Delete over factor'th + n'th from my subdb.
#
# I.e. if factor is 10, and n is 0, remove entries, 0, 10, 20, ...
# if factor is 10 and n is 1, remove entries 1, 11, 21, ...
source ./include.tcl
source $test_path/test.tcl

set usage "subdbscript testfile subdbnumber factor"

# Verify usage
if { $argc != 3 } {
	puts stderr "FAIL:[timestamp] Usage: $usage"
	exit
}

# Initialize arguments
set testfile [lindex $argv 0]
set n [ lindex $argv 1 ]
set factor [ lindex $argv 2 ]

set db [berkdb_open -unknown $testfile sub$n.db]
error_check_good db_open [is_valid_db $db] TRUE

set dbc [$db cursor]
error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
set i 1
for {set d [$dbc get -first]} {[llength $d] != 0} {set d [$dbc get -next]} {
	set x [expr $i - $n]
	if { $x >= 0 && [expr $x % $factor] == 0 } {
		puts  "Deleting $d"
		error_check_good dbc_del [$dbc del] 0
	}
	incr i
}
error_check_good db_close [$db close] 0

exit