puts "================"
puts "OCC1054"
puts "================"
puts ""
#######################################################################################
# Mechanism of transactions' synchronization and mechanizm of nested transactions 
#######################################################################################
# Case 1 (nested mode ON)
#######################################################################################

proc OCC1054_Check_dump {IsGood index good_index case} {
  # Check dump
  if { ${index} != ${good_index} } {
    set IsGood 0
    puts "OCC1054 Error (case ${case} : index = ${index} good_index = ${good_index})"
  }
  return ${IsGood}
}

proc OCC1054_Check_real_attribute {IsGood doc label good_real case} {
  global ${doc}
  # Check real attribute
  set percent_max 0.1
  if [catch { set real [GetReal ${doc} ${label}] } message] {
    set IsGood 0
    puts "OCC1054 Error (case ${case})"
  } else {
    set real_percent [expr abs(${real} - ${good_real}) / double(${good_real}) * 100.]
    if {${real_percent} > ${percent_max}} {
       puts "good_real = ${good_real}"
       puts "real = ${real}"
       puts "real_percent = ${real_percent}"
       puts "OCC1054 Error (case ${case}-2)"
    }
  }
  return ${IsGood}
}


set IsGood 1
set Case 0

NewDocument doc1
NewDocument doc2
NewDocument doc3
mtmCreate 4

mtmNestedMode 1

mtmAdd doc1

mtmOpen
  SetReal doc1 0:1:1 1.1
  OpenCommand doc1
    SetReal doc1 0:1:1 11
  AbortCommand doc1

  OpenCommand doc1
    SetReal doc1 0:1:3 12.1

    OpenCommand doc1
      SetReal doc1 0:1:3 121
    AbortCommand doc1

    SetReal doc1 0:1:4 12.2
  CommitCommand doc1

  SetReal doc1 0:1:1 1.2
  SetReal doc1 0:1:4 1.3
mtmCommit Transaction1

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There is one document ( "2690640" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2690640" )   < Last action
# 
# ***     End     ***
################################################################################
set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 21 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 29 [incr Case]]

# Check real attributes
set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1:1  1.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1:3 12.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1:4  1.3 [incr Case]]

mtmAdd doc2
mtmAdd doc3

mtmOpen
  SetReal doc2 0:2:1 2.1
  SetReal doc1 0:2:2 2.1
  OpenCommand doc1
  OpenCommand doc2
    SetReal doc2 0:2:1 21
    SetReal doc1 0:2:2 21
  AbortCommand doc2

  OpenCommand doc3
  OpenCommand doc2
    SetReal doc3 0:2:3 22.1
    SetReal doc2 0:2:3 22.1

    OpenCommand doc2
      SetReal doc2 0:2:3 221
    AbortCommand doc2

    SetReal doc3 0:2:4 22.2
  CommitCommand doc2
  CommitCommand doc3
  AbortCommand doc1

  SetReal doc1 0:2:1 2.2
  SetReal doc1 0:2:4 2.3
mtmCommit Transaction2

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "2697976" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "2697976" "2705536" "2809192" )   < Last action
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 41 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1  1.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 12.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  1.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmOpen
  SetReal doc1 0:1:1 3.1
  OpenCommand doc1
    SetReal doc1 0:1:1 31
  AbortCommand doc1

  OpenCommand doc1
    SetReal doc1 0:1:3 32.1

    OpenCommand doc1
      SetReal doc1 0:1:3 321
    AbortCommand doc1

    SetReal doc1 0:1:4 32.2
  CommitCommand doc1

  SetReal doc1 0:1:1 3.2
  SetReal doc1 0:1:4 3.3
mtmCommit Transaction3

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "2697976" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "2697976" "2705536" "2809192" ) 
#  Undo: 	Transaction3 - 1 documents  ( "2809192" )   < Last action
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set index4 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 41 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3} 1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4} 49 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1  3.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 32.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  3.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmUndo

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "2697976" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "2697976" "2705536" "2809192" )   < Last action
#  Redo: 	Transaction3 - 1 documents  ( "2809192" ) 
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set redo3 [lindex ${list} [expr ${index3} - 1]]
set index4 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1}     23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2}     31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2}     3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3}     44 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${redo3} "Redo:" [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4}     41 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1  1.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 12.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  1.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmOpen
  SetReal doc1 0:1:1 4.1
  OpenCommand doc1
    SetReal doc1 0:1:1 41
  AbortCommand doc1

  OpenCommand doc1
    SetReal doc1 0:1:3 42.1

    OpenCommand doc1
      SetReal doc1 0:1:3 421
mtmAbort

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "2697976" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "2697976" "2705536" "2809192" )   < Last action
#  Redo: 	Transaction3 - 1 documents  ( "2809192" ) 
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set redo3 [lindex ${list} [expr ${index3} - 1]]
set index4 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1}     23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2}     31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2}     3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3}     44 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${redo3} "Redo:" [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4}     41 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1  1.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 12.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  1.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmRedo

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "2697976" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "2697976" "2705536" "2809192" ) 
#  Undo: 	Transaction3 - 1 documents  ( "2809192" )   < Last action
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set undo3 [lindex ${list} [expr ${index3} - 1]]
set index4 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1}     23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2}     31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2}     3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3}     41 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${undo3} "Undo:" [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4}     49 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1  3.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 32.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  3.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmOpen
  SetReal doc1 0:1:1 5.1
  OpenCommand doc1
    SetReal doc1 0:1:1 51

  OpenCommand doc1
    SetReal doc1 0:1:3 52.1

    OpenCommand doc1
      SetReal doc1 0:1:3 521
mtmCommit Transaction5

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "2697976" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "2697976" "2705536" "2809192" ) 
#  Undo: 	Transaction3 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction5 - 1 documents  ( "2809192" )   < Last action
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set index4 [lsearch -exact ${list} "Transaction5"]
set docnum4 [lindex ${list} [expr ${index4} + 2]]
set index5 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1}     23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2}     31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2}     3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3}     41 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4}     49 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum4}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index5}     57 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1   51 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3  521 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  3.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmUndo

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "3095112" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "3095112" "2705536" "2809192" ) 
#  Undo: 	Transaction3 - 1 documents  ( "2809192" )   < Last action
#  Redo: 	Transaction5 - 1 documents  ( "2809192" ) 
# 
#  ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set index4 [lsearch -exact ${list} "Transaction5"]
set docnum4 [lindex ${list} [expr ${index4} + 2]]
set redo4 [lindex ${list} [expr ${index4} - 1]]
set index5 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1}     23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2}     31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2}     3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3}     41 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4}     52 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum4}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${redo4} "Redo:" [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index5}     49 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1  3.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 32.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  3.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

mtmOpen
  SetReal doc1 0:1:1 6.1
  OpenCommand doc1
    SetReal doc1 0:1:1 61

  OpenCommand doc1
    SetReal doc1 0:1:3 62.1

mtmCommit Transaction6

set list [mtmDump]
################################################################################
# *** Dump of MTM ***
# There are 3 documents ( "2809192" "2705536" "3095112" ) in the manager 
# Nested transaction mode is on
#  
#  Undo: 	Transaction1 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction2 - 3 documents  ( "3095112" "2705536" "2809192" ) 
#  Undo: 	Transaction3 - 1 documents  ( "2809192" ) 
#  Undo: 	Transaction6 - 1 documents  ( "2809192" )   < Last action
# 
# ***     End     ***
################################################################################

set index1 [lsearch -exact ${list} "Transaction1"]
set docnum1 [lindex ${list} [expr ${index1} + 2]]
set index2 [lsearch -exact ${list} "Transaction2"]
set docnum2 [lindex ${list} [expr ${index2} + 2]]
set index3 [lsearch -exact ${list} "Transaction3"]
set docnum3 [lindex ${list} [expr ${index3} + 2]]
set index4 [lsearch -exact ${list} "Transaction6"]
set docnum4 [lindex ${list} [expr ${index4} + 2]]
set index5 [lsearch -exact ${list} "Last"]

# Check dump
set IsGood [OCC1054_Check_dump ${IsGood} ${index1}     23 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index2}     31 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2}     3 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index3}     41 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index4}     49 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${docnum4}     1 [incr Case]]
set IsGood [OCC1054_Check_dump ${IsGood} ${index5}     57 [incr Case]]

# Check real attributes
# doc1
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:1   61 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:3 62.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:1:4  3.3 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:1  2.2 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:2  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc1 0:2:4  2.3 [incr Case]]
# doc2
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:1  2.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc2 0:2:3 22.1 [incr Case]]
# doc3
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:3 22.1 [incr Case]]
set IsGood [OCC1054_Check_real_attribute ${IsGood} doc3 0:2:4 22.2 [incr Case]]

if { ${IsGood} == 1 } {
  puts "OCC1054 OK"
} else {
  puts "OCC1054 Error"
}
