Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvuHh-0000K4-Q8 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Apr 2017 23:24:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cvuHh-0006m8-Cl for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Apr 2017 23:24:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cvuHf-0006jg-Ku for pgsql-hackers@postgresql.org; Wed, 05 Apr 2017 23:24:15 +0000 Received: from mail-yw0-x231.google.com ([2607:f8b0:4002:c05::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cvuHc-00024k-22 for pgsql-hackers@postgresql.org; Wed, 05 Apr 2017 23:24:15 +0000 Received: by mail-yw0-x231.google.com with SMTP id i203so13195558ywc.3 for ; Wed, 05 Apr 2017 16:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=FP1O9e1Qr6xMZYQVRHXLjMoihVvw2JikCaKcH0FOo9c=; b=eWL6uQi3eurM1iC4d4KxnkOpNvbqIEHPUSpt321FEuntXoEoxKCx05KFeKm2grvOmC p9omSRH3+5NZaw5JyvXKcISpoxDoZ34nmj/sIdJyQenabNWAUR/14jgrg8LAlXSmZqFT 5eA2fobqZYazpRGmlK1vHWhMuQTgtRuD6Joz62QNpNuzRjtjGEp6LVVcjWAsPpQ0i+u1 CZ77ij3jUBlOkMOB8SfLuSyllbU7E44iIZQS2nceTyLWvVecSF+yQrXPUHOvMmLRWkn3 TWZ4yA0JJziPBv03AVAXACAPIYpEbvnlTp+hOW5ZQgULq3ZisKVJEYK5TQTYc7OdFqtC F4sQ== 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:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=FP1O9e1Qr6xMZYQVRHXLjMoihVvw2JikCaKcH0FOo9c=; b=NJNECj4bhzYleyk78OA9pxFwxG0IvM5ms9LffGKs0/mBnmK6Jp0BpaE7/0JiohfVZm TT33Yf0shss3rQmq6xFw1sH8YHtGqs3uR7rQRZHMWRTCfKoAhDGuj0dkmhIV3vcC+KCf hKN6vNFnN5OKibIK0SzTxqLvZrm6nN+w7GMWVSgJuj8hkuTlPW4QozDdi9+40lCNez2B 2UllMxBWvW9YefUMi41FQt1nSkbW+in5SOC586DkDzTAJMxLBNy2CbCRevlOAInZ4twN kLdLHJXWyDvRkm22R1xD0KFzl7CDvGYXvZVfbrC2PREvZFIdJYlWGMpFd2LnUvwrA4dz pYXw== X-Gm-Message-State: AFeK/H1ZPr1ZCVQyF6+dQY7ETmYoNyQqW3cZCkBUmqGRryZc816sf0jJnSsKqPLO2UwcNx4CQEkIFMN7jeGJgi3F3Sxz38cD4Eo0QpoB3zVdoIN5i7caQP0x3JOvpzdtOSjb0x7LwmDSnek0d/TzX6M2bh9hhGZe52Om4f2qTdQgus/xqpZA0Vt8HtAWDAwjVYML4tQZcTRGzTw= X-Received: by 10.129.118.8 with SMTP id r8mr21991295ywc.181.1491434649969; Wed, 05 Apr 2017 16:24:09 -0700 (PDT) Received: from [192.168.10.146] ([98.122.164.227]) by smtp.gmail.com with ESMTPSA id p68sm10097002ywf.27.2017.04.05.16.24.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Apr 2017 16:24:09 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: PATCH: recursive json_populate_record() To: Andres Freund References: <687e19a7-14e2-d0f5-2bff-35d62bc5c05a@postgrespro.ru> <934.1485111512@sss.pgh.pa.us> <9e21a39c-c1d7-b9b5-44a0-c5345a5029f6@postgrespro.ru> <13020.1485377905@sss.pgh.pa.us> <295ad4a5-2923-1834-5140-35d0b9a5818c@postgrespro.ru> <16179.1485380983@sss.pgh.pa.us> <9bf14a7c-0794-f90c-c012-8dd0335ab364@pgmasters.net> <754780af-d905-9704-cf4d-b64e632b86a3@2ndQuadrant.com> <20170403211741.7ommm5dssfv3abo6@alap3.anarazel.de> <45c0aa55-1b62-c622-31fd-cb21e017d5cd@2ndQuadrant.com> Cc: David Steele , Nikita Glukhov , Michael Paquier , Tom Lane , Aleksander Alekseev , PostgreSQL mailing lists Message-ID: <8fcd9e65-acb0-8221-ef23-01e5c2fe90e4@2ndQuadrant.com> Date: Wed, 5 Apr 2017 19:24:08 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <45c0aa55-1b62-c622-31fd-cb21e017d5cd@2ndQuadrant.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 04/04/2017 05:18 PM, Andrew Dunstan wrote: > > On 04/03/2017 05:17 PM, Andres Freund wrote: >> On 2017-03-21 14:31:08 -0400, Andrew Dunstan wrote: >>> On 03/21/2017 01:37 PM, David Steele wrote: >>>> On 3/16/17 11:54 AM, David Steele wrote: >>>>> On 2/1/17 12:53 AM, Michael Paquier wrote: >>>>>> On Thu, Jan 26, 2017 at 6:49 AM, Tom Lane wrote: >>>>>>> Nikita Glukhov writes: >>>>>>>> On 25.01.2017 23:58, Tom Lane wrote: >>>>>>>>> I think you need to take a second look at the code you're producing >>>>>>>>> and realize that it's not so clean either. This extract from >>>>>>>>> populate_record_field, for example, is pretty horrid: >>>>>>>> But what if we introduce some helper macros like this: >>>>>>>> #define JsValueIsNull(jsv) \ >>>>>>>> ((jsv)->is_json ? !(jsv)->val.json.str \ >>>>>>>> : !(jsv)->val.jsonb || (jsv)->val.jsonb->type == jbvNull) >>>>>>>> #define JsValueIsString(jsv) \ >>>>>>>> ((jsv)->is_json ? (jsv)->val.json.type == JSON_TOKEN_STRING \ >>>>>>>> : (jsv)->val.jsonb && (jsv)->val.jsonb->type == jbvString) >>>>>>> Yeah, I was wondering about that too. I'm not sure that you can make >>>>>>> a reasonable set of helper macros that will fix this, but if you want >>>>>>> to try, go for it. >>>>>>> >>>>>>> BTW, just as a stylistic thing, I find "a?b:c||d" unreadable: I have >>>>>>> to go back to the manual every darn time to convince myself whether >>>>>>> that means (a?b:c)||d or a?b:(c||d). It's better not to rely on >>>>>>> the reader (... or the author) having memorized C's precedence rules >>>>>>> in quite that much detail. Extra parens help. >>>>>> Moved to CF 2017-03 as discussion is going on and more review is >>>>>> needed on the last set of patches. >>>>>> >>>>> The current patches do not apply cleanly at cccbdde: >>>>> >>>>> $ git apply ../other/0001-introduce-JsonContainerXxx-macros-v04.patch >>>>> error: patch failed: src/backend/utils/adt/jsonb_util.c:328 >>>>> error: src/backend/utils/adt/jsonb_util.c: patch does not apply >>>>> error: patch failed: src/backend/utils/adt/jsonfuncs.c:1266 >>>>> error: src/backend/utils/adt/jsonfuncs.c: patch does not apply >>>>> error: patch failed: src/include/utils/jsonb.h:218 >>>>> error: src/include/utils/jsonb.h: patch does not apply >>>>> >>>>> In addition, it appears a number of suggestions have been made by Tom >>>>> that warrant new patches. Marked "Waiting on Author". >>>> This thread has been idle for months since Tom's review. >>>> >>>> The submission has been marked "Returned with Feedback". Please feel >>>> free to resubmit to a future commitfest. >>>> >>>> >>> Please revive. I am planning to look at this later this week. >> Since that was 10 days ago - you're still planning to get this in before >> the freeze? >> > > Hoping to, other demands have intervened a bit, but I might be able to. > OK, I have been through this and I think it's basically committable. I am currently doing some cleanup, such as putting all the typedefs in one place, fixing redundant comments and adding more comments, declaring all the static functions, and minor code changes, but nothing major. I should be ready to commit tomorrow some time. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers