确定事务是否处于活动状态(Postgres) [英] Determine if a transaction is active (Postgres)

查看:56
本文介绍了确定事务是否处于活动状态(Postgres)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定事务是否处于活动状态?无论事务当前是否处于活动状态,我都希望能够执行创建保存点的 SQL(即,如果它不处于活动状态,我想开始")

How can I determine if a transaction is active? I'd like to be able to execute SQL that creates a savepoint regardless of whether or not a transaction is currently active (i.e. if it isn't active, I want to "BEGIN")

推荐答案

你可以做

begin;
savepoint foo;

开始;"如果已经有交易,则为空操作.

The "begin;" will be a no-op if there is a transaction already.

另见:https://stackoverflow.com/a/28802471/435563

这篇关于确定事务是否处于活动状态(Postgres)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆