Merge branch 'master' into new_codegen
commit
993a01791b
|
@ -26,10 +26,6 @@ HELP: dispose-statements
|
|||
{ $values { "assoc" assoc } }
|
||||
{ $description "Disposes an associative list of statements." } ;
|
||||
|
||||
HELP: db-dispose
|
||||
{ $values { "db" db } }
|
||||
{ $description "Disposes of all the statements stored in the " { $link db } " object." } ;
|
||||
|
||||
HELP: statement
|
||||
{ $description "A " { $snippet "statement" } " stores the information about a statemen, such as the SQL statement text, the in/out parameters, and type information." } ;
|
||||
|
||||
|
@ -285,7 +281,7 @@ ARTICLE: "db-custom-database-combinators" "Custom database combinators"
|
|||
{ $code <"
|
||||
USING: db.sqlite db io.files ;
|
||||
: with-sqlite-db ( quot -- )
|
||||
"my-database.db" temp-file <sqlite-db> swap with-db ;"> }
|
||||
"my-database.db" temp-file <sqlite-db> swap with-db ; inline"> }
|
||||
|
||||
"PostgreSQL example combinator:"
|
||||
{ $code <" USING: db.postgresql db ;
|
||||
|
@ -296,7 +292,7 @@ USING: db.sqlite db io.files ;
|
|||
"erg" >>username
|
||||
"secrets?" >>password
|
||||
"factor-test" >>database
|
||||
swap with-db ;">
|
||||
swap with-db ; inline">
|
||||
} ;
|
||||
|
||||
ABOUT: "db"
|
||||
|
|
|
@ -22,14 +22,13 @@ HOOK: db-close db ( handle -- )
|
|||
|
||||
: dispose-statements ( assoc -- ) values dispose-each ;
|
||||
|
||||
: db-dispose ( db -- )
|
||||
M: db dispose ( db -- )
|
||||
dup db [
|
||||
{
|
||||
[ insert-statements>> dispose-statements ]
|
||||
[ update-statements>> dispose-statements ]
|
||||
[ delete-statements>> dispose-statements ]
|
||||
[ handle>> db-close ]
|
||||
} cleave
|
||||
[ dispose-statements H{ } clone ] change-insert-statements
|
||||
[ dispose-statements H{ } clone ] change-update-statements
|
||||
[ dispose-statements H{ } clone ] change-delete-statements
|
||||
[ db-close f ] change-handle
|
||||
drop
|
||||
] with-variable ;
|
||||
|
||||
TUPLE: result-set sql in-params out-params handle n max ;
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
@ -87,9 +86,11 @@ M: sqlite-statement bind-tuple ( tuple statement -- )
|
|||
in-params>> [ sqlite-bind-conversion ] with map
|
||||
] keep bind-statement ;
|
||||
|
||||
ERROR: sqlite-last-id-fail ;
|
||||
|
||||
: last-insert-id ( -- id )
|
||||
db get handle>> sqlite3_last_insert_rowid
|
||||
dup zero? [ "last-id failed" throw ] when ;
|
||||
dup zero? [ sqlite-last-id-fail ] when ;
|
||||
|
||||
M: sqlite-db insert-tuple-set-key ( tuple statement -- )
|
||||
execute-statement last-insert-id swap set-primary-key ;
|
||||
|
|
|
@ -302,8 +302,8 @@ ARTICLE: "embedding" "Embedding Factor into C applications"
|
|||
"The Factor " { $snippet "Makefile" } " builds the Factor VM both as an executable and a library. The library can be used by other applications. File names for the library on various operating systems:"
|
||||
{ $table
|
||||
{ "OS" "Library name" "Shared?" }
|
||||
{ "Windows XP/Vista" { $snippet "factor-nt.dll" } "Yes" }
|
||||
{ "Windows CE" { $snippet "factor-ce.dll" } "Yes" }
|
||||
{ "Windows XP/Vista" { $snippet "factor.dll" } "Yes" }
|
||||
! { "Windows CE" { $snippet "factor-ce.dll" } "Yes" }
|
||||
{ "Mac OS X" { $snippet "libfactor.dylib" } "Yes" }
|
||||
{ "Other Unix" { $snippet "libfactor.a" } "No" }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue