As far as I understand, the only problem is the CMP_post_access checks used in PackageReferenceNode::pass1. I moved them to PackageReferenceNode::parse, and it worked fine with a simple select statement. But it might not work in more complex scenarios.
I'm also concerned about the possible hard mixing of DDL and DML, but it seems the value should remain unchanged.
set autoddl on;
set autoterm on;
recreate function f RETURNS int as begin return 0; end;
commit;
execute block
RETURNS (a int)
as
begin
execute statement 'alter function f RETURNS int as begin return 4; end';
a = f();
suspend;
execute statement 'alter function f RETURNS int as begin return 8; end;';
a = f();
suspend;
end;
A
============
0
0
recreate package pkg as begin constant c1 integer = 0; end;
commit;
execute block
RETURNS (a int)
as
begin
execute statement 'alter package pkg as begin constant c1 integer = 4; end;';
a = pkg.c1;
suspend;
execute statement 'alter package pkg as begin constant c1 integer = 8; end;';
a = pkg.c1;
suspend;
end;
A
============
0
0