Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on PRIVS: Functions/Procedures #37

Closed
gabrielpiassetta opened this issue Mar 5, 2021 · 4 comments
Closed

Error on PRIVS: Functions/Procedures #37

gabrielpiassetta opened this issue Mar 5, 2021 · 4 comments

Comments

@gabrielpiassetta
Copy link

I'm facing this error when trying to use the clone_schema function:

ERROR:  Action: PRIVS: Functions/Procedures  Diagnostics: line=PL/pgSQL function clone_schema(text,text,boolean,boolean) line 732 at EXECUTE. 42601. syntax error at or near "DEFAULT"
CONTEXT:  PL/pgSQL function clone_schema(text,text,boolean,boolean) line 780 at RAISE

it comes from this generated query.

GRANT EXECUTE ON FUNCTION clone_schema_test_c.price_view_data (materialised_price_list_id integer, ofs integer, lim integer, filtering jsonb DEFAULT NULL::jsonb, sorting jsonb DEFAULT NULL::jsonb, flags jsonb DEFAULT NULL::jsonb) TO my_user;

which is generated by

SELECT 'GRANT ' || rp.privilege_type || ' ON ' || r.routine_type || ' ' || quote_ident(dest_schema) || '.' || rp.routine_name || ' (' || pg_get_function_arguments(p.oid) || ') TO ' || string_agg(distinct rp.grantee, ',') || ';' as func_dcl

for some reason, pg_get_function_arguments(p.oid) is generating an invalid sql?

@MichaelDBA
Copy link
Collaborator

MichaelDBA commented Mar 5, 2021

well I think it's because the prototype header for the function definition itself includes DEFAULT keywords, but the function header for dropping or doing other actions on a function/procedure will barf if DEFAULT language is used.
CREATE FUNCTION whatever(akey integer default 0)... is OK
but
DROP FUNCTION whatever(akey integer default 0) wont work, neither GRANT on it with the default keywords

Let me work on this again...

@MichaelDBA
Copy link
Collaborator

ha, finally an easy one! There is another system func that returns the args WITHOUT DEFAULTS!

This is now fixed.

@gabrielpiassetta
Copy link
Author

Great! now everything is working! thank you very much @MichaelDBA

@MichaelDBA
Copy link
Collaborator

MichaelDBA commented Mar 5, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants