odbc: use cleanup in odbc-query to prevent resource leaks on errors

char-rename
Alexander Iljin 2016-10-31 00:16:18 +03:00 committed by John Benediktsson
parent 6c91db786a
commit a38b9cff93
1 changed files with 10 additions and 7 deletions

View File

@ -1,8 +1,9 @@
! Copyright (C) 2007 Chris Double. ! Copyright (C) 2007 Chris Double.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types alien.data alien.libraries USING: accessors alien alien.c-types alien.data alien.libraries
alien.strings alien.syntax combinators io.encodings.ascii kernel alien.strings alien.syntax combinators continuations
locals make math sequences strings threads ; io.encodings.ascii kernel locals make math sequences strings
threads ;
FROM: alien.c-types => float short ; FROM: alien.c-types => float short ;
IN: odbc IN: odbc
@ -259,8 +260,10 @@ C: <field> field
: odbc-query ( string dsn -- result ) : odbc-query ( string dsn -- result )
odbc-init swap odbc-connect [ odbc-init swap odbc-connect [
swap odbc-prepare [
dup odbc-execute swap odbc-prepare
dup odbc-get-all-rows dup odbc-execute
swap odbc-free-statement dup odbc-get-all-rows
] keep odbc-disconnect ; swap odbc-free-statement
] keep
] [ odbc-disconnect ] [ ] cleanup ;