On Thu, Mar 18, 2021 at 4:23 PM Pavel Stehule <pavel.steh...@gmail.com> wrote:
> But we don't support this feature. We are changing just a top scope's label. > So syntax "ALIAS FOR FUNCTION is not good. The user can have false hopes In this case it looks like it should go together with other labels and have << label_here >> syntax ? And we are back to the question of where to put this top scope label :) Maybe we cloud still pull in the function arguments into the outermost blocks scope, and advise users to have an extra block if they want to have same names in both ? CREATE OR REPLACE FUNCTION fx(a int, b int) RETURNS ... AS $$ << fnargs >> BEGIN << topblock >> DECLARE a int := fnargs.a * 2; b int := topblock.a + 2; BEGIN .... END; END; $$; and we could make the empty outer block optional and treat two consecutive labels as top scope label and outermost block label CREATE OR REPLACE FUNCTION fx(a int, b int) RETURNS ... AS $$ << fnargs >> << topblock >> DECLARE a int := fnargs.a * 2; b int := topblock.a + 2; BEGIN .... END; $$; But I agree that this is also not ideal. And CREATE OR REPLACE FUNCTION fx(a int, b int) WITH (TOPSCOPE_LABEL fnargs) RETURNS ... AS $$ << topblock >> DECLARE a int := fnargs.a * 2; b int := topblock.a + 2; BEGIN .... END; $$; Is even more inconsistent than #option syntax Cheers Hannu PS: > > For cleanness/orthogonality I would also prefer the blocklables to be in > DECLARE > for each block, but this train has already left :) > Though we probably could add alternative syntax ALIAS FOR BLOCK ? > > why? Is it a joke? > > you are defining a block label, and you want to in the same block redefine > some outer label? I don't think it is a good idea.