summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2012-02-27 13:10:40 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2012-02-27 13:14:02 +0100
commitee0cb9d05d11c23421ec5ddddd7b268eb8c5e049 (patch)
tree3ac73846cd6b5e60dfaa6a6734b2ef03d97c7342
parent44b98b588c51c976c38b08844f7e09d236518e32 (diff)
fdo#46675: expand group memberships in get*Privileges
-rw-r--r--connectivity/source/drivers/postgresql/pq_databasemetadata.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 3748098a899d..d925cb166e88 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -2071,7 +2071,8 @@ void DatabaseMetaData::init_getPrivs_stmt ()
{
rtl::OUStringBuffer sSQL(300);
sSQL.append( ASCII_STR(
- " SELECT * FROM ("
+ " SELECT dp.TABLE_CAT, dp.TABLE_SCHEM, dp.TABLE_NAME, dp.GRANTOR, pr.rolname AS GRANTEE, dp.privilege, dp.is_grantable "
+ " FROM ("
" SELECT table_catalog AS TABLE_CAT, table_schema AS TABLE_SCHEM, table_name,"
" grantor, grantee, privilege_type AS PRIVILEGE, is_grantable"
" FROM information_schema.table_privileges") );
@@ -2093,14 +2094,15 @@ void DatabaseMetaData::init_getPrivs_stmt ()
" WHERE c.relkind IN ('r', 'v') AND c.relacl IS NULL AND pg_has_role(rg.oid, c.relowner, 'USAGE')"
" AND c.relowner=ro.oid AND c.relnamespace = pn.oid") );
sSQL.append( ASCII_STR(
- " ) s"
- " WHERE table_schem LIKE ? AND table_name LIKE ? "
+ " ) dp,"
+ " (SELECT oid, rolname FROM pg_catalog.pg_roles UNION ALL VALUES (0, 'PUBLIC')) pr"
+ " WHERE table_schem LIKE ? AND table_name LIKE ? AND pg_has_role(pr.oid, dp.grantee, 'USAGE')"
" ORDER BY table_schem, table_name, privilege" ) );
m_getTablePrivs_stmt = m_origin->prepareStatement( sSQL.makeStringAndClear() );
sSQL.append( ASCII_STR(
- " SELECT * FROM ("
+ " SELECT dp.TABLE_CAT, dp.TABLE_SCHEM, dp.TABLE_NAME, dp.COLUMN_NAME, dp.GRANTOR, pr.rolname AS GRANTEE, dp.PRIVILEGE, dp.IS_GRANTABLE FROM ("
" SELECT table_catalog AS TABLE_CAT, table_schema AS TABLE_SCHEM, table_name, column_name,"
" grantor, grantee, privilege_type AS PRIVILEGE, is_grantable"
" FROM information_schema.column_privileges") );
@@ -2122,8 +2124,9 @@ void DatabaseMetaData::init_getPrivs_stmt ()
" WHERE c.relkind IN ('r', 'v') AND c.relacl IS NULL AND pg_has_role(rg.oid, c.relowner, 'USAGE')"
" AND c.relowner=ro.oid AND c.relnamespace = pn.oid AND a.attrelid = c.oid AND a.attnum > 0") );
sSQL.append( ASCII_STR(
- " ) s"
- " WHERE table_schem = ? AND table_name = ? AND column_name LIKE ? "
+ " ) dp,"
+ " (SELECT oid, rolname FROM pg_catalog.pg_roles UNION ALL VALUES (0, 'PUBLIC')) pr"
+ " WHERE table_schem = ? AND table_name = ? AND column_name LIKE ? AND pg_has_role(pr.oid, dp.grantee, 'USAGE')"
" ORDER BY column_name, privilege" ) );
m_getColumnPrivs_stmt = m_origin->prepareStatement( sSQL.makeStringAndClear() );