如何检查 PostgreSQL 事务中的挂起操作 [英] How to check for pending operations in a PostgreSQL transaction

查看:26
本文介绍了如何检查 PostgreSQL 事务中的挂起操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PostgreSQL 上有一个会话 (SQLAlchemy),有一个活动的未提交事务.我刚刚通过 将会话传递给某个调用树,这些调用树可能已经或可能没有发出 SQL INSERT/UPDATE/DELETE 语句sqlalchemy.orm 或直接通过底层连接.

I have a session (SQLAlchemy) on PostgreSQL, with an active uncommitted transaction. I have just passed the session to some call tree that may or may not have issued SQL INSERT/UPDATE/DELETE statements, through sqlalchemy.orm or directly through the underlying connection.

有没有办法检查这个事务中是否有任何未决的数据修改语句?IE.提交是否为空操作,回滚是否会丢弃某些内容?

Is there a way to check whether there are any pending data-modifying statements in this transaction? I.e. whether commit would be a no-op or not, and whether rollback would discard something or not?

我看到有人在 Oracle 中指出 v$transaction 是为了同样的事情(参见 这个问题).我正在寻找类似于在 PostgreSQL 上使用的东西.

I've seen people point out v$transaction in Oracle for the same thing (see this SO question). I'm looking for something similar to use on PostgreSQL.

推荐答案

首先检查系统视图 pg_locks.

Start by checking into system view pg_locks.

http://www.postgresql.org/docs/8.4/interactive/view-pg-locks.html

这篇关于如何检查 PostgreSQL 事务中的挂起操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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