pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>
Subject: Re: Large writable variables
Date: Tue, 16 Oct 2018 13:17:02 -0400
Message-ID: <2638.1539710222@sss.pgh.pa.us> (raw)
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>
	<CA+TgmoYbL42rJbn3-fakviMurnnwS+p=rt5iXH8ccP+gQsZdMQ@mail.gmail.com>
	<20181016160612.eand666kosvv32cc@alap3.anarazel.de>
	<CA+TgmobgXaBUyVTGGusPvOUbw+zfr2pUQ9js-8+LgFoydufUeg@mail.gmail.com>
	<20181016162621.7nf2xfsl6chc7opo@alap3.anarazel.de>
	<CA+TgmoZw-JZEJacyboSJvZs28dUNhwOOTb9KUV4CVmP3UB5Gqg@mail.gmail.com>
	<20181016165003.ruxut4wbxyytuhyh@alap3.anarazel.de>

Andres Freund <andres@anarazel.de> 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




view thread (51+ messages)  latest in thread

Message-ID: <2638.1539710222@sss.pgh.pa.us>
Permalink:  ../2638.1539710222@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2638.1539710222@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, robertmhaas@gmail.com, thomas.munro@enterprisedb.com
  Subject: Re: Large writable variables
  In-Reply-To: <2638.1539710222@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox