小编nik*_*iks的帖子

如何允许用户在Postgresql中调用存储过程而不授予额外的权限?

我在 Postgresql 中有一个包含 COMMIT 语句的存储过程,我希望用户只能访问此过程,而不授予他们选择、插入等的权利。在函数中,我将使用 SECURITY DEFINER,但来自官方文档 https:// www. postgresql.org/docs/11/sql-createprocedure.html

SECURITY DEFINER 过程无法执行事务控制语句(例如 COMMIT 和 ROLLBACK,具体取决于语言)。

据我了解,这意味着我无法使用 SECURITY DEFINER,并且必须授予用户存储过程中所需的任何权限以允许用户执行它,这完全违背了仅允许用户使用函数或过程的整个目的。

如何调用其中包含 COMMIT 语句的存储过程,而不需要对过程内的所有语句进行单独授权?

postgresql stored-procedures transactions

6
推荐指数
1
解决办法
1万
查看次数

取消TPL数据流块的正确方法

我正在使用TPL块来执行可能被用户取消的操作:我提出了两个选项,首先我取消整个块但不取消块内的操作,如下所示:

_downloadCts = new CancellationTokenSource();

var processBlockV1 = new TransformBlock<int, List<int>>(construct =>
{
    List<int> properties = GetPropertiesMethod(construct );
    var entities = properties
        .AsParallel()
        .Select(DoSometheningWithData)
        .ToList();
    return entities;
}, new ExecutionDataflowBlockOptions() { CancellationToken = _downloadCts.Token });
Run Code Online (Sandbox Code Playgroud)

第二个我取消内部操作,但不是块本身:

var processBlockV2 = new TransformBlock<int, List<int>>(construct =>
{
    List<int> properties = GetPropertiesMethod(construct);
    var entities = properties
        .AsParallel().WithCancellation(_downloadCts.Token)
        .Select(DoSometheningWithData)
        .ToList();
    return entities;
});
Run Code Online (Sandbox Code Playgroud)

据我了解,第一个选项将取消整个块,从而关闭整个管道。我的问题是它是否也会取消内部操作并处理所有资源(如果有)(打开 StreamReaders 等),或者最好选择第二个选项,然后我自己可以确保所有内容都被取消和清理,然后我可以使用一些方法(铁路编程)漂浮OperationCanceledException在管道上并在我想要的地方处理它?

c# task-parallel-library cancellationtokensource tpl-dataflow

5
推荐指数
0
解决办法
156
查看次数