Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kqLtD-0002oN-J5 for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Dec 2020 19:58:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kqLtB-0007vi-5V for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Dec 2020 19:58:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1kqLtA-0007vb-Re for pgsql-hackers@lists.postgresql.org; Fri, 18 Dec 2020 19:58:08 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1kqLt5-0004YH-Qw for pgsql-hackers@postgresql.org; Fri, 18 Dec 2020 19:58:08 +0000 Received: by mail-ed1-x52a.google.com with SMTP id dk8so3608738edb.1 for ; Fri, 18 Dec 2020 11:58:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=fK0muAhNFk08cRJYzrMgvRjIOQm0iU+1rdOjePnLuBE=; b=odIv+rl5otMZ3CyvZeWrIiAa11VF5+7NoIk4rOXJLUQMb1HTI3wrCpwDA4EU4pXGJ5 2YXM1VENG1zwrLC393k0GPafrKptXanx43cFtBbJd3QK/HF2pSiNM5jSqYWXxB2hAKsu 110KnyrWZobDV6AlvrfGI8ZP8vdbgIgDhhr4brMu51dxSaJILPRVYMAptFF5bNE1MNfq K7v/QCbklWz3Mn3Q5GRivDHhRyqgE+plfJUz4eWWTjH1jtGevQtb1NsvFpL+uhFjGZZ9 DYG1wPeki35Kb0PT/GPDZ26XvMTRHhVsGWhjg+SzSZvqAK0ukvk/27Wqvku/JAJRDcMy CuPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=fK0muAhNFk08cRJYzrMgvRjIOQm0iU+1rdOjePnLuBE=; b=YQxFFmTEaF1a+q2KTexDh75zh71z8uwmjDRErQ0vpRYNdVLW6YqzFsLQkSUy3TZUo9 sE1nM/p3GGKiLyh+MGqOJy8L/PjXWFuqkVWMHFeyGSb0mhJov9RCQVI97f7jJA4k0wME P1Scbd4j61zgjYdhvDxZQqT337/XBpjAZWq6zbeoWSe98F4F7tFRDXbA9zBKuL3CAsmr dyI7zMadncvdVXb1CwO2WcI2Ye3LGxDMHPVsU8Y295mRGq4EalvdLO0ASeTX/7xOXq4y B+gDECTSBs7NuKUqeNzXOZBQTAYCXkHq82/oZkgXSK36Va12ZIF99h9RAnMUBHOEHCq+ oTkg== X-Gm-Message-State: AOAM531hGa4BN7nECs9DIHwbTET7PAUnWxfkPKIldZVCDYLKpPhn4mW9 Z+PQkHBNIpLn0YYuqQzM54Y= X-Google-Smtp-Source: ABdhPJzN9Y4JV/8AapJDNBfc2z3a+ax5G0YbnVKJoovVqiJLiU91XGaK6Kj9/ug0c463KrvcjPUNMw== X-Received: by 2002:aa7:c543:: with SMTP id s3mr5984653edr.88.1608321483049; Fri, 18 Dec 2020 11:58:03 -0800 (PST) Received: from localhost (dslb-094-222-016-204.094.222.pools.vodafone-ip.de. [94.222.16.204]) by smtp.gmail.com with ESMTPSA id p3sm5894192ejx.0.2020.12.18.11.58.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Dec 2020 11:58:02 -0800 (PST) Date: Fri, 18 Dec 2020 20:59:25 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Tom Lane Cc: Pavel Stehule , Andres Freund , Alexander Korotkov , Justin Pryzby , David Steele , Nikita Glukhov , Alvaro Herrera , David Fetter , Thomas Munro , Oleksandr Shulgin , Robert Haas , Michael Paquier , Oleg Bartunov , Peter Eisentraut , PostgreSQL Hackers Subject: Re: [HACKERS] [PATCH] Generic type subscripting Message-ID: <20201218195925.4qj6p2kxrvkdrmur@localhost> References: <20201209183704.x5ue5rctdwmhmlmy@localhost> <3674425.1607540422@sss.pgh.pa.us> <3724341.1607551174@sss.pgh.pa.us> <20201211151957.wqlnxdqjwsd7azzd@localhost> <4110100.1607701087@sss.pgh.pa.us> <20201217182003.nrhxqqiutfwjesen@localhost> <107232.1608230957@sss.pgh.pa.us> <20201217200033.qdyjv4iimwyglnwt@localhost> <112397.1608236975@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <112397.1608236975@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Thu, Dec 17, 2020 at 03:29:35PM -0500, Tom Lane wrote: > Dmitry Dolgov <9erthalion6@gmail.com> writes: > > On Thu, Dec 17, 2020 at 01:49:17PM -0500, Tom Lane wrote: > >> We can certainly reconsider the API for the parsing hook if there's > >> really a good reason for these to be different types, but it seems > >> like that would just be encouraging poor design. > > > To be more specific, this is the current behaviour (an example from the > > tests) and it doesn't seem right: > > > =# update test_jsonb_subscript > > set test_json['a'] = 3 where id = 1; > > UPDATE 1 > > =# select jsonb_typeof(test_json->'a') > > from test_jsonb_subscript where id = 1; > > jsonb_typeof > > -------------- > > string > > > I'm rather inclined to think that the result of subscripting a > jsonb (and therefore also the required source type for assignment) > should be jsonb, not just text. In that case, something like > update ... set jsoncol['a'] = 3 > would fail, because there's no cast from integer to jsonb. You'd > have to write one of > update ... set jsoncol['a'] = '3' > update ... set jsoncol['a'] = '"3"' > to clarify how you wanted the input to be interpreted. > But that seems like a good thing, just as it is for jsonb_in. Yep, that makes sense, will go with this idea.