From: Dmitry Dolgov <9erthalion6@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: David Steele <david@pgmasters.net>
Cc: Nikita Glukhov <n.gluhov@postgrespro.ru>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: David Fetter <david@fetter.org>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Oleg Bartunov <obartunov@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] [PATCH] Generic type subscripting
Date: Thu, 17 Dec 2020 21:00:33 +0100
Message-ID: <20201217200033.qdyjv4iimwyglnwt@localhost> (raw)
In-Reply-To: <107232.1608230957@sss.pgh.pa.us>
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>
<CAFj8pRCbH_48FfTGHczts8hTA4e0eKhcs5UwdybotoQEH_Pfcg@mail.gmail.com>
<20201211151957.wqlnxdqjwsd7azzd@localhost>
<4110100.1607701087@sss.pgh.pa.us>
<20201217182003.nrhxqqiutfwjesen@localhost>
<107232.1608230957@sss.pgh.pa.us>
> 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
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: 9erthalion6@gmail.com, tgl@sss.pgh.pa.us, pavel.stehule@gmail.com, andres@anarazel.de, aekorotkov@gmail.com, pryzby@telsasoft.com, david@pgmasters.net, n.gluhov@postgrespro.ru, alvherre@2ndquadrant.com, david@fetter.org, thomas.munro@gmail.com, oleksandr.shulgin@zalando.de, robertmhaas@gmail.com, michael.paquier@gmail.com, obartunov@gmail.com, peter.eisentraut@2ndquadrant.com
Subject: Re: [HACKERS] [PATCH] Generic type subscripting
In-Reply-To: <20201217200033.qdyjv4iimwyglnwt@localhost>
* 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