How to check role of current PostgreSQL user from Qt application?

I have some application based on Qt library and using QPSQL driver. In PostreSQL defined a few user roles (e.g: admin, operator, user). My application creates a connection to postgres server under specified user. How can I check the users role?

Answers


The manual:

SELECT current_user;  -- user name of current execution context
SELECT session_user;  -- session user name

Meaning, session_user shows the role you connected with, and current_user shows the role you are currently operating with, for instance after calling SET role some_other_role;.


You can check PostgreSQL user permissions with this query:

SELECT * FROM pg_roles;

Need Your Help

Export DataTable to Excel with EPPlus

c# excel datatable export epplus

I want to export a data table to an Excel file with EPPlus. That data table has a property with int type, so I want the same format in the Excel file.

How do I get the full path to a Perl script that is executing?

perl path location

I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script $0 varies and sometimes contains the fullp...