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 1kpzQr-0004Gd-Jy for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Dec 2020 19:59:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kpzQo-0001lA-4j for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Dec 2020 19:59:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1kpzQn-0001l2-Ru for pgsql-hackers@lists.postgresql.org; Thu, 17 Dec 2020 19:59:21 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1kpzQh-0001Hm-BY for pgsql-hackers@postgresql.org; Thu, 17 Dec 2020 19:59:20 +0000 Received: by mail-ed1-x52b.google.com with SMTP id h16so29899484edt.7 for ; Thu, 17 Dec 2020 11:59:15 -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=1Mpe6FaLwrh4fL+blGulW2IG4QFNAcjz7Bm7ZChymOw=; b=TBrEC7vl9kGoC4pa2r6hBwlXfNOWAzQGg0O83sBY98HEkwnsgUfcwm5H8TWxZaBqPd FHIyP+4nFVxxbWctl/b1DRIro6kTRCsQXZEQvdTy0hBG8atwMPl0d+b9/0A1xEDjULSu nZ/mAoO/VvDAVkutbyLTjsY0iQSQpCrpVo2PhWV4a7WPXjX3slXmjnxDIF3GafQn8YcN d+CtlTnkuI/7kNv/dVo1mDMXqeAsS6V/MAmUD3Tbg1HLZorYAWc91ZL5vmB1kXYaan6t ywy3rKdprGDBAvSxjFokJstRUNmAnyJcdm0ByQ+2dFAFR6xGkrG7FueJtNc4ka7DBhLd NKZw== 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=1Mpe6FaLwrh4fL+blGulW2IG4QFNAcjz7Bm7ZChymOw=; b=MO8La5OwWdQsPVJjDHQHEKiU9y4xC0JWKY8mzeCpHdfpkt5Y6mUzqaqKCLGAr//vlL TCz2lEZ76y+vvoWFfO/NV4QrvfREhlLLprI0oqLpNvYzleq5I16vnEJCYzVeEdY91tVc sDVHb2VDbx3IenK4Iix2d6TBYG0T5MRr5eD3PLVv9mpOn4IYNdDpX31X1hdELzP3PPpb TQ+ZgMVImqiInO5cfEwAjKTJyu5jfZ9GyHZATg4zGEbD07lvRI7XvxabgRVP2Kim0/TS Ld6jrXIrZd/Zmxw5pgbp4xThIW15e4v9WHwOBzLxpwZ+mie/5Ys5BngJo40UxB38hP+j DvVA== X-Gm-Message-State: AOAM530wGWxzKpcSVaUV1euhnko267qtENwcvAKj20cbMun8BhzuFXKN eIbLfdswIl0O2i7iNWPgI7c= X-Google-Smtp-Source: ABdhPJzOflcqNEtYWKQMM8GQR3CsZbhvT3PsIoG6pWppwFZth6YHtRcyUV7isSPt1QP6XsIaDGwSLg== X-Received: by 2002:a50:bf4a:: with SMTP id g10mr1005693edk.201.1608235153791; Thu, 17 Dec 2020 11:59:13 -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 op5sm4483463ejb.43.2020.12.17.11.59.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Dec 2020 11:59:13 -0800 (PST) Date: Thu, 17 Dec 2020 21:00:33 +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: <20201217200033.qdyjv4iimwyglnwt@localhost> References: <3544235.1607482944@sss.pgh.pa.us> <3635350.1607536188@sss.pgh.pa.us> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <107232.1608230957@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Thu, Dec 17, 2020 at 01:49:17PM -0500, Tom Lane wrote: > Dmitry Dolgov <9erthalion6@gmail.com> writes: > > While rebasing the jsonb patch I found out that the current subscripting > > assignment implementation in transformAssignmentIndirection always > > coerce the value to be assigned to the type which subscripting result > > suppose to have (refrestype). For arrays it's fine, since those two > > indeed must be the same, but for jsonb (and for hstore I guess too) the > > result of subscripting is always jsonb (well, text type) and the > > assigned value could be of some other type. This leads to assigning > > everything converted to text. > > So ... what's the problem with that? Seems like what you should put > in and what you should get out should be the same type. > > 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 =# update test_jsonb_subscript set test_json = jsonb_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 -------------- number