summaryrefslogtreecommitdiff
path: root/test/tcl/recd024.tcl
blob: e6467222a332298beead35df4edaae6db0f401c5 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996, 2015 Oracle and/or its affiliates.  All rights reserved.
#
# $Id$
#
# TEST	recd024
# TEST	Test recovery of streaming partial insert operations. These are 
# TEST	operations that do multiple partial puts that append to an existing
# TEST	data item (as long as the data item is on an overflow page).
# TEST	The interesting cases are:
# TEST	 * Simple streaming operations
# TEST	 * Operations that cause the overflow item to flow onto another page.
# TEST
proc recd024 { method args } {
	source ./include.tcl

	# puts "$args"
	set envargs ""
	set pagesize 512

	set args [convert_args $method $args]
	set omethod [convert_method $method]

	if { [is_record_based $method] == 1 } {
		puts "Recd024 skipping for fixed length access methods."
		return
	}
	set flags "-create -txn -home $testdir $envargs"
	set env_cmd "berkdb_env $flags"

	set testfile recd024.db
	set testfile2 recd024-2.db
	if { [is_record_based $method] == 1 } {
		set key 1
	} else {
		set key recd024_key
	}

	set len 512
	set part_data [replicate "abcdefgh" 64]
	set p [list 0 $len]
	# Insert one 512 byte data item prior to call. To get it off page.
	# Append two more 512 byte data items, to enact the streaming code.
	set cmd [subst \
	    {DBC put -txn TXNID -partial "512 512" -current $part_data \
	    NEW_CMD DBC put -txn TXNID -partial "1024 512" -current $part_data \
	    NEW_CMD DBC put -txn TXNID -partial "1536 512" -current $part_data}]
	set oflags "-create $omethod -mode 0644 $args \
	    -pagesize $pagesize"
	set msg "Recd024.a: partial put prepopulated/expanding"
	foreach op {commit abort prepare-abort prepare-discard prepare-commit} {
		env_cleanup $testdir

		set dbenv [eval $env_cmd]
		error_check_good dbenv [is_valid_env $dbenv] TRUE
		set t [$dbenv txn]
		error_check_good txn_begin [is_valid_txn $t $dbenv] TRUE
		set db [eval {berkdb_open} \
		    $oflags -env $dbenv -txn $t $testfile]
		error_check_good db_open [is_valid_db $db] TRUE
		set db2 [eval {berkdb_open} \
		    $oflags -env $dbenv -txn $t $testfile2]
		error_check_good db_open [is_valid_db $db2] TRUE

		set ret [$db put -txn $t -partial $p $key $part_data]
		error_check_good dbput $ret 0

		set ret [$db2 put -txn $t -partial $p $key $part_data]
		error_check_good dbput $ret 0
		error_check_good txncommit [$t commit] 0
		error_check_good dbclose [$db close] 0
		error_check_good dbclose [$db2 close] 0
		error_check_good dbenvclose [$dbenv close] 0

		op_recover $op $testdir $env_cmd $testfile $cmd $msg \
		    $args
	}
	return
}