!1729 修复设置事务读写模式失效的问题
Merge pull request !1729 from pengjiong/transaction
This commit is contained in:
@ -2260,8 +2260,11 @@ static void set_item_arg_according_to_def_name(DefElem* item)
|
||||
if (strcmp(item->defname, "transaction_isolation") == 0) {
|
||||
SetPGVariable("transaction_isolation", list_make1(item->arg), true);
|
||||
} else if (strcmp(item->defname, "transaction_read_only") == 0) {
|
||||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
/* Set read only state from CN when this DN is not read only. */
|
||||
if (u_sess->attr.attr_storage.DefaultXactReadOnly == false) {
|
||||
if (u_sess->attr.attr_storage.DefaultXactReadOnly == false)
|
||||
#endif
|
||||
{
|
||||
SetPGVariable("transaction_read_only", list_make1(item->arg), true);
|
||||
}
|
||||
} else if (strcmp(item->defname, "transaction_deferrable") == 0) {
|
||||
|
||||
20
src/test/regress/expected/transactions_test.out
Normal file
20
src/test/regress/expected/transactions_test.out
Normal file
@ -0,0 +1,20 @@
|
||||
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
|
||||
START TRANSACTION READ WRITE;
|
||||
CREATE TABLE transaction_test_table(a int);
|
||||
insert into transaction_test_table values(1);
|
||||
update transaction_test_table set a=2 where a=1;
|
||||
select * from transaction_test_table;
|
||||
a
|
||||
---
|
||||
2
|
||||
(1 row)
|
||||
|
||||
commit;
|
||||
-- error
|
||||
delete from transaction_test_table;
|
||||
ERROR: cannot execute DELETE in a read-only transaction
|
||||
drop table transaction_test_table;
|
||||
ERROR: cannot execute DROP TABLE in a read-only transaction
|
||||
START TRANSACTION READ WRITE;
|
||||
drop table transaction_test_table;
|
||||
commit;
|
||||
@ -154,7 +154,7 @@ test: single_node_select_implicit single_node_select_having
|
||||
test: single_node_union
|
||||
#test: single_node_case single_node_join single_node_aggregates
|
||||
#test: single_node_transactions
|
||||
test: single_node_random
|
||||
test: single_node_random transactions_test
|
||||
#test: single_node_portals
|
||||
#test: single_node_arrays
|
||||
#test: single_node_btree_index single_node_hash_index single_node_update
|
||||
|
||||
14
src/test/regress/sql/transactions_test.sql
Normal file
14
src/test/regress/sql/transactions_test.sql
Normal file
@ -0,0 +1,14 @@
|
||||
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
|
||||
START TRANSACTION READ WRITE;
|
||||
CREATE TABLE transaction_test_table(a int);
|
||||
insert into transaction_test_table values(1);
|
||||
update transaction_test_table set a=2 where a=1;
|
||||
select * from transaction_test_table;
|
||||
commit;
|
||||
-- error
|
||||
delete from transaction_test_table;
|
||||
drop table transaction_test_table;
|
||||
|
||||
START TRANSACTION READ WRITE;
|
||||
drop table transaction_test_table;
|
||||
commit;
|
||||
Reference in New Issue
Block a user