diff options
| author | Stephen Frost | 2014-10-03 20:31:53 +0000 |
|---|---|---|
| committer | Stephen Frost | 2014-10-03 20:31:53 +0000 |
| commit | 78d72563ef141ddc507ddd5ae77db613a309041a (patch) | |
| tree | 0961d673236ce0e58a76d59b79aff7e1b5235fed /src/backend | |
| parent | 596857043023738099d6d16f8edbe6b7353876c0 (diff) | |
Fix CreatePolicy, pg_dump -v; psql and doc updates
Peter G pointed out that valgrind was, rightfully, complaining about
CreatePolicy() ending up copying beyond the end of the parsed policy
name. Name is a fixed-size type and we need to use namein (through
DirectFunctionCall1()) to flush out the entire array before we pass
it down to heap_form_tuple.
Michael Paquier pointed out that pg_dump --verbose was missing a
newline and FabrÃzio de Royes Mello further pointed out that the
schema was also missing from the messages, so fix those also.
Also, based on an off-list comment from Kevin, rework the psql \d
output to facilitate copy/pasting into a new CREATE or ALTER POLICY
command.
Lastly, improve the pg_policies view and update the documentation for
it, along with a few other minor doc corrections based on an off-list
discussion with Adam Brightwell.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/catalog/system_views.sql | 10 | ||||
| -rw-r--r-- | src/backend/commands/policy.c | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index da99fd63e82..a819952c75d 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -65,8 +65,9 @@ CREATE VIEW pg_user AS CREATE VIEW pg_policies AS SELECT + N.nspname AS schemaname, + C.relname AS tablename, rs.rsecpolname AS policyname, - (SELECT relname FROM pg_catalog.pg_class WHERE oid = rs.rsecrelid) AS tablename, CASE WHEN rs.rsecroles = '{0}' THEN string_to_array('public', '') @@ -78,8 +79,8 @@ CREATE VIEW pg_policies AS WHERE oid = ANY (rs.rsecroles) ORDER BY 1 ) END AS roles, - CASE WHEN rs.rseccmd IS NULL THEN 'ALL' ELSE - CASE rs.rseccmd + CASE WHEN rs.rseccmd IS NULL THEN 'ALL' ELSE + CASE rs.rseccmd WHEN 'r' THEN 'SELECT' WHEN 'a' THEN 'INSERT' WHEN 'u' THEN 'UPDATE' @@ -89,7 +90,8 @@ CREATE VIEW pg_policies AS pg_catalog.pg_get_expr(rs.rsecqual, rs.rsecrelid) AS qual, pg_catalog.pg_get_expr(rs.rsecwithcheck, rs.rsecrelid) AS with_check FROM pg_catalog.pg_rowsecurity rs - ORDER BY 1; + JOIN pg_catalog.pg_class C ON (C.oid = rs.rsecrelid) + LEFT JOIN pg_catalog.pg_namespace N ON (N.oid = C.relnamespace); CREATE VIEW pg_rules AS SELECT diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index 33bf031346f..8e6393c8c0e 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -556,7 +556,7 @@ CreatePolicy(CreatePolicyStmt *stmt) values[Anum_pg_rowsecurity_rsecrelid - 1] = ObjectIdGetDatum(table_id); values[Anum_pg_rowsecurity_rsecpolname - 1] - = CStringGetDatum(stmt->policy_name); + = DirectFunctionCall1(namein, CStringGetDatum(stmt->policy_name)); if (rseccmd) values[Anum_pg_rowsecurity_rseccmd - 1] = CharGetDatum(rseccmd); |
