SQL state: 42601. Execption handling. - Mailing list pgsql-general

From Ц
Subject SQL state: 42601. Execption handling.
Date
Msg-id 1654607489.576623819@f729.i.mail.ru
Whole thread Raw
List pgsql-general
Community, is that behavior is explainable?
 
create or replace function dbo.func(result out intas $$begin result = 1end; $$ language plpgsql;

-- 1 --
do $$
declare
v_result int;
begin 
  
select p.result from dbo.func(d) p into v_result;
exception when SQLSTATE '42601' then
    raise '42601';
  
when others then 
    
raise 'others';
end;
$$

 
--Exception is handled. This is OK.
ERROR:  
others
CONTEXT:  PL/pgSQL function inline_code_block line 9 at RAISE
********** Error **********
ERROR: 
others
SQL state: P0001
Context: PL/pgSQL 
function inline_code_block line 9 at RAISE

-- 2 --
do $$
begin 
  
select p.result from dbo.func() p into v_result;
exception when SQLSTATE '42601' then
    raise '42601';
  
when others then 
    
raise 'others';
end;
$$

 
--Exception is not handled. This is the question.
ERROR:  
"v_result" is not a known variable
LINE 
3:   select p.result from dbo.func() p into v_result;
********** Error **********
ERROR: 
"v_result" is not a known variable
SQL state: 42601
Character57
 
I suppose the reason of such behavior in different steps of code parsing, but can`t find any discussions or topics in documentation.
Сould someone clarify the situation for sure?

pgsql-general by date:

Previous
From: Niels Jespersen
Date:
Subject: SV: GSSAPI authentication
Next
From: Ц
Date:
Subject: SQL state: 42601. Execption handling.