Re: pgsql: Rename jsonb_replace to jsonb_set and allow it to add new values

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Rename jsonb_replace to jsonb_set and allow it to add new values
Date: 2015-06-01 02:53:51
Message-ID: 556BC93F.3060304@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers


On 05/31/2015 10:25 PM, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> well, that's what we have a buildfarm for.
> It looks like this problem is in setPathObject:
>
> setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
> int path_len, JsonbParseState **st, int level,
> Jsonb *newval, uint32 npairs, bool create)
> {
> JsonbValue v;
> int i;
> JsonbValue k;
> bool done = false;
>
> if (level >= path_len || path_nulls[level])
> done = true;
>
> /* empty object is a special case for create */
> if ((npairs == 0) && create && (level == path_len - 1))
> {
> JsonbValue new = k;
>
> new.val.string.len = VARSIZE_ANY_EXHDR(path_elems[level]);
> new.val.string.val = VARDATA_ANY(path_elems[level]);
>
> (void) pushJsonbValue(st, WJB_KEY, &new);
>
> Since "k" is undefined at this point, initializing "new" that way is pure
> hogwash. I'm surprised gcc doesn't complain about it.
>
> (BTW, could I lobby to not use "new" as a variable name? lldb gets
> confused, probably because "new" is a C++ keyword.)
>
>

OK, I'll fix these too.

cheers

andrew

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2015-06-01 02:57:56 pgsql: Avoid naming a variable "new", and remove bogus initializer.
Previous Message Andrew Dunstan 2015-06-01 02:52:53 pgsql: Add a couple of missing JsonbValue type initialisers.