在一个事务中,pg报错了current transaction is aborted:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
mumy_corehrdban_psdb=> begin; BEGIN mumy_corehrdban_psdb=> select * from orasup_test1 ; a --- 1 2 3 (3 rows) mumy_corehrdban_psdb=> insert into orasup_test1 values(111); INSERT 0 1 mumy_corehrdban_psdb=> select * from not_exist; ERROR: relation "not_exist" does not exist LINE 1: select * from not_exist; ^ mumy_corehrdban_psdb=> insert into orasup_test1 values(222); ERROR: current transaction is aborted, commands ignored until end of transaction block mumy_corehrdban_psdb=> select * from orasup_test1; ERROR: current transaction is aborted, commands ignored until end of transaction block mumy_corehrdban_psdb=> mumy_corehrdban_psdb=> \d ERROR: current transaction is aborted, commands ignored until end of transaction block mumy_corehrdban_psdb=> mumy_corehrdban_psdb=> mumy_corehrdban_psdb=> rollback; ROLLBACK mumy_corehrdban_psdb=> select * from orasup_test1; a --- 1 2 3 (3 rows) mumy_corehrdban_psdb=> |
原因是在一个事务中,pg如果遇到的Error的报错,会忽略后续的命令,后续所有命令都会报错:current transaction is abor […]