简体   繁体   English

PostgreSQL“没有正在进行的交易”

[英]Postgresql “no transaction in progress”

Why am I getting a warning about "no transaction in progress" after a COMMIT even when I have explicitly started a transaction with START TRANSACTION (works the same as BEGIN )? 为什么即使我已经使用START TRANSACTION显式启动了事务(与BEGIN相同),在COMMIT之后仍收到关于“无事务进行中”的警告? This will occur 90% of the time for this specific transaction, but other times the commit will succeed. 对于此特定事务,这将在90%的时间内发生,但其他时候提交将成功。 I'm using postgres 9.3. 我正在使用postgres 9.3。 Here's the postgres log: 这是postgres日志:

2014-07-04 21:47:19 EST LOG:  statement: START TRANSACTION;
2014-07-04 21:47:19 EST LOG:  statement: SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
2014-07-04 21:47:19 EST LOG:  statement: SET autocommit = 1;
2014-07-04 21:47:19 EST LOG:  statement: SET TIME ZONE 'UTC'
2014-07-04 21:47:19 EST LOG:  statement: INSERT INTO "Users" (...) VALUES (...) RETURNING *;
2014-07-04 21:47:19 EST LOG:  statement: INSERT INTO "Profiles" (...) RETURNING *;
2014-07-04 21:47:19 EST LOG:  statement: SET TIME ZONE 'UTC'
2014-07-04 21:47:19 EST LOG:  statement: INSERT INTO "Sessions" (...) VALUES (...) RETURNING *;
2014-07-04 21:47:20 EST LOG:  statement: COMMIT;
2014-07-04 21:47:20 EST WARNING:  there is no transaction in progress

You are using autocommit. 您正在使用自动提交。 When using autocommit, explicitly starting a transaction is meaningless. 使用自动提交时,显式启动事务是没有意义的。

Remove the line "set autocommit = 1" or change the 1 to "off" or an equivalent value and this should work. 删除行“ set autocommit = 1”或将1更改为“ off”或等效值,这应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM