Re: [PATH] Jsonb, insert a new value into an array at arbitrary position

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: David Steele <david(at)pgmasters(dot)net>
Cc: Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATH] Jsonb, insert a new value into an array at arbitrary position
Date: 2016-03-17 06:54:50
Message-ID: CA+q6zcWmzEdwYa8Hao2NxGn2LAGnUs38b_zPtW-8n6iqKPzEjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Vitaly, thanks for the review. I've attached a new version of path with
improvements. Few notes:

> 7. Why did you remove "skip"? It is a comment what "true" means...

Actually, I thought that this comment was about skipping an element from
jsonb in order to change/delete it,
not about the last argument. E.g. you can find several occurrences of
`JsonbIteratorNext` with `true` as the last
argument but without a "last argument is about skip" comment.
And there is a piece of code in the function `jsonb_delete` with a "skip
element" commentary:

```
/* skip corresponding value as well */
if (r == WJB_KEY)
JsonbIteratorNext(&it, &v, true);
```

So since in this patch it's not a simple skipping for setPathArray, I
removed that commentary. Am I wrong?

> 9. And finally... it does not work as expected in case of:

Yes, good catch, thanks.

Attachment Content-Type Size
jsonb_insert_v3.patch text/x-patch 17.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-03-17 07:09:13 Re: IF (NOT) EXISTS in psql-completion
Previous Message Craig Ringer 2016-03-17 06:31:24 Re: TAP / recovery-test fs-level backups, psql enhancements etc