public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pavel Stehule <[email protected]>
To: Tom Lane <[email protected]>
Cc: Michael Nolan <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Declaring a field that is also an out parameter in a function
Date: Sun, 7 Jul 2024 11:13:22 +0200
Message-ID: <CAFj8pRBZUNjmDXwByeSuE5H+vQGBDyn-AQg9-kRX4eKrAUqOCQ@mail.gmail.com> (raw)
In-Reply-To: <CAFj8pRBcwQ3CVGj7eDFezhG-dUtrsry3T9iHf0SmEnU=YXs-LQ@mail.gmail.com>
References: <CAOzAquKPXRWp38u9cURDCd4XzKCbKLhuZvH6AQjtXGW3R6-LoQ@mail.gmail.com>
<[email protected]>
<CAFj8pRBcwQ3CVGj7eDFezhG-dUtrsry3T9iHf0SmEnU=YXs-LQ@mail.gmail.com>
ne 7. 7. 2024 v 9:31 odesílatel Pavel Stehule <[email protected]>
napsal:
>
>
> ne 7. 7. 2024 v 0:14 odesílatel Tom Lane <[email protected]> napsal:
>
>> Michael Nolan <[email protected]> writes:
>> > Shouldn't declaring a field that is also an OUT parameter throw an
>> error?
>>
>> No. The DECLARE is a block nested within the function,
>> and the parameter is declared at function scope.
>> So this is a standard case of an inner declaration masking
>> an outer one.
>>
>> Possibly plpgsql_check can be set to complain about such cases,
>> but they're legal according to the language specification.
>>
>
> yes, it does
>
> (2024-07-07 09:27:14) postgres=# select * from
> plpgsql_check_function('test_function');
> ┌───────────────────────────────────────────────────────────────┐
> │ plpgsql_check_function │
> ╞═══════════════════════════════════════════════════════════════╡
> │ warning:00000:10:statement block:parameter "d3" is overlapped │
> │ Detail: Local variable overlap function parameter. │
> │ warning extra:00000:8:DECLARE:never read variable "d3" │
> │ warning extra:00000:unused parameter "$1" │
> │ warning extra:00000:unused parameter "$2" │
> │ warning extra:00000:unused parameter "$3" │
> │ warning extra:00000:unmodified OUT variable "d3" │
> └───────────────────────────────────────────────────────────────┘
> (7 rows)
>
> but looks so there are false alarms related to using an alias. It is
> interesting so I have not any report about this issue, so probably using
> aliases is not too common today.
>
I was blind, plpgsql_check is correct
Regards
Pavel
>
> Regards
>
> Pavel
>
>
>>
>> regards, tom lane
>>
>>
>>
view thread (5+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Declaring a field that is also an out parameter in a function
In-Reply-To: <CAFj8pRBZUNjmDXwByeSuE5H+vQGBDyn-AQg9-kRX4eKrAUqOCQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox