Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gCSy1-0004SX-UO for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Oct 2018 17:17:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gCSy0-0005vE-A3 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Oct 2018 17:17:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gCSy0-0005v7-39 for pgsql-hackers@lists.postgresql.org; Tue, 16 Oct 2018 17:17:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gCSxy-00024s-2b for pgsql-hackers@postgresql.org; Tue, 16 Oct 2018 17:17:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w9GHH2fG002639; Tue, 16 Oct 2018 13:17:02 -0400 From: Tom Lane To: Andres Freund cc: Robert Haas , "pgsql-hackers@postgresql.org" , Thomas Munro Subject: Re: Large writable variables In-reply-to: <20181016165003.ruxut4wbxyytuhyh@alap3.anarazel.de> References: <20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de> <20181016045051.wr35ubb6h7h3ee2b@alap3.anarazel.de> <20181016050200.c65yjz2qgxulgouv@alap3.anarazel.de> <20181016063013.kigj6e5pqx6n75y3@alap3.anarazel.de> <20181016160612.eand666kosvv32cc@alap3.anarazel.de> <20181016162621.7nf2xfsl6chc7opo@alap3.anarazel.de> <20181016165003.ruxut4wbxyytuhyh@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 16 Oct 2018 09:50:03 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2637.1539710222.1@sss.pgh.pa.us> Date: Tue, 16 Oct 2018 13:17:02 -0400 Message-ID: <2638.1539710222@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-10-16 12:41:44 -0400, Robert Haas wrote: >> In terms of a function that returns both const and non-const >> variables, it seems a bit sketchy that the caller would know what the >> function is doing in particular cases and make decisions based on it, >> but maybe that's just how life is. > I don't think it's necessary the callers doing so in most cases. E.g. in > the DestReceiver case, it'll be the choice of the testreceiver (say > intorel_receive modifying things for DestIntoRel), not the caller > choosing when to modify things. The caller / users of dest receivers > won't necessarily know. Yeah, I think the use-case is more like "this API specifies non-const pointers, but some instances can return pointers to const objects, while others return non-const objects". Changing the API to const isn't better, it just moves where you have to cast away const. regards, tom lane