Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_state.tcl part of check-in [47d52d1efd] - Added convenience method for assertions and used it in place of the existing if/trouble internal constructions. Changed API of 'log write' so that we can defer substituation of the message to when the write actually happen, and converted all places which would be hit by double-substitution. The remaining 'log write' calls will be converted incrementally. by aku on 2007-11-28 05:39:49. [view]

To:

File tools/cvs2fossil/lib/c2f_state.tcl part of check-in [74854a30b8] - Added ability to declare indices on tables in the persistent state. Used this to declare indices on critical columns. Slows down the transactions saving changesets, this however is made up when it comes to successor/predecessor retrieval of changesets. by aku on 2007-12-02 03:40:56. [view]

@@ -94,9 +94,9 @@
 	file delete $mypath
 	return
     }
 
-    typemethod writing {name definition} {
+    typemethod writing {name definition {indices {}}} {
 	# Method for a user to declare a table its needs for storing
 	# persistent state, and the expected structure. A possibly
 	# previously existing definition is dropped.
 
@@ -104,8 +104,16 @@
 
 	$mystate transaction {
 	    catch { $mystate eval "DROP TABLE $name" }
 	    $mystate eval "CREATE TABLE $name ( $definition )"
+
+	    set id 0
+	    foreach columns $indices {
+		log write 1 state "index   $name$id" ; # TODO move to level 5 or so
+
+		$mystate eval "CREATE INDEX ${name}$id ON ${name} ( [join $columns ,] )"
+		incr id
+	    }
 	}
 	return
     }