⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recd007.tcl

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 TCL
📖 第 1 页 / 共 2 页
字号:
	#	# Set our locations to copy and abort	#	set ret [eval $env test copy $copy]	error_check_good test_copy $ret 0	set ret [eval $env test abort $abort]	error_check_good test_abort $ret 0	#	# Open our db, add some data, close and copy as our	# init file.	#	set db [eval {berkdb_open} $oflags]	error_check_good db_open [is_valid_db $db] TRUE	set txn [$env txn]	set ret [$db put -txn $txn $key1 $data1]	error_check_good db_put $ret 0	set ret [$db put -txn $txn $key2 $data2]	error_check_good db_put $ret 0	error_check_good commit [$txn commit] 0	error_check_good db_close [$db close] 0	$env mpool_sync	set init_file $dir/$dbfile.init	catch { file copy -force $dir/$dbfile $init_file } res	if { [is_queue $method] == 1}  {		copy_extent_file $dir $dbfile init	}	#	# If we don't abort, then we expect success.	# If we abort, we expect no file removed.	#	switch $op {	"dbrename" {		set ret [catch { eval {berkdb} $op -env $env -auto_commit \		    $dbfile $subdb $new } remret]	}	"dbremove" {		set ret [catch { eval {berkdb} $op -env $env -auto_commit \		    $dbfile $subdb } remret]	}	"dbtruncate" {		set txn [$env txn]		set db [eval {berkdb_open_noerr -env} \		    $env -auto_commit $dbfile $subdb]		error_check_good dbopen [is_valid_db $db] TRUE		error_check_good txnbegin [is_valid_txn $txn $env] TRUE		set ret [catch {$db truncate -txn $txn} remret]	}	}	$env mpool_sync	if { $abort == "none" } {		if { $op == "dbtruncate" } {			error_check_good txncommit [$txn commit] 0			error_check_good dbclose [$db close] 0		}		#		# Operation was committed, verify it.		#		puts "\t\tCommand executed and committed."		error_check_good $op $ret 0		#		# If a dbtruncate, check that truncate returned the number		# of items previously in the database.		#		if { [string compare $op "dbtruncate"] == 0 } {			error_check_good remret $remret 2		}		recd007_check $op $sub $dir $dbfile $subdb $new $env $oflags	} else {		#		# Operation was aborted, verify it did not change.		#		if { $op == "dbtruncate" } {			error_check_good txnabort [$txn abort] 0			error_check_good dbclose [$db close] 0		}		puts "\t\tCommand executed and aborted."		error_check_good $op $ret 1		#		# Check that the file exists.  Final state.		# Compare against initial file.		#		error_check_good post$op.1 [file exists $dir/$dbfile] 1		error_check_good \		    diff(init,post$op.2):diff($init_file,$dir/$dbfile)\                  [dbdump_diff $dflags $init_file $dir $dbfile] 0	}	$env mpool_sync	error_check_good env_close [$env close] 0	catch { file copy -force $dir/$dbfile $init_file } res	if { [is_queue $method] == 1} {		copy_extent_file $dir $dbfile init	}	#	# Run recovery here.  Should be a no-op.  Verify that	# the file still doesn't exist or change (depending on abort)	# when we are done.	#	berkdb debug_check	puts -nonewline "\t\tAbout to run recovery ... "	flush stdout	set stat [catch {exec $util_path/db_recover -h $dir -c} result]	if { $stat == 1 } {		error "FAIL: Recovery error: $result."		return	}	puts "complete"	if { $abort == "none" } {		#		# Operate was committed.		#		set env [eval $env_cmd]		recd007_check $op $sub $dir $dbfile $subdb $new $env $oflags		error_check_good env_close [$env close] 0	} else {		#		# Operation was aborted, verify it did not change.		#		berkdb debug_check		error_check_good \		    diff(initial,post-recover1):diff($init_file,$dir/$dbfile) \                  [dbdump_diff $dflags $init_file $dir $dbfile] 0	}	#	# If we didn't make a copy, then we are done.	#	if {[string first "none" $copy] != -1} {		return	}	#	# Now restore the .afterop file(s) to their original name.	# Run recovery again.	#	copy_afterop $dir	berkdb debug_check	puts -nonewline "\t\tAbout to run recovery ... "	flush stdout	set stat [catch {exec $util_path/db_recover -h $dir -c} result]	if { $stat == 1 } {		error "FAIL: Recovery error: $result."		return	}	puts "complete"	if { [string first "none" $abort] != -1} {		set env [eval $env_cmd]		recd007_check $op $sub $dir $dbfile $subdb $new $env $oflags		error_check_good env_close [$env close] 0	} else {		#		# Operation was aborted, verify it did not change.		#		error_check_good \		    diff(initial,post-recover2):diff($init_file,$dir/$dbfile) \                  [dbdump_diff $dflags $init_file $dir $dbfile] 0	}}## This function tests a specific case of recovering after a db removal.# This is for SR #2538.  Basically we want to test that:# - Make an env.# - Make/close a db.# - Remove the db.# - Create another db of same name.# - Sync db but leave open.# - Run recovery.# - Verify no recovery errors and that new db is there.proc do_file_recover_delmk { dir env_cmd method opts dbfile } {	global log_log_record_types	source ./include.tcl	# Keep track of the log types we've seen	if { $log_log_record_types == 1} {		logtrack_read $dir	}	set omethod [convert_method $method]	puts "\tRecd007.q: Delete and recreate a database"	env_cleanup $dir	# Open the environment and set the copy/abort locations	set env [eval $env_cmd]	error_check_good env_open [is_valid_env $env] TRUE	if { [is_record_based $method] == 1 } {		set key 1	} else {		set key recd007_key	}	set data1 recd007_data	set data2 NEWrecd007_data2	set oflags \	    "-create $omethod -auto_commit -mode 0644 $opts $dbfile"	#	# Open our db, add some data, close and copy as our	# init file.	#	set db [eval {berkdb_open_noerr} -env $env $oflags]	error_check_good db_open [is_valid_db $db] TRUE	set txn [$env txn]	set ret [$db put -txn $txn $key $data1]	error_check_good db_put $ret 0	error_check_good commit [$txn commit] 0	error_check_good db_close [$db close] 0	set ret \	    [catch { berkdb dbremove -env $env -auto_commit $dbfile } remret]	#	# Operation was committed, verify it does	# not exist.	#	puts "\t\tCommand executed and committed."	error_check_good dbremove $ret 0	error_check_good dbremove.1 [file exists $dir/$dbfile] 0	#	# Now create a new db with the same name.	#	set db [eval {berkdb_open_noerr} -env $env $oflags]	error_check_good db_open [is_valid_db $db] TRUE	set txn [$env txn]	set ret [$db put -txn $txn $key [chop_data $method $data2]]	error_check_good db_put $ret 0	error_check_good commit [$txn commit] 0	error_check_good db_sync [$db sync] 0	berkdb debug_check	puts -nonewline "\t\tAbout to run recovery ... "	flush stdout	set stat [catch {exec $util_path/db_recover -h $dir -c} result]	if { $stat == 1 } {		error "FAIL: Recovery error: $result."		return	}	puts "complete"	error_check_good db_recover $stat 0	error_check_good db_recover.1 [file exists $dir/$dbfile] 1	#	# Since we ran recovery on the open db/env, we need to	# catch these calls.  Basically they are there to clean	# up the Tcl widgets.	#	set stat [catch {$db close} ret]	error_check_bad dbclose_after_remove $stat 0	error_check_good dbclose_after_remove [is_substr $ret recovery] 1	set stat [catch {$env close} ret]	error_check_bad envclose_after_remove $stat 0	error_check_good envclose_after_remove [is_substr $ret recovery] 1	#	# Reopen env and db and verify 2nd database is there.	#	set env [eval $env_cmd]	error_check_good env_open [is_valid_env $env] TRUE	set db [eval {berkdb_open} -env $env $oflags]	error_check_good db_open [is_valid_db $db] TRUE	set ret [$db get $key]	error_check_good dbget [llength $ret] 1	set kd [lindex $ret 0]	error_check_good key [lindex $kd 0] $key	error_check_good data2 [lindex $kd 1] [pad_data $method $data2]	error_check_good dbclose [$db close] 0	error_check_good envclose [$env close] 0}proc is_valid_create_loc { loc } {	switch $loc {		none		-		preopen		-		postopen	-		postlogmeta	-		postlog		-		postsync			{ return 1 }		default			{ return 0 }	}}proc is_valid_delete_loc { loc } {	switch $loc {		none		-		predestroy	-		postdestroy	-		postremcall			{ return 1 }		default			{ return 0 }	}}# Do a logical diff on the db dump files.  We expect that either# the files are identical, or if they differ, that it is exactly# just a free/invalid page.# Return 1 if they are different, 0 if logically the same (or identical).#proc dbdump_diff { flags initfile dir dbfile } {	source ./include.tcl	set initdump $initfile.dump	set dbdump $dbfile.dump	set stat [catch {eval {exec $util_path/db_dump} $flags -f $initdump \	    $initfile} ret]	error_check_good dbdump.init $stat 0	# Do a dump without the freelist which should eliminate any	# recovery differences.	set stat [catch {eval {exec $util_path/db_dump} $flags -f $dir/$dbdump \          $dir/$dbfile} ret]	error_check_good dbdump.db $stat 0	set stat [filecmp $dir/$dbdump $initdump]	if {$stat == 0} {		return 0	}	puts "diff: $dbdump $initdump gives:\n$ret"	return 1}proc recd007_check { op sub dir dbfile subdb new env oflags } {	#	# No matter how many subdbs we have, dbtruncate will always	# have a file, and if we open our particular db, it should	# have no entries.	#	if { $sub == 0 } {		if { $op == "dbremove" } {			error_check_good $op:not-exist \			    [file exists $dir/$dbfile] 0		} elseif { $op == "dbrename"} {			error_check_good $op:exist \			    [file exists $dir/$dbfile] 0			error_check_good $op:exist2 \			    [file exists $dir/$dbfile.new] 1		} else {			error_check_good $op:exist \			    [file exists $dir/$dbfile] 1			set db [eval {berkdb_open} $oflags]			error_check_good db_open [is_valid_db $db] TRUE			set dbc [$db cursor]			error_check_good dbc_open \			    [is_valid_cursor $dbc $db] TRUE			set ret [$dbc get -first]			error_check_good dbget1 [llength $ret] 0			error_check_good dbc_close [$dbc close] 0			error_check_good db_close [$db close] 0		}		return	} else {		set t1 $dir/t1		#		# If we have subdbs, check that all but the last one		# are there, and the last one is correctly operated on.		#		set db [berkdb_open -rdonly -env $env $dbfile]		error_check_good dbopen [is_valid_db $db] TRUE		set c [eval {$db cursor}]		error_check_good db_cursor [is_valid_cursor $c $db] TRUE		set d [$c get -last]		if { $op == "dbremove" } {			if { $sub == 1 } {				error_check_good subdb:rem [llength $d] 0			} else {				error_check_bad subdb:rem [llength $d] 0				set sdb [lindex [lindex $d 0] 0]				error_check_bad subdb:rem1 $sdb $subdb			}		} elseif { $op == "dbrename"} {			set sdb [lindex [lindex $d 0] 0]			error_check_good subdb:ren $sdb $new			if { $sub != 1 } {				set d [$c get -prev]				error_check_bad subdb:ren [llength $d] 0				set sdb [lindex [lindex $d 0] 0]				error_check_good subdb:ren1 \				    [is_substr "new" $sdb] 0			}		} else {			set sdb [lindex [lindex $d 0] 0]			set dbt [berkdb_open -rdonly -env $env $dbfile $sdb]			error_check_good db_open [is_valid_db $dbt] TRUE			set dbc [$dbt cursor]			error_check_good dbc_open \			    [is_valid_cursor $dbc $dbt] TRUE			set ret [$dbc get -first]			error_check_good dbget2 [llength $ret] 0			error_check_good dbc_close [$dbc close] 0			error_check_good db_close [$dbt close] 0			if { $sub != 1 } {				set d [$c get -prev]				error_check_bad subdb:ren [llength $d] 0				set sdb [lindex [lindex $d 0] 0]				set dbt [berkdb_open -rdonly -env $env \				    $dbfile $sdb]				error_check_good db_open [is_valid_db $dbt] TRUE				set dbc [$db cursor]				error_check_good dbc_open \				    [is_valid_cursor $dbc $db] TRUE				set ret [$dbc get -first]				error_check_bad dbget3 [llength $ret] 0				error_check_good dbc_close [$dbc close] 0				error_check_good db_close [$dbt close] 0			}		}		error_check_good dbcclose [$c close] 0		error_check_good db_close [$db close] 0	}}proc copy_afterop { dir } {	set r [catch { set filecopy [glob $dir/*.afterop] } res]	if { $r == 1 } {		return	}	foreach f $filecopy {		set orig [string range $f 0 \			[expr [string last "." $f] - 1]]		catch { file rename -force $f $orig} res	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -