3

我最近将我的 postgres 数据库从 9.5.4 升级到 10.7,并注意到现有查询的一些奇怪行为。

精简版如下所示:

update
    mytable
set
    job_id = 6
where
    id in (
    select * from
    (
        select id from
        mytable
        where job_id is null
        limit 2
    ) x for update)
    and job_id is null

我希望行数更新为 2,但它正在更新与子查询匹配的所有记录,没有限制。如果我删除for update语句或匹配job_id is null语句,更新的记录确实等于 2,如预期的那样。在我们更新此查询之前,将更新正确的行数。

10.x 中的某些行为是否发生了变化?

4

0 回答 0