Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j2EHY-0007zY-Tw for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2020 13:11:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j2EHX-0001uD-Li for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2020 13:11:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from <9erthalion6@gmail.com>) id 1j2EHW-0001u6-Vm for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2020 13:11:51 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1j2EHU-0002g0-NB for pgsql-hackers@postgresql.org; Thu, 13 Feb 2020 13:11:49 +0000 Received: by mail-wm1-x342.google.com with SMTP id p9so6178036wmc.2 for ; Thu, 13 Feb 2020 05:11:48 -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=OZucqF0vtlhLZQpA2+M94uivIIxAzW26w/KF0V5KGMQ=; b=LoSfcad9u8ZQ2jEtZqs3CpyExNAaqXsMS2qoJf2AuNKw3suShc/4rCgXCopViMedsZ pMPqwpsxlSovKSdTNMm7dZIvbUDXMitpdBU1+VOD+ARRdCN5EXOfLb2jfgYvd0nUtrYp kfvAjtr6DruA3G3pe7m30eU+iNDttnsGjW4QVQEpTRO+RvI4sPFGHxnYsWy8XQ+WGuvw 4brR0nOVWXy5yslO24JEihznLDS3JAtDsNvW3IPKX1VBJKl2zD9fsXq8Iv5MeGprMMTy zMdEP8ilKHYsApCy9rDsYrEzM86R9O7IRB57ja4zNqSBuxWsdJQQMkKz7bCZkH+snJ31 gaHg== 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=OZucqF0vtlhLZQpA2+M94uivIIxAzW26w/KF0V5KGMQ=; b=aurklpygVxyUDpuvxXnkVsk9cUm6nmVY/xhjA/z9VuUouGonwTP6lShyUeb9JGhAAT IXYFUtqua7vQox8jNeVpjLPOXARAzjObx237di6p2CRorB/UX5VkFKJtMi0/NC4c7bcq vG5gX7rxHV/1JdqvD+tAlej4kxT4p/d0kZKmiEZgOEx8fJcCcgQNd0Dc5RZ1vReC9/E4 6Vafxws461ukpyEO8SGZJhIi3dfNLb60r//UwAw7TuNqZEXLVa2FRN7Z2b5rPka2w1bP OBijQf4tUgA4n6LZ/X9Tepiw79FXhylMtRnCE+pHC2ImLdOgvSTpr+RBvAd9rstY5IJi C67A== X-Gm-Message-State: APjAAAV9KVvGNR0OvtPOqG0JkJRKKnDMm7Y+HYuoCeAeSyTW0vsUsCkp ZVGB5XR98FD41LxnVTtSpX+5MzQfxGA= X-Google-Smtp-Source: APXvYqxftznHnxqhzfEiyLEuCXmRiV43fMQgoyurnACGUpj/oLUDigpwsrURJaciT/NZCccoYOrW1A== X-Received: by 2002:a05:600c:1009:: with SMTP id c9mr5695433wmc.162.1581599507256; Thu, 13 Feb 2020 05:11:47 -0800 (PST) Received: from localhost ([185.85.220.202]) by smtp.gmail.com with ESMTPSA id r5sm2780950wrt.43.2020.02.13.05.11.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Feb 2020 05:11:46 -0800 (PST) Date: Thu, 13 Feb 2020 14:12:28 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Pavel Stehule Cc: Nikita Glukhov , Alvaro Herrera , David Fetter , Thomas Munro , Thomas Munro , Oleksandr Shulgin , Tom Lane , Robert Haas , Andres Freund , Michael Paquier , Oleg Bartunov , Peter Eisentraut , David Steele , PostgreSQL-development Subject: Re: [HACKERS] [PATCH] Generic type subscripting Message-ID: <20200213131228.i6afwfmjdod7obko@localhost> References: <20190925202205.GA23893@alvherre.pgsql> <099309f0-4b41-2c78-aac8-0835fe9a9ee7@postgrespro.ru> <20191110123208.r4kn5k34wsey5zik@localhost> <20191219142030.uc6en2ci3rx2jc4c@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Thu, Feb 13, 2020 at 10:15:14AM +0100, Pavel Stehule wrote: > > I tested last set of patches. Thanks a lot for testing! > I like patch 0006 - filling gaps by NULLs - it fixed my objections if I > remember correctly. Patch 0005 - polymorphic subscribing - I had not a > idea, what is a use case? Maybe can be good to postpone this patch. I have > not strong opinion about it, but generally is good to reduce size of > initial patch. I have nothing against a compatibility with SQL, but this > case doesn't looks too realistic for me, and can be postponed without > future compatibility issues. The idea about 0005 is mostly performance related, since this change (aside from being more pedantic with the standard) also allows to squeeze out some visible processing time improvement. But I agree that the patch series itself is too big to add something more, that's why I concider 0005/0006 mosly as interesting ideas for the future. > I miss deeper comments for > > +static Oid > +findTypeSubscriptingFunction(List *procname, Oid typeOid, bool parseFunc) > > +/* Callback function signatures --- see xsubscripting.sgml for more info. > */ > +typedef SubscriptingRef * (*SubscriptingPrepare) (bool isAssignment, > SubscriptingRef *sbsef); > + > +typedef SubscriptingRef * (*SubscriptingValidate) (bool isAssignment, > SubscriptingRef *sbsef, > +<-><--><--><--><--><--><--><--><--><--><--><--> struct ParseState > *pstate); > + > +typedef Datum (*SubscriptingFetch) (Datum source, struct > SubscriptingRefState *sbsrefstate); > + > +typedef Datum (*SubscriptingAssign) (Datum source, struct > SubscriptingRefState *sbrsefstate); > + > +typedef struct SubscriptRoutines > +{ > +<->SubscriptingPrepare><-->prepare; #### . > +<->SubscriptingValidate<-->validate; > +<->SubscriptingFetch<-><-->fetch; > +<->SubscriptingAssign<><-->assign; > + > +} SubscriptRoutines; > + > > .... > > I miss comments (what is checked here - some like - subscript have to be > int4 and number of subscripts should be less than MAXDIM) > > + > +SubscriptingRef * > +array_subscript_prepare(bool isAssignment, SubscriptingRef *sbsref) > > +SubscriptingRef * > +array_subscript_validate(bool isAssignment, SubscriptingRef *sbsref, > +<-><--><--><--><--> ParseState *pstate) > Sure, I can probably add more commentaries there. > +Datum > +array_subscript_fetch(Datum containerSource, SubscriptingRefState *sbstate) > > there is a variable "is_slice". Original code had not this variable. > Personally I think so original code was better readable without this > variable. > > so instead > > +<->if (is_slice) > +<->{ > +<-><-->for(i = 0; i < sbstate->numlower; i++) > +<-><--><-->l_index.indx[i] = DatumGetInt32(sbstate->lowerindex[i]); > +<->} > > is more readable Hm, IIRC this is actually necessary, but I'll check one more time. > I really miss a PLpgSQL support > > postgres=# do $$ > declare j jsonb = '{"a":10, "b":20}'; > begin > raise notice '%', j; > raise notice '%', j['a']; > j['a'] = '20'; > raise notice '%', j; > end; > $$; > NOTICE: {"a": 10, "b": 20} > NOTICE: 10 > ERROR: subscripted object is not an array > CONTEXT: PL/pgSQL function inline_code_block line 6 at assignment > > With PLpgSQL support it will be great patch, and really important > functionality. It can perfectly cover some gaps of plpgsql. Oh, interesting, I never though about this part. Thanks for mentioning, I'll take a look about how can we support the same for PLpgSQL. > It needs rebase, I had to fix some issues. > > ... > > regress tests fails Yep, I wasn't paying much attention recently to this patch, will post rebased and fixed version soon. At the same time I must admit, even if at the moment I can pursue two goals - either to make this feature accepted somehow, or make a longest living CF item ever - neither of those goals seems reachable.