System.Data.SQLite
Check-in [acbeea6018]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Corrections to tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessionStreamManager
Files: files | file ages | folders
SHA1: acbeea6018bb095e2d98a2a5d4aad37730c2580b
User & Date: mistachkin 2017-10-13 17:46:31
Context
2017-10-13
17:47
Object lifetime fixes for stream adapters and their managed delegates. check-in: aafb14f219 user: mistachkin tags: sessions
17:46
Corrections to tests. Closed-Leaf check-in: acbeea6018 user: mistachkin tags: sessionStreamManager
17:11
Prevent delegates used for native callbacks from being disposed while in use. check-in: 489188361e user: mistachkin tags: sessionStreamManager
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Tests/session.eagle.

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
107
108
109
110
111
112
113
114



115
116
117
118
119
120
121
...
256
257
258
259
260
261
262

263
264
265
266
267
268
269
...
351
352
353
354
355
356
357
358



359
360
361
362
363
364
365
...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
...
469
470
471
472
473
474
475

476
477
478
479
480
481
482
...
526
527
528
529
530
531
532

533
534
535


536
537
538
539
540
541
542
...
649
650
651
652
653
654
655

656
657
658
659
660
661
662
663
664
665

666
667
668


669
670
671
672
673
674
675
...
708
709
710
711
712
713
714

715
716
717
718
719
720
721
722

723
724
725


726
727
728
729
730
731
732
...
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846


847
848


849
850
851
852
853
854
855
  }
}

###############################################################################

proc createMemoryChangeSetForConnection { connection rawData } {
  if {[isObjectHandle $connection] && $connection ne "null"} then {
    return [$connection -alias \
        -objectflags +NoReturnReference CreateChangeSet $rawData]
  }

  return null
}

###############################################################################

................................................................................

    if {$patch} then {
      $session -alias CreatePatchSet byteArray
    } else {
      $session -alias CreateChangeSet byteArray
    }

    return [createByteArray [arrayToList byteArray]]



  }

  return null
}

###############################################################################

................................................................................

###############################################################################

proc matchSession { connection session expr } {
  if {[isObjectHandle $session] && $session ne "null"} then {
    if {![$session IsEmpty]} then {
      set rawData [createMemoryChangeSetForSession $session]


      if {[isObjectHandle $rawData] && $rawData ne "null"} then {
        return [matchChangeSet [set changeSet \
            [$connection -alias CreateChangeSet $rawData]] $expr]
      }
    }
  }
................................................................................
  $session AttachTable $tableName

  if {![isObjectHandle $session] || $session eq "null"} then {
    error "cannot create session"
  }

  catch {uplevel 1 $script}
  return [createMemoryChangeSetForSession $session]



}

###############################################################################

proc captureChangeSetFile {
        connection databaseName tableName script fileName } {
  if {![isObjectHandle $connection] || $connection eq "null"} then {
................................................................................
  return $result
}

###############################################################################

proc createByteArray { list } {
  set length [llength $list]

  set result [object create -alias \
      -objectflags +NoReturnReference System.Byte\[\] $length]

  for {set index 0} {$index < $length} {incr index} {
    set element [lindex $list $index]
    set value [object invoke -create Byte Parse $element]
    $result SetValue $value $index
  }

  #
  # NOTE: Prevent returning, which unsets all local variables,
  #       from causing the byte array object to be disposed.
  #
  object addref $result; object addref $result; return $result
}

###############################################################################

proc tableFilterCallbackT1 { clientData name } {
  lappend ::callbackResults [object invoke -create \
      System.Boolean Parse [expr {[$name ToString] in [list t1]}]]
................................................................................

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete]

  set rawData [createMemoryChangeSetForSession $session]


  writeRawDataToFile $fileName(1) $rawData
  writeStreamChangeSetForSession $session $fileName(2)
  openStreamChangeSetForConnection $connection $fileName(2) "" state

  list [expr {[file size $fileName(1)] > 0}] \
      [string equal [readFile $fileName(1)] [readFile $fileName(2)]] \
................................................................................

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete]

  set rawData [createMemoryChangeSetForSession $session]


  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData]



  set changeSet(2) [$changeSet(1) -alias Invert]

  list [changeSetToString $changeSet(2) true]
} -cleanup {
  cleanupSomeText

................................................................................
  $session SetToDisabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]


  lappend result Length [$rawData Length]

  $session SetToEnabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]


  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData]



  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

  unset -nocomplain result changeSet rawData byteArray session

................................................................................
  $session SetToIndirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]


  $session SetToDirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]


  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData]



  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

  unset -nocomplain result changeSet rawData byteArray session

................................................................................
  createTheSchema $db main
  makeSomeChanges $db t1 [list insert insert]

  set connection [getDbConnection]

  set rawData(1) [captureChangeSetRawData $connection main null {
    makeSomeChanges $db t1 [list delete] 1
  }]

  makeSomeChanges $db t1 [list insert] 1

  set rawData(2) [captureChangeSetRawData $connection main null {
    makeSomeChanges $db t1 [list insert]
  }]

  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData(1)]



  set changeSet(2) \
      [createMemoryChangeSetForConnection $connection $rawData(2)]



  set changeSet(3) [$changeSet(1) -alias CombineWith $changeSet(2)]

  $changeSet(3) -marshalflags +DynamicCallback \
      Apply conflictCallback null

  list [changeSetToString $changeSet(3) true] Data \







|
<







 







|
>
>
>







 







>







 







|
>
>
>







 







<
|
<







<
<
<
<
|







 







>







 







>



>
>







 







>










>



>
>







 







>








>



>
>







 







|





|




>
>


>
>







88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
...
406
407
408
409
410
411
412

413

414
415
416
417
418
419
420




421
422
423
424
425
426
427
428
...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
...
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
...
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
...
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
...
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
  }
}

###############################################################################

proc createMemoryChangeSetForConnection { connection rawData } {
  if {[isObjectHandle $connection] && $connection ne "null"} then {
    return [$connection -alias CreateChangeSet $rawData]

  }

  return null
}

###############################################################################

................................................................................

    if {$patch} then {
      $session -alias CreatePatchSet byteArray
    } else {
      $session -alias CreateChangeSet byteArray
    }

    set rawData [createByteArray [arrayToList byteArray]]
    object removeref $rawData

    return $rawData
  }

  return null
}

###############################################################################

................................................................................

###############################################################################

proc matchSession { connection session expr } {
  if {[isObjectHandle $session] && $session ne "null"} then {
    if {![$session IsEmpty]} then {
      set rawData [createMemoryChangeSetForSession $session]
      object removeref $rawData

      if {[isObjectHandle $rawData] && $rawData ne "null"} then {
        return [matchChangeSet [set changeSet \
            [$connection -alias CreateChangeSet $rawData]] $expr]
      }
    }
  }
................................................................................
  $session AttachTable $tableName

  if {![isObjectHandle $session] || $session eq "null"} then {
    error "cannot create session"
  }

  catch {uplevel 1 $script}
  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  return $rawData
}

###############################################################################

proc captureChangeSetFile {
        connection databaseName tableName script fileName } {
  if {![isObjectHandle $connection] || $connection eq "null"} then {
................................................................................
  return $result
}

###############################################################################

proc createByteArray { list } {
  set length [llength $list]

  set result [object create -alias System.Byte\[\] $length]


  for {set index 0} {$index < $length} {incr index} {
    set element [lindex $list $index]
    set value [object invoke -create Byte Parse $element]
    $result SetValue $value $index
  }





  return $result
}

###############################################################################

proc tableFilterCallbackT1 { clientData name } {
  lappend ::callbackResults [object invoke -create \
      System.Boolean Parse [expr {[$name ToString] in [list t1]}]]
................................................................................

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete]

  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  writeRawDataToFile $fileName(1) $rawData
  writeStreamChangeSetForSession $session $fileName(2)
  openStreamChangeSetForConnection $connection $fileName(2) "" state

  list [expr {[file size $fileName(1)] > 0}] \
      [string equal [readFile $fileName(1)] [readFile $fileName(2)]] \
................................................................................

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete]

  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData]

  object removeref $changeSet(1)

  set changeSet(2) [$changeSet(1) -alias Invert]

  list [changeSetToString $changeSet(2) true]
} -cleanup {
  cleanupSomeText

................................................................................
  $session SetToDisabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  lappend result Length [$rawData Length]

  $session SetToEnabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData]

  object removeref $changeSet(1)

  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

  unset -nocomplain result changeSet rawData byteArray session

................................................................................
  $session SetToIndirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  $session SetToDirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert]
  lappend result IsEmpty [$session IsEmpty]

  set rawData [createMemoryChangeSetForSession $session]
  object removeref $rawData

  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData]

  object removeref $changeSet(1)

  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

  unset -nocomplain result changeSet rawData byteArray session

................................................................................
  createTheSchema $db main
  makeSomeChanges $db t1 [list insert insert]

  set connection [getDbConnection]

  set rawData(1) [captureChangeSetRawData $connection main null {
    makeSomeChanges $db t1 [list delete] 1
  }]; object removeref $rawData(1)

  makeSomeChanges $db t1 [list insert] 1

  set rawData(2) [captureChangeSetRawData $connection main null {
    makeSomeChanges $db t1 [list insert]
  }]; object removeref $rawData(2)

  set changeSet(1) \
      [createMemoryChangeSetForConnection $connection $rawData(1)]

  object removeref $changeSet(1)

  set changeSet(2) \
      [createMemoryChangeSetForConnection $connection $rawData(2)]

  object removeref $changeSet(2)

  set changeSet(3) [$changeSet(1) -alias CombineWith $changeSet(2)]

  $changeSet(3) -marshalflags +DynamicCallback \
      Apply conflictCallback null

  list [changeSetToString $changeSet(3) true] Data \