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 1kIuOd-000848-DL for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2020 13:56:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIuOc-0006bC-1p for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2020 13:56:22 +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 1kIuOb-0006az-Ow for pgsql-hackers@lists.postgresql.org; Thu, 17 Sep 2020 13:56:21 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1kIuOY-0003M5-Ft for pgsql-hackers@postgresql.org; Thu, 17 Sep 2020 13:56:21 +0000 Received: by mail-wr1-x443.google.com with SMTP id z4so2187229wrr.4 for ; Thu, 17 Sep 2020 06:56:17 -0700 (PDT) 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=r7axEDbGeAdY0Y129doPr14mFWz7LDrzoqT9eVOtQPY=; b=Gx04PYxDy2qcq56B0+qLKrUqLK3bqhXHlKJyFsu5i7ax6O6L7furKlBqjJmx/DsCkZ /MnNhC6CRD9GxyNYltU99KCjCNppn11U6ZvPpUrTBtdi8xbjGHFPWqo7XW9rqCkspMDg a3L2hrAF5LJyYj6itof+6KsdGHCXAKDZu4+ABotTmgUjVqHOvBqsI9b/SLs3jTHarWsq 2A6v1RYS6gj7xc1bhyiJ5WYNLhV0L9syL4qKorpgu5NoQ8lTuN46h7z5528E01cqAvnp mpkhsD03bvXkrbXMLBrjsbmhxu5mqFdPFWrQjzGEYwne1m3maRvKs/jo6YDera0jhMfw xSGQ== 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=r7axEDbGeAdY0Y129doPr14mFWz7LDrzoqT9eVOtQPY=; b=a+1foayMdPozDVIcN5QzvnvftPcRK5d87Yw/rg4YcvPX0n64RnHPEBn2t27hT4I31l EFM4inn1CH9HafLj7a2C1wZawnGG1/f0iJJCXPxt83AM/8XacTGZStG1HnkpTDUjBpct IO3CMit/pc+onbY1ZmgMrpcWXLCbtraevlVUGFIACP2weDGxI/nKsZq4SpSRVMXuDjCf zk0iimiszKQV7vzBwjUnX5FLQodeJjUT1GPqSDL3AIgcfDTR+9bWekPOEJgoZXxwc8cU /ooLpfP4KK+/GTnHUlskg0R60FnlPoPDhwGy6/a6pfMhTTWcDPiKAdAfIOpTm0Gk6GCh SvJA== X-Gm-Message-State: AOAM533YBq0qTzvICF+3kZvUOccSAQGZxSJ/Ew9W3WOOl/WUNHlRv16j tXHFKBmI8EHAsii0w1QwGE0= X-Google-Smtp-Source: ABdhPJwMcwB+gyuG6QlVOOsWyaRYiN7DSfTdqTXxH1mURlC0Do11bLxW545vuMgpu8OKmxfwJqIsVw== X-Received: by 2002:a5d:6343:: with SMTP id b3mr34463637wrw.179.1600350976958; Thu, 17 Sep 2020 06:56:16 -0700 (PDT) Received: from localhost (dslb-178-005-232-008.178.005.pools.vodafone-ip.de. [178.5.232.8]) by smtp.gmail.com with ESMTPSA id v128sm10717492wme.2.2020.09.17.06.56.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 06:56:16 -0700 (PDT) Date: Thu, 17 Sep 2020 15:56:27 +0200 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Pavel Stehule Cc: Justin Pryzby , Tom Lane , David Steele , Nikita Glukhov , Alvaro Herrera , David Fetter , Thomas Munro , Thomas Munro , Oleksandr Shulgin , Robert Haas , Andres Freund , Michael Paquier , Oleg Bartunov , Peter Eisentraut , PostgreSQL Hackers Subject: Re: [HACKERS] [PATCH] Generic type subscripting Message-ID: <20200917135627.7koag6rnhshgjlai@localhost> References: <1808585.1596224122@sss.pgh.pa.us> <20200801143334.d7d3tsb7gaezx6vq@localhost> <20200805140422.fzwnvq7qr5vsgx3b@localhost> <20200909210435.GU18552@telsasoft.com> <20200916093703.rkyl66ggdhmw5pc6@localhost> <20200917105849.vgqhutrooatdxwzq@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, Sep 17, 2020 at 02:47:54PM +0200, Pavel Stehule wrote: > > I have my concerns about the performance side of this implementation as > > well as how surprising this would be for users, but at the same time the > > patch already does something similar and the code change should not be > > that big, so why not - I can include this change into the next rebased > > version. But it still can cause some confusion as it's not going to work > > for negative indices, so > > > > update foo set a[-10] = 1; > > > > and > > > > select a[-10] from foo; > > > > can return different value from what was assigned. Otherwise, if we will > > try to fix a[-10] assignment in the same way, it will prepend the array > > and a[10] will not return the same value. > > What is semantic of negative index? It has clean semantic in C, but in > PLpgSQL? It's just a common pattern for jsonb when a negative index count from the end of an array. I believe it was like that from the very earlier implementations, although can't comment on that from the semantic point of view.