]> gitweb.factorcode.org Git - factor.git/commitdiff
clean up dispose a bit
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 9 Oct 2008 20:42:23 +0000 (15:42 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 9 Oct 2008 20:42:23 +0000 (15:42 -0500)
basis/db/db.factor
basis/db/postgresql/postgresql.factor
basis/db/sqlite/sqlite.factor

index a124914a3584aa387908c558aa0651eaa93662a3..3ee0fe3d09a3e1c9d2c355f8316c95279c735604 100644 (file)
@@ -6,7 +6,6 @@ tools.walker accessors combinators fry ;
 IN: db
 
 TUPLE: db
-    disposed
     handle
     insert-statements
     update-statements
@@ -23,12 +22,13 @@ HOOK: db-close db ( handle -- )
 
 : dispose-statements ( assoc -- ) values dispose-each ;
 
-: db-dispose ( db -- ) 
+M: db dispose ( db -- ) 
     dup db [
         [ dispose-statements H{ } clone ] change-insert-statements
         [ dispose-statements H{ } clone ] change-update-statements
         [ dispose-statements H{ } clone ] change-delete-statements
-        handle>> db-close
+        [ db-close f ] change-handle
+        drop
     ] with-variable ;
 
 TUPLE: result-set sql in-params out-params handle n max ;
index 08df25c13a9ff27e2950cf6f5d99cb5a7956ca9c..f9c9ea73ec413f7bed39ff0a6fa9d5f7dad5b069 100644 (file)
@@ -30,8 +30,8 @@ M: postgresql-db db-open ( db -- db )
         [ password>> ]
     } cleave connect-postgres >>handle ;
 
-M: postgresql-db dispose ( db -- )
-    handle>> PQfinish ;
+M: postgresql-db db-close ( handle -- )
+    PQfinish ;
 
 M: postgresql-statement bind-statement* ( statement -- ) drop ;
 
index 4aa41483d813c32446aa5561a1cf79ef788cf5a8..216f324bbfdfbe2d76563408a116812afed8df2f 100644 (file)
@@ -19,7 +19,6 @@ M: sqlite-db db-open ( db -- db )
     dup path>> sqlite-open >>handle ;
 
 M: sqlite-db db-close ( handle -- ) sqlite-close ;
-M: sqlite-db dispose ( db -- ) db-dispose ;
 
 TUPLE: sqlite-statement < statement ;