Re: Making background psql nicer to use in tap tests

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: Re: Making background psql nicer to use in tap tests
Date: 2023-03-17 22:12:58
Message-ID: a0af1738-699d-7662-9c9a-ab8b4d93eb38@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2023-03-17 Fr 14:07, Dagfinn Ilmari Mannsåker wrote:
> Andrew Dunstan<andrew(at)dunslane(dot)net> writes:
>
>> On 2023-03-17 Fr 10:08, Daniel Gustafsson wrote:
>>>> Why is $restart_before_query a package/class level value instead of
>>>> an instance value? And why can we only ever set it to 1 but not back
>>>> again? Maybe we don't want to, but it looks odd.
>>> It was mostly a POC to show what I meant with the functionality. I think there
>>> should be a way to turn it off (set it to zero) even though I doubt it will be
>>> used much.
>>
>> A common idiom is to have a composite getter/setter method for object
>> properties something like this
>>
>>
>> sub settingname
>> {
>> my ($self, $arg) = @_;
>> $self->{settingname} = $arg if defined $arg;
>> return $self->{settingname};
>> }
> Or, if undef is a valid value:
>
>
> sub settingname
> {
> my $self = shift;
> $self->[settingname} = shift if @_;
> return $self->{settingname};
> }
>

Yes, I agree that's better (modulo the bracket typo)

cheers

andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2023-03-17 22:22:54 Re: Add n_tup_newpage_upd to pg_stat table views
Previous Message Thomas Munro 2023-03-17 21:53:21 Re: File descriptors in exec'd subprocesses