pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: Michael Paquier <michael.paquier@gmail.com>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14849: jsonb_build_object doesn't like VARIADIC calls very much
Date: Wed, 18 Oct 2017 11:46:57 -0400
Message-ID: <661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com> (raw)
In-Reply-To: <CAB7nPqTh-Oo-FxurwDq6V8sfR2yNc-2PE7CB4RrnM8ewwS8Z9A@mail.gmail.com>
References: <20171011020058.27986.42308@wrigleys.postgresql.org>
	<CAB7nPqSDHmjE-6HS-RUufZMEc6qipBDNjL1HktcMagVn7pGOcw@mail.gmail.com>
	<76ff5ede-99a7-536b-4c26-0db0748ea6e1@2ndQuadrant.com>
	<CAB7nPqTP9B_FLDGL=dPx5iGqKTJSENfvD=PoOy=zzC1AmmM55A@mail.gmail.com>
	<CA+q6zcU=6CcmdAdW=J9o-ukmyKYLLL=6-cHYPZNLN5JQr4wRRw@mail.gmail.com>
	<CAB7nPqTppc5w2nX7jaSu94V+VHfThbvRq12hmLrSiiN6ii1spA@mail.gmail.com>
	<CAB7nPqRDvken_V70kGXX3=9w4D9zM9-jj2gfg6pMyjpRzaSvPQ@mail.gmail.com>
	<CA+q6zcUyiqG8HezQT2U+78udtMPeOFiXD9dRmT5saYtESckOpw@mail.gmail.com>
	<CAB7nPqTsuq=rnM8PQGxNS3Gh=JQQp4RmdPxGLGXSV648X4yfhA@mail.gmail.com>
	<CA+q6zcWNs_j5pd_+j6JbFXe7M=n9NX8h0Emb1pux7Ap=w=DWrA@mail.gmail.com>
	<CAB7nPqTh-Oo-FxurwDq6V8sfR2yNc-2PE7CB4RrnM8ewwS8Z9A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>



On 10/15/2017 08:08 PM, Michael Paquier wrote:
> On Mon, Oct 16, 2017 at 4:41 AM, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
>>> On 14 October 2017 at 12:46, Michael Paquier <michael.paquier@gmail.com>
>>> wrote:
>>>
>>> Okay. Attached is an updated patch fixing what you have reported.
>> Thanks for the patch. Everything looks fine, I just have one question -
>> maybe
>> it makes sense to put this pattern `if (variadic) {/*...*/}` into a separate
>> function? Because from what I see it's basically one part of code (I didn't
>> spot any difference) repeated four times for every function.
> The json/jsonb calls have one difference though. For jsonb, arguments
> with unknown type are enforced to text, which is not the case of json,
> and we don't want to change that behavior. Both the json and jsonb
> calls also use different utility routines which are proper to json.c
> and jsonb.c, so moving all things to jsonfuncs.c is out of the game
> (see add_jsonb and add_json). There is a common place for JSON-common
> code in jsonapi.c, but jsonapi.h is wanted as light-weight (see its
> set of headers), so moving things there is incorrect as well IMO.
>
> One thing that could be done though is to have two routines which
> prepare the arguments for the array and object build, one for each
> file json.c and jsonb.c. The routine could return the number of
> arguments processed, at the exception that if the routine returns -1,
> then the result for the object generated should be NULL, which
> corresponds to the case where a NULL array is given in a variadic
> call.
>
> What do you think?


That seems a reasonable approach.

cheers

andrew

-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (33+ messages)  latest in thread

Message-ID: <661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com>
Permalink:  ../661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com/
Also on:    postgresql.org/message-id/661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew.dunstan@2ndquadrant.com, michael.paquier@gmail.com, 9erthalion6@gmail.com, marko@joh.to
  Subject: Re: BUG #14849: jsonb_build_object doesn't like VARIADIC calls very much
  In-Reply-To: <661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com>
  References: <20171011020058.27986.42308@wrigleys.postgresql.org> <CAB7nPqSDHmjE-6HS-RUufZMEc6qipBDNjL1HktcMagVn7pGOcw@mail.gmail.com> <76ff5ede-99a7-536b-4c26-0db0748ea6e1@2ndQuadrant.com> <CAB7nPqTP9B_FLDGL=dPx5iGqKTJSENfvD=PoOy=zzC1AmmM55A@mail.gmail.com> <CA+q6zcU=6CcmdAdW=J9o-ukmyKYLLL=6-cHYPZNLN5JQr4wRRw@mail.gmail.com> <CAB7nPqTppc5w2nX7jaSu94V+VHfThbvRq12hmLrSiiN6ii1spA@mail.gmail.com> <CAB7nPqRDvken_V70kGXX3=9w4D9zM9-jj2gfg6pMyjpRzaSvPQ@mail.gmail.com> <CA+q6zcUyiqG8HezQT2U+78udtMPeOFiXD9dRmT5saYtESckOpw@mail.gmail.com> <CAB7nPqTsuq=rnM8PQGxNS3Gh=JQQp4RmdPxGLGXSV648X4yfhA@mail.gmail.com> <CA+q6zcWNs_j5pd_+j6JbFXe7M=n9NX8h0Emb1pux7Ap=w=DWrA@mail.gmail.com> <CAB7nPqTh-Oo-FxurwDq6V8sfR2yNc-2PE7CB4RrnM8ewwS8Z9A@mail.gmail.com> <661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox