gpt4 book ai didi

database - 在 pgpool 中,在 postgresql 函数中使用删除查询时,它并没有从所有服务器中删除数据

转载 作者:太空狗 更新时间:2023-10-30 01:56:25 24 4
gpt4 key购买 nike

我在 pgpool 中创建了以下函数。

CREATE OR REPLACE Function fun1(Id int)
RETURNS boolean as $executionStatus$
DECLARE

BEGIN
DELETE FROM table1 where table1_id = Id ;
DELETE from table2 where table2_id = Id ;
DELETE from table3 where table3_id = Id ;
RETURN true;
END;
$executionStatus$ LANGUAGE plpgsql;

我在 pgpool 的 postgres shell 中运行以下命令

select fun1(1);

只删除master的数据。我再次尝试然后它从不同的服务器中删除。所以在这种情况下复制失败。但是,如果我单独使用删除查询,那么它工作正常。它正在从所有服务器中删除数据。

DELETE FROM table1 where table1_id =  1 ;DELETE from table2 where table2_id =  1 ;DELETE from table3 where table3_id =  1 ;

请让我知道如何解决这个问题。

最佳答案

我自己找到了答案在复制模式下(replication_mode = on),SELECT 是负载均衡的并且只有一个 PostgreSQL服务器接收命令。解决方案是:

1) 在SELECT前添加“/*REPLICATION*/”注释。

2) 将 func1 添加到 black_function_list。

关于database - 在 pgpool 中,在 postgresql 函数中使用删除查询时,它并没有从所有服务器中删除数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37324226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com