- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit330b84d
committed
pg_dump: Properly handle public schema ACLs with --clean
pg_dump has always handled the public schema in a special way when itcomes to the "--clean" option. To wit, we do not drop or recreate thepublic schema in "normal" mode, but when we are run in "--clean" modethen we do drop and recreate the public schema.When running in "--clean" mode, the public schema is dropped and thenrecreated and it is recreated with the normal schema-default privilegesof "nothing". This is unlike how the public schema starts life, whichis to have CREATE and USAGE GRANT'd to the PUBLIC role, and that is whatis recorded in pg_init_privs.Due to this, in "--clean" mode, pg_dump would mistakenly only dump outthe set of privileges required to go from the initdb-time privileges onthe public schema to whatever the current-state privileges are. If theprivileges were not changed from initdb time, then no privileges wouldbe dumped out for the public schema, but with the schema being droppedand recreated, the result was that the public schema would have no ACLson it instead of what it should have, which is the initdb-timeprivileges.Practically speaking, this meant that pg_dump with --clean mode dumpinga database where the ACLs on the public schema were not changed from thedefault would, upon restore, result in a public schema with *no*privileges GRANT'd, not matching the state of the existing database(where the initdb-time privileges would have been CREATE and USAGE tothe PUBLIC role for the public schema).To fix, adjust the query in getNamespaces() to ignore the pg_init_privsentry for the public schema when running in "--clean" mode, meaning thatthe privileges for the public schema would be dumped, correctly, as ifit was going from a newly-created schema to the current state (which is,indeed, what will happen during the restore thanks to the DROP/CREATE).Only the public schema is handled in this special way by pg_dump, noother initdb-time objects are dropped/recreated in --clean mode.Back-patch to 9.6 where the bug was introduced.Discussion:https://postgr.es/m/3534542.o3cNaKiDID%40techfox1 parent299990b commit330b84d
2 files changed
+51
-3
lines changedLines changed: 21 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4005 | 4005 |
| |
4006 | 4006 |
| |
4007 | 4007 |
| |
4008 |
| - | |
| 4008 | + | |
4009 | 4009 |
| |
4010 | 4010 |
| |
4011 | 4011 |
| |
4012 | 4012 |
| |
4013 | 4013 |
| |
4014 | 4014 |
| |
| 4015 | + | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
| 4027 | + | |
| 4028 | + | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
4015 | 4035 |
| |
4016 | 4036 |
| |
4017 | 4037 |
| |
|
Lines changed: 30 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3081 | 3081 |
| |
3082 | 3082 |
| |
3083 | 3083 |
| |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
3084 | 3112 |
| |
3085 | 3113 |
| |
3086 | 3114 |
| |
| |||
3258 | 3286 |
| |
3259 | 3287 |
| |
3260 | 3288 |
| |
3261 |
| - | |
3262 |
| - | |
3263 | 3289 |
| |
3264 | 3290 |
| |
3265 | 3291 |
| |
| |||
3271 | 3297 |
| |
3272 | 3298 |
| |
3273 | 3299 |
| |
| 3300 | + | |
| 3301 | + | |
3274 | 3302 |
| |
3275 | 3303 |
| |
3276 | 3304 |
| |
|
0 commit comments
Comments
(0)