KingbaseES 参数 - ora_statement_level_rollback
参数 ora_statement_level_rollback 控制KingbaseES 是否实现类似oracle 语句级的回滚。当该参数打开时,如果事务操作失败,仅会回滚最后一条操作,避免了全部操作的回滚。以下举例展示差异。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
create table t1(id integer);create or replace procedure p1 isbegin insert into t1 values(1); insert into t1 values('a');exception when others then null;end;create or replace procedure p2 isbegin insert into t1 values(1); begin insert into t1 values('a'); exception when others then null; end;end; |
注意:例子有进行exception 捕获,如果没有exception 捕获,则不管是oracle ,还是 kingbaseES,这所有操作都回退。
1、Oracle 结果
仅回滚第二条insert 失败的操作。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
SQL> truncate table t1;Table truncated.SQL> call p1();Call completed.SQL> select * from t1; ID---------- 1 |
2、KingbaseES
当 ora_statement_level_rollback = on时,结果与oracle 相同,只回退最后一个操作。
|
1
2
3
4
5
6
7
8
9
|
test=# truncate table t1;TRUNCATE TABLEtest=# call p1();CALLtest=# select * from t1; id---- 1(1 row) |
3、PG
可以看到,所有操作全部回退。
|
1
2
3
4
5
6
7
8
|
test=# delete from t1;DELETE 1test=# call p1();CALLtest=# select * from t1; id----(0 rows) |
以上例子,p1 , p2 过程执行结果在oracle , pg , KingbaseES 执行结果相同。
注意:ora_statement_level_rollback 目前仅能支持过程块内语句级回滚,不支持非块内语句级的回滚(而oracle 支持)。
知识分享,需人人参与,看完请点赞留言,共同讨论进步

浙公网安备 33010602011771号