Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4qYi-00067c-GW for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Oct 2017 15:47:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e4qYh-0007Kz-V8 for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Oct 2017 15:47:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e4qYh-0007Hr-36 for pgsql-bugs@postgresql.org; Wed, 18 Oct 2017 15:47:03 +0000 Received: from mail-yw0-x22b.google.com ([2607:f8b0:4002:c05::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e4qYe-0004N3-8C for pgsql-bugs@postgresql.org; Wed, 18 Oct 2017 15:47:01 +0000 Received: by mail-yw0-x22b.google.com with SMTP id i198so921873ywe.7 for ; Wed, 18 Oct 2017 08:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=pPq81gjAqeNDwj+l5CHl5euI5wXi0xl/ReKC5u6VJR8=; b=0RYs8rY6SuoWyAtUL6UeHnoh2YDBkgWKbVptTd2M+k9WgWuaHPoroc01tYkaohFinu V7PbshL9Hmad9FCxyZ+5xlJhXGruYRAAsWB0O5v0RdWmZbc9+xWvToDWJBIDNyXKrkrf IYB9wM9TYlT2JZL+67Ugg37TWuGIXeSuEvtLwDOBVIno3wyZ+fKVwj+Xe6Jz83WkORUM gLo23kGQcDl7DL1maqbkdeHKd2wvbwuWdG0lp2jBni3EMVwnquo1eHf8khqRTDekfHJo y2eTzUwGVD8bsLcxDcz+bFj/5RZTJxQg3+7y2o7H1EwTp6UFpdcb1OWl64qkUSI4IZko wgJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=pPq81gjAqeNDwj+l5CHl5euI5wXi0xl/ReKC5u6VJR8=; b=LE9gQ7enP0UHOsjdsvJOvMiKbZZqY66BxM+RiwCzHTnPeAVbadCTpHvwo/Yke+fFuC 1HWW1fvqomobW4VTgtAMSmwUp0zoARFYMIH3e9DGFYhKzmmJwQm8ewj7lEcGODnP8rnw 5B5tqm/C8zlMGmKydPxuB0NKgEE+h/sep4zmpFARDlb19P5c0vWECQ7/hetXYq2gBa/5 XBoIx/OkJ/F23BMwEvPcC9J1EI+qUKsgBIeYUB5sYLzXx96r1elHTo2F4ep1OSggOjcP Assm3b1JHbEsh5DfNLfzfhb1rwz81Zxy0UYX/RdfSELuqKlRZpuAliuB3/P7u3f44zYp KEZA== X-Gm-Message-State: AMCzsaUYrtd0rlhLy4WrfVoLNcgGDwdf0vwbgt5aRzahnr31FZCNY1SQ 972UaNO6OIyvoexRryu+3ozZtvRGZ26rbiO2V4i/jTqktCL/gEMH/CB2pJvfGZ3wGSmDUwLHFZK Y53QmErhmRX4xEfCuhVkBreq1yYn84c5vsYUyVKDblcp7FfD7jON9zn0LI4IKLuMLu5XTZi9/na M39lvVbsgq X-Google-Smtp-Source: ABhQp+SM7wGdt+AeTI/+ecbEdxuW9z9dNczfDhGeQMCLenHrtkyt+8MW3BRNv/TEeq4vVoUDus5r0Q== X-Received: by 10.129.14.212 with SMTP id 203mr1758209ywo.445.1508341619216; Wed, 18 Oct 2017 08:46:59 -0700 (PDT) Received: from [192.168.10.146] ([98.122.175.38]) by smtp.gmail.com with ESMTPSA id i5sm6673763ywi.65.2017.10.18.08.46.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2017 08:46:58 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: BUG #14849: jsonb_build_object doesn't like VARIADIC calls very much To: Michael Paquier , Dmitry Dolgov <9erthalion6@gmail.com> Cc: Marko Tiikkaja , PostgreSQL mailing lists References: <20171011020058.27986.42308@wrigleys.postgresql.org> <76ff5ede-99a7-536b-4c26-0db0748ea6e1@2ndQuadrant.com> Message-ID: <661e8bde-aa82-7a83-c330-350e65be4248@2ndQuadrant.com> Date: Wed, 18 Oct 2017 11:46:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-MW List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 >>> 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