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