本文介绍了如何从 Qt 应用程序检查当前 PostgreSQL 用户的角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些基于 Qt 库并使用 QPSQL 驱动程序的应用程序.
在 PostreSQL 中定义了一些用户角色(例如:管理员、操作员、用户).我的应用程序在指定用户下创建到 postgres 服务器的连接.如何检查用户角色?
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?
推荐答案
SELECT current_user; -- user name of current execution context
SELECT session_user; -- session user name
意思是,session_user
显示你连接的角色,current_user
显示你当前操作的角色,例如调用SET role some_other_role;.
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;
.
这篇关于如何从 Qt 应用程序检查当前 PostgreSQL 用户的角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!