Skip to content

Commit

Permalink
remove GRANTED BY on pg < 14
Browse files Browse the repository at this point in the history
  • Loading branch information
lacanoid committed Oct 31, 2024
1 parent 9221cec commit 13fa201
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version 0.29
- improvements in `ddlx_script_parts()`, better handling of extensions
- bug fixes in `ddlx_create_type_range()`, `MULTIRANGE_TYPE_NAME` support
- bug fixes in `SET COMPRESSION`
- bug fixes in `GRANTED BY`

Version 0.28
------------
Expand Down
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Build and tests:
- improve and add to tests
- improve support for non superusers (more testing)
- ✔︎ make some tests to test if what we output actually runs, test execute them
- run execute tests on regtypes, too
- make some tests which compare to output of pg_dump;
make utility for any sql file to compare the dump by pg_dump and ddlx.
Comparison should compare actual contents, not merely text.
Expand Down
33 changes: 18 additions & 15 deletions ddlx.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2034,21 +2034,24 @@ CREATE OR REPLACE FUNCTION ddlx_grants(regclass, text[] default '{}')
with
obj as (select * from ddlx_identify($1)),
a as (
select
coalesce(format(
E'GRANT %s ON %s TO %s%s%s;\n',
privilege_type,
cast($1 as text),
case grantee
when 'PUBLIC' then 'PUBLIC'
else quote_ident(grantee)
end,
case is_grantable
when 'YES' then ' WITH GRANT OPTION'
else ''
end,
' GRANTED BY '||nullif(grantor,current_role)
), '')
select format(
E'GRANT %s ON %s TO %s%s%s;\n',
privilege_type,
cast($1 as text),
case grantee
when 'PUBLIC' then 'PUBLIC'
else quote_ident(grantee)
end,
case is_grantable
when 'YES' then ' WITH GRANT OPTION'
else ''
end,
#if 14
' GRANTED BY '||nullif(grantor,current_role)
#else
null
#end
)
as ddl
FROM information_schema.table_privileges g
join obj on (true)
Expand Down

0 comments on commit 13fa201

Please sign in to comment.