[postmodern-devel] Postgres transaction warnings and save-dao
Daniel White
daniel at whitehouse.id.au
Tue Mar 9 11:04:20 UTC 2010
I've also had the need for determining the state of a transaction.
Previously, I'd defined a local WITH-TRANSACTION macro that bound a
special variable *TRANSACTION* with the transaction in progress.
I have attached a patch that does just that. WITHIN-TRANSACTION-P
will return T if a transaction is open. I've not exported
*TRANSACTION* because I'm unsure whether this should be part of the
public interface. I'm yet to come up with a less hands-on approach to
nested transactions, but this allows options for experiments outside
of the postmodern proper.
For example, my ENSURE-TRANSACTION macro. Really, I should be using
savepoints, but this allows me some more flexibility in how I layer my
database access methods. I'm not sure if this is appropriate, but if
you think it is useful enough, I can prepare a patch to include this
as well.
(defmacro ensure-transaction ((&optional name) &body body)
`(flet ((exec-body ()
(let ,(if name `((,name postmodern::*transaction*)))
, at body)))
(if (within-transaction-p)
(exec-body)
(with-transaction (,name)
(exec-body)))))
--
Daniel White
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-function_-within_transaction_p_-to-determine-if-a-transaction-is-open.dpatch
Type: application/octet-stream
Size: 32941 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/postmodern-devel/attachments/20100309/b8073c15/attachment.obj>
More information about the postmodern-devel
mailing list