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

How to perform a raw query using current user mapping credentials #91

Open
iosifnicolae2 opened this issue Oct 20, 2022 · 1 comment
Open

Comments

@iosifnicolae2
Copy link

SELECT clickhousedb_raw_query(
	'SELECT 1;', 
	(SELECT array_to_string(srvoptions, ' ') FROM pg_foreign_server WHERE oid=(SELECT srvid FROM pg_user_mappings WHERE usename=(SELECT current_user) LIMIT 1)) || ' 
	username=' || (SELECT split_part(umoptions[1], '=', 2) FROM pg_user_mappings WHERE usename=(SELECT current_user) LIMIT 1)||' 
	password=' || (SELECT split_part(umoptions[2], '=', 2) FROM pg_user_mappings WHERE usename=(SELECT current_user) LIMIT 1)||'
	'::text
);
@iosifnicolae2
Copy link
Author

@ildus wouldn't be good to use the second parameter of the above query as default value for clickhousedb_raw_query?

Thank you!

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

1 participant