我发现在9.6.0版本里json方面有个bug,谁能给打个patch
即执行:select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', false);
本语句愿意是替换掉第一个元素,结果给删掉了(false可能给搞反了),结果为:
jsontestdb=> select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]',
false);
jsonb_set
--------------
[2, null, 3]
(1 行记录)
而在9.5.4里面语义完全正确,结果为:
psql (9.5.4)
postgres=# select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', fa
lse);
jsonb_set
-------------------------
[[2, 3, 4], 2, null, 3]
(1 行记录)
后面有时间看看内核里这个bug怎么回事。
bluevaley@gmail.com writes:
> The following bug has been logged on the website:
> Bug reference: 14366
> Logged by: peng sun
> Email address:
bluevaley@gmail.com> PostgreSQL version: 9.6.0
> Operating system: win8.1
> Description:
> select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', false);
> in 9.6, got:
> [2, null, 3]
> in 9.5.4, got:
> [[2, 3, 4], 2, null, 3]
Yeah, this is broken. Fixed, thanks for the report!
regards, tom lane