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 1lGZ6o-0006gP-9b for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Mar 2021 03:20:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lGZ6n-0001pR-78 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Mar 2021 03:20:33 +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 ) id 1lGZ6m-0001pJ-SA for pgsql-hackers@lists.postgresql.org; Mon, 01 Mar 2021 03:20:33 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lGZ6j-0000iF-Oa for pgsql-hackers@postgresql.org; Mon, 01 Mar 2021 03:20:32 +0000 Received: by mail-il1-x133.google.com with SMTP id z9so3132750iln.1 for ; Sun, 28 Feb 2021 19:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ilX+uFnzYWb9KCv09LHSSoj9U8CEUAaIk0J/vitihO0=; b=Ufv7RufFng5J+COLXiGYLrUDedH0msOzdtlzKWuj45ohoKSUiWPei68JKt5rfF88LT DJvhILlMoh+N/gZw4kX2v47X4wt25Z+hQTmZy0pxfWCtpWjK1OQY4kCKSKyxzDdqGxud Jhr0sdYZ1zprnBbfAx0Pq9mvEgfsUJaryiWfJxJrEQ5wOzxuwyXy33rtFzCSHd6FReJQ j6Fw+wpmQ/ai1l7ooDw0JidwYZbfY+MA2Ewan7PExs3P7OIu+s5y9ajpdXUO4o5lHe2q tMVjLX7zRce9PWXTQhK709zDdCQC298dJNdgFz6UJJM24IHVYdemKpOm2J1fqBpwrkAW 0QGg== 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:user-agent; bh=ilX+uFnzYWb9KCv09LHSSoj9U8CEUAaIk0J/vitihO0=; b=UweO7h3ef74+Ivba0h0AZK64BKvHFTy98EbkjiDtPfCTd/dGvJBFYLfUGg5wRAVGY8 rMETV85iTnxHVek799RN4k6cGVwgdRM/cBR/jUPBB6xtCY5PLSaZ9HfKZ48Wp5oO1jSm RltRg2DYGTpyve7V+RXxKGsDfJSVe2aBzosY9wDelc2rw1Eky0Uw2MSedp70LtRKDho+ wIW7GnUQ8+ZFU0IENsJ2p1l7jG+uu90nwUkSWH2pOl99ON/45pxAcVboa0BsBCnq8OSK yI5Ogwzksg8gNyiNEtMnK74iYzvv1u3/jJcCeMGTxGmKsaHrdis9Gis87Pcf8n2jm68S PhRQ== X-Gm-Message-State: AOAM532oT/yP5CJCfr52XzaZVGCydmFkcahx5psQw3tMMo+dLbVswweZ M9gfbxOKS7zWf72R6zjelPCN9Q== X-Google-Smtp-Source: ABdhPJyj/7/Ehc1b2lRuuRiZPI8d+Kads5N04zaJhq2lLPlGc/d0jDDjnDK0ZnWyihcEft7Qlulw1A== X-Received: by 2002:a92:3f08:: with SMTP id m8mr11565984ila.237.1614568827830; Sun, 28 Feb 2021 19:20:27 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id t7sm8555760ilj.62.2021.02.28.19.20.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Feb 2021 19:20:27 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5DF10800929; Sun, 28 Feb 2021 21:20:26 -0600 (CST) Date: Sun, 28 Feb 2021 21:20:26 -0600 From: Justin Pryzby To: Michael Paquier Cc: pgsql-hackers@postgresql.org, Jacob Champion , Heikki Linnakangas , Ashwin Agrawal , Ashutosh Sharma , Andres Freund , Robert Haas , Amit Kapila , Alvaro Herrera , Dilip Kumar Subject: Re: alter table set TABLE ACCESS METHOD Message-ID: <20210301032026.GI20769@telsasoft.com> References: <20210228222530.GD20769@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 01, 2021 at 11:16:36AM +0900, Michael Paquier wrote: > On Sun, Feb 28, 2021 at 04:25:30PM -0600, Justin Pryzby wrote: > > I called this "set TABLE access method" rather than just "set access method" > > for the reasons given on the LIKE thread: > > https://www.postgresql.org/message-id/20210119210331.GN8560@telsasoft.com > > ALTER TABLE applies to a table (or perhaps a sequence, still..), so > that sounds a bit weird to me to add again the keyword "TABLE" for > that. I don't know if you're following along the toast compression patch - Alvaro had suggested that instead of making a new catalog just for a handful of tuples for compression types, to instead store them in pg_am, with a new am_type='c'. So I proposed a patch for | CREATE TABLE .. (LIKE other INCLUDING ACCESS METHOD), but then decided that it should say INCLUDING *TABLE* ACCESS METHOD, since otherwise it was somewhat strange that it didn't include the compression access methods (which have a separate LIKE option). > > I've tested this with zedstore, but the lack of 2nd, in-core table AM limits > > testing possibilities. It also limits at least my own ability to reason about > > the AM API. > > > > For example, I was surprised to hear that toast is a concept that's > > intended to be applied to AMs other than heap. > > https://www.postgresql.org/message-id/flat/CA%2BTgmoYTuT4sRtviMLOOO%2B79VnDCpCNyy9rK6UZFb7KEAVt21w%40mail.gmail.com > > What kind of advanced testing do you have in mind? It sounds pretty > much enough to me for a basic patch to use the trick with heap2 as > your patch does. That would be enough to be sure that the rewrite > happens and that data is still around. The issue is that the toast data can be compressed, so it needs to be detoasted before pushing it to the other AM, which otherwise may not know how to decompress it. If it's not detoasted, this works with "COMPRESSION lz4" (since zedstore happens to know how to decompress it) but that's just an accident, and it fails with when using pglz. That's got to do with 2 non-core patches - when core has only heap, then I don't see how something like this can be exercized. postgres=# DROP TABLE t; CREATE TABLE t (a TEXT COMPRESSION pglz) USING heap; INSERT INTO t SELECT repeat(a::text,9999) FROM generate_series(1,99)a; ALTER TABLE t SET ACCESS METHOD zedstore; SELECT * FROM t; DROP TABLE CREATE TABLE INSERT 0 99 ALTER TABLE 2021-02-28 20:50:42.653 CST client backend[14958] psql ERROR: compressed lz4 data is corrupt 2021-02-28 20:50:42.653 CST client backend[14958] psql STATEMENT: SELECT * FROM t; -- Justin