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 1gOogz-0006Fb-Kd for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Nov 2018 18:54:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gOogx-0005xX-IO for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Nov 2018 18:54:39 +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 ) id 1gOogx-0005x3-2L for pgsql-hackers@lists.postgresql.org; Mon, 19 Nov 2018 18:54:39 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gOogt-0003vU-BI for pgsql-hackers@postgresql.org; Mon, 19 Nov 2018 18:54:37 +0000 Received: by mail-qk1-x743.google.com with SMTP id d135so50377584qkc.12 for ; Mon, 19 Nov 2018 10:54:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=L5QMQL4QwgooAmR+Ov9OCMgiwgoPtK5Z8hCMlrF3me4=; b=UXQoJqKqIJ5TCLTk8Yzt9svynXIGqf2c2YqzUOY8bL21+UEyfQgXJoBGfnTtS4wgUh TuoDwsFi5AmS3ULCfGFTw3XyJ48ER3fFycmZjdo05CX0fIlDeXxtXvnUFo/fBGcCwUdH jbeSb8Ddrdp80OtrwJJd8lNo3ZkH7n1ROR80glcIvV05Je4moU04kxdnEycrWXOUUK+r uCSqTBpfVgj7HZZyTU7juA7YxF1ladBOiVxQnl3B5OeK4lSvlgzb5cujqE8KG7eQKsRw irThps3j+ehkj4L8dmbY9e1x6J5QFG9oFJBF/oQ3k6Ezs8bPll3E0tHZD2U9vuH2BcM6 g5uQ== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=L5QMQL4QwgooAmR+Ov9OCMgiwgoPtK5Z8hCMlrF3me4=; b=fCWueBJeAvKC0thP8iTxhb+2f4WiE8YS59yfG2mGcei83D8V93uevXzDTh2Th2edOX 3o5lQH+pdBQare/s9FHEWLexJJk8YjOIswHz6KIWW3jz+teBTXCb2zQWdg6h/IfX0rqU QMvHyFev2SOO8HPnHSY2ZFxKMVRPGxnU1wnOSsAKOi8fBZZeYV2kEuHJ0a6GUa27ei1q dw3SZyici6XZ89u49jF3W6Sl1aqPRxE8QDq89Hv7k6/1uB4+5FMphEk7IltEZCPXiCju zrP87Mn0HohwrgGzQeVth38aKvKfcTdUWmdwuef9aDvMnqolPuUY2GcCo77lLJMWUByZ +rKg== X-Gm-Message-State: AGRZ1gI5GJF3aAnZPVjFXCsKGe5+3lzYoI44J4kVeTf8gNHTuZ8y+V+2 4bNtafJRl1VQj2f8ho79o+ltDA== X-Google-Smtp-Source: AJdET5dIneSokk6dzTosct2YuHaToWzAQjMZRugtbFKu7/sEKQATQCM9qhJl1bKXkI1XX2iHIgxcjA== X-Received: by 2002:a0c:d29b:: with SMTP id q27mr22744508qvh.62.1542653674329; Mon, 19 Nov 2018 10:54:34 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id f19sm8818407qtf.1.2018.11.19.10.54.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Nov 2018 10:54:33 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 7514C4FD; Mon, 19 Nov 2018 15:54:31 -0300 (-03) Date: Mon, 19 Nov 2018 15:54:31 -0300 From: Alvaro Herrera To: Peter Eisentraut Cc: pgsql-hackers , Michael Paquier , Jaime Casanova Subject: Re: [HACKERS] generated columns Message-ID: <20181119185431.7wfp6rmxtqr2ds3p@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <79e4de23-52e3-2c45-9ba0-5f6932f590aa@2ndquadrant.com> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Disclaimer: I had never seen this patch before. I did not participate in this feature design. I did not discuss this review with the author or anybody in 2ndQuadrant. I do not have any particular affective bonds with its author. I did not receive payment nor goods in exchange for this review. I encourage others to review this patch, and all other patches in the current commitfest and all future commitfests. Now that the TupleTableSlot work has landed, the API of ExecComputeStoredGenerated is clearly inadequate. This should be adjusted to work with the slot only, and not generate a heap tuple at all -- if the calling code needs the heap tuple, have that code generate that from the slot. (Example problem: ExecConstraints runs using the slot, not the heap tuple.) The pg_dump tests verify a virtual generated column, but not a virtual stored column. It'd be good to have one for the latter. The tables in new test "generated" appear not to be dropped, which is good to test pg_upgrade as well as pg_dump; I'd add a comment that this is on purpose, lest someone else add DROP lines there later. I think some tests for logical replication would be good as well. It's unclear why you made generated columns on partitions unsupported. I'd fix the limitation if possible, but if not, at least document it. (I particularly notice that partition key is marked as unsupported in the regression test. Consider partitioning on a SERIAL column, this is clearly something that users will expect to work.) About your catalog representation question: On 2018-Oct-30, Peter Eisentraut wrote: > 1. (current implementation) New column attgenerated contains 's' for > STORED, 'v' for VIRTUAL, '\0' for nothing. atthasdef means "there is > something in pg_attrdef for this column". So a generated column would > have atthasdef = true, and attgenerated = s/v. A traditional default > would have atthasdef = true and attgenerated = '\0'. The advantage is > that this is easiest to implement and the internal representation is the > most useful and straightforward. The disadvantage is that old client > code that wants to detect whether a column has a default would need to > be changed (otherwise it would interpret a generated column as having a > default value instead). I think this is a reasonable implementation. Client code that is confused by this will obviously have to be updated, but if it isn't, the bug is not serious. I would clearly not go to the extreme trouble that #2 poses just to avoid this problem. That said, I think your "radical alternative" #3 is better. Maybe we want to avoid multiple compatibility breaks, so we'd go with 3 for pg12 instead of doing 1 now and changing it again later. Like Robert, I would use something other than '\0' anyhow. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services